Skip to content

diklor/spring

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

spring

3d spring, awesome for recoil

Create

var recoil_spring := Spring.new(8, 3, 2, 8)   # mass, force, damping, speed

Shove

func recoil() -> void:
   var y := 8.0
   var x := 1.0

   recoil_spring.shove(Vector3(x, y, 0))

Get / Update

func _process(delta: float) -> void:
  var recoil_vector: Vector3 = recoil_spring.update(delta) / 100.0

   cam.rotation = mouse_drag + recoil_vector

Mouse Drag

func _input(event: InputEvent) -> void:
   if ((event is InputEventScreenDrag) or (event is InputEventMouseMotion)):
      mouse_drag.x  = -event.relative.y * SENSITIVITY
      mouse_drag.y  = -event.relative.x * SENSITIVITY

  elif event.is_action_pressed('fire'): # ADD FIRE ACTION IN INPUTMAP
      recoil()

About

3d spring. awesome for recoil

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published