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
3
Question by Panamamigo · Aug 17, 2010 at 04:05 AM · mapradarmini

Mini-Map Radar screen with different blips.

This is a radar script, originally made by dasterdlybanana and psychic parrot, that I've been trying to adapt to my game. Their original script works by displaying static objects on their radar screen but the blips move as their character does. It can have two blips. One if the enemy is chasing and one if the enemy is not. I want to use this same concept but have a different blip for each different shape (the shapes move around as well). This displays the background of my radar screen but it doesn't display the blips. Can anyone tell me why? Any help is appreciated. My adaption of the script is below, here's where the original code can be found: http://forum.unity3d.com/viewtopic.php?p=189482.

@script ExecuteInEditMode()

var sphere : Texture; //blip for spheres var cube : Texture; //blip for cubes var cone : Texture; //blip for cones var cylinder : Texture; //blip for cylinders var radarBG : Texture; //background texture (radar screen)

var centerObject : Transform; var mapScale = 0.3; var mapSizePercent = 15;

var sphereTag = "Sphere"; var cubeTag = "Cube"; var coneTag = "Cone"; var cylinderTag = "Cylinder";

enum radarLocationValues {topLeft, topCenter, topRight, middleLeft, middleCenter, middleRight, bottomLeft, bottomCenter, bottomRight, custom} var radarLocation : radarLocationValues = radarLocationValues.bottomLeft;

private var mapWidth : float; private var mapHeight : float; private var mapCenter : Vector2; var mapCenterCustom : Vector2;

function Start () { setMapLocation();
}

function OnGUI () { // GUI.matrix = Matrix4x4.TRS (Vector3.zero, Quaternion.identity, Vector3(Screen.width / 600.0, Screen.height / 450.0, 1));

 // Draw player blip (centerObject)
 bX=centerObject.transform.position.x * mapScale;
 bY=centerObject.transform.position.z * mapScale;   
 GUI.DrawTexture(Rect(mapCenter.x - mapWidth/2,mapCenter.y-mapHeight/2,mapWidth,mapHeight),radarBG);

 DrawBlipsForShapes();

}

function drawBlip(go,aTexture){

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

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

 dx=centerPos.x-extPos.x; // how far to the side of the player is the enemy?
 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?
 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
    GUI.DrawTexture(Rect(mapCenter.x+bX,mapCenter.y+bY,4,4),aTexture);

 }

}

function DrawBlipsForShapes(){

 var gos : GameObject[];
 gos = GameObject.FindGameObjectsWithTag(sphereTag && cubeTag && coneTag && cylinderTag);

 var distance = Mathf.Infinity;
 var position = transform.position;

 // Iterate through them and call drawBlip function
 for (var go : GameObject in gos)  {
     var blipChoice : Texture;
     if(go.tag == "Sphere") {
         blipChoice = sphere;
     }
     drawBlip(go,blipChoice);
     if(go.tag == "Cube") {
         blipChoice = cube;
     }
     drawBlip(go,blipChoice);
     if(go.tag == "Cone") {
         blipChoice = cone;
     }
     drawBlip(go,blipChoice);
     if(go.tag == "Cylinder") {
         blipChoice = cylinder;
     }
     drawBlip(go,blipChoice);
 }

}

function setMapLocation () { mapWidth = Screen.width*mapSizePercent/100.0; mapHeight = mapWidth;

 //sets mapCenter based on enum selection
 if(radarLocation == radarLocationValues.topLeft){
     mapCenter = Vector2(mapWidth/2, mapHeight/2);
 } else if(radarLocation == radarLocationValues.topCenter){
     mapCenter = Vector2(Screen.width/2, mapHeight/2);
 } else if(radarLocation == radarLocationValues.topRight){
     mapCenter = Vector2(Screen.width-mapWidth/2, mapHeight/2);
 } else if(radarLocation == radarLocationValues.middleLeft){
     mapCenter = Vector2(mapWidth/2, Screen.height/2);
 } else if(radarLocation == radarLocationValues.middleCenter){
     mapCenter = Vector2(Screen.width/2, Screen.height/2);
 } else if(radarLocation == radarLocationValues.middleRight){
     mapCenter = Vector2(Screen.width-mapWidth/2, Screen.height/2);
 } else if(radarLocation == radarLocationValues.bottomLeft){
     mapCenter = Vector2(mapWidth/2, Screen.height - mapHeight/2);
 } else if(radarLocation == radarLocationValues.bottomCenter){
     mapCenter = Vector2(Screen.width/2, Screen.height - mapHeight/2);
 } else if(radarLocation == radarLocationValues.bottomRight){
     mapCenter = Vector2(Screen.width-mapWidth/2, Screen.height - mapHeight/2);
 } else if(radarLocation == radarLocationValues.custom){
     mapCenter = mapCenterCustom;
 }

}

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 SpiritWebb · Feb 16, 2011 at 05:59 PM

You have to tag your enemy with "Enemy." To make it fully work, place the radar script on your main camera, and drag your player, tagged with "Player" to the Center Object of the radar script. Drop the EnemyAI script on your enemy, name it something like "dummyEnemy" and then tag it with "Enemy." To create a tag, click the drop down for tag, click "add tag" and then where it says element0 if you haven't created any before, put Enemy here, and now it should show up. Change the tag to Enemy now and everything should work.

I looked at the demo scene that comes with it and it worked.

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 wenhua · Jan 11, 2012 at 02:02 AM 0
Share

where to download the demo scene,as i am currently working on similar blips Can your help me .

$$anonymous$$y Question

(Detect sign on Fix $$anonymous$$ini map,When click on moving map,just like pin point) THX

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

1 Person is following this question.

avatar image

Related Questions

A node in a childnode? 1 Answer

Help with minimap 1 Answer

How to Create a Multi Floor Mini Map 1 Answer

Use kinect depth map as input? 1 Answer

how to implement mini map 2 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