What is the problem? "only assignment call increment decrement await and new object expressions can be used as a statement" Here is the code:
using UnityEngine;
public class PlayerCollision : MonoBehaviour
{
public PlayerMovement movement;
void OnCollisionEnter (Collision collisionInfo)
{
if (collisionInfo.collider.tag == "Obstacle")
{
movement.enabled = false;
FindObjectOfType<GameManager>().EndGame;
}
}
}
CodePudding user response:
From the C# language reference on Compiler Error CS0201:
The compiler generates an error when it encounters an invalid statement. An invalid statement is any line or series of lines ending in a semicolon that does not represent an assignment (=), method call (), new, -- or operation.
If GameManager.EndGame
is a method, then you just need to call it in order to resolve this error:
FindObjectOfType<GameManager>().EndGame();