Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
This question was closed Sep 02, 2015 at 10:26 PM by getyour411 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by $$anonymous$$ · Aug 31, 2015 at 05:48 PM · c#matheuleranglesminimap

Minimap rotating nodes

Hey there !

I'm working on a minimap system and I'm stuck at a point. My minimap is working fine, but I'd like to improve it by rotating the nodes, which are displayed on the map.

Here's what I've done so far.

 using UnityEngine;
 using System.Collections;
 using System.Collections.Generic;
 
 public class MiniMap : MonoBehaviour {
     public Texture building, arrow;
 
     private Rect buildingRect;
 
     private GameObject[] objects;
     private GameObject player;
 
     // Use this for initialization
     void Start () {
         objects = GameObject.FindGameObjectsWithTag("Objects On Map");
         player = GameObject.Find ("Player");
     }
 
     void OnGUI () {
         foreach (var obj in objects) {
             if (Vector3.Distance(obj.transform.position, player.transform.position) < 100) {
                 buildingRect = new Rect((100 + (obj.transform.position.z - player.transform.position.z )),300 + ( obj.transform.position.x - player.transform.position.x ) , 10,10);
                 GUI.DrawTexture(buildingRect, building);
             }
         }
 
         GUI.DrawTexture(new Rect(100, 300, 10,10),arrow);
     }
 }

For now I'm displaying all nodes from a for each cycle, and it's only for testing purposes. I was playing around with either adding or subtracting the eulerangles.y from the displayed nodes X and Z coordinates but hence I don't know that much about that part of math, I'm asking for your help.

I think I'm on the right way to go, but would need a push to continue developing my system. Thanks in advance !

Comment
Add comment · Show 4
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 getyour411 · Sep 01, 2015 at 12:38 AM 0
Share

Personally I would not do this in OnGUI - that fuction is called many times per frame and you are doing some stuff in it that I'd try to avoid. Is your $$anonymous$$imap the oft seen 2nd camera, orthographic style? You could place something above objects you want to see on the $$anonymous$$imap and use the camera culling mask so they show up (and don't in normal view).

avatar image $$anonymous$$ · Sep 01, 2015 at 03:28 PM 0
Share

As I already pointed it out, this is only for testing purposes. And we aren't talking about any cameras, that's something I'd like to avoid. Basically I'm using my gameobjects coordinates to make a 2d projection from it. $$anonymous$$y only issue is the math behind changing the position of the X,Z coordinates either adding/subtracting to create the illusion of the map rotating.

avatar image $$anonymous$$ · Sep 01, 2015 at 04:45 PM 0
Share

I think that's what I was looking for !

I'm gonna test it out later, then reply to you if it works ! :)

avatar image $$anonymous$$ · Sep 02, 2015 at 06:30 PM 0
Share

Thank you !

It's working as intended ! :)

1 Reply

  • Sort: 
avatar image
1
Best Answer

Answer by Scribe · Sep 01, 2015 at 03:42 PM

You need to decide on some central point (which you rotate around), then this function can rotate around that point (hopefully! untested...):

 Vector3 RotatePoint(Vector3 point, Vector3 centre, Vector3 axis, float angle){
     Vector3 offset = point - centre;
     Quaternion q = Quaternion.AngleAxis(angle, axis);
 
     Vector3 newPos = centre + (q*offset);
     return newPos;
 }

and so you could call it as:

 Vector3 newPoint = RotatePoint(currentPoint, Vector3.zero, Vector3.up, 30f);

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

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Limit Rotation Issues 1 Answer

Am I missing something when it comes to basic math? 1 Answer

Player rapidly accelerating instead of stopping 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