Vector3.Project
Unity3D 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);
}
}
반응형
'Unity3D' 카테고리의 다른 글
TransformDirection, InverseTransformDirection, TransformPoint, InverseTransformPoint (0) | 2020.11.24 |
---|---|
Cinemachine Camera (0) | 2020.11.19 |
aspect ratio (0) | 2020.09.14 |
AssetBundle 만들기 (Unity Pro, iPhone Advanced Only) (0) | 2020.08.06 |
XR is currently not supported when using the Vulkan Graphics API. (0) | 2020.06.02 |