Skip to content

Instantly share code, notes, and snippets.

@ted80
Created March 7, 2016 08:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ted80/316be9a4b38221d79dcc to your computer and use it in GitHub Desktop.
Save ted80/316be9a4b38221d79dcc to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
public class AIMovement : MonoBehaviour
{
[SerializeField] private NavMeshAgent navMeshAgent;
public GameObject head;
public GameObject playerHead;
public bool MoveTo(Vector3 point)
{
if(navMeshAgent.SetDestination(point))
{
navMeshAgent.speed = 3f;
navMeshAgent.Resume();
return true;
}
return false;
}
public void shootAtPlayer()
{
gameObject.transform.LookAt(getPlayerPosition());
}
public void stopShooting()
{
}
public void reloadWeapon()
{
}
public int getBulletsLeft()
{
return 0;
}
public float getMovingDistance()
{
return navMeshAgent.remainingDistance;
}
public void stopMoving()
{
navMeshAgent.Stop();
}
public Vector3 getHeadPosition()
{
return head.transform.position;
}
public Vector3 getPlayerHeadPosition()
{
return playerHead.transform.position;
}
public Vector3 getPlayerPosition()
{
return playerHead.transform.position;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment