- Home /
collision system being buggy
So im following a unity tutorial on youtube, I have made my code exactly as his, and when he runs his code, he gets a debug.log message while I dont, a number doesn't even appear. Keep in mind that I have my code exactly the same. Simple things like " hello" wont even work. Also When I Used public PlayerMovement movement; it never creates a slot in a player collision section. When I look I found out I never had one. But I have followed everything. here is my code:
using UnityEngine;
public class PlayerCollision : MonoBehaviour {
public PlayerMovement movement;
void OnCollisionEnter (Collision collisionInfo)
{
if (collisionInfo.collider.tag == "Obstacles")
{
Debug.Log ("We hit an obstacle!");
}
}
}
my scripting for the debug.log message
void OnCollisionEnter (Collision collisionInfo) { if (collisionInfo.collider.tag == "Obstacles") { Debug.Log ("We hit an obstacle!"); }
I know this sounds stupid but did you assign the tag to the obstacles? Sometimes i accedientally create layers instead of tags.
I know you are watching brackeys it easy to follow his tutorials so give them another watch to see what he did exactly if it is your first time do exactly as he does
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
OnCollisionStay is doing nothing. 1 Answer
Distribute terrain in zones 3 Answers
Check for collision while animating 0 Answers
Jump on the ground 2 Answers