• 3D
  • Raycasting and Cast To

I'm making a first-person game, so I'm trying to use Raycast nodes

My Player scene is arranged liked this: (irrelevant nodes omitted) -Player (Kinematic Body) ---MainCamera (Camera) -----Attack (Raycast) -----ContextSensor (Raycast)

Attack and ContextSensor are both used to detect certain collisions, (weapon attacks and object interaction prompts, respectively) and are supposed to cast in a direction relative to MainCamera, which is why I made them children of the camera.

However, when testing my game, these Raycasts clearly aren't colliding with things above or below the player when the camera is aligned so that this should be the case. I can still rotate horizontally and hit things. What seems to be happening is that for whatever reason, the Raycast nodes are correctly following the Y axis of the camera, but not the X axis. I made a separate object to test to see if cast_to is meant to be relative to the rotation of the parent node, and this is definitely meant to happen, so I'm not sure what's going on. What could possibly be causing this?

Do the raycast nodes have the same collision layer(s) as the objects on the floor/ceiling? Also, is the length of the cast_to property long enough to reach the objects? I don’t know if that’s what is causing the issue, but it might be worth a check.

One thing I have found that helps with debugging raycast issues is assigning a transparent MeshInstance node to the raycast so there is some visuals to help debug. Having a visual might help with figuring out what is going on with the raycast’s rotation. It doesn’t always help, but sometimes it makes the issue more apparent.

(Side note: Welcome to the forums)

I discovered the problem and it makes me feel silly; somehow my player's collision layers got reset, so I guess the KinematicBody was blocking the Raycasts, but only when looking up or down.