playMaker

Author Topic: Simple Collision not working  (Read 11259 times)

markfrancombe

  • Sr. Member
  • ****
  • Posts: 338
Simple Collision not working
« on: May 28, 2012, 04:59:59 PM »
Hello...

So the Cardboard Robot finally makes it to the top of the tricky level to where the golden egg is twinkling... The little robot goes to touch it and KA--Booom! There is a terrible explosion and the egg vanishes...

... except it doesnt...

Here...
https://skitch.com/markfrancombe/87bh7/robotfactory.unity-robot-factory-pc-and-mac-standalone

I have a collidor with a FSM on, a transitin with COLLISINO ENTER and an buncj of actions that turn on an explosion game object, and turn off the egg object...

Nothing happens though...
Is it the right transition?
What does the Roblt need to MAKE a collision? He has a Character Controller but not a Rigid Body...  and no other collidor thingy.. does he need one?

Help?

Mark

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: Simple Collision not working
« Reply #1 on: May 28, 2012, 05:58:35 PM »
it should work if you add a rigidbody to the receiver (the one with the collision event FSM on it). Just freeze it's position and rotation if it's not supposed to be moving, or give it a huge drag/angular drag.

The transition is of no importance whatsoever, you could just as well call it BLUEBERRY PANCAKES if you felt like it. what's important is that you use the collision event action with the right tag and a transition that you do have on that state.
« Last Edit: May 28, 2012, 06:01:04 PM by kiriri »
Best,
Sven

Disastercake

  • Full Member
  • ***
  • Posts: 101
  • www.disastercake.com
    • Disastercake
Re: Simple Collision not working
« Reply #2 on: May 28, 2012, 08:19:11 PM »
Your picture is a broken link, but...

The way I would make the collision work:
1. Add Collider to egg that surrounds it.
2. Click "Is Trigger" on the egg inspector
3. Set a Rigidbody and collider to the player (do not select "Is trigger" on player collider)
4. Add an "On Enter Trigger" FSM to the Egg with the trigger collider
5. Make the Egg FSM state move to the rest of the needed code.
Soul Saga - Anime themed adventure RPG by Disastercake

http://www.disastercake.com

markfrancombe

  • Sr. Member
  • ****
  • Posts: 338
Re: Simple Collision not working
« Reply #3 on: May 29, 2012, 02:26:46 AM »
Thanks for your suggestions!

I AM trying some things exactly like you guys are saying, but obviously missing one tiny thing...

So in an attempt to figure this out, here are some more pics.. (@Disastercake dunno about broken ik, it worked fine for me here, so hope these work for you?)

1. Where I add the FSM to the egg and make it a trigger.
https://skitch.com/markfrancombe/87d1u/robotfactory.unity-robot-factory-pc-and-mac-standalone

2. Where I show that my little cardboard robot has a character controler and a rigid body..

Wait..? Is that is.. you said Add a collidor, (which IS a character controller) but when I try to add one it asked if I want to remove the C controller, I said cancel, and left it there...

hold on a sec while I try...

Nope didnt work, apparently having 2 collidors present made a pigs ear of lots of stuff.. he was bouncing and jittering...

can you guys be VERY specific? I feel like Im missing a tiny thing...

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: Simple Collision not working
« Reply #4 on: May 29, 2012, 02:31:07 AM »
the primary reason why it isn't working should be that you left the 'send event' property in your collision event empty. Set it to ''touched'' so it knows it's supposed to trigger the transition ''touched''.

You do need two collidors though, but only the one with the FSM needs a rigidbody. You could alternatively also set the other object to the rigidbody as long as at least one of them is a rigidbody.

though I agree with disastercake, I too think a trigger event might be better suited as you don't care for details like collision speed etc...
« Last Edit: May 29, 2012, 02:38:27 AM by kiriri »
Best,
Sven

markfrancombe

  • Sr. Member
  • ****
  • Posts: 338
Re: Simple Collision not working
« Reply #5 on: May 29, 2012, 04:34:23 AM »
YEah Im a little confused by the basic op of PlayMaker... (newbie did u guess?)

Is it to ALWAYS have an action on the first state that is what should happen to cause the second action on the second state? Im not sure the purpose of the transition actually.. or why I need to first select it on the first state, and then again in that drop down menu, you pointed out

(It didnt work by the way, something else wrong...) But probably getting closer...

The good thing is that once Im past this small operational hurdle I can see the immense potential of PlayMaker for me, I have always been good at visualizing HOW a programmer should achieve a thing, but NOT at programing myself...

So... the character MUST have an extra Collider despite getting a warning that Im basically adding a second one (the first being the character controller) and this causing jittering problems??? Maybe I can tweak the settings, if the second collider is EXACTLY the same dimensions as the first, it will help?

I am nearly the solution... I can feel it...

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: Simple Collision not working
« Reply #6 on: May 29, 2012, 06:05:33 AM »
ah no sorry, I made myself unclear, the character controller itself is a collider already.

About the transitions :
each state can have multiple transition and multiple actions. Eg. you could add several Collision Events, one which triggers if a mesh enters that has the tag "untagged", and sends the event/triggers the transition "blueberries", and another collision event which triggers if a mesh with the tag "player" exits and which triggers the event "pancake".
This means an untagged mesh has completely different results than a player mesh, because the 'blueberry' transition might lead to State 1 and the pancake transition would lead to State 2.

Since the state machine works (just like in hard code) from top to bottom of a state, you could also create a lot of actions that might not happen at the top of the state, like gameObject Compare and then try to see if it is the game object you're looking for. If you do only specify an event in the "Is True" property of that action, no transition will be triggered if the gameObject is not the one, and the stateMachine will start looking at the next action in the state. You could repeat that for each gameObject you think should be needed and then finish the state with a "send event" action, which always sends an event, no matter what, but since it's at the bottom of the state this action will only trigger an event if no other action did so before.

So about the setup, what disastercake wrote should work, I'll just describe it more thoroughly:
1) check if both objects have a collider or character controller on them. The mesh with the FSM on it should in this case be a collider and the other one should be a character controller or a collider + rigidbody.
2) on the egg (or whichever object should recognize the collision), set the collider to Is Trigger.
3) create an fsm and right click at the start state. Create a transition. Call it FINISHED (always handy to use the default ones, so it won't clutter you up)
4) add another state and connect FINISHED to that state
5) in your start state, create a Trigger Event
6) make sure the tag matches your other object's tag
7) set Send Event to FINISHED
8) run it :D
« Last Edit: May 29, 2012, 06:09:03 AM by kiriri »
Best,
Sven

markfrancombe

  • Sr. Member
  • ****
  • Posts: 338
Re: Simple Collision not working
« Reply #7 on: June 04, 2012, 05:56:00 PM »
Tentatively I would like to propose a SOLVED...! :)

I discovered where the hole in your solutions was (for me) you both foolishly assumed that I knew about tags!

I didnt!

@Disastercake thx for the solution

@kiriri Thank your so much for taking the trouble to be so clear and concise, its was your
"make sure the tag matches your other object's tag" that made me figure it out...

I had a default Player tag (that my player was NOT set to, so I simple did that, and then selected player in the tag drop down of the state.. et voila!

I owe you guys a beer.. (if you are old enough?)