playMaker

Author Topic: [SOLVED] How would you handle unit information?  (Read 2362 times)

Disastercake

  • Full Member
  • ***
  • Posts: 101
  • www.disastercake.com
    • Disastercake
[SOLVED] How would you handle unit information?
« on: May 10, 2012, 08:41:09 PM »
I'm new to Playmaker and Unity, so I'd like to ask for advice on how the veterans would recommend following through with this:

I want to be able to decide which team a character is on, so it reacts differently to different player interactions and AI choices.  How would you use playmaker to use a standard class of variables that could be applied to objects that will be created on the fly during gameplay?

The only thought I can think of is having a custom script applied to each game object that contains information such as level, hp, skills, team number, and anything else related to any interactive character or npc.  Is it best to make a prefab for every possible character and use playmaker variable to store this information?  How would you run checks for the HP, team number, etc?
« Last Edit: May 11, 2012, 07:02:42 PM by Disastercake »
Soul Saga - Anime themed adventure RPG by Disastercake

http://www.disastercake.com

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How would you handle unit information?
« Reply #1 on: May 11, 2012, 06:27:31 AM »
Hi,

 if you have a fixed, given number of teams, I suggest you use Unity tag system. Playmaker has many actions using tags as well, this would be a good starting point for team checks.

If you want a flexible amount of team, your suggestion is good. I would create either a Fsm or a script that is responsible for maintaining the tem reference ( and other such meta data). it would be attached to the player or gameObject, and when something wants to check for the team, it would query that Fsm or script,

don't create a prefab per team, that's not a very good practice, even for a given number of team, instead create a prefab that accepts a team ID, and create a small "framework" so that components and things interacting with this prefab can query for the team Id conveniently. If you have only two teams ( and that it's never going to change) then yes, go for hardcoded, will be quicker.

 typical example: someone spot a moving target in front, the raycast give you a reference of that object, and you have likely done a good job at filtering this raycast to only detect players, so you know this is a player and you know it has the team Fsm component, query this Fsm for it's Id, check it against yours and then either do nothing if it belongs to the same team or act and fire or do something because it's someone from another team.

It is of course very abstract if you don't really know Unity and playmaker, if you need a working example, I can do something showing what I just explained.

Bye,

 Jean
Bye,

 Jean

Disastercake

  • Full Member
  • ***
  • Posts: 101
  • www.disastercake.com
    • Disastercake
Re: How would you handle unit information?
« Reply #2 on: May 11, 2012, 07:02:21 PM »
Thanks Jean!

I don't think I'll need an example.  I ended up writing something similar I think.  If I need one I will definitely ask!
Soul Saga - Anime themed adventure RPG by Disastercake

http://www.disastercake.com