Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

problem with timer. OnTriggerStay

Discussion in 'Scripting' started by love_candy, Sep 1, 2014.

?

why timer>timer_of_action doest see the values

  1. couse its not how you should do it

    0 vote(s)
    0.0%
  2. couse -- i dont know, it should have worked

    0 vote(s)
    0.0%
  1. love_candy

    love_candy

    Joined:
    Aug 19, 2014
    Posts:
    17
    Hi.I made code where while OnTriggerStay + when time of level is > time_of_action and when boolean wykonano==false then create an object.
    Sadly. it doest not work.Could somobdy take a look. The code compile
    Code (JavaScript):
    1. #pragma strict
    2. var obiekt : GameObject;
    3. private  var wykonano : boolean;
    4. var miejsce : Transform;
    5. private var timer:int;
    6. public  var time_of_action:int;
    7.  
    8.  
    9. function Start(){wykonano  = false;
    10.  
    11. }
    12. function Update(){
    13. timer=Time.timeSinceLevelLoad;
    14. }
    15.  
    16. function  OnTriggerStay(other : Collider) {
    17. if (other.gameObject.tag == "Player"&& timer>time_of_action   && wykonano==false ){
    18. wykonano=true;
    19. var  objectcreate = Instantiate(obiekt,miejsce.position,Quaternion.identity);}}
     
  2. love_candy

    love_candy

    Joined:
    Aug 19, 2014
    Posts:
    17
    solved, I have put the script on wrong object .that was the reason o did not see it working