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

asked Jul 3, 2018 in Engine by websterek (227 points)
edited Jul 3, 2018 by websterek

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 ;-)

answered Jul 4, 2018 by websterek (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.