We are making a 2d platformer right now. One of the obstacles are rocks.
The desired behavior is that when walking against the rock and holding the ‘E’ Button the rock starts being pushed. Otherwise it goes back to not being movable. The character should be able to push the rock into a hole doing this.
My attempt to do this was checking if the button is pressed and then setting the rigidbody from kinematic to non kinematic.
This ended up leaving the rock hanging in the air once the character stopped pressing.
I worked around this by checking if the rock was colliding with the ground and not setting it back to kinematic if it wasn’t. This kinda worked but it seems like a really hacky solution.
What i would simply like to express is, that the force the character normally applies to the rock is only applied if the button is pressed, but simply keeping the rock as a physics object, that all other forces act normally upon.
Is this possible?
if(Input.GetKey(KeyCode.E)){ // Apply Force }else{ // Set Rigidbody to kinamatic }
– 5c4r3cr0w