0 votes

Hi, I'm trying to perform a Raycast from the camera to the world using a RayCast object. This error comes up when I run ForceRaycastUpdate()


So, how do I make the RayCast work properly? Here's my failed attempt (C#):

Vector3 rayOrigin = camera.ProjectRayOrigin(GetViewport().GetMousePosition()) 
    + camera.ProjectRayNormal(GetViewport().GetMousePosition());
Vector3 rayCastTo = camera.Transform.Xform(Vector3.Forward);
RayCast r = new RayCast();
r.Translation = rayOrigin;
Vector3 projPos = r.GetCollisionPoint();

If I remove the ForceRaycastUpdate() part, then it always returns (0, 0, 0)

in Engine by (103 points)

I think you just missed adding it as a child of another node, before using it.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.