- Home /
How to increase score on hit
Hey I am making a very basic FPS game for a university project in javascript and I am currently stuck on how to make my score counter. I am using a raycast for my shooting and that is what I want to attach my code to. I want the score to display on screen and increase by 100 when the raycast hits a rigidbody. I have a few lines of code that I found on unity answers and have changed the variables to my own, this is only a very small amount but can anyone help me please.
var score : int;
var Counter : GUIText;
function OnHit {
if(Hit.rigidbody){
score += 1;
Counter.text = ("Score: ") +score;
}
Comment
Your answer
Follow this Question
Related Questions
Making raycasts go to the centre of the screen 1 Answer
Making bullets go to the crosshair 1 Answer
Unity Raycast Script, Help! 1 Answer
Vertical distance indication 1 Answer
raycast to determine pivot 1 Answer