trouble with collision in Unity

Updated on February 2, 2019 in Unity
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
2 on February 2, 2019

I have been trying to have the player stop when they hit an obstacle. The code is written as: 

public PlayerMovement movement;

void OnCollisionEnter (Collision collisionInfo);

{

      if(collisionInfo.collider.tag == “Obstacle”)

{

movement.enabled = false;

}

}

The if statement is not being read please help

  • Liked by
Reply
1 on February 2, 2019

public PlayerMovement movement;

void OnCollisionEnter (Collision collisionInfo)

{

      if(collisionInfo.collider.tag == “Obstacle”)

{

movement.enabled = false;

}

}

you shouldn’t write a ; after a method

on February 2, 2019

When I take the ; out it gives me an error

Show more replies
  • Liked by
Reply
Cancel