Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • 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 TheGronne · May 29, 2020 at 10:07 AM · objectspeedmoveobjectsconstant

Why do my objects keep changing speed?

I have followed and found countless posts and guides, yet this problem seems to never get fixed. I have 8 objects that randomly choose an object which is set to targetFood to go to. This is how I calculate the speed:

transform.position = Vector3.MoveTowards(transform.position, targetFood.transform.position, (Time.deltaTime speed GameObject.Find("EnvironmentController").GetComponent().time) / 60);

Basically, the last part is meant to make the objects go slower the more time they spend on the field (I have tried removing this in case that was the problem).

However for some reason, my objects sometimes move in a half circle to get to the object, and slow down drastically, then when they find a new object, it speeds up again to insane speeds sometimes.

I have tried to addforce on rigidbody, but then it doesn't move at all.

Why does this happen?

Comment
Add comment · Show 1
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 KoenigX3 · May 29, 2020 at 01:48 PM 0
Share

When you said you tried removing the last part, what happened? Did it slow down and speed up like before? Also, does targetFood move?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by viesc123 · May 29, 2020 at 07:52 PM

The code looks OK, apart from the EnvironmentController.time, which we can't look into. I assume counts down somehow? (Also, instead of searching for it every frame, it would be better for performance if you stored a reference to it on Start.)

Since you mentioned Rigidbodies: The commands you are using are intended for kinematic Rigidbodies or objects without Rigidbodies, so make sure that your object's Rigidbodies are set to isKinematic = true. That also means you'll get no collisions between the 8 objects. If that's not intended behavior and the objects should be able to collide with each other it's better to work with Rigidbody velocities instead.

Some more thoughts:

  • Have your tried running the code in a clean test scene to see if any other part of your scene interferes with it?

  • Also make sure your objects are not parented to other objects carrying non-kinematic Rigidbodies.

Comment
Add comment · Share
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

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.

Follow this Question

Answers Answers and Comments

139 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 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 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 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 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 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 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 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Pushing and object up/down/left/right at constant speed 0 Answers

how to keep speed canstant in flappy bird? 2 Answers

My moving object decelerates when almost reaching a next point in the bezier curve,My gameobject decelerates when reaching a next point 0 Answers

Move Object A towards Object B at a definite speed 1 Answer

How should I move an object that parents on collision? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges