Hi there!
I'm trying to implement a system that knocks the player back when you fire a gun. I've been trying to use $Head.rotation_degrees, but that only outputs one axis. When I print it, it outputs something like (-0, 138.78, 0) instead of 3 numbers.
This is my current (messy) code:
var knockback = Vector3()
aim = $Head.rotation_degrees
print(aim)
knockback += aim.z - 175
knockback += aim.x - 175
knockback += aim.y - 175
print(knockback)
velocity.x += knockback.x
velocity.y += knockback.y
velocity.z += knockback.z
Is there some other way I could implement a knock back system or get rotation_degrees to work?
Edit: I was able to get it to work using:
var knockback = Vector3()
aim = $Head/Camera.get_camera_transform().basis
knockback += (aim.z)
knockback.normalized()
knockback = knockback * -10
velocity -= knockback
Thanks for your answers!