#How do i make a dash with the direction of this ray?

1 messages · Page 1 of 1 (latest)

slim moon
#

I am trying to implement a "dash" mechanic and i am a little confused on how to make the direction of velocity boost be the same direction of this raycast (for example).

dark stump
#

Just get the direction of the ray and rotate it.

direction = direction.rotated(global_rotation)

dark stump
# slim moon uhh...

It has to be called on a Vector2. I imagine you want the raycast's target_position

slim moon
#

I don't think i understood...

dark stump
#

rotated() is a function of Vector2s

#

It gets you a rotated version of it

slim moon
#

Oh, ok

dark stump
#

Example:
Vector2.RIGHT.rotated(PI/2)
This gets you a vector rotated 90 degrees, which would mean pointing down due to starting pointing to the right

slim moon
#

Wait, where do i put the target position here?

slim moon
dark stump
#

Your code may be fetching the exact same raycast each time.

Make sure to not use node paths.

dark stump
#

Groups, autoloads, some sort of controller to handle references.
Node paths are only suitable for prototyping or one-and-done scenes.

slim moon
#

I see...