- Home /
Question by
Palai · Mar 12, 2013 at 01:31 PM ·
rotationmultiplesimultaneous
Multiple simultaneous rotation changes on one object
//Called in Update()
float yAngle = Mathf.SmoothDampAngle(angles.y, rot.eulerAngles.y, ref velocity, minTime, core.groundcraftMovement.turnSpeed * speedMod, Time.deltaTime);
Vector3 newRot = new Vector3(_transform.rotation.x, yAngle, _transform.rotation.z);
_transform.rotation = Quaternion.Euler(newRot);
//Called in FixedUpdate()
Vector3 temp = _transform.forward - Vector3.Dot(_transform.forward, hitNormalSum) * hitNormalSum;
Quaternion rot = Quaternion.LookRotation(temp, hitNormalSum);
_transform.rotation = Quaternion.Slerp(_transform.rotation, rot, 1 * Time.deltaTime);
This is from a hover tank script that can be controlled by both players and AI.
The first snippet controls AI rotation, which only affects the Y axis.
The second snippet is the hover tank adjusting to the surface normal.
How do I use both these rotation changes simultaneously without one overriding the other?
Comment
Your answer
Follow this Question
Related Questions
Multiple animations problem. 0 Answers
Multiple cameras with different viewport rotations 2 Answers
Rotation multiple points, help needed 1 Answer
Multiple Simultaneous Rendering Unity Instances 2 Answers
Simultaneous button presses 2 Answers