Playmaker Forum
PlayMaker News => General Discussion => Topic started 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: - tags
- collision boxes
- is trigger enabled
- rigidbody
- trigger enter
- collision enter
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.
-
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
-
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:
- make sure the trigger on the weapons collider is turned on. This is what will allow you to pickup the weapon. It is also used to trigger the crates destruction.
- After the player has picked up the weapon you will need to add a rigidbody component to the weapon and disable gravity
- on the crate you will need to detect for a trigger event.
- I use a custom tag on the weapon to make sure nothing else sets off the crates destruction
(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.
-
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
-
So in playmaker whats the difference between TRIGGERENETER and COLLISIONENTER
-
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