|
Hello, this is the script for a projectile in my game. I want to make it so that when Object A collides with an object with tag B the score is increased, to put it simply, why doesn't this work?
(comments are locked)
|
now you can access this variable from any script by using scriptname.Score, being scriptname the name of the script you declared the variable into. also, if your score var is in a script attached to the projectile, you gonna have multiple scripts in the scene, which will be destroyed along with the projectile when they collide. Put the score in the player or any other object you know that wont be destroyed. other solution would be to use http://unity3d.com/support/documentation/ScriptReference/PlayerPrefs.html
Nov 18 '10 at 11:28 AM
Bravini
(comments are locked)
|
|
do you want show score? recommand below { int score = 0; function OnTriggerEnter ( ) ... score++; ... } void OnGUI() { if (score == 5) {
} } }
(comments are locked)
|

The indentation and formatting of your post is all messed up, I unfortunatly don't have the permission to edit it for you so I would kindly ask you , or another with the permission to do so. And no I sadly don't have the answer for you