I want to make GameObject’s rotating when Im inside the GameObject-hitbox. But no rotation happens when I do the list-stuff in the colliders. Debug.Log() gives me the correct among of objects
MapPhys.cs
public class MapPhys : MonoBehaviour
{
public List<GameObject> listRotateXLeft = new List<GameObject>();
private void FixedUpdate()
{
Debug.Log(listRotateXLeft.Count);
foreach (GameObject x in listRotateXLeft)
x.transform.Rotate(Vector3.down * 30.0f * Time.fixedDeltaTime);
/*for(int i = 0; i < listRotateXLeft.Count; i++)
listRotateXLeft[i].transform.Rotate(Vector3.down * 30.0f * Time.fixedDeltaTime);*/
}
}
MyPlayer.cs
public class MyPlayer : MonoBehaviour
{
public MapPhys mapPhys;
private void OnTriggerEnter(Collider coll)
{
if (coll.gameObject.CompareTag("RotateXLeft"))
mapPhys.listRotateXLeft.Add(coll.gameObject);
}
private void OnTriggerExit(Collider coll)
{
if (coll.gameObject.CompareTag("RotateXLeft"))
mapPhys.listRotateXLeft.Remove(coll.gameObject);
}
}