Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

Do you know how to move rigidbodies like they are children, whilst allowing them to collide with the level?

$
0
0
Here's my issue: I have a rigidbody that I want the player to be able to "pick up" by holding down the LMB and then drop by releasing the LMB. I've managed to get this working two ways. The first way is to make the object kinematic and then to parent it to the camera. This works perfectly until I get close to a wall or other game object. The rigidbody being carried just passes right through, like it's nothing. Obviously, this can render the game unplayable if the player happens to drop an important object outside of his area and is otherwise just silly and undesirable. The other method I tried was to keep the item as a non-kinematic rigidbody and just move it with rigidbody.MovePosition. This also works marvelously well, and has the bonus of allowing the rigidbody to ACTUALLY collide with other the other gameobjects! But the MAIN issue, which is that the rigidbody will eventually pass through the other end of the game object, persists. I can't figure out a way to let the player carry around an object that can NOT be dropped or just "pushed" onto the opposite side of a wall. ![![![alt text][1]][2]][1] This is a picture of what's okay: The gameobject is picked up and relocates itself to the center of the player's cursor every time he moves. ![alt text][3] And this is what's happening that I DON'T like. As you can see, the carried object is actually right inside the wall, when it shouldn't be. If you were to walk a little closer, it would be right on the opposite side. [1]: /storage/temp/14571-good.png [2]: /storage/temp/14571-good.png [3]: /storage/temp/14572-bad.png

Viewing all articles
Browse latest Browse all 171066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>