Call function....cant get it to work on iPhone

this works well in unity on all other platforms other than iPhone…

var score_amount = 100;
var scoreCounter : GameObject;



function OnTriggerEnter (col : Collider)
	{
		Score();	
	}

function Score()
	{
		scoreCounter.GetComponent(score_count_script).AddScore();	
	}

error on this line…

		scoreCounter.GetComponent(score_count_script).AddScore();

im guessing from the documentation that “AddScore” isnt working because on the iPhone it wont call functions backwards like it would in normal unity??

it works perfectly until its compiled for iPhone…

try defining your score script like so (cast):

and then call it

Remember that the iPhone needs static typing. So var score_amount = 100; should also be

Also, try adding #pragma strict to the top of your script files and see what breaks.

scoreCounter.GetComponent(score_count_script) returns a Component, not an object of class score_count_script

you must cast the return first.

there are like 120 threads on the matter which will help you to find out how :slight_smile: