Score not working.

I have an attachment of my script. I when to the Unity forum and check Send Messages, Broadcast Messages, and GetCompenents and I still cannot get the score to increase by 5. I know I have to attach a script to my enemy and player. It is a first person game. Can someone please help me. 484757–17016–$enemyHit.js (78 Bytes)484757–17017–$playerWin.js (277 Bytes)

You don’t necessarily need scoring scripts on both. If you’re scoring points by the number of hits on the enemy, you could use raycasting to detect the hit and use the RaycastHit Class to tell you the tag of the object that’s been hit.

function Update () {
var hit : RaycastHit;
if (Physics.Raycast (transform.position, -Vector3.up, hit)) {
var distanceToGround = hit.distance;
}
}

This is directly from the scripting reference. The “hit” variable contains all kinds of information on what was hit, distance, etc. You can then score from that and call a “die” function on the enemy if he’s taken enough damage. The example above registers distance, but it could just as easily tell you the collider that’s been hit and the game object. In your case you would use Vector3.forward instead of Vector3.up. Check out raycasting in the scripting reference. You can also make the number of hits a static variable available to other scripts such as your GUI script (if there is one).

If you haven’t gone through the Lerpz tutorial, I highly recommend it. You can also watch some informative videos on Will Goldstone’s site www.unity3dstudent.com Start with essentials and work you way through.