Files
HauntedBloodlines/Assets/Scripts/Scripted Events/TeleportNavMeshAgent.cs
2025-05-29 22:31:40 +03:00

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");
}
}