Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends CharacterBody3D
- const BOB_FREQ = 1.5
- const BOB_AMP = 0.04
- var t_bob = 0.0
- func _process(delta):
- t_bob += delta * velocity.length() * float(is_on_floor())
- camera.transform.origin = headbob(t_bob)
- func headbob(time) -> Vector3:
- var pos = Vector3.ZERO
- pos.y = sin(time * BOB_FREQ) * BOB_AMP
- pos.x = cos(time * BOB_FREQ / 2) * BOB_AMP
- return pos
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement