Hi all
So I’m trying to develop a game out of passion despite having no background in coding or computer science. My knowledge is basically came from the tutorials from youtube.
I’ve been trying to make my gameobject move around. But now I’m stuck with the part of adding animationclip to the character so that when it moves, it will have the animation of running
so this is my code.
can you please help me
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class worldinteraction : MonoBehaviour
{
public NavMeshAgent playerAgent;
void Start()
{
playerAgent = GetComponent();
}
void Update()
{
if (Input.GetMouseButtonDown(0) && !UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject())
GetInteraction();
}
void GetInteraction()
{
Ray interactionRay = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit interactionInfo;
if (Physics.Raycast(interactionRay, out interactionInfo, Mathf.Infinity))
{
GameObject interactedObject = interactionInfo.collider.gameObject;
if
(interactedObject.tag == “interactable Object”)
{
Anim.CrossFade(“run”);
Debug.Log(“interactable interac”);
}
else
{
playerAgent.destination = interactionInfo.point;
}
}
}
}