void Update() { // Check for occasional energy core getting out of arena // and dropping down. if (transform.position.y < -0.5f) { transform.position = arena.GetRandomSpawnPosInArena(); } }
protected void ResetAgent() { // Physics by default updates Transform changes only during Fixed Update which makes Physics.CheckBox // to not work correctly when Transform changes and call to Physics.CheckBox are made at the same frame. // Physics.SyncTransforms() updates the Transforms to the physics engine and Physics.CheckBox works Physics.SyncTransforms(); var randomRotY = UnityEngine.Random.Range(-180f, 180f); transform.rotation = Quaternion.Euler(new Vector3(0, randomRotY, 0)); transform.position = m_GameArena.GetRandomSpawnPosInArena(); m_AgentRb.velocity = Vector3.zero; m_AgentRb.angularVelocity = Vector3.zero; }