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 Luci85 · Apr 25, 2012 at 03:18 PM · rotationlinerendererminimap

Rotating a line renderer

I want to make a really abstract minimap for my racing game, which consists only of a line for the track (the line renderer) and a dot/s for the car/s. My problem is that I don't know how to set the main camera as pivot point of the map so that the map is always in the top right corner of the screen and how to rotate the whole line when the camera rotates.
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 Luci85 · Apr 26, 2012 at 11:32 AM

Ok, found the answer, you loop through the whole line and rotate every point with the rotation matrix. If someone needs the code:

 var PIDiv180 = Mathf.PI/180;
 function rotate(pivotPoint:Vector3, pointToRotate:Vector3, angle:float)
 {
    var result:Vector2;
    var Nx = (pointToRotate.x - pivotPoint.x);
    var Ny = (pointToRotate.z - pivotPoint.z);
    angle = -angle * PIDiv180;
    result = Vector2(Mathf.Cos(angle) * Nx - Mathf.Sin(angle) * Ny + pivotPoint.x, Mathf.Sin(angle) * Nx + Mathf.Cos(angle) * Ny + pivotPoint.z);
    return result;
 }
Comment
Add comment · Show 2 · 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 LastSipahi · Oct 10, 2016 at 10:51 AM 0
Share

How can we convert this to vector3 ?

avatar image Luci85 LastSipahi · Oct 10, 2016 at 11:06 AM 0
Share

Depends on what you want to do with the vector3. Simplest method would be change the result to vector3 and initialise the y-coordinate with 0. Like this: var result:Vector3; ... result = Vector3($$anonymous$$athf.Cos(angle) * Nx - $$anonymous$$athf.Sin(angle) * Ny + pivotPoint.x, 0, $$anonymous$$athf.Sin(angle) * Nx + $$anonymous$$athf.Cos(angle) * Ny + pivotPoint.z);

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Minimap arrows 0 Answers

Is it possible to fit a linerenderer turn in the rotation of the parent object? 0 Answers

Minimap rotation 2 Answers

Object rotation as a children of the main camera 1 Answer

Spawning a BoxCollider2D between 2 vector3 (JS) 0 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