- Home /
Point system, something wrong
on my finish line I have a cube which can be triggered and I wanted to give points once user reaches to finish and this is what i made but it isnt working
cube script
public spherescript player;
private void OnTriggerEnter(Collider other)
{
GameObject.Find("Sphere").SendMessage("FinishL4");
PlayerPrefs.SetInt("levelReached", 2);
Instantiate(patlama, this.gameObject.transform.position, this.gameObject.transform.rotation);
scorePanel.SetActive(!scorePanel.activeSelf);
player.score += 50;
}
and player sphere script
void Update () {
rigidbodyy = GetComponent<Rigidbody>();
rigidbodyy.velocity = new Vector3(joystick.Horizontal * 15f,
rigidbodyy.velocity.y,
joystick.Vertical * 15f);
scoreText.text = "Points: " + score.ToString();
}
Answer by Just_Jim_98 · Mar 01, 2019 at 08:59 PM
@panim0_unity Firstly if you have a logic problem like this, its best to always check if a function is being called, either using line by line debugger such as Visual Studios has, which allows you to step through your code as it runs. Or simply use debug.log("Error is...."); to output to the engines console window to see if it is being called.
So my first guess would be to make sure that the object the cube script component is attached to has a collider component attached, that is set to be a trigger . Also make sure that the object the player script is attached to has a collider attached also.
Apart from that i dont see anything too wrong with your code.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Please Help Me 1 Answer
Is it possible to add a point to the score, everytime the Player rotates 180°? 2 Answers