This question was
closed Mar 14, 2017 at 11:07 PM by
Nova-1504 for the following reason:
Other
Nothing is happening with these scripts, why?
With these scripts:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PunchingStuff : MonoBehaviour {
Vector3 vect = Vector3.zero;
float move;
Transform player;
static Animator anim;
UnityEngine.AI.NavMeshAgent nav;
void Awake () {
anim = GetComponent<Animator> ();
nav = GetComponent<UnityEngine.AI.NavMeshAgent> ();
}
void Update () {
player = GameObject.FindWithTag ("Player").transform;
nav.SetDestination (player.position);
move = Vector3.Distance (vect, player.position) / Time.deltaTime;
anim.SetFloat ("Speed", move);
}
public static IEnumerator TriggerSet (){
nav.Stop ();
anim.SetTrigger ("PunchTrigger");
yield return new WaitForSecondsRealtime (1);
nav.Resume ();
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PunchTriggerScript : MonoBehaviour {
void Awake () {
}
void OnTriggerEnter (Collider other) {
if (other.tag == "Enemy"){
PunchingStuff.TriggerSet ();
}
}
}
Nothing happens when I run it. It's supposed to be an enemy that plays it's "Punch" animation on entering a trigger I placed and parented to the player. The trigger is big enough, no errors, Unity 5.5. What is going on?
Comment