I was given some pseudo code for finding the right-most object in a game. Unfortunately it is in C#. Could anybody convert this for me so I can tweak it? Or can someone rewrite another code that serves the same purpose except in UnityScript.
Thanks.
CODE:
float maxX = -float.Infinity;
GameObject farthest = null;
foreach (GameObject current in gameObjects) {
float x = current.transform.position.x;
if (x > maxX) {
maxX = x;
farthest = current;
}
}
CURRENT CODE:
function Update() {
var maxX = Mathf.NegativeInfinity;
var farthest : GameObject;
for (current in gameObjectTypes) {
var x = current.transform.position.x;
if (x > maxX) {
maxX = x;
farthest = current;
}
}
}
function allGameObjects()
{
var gameObjectTypes = FindObjectsOfType(GameObject);
return;
}
ERROR: Unknown identifier 'gameObjectTypes'