0 votes

It's slightly hard to explain what I'm looking for. But in general I need to find offset of rotation on one axis between 90 degrees angles. I need this to slightly rotate RayCast when the parent is on the curve (to better detect objects or obstacles on the curved route).

I've made this silly animation to explain it better :D
enter link description here

And here is screen of example route with raycast and red arrow showing vector of movement:
enter image description here

The best for me will be getting this value between -1 and 1:
like this:

rotation 00 deg = 0
rotation 45 deg = 1
rotation 90 deg = 0
rotation 135 deg = 1
rotation 180 deg = 0
and so on...

rotation 00 deg = 0
rotation -45 deg = -1
rotation -90 deg = 0

in Engine by (227 points)
edited by

So in general right value I can get using sin(deg*2) but only when rotation in in one direction (for example from 0 degree to 90) but in oposit direction (when rotation is still above 0 degree) it still returns the same value. How can i detect direction of rotation (clockwise or opposite)?

1 Answer

0 votes
Best answer

I've got this!

So I have use sin function with angle devided by 2 and (all) in abs() function to keep it above zero. Then returned value I'm multiplaying by rotation (before transform) - rotation (after transform) what's gives me correct plus/minus value.

It's simpler than I thought ;-)

by (227 points)
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.