Guest User

Suspension

a guest
Mar 26th, 2019
82
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var rb : RigidBody
  2. var stiffness = 150
  3.  
  4. func _ready():
  5. rb = get_parent()
  6. pass
  7.  
  8.  
  9.  
  10. func _physics_process(delta):
  11. if is_colliding():
  12. var collisionPoint : Vector3 = get_collision_point()
  13. var distance = (collisionPoint - global_transform.origin).project(global_transform.basis.y).length()
  14. var springOffset = 1 - distance
  15. rb.add_force(global_transform.basis.y * stiffness * springOffset, translation)
  16. pass
RAW Paste Data