playMaker

Author Topic: Select character, then point and click to move  (Read 2380 times)

bmeals

  • Playmaker Newbie
  • *
  • Posts: 1
Select character, then point and click to move
« on: January 22, 2015, 11:51:38 AM »
I'd like to Select a character, then point and click to move that character around. After that, I'd like to deselect it so that it's left in it's idle state, and select something else, like another character and then point and click to do the same. Any ideas?

I'm new to Playmaker and still learning, but I can't seem to find any info on how to do this. Thanks

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Select character, then point and click to move
« Reply #1 on: January 22, 2015, 12:09:32 PM »
It's not as hard as you think, being new it could be a bit confusing though. I can make an example some time, but I'll explain how it works here.

  • We need to make an FSM for managing the clicking, you can just put it on your Main Camera or something.
  • Now the in the click manager you have a few states.
    State 1: Get Mouse Button Down
    State 2: Mouse Pick & Next Frame Event
    State 3: If you clicked a unit, idle here, wait for click to order a move.
    State 4: Send the order to move the unit
  • In State 1 setup the Get Mouse Down Button to fire a transition to State 2.
  • In State 2 setup the Mouse Pick to only pick on the Layer that the Unit is on, store the GameObject, and do a GameObject Is Null action. If the Object is null, then nothing was picked, go back to State 1... Otherwise something was picked so you can move to State 3.
  • Now you know you have a GameObject to send orders to, use Get Mouse Button Down again but for the Right Click and transition to State 4. If Left Click then go to State 3 to check everything out again.
  • In State 4 do another Mouse Pick but only store the Hit Point. Use Set FSM Vector3, target the GameObject you stored, the FSM, and the Variable for the destination (the clicked point from right clicked Mouse Pick)... Now do a Send Event, choose a Game Object FSM, target the GameObject, FSM, and send a global event called "OrderMove" or something.

That covers getting the data to the object, now just setup a Global Transition on the Unit to do something like Move Towards in a state where the "OrderMove" transition is called, roll back to the idle state and bob's your uncle.

If any of those terms are mysterious to you then I would recommend you watch a bunch of the tutorials on the YouTube channel before proceeding any further. You need to grasp how to operate states, use global transitions, communicate between FSMs and have a basic understanding of Variables and design principles in Unity.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D