0 votes

Hello, i'm working on a IA for a enemy, and i have a problem that blows my mind with raycasts.

For some reason, my RayCast isn't colliding with anything, i have tried with both bodys and areas checked and it doesn't collide.

Yes, i'm aware that RayCast info is only updated per physics frame, i'm forcing the raycast's update when needed. This is my code.

        Vector3 rotation = this.LeftRay.Rotation;
        Vector3 castto= this.LeftRay.CastTo;
        this.LeftRay.CastTo = new Vector3(position.x,position.y,position.z+this.LeftRay.Translation.z);
        this.LeftRay.Rotation = new Vector3(0,0,0);

            toreturn = true;
        this.LeftRay.CastTo = castto;
        this.LeftRay.Rotation = rotation;

This is code for a collision checker, it checks if there's a collision between the enemy and a given position, LeftRay is the Ray's node, and position is the given position, in Vector3.

I'm using c# but i think is very easy to translate to GDScript if you aren't familiar with c#.

Thanks! Sorry for my bad english.

edit: i'm actually using godot 3.2.3 mono, not 3.3.3 mono.

Godot version Godot 3.2.3 mono
in Engine by (22 points)
edited by

raycast "Enabled" == true ??
sometimes we forget to do it "true" that's why i asked

Yes, "Enabled" is checked, i checked that like 10 times

Mabey its the collision layers/masks?

Idk, i don't touched the collision layers, i think that isn't the problem. I will later try to update the project to a newer version of the engine but i don't think that's the problem.

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.