I’m just getting back into the game programming world, so I’m a little rusty. I’m using this script to check my player colliding with a collider in the hallway. I check it like this
using UnityEngine;
using System.Collections;
public class Rendering : MonoBehaviour {
public BoxCollider hallwayCollider;
void OnTriggerStay(Collider col) {
if (col == hallwayCollider) {
Debug.Log ("It Worked");
}
}
}
It never debugs my message. Can anyone spot my error? I couldn’t for my life, and it’s probably really easy. If you can see it, let me know. Thanks!
Does your player have a rigidbody?
I’m assuming this script is on the player, so the hallwayCollider is set to your collider in the hallway.
Yes, it’s the unity Prefab FPSController
If you remove the if part, does the debug print out?
No, with just the OnTriggerStay and the Debug command, it doesn’t print
The collider in the hallway has the istrigger box checked?
Also, if I do this and start the game
void Start()
{
Debug.Log ("test");
}
It doesn’t print.
Yes, I’m beginning to think the underlying cause is the Debug.Log command itself
Your script is on your player and not on a part of the player that isn’t active?
You can try using print(“something”); if you think debug is wrong.
Also try debug.log in the awake, as awakes always run once even if the object isn’t active.
I put print(“something”) in the Start function and nothing happened. I re-imported the FPSController and still no avail
honestly, that just sounds like your script is on an inactive gameobject or your script isn’t enabled on the gameobject. If print or debug works in Awake, then I would say that is a good chance.
Otherwise, it could be an odd glitch.
Do you have an actual instance of the FPSController somewhere in your scene? Can you provide a picture of the inspector with the scene hierarchy visible and the FPS Controller selected?
I did a full editor refresh and it fixed the problem, stuff debugs now. I may never know what caused it, but thanks for helping out