How do I "set angle of an object to the collision polygon...

Get help using Construct 2

Post » Sat Mar 21, 2015 2:55 pm

Hi - i need a hint how to set the angle of an object to the collision polygons of an other object (like a physics object would do) but not using physics.

Like a car driving a hilly road...

Image
Image Image Image
B
43
S
22
G
15
Posts: 383
Reputation: 12,262

Post » Sat Mar 21, 2015 5:21 pm

Since you can't get the angle of lines making up collision polygons, you'll have to manually find it, as I've demonstrated in the included example.

Essentially, it finds the contact points for the bottom-left and bottom-right corners of the vehicle, then gets the angle from the X-axis to the line formed by those points. You'll want to pay close attention to the origin and image point locations of the vehicle. It would be reasonably trivial to adjust the positions of these -- requires some small adjustments to vehicle and detector positioning -- but as it is, this should provide the most accurate fitting to the road.

Note: The example has no terminating condition in the case that you drive off the edge and the detector can't find the ground, so be mindful of that.

EDIT: Attachment not working, here's a link -> Normal detection example
Moderator
B
113
S
41
G
20
Posts: 1,586
Reputation: 19,126

Post » Sun Mar 22, 2015 7:26 am

Hi @linkman2004,

thank you very much for this clever solution and the demo script!
It's exactly what i was looking for.
Image Image Image
B
43
S
22
G
15
Posts: 383
Reputation: 12,262

Post » Tue Mar 24, 2015 11:21 am

Hi thanks
this is very cool..
But How do I implement wheels on it?
Thanks
B
6
S
1
Posts: 55
Reputation: 545


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 19 guests