playMaker

Author Topic: [SOLVED] move along a string of gameobjects from start to end  (Read 1310 times)

S0ULART

  • Playmaker Newbie
  • *
  • Posts: 22
    • View Profile
[SOLVED] move along a string of gameobjects from start to end
« on: January 09, 2018, 06:34:10 AM »
Hello folks!
I'm struggling with the iterate and array actions that get me confused!

I have build a string made out of nodes on runtime and want to move along them (select them) from start to end of the string with the left & right arrow keys.


I tried to achieve this with closest object action but that worked only in one direction and I think it's quite unefficient.

After that I got used to arrays but I couldn't figure out how to move to the next and previous gameobject because there is only a next action?
I also tried the iterate action but it only saves results to int and not to gameobjects?

I'm glad for any help!
« Last Edit: January 13, 2018, 04:27:11 PM by S0ULART »

nFighter

  • Beta Group
  • Full Member
  • *
  • Posts: 116
    • View Profile
    • multiplayer adult fighting
Re: move along a string of gameobjects from start to end
« Reply #1 on: January 09, 2018, 08:15:15 AM »
Actions Array List Get Next and Array List Get Previous works fine for me.

Anyway, you can iterate with INT and use this INT as an index for your array.
indie developer of multiplayer adult fighting
http://nakedfighter3d.com

S0ULART

  • Playmaker Newbie
  • *
  • Posts: 22
    • View Profile
Re: move along a string of gameobjects from start to end
« Reply #2 on: January 09, 2018, 08:17:45 AM »
Oh that's great! Can you provide me with some help how to set it up correctly?

How can I setup an array list with game objects  when the objects are created on the fly from a prefab ?
« Last Edit: January 09, 2018, 08:19:51 AM by S0ULART »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 3504
    • View Profile
    • jinxtergames
Re: move along a string of gameobjects from start to end
« Reply #3 on: January 09, 2018, 09:17:59 AM »
Hi.

the problem is they are 2 different actions and you would get issues as they do not share the current index each action is on, i have been testing a bit and i think this is a good way to set this up :


for some reason the direct video link does not seem to work

https://www.youtube.com/watch?v=-o9VgFxDv6A&t

Edit : It works now :)

nFighter

  • Beta Group
  • Full Member
  • *
  • Posts: 116
    • View Profile
    • multiplayer adult fighting
Re: move along a string of gameobjects from start to end
« Reply #4 on: January 09, 2018, 10:59:25 AM »
https://www.youtube.com/watch?v=X8rUuZDjS3Y
Also, don't forget to check this quick overview of ArrayMaker and related videos. It describes all the basic features you need.
indie developer of multiplayer adult fighting
http://nakedfighter3d.com

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 3504
    • View Profile
    • jinxtergames
Re: move along a string of gameobjects from start to end
« Reply #5 on: January 09, 2018, 02:25:37 PM »
Hi.
Array maker is a advanced array version, but the basics still work the same for included array's and array maker :)

You can find more tutorials on the User Tutorial Wiki page for both arrays and array maker :)

S0ULART

  • Playmaker Newbie
  • *
  • Posts: 22
    • View Profile
Re: move along a string of gameobjects from start to end
« Reply #6 on: January 09, 2018, 04:26:32 PM »
Wow Dino amazing tutorial.
thanks for your time and effort! your solution worked wonders and fits perfectly.

many thanks! just subscribed to your channel :)

S0ULART

  • Playmaker Newbie
  • *
  • Posts: 22
    • View Profile
Re: move along a string of gameobjects from start to end
« Reply #7 on: January 09, 2018, 06:23:25 PM »
One question though!
How can I get my array to work when I generate the objects/cubes/nodes at dynamicly runtime and don't have a fixed size?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 3504
    • View Profile
    • jinxtergames
Re: move along a string of gameobjects from start to end
« Reply #8 on: January 10, 2018, 12:08:22 AM »
Hi,
When you generate, add them to the array (you can leave the array empty at the start or have some preset already).
The 'string length' takes care of it when it is a dynamic size :)

A disadvantage is that they should be placed in sequence into the array.

If you need a different way let me know.

and thank you to subscribe to my channel :)

S0ULART

  • Playmaker Newbie
  • *
  • Posts: 22
    • View Profile
Re: move along a string of gameobjects from start to end
« Reply #9 on: January 10, 2018, 04:54:24 AM »
Yes exactly yesterday I figured out that I have to generate the string by counting the tags of my node objects. After that I tried to put a FSM into my node prefab that checks every index from start to end of the string with an object with the tag. If it finds it goes index +1 to the next spot checking for the tag. When it finds an empty spot without an object with the tag the node sets itself into the Array with the 'array add'  action.

Although it doesn't work yet and I don't know if the index order will be sorted or messed up. Is there maybe a simpler approach?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 3504
    • View Profile
    • jinxtergames
Re: move along a string of gameobjects from start to end
« Reply #10 on: January 10, 2018, 08:17:10 AM »
hi.
I am not sure what you mean, can you show me a video or some gifs/images.

S0ULART

  • Playmaker Newbie
  • *
  • Posts: 22
    • View Profile
Re: move along a string of gameobjects from start to end
« Reply #11 on: January 10, 2018, 02:03:19 PM »
I've made a short Video to explain better.
https://www.dropbox.com/s/xf32cl034ekvtpu/Playmaker.wmv?dl=0

Okay so here are my steps I've done that you can see in the video:

01. I recreated your video Sample project and modified it a bit so that I can move seemless between the cubes with A and D keys.

02.  Then I made a FSM that randomizes the size of my cube objects that get spawned on runtime

03.  Then I made a FSM that checks the tag count of those cubes (how many cubes are in the scene?) to make my array size dynamic

04.  Another FSM then checks for empty slots in the array to fill in the index place with the next spawned cube object. e.g check if index 0 is without tag "node" then place a cube instance in it. If its tagged with "node" add 1 to the index and check the next index number which would be 1 (2, 3 ,4 etc)

_
Somehow this approach still doesn't seem to work and I have thoughts that I'm maybe overcomplicating things here.
« Last Edit: January 10, 2018, 02:06:23 PM by S0ULART »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 3504
    • View Profile
    • jinxtergames
Re: move along a string of gameobjects from start to end
« Reply #12 on: January 10, 2018, 11:51:19 PM »
Hi.
I think you missed the part @5:04 on the video,
Action sequence needs to be enabled.

If this is enabled Each action in the state will wait until the previous state is finished.
So you might need to place the wait and the key key up in a separate state as the wait will not activate then.
You can see if Action sequence is enabled if there is a v formed in the line between the actions.

S0ULART

  • Playmaker Newbie
  • *
  • Posts: 22
    • View Profile
Re: move along a string of gameobjects from start to end
« Reply #13 on: January 11, 2018, 03:22:41 AM »
I did turn on Action sequence and your sample works for me as intended but I can't get a dynamic array of cubes get to work that are being created at start trough which I can navigate.

So every start there is a different number of cubes. One time it's maybe 3 another 6 or 5. Check out my video above to see my approach.


djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 3504
    • View Profile
    • jinxtergames
Re: move along a string of gameobjects from start to end
« Reply #14 on: January 11, 2018, 09:59:34 AM »
Hi.
Make the array on the 'FSM Simple Navigation' empty.
Then on 'FSM Dyn amic Objects Spawn' make an (empty) array.
Then in the 'Create Object' State when you create an object, store the object in a variable and then use the variable to add it to the array.

Then in the 'End' state use Set Fsm Array and copy the array to the 'FSM Simple Navigation' array and check 'Copy Values'