- Home /
How to properly make a pull and push mechanic?,How to properly make a pull an push mechanic?
First, please forgive me about my english, it's not my native language xD So, I'm trying to make a 2D Game where the character needs to pull and push some boxes. I've tried every tutorial on the internet but I'm having some problems with it. For example, since my box needs to have gravity it has a Dynamic Rigidbody2D in it and my player has one as well but when the box is not being pulled or pushed by the player it needs to be a static block so that the player can jump on it. I tried to prevent the box from moving by code using transform.Position (Rigidbody.Velocity doesn't work at all), but my player keeps trying to pass through the box. I tried to increase the box's mass and linear drag but I'm not getting the result I want. How should I do it? I'm using Unity 2018 3.0f2. I thank you all in advance!
Answer by xxmariofer · Jan 13, 2019 at 10:40 AM
Im not sure if i 100% understand your question since, i dont know if u want the box to drop if the player pushes the box out of the ground or stay in the air, but i think making the box Kinematic will work for your case when the player stops pushing the box.
Sorry, yes, i want the box to drop if the player pushes the box out of the ground, but if I make the box's rigidbody $$anonymous$$inematic when the player stops pushing the box it won't fall to the ground. It stays in the air.
Ok, maybe playing arround with drag and angular drag propertys will work for you, incrementing it (a lot) when player stops moving arround items.