Restrict held object movement
I allow my player to pick up objects and have them follow the cursor, which presents 3 unique problems:
when i hold the object, i set it's transform.position to the Camera.main.ScreenPointToRay, however, it phases through the walls of my building (both have mesh collider, rigidbody)... The building has kinematic enabled on the rigidbody, and the objects, when not held have it disabled so they can sit on the building floor. When i pick up the object i turn kinematic on the object, and gravity off so it sticks to the screen point. However, when i do this it won't be affected by the wall since they are both kinematic.
some assets don't have the proper rotation. however, if i try to parent it to a corrected object, then the raycast to pick up the object won't find the collider of the child
i have weights for the objects, obviously a 1lb object shouldnt knock around a 1000lb object, but i'm not sure how to make this happen. Rigidbody.mass doesn't help
Not sure how to completely answer your questions, but I can offer a couple of tips. For starters, setting a rigidbody to kinematic means that it no longer reacts to collisions or forces. Secondly, its generally a bad idea to move a rigidbody by setting its transform. You might try using rigidbody.moveposition ins$$anonymous$$d.
https://docs.unity3d.com/ScriptReference/Rigidbody.$$anonymous$$ovePosition.html
I’ll give that a try and see if that gets rid of my need to mess with kinematic
Your answer
Follow this Question
Related Questions
Rigidbody randomly going through collider 1 Answer
Why do objects fall through terrain? 0 Answers
How to ensure raycasts hit colliders inside of trigger colliders on objects that have a rigidbody? 0 Answers
Freezed object loses it's collider 1 Answer
how to prevent a kinematic rigidbody from going through static colliders 0 Answers