# Dragging fast... Precise Collision ?

0 favourites
• 6 posts
From the Asset Store
Full game Construct 2 and Construct 3 to post on Google Play
• Hi All,

I'm messing around with 2 sprites trying to understand how can I make each one STOP when colliding each other no matter what speed I will be dragging it...

Should I use Solid? should I not? I don't know.

What is the most efficient way to do it? or easiest? or basically any way will be interesting for me to learn how I can achieve that.

In case you want to show it to me, here is the project:

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• One way would be to loop between the previous and current positions and check for overlaps there.

If you’d like an algorithm, this should work, or at least some variation of this would be acceptable.

``````Global number x0=0
Global number y0=0
Global number x1=0
Global number y1=0
Global number steps=0

Sprite: is dragging
Or
Sprite: on drop
— Set x1 to sprite.x
— set y1 to sprite.y
— set steps to max(abs(x1-x0),abs(y1-y0))
— repeat steps+1 times
— — sprite: set x to lerp(x0,x1,loopindex/steps)
— — sprite: set y to lerp(y0,y1,loopindex/steps)
— — sprite: overlaps sprite2
— — — stop loop
— — — sprite: set x to lerp(x0,x1,(loopindex-1)/steps)
— — — sprite: set y to lerp(y0,y1,(loopindex-1)/steps)

Sprite: on drag start
Or
Sprite: is dragging
— set x0 to sprite.x
— set y0 to sprite.y``````
• It's easier to use BBBox** expressions.

dropbox.com/s/cxojv9oqh15f870/Dragging%20Precise%20Collision2.c3p

• Thanks for sharing your solutions, I appreciate it.

I will give it a a try soon!

Any other/extra solutions are welcome, it's always nice to learn from different options.

• Thanks for sharing newt :)

It's not exactly what I'm trying to achieve but this is VERY useful!

EDIT:

After playing with it for few minutes, I've managed to make it work nicely, here is the example if anyone interested:

This is one of the tools I wish it was built-in as a part of C3, maybe as part of the Drag-N-Drop itself instead of extra object, but anything works! :)

• 6 posts