x


Geometry Wars game experience in Unity

Hi, I building a game Geometry Wars like; I want to be able to rotate the "player" when moving the mouse to aim to the enemies. I'm using the MouseLook script as an start point but it's not working for me as the "player" rotating is not in synch with the mouse movement.

more ▼

asked Sep 07, 2010 at 01:46 AM

arkkitekktura gravatar image

arkkitekktura
19 9 6 9

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

Orienting an object towards the mouse position is a topic that's discussed frequently in the forums. Try searching the forums for (e.g.) 'aim at mouse'. Also, check out the EvacCity tutorial, as it shows how to do this (including code).

Note that if the player is not always located at the center of the screen, you may need to tweak things a bit. In short, the player and mouse position need to be expressed in the same space for the purpose of determining the rotation (this could be screen space, or world space - whichever you prefer). Once you have the positions in the same space, compute the vector from the player position to the mouse position, and then use Transform.LookAt() to aim the player at the cursor. (You can also compute the angle using Atan2() and rotate the player accordingly if you prefer.)

more ▼

answered Sep 07, 2010 at 11:41 AM

Jesse Anders gravatar image

Jesse Anders
7.7k 11 25 61

(comments are locked)
10|3000 characters needed characters left

If You haven't found anything try to get some ideas from that demo island they made. The camera could give you some "Lightbulb"

more ▼

answered Dec 27, 2010 at 09:29 AM

Dimitar gravatar image

Dimitar
1

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3600
x1409
x224
x180

asked: Sep 07, 2010 at 01:46 AM

Seen: 2076 times

Last Updated: Sep 07, 2010 at 01:46 AM