need help in my script working in PC and Mac standalone but not working in Android

here is the link for the tutorial that i saw few days ago,http://www.jakel168.com/2010/09/how-to-make-mini-map-for-your-scene-in.html, its nice but seems not working on android platform.

this error is always popping out Assets/minmap.js(53,12):BCE0051: Operator ‘*’ cannot be used with a left hand side of type ‘float’ and a right hand side of type ‘Object’.

error at Assets/minimap.js at line: 48

pls :frowning: can anyone out there help me to make it work on android platform.

//just paste this code to the first/3rd person controller/you're character

//For placing the image of the mini map.
var miniMap : GUIStyle;
//Two transform variables, one for the player's and the enemy,
var player : Transform;
var enemy : Transform;


var enemy2 : Transform;
var enemy3 : Transform;
var enemy4 : Transform;


//Icon images for the player and enemy(s) on the map.
var playerIcon : GUIStyle;
var enemyIcon : GUIStyle;




var enemyIcon1 : GUIStyle;

var enemyIcon2 : GUIStyle;

var enemyIcon3 : GUIStyle;



//Offset variables (X and Y) - where you want to place your map on screen.
var mapOffSetX = 762;
var mapOffSetY = 510;
//The width and height of your map as it'll appear on screen,
var mapWidth = 200;
var mapHeight = 200;
//Resolution (both width and height) of your terrain.
var sceneWidth = 500;
var sceneHeight = 500;
//The size of your player and enemy's icon as it would appear on the map.
var iconSize = 10;
var iconHalfSize;

function Update () {
iconHalfSize = iconSize/2;
}

function GetMapPos(pos : float, mapSize, sceneSize) {
return pos * mapSize/sceneSize;
}

function OnGUI() {
//Everything about the map.
GUI.BeginGroup(Rect(mapOffSetX,mapOffSetY,mapWidth,mapHeight), miniMap);
var pX = GetMapPos(transform.position.x, mapWidth, sceneWidth);
var pZ = GetMapPos(transform.position.z, mapHeight, sceneHeight);
var playerMapX = pX - iconHalfSize;
var playerMapZ = ((pZ * -1) - iconHalfSize) + mapHeight;
GUI.Box(Rect(playerMapX, playerMapZ, iconSize, iconSize), "", playerIcon);
  
var sX = GetMapPos(enemy.transform.position.x, mapWidth, sceneWidth);
var sZ = GetMapPos(enemy.transform.position.z, mapHeight, sceneHeight);



var aX = GetMapPos(enemy2.transform.position.x, mapWidth, sceneWidth);
var aZ = GetMapPos(enemy2.transform.position.z, mapHeight, sceneHeight);

var bX = GetMapPos(enemy3.transform.position.x, mapWidth, sceneWidth);
var bZ = GetMapPos(enemy3.transform.position.z, mapHeight, sceneHeight);

var cX = GetMapPos(enemy4.transform.position.x, mapWidth, sceneWidth);
var cZ = GetMapPos(enemy4.transform.position.z, mapHeight, sceneHeight);





var enemyMapX = sX - iconHalfSize;
var enemyMapZ = ((sZ * -1) - iconHalfSize) + mapHeight;

var enemy2MapX = aX - iconHalfSize;
var enemy2MapZ = ((aZ * -1) - iconHalfSize) + mapHeight;

var enemy3MapX = bX - iconHalfSize;
var enemy3MapZ = ((bZ * -1) - iconHalfSize) + mapHeight;

var enemy4MapX = cX - iconHalfSize;
var enemy4MapZ = ((cZ * -1) - iconHalfSize) + mapHeight;




GUI.Box(Rect(enemyMapX, enemyMapZ, iconSize, iconSize), "", enemyIcon);


GUI.Box(Rect(enemy2MapX, enemy2MapZ, iconSize, iconSize), "", enemyIcon1);

GUI.Box(Rect(enemy3MapX, enemy3MapZ, iconSize, iconSize), "", enemyIcon2);

GUI.Box(Rect(enemy4MapX, enemy4MapZ, iconSize, iconSize), "", enemyIcon3);

}


GUI.EndGroup();

Please format your code. It’s hard to read. Select the code and click the # icon in the post editor, or type the opening and closing CODE tags manually, for example:

[code]
... your code here ...
[/code]

Please provide the entire code file, unmodified, and point out exactly which line is producing the error.

sorry dude im new in this community and my English is not that good, my script is 100% running in PC standalone but when i switched to Android it’s not working anymore. btw thanks i already edited my post and point out the line where the error is

I’m not sure if the line-number matches up, but I noticed this:

function GetMapPos(pos : float, mapSize, sceneSize) {
return pos * mapSize/sceneSize;
}

You’re not declaring a type for mapSize and sceneSize. I’m not sure about Android, but on iOS you need to declare a type for all your variables - which would also include the properties from mapOffsetX to iconHalfSize.

Even if it’s not required, it’s a good idea to prevent errors and may make things more efficient.

dude i double checked the script and the error line should be on line 48 not 47 thanks, ill try to modify my codes when i get home and thank you for your suggestion, ill inform you immediately the result

hey dude thanks a lot, its now working i try to follow ur suggestion and now its 100% working on android platform here is the code

//For placing the image of the mini map.
var miniMap : GUIStyle;
//Two transform variables, one for the player's and the enemy,
var player : Transform;
var enemy : Transform;



var enemy2 : Transform;
var enemy3 : Transform;
var enemy4 : Transform;






//Icon images for the player and enemy(s) on the map.
var playerIcon : GUIStyle;
var enemyIcon : GUIStyle;




var enemyIcon1 : GUIStyle;

var enemyIcon2 : GUIStyle;

var enemyIcon3 : GUIStyle;





//Offset variables (X and Y) - where you want to place your map on screen.
var mapOffSetX = 300;
var mapOffSetY = 310;
//The width and height of your map as it'll appear on screen,
var mapWidth = 200;
var mapHeight = 200;
//Resolution (both width and height) of your terrain.
var sceneWidth = 500;
var sceneHeight = 500;
//The size of your player and enemy's icon as it would appear on the map.
var iconSize = 10;
var iconHalfSize : float;

function Update () {
iconHalfSize  = iconSize/2;
}

function GetMapPos(pos : float, mapSize : float, sceneSize: float) {
return pos * mapSize/sceneSize;
}

function OnGUI() {
//Everything about the map.




GUI.BeginGroup(Rect(mapOffSetX,mapOffSetY,mapWidth,mapHeight), miniMap);
var pX = GetMapPos(transform.position.x, mapWidth, sceneWidth);
var pZ = GetMapPos(transform.position.z, mapHeight, sceneHeight);
var playerMapX = pX - iconHalfSize;
var playerMapZ = ((pZ * -1) - iconHalfSize) + mapHeight;
GUI.Box(Rect(playerMapX, playerMapZ, iconSize, iconSize), "", playerIcon);
  
var sX = GetMapPos(enemy.transform.position.x, mapWidth, sceneWidth);
var sZ = GetMapPos(enemy.transform.position.z, mapHeight, sceneHeight);





var aX = GetMapPos(enemy2.transform.position.x, mapWidth, sceneWidth);
var aZ = GetMapPos(enemy2.transform.position.z, mapHeight, sceneHeight);

var bX = GetMapPos(enemy3.transform.position.x, mapWidth, sceneWidth);
var bZ = GetMapPos(enemy3.transform.position.z, mapHeight, sceneHeight);

var cX = GetMapPos(enemy4.transform.position.x, mapWidth, sceneWidth);
var cZ = GetMapPos(enemy4.transform.position.z, mapHeight, sceneHeight);







var enemyMapX = sX - iconHalfSize;
var enemyMapZ = ((sZ * -1) - iconHalfSize) + mapHeight;

var enemy2MapX = aX - iconHalfSize;
var enemy2MapZ = ((aZ * -1) - iconHalfSize) + mapHeight;

var enemy3MapX = bX - iconHalfSize;
var enemy3MapZ = ((bZ * -1) - iconHalfSize) + mapHeight;

var enemy4MapX = cX - iconHalfSize;
var enemy4MapZ = ((cZ * -1) - iconHalfSize) + mapHeight;








GUI.Box(Rect(enemyMapX, enemyMapZ, iconSize, iconSize), "", enemyIcon);


GUI.Box(Rect(enemy2MapX, enemy2MapZ, iconSize, iconSize), "", enemyIcon1);

GUI.Box(Rect(enemy3MapX, enemy3MapZ, iconSize, iconSize), "", enemyIcon2);

GUI.Box(Rect(enemy4MapX, enemy4MapZ, iconSize, iconSize), "", enemyIcon3);




GUI.EndGroup();
}

Sorry about the problem. The post was written exactly 2 years ago (what a coincidence!), haven’t had time to re-check it back.
I’ve since fixed the code to prevent any more problems for future readers. Thanks~!

Thank you also :slight_smile: