18 lines
553 B
C#
18 lines
553 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.AI;
|
|
|
|
public class TeleportNavMeshAgent : MonoBehaviour
|
|
{
|
|
[SerializeField] NavMeshAgent navMeshAgent;
|
|
|
|
public void TeleportToTargetPosition(Transform targetPosition)
|
|
{
|
|
navMeshAgent.Warp(targetPosition.position);
|
|
// Match the rotation of the destination transform
|
|
navMeshAgent.transform.rotation = targetPosition.rotation;
|
|
Debug.Log("Teleported" + navMeshAgent.name + "nav mesh agent to target position");
|
|
}
|
|
}
|