position2 벡터의 연산 : 게임오브젝트 이동 using System.Collections; using System.Collections.Generic; using UnityEngine; public class App : MonoBehaviour { [SerializeField] private GameObject playerGo; //게임오브젝트 변수 xxxGo private void Start() { Vector2 playerPos = new Vector2(3.0f, 4.0f); playerGo.transform.position = playerPos; // 오브젝트 이동 3, 4, 0 playerPos.x += 8.0f; playerPos.y += 5.0f; playerGo.transform.position = playerPos; //11, 9, .. 2024. 1. 28. 벡터 연산의 이해 using System.Collections; using System.Collections.Generic; using UnityEngine; public class App : MonoBehaviour { [SerializeField] private Transform a; //멤버변수 [SerializeField] private Transform b; private void Start() { //두 벡터의 뺄셈 연산 //연산 결과 : 방향 벡터 (새로운) Vector3 c = b.position - a.position; //벡터의 방향과 길이 DrawArrow.ForDebug(a.position, c, 10, Color.red); } } 2024. 1. 25. 이전 1 다음