playMaker

Author Topic: [SOLVED] 'Controller Is Grounded' Working?  (Read 15080 times)

SeanC

  • Junior Playmaker
  • **
  • Posts: 61
[SOLVED] 'Controller Is Grounded' Working?
« on: June 24, 2012, 10:31:10 PM »
Im getting what I perceive as weirdness with the "Controller Is Grounded" action so i built a test case. I have a box over a plane in Unity. I gave the box a simple FSM that moves to one of two states depending on whether it is grounded or not.

The origins of the two are the exact same, yet when i run the game, it returns back that the box is not grounded. Perhaps i am misunderstanding how this action works, but shouldnt that return 'true'?

Do i have to tag the plane in order for it to be defined as "ground"?





Thanks all for lookin at this!
Sean


« Last Edit: June 28, 2012, 06:29:50 PM by Alex Chouls »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: 'Controller Is Grounded' Working?
« Reply #1 on: June 25, 2012, 01:12:12 AM »
Hi,

 if the box has no character controller assigned I think it won't work.

 bye,

 Jean

SeanC

  • Junior Playmaker
  • **
  • Posts: 61
Re: 'Controller Is Grounded' Working?
« Reply #2 on: June 25, 2012, 08:13:02 PM »
It does have a character controller assigned.

Would somebody else be willing to do a quick repro of my test case and see if they get different results? It should only take a few minutes. Unless, of course, I am understanding the concept of "Controller Is Grounded" incorrectly.

Thanks all,
Sean

Red

  • Hero Member
  • *****
  • Posts: 563
Re: 'Controller Is Grounded' Working?
« Reply #3 on: June 25, 2012, 11:13:29 PM »
i'm not 100% sure this would be the case but could you try increasing the size of the controller's "cage?" same parameters if it were to be a regular collider.

SeanC

  • Junior Playmaker
  • **
  • Posts: 61
Re: 'Controller Is Grounded' Working?
« Reply #4 on: June 26, 2012, 02:28:26 AM »
I tried that and no dice.

Unless anyone has any other ideas im gonna post this over in the bug forums and see what the experts say.

Thanks all,
Sean

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 318
Re: 'Controller Is Grounded' Working?
« Reply #5 on: June 26, 2012, 03:06:51 AM »
I've had this problem in the past but it was caused by an oversight of my own.  Had the same initial reaction though, but I can tell you that it is working. 

Can you post a screen of what components you have on your box? 

SeanC

  • Junior Playmaker
  • **
  • Posts: 61
Re: 'Controller Is Grounded' Working?
« Reply #6 on: June 26, 2012, 10:13:51 PM »
Oversight is my middle name, so it wouldn't surprise me at all.

Thanks a lot for taking a look at this.

Here is the components for the cube and the plane:

CUBE


PLANE

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: 'Controller Is Grounded' Working?
« Reply #7 on: June 27, 2012, 01:22:26 AM »
Hi,

 Move the box so that the bottom is slightly off the ground, so that the physics does it job and let it settle on the ground. It might the problem.  In short the plane and the box should not intersect when starting.
 
bye,

 Jean

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 318
Re: 'Controller Is Grounded' Working?
« Reply #8 on: June 27, 2012, 03:48:39 AM »
That really is my only other suggestion too.  I use ControllerIsGrounded pretty extensively in my scripts and I can't see anything else that would cause an issue with your setup.

Let us know how it worked out and if you're still having trouble I'll see if I can think of something else. 

Oh, I can suggestion one other thing, though it's kind of stupid: restart Unity.  I know that's silly and you've probably been in and out of the Editor since you ran into the issue, but I have had a substantial number of bugs in Unity where collision and scripts wouldn't work during one session, but worked fine after restarting the Editor.  That has happened to me quite a lot.

Hope that helps.

SeanC

  • Junior Playmaker
  • **
  • Posts: 61
Re: 'Controller Is Grounded' Working?
« Reply #9 on: June 27, 2012, 06:22:53 PM »
Hey all,

The problem was twofold. First, you were right Jean and Artician, i had to have the cube raised up a bit and let it fall. The second problem was my FSM setup. The way it was built, it checks the grounded status, and then moves to a new state, where nothing additional happens. So, it shows as "not grounded" and switches states, but there is nothing in that new state to tell it to keep checking for grounded status.

Here is the layout that finally got me working:



It essentially loops its own state forever until it is grounded.

The only issue I'm having now, is the game essentially freezes until the cube lands and the grounded check returns true. Perhaps there is a better way to build the FSM. Has anyone else noticed any performance issues when using the grounded check?

Thanks a lot for taking the time to check this out
Sean
« Last Edit: June 27, 2012, 06:25:31 PM by SeanC »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: [SOLVED]'Controller Is Grounded' Working?
« Reply #10 on: June 28, 2012, 01:25:51 AM »
Hi,

 don't loop back on that state, this is likely the source of your problem.

Controller is grounded is checked to run everyframe, so until the "ISGrounded" event is fire, it will run properly. so remove the "IsNotGrounded" event from the "false event" in that action, you don't want that.

 you want your set up when you need to check out of the blue and only once.

Bye,

 Jean

Red

  • Hero Member
  • *****
  • Posts: 563
Re: [SOLVED]'Controller Is Grounded' Working?
« Reply #11 on: June 28, 2012, 03:13:54 PM »
Good on ya for the solution.

if you wish to clean it up a bit though so it's not soaking up CPU cycles with the (essentially) infinite loop, maybe have the "is not grounded" test loop to a new state with one single "next frame event" action in it (and set the finished event as the trigger to "finish" the loop)

that could help because it will slow the looping down but should still be fast enough as to be invisible to the player...?

... yes, i'm all about the "next frame event" action! :P