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).
Collision checking script (cannontrans.js)
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.
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.
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 -> http://codepad.org/B4Djc6ve
THANK YOU VERY MUCH
asked Dec 08 '11 at 11:19 PM
This should work... Mostly psuedocode, but basically you pass in the object that has the GUI on it, store it as obj. Then you access the component (The script) of the object that contains the GUI and in result, the score variable, then just ++ it.
I think this is what you want, no?
Seems the code you have already handles the random movement.
If not, reply, I'll try to help further.
answered Dec 09 '11 at 01:07 AM