I have a ship moving, that checks for collision as well as trigger. When ship collides with another ship it gives a collision status message.
I have another object that has checks for trigger.
In Editor
My onGUI() function works perfectly for both collision as well as trigger
In Build
OnCollisionEnter() and OnCollisionExit() works against another ship which detects collision and not trigger.
OnTriggerEnter() and OnTriggerExit() DOES NOT WORK which means
GUI.Box(new Rect(winX, winY, 200, 100), content); doesn’t show up with my status messages.
public class OnDriftingCourse : MonoBehaviour
{
public Boolean collided = false;
GUIContent content;
public Texture BoxTexture;
public int winW = 200;
public int winH = 100;
private int winX;
private int winY;
void OnTriggerExit(Collider c)
{
collided = true;
content = new GUIContent(" Trigger Exited " , BoxTexture, "--");
print("ON Trigger Exit");
}
void OnCollisionEnter(Collision collision)
{
collided = true;
content = new GUIContent(" Collided enter ", BoxTexture, "--");
print("ON Colission Enter");
}
void OnCollisionExit(Collision collision)
{
collided = false;
//content = new GUIContent(" Collided enter ", BoxTexture, "--");
//print("ON Colission Enter");
}
void OnTriggerEnter(Collider c)
{
collided = true;
content = new GUIContent(" Trigger ENTER ", BoxTexture, "--");
print("ON Trigger Enter");
}
void OnGUI()
{
winX = (Screen.currentResolution.width) / 2;
winY = (Screen.currentResolution.height) / 2;
winX = 600; winY = 50;
if (collided)
{
GUI.Box(new Rect(winX, winY, 200, 100), content);
}
else
{
collided = false;
}
}
}