playMaker

Author Topic: Wrapping Head around how PM compares objects relative to others[SOLVED]  (Read 2362 times)

part12studios

  • Playmaker Newbie
  • *
  • Posts: 41
Hi everyone,

So I'm a long time Construct 2 and 3 user, but I'm ready to master Playmaker. 

One of the basic things that I took for granted with C2 is to be able to easily compare something.  For example.  Let's say I make a pool of 5 sets of obstacles.  I would want them to "teleport" back to the other side (endless runner for example) when the object is number of units of space to then jump over.

As I go through various actions in PM, I find I'm having to figure out which things what certain data types and this proves confusing to really give PM what it wants so I can do what I want.

In my mind I would think I could just setup an FSM that is like...  "when object is 5 units behind player, move object +10 X units ahead of the player.

I'm not saying PM can't do this, but on a gut level I think to myself I would in the object's state machine, continuously compare  object X - player X.  when answer is greater than 10, move object +10 x units.

I imagine each "clone" of the original prefab would be measuring this individually so when each individual's distance goes over the 10 unit value they operate independently. 

This has proven to be difficult for me to express because for example i would (gut instinct) do something like "get vector 3 value" of an object, which I assume is the objects XYZ value, but the action wants a vector3 variable.. 

This has stumped me for awhile and I think that if I can wrap my head around how PM properly compares various values would open up a lot of possibilities.

Thanks!
Caleb
« Last Edit: July 12, 2018, 01:28:15 PM by djaydino »

DanielThomas

  • Beta Group
  • Full Member
  • *
  • Posts: 150
Re: Wrapping Head around how PM compares objects relative to others
« Reply #1 on: July 09, 2018, 07:20:01 AM »
I think this is what you're trying to do?
This would get the distance and see if it's greater than 5. You would of course need to tweak to fit your situation and which direction you use.

part12studios

  • Playmaker Newbie
  • *
  • Posts: 41
Re: Wrapping Head around how PM compares objects relative to others
« Reply #2 on: July 09, 2018, 09:04:01 AM »
oooo yes, this looks promising.  some new actions I wasn't familiar with.  I'm going to experiment with this and see where it gets me!  :)   Definitely a big help to see a working example. 

the main thing i'm struggling with i think is how things want to look at variables in some cases and not game objects..  but the game objects have the vector3 info.. and i can't compare a v3 with a float..  and i have yet to see how a v3 would compare with another v3 within a given object so this looks great!  I will report back

Sincerely,
Caleb

DanielThomas

  • Beta Group
  • Full Member
  • *
  • Posts: 150
Re: Wrapping Head around how PM compares objects relative to others
« Reply #3 on: July 09, 2018, 09:10:06 AM »
A vector3 is three values (x,y,z), so you can't compare one value with two. So you will need to get one of the values out that you want to compare. For an example as in the screenshot I made above you just take the X value from the vector3.

You can compare two vectors3, of course.

part12studios

  • Playmaker Newbie
  • *
  • Posts: 41
Re: Wrapping Head around how PM compares objects relative to others
« Reply #4 on: July 09, 2018, 09:18:57 AM »
cool i'm diving into it now to see.  that does make sense though.. to be able to "extract" a particular value and then compare those.

part12studios

  • Playmaker Newbie
  • *
  • Posts: 41
Re: Wrapping Head around how PM compares objects relative to others
« Reply #5 on: July 09, 2018, 06:58:40 PM »
so i see the way you're doing it, but i'm hitting an issue.  i've been slamming my head against this for awhile today..    i'm spawning "clones" of the flappy bird pipes.  these are prefabs I made..

now i did try to be careful that the prefabs are current to the latest version of the "pipes" sets to have all of the rules in place.  i'm putting the rules in each clone because i figure each clone needs to be doing it's own distance check

however this is where things get weird...

when I do my compare.. i can drag the prefab into the first "get position".. but then when i want to compare it to my "player" object the player object won't drag into the 2nd "get position".. to get around this (and completely shooting in the dark) i did make a prefab player object, but i'm skeptical that this is right because i don't call on the prefab player object anywhere..   but i don't get why i can't compare the actual player object...

everything i think is right...  all i'm really trying to do right now is print text to see what the math is when i do the float operator (haven't gotten past that) so i can see the operator is even working..   i have the operator "add" to a global variable..  all of it looks right and i think is right..  but the whole prefab vers objects from the hierarchy is where things first felt wrong.. 

DanielThomas

  • Beta Group
  • Full Member
  • *
  • Posts: 150
Re: Wrapping Head around how PM compares objects relative to others
« Reply #6 on: July 10, 2018, 06:06:59 AM »
I honestly have no clue what you mean. It's better you post some screenshots of your FSM's and objects inspector.

part12studios

  • Playmaker Newbie
  • *
  • Posts: 41
Re: Wrapping Head around how PM compares objects relative to others
« Reply #7 on: July 10, 2018, 07:17:21 AM »
yea sorry, i think i made a mistake involving prefabs.  i'm going to see if I can avoid using them. 

one of the things I wasn't sure about (still not 100%) is when spawning copies of a given object.  how do I insure that each copy acts independently and not have all objects act on the same action..   but i think i was overthinking things. 

I have more things to try today and yes I'll be sure to include screenshots as well. 

your approach looks good and probably will work.. I just have to figure out what math to apply exactly to get usable data..  as it is i seem to be getting a constant -16 text display in the UI (which is an improvement as yesterday I was getting a constant 0 which is what the UI was set to anyway.

So yea I have more to try today and I can't tell you how much I appreciate your feedback on this question!  TYTYTY! :)

DanielThomas

  • Beta Group
  • Full Member
  • *
  • Posts: 150
Re: Wrapping Head around how PM compares objects relative to others
« Reply #8 on: July 10, 2018, 08:27:43 AM »
Still, I'm not sure what you mean.  This isn't really Playmaker specific and it would be better to just study Unity documentation about prefabs as that would give more detailed information than I could write up in here.

As mentioned above, I can't help if you don't post screenshots of your current FSM and game objects.

part12studios

  • Playmaker Newbie
  • *
  • Posts: 41
Re: Wrapping Head around how PM compares objects relative to others
« Reply #9 on: July 10, 2018, 08:45:47 AM »
OK so now I'm seeing some movement.. i found some issues and it was my mistake of course. 

Completely understood about the need for screenshots. 

I'm thinking now that i can see the values change, this is a big help, I'm going to see how far I can get with that! :)

part12studios

  • Playmaker Newbie
  • *
  • Posts: 41
Re: Wrapping Head around how PM compares objects relative to others
« Reply #10 on: July 11, 2018, 12:15:10 PM »
great success!  ;)   

So yes I was able too after a bit of trial and error able to spawn 6 sets of pipe and take the 7th (original in scene one) and work it out so it would place nicely with it's cloned counterparts. 

Thanks for the pointers and the comparison stuff!   I never used the term "operator" in Construct so it was out of my lexicon, but now i can see how it would work. 

Thanks!
Caleb