Happy Friday everyone. So I’m a bit foggy on modifying the collision box for my ground platform. I found the documentation on the site for adjusting the collision box but I would like to understand it more so I don’t keep putting random numbers in hoping it works. With the code below, I know that the setSize method adjusts the body but I don’t think I fully understand each value. Also setting body.velocity.x and body.immovable, is that part of the modified collision box?
// This adjusts the collision body size to be a 100x50 box.
// 50, 25 is the X and Y offset of the newly sized box.
sprite1.body.setSize(100, 50, 50, 25);
sprite1.body.immovable = true;
sprite2.body.velocity.x = -100;
I don’t want it to move, this particular platform is static (my ground platform). The problem is that my art work for the platform (because of how I have my grass implemented) makes the objects hover slightly above the ground platform by about 5 pixels. So I want to reduce the collision box so that my objects will appear to be actually on the platform.
@samme thank you for the help. I used this and it worked great. Thanks for the documentation resources for this. This still feels like a somewhat clunky way to adjust collision boxes just because I have to change the collision box on each object and it doesn’t let me target an entire group which would be ideal. Especially when my physics group objects are all the same size. but it works!