How do I orbit one object around another based on cursor?

0 favourites
  • 3 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Alright, so I have a concept I put together in GameMaker Studio that I want to replicate in Construct2. This is for a topdown perspective where I want the character to "rotate" to face a direction (in this case the mouse, but eventually other things as well.)

    The way I want to do this is NOT using static images I either rotate or replace with different angles, but rather a group of objects that are pinned to a player object and "orbit" the player based on cursor position (they also have to update Z-Order as well).

    To better illustrate this, here are some screenshots from the GameMaker project.

    As you can see here the robot is facing down and to the left.

    And here he is facing up and to the right.

    These are not animations nor is anything rotated, just static images that I have drawn based on a lengthdir_x value from a point on the robots body, and then shuffled their Z-Order (depth) to give silky smooth rotations when you move the mouse around.

    A different game example of this would be the wand in Sorcerobe that orbits the player in this same way:

    Subscribe to Construct videos now

    What would be the best way to replicate this behavior in Construct2?

    EDIT: Shoot, I almost forgot, these are not orbiting based on a perfect circle, but rather an ellipse that is shorter than it is wide, which is another property I would like to keep as it helps a great deal with the illusion of depth.

  • player.x+ cos(angle(player.x,player.y,mousex,mousey))*distance from player*2

    player.y+ sin(angle(player.x,player.y,mousex,mousey))*distance from player

    Set instance variable myang to angle(player.x,player.y,mousex,mousey)

    myang is between 0, and 180, box send to front

    -else box send to back

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That's very similar to what I had made in Game Maker, but I was hoping that there was maybe a behavior function or something to do it for me instead. In any case, thank you, I'll do it that way again.

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