I’m working on a game that need to drag the existed clone object (that created by raycast) by mouse.
I’m asking whether there is a tutorial for that.
Thanks a lot.
This is my project:
There isn’t one, not for that type of scenario.
There are several ways you can do it, some of which are a bit tricky.
I’m assuming you want to drag an item across the ground? While you can do a ray cast from the object in the same direction as the mouse -> camera -> world.
The tricky part comes where you want the physics object to ‘sit’ on the surface which requires you to know how big the object is to move it above the intersection point.
It gets worse when you have an object that can be any orientation and therefore the distance between the intersection point and the pivot point of the object can change.
Another alternative is to use forces to ‘push’ the object to the cursor. Not the most responsive but can work for some styles of game.
Thanks a lot. I’ll try my best.