- Home /
Any way to have a rigidbody not be affected by forces, but still collide with other objects?
If i understand unity's physics right, you can have kinematic rigidbodies which won't be affected by forces and also not detect collisions, non-kinematic rigidbodies which do both, and static colliders without a rigidbody that aren't expected to move. So I want my player character to not be affected by forces, because 1. for some reason, the camera (which is a child of the player gameobject) starts rotating wildly when the rigidbody is non-kinematic 2. I don't want my player to bounce off other objects 3. If I make it kinematic, I have to add rigidbodies to all of the scenes objects which would move when the player collides with them which is certainly not what i want (the constraints don't help, the player doesn't collide with the object anymore when all the constraints are enabled). Also I don't like to use the built-in character controller, as there doesn't seem to be a way to change the capsule Collider to anything else, however i need a compound collider on my player. So is there any way to do it?
PS: This is my first question here, so pls don't kill me
I'm not sure I understand exactly what you are looking for. Does this help? "A trigger doesn't register a collision with an inco$$anonymous$$g Rigidbody. Ins$$anonymous$$d, it sends OnTriggerEnter, OnTriggerExit and OnTriggerStay message when a rigidbody enters or exits the trigger volume."
https://docs.unity3d.com/ScriptReference/Collider-isTrigger.html
Sorry if my question was confusing, but trigger colliders are not my issue. I want an object to still collide with others while not being affected by any forces. Thanks nevertheless for trying to help
I guess I'm confused by what forces you mean? "All" forces would include reaction forces due to collisions. The only other forces I can think of would be Gravity (a checkbox), and the AddForce function (just DON'T call it). Which am I missing?
Edit/addition: "2. I don't want my player to bounce off other objects " But you DO want to detect collisions? If not to bounce off each other, I fail to see why triggers won't work.
Answer by Bunny83 · Nov 08, 2017 at 07:27 PM
No, that's not possible. Collisions are detected when a non kinematic rigidbody overlaps another collider. Collisions and the collision response depend on the physics materials of the colliders.
You can try using a kinematic rigidbody and use SweepTest to manually test if the rigidbody can move to your target location.
Answer by Mazer83 · Nov 08, 2017 at 09:57 PM
Yes it is possible. Just use a collider and check the box that says: "TriggerCollider". Use OnTriggerEnter, OnTriggerExit, etc.. to detect collisions.
You can set the "isKinematic" member to false, so that it isn't affected by forces.
There's a huge difference between trigger events and collisions. Triggers just tell you that you entered / exit the trigger but not where or how much. The important information that collisions give you / the physics engine are the actual collision points and the collision normal which are necessary to properly handle collisions (in the sense of stopping your object when you hit a wall).
Trigger serve a different purpose.
$$anonymous$$azer83
I think you didn't understand my question right, I updated it now so that it hopefully is clearer what i mean. I don't only want to check if it hits another collider, I want an actual collision to happen, the difference of which Bunny83 already explained. Sorry for the bad formulation of the question, I should have made it clearer in the first place.