- Home /
Unity Ai Tutorial
Does anyone know of a good tutorial that could show me how to make a health bar, make an enemy which could cause damage until the player dies and then have a re spawn button?
That is not AI. Is a HUD tutorial. The question is quite misleading. Could you change it pls?
Answer by kabel · Sep 18, 2011 at 01:48 PM
here is a tutorial but it is very long. http://www.burgzergarcade.com/hack-slash-rpg-unity3d-game-engine-tutorial
Answer by MrLolEthan · Oct 12, 2012 at 05:00 PM
For the AI to make something follow you, you want to use something like this script I wrote:
function Update() {
enemy.transform.LookAt(target);
enemy.transform.position = Vector3.Lerp(
enemy.position, target.position,
Time.deltaTime * moveSpeed);
}
Then you want to use the variables:
var target : Transform;
var enemy : Transform;
var moveSpeed : float = 5.0;
You can select the items as the target and the enemy (which chances are is the gameobject the script is attached to) in the unity Inspector view under the script options. The complete script should look something like this:
var target : Transform;
var enemy : Transform;
var moveSpeed : float = 5.0;
function Update() {
enemy.transform.LookAt(target);
enemy.transform.position = Vector3.Lerp(
enemy.position, target.position,
Time.deltaTime * moveSpeed);
}
PS: If you don't understand what i'm talking about you should start with something easier.
Also learn about Vector3s and Vector3.Lerp. You can read up about Vector3's HERE and Vector3.Lerp HERE.
Your answer
Follow this Question
Related Questions
Complete AI Tutorial? 1 Answer
A node in a childnode? 1 Answer
Zombie AI tutorial 2 Answers
Stealth Tutorial - Navmesh AI not moving. -1 Answers
Shooting Damage Help 1 Answer