0 answers · asked · Lesson: Point and Click Movement · Course: Game C# Programming Bootcamp

The sphere goes back to the world origin

When there is no impact point between the raycast and the object with the right mask, the sphere goes back to where it was (world origin). To make it stay where it is when the raycast doesn't collide with the floor then we should include :
" moveTarget = new Vector3(hit.point.x, character.position.y, hit.point.z);"
Inside :
"if (Physics.Raycast(ray, out hit, 100f, mask))

Debug.Log("We hit " +;