Geometry Wars style movement

Hi everyone!
Im making a game similar to geometry wars.
I have a ship asset, and what I want to do is that this asset to rotate acorrdly to the mouse position(for targeting enemies).
Im going mad to solve this issue, I cant figure out how it is donde.
I´ve tried so far assigning the asset rotation to the mouse position, and also intantiatin a invisible dummy where the mouse is and using the lookAt() method. But none of these aproaches work.

Any help is realy aprreciated.

This sounds similar to the problem under discussion here.

Out of curiosity how did you go about this as i may be able to get this to work almost definitely if the theory is as sound as it sounds.

Thanks for the answers guys.

Jesse Anders: Yes, it sounds a similar problem to mine, I will look into it.

That Homeless Guy: what I did wast to cast a ray with the pointToScreen Method. The problem with this is that the ship will rotate in all its axis.

can you post the script you used (if you still have it)
I can see if we can do something like locking the axis of the instantiated dummy to the same plane as the player.

public var object : Transform; //Dummy object goes here
function LateUpdate () {
var ray = camera.ScreenPointToRay (Input.mousePosition);
Debug.DrawRay (ray.origin, ray.direction * 20, Color.red);
var target = ray.GetPoint(-ray.origin.y / ray.direction.y); 
object.transform.position = target;
}

this should work for a top down view just attatch it to the camera its not complete but if you place a debug object (sphere) into the slot in the camera’s Inspector window it will follow the mouse along the Y axis at 0

Placing an emtpy game object In the inspector is your object for the gun to track.

Further deatails of incomplete progress csn be found in the middle of my thread here http://forum.unity3d.com/viewtopic.php?t=59013 thanks again Jesse

You don’t need to use rays, you just need like some simple math to find the angle and distance.

Howso? this was the only way i could achieve the desired results.

oh yeah and can anybody here tell me how to rotate towards the mouse position on the verticle plane without the the object fliping over at certain angles
this is driving me IN-FUCKIN-SANE. :evil:

The transform.LookAt function has an optional second parameter that specifies the upward direction of object. This defaults to the Y axis - the flipping occurs if the upward direction and the direction you’re looking at get too close together. The solution is to pass the axis of rotation as the upward direction (this will probably be equal to -Vector3.forward if I understand what you’re doing correctly):-

transform.LookAt(targetPoint, -Vector3.forward);

Thanks but i fixed it with this piece of code last night

var target : Transform;
function Update ()
{
	transform.LookAt(Vector3(target.position.x, target.position.y, transform.position.z)); 
}

simple eh!this stops the object fliping on all axises
for a top down view i think its

var target : Transform;
function Update ()
{
	transform.LookAt(Vector3(target.position.x, transform.position.y, target.position.z)); 
}