How do I rotate object towards collission vector angle?

Get help using Construct 2

Post » Tue Oct 25, 2016 11:50 am

Hi Everyone,

After working with Construct 2 for a while I can gladly say that I am very comfortable with the engine. I have one problem though which I can't find a solution for. I am making a 2D platformer and would like to rotate the player object in the same angle as the ground. Unfortunately not the same angle as the ground object, rather the same angle as the colliding vector of the object's collision map.

Is this even possible? I currently use:

Code: Select all
*/ "playerOne" is the graphics object pinned to the "playerCollision", ground is the ground-object with the collision vector map. */

ground > On Collision with playerCollision = Set groundSurfaceAngle to ground.angle
System > Every Tick && playerCollision > Platform is on floor = playerOne rotate 1.5 degrees towards groundSurfaceAngle
Else = playerOne > Rotate 3 degrees toward 0

This solution will make playerOne object rotate towards the angle of the ground object, but not the angle of the collision vector. Any ideas?
Currently working on "Unsung" - an open world platform adventure for PC and Consoles. follow me on Instagram :D
Posts: 54
Reputation: 1,310

Post » Tue Oct 25, 2016 5:33 pm

Solutions include using:
* The chipmunk physics behavior. This has expressions to get the collision vector (or normal).
* The raycasting plugin. It doesn't give the collision vector between two shapes but you can use some rays to calculate it.
* Here are a few other ideas I've used to calculate the collision vector:
Posts: 5,489
Reputation: 81,541

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 19 guests