Search Unity

  1. Get the latest news, tutorials and offers directly to your inbox with our newsletters. Sign up now.
    Dismiss Notice

Change an object

Discussion in 'Visual Scripting' started by Osed30, Sep 14, 2020.

  1. Osed30

    Osed30

    Joined:
    Sep 6, 2020
    Posts:
    1
    Hi guys, I'm really new in all this thing, I'm trying to learn with Playmaker, I have a sprite button A and a Sprite button B, I want to start with sprite button A, click a key, the sprite change to button B, wait 1 sec and return to button A. Do you guys know how to do it?
     
  2. Ex-Crow

    Ex-Crow

    Joined:
    Aug 14, 2020
    Posts:
    111
  3. michealcaj

    michealcaj

    Joined:
    Aug 18, 2017
    Posts:
    176
    Code (CSharp):
    1. Private float timer;
    2. Public GameObject ObjA,ObjB;
    3.  
    4. Void Start()
    5. {
    6. ObjA.setactive(true);
    7. ObjB.setactive(false)
    8. }
    9. Void Update()
    10. {
    11.   MakeVisble();
    12.     If(timer > 0.1f)
    13.     {
    14.      timer -=Time.deltatime;
    15.     }
    16.    If(timer < 0.1f)
    17.       Timer = 0.0f;
    18. }
    19. //
    20. Void MakeVisble ()
    21. {
    22.   If(timer  == 0)
    23.   {
    24.      If(input.GetKey(key code.A))
    25.      {
    26.         ObjA.setactive(false);
    27.         ObjA.setactive(true);
    28.         Timer = 1;
    29.      }
    30.    }
    31.  }
    32.  
     
  4. Kerihobo

    Kerihobo

    Joined:
    Jun 26, 2013
    Posts:
    26
    Don't try learn PlayMaker in 2020, especially don't try to learn it in 2021. Use Unity's Visual Scripting instead xD
     
unityunity