0 votes

I have a script where I lerp the camera from one position to another on a character scene. If I use any position that is a part of the character, it works fine. If I use a position on a gun scene that is instanced and made a child of the character's hand, the camera basically goes to the ground. What gives?

func _physics_process(delta):
    var end

    if aiming == true:
        var weapon = strongHand.get_child(0)
        var weaponSkeleton = weapon.get_node("Armature/Skeleton")
        var gunCam = weaponSkeleton.get_bone_pose(weaponSkeleton.find_bone("GunCam"))
        end = gunCam.origin
    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)
in Engine by (93 points)

You might want to try using global coords for your case.
e.g. camattachment.get_global_transform.origin to get global coords of an object and e.g. camattachment.set_global_translate(vector) to set global transform origin.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.