Quantcast
Channel: Questions in topic: "around"
Viewing all articles
Browse latest Browse all 101

stop rotate around c#

$
0
0
Hey guys, I got a little problem. I have an enemy gameobject that I want to rotate around a background gameobject on a specific angle I tried this bit of code using UnityEngine; using System.Collections; public class rotatearoundme : MonoBehaviour { public float rotationSpeed = 5f; private float currentYAngle = 0f; private float targetYAngle = 0f; // Use this for initialization void Start () { } // Update is called once per frame void Update() { if (Input.GetKey(KeyCode.Alpha1)) targetYAngle = 0 - 90; else if (Input.GetKey(KeyCode.Alpha2)) targetYAngle = 90 - 90; else if (Input.GetKey(KeyCode.Alpha3)) targetYAngle = 180 - 90; else if (Input.GetKey(KeyCode.Alpha4)) targetYAngle = 270 - 90; currentYAngle = Mathf.MoveTowardsAngle(transform.eulerAngles.y, targetYAngle, rotationSpeed * Time.deltaTime); transform.RotateAround(new Vector3(0f,6.73f,30f), Vector3.up, currentYAngle); } } But it doesn't stop the rotation. The enemy just keep orbiting around the cube instead of stopping. What did I miss?

Viewing all articles
Browse latest Browse all 101

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>