Question by
nerminshawkat · Dec 21, 2015 at 04:33 PM ·
physicsrigidbody2dforce
Impulse Force not smooth
I'm trying to make falling rocks with different speeds and directions
here is the code , it is working perfectly however The rocks aren't falling smoothly. am I missing something
gravity scale = 0
void Start () {
int MaxForce = 0;
int MinForce = 0;
switch (GameManager.Instance.mode)
{
case GameMode.Easy:
MaxForce = 10;
MinForce = 5;
break;
case GameMode.Medium:
MaxForce = 15;
MinForce = 7;
break;
case GameMode.Hard:
MaxForce = 20;
MinForce = 9;
break;
default:
break;
}
Vector2 Force = new Vector2(Random.Range(MinForce-3, MaxForce-3) * Random.Range(-1f, 1f), Random.Range(-MaxForce, -MinForce));
GetComponent<Rigidbody2D>().AddForce(Force,ForceMode2D.Impulse);
}
Comment
Answer by Bicsi · Jun 28, 2021 at 07:00 PM
Hi,
I know this is very old, but in case anyone finds this in the future, i believe the problem here is the fact that you are using "ForceMode2D.Impulse" Impulse is instant and not smooth at all. Using the Forcemode "Force" would be more sufficient if you want a realistic moving object.