Hello,
I am working on a Projectile Motion and when the ball hits the enemy I wish to increase score whenever the enemy is killed. Hence I have an Enemy prefab, which is instantiated through script (on FIRING).
Code:
Collision checking script (cannontrans.js)
var ene_hit : la_point;
function OnCollisionEnter(hit : Collision)
{
randomrange();
if(hit.gameObject.tag == "cannonball")
{
transform.position = Vector3(r_enepos,2,0);
}
}
Code Explanation:
Whenever it gets a hit I wish to move position of the object. Hence here I would also like to increase the score to display on the UI using OnGUI function. The above code it attached onto the enemy Prefab I was talking earlier about.
Perception:
I wish to increase the score on a different script. The reason is - I have lots of scenes and every scene requires it own scoreline.
Request:
I humbly request someone to help me on this issue. I am not sure how to proceed. My main aim at the end of the day is to have the prefab initiated through script and update the score line whenever there is a hit. Kindly let me know if I have to detailed certain aspects out too.
cannontrans.js → C code - 65 lines - codepad
THANK YOU VERY MUCH