Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //this is the script the player sends the damage to, and the text only shows ontop of eachother, or actually it keeps repeating on the same line
- using UnityEngine;
- using UnityEngine.UI;
- using System.Collections;
- public class DamageLogBox : MonoBehaviour {
- public static DamageLogBox Instance;
- private PlayerMovement player;
- private EnemyController eC;
- public Text textHolder;
- public string logText;
- void Start()
- {
- eC = FindObjectOfType<EnemyController>();
- player = FindObjectOfType<PlayerMovement>();
- Instance = this;
- textHolder = GetComponentInChildren<Text>();
- }
- void Update()
- {
- if(logText.Contains(player.name))
- {
- textHolder.color = Color.green;
- }
- else if(logText.Contains(eC.name))
- {
- textHolder.color = Color.red;
- }
- textHolder.text = logText;
- }
- }
- //this is hte code in the player script
- DamageLogBox.Instance.logText = this.name + " did " + PlayerStats.Instance.damage.ToString() + " damage to " + hit.collider.gameObject.name;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement