How can I make aiming with a raycast more forgiving?

4.4.1

I’m making an FPS with a grappling hook mechanic. The grappling hook uses a raycast and checks if its colliding with anything and pulls the player to that point. The problem is that its really hard to aim if you’re going a little fast. How would I check for a point near where I’m aiming and make that the point my player grapples to, even if the ray doesn’t touch it?

Just throwing an idea out, try to give the grapple point an area node with a “forgiving sized” collision shape. You have to configure your raycast to be able to interact with areas in the inspector window.

       Var collider = raycast.get_collider()
        If collider is Area#(2D/3D) whichever...
          #collider.grapple_and_swing()
1 Like

I’ve thought about doing this, but would it it cause performance issues if i had a lot of grapple points in a scene?

Only one way to know that. Make it and run the profiler on your target hardware. No use in guessing.

Physics engines are well optimized nowadays. The cheap broadphase detection can efficiently handle a large number of colliders.

1 Like

You can use a ShapeCast with a sphere, make sure you have a specific collision layer/mask for it to interact with only the objects you want.

2 Likes