Hi,
I'm trying to better my understanding of programming physics so I actually understand what Rigidbody is doing which is why I'm not using Rigidbody.
I'm moving the player based on force and velocity and I'm trying to do the same for rotation.
I'm calculating the angular velocity but am having trouble passing that into the transform. This comes down to my understanding of it. I know I'm trying to pass in a vector3 to a Quaternion which is like a no no but I can't find anything to work which makes me think I'm going about it all wrong.
private Vector3 deltaYaw;
private Vector3 deltaPitch;
private Vector3 deltaRoll;
private Vector3 rotationVelocity;
private Vector3 rotationLast;
private Vector3 rotationDelta;
rotationVelocity = transform.rotation.eulerAngles - rotationLast / Time.deltaTime;
deltaYaw = transform.rotation.eulerAngles * (yawOutput * Time.deltaTime / mass);
deltaPitch = transform.rotation.eulerAngles * (pitchOutput * Time.deltaTime / mass);
deltaRoll = transform.rotation.eulerAngles * (rollOutput * Time.deltaTime / mass);
rotationVelocity += deltaYaw += deltaPitch += deltaRoll;
rotationDelta = rotationVelocity * Time.deltaTime;
transform.rotation += rotationDelta;
rotationLast = transform.rotation.eulerAngles;
transform.rotation += rotationDelta I know is never going to work but after trying many things I've left it here as that is in movement speak is what I'm trying to achieve if that makes sense.
If any one has any help or suggestions I will be very grateful.
Thanks in advance.
↧