playMaker

Author Topic: Mouse Pick 2D stores in Vector2 but Move Toward does not use Vector2  (Read 5046 times)

sidd4friends

  • Playmaker Newbie
  • *
  • Posts: 17
Hello Friends,

I have been going through the tutorials for Playmaker and really getting to know the tool much better. However I have encountered a small problem.

In my 2D project, I am using the Mouse Pick 2D action which stores the store point as a Vector 2 variable. However the actions which I can use to move my object like Move Toward, Translate, iTween Move To only uses a Vector 3 variable as a Target Position.

I have also tried to get the Mouse Y and Mouse X positions on mouse button down and store it into a Vector3 variable by using the Vector3 Add XYZ action and then use this variable to move my object using Move Toward, but it doesn't seem to work.

Please guide me as how I can use the Mouse Pick 2D action to move my object to the position of my mouse click in a 2D game. BTW, thanks for this amazing tool :D

sidd4friends

  • Playmaker Newbie
  • *
  • Posts: 17
Can anyone please help me out in how to use the vector 2 position picked up by Mouse Pick 2D as the current Move Toward and iTween Move To actions use the Vector 3 positions. Sorry if I am missing something basic as I am very new to Playmaker :)

cliffordthedog

  • Playmaker Newbie
  • *
  • Posts: 2
I am having the same problem. I am very new to both Playmaker and Unity, and it really feels like I must be missing something obvious in regards to 2d. I couldn't even figure out how to animate a simple sprite in Playmaker until I found a custom action on the ecosystem addon.

Anyway, I found a solution for what your trying to do, as it is the same thing I am attempting to do. It uses the "itween move to" action. Which I didn't even look into until I read your post (Thanks BTW).
Here's what I did:

1. Download these custom actions for working with vector2:
https://hutonggames.fogbugz.com/default.asp?W1004

2. Use the "Get Vector2 XY" action. This takes a vector2 and stores the X and Y components in separate variables. Plug in your vector from the "Mouse Pick 2d" action, and then create two variables to store the values of X and Y.

3. Next, use the "Set Vector3 XYZ" action. This will let you create a vector3 from the X and Y variables you stored earlier in step 2. Just leave the Z field to none.

4. With your new Vector3, plug it into the 'vector position' field for the "itween move to" action. In the 'look at' section you will find an 'Axis' field. Make sure to set it to the 'Z' axis. If you don't, your sprite will rotate out of the XY axis. It should now move towards what you click.


Problems
Now I just need to figure out how to cancel "itween move to" while the sprite is still moving. As it is right now (in my setup at least), I can't click somewhere else while the sprite is still moving. It has to finish the move before I can click a new location to move too.

Also, I still don't know how to rotate the sprite to look at the position it is walking towards. There is an "add torque 2d" action that will rotate a sprite (presumably), but it only accepts a single float variable. I am unsure how to make that work with my vector2 position. Same with the various other rotate actions, I am not sure how to work with them in a 2d space (or at all really).



*USING "MOVE TOWARD" ACTION: For me, it only moves near what my mouse has clicked. As in, the sprite starts moving towards the point, then stops just before it. If I keep clicking, it takes small little stutter steps and will eventually get to the point I click. I'm not sure whether something in my scene setup is causing this, or if it's something to do with the "move towards" action I do not understand.

« Last Edit: July 26, 2014, 02:00:34 PM by cliffordthedog »

sidd4friends

  • Playmaker Newbie
  • *
  • Posts: 17
Hi Clifford, thanks for replying man :) I would definitely try this out....thanks a lot man and all the best with Playmaker and Unity :D