Unity3D
Vector3.Project
일등하이
2020. 10. 27. 21:42
반응형
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class App : MonoBehaviour
{
public GameObject cube;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
void OnDrawGizmos()
{
Vector3 a = this.cube.transform.position;// new Vector3(-1.0f, 0, 0);
Vector3 b = new Vector3(7.0f, 0, 0);
Vector3 c = new Vector3(0, 0, 7);
Gizmos.color = Color.gray * 0.3f;
Gizmos.DrawLine(c, a);
Gizmos.DrawLine(c, b);
Gizmos.color = Color.green * 0.5f;
Gizmos.DrawLine(a, b);
Gizmos.color = Color.magenta;
Gizmos.DrawLine(a, Vector3.Project(c - a, cube.transform.forward)+a);
}
}
반응형