playMaker

Author Topic: help with game system  (Read 2344 times)

johanesnw

  • Playmaker Newbie
  • *
  • Posts: 26
help with game system
« on: January 04, 2014, 03:19:18 PM »
I got stuck here. sorry im really new to unity(about a month) and playmaker(just a week). I'm now developing a 2D tower defense like game. It's not really a tower defense tho. a bit blending with action/shooting.
so my game has 7 playable characters, and you can just pick 3 to bring them to game.
My question is, how u make that 3 characters in the scene just like what u chose in character selection scene?
do u use 3 empty gameObjects 1st and change them based on what u chose? (if that's even possible)
or do u put all 7 characters to scene in an area faraway from the camera? and then change the position of what characters u chose to the spawn position so that 4 others actually exist but invisible?

and 1 more.
when I touch/click a character, then I'll gain control of that unit (the camera follows the controlled unit, and the character face on GUI will change too), and the other 2 will behave as AI.
anyone can explain me how to know that the character is selected?
something like this to apply on each character FSM
Code: [Select]
if(isSelected) then icancontrolyou
else youreanAI

thanks

Flying Robot

  • Sr. Member
  • ****
  • Posts: 293
  • Od ton yebo redro
    • Flying Robot Studios
Re: help with game system
« Reply #1 on: January 04, 2014, 11:19:43 PM »
Hi,

TD games are my favourite!

These problems have fairly simple solutions.

Your first problem :

When you want to get something into the scene, you can use instantiate (create object in PlayMaker). Create object will require a prefab, which you can make out of your characters. Now, the question is how do you want to get them into the scene. Do you want to select them from a GUI? Will them be created by a game event, or they can be created from the start? And where do you want them in the scene? You can use mouse pick of PlayMaker to denote the spawn position. Delve into projects/tutorials using create object and you will get your answer.

2nd Problem :

Now this requires some more brainwork. You will need two separate control mechanism for your characters. One can use the keyboard input and another AI pathfinding mechanics. You can have them in the same FSM. Each one will need to be initiated by their own global event, for example you can create a global event 'player control' and another 'AI control' and use these to init the two FSM trees. Now, these are slaves and will need to be initiated on commands or clicks by a master. For this you will need to create an empty gameobject (I always name it GameController) and attach a PlayMaker FSM to it. That is your command center. From that, you can choose whom to control and whom to make AI.

I guess you already know how to select a character. Mouse pick Man! Now when you do that from this GameController GameObject, from the same state tell the camera to follow that picked object. You can do that by changing the GameObject Variable which the Smooth Follow Action was using in the Camera. I guess you also know how to use 'Set FSM GameObject'.

That's it.

johanesnw

  • Playmaker Newbie
  • *
  • Posts: 26
Re: help with game system
« Reply #2 on: January 12, 2014, 12:14:22 PM »
sorry for super late reply. haha. after reading your reply i got very busy w/ myself  :P
and thanks. my first problem hav been solved.
I'm still working the player/AI system tho.
ya I'm using mouse pick now. does it work on mobiles?
or should I use touch info and screen pick instead?

and I wanna ask again to everyone here.
So I have 7 playable characters (just 3 to go into the stage). then I copied the original FSM from the 1st char to the rest, and change some variables/animations/sounds/etc.
Will that many copies of FSMs, scripts, conditions, looping, etc make a serious performance hit? (3 chars FSM compared to 1 char FSM)
If it's not really noticeable, I'll just keep on working then.  :)