Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 arkon · Nov 12, 2014 at 12:14 PM · rotationtransformradar

How to calc new coordinates of an object based on rotation

I'm trying to make a radar like thing where all the enemies are shown relative to my player on a display. (just like in the old elite) I have it all working properly until I rotate the player. I need to calculate the new coordinates of the enemies when the player rotates. for example: (assume 2d)

The player is at 0,0 and a enemy is at 0,6 so in front of the player and showing up in front of the player on the radar. now I rotate the player left 90 degrees, I need to turn the enemy real world coordinate into a new one based on the players new rotation so it shows up to the right of the player on the radar so in this example the coordinates would be 6,0

Any ideas?

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 troien · Nov 12, 2014 at 02:45 PM

The easiest way to do such thing is to actually just add a extra camera who looks at your player top-down (Who is a child of your player so that it rotates along). And make it render a different layer, and put all minimap/radar associated things on that layer. This is probably easier then calculating and positioning everything yourself, as you can simply add something to your prefabs in that layer, and as long as your main camera doesn't render that layer, only your minimap will be able to see it.

As for you question. What you wan't is the local position to the player. You can get that using transform.InverseTransformPoint.

 player.transform.InverseTransformPoint(other.position);

The result of that would be a position relative to the player.

Comment
Add comment · Show 1 · 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
avatar image arkon · Nov 12, 2014 at 09:20 PM 0
Share

Thanks. That worked perfectly! I couldn't use your camera suggestion as the radar is on the 2d hud and is an ellipse to make it look 3d, so I'd not be able to put the output of the other camera on it and make it fit and look right. Doing it myself is more useful too as I can add stuff to the radar that doesn't exist in the world. Thanks for the inverse transformpoint idea tho!

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

27 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

When I rotate my player in open 3 space, the transform rotation component keeps snapping back to origin. However, when I disable my rigidbody.rotate command, the transform rotation works just fine. 0 Answers

Rotating Camera around player object 0 Answers

rotation of the object to a given angle 1 Answer

Get slerp to work just as LookAt(,Vector3.right) does 1 Answer

Rigidbody.AddForce with Raycast? 1 Answer


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