Set angle to physics angle of motion.

Get help using Construct 2

Post » Mon Jun 09, 2014 3:00 am

Hi there. So I was wondering about this for a while, how do I set the angle of an object to it's angle of motion?
I have the feeling that it would be:
tan(a) = y/x
∴ tan(velY/velX)^(-1) = a
But that doesn't seem to work very well at all, possibly due to being negative or positive, I'm not sure. There's also the x ≠ 0 problem. I would think then that it would be tan(abs(velY)/(abs(velX) + 0.0001)) = a or something but I'm hesitant to try that one out.

I'd rather not learn how to deal with vector, but if it comes to that, oh well.
ImageImage

Take a look at my itch.io games
B
45
S
14
G
3
Posts: 167
Reputation: 5,204

Post » Mon Jun 09, 2014 5:55 am

I think the expression you wanted to do was:
atan(velY/velX) = a

But it will have issues with pos/neg in some quadrants, but fortunately you can just do this:
angle(0,0,velX,velY)
B
95
S
33
G
128
Posts: 5,491
Reputation: 81,570

Post » Mon Jun 09, 2014 7:19 am

Thanks so much! I'm not entirely sure how, but it works, and it's awesome.
ImageImage

Take a look at my itch.io games
B
45
S
14
G
3
Posts: 167
Reputation: 5,204


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 25 guests