Search

Object Control

[- Disclaimer -] 아래 내용은 정보보안 공부 목적으로 작성된 것이나, 이를 토대로 허가되지 않은 대상에 실습을 진행할 경우 해킹 시도로 간주하여 법적 처벌을 받을 수 있음을 알려 드립니다.
객체 속성
✦ 객체 Click 시 Capsule 객체의 제어 Script와 속성 값 설정 가능
객체 속성에 접근해 제어
✦ 객체 접근용 Class로 capsule 객체 생성 후 GameObject.Find(calsule) 저장
✦ GetComponent<>()로 Transform Component를 호출해 3D 객체를 앞방향으로 speed만큼 이동
using System.Collections; using System.Collections.Generic; using UnityEngine; public class MailController : MonoBehaviour { public int timer = 0; public GameObject capsule; public float speed = 3.0f; // Start is called before the first frame update void Start() { Debug.Log("초기화가 이루어졌습니다."); capsule = GameObject.Find("Capsule"); } // Update is called once per frame void Update() { timer++; Debug.Log(timer + "번째 Update"); capsule.GetComponent<Transform>().Translate(Vector3.forward * speed * Time.deltaTime); } }
Plain Text
복사
✦ this 객체로 해도 된다고 하는데 나느 잘 모르겠음
객체 속성에 접근해 제어
✦ 집으로 가고 있는 모양인 Capsule