- Home /
How do I create enemies?
I'm making a survival game and i need scripts for enemy movement, spawning, and to make them die when they get shot any help? (using new version of unity)
Answer by AVividLight · Feb 01, 2011 at 10:16 PM
Randomguy1273,
I don't sugest you ask for script, as people tend to disregard it... I suggest you google "Unity 3D AI" or "Unity 3D Path". Then if I didn't like This or This you should search around on the forums for what you need... If you can't find an answer, then you need to be creative, and at least try... I (and lots of other people) will help you later, if you at least try to help yourself
Answer by Noah-1 · Feb 01, 2011 at 10:18 PM
Well enemies is one of the most difficult parts of a game, I reccomend you watching this tutorial:
http://www.youtube.com/user/TornadoTwins#p/u/48/u8t3fdKhDxg
This tutorial will show you how to create turrets.
Good Luck Randomguy.
Answer by yourgameshowhost · Oct 20, 2012 at 09:05 PM
yeah, i have been trying to. I cant seem to get it to work... I'd help if i could.
Answer by Jado406 · Jan 17, 2013 at 02:31 AM
Maybe you should try this script: var distance; var target : Transform;
var lookAtDistance = 15.0; var attackRange = 10.0; var moveSpeed = 5.0; var damping = 6.0; private var isItAttacking = false;
function Update ()
{
distance = Vector3.Distance(target.position, transform.position);
if(distance < lookAtDistance)
{
isItAttacking = false;
renderer.material.color = Color.yellow;
lookAt ();
}
if(distance > lookAtDistance)
{
renderer.material.color = Color.green;
}
if(distance < attackRange)
{
attack ();
}
if(isItAttacking)
{
renderer.material.color = Color.red;
}
}
function lookAt () { var rotation = Quaternion.LookRotation(target.position - transform.position); transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * damping); }
function attack () { isItAttacking = true; renderer.material.color = Color.red;
transform.Translate(Vector3.forward * moveSpeed *Time.deltaTime);
}
Your answer
Follow this Question
Related Questions
Rotating on X and Z axis only 2 Answers
losing lives 1 Answer
Enemies Shoot Towards Face, Would Like to have them Shoot to Chest 1 Answer
Melee range AI 1 Answer