1. 간단한 3D 오브젝트중 큐브를 만들어서 Scale을 조절하자
예. Scale x = 10, y = 0.2, z = 10

2. 간단한 스크립트를 작성해서 Cube 오브젝트에 넣어준다.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Map_Ground : MonoBehaviour
{
private Vector3 initialScale;
public float timer = 5f;
void Start()
{
// 초기 스케일 저장
initialScale = transform.localScale;
}
void Update()
{
// 타이머 업데이트
timer = timer - Time.deltaTime;
// 5초마다 실행
if (timer <= 0f){
// Y값 유지, XZ축의 스케일 감소
transform.localScale = new Vector3(transform.localScale.x - 1f, initialScale.y, transform.localScale.z - 1f);
// 타이머 초기화
timer = 5f;
}
}
}
각자 transform.localScale = new Vector3의(x , y , z)의 Scale을 원하는 만큼 조절해준다.
| 유니티 플레이어 3D 캐릭터 방향전환(rotate,rotation) (0) | 2023.07.12 |
|---|---|
| 유니티 플레이어 3D 캐릭터 움직임, 이동 시키기 (0) | 2023.07.05 |
| 16. 유니티 모바일 이동(터치 컨트롤) (1) | 2023.06.14 |
| 15. 유니티 마우스 클릭 이벤트, 마우스 입력 사용하기 (0) | 2023.06.11 |
| 14. 유니티 안드로이드 프로젝트 빌드하기(2) (0) | 2023.06.10 |