Hi guys! I’ve bumped into a problem. My player is controlled by character controller, my goal is to Slerp my character from 0 to 10 degrees on z axis while player is running forward+left, Slerp my character from 0 to -10 on z axis while player is running forward+right and Slerp back to 0 if non of this conditions are true. Please give me a hint.
thanx.
Sounds like an airplane…
Transform.Rotate would do that.
float fAngle = 0.0f;
void Update()
{
if(Input.GetKeyDown(KeyCode.Up) Input.GetKeyDown(KeyCode.Left))
{
fAngle -= Time.deltaTime;
fAngle = Mathf.clamp(-10.0f, 0.0f);
this.Rotate(Vector3.forward, fAngle);
}
else if(Input.GetKeyDown(KeyCode.Up) Input.GetKeyDown(KeyCode.Right))
{
fAngle += Time.deltaTime;
fAngle = Mathf.clamp(0.0f, 10.0f);
this.Rotate(Vector3.forward, fAngle);
}
else
{
fAngle = 0.0f;
this.Rotate(Vector3.forward, fAngle);
}
}
Please take care of the default argument(relativeTo, default to local).
thank U for answering, but that is not exactly what i was looking for i don’t want a characater to rotate around constantly just bend a bit to the side he is running