playMaker

Author Topic: Please can someone explain the logic?[SOLVED]  (Read 1783 times)

prattfall

  • Playmaker Newbie
  • *
  • Posts: 19
Please can someone explain the logic?[SOLVED]
« on: April 22, 2014, 04:55:31 PM »
I guess I must be pretty dim, because I thought PM was exactly what I needed, being useless at code. It looks EXACTLY what I need, but, seriously, unless I can understand its logic (which currently I can't), I have thrown away my money.

I set up a couple of test states to try to understand the logic what the hell is happening.
State 1: Find Closest (food object - store in variable); Next Frame Event (FINISHED) transitions to...
State 2: Move Towards (the object stored in State 1); Next Frame Event (FINISHED) transistions back to State 1.

This is what I expected to happen:
Agent (the sphere) stores the closest food object and starts moving towards it. If another food appears which is closer, it will move to the second food instead, ignoring any further away, and so on. Finally, it will push against one food as the two states rapidly oscillate.

Alternatively, I thought this might happen:
Agent stores the closest food object and moves all the way towards it. It effectively ignores any other food objects because it is now touching the first food object and so all others will be further away.

In fact, what happens is this:
Agent stores the first food object and starts moving towards it. If another food object appears, it changes and moves towards that instead - even if it is further away. Even after it collides with a food object, it will go after the next food object placed. Sometimes, if you have about five or more food objects, it starts to move randomly from one to another (not normally the closest). Like so:
https://www.flickr.com/photos/120865053@N02/13971131102/

Seriously, I must be missing some basic logic on how this works, because this is just two states. Four actions. Surely nothing complicated at all. Please, before I wave farewell to the money I spent on this (and my sanity), could someone try to explain to me how this works?

(Incidentally, can someone also explain how I'm supposed to use debug log, because this action doesn't seem to do anything. Also, as I said elsewhere, the log window doesn't show variable values for the selected state as it claims - only the current value regardless of what state is selected.)
« Last Edit: April 24, 2014, 05:00:28 AM by jeanfabre »

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Please can someone explain the logic?
« Reply #1 on: April 22, 2014, 05:29:31 PM »
Well, I think the issue is understanding what you should be doing with States.

You can push any logic through it and use States as more like Steps or Iterations or something but if you have two states, one state saying "find this thing" then immediately doing into "move to the thing" then immediately returning to the first state then you're stuck in a horrific loop and im surprised it even agrees to run without a loop exception.

There's several ways to go about doing this but you could just have a "Going toward food" state. Put the Find Closest and Move Towards in the same state and use the Every Frame checkboxes. This will do what you want and not cause a state loop that repeats insanely fast. You don't want that to ever happen.

You could also have a separate FSM that does nothing but find the nearest food and tell the Movement FSM where to go toward. You could even set it up with a Wait state so it would do a nearby check for food then wait a couple of seconds so its not too heavy.

This is fairly normal, until you start wrapping your head around the FSM system and how States work, whats ideal, whats the big no-no's are, etc, then you're going to be getting frustrated just like you would get when learning anything else. Don't hesitate to ask questions or post about the struggles you're having, and screenshots as they're really helpful to see whats going on and often save a lot of time writing explanations out.

Theres something wonky going on with the stuff in that video, ill take a closer look later.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

prattfall

  • Playmaker Newbie
  • *
  • Posts: 19
Re: Please can someone explain the logic?
« Reply #2 on: April 22, 2014, 05:47:02 PM »
Thank you - for the explanation and for your patience! I knew this set-up wasn't "proper". The trouble is, I've been working with more complex states and having FSMs talking to each other etc. as per the tips page. But I haven't got the hang of debugging properly (and the debug log action is a mystery to me). I was simply trying to make the simplest possible set-up to understand how/when actions actually finish and how the slightly more usable set-up was going wrong.

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Please can someone explain the logic?
« Reply #3 on: April 23, 2014, 10:18:26 AM »
Take a look at this scene, I think this is what you're trying to do.

Let me know if it helps at all.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

prattfall

  • Playmaker Newbie
  • *
  • Posts: 19
Re: Please can someone explain the logic?
« Reply #4 on: April 23, 2014, 12:03:27 PM »
Thank you very much for your time in doing that! It does clarify things with respect to splitting things up like that. I will play with it a bit to see how to build on it. Thank you again, I really appreciate it.