playMaker

Author Topic: How to get a variable from a dynamic FSM?  (Read 1850 times)

Richardm1985

  • Playmaker Newbie
  • *
  • Posts: 15
How to get a variable from a dynamic FSM?
« on: February 12, 2015, 08:25:47 PM »
Hi Guys,

I am trying to add 4 AI and a player. I want them all to attack each other. I have colliders and rigid bodies on all the characters and weapons.

What is the best way to go about getting the damage from an FSM that I do not know of until during gameplay?

I was thinking of setting up an FSM to have a variable for weapon damage on the weapon and when it collided with whoever the AI was targetting, I could reduce the health bar by the damage specified on the weapon.

What actions do I have available to accomplish this? I'm finding it difficult to find resources on using a dynamic set up.

Richardm1985

  • Playmaker Newbie
  • *
  • Posts: 15
Re: How to get a variable from a dynamic FSM?
« Reply #1 on: February 12, 2015, 08:39:27 PM »
Do I use global variables? How many globals do I use though? 5 for all players? What if I increase the AI to 100, will I need 100 global variables? Surely there is an easier way to get the health status from an FSM that becomes available during gameplay.

Richardm1985

  • Playmaker Newbie
  • *
  • Posts: 15
Re: How to get a variable from a dynamic FSM?
« Reply #2 on: February 12, 2015, 09:22:08 PM »
Hold your horses fellas! I might have figured it out...I'll post up my method when it's complete, in case someone might find it useful.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to get a variable from a dynamic FSM?
« Reply #3 on: February 14, 2015, 10:32:40 AM »
Hi,

 Have you tried ArrayMaker? this will allow you to create a dynamic hashtable of data ( like variables really), this is likely the best way to solve this, else you would need to go object oriented and give more responsability to each GameObject each with an fsm holding private/local data, and that can grow better as opposed to have a global manager or some global variables.

 Bye,

 Jean

invayne

  • Full Member
  • ***
  • Posts: 105
Re: How to get a variable from a dynamic FSM?
« Reply #4 on: February 15, 2015, 10:11:35 PM »
best way to do this is triggers and using tags for me in my fps i use ray casting with a gun to get the tag of the object im hitting this will determine what im hitting with it. with swords or any melee wep i use colliders and triggers this will detect what im hitting by tag on trigger enter. you basically use strings to call your fsm vars and store them and add your health or take health that way with the set fsm action no need for globals other wise you'll be there for weeks trying to set up different globals.