Raycast Issue

I have a small Issue with my raycast script. Here it is:

public override void OnUpdate()
    {
        RayCastHit hit;
        Physics.RayCast(Actor.Position, Vector3.Right, out hit);
        DebugDraw.DrawLine(Actor.Position, hit.Point, Color.Green);
        
    }

It creates a ray to the right from the actor it’s attached to. But instead it the line goes straight to (0, 0, 0).

Did the ray hit something in your scene?
RaycastHit is valid only when the ray hits something.

I can surround it with boxcolliders, but it will always go to the 0-point. Even through the floor.

try Actor.Transform.Right instead of vector3.

1 Like