• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by olivercaddy · Apr 26, 2013 at 02:49 PM · ainoobdeltatime

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);
 }
Comment
Add comment · Show 6
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image robertbu · Apr 26, 2013 at 02:58 PM 0
Share

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 mind. 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.

avatar image olivercaddy · Apr 26, 2013 at 03:06 PM 0
Share

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 :/

avatar image robertbu · Apr 26, 2013 at 03:13 PM 0
Share

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.

avatar image olivercaddy · Apr 26, 2013 at 03:19 PM 0
Share

Yeah you are right I just delete the enemy and still had the problem hmmmm I dont know what to do now lol

avatar image olivercaddy · Apr 26, 2013 at 03:23 PM 0
Share

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

Show more comments

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

13 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Controlling AI Movement 0 Answers

Simple AI Script help 2 Answers

Where do I assign GUI scripts? 1 Answer

How can an enemy deplete players health? 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges