|
Hi Guys! :) I have a script here and i need help how do i do so The AI Follows player just when the player is Close? I have a Script Temp Already here :D : SCRIPT using UnityEngine; using System.Collections; public class EnemyAI : MonoBehaviour { public Transform target; public int moveSpeed; public int rotationSpeed; public int maxDistance; } Any Ideas :)?
(comments are locked)
|
|
Ok, this would be a simple version. You have your target (player) that you drag in the inspector. Then it compares the position of each and if smaller than a range the NPC looks at the player and walk towards him. If the NPC gets too close, it stops walking. This way your guy is keeping its distance from the player and just follows him around. Now if you want the NPC to follow no matter what Now your guy will start follow when you get close and since the boolean never changes it will follow you till death. thanks buddy :)
Apr 22 '12 at 05:14 PM
Nahoyman78
but i get a Error: Assets/Scripts/AI Follow.js(7,13): BCE0005: Unknown identifier: 'Distance'.
Apr 22 '12 at 05:17 PM
Nahoyman78
Ooops Vector3.Distance()
Apr 22 '12 at 05:19 PM
fafase
And it is JS, you will have to convert...
Apr 22 '12 at 05:20 PM
fafase
Yeah. Thanks :)
Apr 22 '12 at 05:23 PM
Nahoyman78
(comments are locked)
|

What is the specific problem: What does it do now and how do you want that to change?
This looks like it should move closer until it gets to 1 unit away, which seems fine (but it measures center to center, so if you used normal sized cubes, 1 unit away is touching.)
I want to make so If a Player Touches/Walk near the Enemy. It starts to Follow it until the enemy / player dies
Any Ideas? :)