Raycast doesnt hit in Freespace

hello there,

i have a slight problem in my spaceshooter project.
i have a gun pointing on the mouseposition.
i use a raycast to get my LookAt done which is working fine if i target
any gameObject with a collider. but in freespace the cast doesnt hit so no hit.point to
target. It works if i implement a plane without mesh renderer.(so i have to build a cube out of meshes around everything ?)
So i tried to make a huge sphere around the level but this doesnt work from the inside.

So my next thought was just to use the direction value the raycast uses … basically it should do the same thing …without a hit
but i can not convert this value into a Vector3 LookAt compatible thing.
I am running out on alternatives so i like to ask if someone solved this issue . I didnt find a solution here - or i havent use the right keywords …
thanx for ur help & suggestions …

var ray : Ray = Camera.main.ScreenPointToRay (Input.mousePosition);
transform.LookAt(ray.direction);

or

var ray : Ray = Camera.main.ScreenPointToRay (Input.mousePosition);
var gg : Vector3 = transform.TransformDirection(ray.direction);
transform.LookAt(gg);

:frowning:

Sounds like having your gun LookAt a point well down the length of the ray would work.
For example, a point 1000 units down the ray would be: transform.LookAt( ray.origin + ray.direction * 1000.0f ).
Or you could try the Ray’s built in function for that: transform.LookAt( Ray.GetPoint( 1000.0f ) )

(I recommend boning up on your vector and matrix math in general if you’re going to be making a 3D game - the first few chapters of any linear algebra textbook should be all you need.)