How do I calculate object relation to each other via angle?

Get help using Construct 2

Post » Mon Sep 18, 2017 6:10 pm

Image

Hello! I have too trucks and, to calculate collisions and such, I need a reliable system to measure their angle difference. Then, If angle difference = x, I know that one car is, say, perpendicularly against second truck's side.

Is it even possible in construct, since angles go from -∞ to +∞?
I've tried to come up with my own formula, but I am a bit unsure with the results.
Thanks in advance.
B
6
S
3
Posts: 121
Reputation: 1,630

Post » Mon Sep 18, 2017 7:44 pm

you can use the bbox top and bottom of the standing truck, and measure between angle of those positions its a bad solution though to play with angles. better use distance.
B
78
S
23
G
69
Posts: 1,353
Reputation: 44,005

Post » Mon Sep 18, 2017 9:39 pm

There is the angleDiff(a,b) expression that will do that. It gives a value of 0 to 180.
If you need a signed angle result of -180 to 180 you can do angle(0,0,cos(a-b),sin(a-b))
B
94
S
33
G
114
Posts: 5,357
Reputation: 73,775


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 18 guests