I am trying to have my text only activate once I press x but the only problem is Idk how to inactivate a text in script but I see it’s possible in the scene screen. Help?
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class PlayerMovement : MonoBehaviour
{
public float speed;
private int count;
private Rigidbody rb;
public Text countText;
void Start()
{
rb = GetComponent<Rigidbody>();
count = 0;
countText.text = "Count = " + count.ToString();
SetCountText();
}
void Update()
{
if (Input.GetKeyDown("x"))
{
//Put script suggestion in here
}
}
void FixedUpdate()
{
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
rb.AddForce(movement * speed);
}
void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("PickUp"))
{
other.gameObject.SetActive(false);
count = count + 1;
SetCountText();
}
}
void SetCountText ()
{
countText.text = "Count:" + count.ToString();
}
}
Did you try this?
countText.enabled = false;
.-. , if only Ik .enabled was a thing