x


Hey guys, I want to no how to go inside an object with a collider but to still collide with it?

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); 
    } 
}
}
more ▼

asked Jun 29 '10 at 05:53 AM

Daniel 8 gravatar image

Daniel 8
71 13 15 24

So you want it to collide with other things but not the player?

Jun 29 '10 at 05:57 AM 0V3RWR173D

what i want is like a hint box, you can move through it but when the player touches it the gui comes up

Jun 29 '10 at 06:04 AM Daniel 8
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

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.

more ▼

answered Jun 29 '10 at 06:05 AM

Eagle32 gravatar image

Eagle32
452 2 6 17

(comments are locked)
10|3000 characters needed characters left

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.

more ▼

answered Jun 29 '10 at 06:06 AM

Deikkan gravatar image

Deikkan
198 8 9 19

cool, thanks that was alot of help

Jun 29 '10 at 06:19 AM Daniel 8
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5087
x3740
x3694
x1703
x799

asked: Jun 29 '10 at 05:53 AM

Seen: 1079 times

Last Updated: Jun 29 '10 at 07:11 AM