|
Post by britannis on Apr 16, 2016 7:08:36 GMT
I know I need to normalize my rotation, but I'm not sure where.
protected override void Start() { base.Start(); myRigidbody = GetComponent<Rigidbody>();
// Set target direction to the camera's initial orientation. targetDirection = transform.localRotation.eulerAngles; yRotation = Quaternion.Euler(targetDirection); }
// We use fixed update since we are moving a rigidbody. void FixedUpdate() { myRigidbody.MovePosition(myRigidbody.position + velocity); myRigidbody.MoveRotation(yRotation * Quaternion.Euler(targetDirection) * targetOrientation); } 'velocity' in MovePosition is normalized earlier in my public Move method:
public void Move(Vector3 moveVelocity) { velocity = moveVelocity.normalized * moveSpeed; } I tried normalizing yRotation but then my object doesn't rotate along the y-axis anymore. Any ideas?
|
|
|
Post by Admin on Apr 17, 2016 23:00:22 GMT
I am not sure what the kinds of data types you are multiplying or what their values might be, but remember that if you are multiplying a Vector that it multiplies each axis in turn and if the Y axis is zero or close to zero then you won't see rotation in that direction. You could try assigning the result to a temporary variable so you can see what it is calculating.
|
|