playMaker

Author Topic: Turn based setup  (Read 5510 times)

Carwash

  • Playmaker Newbie
  • *
  • Posts: 11
Turn based setup
« on: December 27, 2012, 04:08:34 PM »
Hi there,

I'm new to playMaker and Unity, bought playMaker to (hopefully) help me make my ideas easier in Unity - as I'm sure many have.

A little bit about my game before the question.

It's a top down puzzle game, the player has to get their character from point A to B, by setting up the path and getting past obstacles and enemies (move/ jump/ climb/ shoot something to make it explode/ etc). They setup the path, then press 'Go' and their actions will then take place in the order they setup them up in.

The play area is in a town/ city, the puzzles become bigger and more difficult which changes the location slightly, and there is a grid to show the player how movement works.

I'm going to be using iTween, there's an example with the movement almost exactly what I want (here 4th one down - Grid base movement).

So I just need to know, if/ how:
- to achieve the same in playMaker
-- or how to integrate the script with playMaker (if this is the better way..)
- to get the moves setup/ saved so pressing 'Go' will then action them , can this be done in playMaker?

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: Turn based setup
« Reply #1 on: December 28, 2012, 05:04:03 AM »
I haven't bought this thing so I don 't know how they did it, but to me it's primarily a logic thing, and not a feature of iTween.
Each vector3 variable contains 3 floats: x,y,z. Normally we'd move from point A to B by doing:
vector3 operator B-A=C
itween move by C

But in this case we'd want to move first on one axis, then on another. So we create 2 more vector3 variables called V3_X and V3_Z. Then we create 2 floats called X and Z. Then we do:
vector3 operator B-A=C
get vector3 XYZ from C and save X and Z coordinates.
set vector3 XYZ for V3_X  :  X=X, Y=0, Z=0
set vector3 XYZ for V3_Z  :  X=0, Y=0, Z=Z
itween move by V3_X : Finished Event FINISHED

then we create a new state and link it up with a transition of the event FINISHED. In the new state, we do :
itween move by V3_Z


and that's it, nothing really using iTween apart from the move by action. Bad example IMO.
Best,
Sven

vonpixel

  • Playmaker Newbie
  • *
  • Posts: 14
Re: Turn based setup
« Reply #2 on: December 28, 2012, 03:07:01 PM »
I am by no means an expert.

But it sounds to me like you might want to work with arrays for this. You could have the players actions (x,y,z positions) and other states/values stack into an array. Then you could have those array actions execute in order when a player event gets activated.

You can get array maker for playermaker on this site somewhere. It has some examples that might help.

Carwash

  • Playmaker Newbie
  • *
  • Posts: 11
Re: Turn based setup
« Reply #3 on: December 29, 2012, 09:24:53 AM »
Yeah, I don't think I want to be using iTween in the form of the example linked to. Instead, I need to add a marker/ waypoint to the game (in an array) when the player clicks on the grid, then action them in order.

Can FSM's be added to GUI items?
There will be icons on screen, to switch between the actions, so the player would select move and click on the grid where they want to move to, this would place the waypoint.

Can I create a button, add an FSM to it, so that it places the marker and adds it to the array in a 'marker manager' attached to an empty gameobject?

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: Turn based setup
« Reply #4 on: December 29, 2012, 10:55:40 AM »
Can I create a button, add an FSM to it, so that it places the marker and adds it to the array in a 'marker manager' attached to an empty gameobject?
What do you mean? If you create a mesh button you can use a global system event to detect mouse button down for example. If you're using GUI buttons, then no you can't, they are not really created, they are just post processed in the OnGui call.

Also, you really don't have to work with arrays here. You could for example also use naming conventions or if the camera position is fixed raycast offsets to determine connections between fields.
Not saying that arrays are a bad idea though ;)
Best,
Sven