Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Resolved Picking up rigidbody item with non-kinematic player

Discussion in 'Physics' started by Atix07, Aug 1, 2021.

  1. Atix07

    Atix07

    Joined:
    Jul 27, 2013
    Posts:
    182
    Hello!

    Today I had to change my character controller player to non-kinematic player controller. The issue I had with it is when I pick up objects with rigidbody and parent them to player->inventory empty gameobject, item is no longer following the player and rigidbody goes crazy even though Im swithing picked up items rigidbody to kinematic. When I make items rigidbody kinematic shouldnt it get effected by physics?

    I know instead of setting it to kinematic I could destroy the rigidbody on item and re-add it when Im going to drop the item but I wanted to ask if there is another way to do this?

    Thanks!
     
  2. r31o

    r31o

    Joined:
    Jul 29, 2021
    Posts:
    460
    Without the code ishard to figure ot what is happening.
    The rigidbody SHOULD nit be physics based while being kinematic.
    You coul make two prefabs: one the pickable with rigidbody and another the inventory item with no rigidbody. When you pick up an item you could destroy the item and add the inventory item to the inventory. When dropped you could destroy the inventory item and add the pickable.

    If you want to keep your code, then instead of making it kinematic destroy it
     
    Atix07 likes this.
  3. Atix07

    Atix07

    Joined:
    Jul 27, 2013
    Posts:
    182
    Thank you for your answer. Actualty your idea is way better than destroying the rigidbody.