How do I set the speed when teleported (with physics) to the angle of an object?

0 favourites
  • 3 posts
From the Asset Store
*********** Fidget popper tile sets **************
  • Hello everyone! Again, I have physics on top of Platformer, so that the player (a circle) will rotate when it moves. I have portals, and use the physics teleport to keep the momentum, but when it travels through, I want it to set the movement that happened with the physics to be put towards the angle of the portal, for example if the player goes through portal1 falling at a high speed, and portal2 is pointing up, they will come out of portal2 going up, the angle that portal2 is facing. Does anyone have any ideas? Below is my portal logic FYI:

    + player: On collision with portal1

    + System: [X] Is portaling

    + portal1: Is animation "Idle" playing

    -> player: Teleport Physics to (portal2.X, portal2.Y)

    -> System: Set portaling to True

    + player: On collision with portal2

    + System: [X] Is portaling

    + portal2: Is animation "Idle" playing

    -> player: Teleport Physics to (portal1.X, portal1.Y)

    -> System: Set portaling to True

    + player: [X] Is overlapping portal2

    + player: [X] Is overlapping portal1

    + System: Is portaling

    -> System: Set portaling to False

    Does anyone have any ideas? Thanks.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can save object velocity in a variable using this expression:

    set v to distance(0, 0, Obj.Physics.VelocityX, Obj.Physics.VelocityY)

    And restore it after teleporting with "Set velocity" action:

    Set velocity X to v*cos(teleportAngle)

    Set velocity Y to v*sin(teleportAngle)

  • Thanks a lot! Will try!

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