I want to connect float to text mash pro

Help me pls i need to this float will be in game scene. Like counter.

using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Scripting.APIUpdating;

public class PlayerController : MonoBehaviour
{
    public GameObject holePref;
    public GameObject muzzleFlash;

    public float speed = 12;
    public Transform cam;
    public float mouseSensitivity = 2f;
    public float jumpHeight = 1;
    public float balllimit = 10;
    public TextMeshPro txtBall;

    bool isGrounded;
    Rigidbody rb;
    // Start is called before the first frame update
    void Start()
    {
        txtBall = balllimit;
        Cursor.lockState = CursorLockMode.Locked;
        rb = GetComponent<Rigidbody>();
    }

6921446--811982--Screenshot_1.png

Here is how to report your problem productively in the Unity3D forums:

http://plbm.com/?p=220

How to understand compiler and other errors and even fix them yourself:

If you post a code snippet, ALWAYS USE CODE TAGS:

How to use code tags: Using code tags properly

Like this ?

I don’t know what this means. Have you tried googling for what you want?! Nobody here reads minds so you have to be very explicit.

“I want my code to do this, exactly like this game here, and in fact here is a video of what I want to achieve.”

1 Like

In your code you are trying to replace the reference to a TextMeshPro component with the float itself. That’s not how you do it.

Take a look at how it is done in the documentation:

How i can show my float in game scene ?

I just want to display ball/bullet count in game. I have float that counts bullets i just want to display it in game

There are about seven steps involved.

Code is only ONE tiny step in the process.

Rather than we retyping all the steps here for you, check out some Youtube tutorials, such as any one of these 20,000+:

6921557--812000--Screen Shot 2021-03-10 at 10.25.28 AM.png

1 Like

ok, thanks

I literally linked you to an example in the documentation of what to do. Have you looked through the documentation for the thing you’re trying to use yet?

1 Like