playMaker

Author Topic: Car Controller  (Read 10015 times)

Vallar

  • Junior Playmaker
  • **
  • Posts: 90
Car Controller
« on: May 21, 2013, 03:57:59 PM »
Hello Playmaker community,

Recently I have decided to develop a little racing game, so I started on creating a controller for the car itself.

So far, I got the entire controller setup but I get this error
Car : Speeding : Loop count exceeded maximum: 1000 Default is 1000. Override in Fsm Inspector.

I understand that the problem can be resolved by editing some value in the Inspector; however, my question is that recommended? It sounds that I am doing something wrong. I went through the 4 FSMs I had and none of them had "Every Frame" or "Every Second" checked. Yet, I do have multiple loops active in each FSM (created on the same object).

Another question I had 4 FSMs on the car model I am using:
1- Movement (simply a state to with "Get Axis Vector" saving the Vector output and another state with Character Simple Move to get it to move forward and backwards).
2- Rotate (It has 1 state with "Get Axis" and saving the axis info in a float variable and the second state with "Rotate" which gets it to rotate left and right).

Now where the problems arise...

3- Speeding
One state with Get Key Down (checking if "W" is pressed and storing the info in global var "keyPressed") flowing to a Float Compare (to check if the speed isn't more than 10 -- speed here is the multiplier used in the previously mentioned Movement FSM) which would either flow to a state with Float Add (to increase speed if the speed isn't more than 10) or to a state with a Send Event (to send an event to Stopping FSM to stop the car and reset the speed to 0).
If the speed is less than 10 as mentioned above and it flows to the Float Add state (to increase the speed) another check is done on "keyPressed" to see if "W" is still pressed, if it is then it flows back to the previously mention Get Key Down and goes through the cycle again. If not, however, it flows directly to the Send Event state to stop the car.

4- Stopping:
Another FSM setup with similar to number 3 except I am checking if the "W" is released. If it is, then the car speed is set to 0 and if not then an event is sent back to the previous FSM to get the car to accelerate.

When I play the game, I find that the car accelerates at a constant speed of 1 (though W is pressed and never released) once I release the "W" key I get the speed set to 0 (as intended when stopping) but once I press "W" again to restart my acceleration I see that the speed is set directly to 10 without any scaling up and the message stated above (Car : Speeding : Loop count exceeded maximum: 1000 Default is 1000. Override in Fsm Inspector.) is displayed and the game is paused.

Any idea what am I doing wrong? Or do you have any pointers/tutorials on how to create a car controller with Playmaker?

Thank you very much in advance.
Best Regards,
Vallar.



=

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Car Controller
« Reply #1 on: May 21, 2013, 04:18:53 PM »
It's not good practice to allow a loop like that. The catch is there for a reason, generally the loop is identified and you can follow it back to the culprit to fix it.

I'm not sure whats going on from your description, from your explanation it seems like there is room for improvement but I cant see where there would be a looping issue without looking at the FSM.

Can you post a scene? Or screenshots of the FSM at least?
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Vallar

  • Junior Playmaker
  • **
  • Posts: 90
Re: Car Controller
« Reply #2 on: May 21, 2013, 11:45:05 PM »
Hello,

Alright I made some snap shots hope they help:



[URL=http://imageshack.us/photo/my-images/197/speeding.png/]

[URL=http://imageshack.us/photo/my-images/405/rotatey.png/]

[URL=http://imageshack.us/photo/my-images/823/movement.png/]


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Car Controller
« Reply #3 on: May 22, 2013, 12:58:19 AM »
Hi,

 Yes, avoid loops in such controllers. Prefer the option to send discrete events.

example, if you want to watch a value and compare it somehow, you need to then simple use a compare action and fire events when values reaches threshold, then another fsm will simply implement events, and stay in a particular state performing an operation until another event will make it leave that state and enter another state.

 so avoid checking something, then moving to another state, then back checking, that's always going to give you trouble. If that really the way you want to do it, then you need to check within the state that perform an operation.

Does that make sense?

bye,

 Jean

Vallar

  • Junior Playmaker
  • **
  • Posts: 90
Re: Car Controller
« Reply #4 on: May 22, 2013, 01:43:21 AM »
Thank you very much for replying so fast.

Unfortunately, I didn't understand what do you mean with the following:

"example, if you want to watch a value and compare it somehow, you need to then simple use a compare action and fire events when values reaches threshold, then another fsm will simply implement events, and stay in a particular state performing an operation until another event will make it leave that state and enter another state."

Can you elaborate or give an example please?
Sorry.

Thank you very much.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Car Controller
« Reply #5 on: May 22, 2013, 05:31:08 AM »
Hi,

 No worries :) here's one simple example

 I use the "wasd" input together to find out the magnitude, which can go over 1 when both horizontal and vertical are held together "WD" for example.

 So, I have one fsm that specifically deal with checking the input and fire global events. based on the magnitude value and if it goes above 1, another fsm simply listen to these global events can is free to do anything else it wants and not worry about the logic behind the input check.

 Does that make more sense? in a car controller situation, you might want to check for oversteering or understeering or speed. The key is to assign a particular logic to a given fsm, and create multiple fsm to answer everytime a specific behavior, this allos for greater flexibility in our case.

bye,

 Jean

Vallar

  • Junior Playmaker
  • **
  • Posts: 90
Re: Car Controller
« Reply #6 on: May 22, 2013, 11:48:11 AM »
Ohhh, I understand what you are referring to now. Sorry for being so stupid.

Thank you very much, I will try to do it this way. Thank you again! :)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Car Controller
« Reply #7 on: May 23, 2013, 01:11:55 AM »
Hi,

 you are not stupid, you are simply learning, so no need to apologies here.

bye,

 Jean

Cool_Flow

  • Playmaker Newbie
  • *
  • Posts: 10
Re: Car Controller
« Reply #8 on: June 24, 2013, 12:18:41 PM »
Hey all,

I'm new to Playmaker and I just wanted to say that, that type of reply is something I like to see when trying to learn another piece of software. I applaud you jean for your lighthearted replies and gives me hope that people are willing to help people that just want to learn.

 ;D to Jean.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Car Controller
« Reply #9 on: June 25, 2013, 02:01:11 AM »
Hi,

 You are welcome :) To be fair, Alex, the one behind PlayMaker, should be credited as well here, for re-investing  a lot into community support and providing me with the time needed to help you.

and also, because the forum activity is growing and growing, do not hesitate to bump threads that are missed somehow, it's never in purpose... simply sometimes it's too much and it gets lost. So if you find even a very old question that hasn't been answer let us know and bring it back on top of the pile so we can answer it.

bye,

 Jean