Top-Down Shooter aiming issue

Hi guys,
I’m working on a top-down shooter, and I ran into a problem. I use this player character for my game:

As you can see, the character holds his weapons on his right side. That means if I use centre mass as origin, the bullet will not hit the crosshair, but rather a few pixels right of it.

I want the player to turn like the following:

(the red dot is the origin).

Despite the crosshair always having the same angle to the origin, the player should turn according to the distance of the crosshair, so the gun aims properly.

Any ideas how to achieve that in GDevelop?

:wave:
You can do that:

1 Like

I found a little bit different solution with small bug - when I move the cursor too close to the player character, then he starts spining.

I’ll try yours method tomorrow. Thx! :slight_smile:

So don’t use the centre of mass. What’s stopping you from adding a point on the sprite that’ on the tip of the gun, and use that instead :

@MrMen
If the player rotates around the gun, it’ll look weird.

@BeF1990 My solution has the same issue, you need to set up a safety net, disable the events if crosshair is in collision with player, or too close.

I’m not suggesting rotating round the gun because, yes, that would look weird. I’m suggesting just using that to place the bullet and firing it straight out from there, and not worry so much about rotating the player.

I think it’d look weird if the player rotates when the enemy is moving in closer in a straight line. Real life behaviour is to move the arm/hand/gun to point at the target, and not swivel you body round while keeping your arm at a fixed angle to your body.

Well, if you aim with one eye, rotate the firearm and your shoulders and eye don’t follow, your targeting will be off, and the recoil may be harsh, but we’re sidetracking.
Either way, it seems there’ll be no ideal solution here unless the head is a separate sprite to follow the crosshair too.

1 Like

I use separate head in my game already and I think I found good solution, but I have to implement it.

I want to use separate body parts like arms, forearms, hands and guns for aiming animation. It will be much more complex, but I think the results are worth this additional work.

OK, finally I found a good solution for my problem. Here you have a simple demo to see how it works:

I’ll improve the logic and cleaning up the code, and after that I’ll share my project.

3 Likes