x


Point an arrow at the mouse position, 2.5D

I'm making a 2.5D archery game for a university project and having some trouble spawning the arrows pointing at the mouse position.

I'm working with the coords y=vertical, x=horizontal, z=depth (but not seen due to orthographic camera).

Essentially I want an arrow to be instantiated at the players position pointing at the mouse (the x,y of the mouse - where z is always 0), it should be simple enough although I'm having some real trouble with getting the rotation correct.

transform.LookAt doesn't seem to work too well in the 2.5d space.

Any help would be greatly appreciated, Hawk

more ▼

asked Nov 16 '11 at 10:40 PM

Hawkules gravatar image

Hawkules
3 3 3 4

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

1 answer: sort voted first

if you build your 2.5D univers in real 3D coords, the lookAt should work in both perspective and orthographic camera.

are you sure that your objects are aligned correctly to the right axis? Eg. if you export from Blender the Z and Y is oppersite and that could be the problem.

Regarding the mousepos, there is something called ScreenToWorld and WorldToScreen + a bunch of similar calculations/functions available for such translations.

Here is just one of them, I recommend you take a look at see if there is anything usefull in it.

http://unity3d.com/support/documentation/ScriptReference/Camera.ScreenToWorldPoint.html

more ▼

answered Nov 16 '11 at 10:43 PM

BerggreenDK gravatar image

BerggreenDK
2.4k 54 62 75

(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:

x2174
x1042
x286
x75
x62

asked: Nov 16 '11 at 10:40 PM

Seen: 1068 times

Last Updated: Nov 16 '11 at 10:43 PM