- Home /
Score count increase 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;
}
Answer by Jessespike · Oct 28, 2012 at 10:16 AM
function OnTriggerEnter (other : Collider) {
score += 1;
Counter.text = ("Score: ") +score;
}
Answer by Grim_Darknight · Oct 04, 2013 at 11:11 PM
You need to use physics.raycast
http://docs.unity3d.com/Documentation/ScriptReference/Physics.Raycast.html
Your answer
Follow this Question
Related Questions
Score counter out of control, help needed. 1 Answer
Collision with cube isn't working when Instantiate clone it 2 Answers
Score updating after collision 1 Answer
Make a custom score counter in unity with c# 1 Answer
Score Counter Help 2 Answers