Skip to content
This repository has been archived by the owner on Aug 28, 2022. It is now read-only.

Commit

Permalink
Fix AI and navmesh
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandy Carter committed Mar 21, 2013
1 parent 4e9494d commit ea2bacb
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
Binary file modified Assets/Prefabs/Characters/Sal Instance.prefab
Binary file not shown.
Binary file modified Assets/Prefabs/Level_01_Exterior_prefabs/Landscape_01.prefab
Binary file not shown.
Binary file modified Assets/Scenes/Level_01_Exterior/NavMesh.asset
Binary file not shown.
9 changes: 7 additions & 2 deletions Assets/Scripts/Instance/AIFollow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class AIFollow : MonoBehaviour {

public float satisfaction_radius = 2.5f;
public float urgency_radius = 7.5f;
public float movingSpeed = 0.1f;
public float movingSpeed = 0.11f;

void Start ()
{
Expand All @@ -17,7 +17,12 @@ void Start ()

void Update ()
{
float distance = Vector3.Distance(transform.position, m_Player.position);
Vector3 travelVector = m_Player.position - transform.position;
travelVector.y = 0.0f;
float distance = travelVector.magnitude;
float yRot = Quaternion.LookRotation(travelVector).eulerAngles.y;
transform.rotation = Quaternion.Euler(transform.rotation.x, yRot, transform.rotation.z);

if(distance < satisfaction_radius) {
//Debug.Log("Player within satisfaction radius. Idling.");
agent.Stop();
Expand Down

0 comments on commit ea2bacb

Please sign in to comment.