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

  • 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...

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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

  • Hi linkman2004,

    thank you very much for this clever solution and the demo script!

    It's exactly what i was looking for.

  • Hi thanks

    this is very cool..

    But How do I implement wheels on it?

    Thanks

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)