- Home /
Question by
Heu · Feb 09, 2015 at 07:16 PM ·
rotaterotatearound
How to Rotate Player Around Specific Angle.
Hello there! Thanks for taking your time to read this.
Okay, so here is my issue. I'm trying to make my player be able to dynamically rotate around a corner so the view can be changed, but my problem is sometime the rotation is overshot, or undershot and it just gets messy.
public Transform center;
public float rotationSpeed = 5f;
void Start(){
center = GameObject.Find ("Center").transform;
}
void OnTriggerStay(Collider other){
if (other.gameObject.tag == "Player") {
if(Input.GetAxis("Horizontal") > 0f){
transform.RotateAround (center.position,Vector3.up, rotationSpeed * Time.deltaTime);
}
if(Input.GetAxis("Horizontal") < 0f){
transform.RotateAround (center.position,Vector3.down, rotationSpeed * Time.deltaTime);
}
}
}
I'm trying to make my player move rotate around a corner, only if he is press left or right, and be able to dynamically change the radius of the RotateAround, if the player moves forward or backwards.
Here's an illustration if it may be confusing.
help.png
(14.1 kB)
Comment