tags: 3apersona tercera 3a
Basic Raycast Door
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class CharacterMovementScript : MonoBehaviour
{
public NavMeshAgent playerNavMeshAgent;
public Camera playerCamera;
public Animator playerAnimator;
public bool isRunning;
public bool isDeath;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
bool isDeath = playerAnimator.GetBool("isDeath");
if (Input.GetMouseButton(0) && !isDeath)
{
Ray myRay = playerCamera.ScreenPointToRay(Input.mousePosition);
RaycastHit myRaycastHit;
if(Physics.Raycast(myRay, out myRaycastHit))
{
playerNavMeshAgent.SetDestination(myRaycastHit.point);
}
}
if (playerNavMeshAgent.remainingDistance <= playerNavMeshAgent.stoppingDistance)
{
isRunning = false;
}
else
{
isRunning = true;
}
playerAnimator.SetBool("isRunning",isRunning);
}
}