Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Character Controller Moving Things

Discussion in 'Scripting' started by lucashaley, May 26, 2006.

  1. lucashaley

    lucashaley

    Joined:
    May 26, 2006
    Posts:
    8
    Hello all -- I'm really new to Unity, and have been poking around. I was just wondering what the easiest way was to allow the FPS Controller package be able to push RigidBodies around. I have tried adding a RigidBody and Capsule Collider to the Graphics instance, but it just falls over and rolls around helplessly.

    Any help greatly appreciated!
     
  2. forestjohnson

    forestjohnson

    Joined:
    Oct 1, 2005
    Posts:
    1,370
    The character controller can't really interface with rigidbodies. I bet you could make a script that allows you to grab and move regular or physics objects.
     
  3. jeremyace

    jeremyace

    Joined:
    Oct 12, 2005
    Posts:
    1,661
    Can't you just parent an empty game object to it and attach a kinematic rigid body to it? Or parent a mesh in whatever shape with a collider and RB but kill the mesh renderer? Never tried it...

    EDIT: that would just work for walking and knocking things like garbage cans over or pushing pop cans, not quite sure what you want to do.

    -Jeremy
     
  4. SupaPuerco

    SupaPuerco

    Joined:
    Aug 17, 2005
    Posts:
    48
    I'm also having trouble with this. If I remember correctly an old version of the first person controller pushed other objects just fine. Is it because the FPS controller uses transforms instead of physical forces?
     
  5. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    The FPS prefab that ships with Unity is a CharacterController.
    The character controller is a very unphysical component. That is, it only handles collision detection like quake 3 does.
    If you think about it, first person controllers are not based on physics. In quake you run at 90 miles per hour, turn on a dime and stop completely in one frame.
    A rigidbody can not do this because it simply isn't physics you are trying to achieve.

    Older versions of Unity used a rigidbody based First person controller and i am sure you can find the scripts somewhere in the forum archives. It is still useful for cases where you want your character to also be affected by forces automatically.


    If you want a more traditional quake style controller but want to affect other objects just apply forces manually. The CharacterController documentation describes how to do that here:
    http://www.otee.dk/Documentation/ScriptReference/CharacterController.html#OnControllerControllerHit