playMaker

Author Topic: GameObjects and Self Awareness  (Read 4841 times)

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 318
GameObjects and Self Awareness
« on: August 17, 2012, 07:05:25 AM »
I have several gameobjects in my scene which are all clones of one another.  During play the Player object will store one of them in a variable on itself, for example as a gameobject variable named "Target".  From time to time these gameobjects will retrieve the "Target" variable on the player to perform some function.

I'd like to know if there is any way for a gameobject to identify itself without me having to assign each an individual ID.  Something like "Get Owner" and "Get FSM Game Object", "Are These The Same?"

Thanks.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: GameObjects and Self Awareness
« Reply #1 on: August 17, 2012, 09:07:20 AM »
Hi,

 GetOwner will return the gameObject that this fsm is attached too. This is what you want.

 GetFsmGameObject will simply allow you access a Fsm gameObject variable from another gameObject or fsm.

now, for identification, I would think that the best way is indeed to keep track of them, maybe in a list, with arrayMaker, or quite simply, with a Fsm, that is responsible for storing and managing access to it by id. I do that regularly actually, and I call these fsm "META"

 so in your "Meta" fsm, you have an int "ID", and other gameObjects can simply query for that id. Now one limitation of playmaker currently, is that you can't really get a response when you fire an event. I would really enjoy the ability to establish a two way communication system in playmaker, say send an event "ARE YOU JEAN" and the action that sent that event could get a result, a bool in that instance, and the receiver would have the ability to return true or false.

but, right now, you will have to store the id of the object you want to check, and do your thing locally on the fsm that wants to check for a given gameObject id.


bye,

 Jean

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 318
Re: GameObjects and Self Awareness
« Reply #2 on: August 17, 2012, 11:34:05 AM »
Thanks for your reply Jean.

Yeah, I wasn't asking if those two actions were the same.  I meant if there were an equivalent action like "Are these two game objects the same".  Haha. 

I'm feeling lazy and didn't want to set up a script to assign ID's for each one.

Thanks for the explanation though, at least you have given me the way to do it clearly.  Now I just have to muster the energy for it.