Bullets and Gun Point Problem [SOLVED]

Hi! I’m making a Top-Down shooter game and my problem is that the bullet direction is not in the center of the cursor.
I already know the reason why this is happening.

It’s because the origin and center is different from the bulletplace. The rotation of the gun uses the center of the gun so when the bullets where fired, the bullets will follow the angle of the center of the gun instead of the bulletplace. I tried to put the center and origin in the bulletplace as well and it works! But the problem is the rotation of the gun will be awkward since the center of the rotation will be in the mouth of the gun. I already tried the 2 Gdevelop templates with Top-down shooter on it and has the similar problem with mine.

How are you firing the bullets? Can you give a screen shot of those events?

1 Like

Here it is:

I already tried many options like adding an object that follows cursor then add point at the center. I also use the cursorX() and Y() as well. The problem is the gun has different point where the bullet spawn and where it rotates. All of the forces that will use to the bullet will always consider the center point of the gun instead of the bulletplace. I already tried to put the center of the point to the bulletplace point and it will work fine. But when I do that, the gun will now rotate awkwardly since the center of the gun is in the mouth of the gun. So in this scenario, I have to choose whether I want make the bullet be in the right position when fired, or my gun will rotate correctly.

I’m not sure I fully understand the problem, but maybe using this as your force’s angle can help you: AngleBetweenPositions(Pistol.CenterX(), Pistol.CenterY(), Pistol.PointX("BulletPlace"), Pistol.PointY("BulletPlace"))

1 Like

If you are aiming at the mouse position, then you need to use an amended version of @arthuro555’s suggestion :

AngleBetweenPositions(Pistol.PointX("BulletPlace"), Pistol.PointY("BulletPlace"), MouseX(), MouseY())


It works! Thanks @MrMen and @arthuro555 !

1 Like