Please help, what can i do? i am newbie to coding (1 week)
,Imade a doddle jump like game and want to add score to it.
I want the score to display the Y position of the player.
Here is my code
ScoreScript
using UnityEngine;
using UnityEngine.UI;
public class scorescript : MonoBehaviour
{
public static int ScoreValue = 0;
Text score;
void Start()
{
score = GetComponent<Text>();
}
void Update()
{
score.text = "Score " + ScoreValue;
}
}
Player script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class rigidbody : MonoBehaviour
{
private Rigidbody rb;
void Start()
{
rb = GetComponent<Rigidbody>();
Vector3 v3Velocity = rb.velocity;
GetComponent<scorescript>();
}
void Update()
{
scorescript.scoreValue += rb.velocity.y;
}
}
Whats wrong, please help me i am newbie to unity.