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: 137
Reputation: 1,662

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
79
S
24
G
69
Posts: 1,356
Reputation: 44,125

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
95
S
34
G
128
Posts: 5,494
Reputation: 81,676


Return to How do I....?

Who is online

Users browsing this forum: jhjconstruct and 8 guests