Step-by-step rotation of the L-shaped platform around its axis

0 favourites
  • 9 posts
From the Asset Store
Glow Creatures
$1.50 USD
50% off
5 glow creatures with size, shape and color variations.
  • On the one hand, the question is simple, but on the other, it is not. How do I make the platform move around its axis? The game is viewed from above, the player can move through the cells in 4 directions, therefore, when he rests against an L-shaped platform, it must rotate 90 degrees. At the same time, it should not turn if the player rests on certain sides. I hope I was able to explain what I want to do, here is a picture for clarity :)

  • You can define an image point (or set origin point) on the shape sprite at the yellow dot:

    And then compare two angles: player movement angle, and the angle between the player and the yellow dot.

    If angle1=angle2, then rotation is not required.

    If angle2 is clockwise from angle1, rotate 90 degrees.

    If angle2 is counterclockwise from angle1, rotate 90 degrees.

    .

    You can add another condition "the difference is over 5 degrees", to avoid rounding errors.

  • You can define an image point (or set origin point) on the shape sprite at the yellow dot:

    And then compare two angles: player movement angle, and the angle between the player and the yellow dot.

    If angle1=angle2, then rotation is not required.

    If angle2 is clockwise from angle1, rotate 90 degrees.

    If angle2 is counterclockwise from angle1, rotate 90 degrees.

    .

    You can add another condition "the difference is over 5 degrees", to avoid rounding errors.

    Thanks for the answer, I kind of understood your idea, but I didn't understand at all how to implement it. If you have the opportunity to make a small source code, I would be very grateful.

  • I don't know which behavior you are using, so it's up to you to determine the moving angle of the player. In 8direction behavior it's Self.8Direction.MovingAngle. Or you can check which button was pressed:

    If Down key is pressed : Set angle1 to 90

    If Left key is pressed : Set angle1 to 180 etc.

    .

    angle2, the angle between the player and the yellow imagepoint:

    angle(Player.x, Player.y, Shape.ImagepointX("tag"), Shape.ImagepointY("tag"))

    And to compare them use System conditions - "Is Between angles", "Is within angle", "Is clockwise".

  • So it is like trap door? The turn based on torsion & center mass shifting correct?

  • So it is like trap door? The turn based on torsion & center mass shifting correct?

    Something like that. I use the player's "cell movement" behavior, and when I touch a piece, it's like I'm pushing it, and it turns 90 degrees

  • Here try it: dropbox.com/scl/fi/h943c9x4no574uy540alo/swivel_plank.capx

    I am thinking about optimizing the code later but that's it for now.

  • If it were seen from above the 8 directions behavior would make more sense, but from the example it looks more like a platformer seen from the side

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If it were seen from above the 8 directions behavior would make more sense, but from the example it looks more like a platformer seen from the side

    Yes, this is a top view.

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