Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Question "Expanding/Growing" A cube or circle keybind

Discussion in 'Scripting' started by MrPuppyy, Sep 4, 2020.

  1. MrPuppyy

    MrPuppyy

    Joined:
    Nov 4, 2019
    Posts:
    40
    Hello, I don't know how to do this, I am assuming it would need to be a scale tool script that scales it to the size by clicking a keybind, let's say Q. How would one start to set this up?

    I don't think I wan't any transactions like animations and stuff yet.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    39,445
    Steps to success:

    1. read inputs from keys, set variables (such as booleans that say "Scale up" and "sacle down")

    2. process the result of the inputs to change the
    transform.localScale
    of the target object.
     
  3. MrPuppyy

    MrPuppyy

    Joined:
    Nov 4, 2019
    Posts:
    40
    Can I get a example instead? so I can learn how to do it like this?
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    39,445
    The steps are so simple there really isn't an example to make, and this forum isn't about us making your scripts on call. That usually bills at about $400/hr for custom programming.

    You can solve this yourself, honest. Start with the simplest coding tutorials you can find for Unity, and in the process identify how the Update() function works, how Input is gathered and assigned to variables, and how transform components (such as .localScale) are changed.

    Armed with that knowledge you can write the script (it's probably only a few lines long) and then configure your scene (or prefab if you prefer) to make such a thing happen for your precise game context. Setting up the scene to intermesh exactly the way the rest of your game needs it to is not so much coding as it is about setting things up properly, connecting stuff, and all of this the tutorials will also help you reason about.
     
    JoNax97 likes this.