Search Unity

Questions about Character Controller, Colliders, and Physics in general

Discussion in 'Editor & General Support' started by Aspiring_Failure, Aug 18, 2013.

  1. Aspiring_Failure

    Aspiring_Failure

    Joined:
    Jan 21, 2013
    Posts:
    42
    Here's my specific problem: I'm trying to allow the player to pick up items and then drop them. Nothing complicated there, I just make the GameObject clicked Kinematic, parent it to the player, and then reverse all this when he releases the mouse.

    The issue is, once the gameobjecti s kinematic it doesn't interact with anything (except other rigidbodies) so it passes through walls and other gameobjects. If the player releases it in front of a wall, for example, he will drop it through the wall. So my initial question, and the foundation for my other questions is: is there a way for me to either allow the player to pick this object up without changing it's physics behavior or is there a way for me to change the player's own collider to ENCAPSULATE or INCLUDE the picked up object?

    I've messed around with the character controller component and it doesn't seem compatible with compound colliders. If I add more colliders as children, they are basically ignored. My second question (which is sort of moot if the firsto ne is answered) is: Is there ANY way to either make the character controller work with other colliders, or at least scale it differently across the x and y axis?

    And my last question is: Is there any way to reduce the performance overhead of static colliders? Right now I'm getting reasonable performance by playing with the time scale, but this has some pretty ugly effects when you actually mess with dropping rigidbodies. I've got hundreds of tree colliders and many colliders within each level that I control by activating or deactivating when the player gets so close, but the performance overhead is still pretty huge. On a side note, this conclusion that the problem is colliders is based only on me comparing performance with and without certain colliders enabled and disabled, plus messing with the timescale, It could be that I have some horribly written scripts slowing me down, but I don't have Unity PRO so no profiler.
     
  2. selvin

    selvin

    Joined:
    Dec 30, 2012
    Posts:
    57
  3. Aspiring_Failure

    Aspiring_Failure

    Joined:
    Jan 21, 2013
    Posts:
    42
    The problem with this is that the object being picked up is still going to just pass through all the walls. That's just what happens when you make a rigidbody kinematic, -only other rigidbodies will collide with it. Is there a way to parent an object (or get it to follow the player) without making it kinematic first?

    Btw thanks for the reply, I really appreciate any help on this.
     
  4. selvin

    selvin

    Joined:
    Dec 30, 2012
    Posts:
    57
    Have you tried to disable gravity instead of setting the rigidbody to kinematic? Something I would try :) and see what happens.