Here’s my script, bolded is where the location of the error is
using UnityEngine;
using System.Collections;
public class Player_Movement : MonoBehaviour {
public GameObject playerStatus;
[Header("Player Variables")]
public int playerSpeed = 500;
public int playerJumpForce = 1000;
public float waitTime = 3.0f;
public float damage = 2.0f;
public bool facingRight = true;
[Space(10)]
public float movement;
public bool jump;
[Header("Ground Check")]
public Transform groundCheck;
public bool grounded = false;
public float groundCheckRadius = 0.1f;
public LayerMask whatIsGround;
[Header("Animations")]
public Animation player_Animation;
public AnimationClip animation_PlayerIdle;
public AnimationClip animation_PlayerWalk;
public AnimationClip animation_PlayerJump;
public AnimationClip animation_PlayerFall;
public AnimationClip animation_PlayerDie;
public AnimationClip animation_PlayerDamage;
void Start()
{
//player_Animation = gameObject.GetComponentsInChildren<Animation> ();
}
void Update()
{
if (Input.GetButtonDown ("Jump") && grounded) {
jump = true;
player_Animation.Play ("Jump_Anim_1");
}
else if (Input.GetButtonUp ("Jump")) {
jump = false;
player_Animation.Play ("Falling_Anim_1");
}
movement = Input.GetAxis("Horizontal");
}
void FixedUpdate()
{
GroundCheck();
PlayerMovements();
}
void FlipModel()
{
facingRight = !facingRight;
Vector3 scale = transform.localScale;
scale.x *= -1;
transform.localScale = scale;
}
void GroundCheck()
{
grounded = Physics2D.OverlapCircle(groundCheck.position, groundCheckRadius, whatIsGround);
}
void PlayerMovements()
{
GetComponent<Rigidbody2D> ().velocity = new Vector2 (movement * playerSpeed * Time.deltaTime, GetComponent<Rigidbody2D> ().velocity.y);
if (movement > 0 && !facingRight) {
FlipModel ();
player_Animation.Play ("Walk_Anim_1");
} else if (movement < 0 && facingRight) {
FlipModel ();
player_Animation.Play ("Walk_Anim_1");
}
if (grounded == true && jump == true)
GetComponent<Rigidbody2D> ().AddForce (new Vector2 (0, playerJumpForce));
jump = false;
}
**void OnTriggerEnter (float playerStatus)
{
playerStatus = GameObject.FindGameObjectWithTag ("Player").GetComponent<Player_Health>();
playerStatus.ApplyDamage (damage);
player_Animation.Play ("Damage_Anim_1");
}**
public void ApplyDamage (damage)
{
print("applying damage" + damage);
print("Health left " + Player_Health);
if (Player_Health <= 0)
{
Player_Health = 0;
Die();
}
}
void Die()
{
print ("dead");
AnimationState = GetComponent<Animation>("Lose_Anim_1");
AnimationState.Play ("Lose_Anim_1");
}
}