Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

raul21

Newbie
  • Content Count

    1
  • Joined

  • Last visited

Community Reputation

0 Neutral

About raul21

  • Rank
    Newbie

Profile Information

  • Gender
    Male
  • Location:
    Brazil
  1. Hello,i'm kind a new in programing and i hope can someone help me to make a damage script on my game,cause i can t figure out how. Here is my health script,and hope someone can help. using UnityEngine; using UnityEngine.Networking; namespace S3 { public class PlayerHealth : NetworkBehaviour { public const int maxHealth = 100; [SyncVar(hook = "OnChangeHealth")] public int currentHealth = maxHealth; public RectTransform healthbar; public void TakeDamage(int ammount) { if(!isServer) { return; } currentHealth -= ammount; if(currentHealth <=0) { currentHealth = maxHealth; RpcRespawn(); } } void OnChangeHealth(int health) { healthbar.sizeDelta = new Vector2(health * 2, healthbar.sizeDelta.y); } [ClientRpc] void RpcRespawn() { if(isLocalPlayer) { transform.position = Vector3.zero; } } } }
×
×
  • Create New...