외적 활용 (좌우 알아내기, 문의 앞뒤 알아내기)

Unity3D 2020. 11. 25. 00:46
반응형

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

public class Model : MonoBehaviour
{
    public Transform target;

    // Start is called before the first frame update
    void Start()
    {
        
    }

    public Vector3 myDir;
    private void OnDrawGizmos()
    {
        var toOther = this.target.position - this.transform.position;

        Gizmos.color = Color.blue;
        Gizmos.DrawLine(this.transform.position, this.transform.position + this.transform.forward);

        Gizmos.color = Color.cyan;
        Gizmos.DrawLine(this.transform.position, this.transform.position + toOther.normalized);

        var perp = Vector3.Cross(this.transform.forward, toOther);
        Gizmos.color = Color.yellow;
        Gizmos.DrawLine(this.transform.position, this.transform.position + perp * 10);
        
    }
}

 

 

 

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

public class Model : MonoBehaviour
{
    public Transform target;

    // Start is called before the first frame update
    void Start()
    {
        
    }

    public Vector3 perp;
    private void OnDrawGizmos()
    {
        Gizmos.color = Color.blue;
        Gizmos.DrawLine(this.target.position, this.target.position + this.target.forward * 3);

        var toOther = this.target.position - this.transform.position;

        Gizmos.color = Color.blue;
        Gizmos.DrawLine(this.transform.position, this.transform.position + this.transform.forward);

        Gizmos.color = Color.cyan;
        Gizmos.DrawLine(this.transform.position, this.transform.position + toOther);

        perp = Vector3.Cross(this.target.right, toOther);
        Gizmos.color = Color.yellow;
        Gizmos.DrawLine(this.transform.position, this.transform.position + perp * 10);
        
    }
}
반응형

'Unity3D' 카테고리의 다른 글

랜더링 파이프라인  (0) 2020.12.21
유니티 좌표계  (0) 2020.11.27
유도탄 (내적 + 외적)  (0) 2020.11.25
unity skill indicator shader  (0) 2020.11.24
Vector3.Dot (내적)  (0) 2020.11.24
: