- Home /
This post has been wikified, any user with enough reputation can edit it.
Question by
harrietradcliffe · Jul 11, 2013 at 06:32 PM ·
2d game
Creating the score in hidden object game
So we're creating a hidden object game using Unity. We already created a script for score and for the hidden object to be destroyed whenever clicked.
sc_click.js
function Update () {
if(Input.GetMouseButtonDown(0))
{
var hit: RaycastHit;
var ray: Ray=Camera.main.ScreenPointToRay (Input.mousePosition);
if(Physics.Raycast(ray, hit))
{
if(hit.transform.gameObject == this.gameObject)
{
Destroy(this.gameObject);
}
}
}
}
We just created timer on score.js... Can you help us? How to add score (+5) once you destroy an object?
Comment
Wiki
Answer by create3dgames · Jul 11, 2013 at 07:46 PM
Use GetComponent
to get the score variable, and then do:
score += 5;
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
What Is/Are... (Common Game Terms) 1 Answer
Add score when object destroys (For Hidden Object Game) 1 Answer