PlayMaker Help & Tips > iOS Help

Add velocity to object based on drag velocity

(1/3) > >>

OleP:
Hi there.
I've made a FSM to drag and drop a gameobject on a plane(based on the MouseClickToDrag sample). But when I release the gameobject, I want to add velocity to it, based on the velocity it had on the point of release. The goal is to make the gameobject behave like an ice puck, and bounce around inside a 2D frame.

 I currently got 5 states:
Wait for click -> Clicked world? -> clicked object? -> drag object -> add velocity

On the "drag object" state, I've added a "Get Velocity" action, and stored it into a vector3 variable. On the "add velocity" state, I've added a "Add Velocity" action, and chosen the vector3 variable as source.

And here comes the problem: How do I measure the velocity the gameobject has on the point of release? I'm using "Mouse Pick" and "Set position", but when I drag it around, it dosen't measure any velocity.


I hope I've explained it well enough for you guys to understand. If not, I can post the whole project for you.
If you know another way to do this, feel free to post the suggestion.

jeanfabre:
Hi,

 To measure velocity,  store the delta position between two updates and the also the deltatime that goes with it. the velocity is then the deltaposition magnitude divided by the deltatime it took.

The speed would be then expressed in unity/seconds.

Is that clearer? Or do you know this already and have problem implementing it in playmaker?

Bye,

 Jean


 

OleP:
Thank you.

It sure makes sense when you say it like that. But as you mention youself, I don't really know how to implement this with playmaker..

I'm trying to just measure the velocity(of the drag) in one state, and add it to the object in the next state. But it does not measure velocity when I drag the object, only when it reacts with the physic engine.

I have attacted my scene if you got a minut to look at it.. I've been playing around with this problem for a couple of days now :(

EDIT:
It's like when I drag the object, it ignores all physics. I can move it through the walls too. If I find a solution to that problem, I think it can measure the velocity too.. maybe..

MODERATION EDIT : removed package. Make sure you don't include the playmaker dll when packing...

jeanfabre:
Hi,

 I'll have a look over the week end ( sorry, a bit busy at the moment).

 bye,

 Jean

OleP:

--- Quote from: jeanfabre on February 16, 2012, 05:39:55 AM ---Hi,

 I'll have a look over the week end ( sorry, a bit busy at the moment).

 bye,

 Jean

--- End quote ---

Thank you.. :)!

Navigation

[0] Message Index

[#] Next page

Go to full version