Quantcast
Viewing all articles
Browse latest Browse all 133

How to offset an object's rotation using Lerp.

I have 2 objects 'a' and 'b' I want object b to have the same rotation as a, but when I press or hold 'W' i want object b to have a small offset on the X-axis making it seem to tilt forward a bit when moving and when I release the 'W' key it should lerp back to object a' position, but I want it to smoothly tilt using Lerp or Slerp, the only result I get is object b moving in a completely different direction. husk.transform.rotation = Quaternion.SlerpUnclamped(husk.transform.rotation, huskrot, turnAmount*Time.deltaTime); if (Input.GetKey(KeyCode.W)) { this.GetComponent().AddForce(transform.forward * Forward_Backward_Speed); huskrot = new Quaternion(transform.rotation.x + tiltAmount, transform.rotation.y, transform.rotation.z, transform.rotation.w); } else { huskrot = new Quaternion(transform.rotation.x, transform.rotation.y, transform.rotation.z, transform.rotation.w); }

Viewing all articles
Browse latest Browse all 133

Trending Articles