Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Hawkules · Nov 16, 2011 at 10:40 PM · 2drotationdirectionmouseposition2.5d

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

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by BerggreenDK · Nov 16, 2011 at 10:43 PM

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

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

rotation LookAt of 2D gameObject in 3D space 1 Answer

Why is my GameObject rotation snapping to a certain angle when he reaches its destination? 2 Answers

Locking the Z-axis based on direction 0 Answers

2d character, how to limit rotation to z, with character looking left? 0 Answers

Sprites always face the camera, Camera freely rotates 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges