+1 vote

I used the following code to make the arms in the model rotate along with the camera. The arms holding the gun end up continuing to rotate past the head. I've also tried clamping it to the camera's rotation, using inverse kinematics and making the arms children of the camera and just rotating the camera. IK won't work because I couldn't use better collada as it seems to be broken, so I'm just using a GLTF model. This makes it so that the bones in the mesh are just spatial nodes, and I made the mesh out of modular pieces and didn't combine them, so each ones has either a child spatial or a mesh for that body part or both. Different kinds of clamping either break the camera's clamp or somehow rotate it on the Y axis. Here's my code:

func _input(event):
if event is InputEventMouseMotion:
    rotate_y(deg2rad(-event.relative.x * mouse_sensitivity))
    head.rotate_x(deg2rad(-event.relative.y * mouse_sensitivity))
    head.rotation.x = clamp(head.rotation.x, deg2rad(-80), deg2rad(80))

    leftshoulder.rotate_x(deg2rad(-event.relative.y * mouse_sensitivity))

    leftshoulder.rotation.x = clamp(rightshoulder.rotation.x, deg2rad(-80), deg2rad(80))

    rightshoulder.rotate_x(deg2rad(-event.relative.y * mouse_sensitivity))
    rightshoulder.rotation.x = clamp(rightshoulder.rotation.x, deg2rad(-80 ), deg2rad(80))
Godot version 3.3
in Engine by (47 points)

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 Frequently asked questions and 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 [email protected] with your username.