Hi, please can someone help me with the syntax here, I cannot get this to work.
Basically, I have a bunch of gameobjects in an array called blocksInPlay. Each gameobject has a script attached that manages a float called actualHeight.
I need to iterate through the array everyframe and find the highest height value and assign to a float called currentHeight.
I figured that Mathf.Max was the best solution, but I cant find the right syntax. Please can someone help, so far I have this:
foreach(GameObject block in blocksInPlay)
{
blockScript = block.GetComponent<BlockManager>();
if (blockScript.objectSettled == true)
{
currentHeight = blockScript.actualHeight;
}
This above gives the total from all of them within blockscript, so how can I use Mathf.Max on the above?