How to change dragging speed of draggable object

I need to figure out how to change the speed of dragging an object for a game you control the character kind of like in other games were you click an area on the map and the player goes to it but I am making it so that you drag the player but I don’t want the player to easily get through the level by making dragging him extremely fast.

You would need to build your own event logic that somehow tracks your mouse movements then applies them to your dragged object at whatever speed you want.

The default draggable behavior won’t allow you to do this.

1 Like

do i need to use the javascript?

No need for javascript, you can do it all with events:

[edit] whoops, wrong image. give me a minute…

its ok i was actully copying that lol

Yeah, sorry about that one. It was just to allow dragging for an object, not vary the speed.

Try this. Use the pathfinding behaviour on the object you want to follow the mouse:

You can set the speed in the pathfinding behaviour configuration

1 Like

could you maybe explain how this works?

Pathfinding is a type of AI function in which you tell the pathfinding object find a path to a position while avoiding specific obstacles (objects with the pathfinding obstacle behaviour).

When the left mouse button is held, it sets the target position to the mouse’s position, and the pathfinding behaviour will move the object to that target. When the mouse is released, the target is set to the object’s current position, effectively stopping it (there’s no action available to stop an object partway along it’s path towards the target position)

thank you I will test it now if it works I will tell you if it works. I originally wanted to drag the player because I couldn’t figure out how to do it the way you are teaching me thank you again.

it works the the character doesn’t stop move when I stop dragging it continues the move in the same direction

With the events in my screen shot, the mouse button needs to be released to get it to stop. Stopping the mouse won’t effect it.

If you want to stop dragging when the mouse stops moving, it’ll require a bit more work. Try this :