- Home /
How to get score point if i click a rock in 3d
Hi I try to make a 3d clicker and i don't now how to make score system
I don't have any skills in C # and all I have it's Raycast on the camera
i just need a help or tutorial how to do it
(it's my first game in unity)
Answer by Malek-Bakeer · Jan 11, 2020 at 12:30 PM
Use a method called
void OnMouseDown()
{
//The object has been clicked on, it must have a box collider!
}
Answer by SuperSugarPL · Jan 12, 2020 at 12:06 AM
Thx it's works!
But i found tutorial how to make score system
and it works so much that I don't know how to convert the code to add points only after clicking the rock
Hi, yeah sure
//remove the if statement and score++ in update and replace the int score //with static, it should look like this.
public Text scoreText;
public static int score;
void Update()
{
scoreText.text = score.ToString();
}
Then in the RockScore script, add this line after the debug.
Score.score++;
I probably do something wrong
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RockScore : $$anonymous$$onoBehaviour
{
void On$$anonymous$$ouseDown()
{
Debug.Log("hit rock");
Score.score++;
}
}
displays an error because I probably broke something xd
Your answer
Follow this Question
Related Questions
Creating piping model at runtime 0 Answers
How to change terrain with code?,How to edit terrain with code? 0 Answers
Jump with physics 1 Answer
Human model clothes 1 Answer
Raycast from one camera using a gameobject relative to another camera 1 Answer