Weapon sway/kick back in 2d games

noobidoonoobidoo Posts: 1Member
edited August 2019 in 2D

Im working on a top down shooter where im trying to make the aim not directly connected to mouse position, this is so that i can have gun sway and also implement "kickback" for the guns.
So the mouse position is only where you have an intention to aim.

The problem is i have not faund a good way to implement this.
I tried to have the reticle as a rigid2d node and trying to manipulate it with 4 dampeningsprings, that results in it circeling around the mouse if i flick it.
Also tried to use physics engine to controll it but just ended up with it circling the mouse I a orbit.

Now i have a "weapon" that i rotate around the player with _integrate_forces function and use that to display where the shot is going to land.
This approach works the best but I still can't figure out a good algorithm for dampening the swing in a natural manor once close to the mouse angle.

If you think about how you aim girl you are more lose and move quicker if target is further away and tense up as you get close to do finer adjustments.

So I'm looking for some good ideas on what to try next or ideas for the rotation algorithm.

Tags :

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file