Hello, I’m making a 2d block game. I want the blocks to fall down when I instantiate them and i want them to stop when they land on top of another block or a block I’m using as the ground. I am currently using rigid bodies and gravity to make the blocks fall and have given them constraints so they may only move in the Y Axis. However I am having a problem when the blocks land they bounce for a short time before coming to a stop. I have tried modifying their masses, sizes, the mass and size of the block they are hitting, adjusting the gravity, adjusting the bounce threshold, using physics materials and setting the bounce value to 0. But nothing has worked, when the blocks land they always bounce for a short period of time before stopping, is there something i can do in script to make them stop as soon as they land, or a setting I am using wrong?
Strange that the values you changed didn’t worked… Maybe some more experience people can help you out with this.
For now I would suggest using some kinda OnTriggerEnter Effect, and just make them force in the position they currently are when they hit something (your blocks). You could also try to remove the rigidbody or something in that direction to make them stop bounce when they enter the trigger are or the collider. Can’t say something certain, just try it out and test what suits your needs, until another one could help you a bit more, hehe
While it’s probably not the best answer… You could just run a script to check if the y velocity is greater then 0 (meaning moving up) and if it is, apply gravity to it.
Should look something like this in C#.
Rigidbody rb;
void Start()
{
rb = GetComponent<Rigidbody>();
}
void Update()
{
if(rb.velocity.y >= 0)
{
rb.velocity.y = Physics.gravity.y;
}
}
Physics.gravity.y should equal -9.8 if I recall correctly. This would also have to be applied to everything you don’t want to bounce, so it could take up a bit more processing. This should help until you can find an answer in the mean time. Or, if it isn’t causing performance issues, just keep it.
Thanks Mengsk that seems to have fixed it