Detect that the user wants to move forward after a collision

I am trying to use the mouse to move objects in the editor. When a collision occurs, if the user continues to move the mouse a certain distance X towards the collided object, the main object will jump on top of the collided object (similar to the attached video). What is the best approach to detect this user behavior? I have considered keywords like Raycaster and Collision vector, but I have not been able to implement it yet.

Anyone have idea for this section?
Thank you~

Without ever having worked with the editor:

I would assume, that you will have to maintain a suitable circular buffer of the recent history. If a collision with the current obstacle occurred before, let’s say, within the last “n” frames or so, interprete the current collision with the same object as the intention to jump on top of the obstacle.

1 Like

Thank you so much. It is a good idea and is worth testing

Hey there, you could also look at the source code.

This line looks relevant, inside onPointerMove of DragControls:

three.js/examples/jsm/controls/DragControls.js at d6c3bcc75e7953af34436cb6518d8130113bf17b · mrdoob/three.js · GitHub

1 Like