본문 바로가기

Vector36

벡터의 연산 2 Transform.position (1,1) = (1,1) 지점으로 이동 Transform.Translate (1,1) = 현재위치에서 (1,1) 만큼 이동 벡터의 스칼라곱 : 벡터의 길이가 늘어난다 벡터의 내적 Vector3 a = new Vector3(0,1,0); 위쪽 Vector3 b = new Vector3(1,0,0); 아래쪽 Vector3.Dot(a,b); 수직인 벡터끼리 내적하면 결과는 0 두 벡터의 방향이 일치하는 정도의 크기를 구하는 것(두 벡터의 유사도). 정확히 말하면, 한 벡터에 대한 다른 벡터의 포함 정도. -1~ 1 사이의 값이 나옴 1이 나오면 두 벡터가 같다는 의미 시야각에 들어왔는지 또는 전방, 후방에 있는지 체크할 때 좋다 내적의 값이 0보다 클때는 전방 0보다 작을 때.. 2024. 3. 4.
벡터의 연산1 using System.Collections; using System.Collections.Generic; using UnityEngine; public class Capsule : MonoBehaviour { [SerializeField] private GameObject firePoint; [SerializeField] private float moveSpeed = 1f; [SerializeField] private float fireRange = 1f; void Update() { // 화살표 그리기 DrawArrow.ForDebug(this.transform.position, transform.forward* fireRange , 10, Color.yellow, ArrowType.Solid); /.. 2024. 3. 4.
매 프레임마다 가장 가장 가까운적 찾기 using System.Collections; using System.Collections.Generic; using UnityEngine; public class CSightVisualizer : MonoBehaviour { public float radius = 8; private void OnDrawGizmos() { //탐지 범위 보여주기 //위치, 방향, 360도, 시야 3유닛 GizmosExtensions.DrawWireArc(this.transform.position, this.transform.forward,360,radius); } } using System; using System.Collections; using System.Collections.Generic; using Unity... 2024. 2. 27.
SwipeCar Car using System.Collections; using System.Collections.Generic; using UnityEngine; public class CarController : MonoBehaviour { [SerializeField] private float attenAttenuation = 0.96f; [SerializeField] private float divied = 500f; private float speed = 0; private Vector3 startPosition; void Update() { if (Input.GetMouseButtonDown(0)) { //화면을 터치한 위치 가져오기 Debug.Log(Input.mousePosition); this.start.. 2024. 1. 28.
벡터의 연산 : 게임오브젝트 이동 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.