Ray. Find Point without Physic Collision!

Hi mates!

Im using ScreenPointToRay to get a hit on a gameObject.
Now I want to move and drag it around the world, but i dont want to create a floor geometry, just to catch Physic.RayCast.

All I need is the point, where Camera.main.ScreenPointToRay hits the point Vector3 (x,0,z) and return x and z!
Hope someone can help.

Thx

2 Answers

2

static Vector3 GetYInterSect(Ray ray)
{
return ray.origin - ray.direction / ray.direction.y * ray.origin.y;
}

note that it will return NaN if ray is parralel to [Y=0] plane

Thank you very much, exactly what I was looking for!!

No, sry its not, since there is no gameObject, means no collider to hit!
Of course I could create a floor mesh, but this is in my case not an option!

There must be a way to ask the Ray, which point are you at y=0?

Ray.GetPoint seems to be not the answer???

i'd edit answer. understand it wrong at first time