- 버튼 누르면 큐브 생성하기
B 버튼 클릭하면 큐브 생성해서 내가 만든 mergeTest.cs 스크립트 컴포넌트 추가하기.
using UnityEngine;
public class playerInput : MonoBehaviour
{
void Update()
{
if (Input.GetKeyDown(KeyCode.B))
{
GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
cube.AddComponent<mergeTest>();
}
}
}
- mergeTest.cs
using UnityEngine;
public class mergeTest : MonoBehaviour
{
void Update()
{
Vector3 playerPosition = GameObject.FindGameObjectWithTag("Player").transform.position;
transform.position += Vector3.forward * Time.deltaTime;
}
}
유니티 오브젝트 부모(상위),자식(하위) 관계 만들기 (0) | 2024.09.30 |
---|---|
유니티 procedural animation, rigging 연구중 (0) | 2024.09.29 |
유니티 파티클 시스템 제거하기(Destroy) (1) | 2024.09.28 |
유니티 캐릭터 위치 그대로 저장하고 불러오기 (0) | 2024.09.25 |
유니티 포탈타고 다음 씬으로 넘어가기, 씬전환시 페이드 인 아웃 효과 (0) | 2024.09.25 |