Playmaker Forum

PlayMaker News => General Discussion => Topic started by: joduffy on May 02, 2013, 10:36:35 AM

Title: Using collision enter for weapon hitting cube
Post by: joduffy on May 02, 2013, 10:36:35 AM
Hi guys,

I am trying to get "on collision enter" to work in playmaker.
What I am trying to do is create a weapon that you can pick up. Then using the mouse button you can use it to hit a cube.

When the weapon hits the cube, the cube should detect the collision and destroy itself.

I have all the parts together and they all work but for one thing. I cannot seem to get the collision between the cube and weapon working.

I have tried using a combination of the following:
All to no luck. Can anyone tell me how they can get one gameobject to react to a collision from another gameobject. In my case it is a weapon hitting a crate. But it could be used many things like meteors hitting meteors and exploding.
Title: Re: Using collision enter for weapon hitting cube
Post by: jeanfabre on May 02, 2013, 03:11:38 PM
Hi,

 could it be that in the first place your two colliders are not set properly? one of them  must have a physics components, else triggers will not work.

bye,

 Jean
Title: Re: Using collision enter for weapon hitting cube
Post by: joduffy on May 03, 2013, 11:04:26 PM
Thank you for your reply Jean.

I have tried all of those combination. I attempted again today and got it to work.
Here is screenshots of the setup that is needed in case anyone else tries to do something similar.
What you need to do is:

(http://)

I'm pretty sure I added a rigidbody to the weapon manually, but assigning it through playmaker works. Plus you don't set off the weapons trigger.

I do have one question. I know triggers are used in games for say invisible traps, turning lights on when you walk into a room, automatic doors etc and that collision detection is used to determine when two object collide eg cars crashing into each other in grand theft auto.

My question is how do you achieve this in playmaker. I have tried to setup both systems but to no avail. I know it might sound like a stupid question but I am just having some difficulties in implementing it.
Title: Re: Using collision enter for weapon hitting cube
Post by: jeanfabre on May 07, 2013, 03:33:53 AM
Hi,

 you can use the global events "ONTRIGGERENTER" and "ONTRIGGEREXIT" to transit to a state yntime something triggers your object, else you can use the action "TriggerEvent" in conjunction with "Get trigger info" if you need to only check for tagged gameObject, and/or do manual checks before an action.

 does that answer your questions? the rest is really about setting up your gameObject properly, that's outside playmaker. Do you have problem detecting triggers?

bye,

 Jean
Title: Re: Using collision enter for weapon hitting cube
Post by: joduffy on May 07, 2013, 04:44:04 AM
So in playmaker whats the difference between TRIGGERENETER and COLLISIONENTER
Title: Re: Using collision enter for weapon hitting cube
Post by: jeanfabre on May 07, 2013, 06:36:52 AM
Hi,

 this is unity Physics Terms actually.

Trigger: http://docs.unity3d.com/Documentation/ScriptReference/Collider.OnTriggerEnter.html

Collider:
http://docs.unity3d.com/Documentation/ScriptReference/Collider.OnCollisionEnter.html

you use colliders when your players hit a wall for example, and you use triggers to detect that your player entered an area. Triggers are usually invisible, Colliders are usually visible and represent physical obstacles. Triggers and colliders use the same component ( a Collider), only you can set a collider to be a "Trigger" using "is trigger" check box:

http://docs.unity3d.com/Documentation/ScriptReference/Collider-isTrigger.html

 Bye,

 Jean