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

public class App : MonoBehaviour
{

    public GameObject hero;
    public GameObject monster;

    void Start()
    {
        float distance = Vector3.Distance(this.hero.transform.position, this.monster.transform.position);

        Vector3 c = this.hero.transform.position - this.monster.transform.position;
        // 방향은 모른다.
        Debug.Log(c.magnitude);

        // 정규화 시켜서 길이를 1로 만든다. 그럼 방향을 알수 있다.
        Debug.Log(c.normalized);
        
    }
}

ctor3 distance 는 벡터의 길이
길이가 1인 벡터를 만든다. 단위 벡터 
비교하기 쉽게하기 위해

'c# 강의 > 유니티' 카테고리의 다른 글

20200508 - 프리팹  (0) 2020.05.08
20200507 - 캐릭터 생성 및 무기 장착  (0) 2020.05.08
20200508 - 복습  (0) 2020.05.08
20200507 - 오브젝트 생성 및 부모설정(Instantiate)  (0) 2020.05.08
20200507 - 애니메이션2  (0) 2020.05.08

+ Recent posts