101won 2024. 8. 20. 21:51

백터
float
Game 캔버스ui는 픽셀 Vector2
Scene은 3D Vector3

씬 단위는 유닛



z 앞
x 오른쪽
y 위

- 방향 백터(c백터)


this.transform.position = new Vector3(a, 1, 1);

Vector3 변수명 = this.transform.position;
위치 변경
월드 포지션, 절대 좌표
기본은 0,0,0  
리셋하면 로테이션 값도 변하뮤

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class App : MonoBehaviour
{
    private void Update()
    {
        float a = 10;
        this.transform.position = new Vector3(a, 1, 1);
    }
}



Transform.localPosition
길이=거리=크기, 방향
로컬 포지션, 부모 클래스 대비 상대 좌표



this.transform.localScale = new Vector3(a, 1, 1);

축 방향으로 스케일 변경

스프라이트 반전

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class App : MonoBehaviour
{
    private void Update()
    {
        float a = 10;
            this.transform.localScale = new Vector3(a, 1, 1);
    }
}




this.transform.Rotate(0, 1f, 0);
축으로 회전

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class App : MonoBehaviour
{
    private void Update()
    {
        this.transform.Rotate(0, 1f, 0);
    }
}




this.transform.Translate(0.01f, 0, 0);
현재 위치에서 이동

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class App : MonoBehaviour
{
    private void Update()
    {
        this.transform.Translate(0.01f, 0, 0);
    }
}

 



Distance 오브젝트 간 거리 체크 및 충돌 감지 방법

https://101won.tistory.com/47

 


유니티 draw arrow git : 방향 표시
https://gist.github.com/MatthewMaker/5293052#file-drawarrow-cs

 

DrawArrow.ForDebug(a, c, 5,Color.yellow, ArrowType.Solid); // 위치, 방향, 듀레이션 컬러, 화살표 모양