Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
3
Question by haqqaton · Nov 17, 2013 at 01:57 PM · rigidbodyrigidbody2dvelocitymove an object

Unity limiting max velocity on Rigidbody?

Hi all,

I've made a scene (2d) with walls (rigidbody2d + boxcolliders2d) - top, down, bottom, left - and a quad moving with an horizontal velocity (there's no Y component).

I got an script attached to the quad:

 using UnityEngine;
 using System.Collections;
 
 public class test : MonoBehaviour {
 
     // Use this for initialization
     void Start () {
         rigidbody2D.velocity = new Vector2(1000f, 0f);
     }
     
     // Update is called once per frame
     void Update () {
 
     }
 
     void FixedUpdate()
     {
         Debug.Log(rigidbody2D.velocity);
     }
 }

But, the quad moves really slow and the console shows that the rigidbody's X velocity is always 100f (at max) after the initial 1000f set in Start().

I can't get it any faster. Why is that?

Thanks!

alt text alt text

screen.png (16.9 kB)
screen2.png (17.9 kB)
Comment
Add comment · Show 7
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 MileSplit · Nov 22, 2013 at 08:48 PM 0
Share

PLEASE can someone from unity explain this? i have the same problem and it severely limits my game.

Thanks

avatar image haqqaton · Dec 27, 2013 at 01:48 PM 0
Share

Hello @CleanCut, no I didn't get any word from Unity. I opened a bug report for this just to now if it's a bug or an expected behaviour but so far nothing. I got a solution (maybe a band-aid solution). As some fellows have said, try downsizing your scale. I'm using it 10x smaller now and so, my max velocity now is 10x faster. I didn't expected that would do a big difference in physics, but now everything works just fine. Every collision works as expected, even when the ball is too fast to play. So, for now, try that. Down the scale of everything: size of camera and objects. $$anonymous$$aybe that will work for you too.

avatar image CleanCut · Dec 27, 2013 at 07:28 PM 0
Share

Thanks @haqqaton, I'll try that. Did you scale down by changing the sprite's pixel-to-units, changing the scale on the transform, or both?

avatar image haqqaton · Dec 28, 2013 at 08:48 PM 0
Share

Hi @CleanCut, my game doesn't have any sprites (only polygons) so I've changed the transform scale only.

avatar image CleanCut · Dec 29, 2013 at 06:21 AM 0
Share

@haqqaton - Thanks. Since I wanted to go about 2.5 faster than the limit, I decreased my transform scale on everything by 10 times ((0.1, 0.1, 0.1) ins$$anonymous$$d of (1, 1, 1)) to end up with some headroom in case I want to go even faster. This still seems like an unreasonably low limit for a physics system, but at least I can make it work now.

Show more comments

5 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Balint · Nov 17, 2013 at 04:08 PM

This is'n an exact answer, but maybe could help. Go to edit, project settings, physics2d. Maybe there you can find the problem. (I have similar problems in 3d, here could I solve them.) Be sure to check other menus in the project settings, (i.e.: Graphics). Lot of problems hides the sollution here.

Comment
Add comment · Show 1 · 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
avatar image haqqaton · Nov 18, 2013 at 11:10 AM 0
Share

Thanks Balint, but I couldn't find anything that might help there.

avatar image
-1

Answer by sattri99 · Dec 31, 2013 at 03:04 PM

If you want to Limit the maximum Velocity of A 2dRigidbody you can apply the following script

var max : Vector2; //here you can assign your maximum values for limiting velocity for both x and y

function Update () { //this line checks whether the rigidbody exceeded the maximum velocity, and if it is,then limit it to maximum velocity if (rigidbody2d.velocity.x > max.x) rigidbody2d.velocity.x = max.x; //this is the same for y axis if (rigidbody2d.velocity.x > max.x) rigidbody2d.velocity.x = max.x;

This is how it is done. I hope you will find it useful

Comment
Add comment · Show 4 · 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
avatar image CleanCut · Dec 31, 2013 at 06:58 PM 0
Share

Not really useful for dealing with the system-imposed maximum velocity. This question is about stopping the system from imposing a max velocity upon you.

avatar image sattri99 · Jan 01, 2014 at 03:50 AM 0
Share

This was not so really bad that you have voted it down please take your vote and i will delete the answer

avatar image CleanCut · Jan 01, 2014 at 03:59 AM 0
Share

I don't have sufficient reputation to cast downvotes yet.

avatar image Benproductions1 · Jan 01, 2014 at 04:35 AM 0
Share

The answer has nothing to do with the question and doesn't answer it. Either convert it to a comment or delete it

avatar image
0

Answer by Twice-Circled · Nov 22, 2013 at 12:22 AM

I have the exact same issue, very strange. One way around it is to continue to use Rigidbody (as in the 3D version), it doesn't seem to have the same limitation.

Can anyone from Unity shed some light on this? To restate the issue, the linear velocity of Rigidbody2D seems to be capped at 100.0.

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

Answer by Lev-Lukomskyi · Nov 25, 2013 at 03:00 PM

I have the same issue. Another solution is to set bigger «Pixels to Unit» property (eg. 100) for all sprites and decrease camera size.

Comment
Add comment · Show 3 · 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
avatar image haqqaton · Nov 26, 2013 at 02:34 AM 0
Share

Thanks Lukomskyi, but I ain't not using sprites. $$anonymous$$y game is made just with polygons. That quad scale is (10, 10, 1) while camera is like the image. Do I need to worry about the scale? Do you still think that it may be the problem? Thanks!

alt text

avatar image Lev-Lukomskyi · Nov 26, 2013 at 01:20 PM 0
Share

It appears that 2d physics engines don`t like big numbers for velocity. For example in Box2D there is limit 2 units per step - see here: http://www.iforce2d.net/b2dtut/gotchas

avatar image haqqaton · Nov 30, 2013 at 11:19 AM 0
Share

Thanks Lukomskyi, I have scaled down my polygons and so the velocity has "increased" to the point it's ok for my purpose. I'll use it this way for now, but I send a message to Unity to see if it's the expected behavior (be capped). Waiting for an answer there.

avatar image
0

Answer by rxninja · Nov 25, 2013 at 11:48 PM

The 2D physics engine is strongly tied to scale. When using sprites, adjust the pixels per unit in order to get your objects down to a scale of 1. At that scale, nothing should ever need to go faster than 100 units/second, as that would pretty much teleport them across the screen instantly.

I ran into this same problem. I was using very high-res sprites and trying to work at a much larger scale (large camera size to compensate for large objects). Everything was moving super slow and it was obnoxious, but getting the PPU right fixed everything. If you don't do that, you'll start to also have trouble with forces, too.

Comment
Add comment · Show 1 · 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
avatar image haqqaton · Nov 26, 2013 at 02:35 AM 0
Share

Hi @rxninja, thank you for replying. Could you read my reply to Lukomskyi? Do you still think that the scale may be the problem? Thanks!

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

23 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

Related Questions

Keeping momentum with rigid bodies. 0 Answers

Stoping Velocity Breaks Script [Solved] 0 Answers

Velocity powered rigidbody on a moving platform without parenting. 3 Answers

Slow a rigidbody to a stop over a set distance? 1 Answer

How do i add a boost in velocity to a 2D ball when you press it? 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