Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Sir_Skurpsalot |
I’m working on part of a script for my player in a 3d fps that is supposed to move the camera smoothly from a default position to an aiming position behind the gun upon pressing the aim button. The aiming position is a spatial node called GunCam that is a child in a pistol scene that is instanced and made of a child of the StrongHand bone attachment node on the player. The problem is when I press the aim button the camera seems to go the position that the node is in in the pistol scene (ie, on the floor), not to where it is in the current scene.
func _physics_process(delta):
if aiming == true:
gunCam = $Model/Armature/Skeleton/StrongHand/Model/GunCam
end = gunCam.get_translation()
else:
end = camAttachment.get_translation()
var camPos = camera1.get_translation()
var start = camPos
var lerpPos = start.linear_interpolate(end, delta * 20)
camPos = lerpPos
camera1.set_translation(camPos)