playMaker

Author Topic: Implementing Movement Between Points on an Array [SOLVED]  (Read 6302 times)

Stinkhorse

  • Playmaker Newbie
  • *
  • Posts: 20
Implementing Movement Between Points on an Array [SOLVED]
« on: January 09, 2016, 12:34:35 AM »
Hi there, I'm a little nervous to ask this because it seems like it should be pretty basic, but I'm having some trouble understanding how to set up an array, create a position variable from its various contents, and then use that information to move a player between the set positions on a button press.

I'm very new at this, I  started using Unity a few weeks ago and I was so bad at understanding the syntax and calls for scripting that I opted into playmaker. All of that might have been a foolish decision but in for a penny, in for a pound.

I've attached a picture of what I'm trying to build for reference. Each of the tiles would be a spot the player can move to and they would move one space per button press.

Feel free to give me an explanation that's as ground level basics as you like because my level of understanding is poor enough that reading the manual for Playmaker is a bit greek.
« Last Edit: January 16, 2016, 01:36:46 AM by Stinkhorse »

mdotstrange

  • Hero Member
  • *****
  • Posts: 555
    • Can't code? Who cares! Make games anyway!
Re: Implementing Movement Between Points on an Array
« Reply #1 on: January 09, 2016, 01:44:21 AM »
Not sure I totally understand the question but to store positions in an array you would create an array and add Vector3 variables to it to store the positional data.

When it comes to moving the player to one of the positions there's several ways you could do that depending on what kind of controls you want-

You could make the player a navmesh agent and use that position as a destination for the agent-

You could use the itween move actions to move the player to the position

You could add force to the player in the direction of the position

You could use a controller move action to move the player if it has a character controller-

There's many ways to do it- just depends on what you want  :)
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!

Stinkhorse

  • Playmaker Newbie
  • *
  • Posts: 20
Re: Implementing Movement Between Points on an Array
« Reply #2 on: January 09, 2016, 02:02:00 AM »
Ah awesome! Let me see if I can explain this better.

Each of those white floor tiles is a game object, and the player character should move from tile to tile on a button press. So if the player presses right the character will check his current tile, find the next tile in the array, and then lerp from his current tile to the next one in sequence. Every move is absolute, like a piece in a board game.

I have a general idea of the implementation I need, but what I don't understand is how to create a variable referencing the array. All the variables I've made so far require an object reference, but the array itself isn't an object, it's a script on a game object.

I think I'm simply missing or misunderstanding some fundamental aspect of Playmaker, and likely Unity itself.

mdotstrange

  • Hero Member
  • *****
  • Posts: 555
    • Can't code? Who cares! Make games anyway!
Re: Implementing Movement Between Points on an Array
« Reply #3 on: January 09, 2016, 03:50:18 AM »


You referred to array scripts- you know Playmaker 1.8 can use arrays as native variables- so you can do array lists right inside of Playmaker- for additional array+hash table functions or for older versions of Playmaker install the free add-on Arraymaker-

If the tiles are Game Objects you can store those in an array and use those to move too as well-

If you use arrays in Playmaker- you would store your game object or positions in an array- then you would use an array GET action to retrieve something from the array-

So basic workflow-

Store items in array-
Retrieve from array-
Save it in a var-
Do something to/with it

Hope that helps
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!

Stinkhorse

  • Playmaker Newbie
  • *
  • Posts: 20
Re: Implementing Movement Between Points on an Array
« Reply #4 on: January 09, 2016, 11:30:57 AM »
Yeah I think that does help, thank you!

I'll try implementing it and report back.

Stinkhorse

  • Playmaker Newbie
  • *
  • Posts: 20
Re: Implementing Movement Between Points on an Array
« Reply #5 on: January 09, 2016, 06:49:17 PM »
Whelp I'm still completely stuck.

I can build the array, I can create a 'get' action, but I can't figure out how to take a step from there. A lot of the fields in the various actions that want variables don't populate when I open them up. I suspect this is because I don't have the right type of variable for it.

I've created a local variable on my player called Current Position, but I can't figure which action would allow me to say:

1. Get the list of objects from the Tile Array
2. Find the next Tile in the sequence from the one the player is standing on
3. The player should now translate to his Current Position +/- 1 depending on the button press.
4. Update the Current Location variable with the new position.

My next step is going to be building a way too complicated state machine that moves the player forward and backward by specific increments for every single tile, rather than the way I know it SHOULD be done with the array and a set of variables.

mdotstrange

  • Hero Member
  • *****
  • Posts: 555
    • Can't code? Who cares! Make games anyway!
Re: Implementing Movement Between Points on an Array
« Reply #6 on: January 09, 2016, 07:21:12 PM »
I see- I'm in the business of creating Playmaker tutorials  :)

I'd be glad to kick out a fast free array tutorial-

Just let me know what it is about arrays and the process that you don't understand and I'll try to cover that-
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!

Stinkhorse

  • Playmaker Newbie
  • *
  • Posts: 20
Re: Implementing Movement Between Points on an Array
« Reply #7 on: January 10, 2016, 03:12:03 AM »
Well I suppose it's a combination of arrays, pulling information, converting it into a variable and then using that variable to do something else.

How do you even know that the variable has the information?

mdotstrange

  • Hero Member
  • *****
  • Posts: 555
    • Can't code? Who cares! Make games anyway!
Re: Implementing Movement Between Points on an Array
« Reply #8 on: January 11, 2016, 02:54:23 AM »
I made a video tutorial going over the basics of arrays in Playmaker 1.8 hope its helpful https://www.youtube.com/watch?v=yOZK8yr3IKo  :)
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!

Stinkhorse

  • Playmaker Newbie
  • *
  • Posts: 20
Re: Implementing Movement Between Points on an Array
« Reply #9 on: January 13, 2016, 02:20:55 AM »
Fantastic! I'm going to watch at least part of it tonight, I'm sorry I didn't see this post sooner mdotstrange. I'll try and implement based on what I learn from it and report back.

Really thank you so much for going to such lengths to answer a beginner question. I'm very grateful!

Stinkhorse

  • Playmaker Newbie
  • *
  • Posts: 20
Re: Implementing Movement Between Points on an Array
« Reply #10 on: January 13, 2016, 03:03:36 AM »
First wide-eyed-knowledge moment:
"So we're going to make a global variable array so everything can access it"

I did not know that was a variable type.

Back to the vid...

mdotstrange

  • Hero Member
  • *****
  • Posts: 555
    • Can't code? Who cares! Make games anyway!
Re: Implementing Movement Between Points on an Array
« Reply #11 on: January 13, 2016, 05:43:29 AM »
No prob- yeh I didn't know about global variables and even multiple FSM's on a single object until I had been using Playmaker for about a month  :)
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!

Stinkhorse

  • Playmaker Newbie
  • *
  • Posts: 20
Re: Implementing Movement Between Points on an Array
« Reply #12 on: January 13, 2016, 09:40:50 PM »
Sat down to finish watching the video and implement along with it, but I've discovered I don't have "array" listed as a global variable option on the drop down. I also don't have Enum which is also on your list. Am I on the wrong version of Playmaker, and is there a way to update it without rebuilding my entire project?

Stinkhorse

  • Playmaker Newbie
  • *
  • Posts: 20
Re: Implementing Movement Between Points on an Array
« Reply #13 on: January 13, 2016, 09:45:49 PM »
Ah, I was on 1.7. Updating to the beta!

mdotstrange

  • Hero Member
  • *****
  • Posts: 555
    • Can't code? Who cares! Make games anyway!
Re: Implementing Movement Between Points on an Array
« Reply #14 on: January 13, 2016, 10:22:13 PM »
If you want to work with arrays and 1.7 and earlier you would use Arraymaker- its a free add-on- its a little more work to use than the native arrays in 1.8 but there are more actions for Arraymaker at this time

In the video I'm using 1.8 and the native arrays since they are new and a much more elegant solution if you don't need the additional actions that Arraymaker has available-
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!