Hi guys i have a problem with transform.RotateAround and I hope that you could help me out. I want my GameObject(which is attached to the script) to rotate around an object with a OnTriggerStay function. I made another object, so when he triggers with that my GameObject will rotate around the object i want, but instead it rotates around the object it triggers with. Any Idea ?
Here is my code (I dont move my GameObject via Script at the moment i do it manually on the
playmode):
public class Player : MonoBehaviour
{
[SerializeField]
GameObject target;
bool rotate = true;
void FixedUpdate()
{
Launch();
}
void Launch()
{
if (Input.GetKeyDown(KeyCode.Space))
{
rotate = false;
}
}
void OnTriggerEnter(Collider other)
{
if (other.tag == "Planet")
{
Destroy(gameObject);
}
}
void OnTriggerStay(Collider other)
{
if (other.tag == "PerfectLanding" && rotate == true)
{
transform.RotateAround(target.transform.position, Vector3.up, 200 * Time.deltaTime);
}
}
}