• Create Account

### #ActualRipiz

Posted 05 October 2012 - 01:10 PM

Looks like you should allow movement only if angle between movement direction and vector is over 90 degrees.

Depending on directions of both vectors, this may or might not be correct, hopefully I didn't mess up logic/maths either.
if(dot(normalize(movement), normalize(vector)) < 0)
position += movement;


If in #2 you mean completely opposite direction you need to compare to -1, but it's not likely to ever be ==-1, so try <-0.99 or something like that.

### #1Ripiz

Posted 05 October 2012 - 01:08 PM

Looks like you should allow movement only if angle between movement direction and vector is over 90 degrees.

Depending on directions of both vectors, this may or might not be correct, hopefully I didn't mess up logic/maths either.
if(dot(normalize(movement), normalize(vector)) < 0)
position += movement;


PARTNERS