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
B
18
S
2
G
2
Posts: 50
Reputation: 1,230

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:
viewtopic.php?f=147&t=169741&p=1021373&hilit=collision+angle#p1021373
viewtopic.php?f=147&t=182044&p=1069066&hilit=collision+angle#p1069066
B
91
S
31
G
103
Posts: 5,235
Reputation: 67,756


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, newt and 7 guests