Hello,
I have downloaded this Unity Asset Store - The Best Assets for Game Making little fellow for my game, outstanding model i give that to the creator but here’s my problem. I want him to be my nemesis in game, the final boss, the one i have to beat to complete the game. But i cant get it right. I have wrote a simple script for him to detect and attack me but it wont work…
#pragma strict
var Distance : float;
var Target : Transform;
var lookAtDistance = 25.0;
var attackRange = 15.0;
var moveSpeed = 5.0;
var Damping = 6.0;
function Update ()
{
Distance = Vector3.Distance(Target.position, transform.position);
if (Distance < lookAtDistance)
{
lookAt();
}
if (Distance > lookAtDistance)
if (Distance < attackRange)
{
attack ();
}
}
function lookAt ()
{
var rotation = Quaternion.LookRotation(Target.position - transform.position);
transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * Damping);
}
function attack ()
{
transform.Translate(Vector3.forward * moveSpeed * Time.deltaTime);
}
That’s not even the biggest of my problems, he is moving exactly like my player, i press w he also moves in his direction, i press space he jumps with me, why? And since i am a new programmer or yeah, lets call me that i cant find a solution here is the code for his movement. If there is anyone out there that can find something, please…help!
Thank you for your time guys
2606680–182702–monstercontroller.js (7.06 KB)