I have a rigidbody controller and want to show it’s speed on the UI. I’ve tried some script but got an error. Here’s what I wrote
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Speedscript : MonoBehaviour {
Text speedtext;
Rigidbody rb;
public GameObject Player;
// Use this for initialization
void Start () {
speedtext = this.GetComponent ();
rb = Player.GetComponent ();
}
// Update is called once per frame
void Update () {
speedtext = "Speed: " + rb.velocity.ToString();
}
}
Error
Assets/Speedscript.cs(21,15): error CS0029: Cannot implicitly convert type string' to UnityEngine.UI.Text’