Interpolate Rotation value - how do i stop the actor rotating the 'wrong' way?

EwokPDEwokPD Member, PRO Posts: 35
edited September 2012 in Working with GS (Mac)
Hello,

I have an actor that i want to point where it is shooting - imagine a triangle facing upwards with bullets coming out of the top part of the triangle... and three targets above it... one off centre to the left... one straight up and one to the right.

I am using vector to angle based off start XY coords for the triangle actor... and end XY coord for the target clicked.

I am then interpolating the triangles self.rotation to the angle i have generated above (+or- a correction factor needed to align the triangle properly) - eventually each of the three corners of the triangle will be able to target independently so each corner of the triangle with have a different correction factor.

Now this almost works - for two of the actors the triangle will rotate the shortest distance and target the target properly... for the other target the triangle spins the wrong way when interpolating to the target so takes the longer route which looks silly and need fixing. I am guessing the triangle is choosing to rotate the 'wrong' way due to the maths getting confused when the angle goes from 359 back to 0 - but am not sure how to fix it - can anyone offer any ideas please.

Should i have not explained myself properly please let me know and will upload some graphics to aid in the description.

Comments

Sign In or Register to comment.