Transform.TransformDirection
=> Local공간에서 World공간으로 방향 Vector로 변환한다.
=> Scale이나 position의 영향을 받지않는다.
code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Hero2 : MonoBehaviour
{
public Transform target;
public Vector3 testWorldPosition;
public Vector3 testLocalPosition;
public Vector3 p1;
public Vector3 p2;
public Vector3 p3;
public Vector3 p4;
private void OnDrawGizmos()
{
this.testWorldPosition = this.transform.position;
this.testLocalPosition = this.transform.localPosition;
Vector3 offset = target.transform.position;
Gizmos.color = Color.blue;
Gizmos.DrawLine(this.transform.position,
this.transform.position + this.transform.forward * offset.z);
Gizmos.color = Color.red;
Gizmos.DrawLine(this.transform.position,
this.transform.position + target.transform.right * offset.x);
Gizmos.color = Color.yellow;
var tv = this.transform.forward * offset.z + target.transform.right * offset.x;
Gizmos.DrawLine(this.transform.position, this.transform.position + tv);
Gizmos.color = Color.white;
p1 = this.transform.TransformDirection(offset);
Gizmos.DrawLine(Vector3.zero, p1);
/**
Gizmos.color = Color.magenta;
Vector3 tv2 = Vector3.forward * offset.z + Vector3.right * offset.x;
Gizmos.DrawLine(this.transform.position, this.transform.position + tv2);
Gizmos.color = Color.green;
p3 = this.transform.InverseTransformPoint(offset);
var tv3 = this.transform.forward * p3.z + this.transform.right * p3.x;
Gizmos.DrawLine(this.transform.position, this.transform.position + tv3);
Gizmos.color = Color.cyan;
p4 = this.transform.TransformPoint(offset);
Gizmos.DrawLine(Vector3.zero, p4);
**/
}
}
'Unity3D > 수업내용' 카테고리의 다른 글
Unity2D) Sprite 편집하기 (0) | 2020.11.25 |
---|---|
2020.11.06 IntroScene 만들기 (0) | 2020.11.06 |
2020.11.05 미니맵 생성 (0) | 2020.11.05 |
2020.11.04 코루틴함수(Coroutine) (0) | 2020.11.04 |
2020.11.03 스크린에서 클릭 시 해당 위치에 Ray 체크 (0) | 2020.11.03 |