Skip to content

Latest commit

 

History

History
34 lines (25 loc) · 2.26 KB

README.md

File metadata and controls

34 lines (25 loc) · 2.26 KB

Single Script for Gun Sway in Godot

Licence

How to Use

  • Create a Spatial node, move it to where your hand should be
  • Place your Gun Model as a child of the Spatial
  • Give the Spatial node the Gun Sway script
  • (Optional) for rolling motion when moving left or right, set input_direction to the direction of the joystick or keyboard input

Parameters

  • LIMITS controls how far the gun swings on each axis (see below)
  • return_speed controls how quickly it interpolates back to the rest position
  • sway_speed controls how quickly the gun sways when your mouse moves
  • mouse_sensitivity controls how sensitive mouse inputs are

How Damping works

Everytime the gun is to be rotated, the rotation amount is diminshed by the following graph: image The effect of the sway decreases as the gun swings outwards further so that it converges to a maximum limit

This is where the following export variable is used:

export(Vector3) var LIMITS := Vector3(1.0, 1.0, 1.0)

Each value of LIMITS controls how much the Gun Sways on each axis.

Note that LIMITS.z actually controls the roll of the gun when moving. Rolling only works if you pass a value to input_direction

Support Me

YouTube Itch.io Reddit Twitter Godot Engine

If you like my stuff, consider a sub to my channel?