This is the testing Godot forums! All forum posts unique to this forum will be deleted! Please use the main forums here for any posts you want to keep. All forum rules still apply.

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

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.