- Home /
Simple AI Script help
Hi, I have Unity Pro and I have created a game. I have downloaded a character from the asset store and I wanted to make a script for him, so he just follows the first person controller and will kill him if he gets to close. I am fairly new to scripting so yeah. Please help, thanks.
That's a very broad question - you need to do some tutorials - give it a go and come back with specific problems :) UA is for questions with specific answers...
I would also suggest to first work purely in Unity, without any imported assets or models. Create a Cube or Sphere primitive, make your script for it first and only later (much later) start working with other people's models.
Answer by hijinxbassist · Jun 26, 2012 at 07:51 AM
As @whydoidoit stated, this is for more specified question...however i know that the question you are looking for has been answered more than completely time and time again. I suggest doing some searching... heres something to get you started
public var player:Transform;
private var dist:Vector3;
function Start()
{
dist=(player.position-transform.position).magnitude;
}
function Update ()
{
if (dist < 10)
{
//attack enemy
}
}
Answer by TDGuy · Jun 26, 2012 at 07:54 AM
Something that I found a while ago and has helped me with a lot of my other work.
http://www.burgzergarcade.com/hack-slash-rpg-unity3d-game-engine-tutorial
I hope this helps.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
GuiTexture Width Change 1 Answer
ZOMBIE AI SCRIPT 1 Answer
Animay play in editor 0 Answers
Problems with java script. 1 Answer