So guys i’m getting here an error and i cant get what´s the problem can some one help me please?
these are the errors :
Assets\Health.cs(17,48): error CS0411: The type arguments for method ‘GameObject.GetComponentInChildren()’ cannot be inferred from the usage. Try specifying the type arguments explicitly.
Assets\Health.cs(22,13): error CS0411: The type arguments for method ‘Component.GetComponent()’ cannot be inferred from the usage. Try specifying the type arguments explicitly.
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
public class Health : MonoBehaviour
{
public float hitPoints = 100f;
float currentHitPoints;
public Text healthText;
// Start is called before the first frame update
void Start()
{
currentHitPoints = hitPoints;
healthText = GameObject.Find("Canvas").GetComponentInChildren();
}
void Update()
{
if (GetComponent().isMine) { healthText.text = "Health: " + currentHitPoints; }
}
[PunRPC]
public void TakeDamage(float amt)
{
currentHitPoints -= amt;
if (currentHitPoints <= 0)
{
Die();
}
}
void Die()
{
if (GetComponent<PhotonView>().instantiationId == 0)
{
Destroy(gameObject);
}
else
{
if (GetComponent<PhotonView>().isMine)
if (gameObject.tag == "Player")
{
NetworkManager nm = GameObject.FindObjectOfType<NetworkManager>();
nm.standbyCamera.SetActive(true);
nm.respawnTimer = 5f;
}
{
PhotonNetwork.Destroy(gameObject);
}
}
}
}