playMaker

Author Topic: How do I make this math?  (Read 7183 times)

LogLady

  • Full Member
  • ***
  • Posts: 150
How do I make this math?
« on: January 09, 2014, 06:38:51 PM »
Hello!

I'm a bit new to Unity + Playmaker and don't know how to make this using Playmaker:

Code: [Select]
Left mouse key is down
[i]Sqr[/i]((X position "player")-X position mouse) [i]pow 2[/i] + (Y position "player")-Y position mouse) [i]pow 2[/i]) > 5

Set player to Look at mouse X 0, Y 0

Left mouse key is down
[i]Sqr[/i]((X position "player")-X position mouse) [i]pow 2[/i] + (Y position "player")-Y position mouse) [i]pow 2[/i]) > [b]Speed[/b] "player" + 5

Set [b]Speed[/b] to Min([b]Speed[/b] "player" + 5, 60)

I used this code to move the "player" in a 2D space with a bit of ease in/out. While the mouse key is down it "accelerates" towards the mouse position (and keep following the mouse), stops when in the same position of the mouse pointer while the left key is pressed and loses speed until stop with ease even without reaching the last mouse position were the left mouse key was down.

It worked very well on Multimedia Fusion but I couldn't figure how to achieve this using Playmaker. I tried iTween, Add Force, Move To and none gave me the same result as the code above.

I don't have any intention to stick with this code at any cost so if you know another way to achieve the same thing or want to share how to use this code on Playmaker, please help.

Thanks in advance!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How do I make this math?
« Reply #1 on: January 10, 2014, 08:12:36 AM »
Hi,

 can you paste the actual code as is? this is pseudo code you have written right?

bye,

 Jean

LogLady

  • Full Member
  • ***
  • Posts: 150
Re: How do I make this math?
« Reply #2 on: January 10, 2014, 11:27:46 AM »
Hello!

I described the code as I did in multimedia fusion. I don't have a programming background so I don't know how to show it in code language...

The movement is the same like in this video:
Thanks!

colpolstudios

  • Sr. Member
  • ****
  • Posts: 370
Re: How do I make this math?
« Reply #3 on: January 11, 2014, 06:08:11 PM »
Hi LogLady, as a newbee myself to playmaker I tried myself to use code from mmf.

A lot of things are the same but different in so many ways it would be hard to put it all down here.

Use the code from mmf but think, what way do I need to do the same actions.

By using the itween actions you wont need to worry about the math I think.

I lacked the basic understanding of the very basics but playmaker has helped me understand so much.

I considered going back to mmf which I have, but Playmaker and unity is where I want to be.

The power you have here is outstanding and the community is so helpful.






LogLady

  • Full Member
  • ***
  • Posts: 150
Re: How do I make this math?
« Reply #4 on: January 13, 2014, 10:11:49 AM »
The problem with iTween is that I couldn't accomplish the same result of the code I used before. :(

I couldn't:

- stop the movement with easing (slowing down until stop) when mouse button is up. I got the easing in (start movement) but when the mouse button is up it stop suddenly or goes to the last vector3 position.

- stop the movement but without the object reaching the last place where the mouse button were down;

- move the object again without letting the mouse button down if the object reach the same position of the mouse pointer. At now, it stops the movement and I need to click again to move.

Thanks in advance!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How do I make this math?
« Reply #5 on: January 14, 2014, 07:03:08 AM »
Hi,

 can you get bump this thread next week? I'll have ac lose and provide a working sample. But I am travelling now, so I can't really produce anything.

Bye,

 Jean

LogLady

  • Full Member
  • ***
  • Posts: 150
Re: How do I make this math?
« Reply #6 on: January 14, 2014, 08:09:28 AM »
For sure, Jean!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How do I make this math?
« Reply #7 on: January 21, 2014, 02:36:57 AM »
Hi,

 ok, sorry for this delay, slowly but surely catching up now :)

 please find a working sample attached. Click on screen adn the sphere will move towards your mouse.

I think this is the behavior you expect. In terms of math, Unity and PlayMaker brings so much on the table that you don't need to compute all this manually. Typically, you have functions to express a screen position into a work position and some convenient actions to move an object towards a target.

 So study this example, if you don't understand how it works let me know.

bye,

 Jean

LogLady

  • Full Member
  • ***
  • Posts: 150
Re: How do I make this math?
« Reply #8 on: January 21, 2014, 07:40:44 AM »
Hello Jean!

Thanks for your reply!

Sadly it's not what I'm looking for. Do you mind if I send to you the original project so you can play and see exactly the kind of movement I'm talking about?

Cheers!

LogLady

  • Full Member
  • ***
  • Posts: 150
Re: How do I make this math?
« Reply #9 on: January 21, 2014, 03:42:15 PM »
Jean, I PM you with a dropbox link to the file.

Cheers!

LogLady

  • Full Member
  • ***
  • Posts: 150
Re: How do I make this math?
« Reply #10 on: January 28, 2014, 06:45:53 AM »
Hello Jean!

Any news?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How do I make this math?
« Reply #11 on: January 29, 2014, 12:53:30 PM »
Hi,

Ok, I see, it's a simple spring based connection. I'll work on a sample tomorow first thing, I have an action just for that and it's straight forward to apply.


 Bye,

 Jean

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How do I make this math?
« Reply #12 on: January 30, 2014, 03:30:36 AM »
Hi,

 actually, it's way easier and everything is there to do that without the need for custom actions.

I have attached a sample, where as you click, the cube will move towards the mouse point.

 The set up is very simple, one object is following the mouse using the action "mouse follow", then the cube is using the "move towards" action to move towards this target if the mouse left button is down.

notes:

-- check the way the camera is setup, it's important. The z distance is the same as the mouse follow setup so that everything stays in the same 3d plane

-- the move toward action has its Finish distance set to 0 so that it never stops catching up even if at some point it's perfectly positionned where the target is.

 If you have questions let me know.

 Bye,

 Jean

« Last Edit: January 31, 2014, 06:08:01 AM by jeanfabre »

LogLady

  • Full Member
  • ***
  • Posts: 150
Re: How do I make this math?
« Reply #13 on: January 30, 2014, 11:21:21 AM »
Hi Jean!

Thanks for your reply.

I couldn't understand the example you made. Inside the Mouse game object is a "missing Action" inside named FollowMouse. Are you using it for a placeholder (as described here: https://hutonggames.fogbugz.com/default.asp?W838) or my Playmaker is missing this action?

Quote
-- the move toward action has its Finish distance set to 0 so that it never stops catching up even if at some point it's perfectly positionned where the target is.

I tried it before but couldn't set an easing to it (as it originally has on the game I sent to you).

Again, thanks for your time and patience!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How do I make this math?
« Reply #14 on: January 31, 2014, 06:07:19 AM »
D'oh,

 Updated the package, please redownload.

bye,

 Jean