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 am affected by this issue as well. haqqaton, did you get a response from Unity? "Nothing should ever need to go faster than 100 units/second" is a lousy attitude in my opinion. In my experience the max feels more like 25 units/second. My camera follows my ship, and my ship fires projectiles. Right now, when my ship hits the velocity cap, all sorts of physics stuff breaks down. My projectiles can't speed away from the ship in the forward direction, for example. I view this as a glaring bug.
@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) instead 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.
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.
Thanks Balint, but I couldn't find anything that might help there.
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.
I have the same issue. Another solution is to set bigger «Pixels to Unit» property (eg. 100) for all sprites and decrease camera size.
Thanks Lukomskyi, but I ain't not using sprites. My 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][1] [1]: /storage/temp/18503-camera.png
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
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.
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.
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!
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
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.
PLEASE can someone from unity explain this? i have the same problem and it severely limits my game. Thanks
– MileSplitI am affected by this issue as well. haqqaton, did you get a response from Unity? "Nothing should ever need to go faster than 100 units/second" is a lousy attitude in my opinion. In my experience the max feels more like 25 units/second. My camera follows my ship, and my ship fires projectiles. Right now, when my ship hits the velocity cap, all sorts of physics stuff breaks down. My projectiles can't speed away from the ship in the forward direction, for example. I view this as a glaring bug.
– CleanCutThanks @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?
– CleanCutHi @CleanCut, my game doesn't have any sprites (only polygons) so I've changed the transform scale only.
– haqqaton@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) instead 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.
– CleanCut