I have a problem in my enemy ferab and i want to solve it because i try everything until now..
This is the codes:
1- Enemy animation:
using System.Collections;
using UnityEngine;
public class EnemyAnimation : MonoBehaviour {
Animation _animation;
void Start () {
_animation = GetComponentInChildren<animation> ();
string animationToPlay = "";
switch (Random.Range (0, 3)) {
default:
case 0:
animationToPlay = "Move1";
break;
case 1:
animationToPlay = "Move2";
break;
case 2:
animationToPlay = "Move3";
break;
}
_animation [animationToPlay].wrapMode = WrapMode.Loop;
_animation.Play(animationToPlay);
_animation [animationToPlay].normalizedTime = Random.value;
}
}
The problem is line 23:
_animation [animationToPlay].wrapMode = WrapMode.Loop;
the second one:
using System.Collections;
using UnityEngine;
public class CombatGui : MonoBehaviour {
Health _playerHealth;
PlayerStats _playerStats;
[SerializeField]
Texture2D _gameOverImage;
[SerializeField]
Texture2D _winImage;
void Start () {
GameObject playerGameObject = GameObject.FindGameObjectWithTag ("Player");
_playerHealth= playerGameObject.GetComponent<health>();
_playerStats = playerGameObject.GetComponent<playerstats>();
}
void OnGUI () {
if (_playerHealth.IsDead) {
float x = (Screen.width- _gameOverImage.width)/2;
float y = (Screen.height-_gameOverImage.height)/2;
GUI.DrawTexture (new Rect (x, y, _gameOverImage.width, _gameOverImage.height), _gameOverImage);
GUI.Label (new Rect (x + 100, y + 280, 100, 100), "Zombies Killed:" + _playerStats.ZombiesKilled);
}
else if (gameManager.HasPlayerWon){
float x = (Screen.width - _winImage.width)/2;
float y = (Screen.height - _winImage.height)/2;
GUI.DrawTexture (new Rect (x, y, _winImage.width, _winImage.height),_winImage);
GUI.Label (new Rect (x + 100, y + 280, 100, 100), "Zombies Killed:" + _playerStats.ZombiesKilled);
}
}
}
The problem in:
if (_playerHealth.IsDead) {
What I have tried:
I do everything from the start along with toturials