Search Unity

call function no matter what

Discussion in 'Scripting' started by wisien92, May 10, 2014.

  1. wisien92

    wisien92

    Joined:
    Nov 16, 2012
    Posts:
    56
    i have function called SendRaycast() and i want to call it every frame .... or at least very often :) right now it's called whenever the object comes out of the if's inside update ... dunno how to achieve what i want



    here is the code:

    Code (csharp):
    1.  
    2. void Update () {
    3.         chaseTarget = GameObject.FindWithTag("Player").transform.position;
    4.         SendRaycast();
    5.  
    6.         if( isBlinded == true) {
    7.             StartCoroutine(BlindedBehavior());
    8.         }
    9.  
    10.         else if(chase == true) {
    11.             Chasing();
    12.         }
    13.  
    14.         else if(checkNoise == true  chase == false) {
    15.             CheckNoise();
    16.         }
    17.         else {         
    18.             Patroling();
    19.         }
    20. }
    21.  
     
  2. DanielQuick

    DanielQuick

    Joined:
    Dec 31, 2010
    Posts:
    3,137
    It is already being called every frame that the component is enabled and the GameObject is active. Perhaps the other functions are cancelling it out?