I need to have an object with a rigidbody move relative to the player, but still collide with things.
In my game, the player can pick up objects (like Amnesia or Portal), and walk around with them. This is accomplished by parenting the object to the player when they click it. The problem is that the rigidbody on the object acts extremely strange and moves independently of the player’s movement.
Originally, I just deleted the rigidbody from the object when the player picked it up, and then added it back when they dropped it. However, when I do that, the object didn’t collide, and went through walls.
So, I need to keep the object in the exact same position relative to the player at all times, but still collide with other objects and walls. How could I do this?
Because it is still affected by physics. Set the child object’s rigid body to kinematic like so: rigidbody.isKinematic = true; which will prevent it being affected by external physics (although it will still affect other physical objects.
As above, but remember, the actual kinematic rigid body will never be affected by other things. Although it will affect them.
I’ve tried making it kinematic, but it doesn’t collide with non-rigidbody objects, like the wall, which is the problem. Can I make it collide with the wall but also not have physics applied to it? Or am I just trying to do something near-impossible?