0 votes

So in my game vertical vs horizontal has some minor differences. In vertical combat the melee strikes have a wider range. In horizontal the range is longer.
So I need a wider detection range in vertical movement for player detection. Will increasing the raycast scale be enough for horizontal movement?

Godot version 3.4.4
in Engine by (202 points)

1 Answer

+1 vote
Best answer

Raycasts have no thickness. It's a test for collisions on a line from vector A to vector B (from the raycast's origin to the cast_to vector).

You haven't shared your code but probably you just need to normalise the cast_to vectors and then multiply it by a scalar.

Something like this: cast_to(Vector3(1, 2, 3).normalized() * ray_length) That'll preserve the direction and allow you to control the length.

by (2,087 points)
selected by

Thank you. This really helps me out.

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 Frequently asked questions and 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 [email protected] with your username.