I want to make a game where the player can move the object using the position of the end of a raycast, when the ray cast is long enough.
Is this possible?
This is possible. Basically, you will need:
- Colliders that the Raycast will hit and return information from.
- A combination of scripts such as: 1) Camera.main.ScreenPointToRay, and 2) Physics.Raycast, where the origin and destination of the ray returned by ScreenPointToray is used as parameters in Physics.Raycase.
An unrelated example of using this would be reacting when the ray intersects a collider:
mouseRay = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(mouseRay.origin, mouseRay.direction, out hitInfo, 100.0f))
{
// update the touch controller with touch information
}