#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# Dragging an object and let it go with the velocity before released

Posts: 140Member
edited June 2016

Ok so my question is simple and what I want to do kind of works in my project but so weird that the object sometimes goes in the wrong direction when I let it go.

So I have an actor what I can drag around on the x axis with an offset (I can grab the actor where I want without having to deal with the problem that it constrains to the Mouse Position when I touch it.) and now when I don't press it anymore I want that it keeps moving with the velocity before I released it in the direction I dragged it.

• London, UK.Posts: 12,822Member

Constrain Liner Velocity X to 30*( game.Mouse.Position.X - self.Position.X )

• London, UK.Posts: 12,822Member
edited June 2016

With offset ("O"):

Change O to mouse x - self x
Constrain Liner Velocity x to 30 *(mouse x - self x) -30 * O

• Posts: 140Member

@Socks said:
With offset ("O"):

Change O to mouse x - self x
Constrain Liner Velocity x to 30 *(mouse x - self x) -30 * O

(**** you did understand me wrong. You thought that I want to keep it constraining to my mouse position after I released it? I want to let it move freely after that.)
What I want to achieve
Actor A:
When touch is pressed it constrains to my mouse position (with the offset) on the x axis. Now I start dragging it with a speed 'z' and then I release the object, so touch isn't pressed anymore it's now released. Now I want that the object keeps moving with the 'z' speed on the x axis in the direction I dragged it.

• London, UK.Posts: 12,822Member

@Creator97 said:
you did understand me wrong.

Did you try the suggested code ?

• Posts: 140Member

@Socks said:

@Creator97 said:
you did understand me wrong.

Did you try the suggested code ?

of course and it keeps constraining to the mouse position even if touch is released.
So you didn't understand me wrong?

• London, UK.Posts: 12,822Member

@Creator97 said:

@Socks said:

@Creator97 said:
you did understand me wrong.

Did you try the suggested code ?

of course and it keeps constraining to the mouse position even if touch is released.
So you didn't understand me wrong?

Can you share a quick screenshot of your rule ?

• Posts: 140Member

@Socks said:

@Creator97 said:

@Socks said:

@Creator97 said:
you did understand me wrong.

Did you try the suggested code ?

of course and it keeps constraining to the mouse position even if touch is released.
So you didn't understand me wrong?

Can you share a quick screenshot of your rule ?

of my rule that didn't work or of the rule I copied from your post?

• London, UK.Posts: 12,822Member

@Creator97 said:
of my rule that didn't work or of the rule I copied from your post?

The rule I suggested.

• Posts: 140Member

@Socks said:

@Creator97 said:
of my rule that didn't work or of the rule I copied from your post?

The rule I suggested.

ok here is it.

• Posts: 140Member
• London, UK.Posts: 12,822Member
edited June 2016

Your rule (in the linked image) is nothing like what I suggested ! I have one change attribute and one constrain, your rule has one change attribute and three constrain attributes.

Give my suggested code a quick try, it will take less than a minute to try and it really does work !

• Posts: 140Member

@Socks said:
Your rule (in the linked image) is nothing like what I suggested !

I have one change attribute and one constrain, your rule has one change attribute and three constrain attributes.

Why not give my suggested code a quick try, it will take less than a minute to try and it does work !

it s exactly what you suggested it was just added to my old code because I thought I still need that basic stuff and you're just adding the "releasing part"

so in fact your code does works great when included in a touch is pressed rule. So where does that 30 come from?

• Posts: 140Member

and yeah quote your own second post that I can click 'yes' after did that answer your question because i clicked already no...

• London, UK.Posts: 12,822Member

@Creator97 said:
where does that 30 come from?

From the world of numbers

Higher values = tighter tracking
Lower values = looser tracking

• Posts: 1,040Member, PRO
edited June 2016

@Socks said:

@Creator97 said:
where does that 30 come from?

From the world of numbers

When a Lady 15 and a Gentleman 15 like each other a lot they become really close and have what's called "addition" and that's where 30's come from.