All I want is for my character to be able to go inside an object as if it wasn't there, but i still want the gui to show up .onCollision?
Is this Possible?
My script is:
var showGUI: boolean;
function OnCollisionEnter(coll: Collision) {
if(coll.gameObject.tag == "Hint")
showGUI = true;
}
function OnCollisionExit(coll: Collision) {
if(coll.gameObject.tag == "Hint")
showGUI = false;
}
function OnGUI() {
if (showGUI) {
GUI.Box (Rect (10,10,100,90), "Loader Menu");
// Make the first button. If it is pressed, Application.Loadlevel (1) will be executed
if (GUI.Button (Rect (20,40,80,20), "Level 1")) {
Application.LoadLevel (1);
}
// Make the second button.
if (GUI.Button (Rect (20,70,80,20), "Level 2")) {
Application.LoadLevel (2);
}
}
}
It sounds like you probably want the object your character is walking into to be a trigger rather than a collider.
Quoting the BoxCollider page of the Reference Manual
Triggers
An alternative way of using Colliders
is to mark them as a Trigger, just
check the IsTrigger property checkbox
in the Inspector. Triggers are
effectively ignored by the physics
engine, and have a unique set of three
trigger messages that are sent out
when a collision with a Trigger
occurs. Triggers are useful for
triggering other events in your game,
like cutscenes, automatic door
opening, displaying tutorial messages,
etc. Use your imagination!
Then you just use `OnTriggerEnter (other : Collider)`, etc rather than the OnCollision versions.
The thing that comes to mind first is setting the collision to be a trigger.
So instead of:
function OnCollisionEnter(coll: Collision) {
if(coll.gameObject.tag == "Hint") showGUI = true; }
It would be:
function OnTriggerEnter(other: Collider) {
if(other.gameObject.tag == "Hint") showGUI = true; }
On the gameobject that contains the collider, make just the Is Trigger box is checked.
EDIT: Looks like a reply was posted while I was typing. I'll leave this up here incase it is still useful.