Weapon for top down? Rotating a object around another object (SOLVED)

Hello! I’m pretty new here, I’m trying to make a shoot em up top down game, although I don’t know how to make the pistel rotate around the player, I want the pistel to aim towards the mouse as well. Any help would be appreciated!!!

Add action
Click on your gun
In searchbar in center type AROUND
Now select put the object around another
In right section choose your player
In distance put how far from your player gun should be
In angle put
AngleBetweenPositions(Player.CenterX(),Player.CenterY(),CursorX(),CursorY())

And you are set

1 Like

Its not working? These are my events.


Whenever I start rotating my mouse left it begins glitching.

I deleted a line from my last attempt but it didn’t do anything? Here it is now:

What do you mean by glitching?

1 Like

Like it starts jittering and getting out of control.

Sometimes just straight up flips the sprite.

As in the position changes rapidly, or the rotation goes haywire?

1 Like

Rotation.

Are you using a touch device?

1 Like

No, I’m not. I’m on PC.

Do you have multiple player obejcts on the scene?

1 Like

Yes.

The issue is GDevelop doesn’t know which player to use for the co-ordinates.

Ideally you should have only 1 player object, and any other instances should be of a duplicate object of player object.

Its still broken… I tried debug, Only one player there.


The events have not changed.

So you only have 1 player object on the scene, and don’t create a new player object at all?

If you run preview in debug mode, then you can see how many instances of player object are in the scene.

1 Like

Have the events changed? Is there anywhere else where the gun (or player) is being repositioned?

1 Like

2024-04-28_10_05_k14aMQY3Du_GDevelopRed

I say it works perfectly fine

So screenshot to of your events and link to game preview plz

1 Like

I used another method. Instead the sprite is just in the middle of the and doesn’t rotate around him, Its fine I guess. Sorry I wasn’t able to reply at the time of when you were talking. My account was made that day, so I reached my maximum amount of replies.