Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Derphouse on August 07, 2013, 08:09:12 AM

Title: Generate path to follow with Mouse Pick[SOLVED]
Post by: Derphouse on August 07, 2013, 08:09:12 AM
Basically I was using the Mouse Pick to get my character to move to a position.

I am definitely in the beginner stage regarding game making, but using a Mouse Pick to get the position was easy enough. The problem is that I need be able to create several new points afterwards, and have the character go through all of them. I guess I am asking how I continuously store these new points so they make a path?
Title: Re: Generate path to follow with Mouse Pick
Post by: Derphouse on August 07, 2013, 05:51:52 PM
Is it really that complicated? :/
Title: Re: Generate path to follow with Mouse Pick
Post by: sebaslive on August 07, 2013, 06:04:54 PM
Not entirely sure what you mean but I assume you want to store the position of each point that is clicked so that it follows those points one by one?

I would suggest arraymaker. Check out the samples that are included in the package that would help out. https://hutonggames.fogbugz.com/default.asp?W715

Another way I suppose would be to create an empty game object that places the move to position and have a difference action from player position to empty gameobject position so it always goes to the closest empty game object but the arraymaker would organize it much better and have them numbered as a path.

Lane also has an action up called clickmove.unityPackage that you can check out.

http://hutonggames.com/playmakerforum/index.php?topic=3122.msg14297#msg14297
Title: Re: Generate path to follow with Mouse Pick
Post by: Derphouse on August 07, 2013, 06:27:41 PM
I will try out ArrayMaker and see what happens.

Thanks for the help. :)
Title: Re: Generate path to follow with Mouse Pick
Post by: Derphouse on August 10, 2013, 06:29:34 AM
Tbh. my "trying it out" seems to be overqualifying myself.

I might need some help on the ArrayMaker solution. As to how do I specifically store several points etc. I am really not experienced here.

My closest attempt was to continuously switch from one state to another as you click to make a point for the path. This way it would jump between two on-going points. The problem, however, you can easily place 3 or in theory, 10 points, before the player reaches the first.

So I guess ArrayMaker is the way to go, but I could really use any help on the matter.
Title: Re: Generate path to follow with Mouse Pick
Post by: escpodgames on August 10, 2013, 07:16:20 AM
What functionality are you after exactly.

If the player clicks, it creates a point to move to, if the player clicks again and the player hasn't reached the first, it adds it as a second way point IF it isn't closer then the first? and also a set max distance from the first point.

That's just an example of what you might be after ... but would be helpful to hear exactly with all the possible outcomes what you want.
Title: Re: Generate path to follow with Mouse Pick
Post by: Derphouse on August 10, 2013, 07:30:49 AM
Sorry, I tend to forget the clear picture of what I want is restricted to my mind, lol.


Well, basically you're suppose to create a path. And clicking on the surface creates a waypoint. Nothing will interfere the player from going to this waypoint. So you basically create a path that is restricted to go through ALL waypoints. Which means I need to store the position of all the waypoints made, and make sure the player doesn't skip, or ignores any of them, etc.

I hope this makes more sense.
Title: Re: Generate path to follow with Mouse Pick
Post by: escpodgames on August 10, 2013, 08:49:28 AM
Makes perfect sense!

Array maker is what you will need so you're on the right track.

Click one position is stores in an array of vector 3's (I assume you can use array maker - if not I can write a step by step for ya)
Player walks to that point using a separate FSM
Check the distance to this point everyframe (or some form of checking if the player has reached the point. If the player hasn't reached this point add the second click as a second vector3 to the array.
When the player gets to a point, remove it from the array and get the next position (if there is one) and move to that. this sequence will end when there are no more vector3 variables in the array.

Hope you understand ... if not just tell me and ill write it .... when it's not 2am :P
Title: Re: Generate path to follow with Mouse Pick
Post by: Derphouse on August 10, 2013, 09:02:14 AM
Haha, I appreciate the help..

but yes, I do think my problem persists in not completely understanding ArrayMaker, even though it sounds like it makes sense, I'd much appreciate a step by step if you get the time for it!

Thanks in advance! :)
Title: Re: Generate path to follow with Mouse Pick
Post by: escpodgames on August 10, 2013, 08:19:54 PM
Ok, ill make some screen grabs .. will be easier

Title: Re: Generate path to follow with Mouse Pick
Post by: Derphouse on August 11, 2013, 02:17:47 PM
Sounds awesome! :)
Title: Re: Generate path to follow with Mouse Pick
Post by: escpodgames on August 15, 2013, 08:44:35 AM
Here ya go, better than screens, hope it helps :D Any questions just ask.
Title: Re: Generate path to follow with Mouse Pick
Post by: Derphouse on August 15, 2013, 09:01:17 AM
It looks great, I'm getting an error that I don't understand, considering both the type and the variable is vector3

"The fsmVar value <UnityEngine.Vector3> doesn't match the value <System.Single>"

EDIT: Works very nice! It seems it was just set to float instead of v3 in the input for the array list.
Title: Re: Generate path to follow with Mouse Pick
Post by: escpodgames on August 15, 2013, 05:29:02 PM
Hmmm weird, it's a vector3 on mine and I tested it on both my mac and pc ... oh well ;P

Is that what you were after?
Title: Re: Generate path to follow with Mouse Pick
Post by: gegagome on August 15, 2013, 05:41:46 PM
I think you need a plugin called::: Spark Plug Tools Path Drawing System
https://www.assetstore.unity3d.com/#/content/5619
I am testing it in my app, and it is great!

Haven't implemented it in PlayMaker but I'm here to learn more
Title: Re: Generate path to follow with Mouse Pick
Post by: Derphouse on August 15, 2013, 07:34:39 PM
Hmmm weird, it's a vector3 on mine and I tested it on both my mac and pc ... oh well ;P

Is that what you were after?

It's exactly what I was after! Thank you very much for the help :)
Title: Re: Generate path to follow with Mouse Pick[SOLVED]
Post by: Saputo on September 07, 2013, 11:53:55 AM
"The fsmVar value <UnityEngine.Vector3> doesn't match the value <System.Single>"

EDIT: Works very nice! It seems it was just set to float instead of v3 in the input for the array list.


How was this Fixed I have the Same Error, but idk what or w.e the Inputs is I looked in the Input under edit, but there is no ArayList there, and I looked on the Inspector, I dont see were to go to fix this, i feel kinda dumb :(