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

Get help using Construct 2

Post » Tue Apr 18, 2017 5:45 pm

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:

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.
Posts: 14
Reputation: 353

Post » Tue Apr 18, 2017 10:36 pm

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
Posts: 8,723
Reputation: 128,814

Post » Tue Apr 18, 2017 11:30 pm

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.
Posts: 14
Reputation: 353

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 10 guests