Script that allows a player to change the size of a game object using the arrow keys. The object should grow larger when the up arrow is pressed and shrink when the down arrow is pressed.

using UnityEngine;

public class ObjectResize : MonoBehaviour
{
    public float resizeSpeed = 0.1f;

    private void Update()
    {
        if (Input.GetKey(KeyCode.UpArrow))
        {
            transform.localScale += Vector3.one * resizeSpeed * Time.deltaTime;
        }
        if (Input.GetKey(KeyCode.DownArrow))
        {
            transform.localScale -= Vector3.one * resizeSpeed * Time.deltaTime;
        }
    }
}

Related Posts

Leave a Reply