0 votes

I was just finishing work for today and for some reason this appeared to me, i really don't know why, here's the code:

onready var sensorFrontRight = get_node("RayCasts/RayCastFrontRight")

    if sensorFrontRight.cast_to(0, 0, sensorFrontLength) && reversing != true:
        if sensorFrontRight.is_colliding():
            avoiding = true
            avoidMultiplier -= 1.0

the node is a RayCast and on the documentation it's says i can use the method cast_to but at the same time it isn't working, what am i missing here?

in Engine by (84 points)

1 Answer

+1 vote
Best answer

Hi,
cast_to is a property not a method ... so

sensorFrontRight.cast_to = Vector3(0, 0, sensorFrontLength)

and you have to call forceraycastupdate( ) for immediate response

sensorFrontRight.cast_to = Vector3(0, 0, sensorFrontLength)
sensorFrontRight.force_raycast_update( ) 
by (2,470 points)
selected by

oh, that makes sense, thanks!

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.