본문 바로가기
KDT/유니티 기초

23/08/04 유니티짱 대각선으로 이동

by 잰쟁 2023. 8. 4.
728x90

멈춤 없이 타겟까지 이동(애니메이션 효과 x)

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

public class UnitychanController : MonoBehaviour
{
    public Transform target;
    private bool isMoveStart = false;

    void Start()
    {
    }

    void Update()
    {
        if(this.isMoveStart)
        {
            this.transform.Translate(this.transform.forward * 1f * Time.deltaTime,Space.World);        
        }     
    }

    public void MoveStart()
    {
        this.isMoveStart = true;
        this.transform.LookAt(target);       
    }
}