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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by san santhosh · Mar 16, 2013 at 05:32 AM · androidtransformobject

Error: 'transform' is not a member of 'Object'

Asserts.radar/Radar.js(47,23): BCE0019: 'transform' is not a member of 'Object'

I am getting this error when i am working in android platform but in pc platform i m not getting any error.

Here is the script:

@script ExecuteInEditMode() // radar! by PsychicParrot, adapted from a Blitz3d script found in the public domain online somewhere .. //Modified by Dastardly Banana to add radar size configuration, different colors for enemies in different states (patrolling or chasing), ability to move radar to either one of 9 preset locations or to custom location. //some lines are particular to our AI script, you will need to change "EnemyAINew" to the name of your AI script, and change "isChasing" to the boolean within that AI script that is true when the enemy is active/can see the player/is chasing the player. var blip : Texture; // texture to use when the enemy isn't chasing var blipChasing : Texture; //When Chasing var radarBG : Texture; var centerObject : Transform; var mapScale = 0.3; var mapSizePercent = 15; var checkAIscript : boolean = true; var enemyTag = "Enemy"; 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) var bX=centerObject.transform.position.x * mapScale; var bY=centerObject.transform.position.z * mapScale; GUI.DrawTexture(Rect(mapCenter.x - mapWidth/2,mapCenter.y-mapHeight/2,mapWidth,mapHeight),radarBG); // Draw blips for Enemies DrawBlipsForEnemies(); } function drawBlip(go,aTexture){ var centerPos=centerObject.position; var 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 var bX=dist*Mathf.Cos(deltay * Mathf.Deg2Rad); var 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 DrawBlipsForEnemies(){ //You will need to replace isChasing with a variable from your AI script that is true when the enemy is chasing the player, or doing watever you want it to be doing when it is red on the radar. //You will need to replace "EnemyAINew with the name of your AI script // Find all game objects tagged Enemy var gos : GameObject[]; gos = GameObject.FindGameObjectsWithTag(enemyTag); var distance = Mathf.Infinity; var position = transform.position; // Iterate through them and call drawBlip function for (var go : GameObject in gos) { var blipChoice : Texture = blip; if(checkAIscript){ var aiScript : EnemyAI = go.GetComponent("EnemyAI"); if(aiScript.isChasing) blipChoice = blipChasing; } 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

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Seth-Bergman · Mar 16, 2013 at 06:08 AM

Note that the error gives you the exact location of the issue:

Radar.js(47,23):

The javascript named Radar, line 47 (23 characters in)...

the problem is this line:

 var extPos=go.transform.position;


my guess is you can fix this by designating "go" as a GameObject:

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

      var centerPos=centerObject.position;
      //etc

otherwise it is passed in as just an "Object" (generic), which would then need to be typecast I suppose..

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
avatar image
0

Answer by san santhosh · Mar 17, 2013 at 02:05 PM

Thank you so much :) .It works :)

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

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

11 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

Related Questions

Adding data to a set of transforms 1 Answer

Scaling Script? 1 Answer

Help I can not understand how to do it with joints 2 Answers

Moving an object towards a clicked object 1 Answer

Object not moving,Object not moving in any direction 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