Collision Loop

I have an issue where I join a game and the menu keeps popping up, the reason comes from this program:

using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement;

public class MonsterScript : MonoBehaviour
{
private Rigidbody MyBody;
public float MonsterSpeed;

void OnCollisionEnter(Collision collision)
{
    if (collision.gameObject.tag == "Player")
    {
        GameOver();
    }
}

void Start()
{
    MyBody = GetComponent<Rigidbody>();
}

void Update()
{
    transform.LookAt(Camera.main.transform.position, -Vector3.up);
    MyBody.MovePosition(transform.forward * Time.deltaTime * MonsterSpeed);
}

void GameOver()
{
    Debug.Log("You've died...");
    SceneManager.LoadScene("Menu");
    SceneManager.UnloadSceneAsync("Menu Scene");
}

}

The program makes a monster.

:slight_smile: if you need any more ask!

Nevermind, I found the solution. I changed MyBody.MovePosition(transform.forward * Time.deltaTime * MonsterSpeed) to MyBody.velocity = (transform.forward * Time.deltaTime * MonsterSpeed)