Hey all, I’m trying to simply have my player rotate 90 degrees, when I say so well when he hits certain objects. However, when the player rotates its never a precise 90 degrees. I can not figure this out, and it’s been a problem all weekend.
Any ideas are really appreciated, I’ve scouted the docs most of this morning; this is my most recent attempt
var Yangle :float;
static var turnR : boolean = false;
function Start(){
Yangle = 0;
}
function Update () {
transform.eulerAngles =Vector3(0,Yangle,0);
var hit2 : RaycastHit;
if (Input.GetButton ("Jump")) {
if (Physics.Raycast (transform.position, -transform.right, hit2, 2.2)) {
if (hit2.collider.tag=="Turn2"){
Debug.Log("non");
turnright = true;
turnR = true;
}
if(turnR == true)
{
TR();
}
function TR(){
transform.localRotation = Quaternion.identity;
print(transform.localRotation.y);
var B : float = (Yangle -90);
var angle : float = Mathf.LerpAngle(Yangle,B,1*Time.deltaTime);
transform.eulerAngles = Vector3(0, angle, 0);
Yangle =angle;
yield WaitForSeconds(1);
turnR = false;
}
Thank you in advance.