playMaker

Author Topic: Get multiple game objects?  (Read 5067 times)

empika

  • Playmaker Newbie
  • *
  • Posts: 4
Get multiple game objects?
« on: July 01, 2012, 06:48:21 PM »
Hallo

I've just started using playmaker this weekend, and have come up against the same problem multiple times. How do I get multiple gameobjects to interact with?

For example, I am trying to create a turn based battle system (FFVII style). When the player timer reaches it's limit, i'd like to present multiple gui buttons, one for each enemy the player is facing. How would I get a count of the enemies and create buttons for them, and then select the correct enemy to attack when a button is clicked?

I have also come across the problem where I need to tell all the enemies to pause their timers once a player or enemy takes their turn. Any ideas how I could send an event to multiple objects also?

I have the basics down when fighting a single enemy and everything is static. Fighting multiple enemies when I don't know how many there are is baffling me though.

Many thanks

empika

  • Playmaker Newbie
  • *
  • Posts: 4
Re: Get multiple game objects?
« Reply #1 on: July 01, 2012, 07:10:03 PM »
Ah, just found Get Child Count and Get Child Num. I think that should get me on my way with get the object once a button has been clicked. Still not sure how to create the correct amount of buttons though.

Sorry, fairly new to Unity too, so am confused at a lot of things right now.
« Last Edit: July 01, 2012, 07:12:10 PM by empika »

yezzer

  • Playmaker Newbie
  • *
  • Posts: 24
    • Follow me on Twitter
Re: Get multiple game objects?
« Reply #2 on: July 02, 2012, 03:58:40 AM »
Hello Mr Empika Sir,

Since you're new to Unity, and you're a coder, I'd recommend doing it without PlayMaker to start with. You can easily refactor later.

Since I've started using PM, I've found that while it's possible to do pretty much everything with it, it's real power lies in using it in the right places.. which is kinda hard to define. A mix of US/C#, multiple FSMs, and custom PM actions seems to be the way to go.

If you're making a turn based battle system, you'll probably find that PM is great for handing all the game states, and also all the character states, using multiple FSMs.

The UI *might* be better scripted from scratch though. Particularly as the built in GUI in Unity leaves a lot to be desired.

Re: the GUI, use NGUI for now. There's a free version on their site, which might be useful.
Freelance games & App developer using Unity3D, Flash & Adobe AIR for web, iOS, & Android. Interested in AR & other emerging tech.
@yezzer

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Get multiple game objects?
« Reply #3 on: July 02, 2012, 07:27:56 AM »
Hi,

Yes, Yezzer is right, you are on the right path, but unfortunatly, what you are asking is going to require a custom action, since you can only define gui element in states per actions, dynamically generated gui content is difficult to achieve with playmaker currently.

If however you want to use playmaker, I can write an action that will create these buttons based on what you are describing.


 bye,

 Jean

empika

  • Playmaker Newbie
  • *
  • Posts: 4
Re: Get multiple game objects?
« Reply #4 on: July 02, 2012, 08:40:21 AM »
Thanks guys.

I had already fallen back to a C# script in order to set up some of the more complex variables used for the character timers. I didn't know about custom actions, perhaps that would be a better way to have done that, they certainly sound like something I need to look in to.

Cheers!

yezzer

  • Playmaker Newbie
  • *
  • Posts: 24
    • Follow me on Twitter
Re: Get multiple game objects?
« Reply #5 on: July 02, 2012, 08:43:15 AM »
Custom actions are great. There's documentation, and all the existing actions are C# too, so you can pick them apart. Click on the cog next to the action and select Edit Script :)

Freelance games & App developer using Unity3D, Flash & Adobe AIR for web, iOS, & Android. Interested in AR & other emerging tech.
@yezzer

empika

  • Playmaker Newbie
  • *
  • Posts: 4
Re: Get multiple game objects?
« Reply #6 on: July 02, 2012, 01:32:58 PM »
Great, thanks champ!