Quantcast
Channel: Questions in topic: "invokerepeating"
Viewing all articles
Browse latest Browse all 220

How to cancel an Invoke from another script,How to Cancel an invoke from another script

$
0
0
So basically I'm trying to cancel an InvokeRepeating call from another script using this code: void OnTriggerExit(Collider otherCollider) { if (otherCollider.tag == "Player") { CancelInvoke ("Approached"); But the cancel Invoke doesn't cancel it. This is the invoke I am trying to cancel: using UnityEngine; using System.Collections; public class EnemyAi : MonoBehaviour { public Transform target; public Transform myTransform; Animator anim; // Use this for initialization void Start () { anim = GetComponent (); } // Update is called once per frame void Update () { } void Approaching () { transform.LookAt (target); transform.Translate (Vector3.forward * 1 * Time.deltaTime); anim.SetInteger ("EnemyState", 1); } public void Attack () { anim.SetInteger ("EnemyState", 2); CancelInvoke ("Approached"); } public void Approached () { InvokeRepeating ("Approaching", 0.01f ,0.01f); } ,

Viewing all articles
Browse latest Browse all 220


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>