How do I rotate object towards collission vector angle?

0 favourites
  • 2 posts
From the Asset Store
Simple resize and rotate events for any sprite, quick and easy event sheet that you can use for your own projects.
  • 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:

    */ "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
    [/code:2g89utzk]
    
     This solution will make playerOne object rotate towards the angle of the ground object, but not the angle of the collision vector. Any ideas?
  • Try Construct 3

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

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

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