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);