- Home /
Forward movement Slow? Delta.time? Frame Rate?
Hey I honestly dont know what I am doing with script I have just used ones from the web but as soon as I got the AI script for my enemy, my players forward movement became really slow. However when I look in the sky it become how it should. I have read a lot on hear but could really do with some help.
Thanks for your time.
Hears the AI script,
var Distance;
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 < 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);
}
How many enemies are being spawned and how complex is the mesh you are using for your enemies? The behavior you describe would happen if there were a bunch of enemies or if the mesh of the enemies was complex. Or if you were using a mobile device with a shader that was not created with mobile in $$anonymous$$d. Your game would speed up when you look up because the enemies would not be rendered. I doubt your performance problems have much or anything to do with this script. To test, disable the script but leave the enemies.
I only have one enemy and he is just a cube at the moment. It still seems to happen when the scrip is disabled the thing is it was fine before I added the enemy :/
Delete the enemy as well just to make sure the issue is in no way related to the enemy, but it sounds like there problem is elsewhere.
Yeah you are right I just delete the enemy and still had the problem hmmmm I dont know what to do now lol
Sorted it i had a flash light in front of my that once I removed that I could move again Thanks for the help man very appreciated
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Controlling AI Movement 0 Answers
Enter Trigger, display Text, then delete object 1 Answer
Digital Clock: Time.time > 60 2 Answers
Simple AI Script help 2 Answers