playMaker

Author Topic: Collider triggers  (Read 6188 times)

alcitos

  • Playmaker Newbie
  • *
  • Posts: 5
Collider triggers
« on: July 31, 2011, 09:31:18 PM »
Hi,

I'm using a Playmaker FSM on several objects, such as helmets, which sit on the terrain.  The state machine just waits for the MOUSE DOWN event which then kicks off to the next state.  The problem I'm having is it's very difficult in game to get the event to trigger when clicking on the objects.  I've tried all types of colliders, set to trigger, making the radius/size larger/smaller, etc.  but it still take multiple clicks most times to set off the trigger event.  Any ideas?

Thanks

justifun

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 285
Re: Collider triggers
« Reply #1 on: August 01, 2011, 01:08:51 PM »
There might be 2 things you are getting confused about so i want to make sure we are on the same page.

Collisions occur when 2 objects touch / stay touched / or seperate from each other if they have colliders and rigid bodies on them or are set as triggers.

What you are asking about is actually just a transition (MOUSE DOWN), which is something different.

From the sounds of it all you need is to put a "MOUSE DOWN" transition on your helmet object, and have that lead to your next state

try this.

make a cube.  Attach a new FSM to it, and "add a transition" MOUSE DOWN.  then create a second state and add the transition called MOUSE UP

then connect each state to each other. 

as you hold the mouse down over the cube, it will transition to state 2, and when you release the mouse it will go back to state 1



now what "might" be happening in your case, is that you have some other events going off during a collision event eg: if your helmet falls from the sky and triggers something when it hits the ground, and is therefore taking you out of the state that is checking for that MOUSE DOWN event, so you might have to add a MOUSE DOWN event in another state if that's the case.   (or you can add a second FSM to the same helmet object and take care on MOUSE DOWN events on that FSM and collision actions on the other FSM to simplify and seperate what's going on.)

hope that helps!

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4157
  • Official Playmaker Support
    • LinkedIn
Re: Collider triggers
« Reply #2 on: August 01, 2011, 02:23:41 PM »
Also check that other triggers aren't interfering with the mouse picking. For example, you might need to set game objects that shouldn't be mouse picked to use the Ignore Raycast layer. Quite often when a trigger doesn't work, I find that another trigger is interfering...

qholmes

  • 1.2 Beta
  • Hero Member
  • *
  • Posts: 509
Re: Collider triggers
« Reply #3 on: August 01, 2011, 03:43:17 PM »
I also had issues using the standard transitions for picking up consistent mouse events.. I had to switch to using the Mouse Pick Event action instead.. Dont know why.

Q

alcitos

  • Playmaker Newbie
  • *
  • Posts: 5
Re: Collider triggers
« Reply #4 on: August 01, 2011, 03:52:01 PM »
Thanks.  I don't think there's any other triggers or such things interferring as the only thing near this object is the terrain.  I've attached some screen shots which show my FSM and the object and its collider.





It works sometimes.  I have to click all over the object several times to get it to trigger sometimes.  I've tried different colliders (cube, sphere, mesh, etc) and resizing etc. 

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4157
  • Official Playmaker Support
    • LinkedIn
Re: Collider triggers
« Reply #5 on: August 01, 2011, 04:15:14 PM »
Can you open the PlayMaker Log window (Debug Menu > Open Log Window) and look at the events. Is the MOUSE DOWN event being sent every time you click on the object?

If you have a small test scene that reliably repros the problem I'd love to take a look at it.

Haven't come across this myself, so I'd need a repro to fix it...

alcitos

  • Playmaker Newbie
  • *
  • Posts: 5
Re: Collider triggers
« Reply #6 on: August 01, 2011, 04:23:57 PM »
Mouse Pick isn't getting the object either

alcitos

  • Playmaker Newbie
  • *
  • Posts: 5
Re: Collider triggers
« Reply #7 on: August 01, 2011, 04:29:37 PM »
It looks like it might have to do with my camera script actually.  It's working fine until I start rotating my camera from it's default position.

alcitos

  • Playmaker Newbie
  • *
  • Posts: 5
Re: Collider triggers
« Reply #8 on: August 01, 2011, 08:04:04 PM »
Ok, I figured it out.  It didn't have to do with my camera rotation, but it was set off by the same input (right click).  I'm using Smart Water Basic, and in the Smart Water Camera there's a MouseLookPlusOcean script which receives Input.GetMouseButtonDown(1) (right click) and then calls the AddForce method of the camera's rigidbody.  This messes up the raycasting for the rest of the game for some reason, so I commented it out for now and there's no more issue.