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 Luzhien · Jan 13, 2012 at 08:20 PM · axisradar

invert radar axis

Hi all, I'm using a radar version from unify wich works perfectly. It draws blips for objects around you by their tags as if you look the scene from above. So, objects above you in the radar are in front of you and the ones down the radar are behind you. I want it to show as if the radar is looking from behind you instead from above, so blips up in the radar are above you and down the radar are below you. Objects centered in the radar won't be in your same position but just in front of you, as it should work in an Space Game or Flight Simulator. There is the code drawing blips:

function drawBlip(go : GameObject, aTexture : Texture, iconPixels : int){

 centerPos=centerObject.position;
 extPos=go.transform.position;

 // first we need to get the distance of the enemy from the player
 var dist=Vector3.Distance(centerPos,extPos);

 var dx=centerPos.x-extPos.x; // how far to the side of the player is the enemy?
 var dz=centerPos.z-extPos.z; // how far in front or behind the player is the enemy?

 // what's the angle to turn to face the enemy - compensating for the player's turning?
 var deltay=Mathf.Atan2(dx,dz)*Mathf.Rad2Deg - 270 - centerObject.eulerAngles.y;

 // just basic trigonometry to find the point x,y (enemy's location) given the angle deltay
 bX=dist*Mathf.Cos(deltay * Mathf.Deg2Rad);
 bY=dist*Mathf.Sin(deltay * Mathf.Deg2Rad);

 bX=bX*mapScale; // scales down the x-coordinate so that the plot stays within our radar
 bY=bY*mapScale; // scales down the y-coordinate so that the plot stays within our radar

 if(dist<=mapWidth*.5/mapScale){
     // this is the diameter of our largest radar circle
    if (iconPixels == iconSize) { 
        GUI.DrawTexture(Rect(mapCenter.x+bX,mapCenter.y+bY,iconSize,iconPixels),aTexture);
     } else if (iconPixels == iconBig) {
     GUI.DrawTexture(Rect((mapCenter.x+bX)-((iconBig-iconSize) / 2),(mapCenter.y+bY)-((iconBig-iconSize) / 2),iconBig,iconPixels),aTexture);
     }
 }

}

How to modify it to draw blips as I explain above? Thanks in advance!

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
0

Answer by roamcel · Jan 13, 2012 at 10:23 PM

Have you tried changing the '270' value? I really didn't try to sort out how the script works, but that number seems to be related with target positioning :D

 var deltay=Mathf.Atan2(dx,dz)*Mathf.Rad2Deg - 270 - centerObject.eulerAngles.y;
Comment
Add comment · Show 3 · 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 Luzhien · Jan 13, 2012 at 11:05 PM 0
Share

Hi, thanks for the answer but it's not this value. I need to change the entire coordinates system, this 270 value is to keep the facing direction of the player as nord of the radar but it keeps looking at your position from above. It's nomething about the x y and z axis but I don't know how to change/combine them...

avatar image roamcel · Jan 14, 2012 at 06:43 AM 0
Share

Ok let's try this one: var dz=centerPos.z-extPos.z; // how far in front or behind the player is the enemy?

turn it into

var dz=-(centerPos.z-extPos.z);

Sorry if these look as half-assed attempts, but they actually are. The script seems exceedingly complicated for its purpose, and going through it line by line is a pain.

avatar image Luzhien · Jan 14, 2012 at 11:19 AM 0
Share

Ok, I think I didn't explain well what kind of new functionallity I need. Changing just a line won't work and the part to change are the axis. Now the radar is looking from above and it will if any axis is changed, no mather how a line is modified. I think the key is changing the axis here:

var dx=centerPos.x-extPos.x;

var dz=centerPos.z-extPos.z;

var deltay=$$anonymous$$athf.Atan2(dx,dz)*$$anonymous$$athf.Rad2Deg - 270 - centerObject.eulerAngles.y;

This three lines tell the script how to use the x, y and z axis for an above radar and I need them to work as a behind radar. But any convination I tried didn't work as expected...

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Navmesh or terrain axis swap from XZ to XY? 0 Answers

Objects not rotating their axis. 0 Answers

Does unity support a 16 bits axis input? 0 Answers

'GetAxis' is not a member of 'function(): void' 1 Answer

how to know if an axis has been full rotated? 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