I am trying to create an impassible object (i.e. invisible wall). I have been using a combination of components to the object but I have not found a solution.
I have added ridbodies, and colliders to the wall but the ship object manages to always pass through or simply push it
My ship object is structured like this
player_ship
Box collider - IsTrigger not enabled
Ridgidbody - IsKinematic enabled
Box Collider - isTrigger enabled
Rigidbody - nothing enabled
<Child Obj of player_ship - ship>
Sphere collider - IsTrigger enabled
I need to have these things enabled for the various scripts attached to each of these objects.
What would I need to do to create an impassible object for this object?
Thanks.
To expand on the issue: translating an object simply sets it’s new position. The physics system is not taken into account in any way.
To move using physics, you either add forces to it with the Rigidbody’s AddForce method, or you set the Rigidbody’s velocity directly. The second one is a lot easier to deal with if you’re a beginner, as you can replace your transform.Translate(direction) with rigidbody.velocity = direction.
Also, kinematic rigidbodies will not move by velocity, so make sure to turn that off.
Rigidbody.MovePosition moves the rigidbody to a certain position. If that position is inside a wall, the rigidbody will be pushed out of the wall again through physics.
If that position is on the other side of that wall, though, the rigidbody will teleport through. Unless you have interpolation settings on, the MovePosition method isn’t in any way different from just setting the transform’s position.