Unity Tutorial – Touch Hold to Grow and Shrink Game Object
- Subject: Unity 3D Tutorial
- Learning Time: 30 mins
In this tutorial we will explore how to work with the Touch Stationary selection inside of Unity Touch Functionality. In this project we have two 3D cubes which will be used to test the touch functionalities where you can touch and hold on the object and it grow to 3 points and when it does it will start to shrink down to 1 point in scale.
C# Flappy Bird Hunting Game MasterClass
Create a interactive shooting game with Flappy Birds
- Use OOP to make the game
- Backgrounds and Play Music
- Work with Multiple Forms
- & Much more ..
In this new course we will recreate the very popular game with a twist. We will create this game from an empty project to a fully compiled EXE file using Visual Studio. Click here to see the full course details.
Lesson objective –
- Create a Touch and Hold app in Unity using C#
- Using the Touch Phase Stationary to interact with 3D Cube.
- Limit the Growth and Shrink of the 3D Object in Real Time
- use the same method on Multiple objects in the same scene
Full Video Tutorial on How to Scale Game Objects using Touch and Hold in Unity and C#
Full Script for this project –
public class HoldAndScaleObjects : MonoBehaviour
Vector3 scaleChange = new Vector3(-0.01f, -0.01f, -0.01f);
private GameObject selectedObject;
// Start is called before the first frame update
// Update is called once per frame
if (Input.touchCount > 0 && Input.touches.phase == TouchPhase.Stationary)
Ray ray = Camera.main.ScreenPointToRay(Input.touches.position);
if (Physics.Raycast(ray, out hit))
if (hit.transform.tag == "cube")
selectedObject = hit.collider.gameObject;
selectedObject.transform.localScale += scaleChange;
if (hit.transform.localScale.y < 1f || hit.transform.localScale.y > 3f)
scaleChange = -scaleChange;