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

character controller physics

Discussion in 'Scripting' started by Radiators, Oct 13, 2020.

  1. Radiators

    Radiators

    Joined:
    Aug 13, 2020
    Posts:
    29
    Hello
    How can character physically affect other objects ?
    for example when my 3d fps character which have character controller will collide with ball
    the ball will start to roll like when i add rigidbody
    sorry for my maybe newbie quiestion but i cannot find video or smth on this topic...
     
  2. Meishin

    Meishin

    Joined:
    Apr 12, 2019
    Posts:
    26
    The rigidbody & collider of your gameobjects define physics. So if you have 2 gameobjects (whatever those gameobjects), each with a rigidbody and a collider, they will collide (unless they are on different layers and those different layer do not apply physics).
     
  3. Radiators

    Radiators

    Joined:
    Aug 13, 2020
    Posts:
    29
    i tried to add rigidbody to gameobject with character controller but it didnt detect collisions with other objects...
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,756
    Rigidbody and CharacterController are not intended for use together, as implied in the CharacterController API documentation.

    You can instead us a Rigidbody player controller... there's probably several hundred examples around the web, or it's pretty easy to roll your own.
     
    Joe-Censored likes this.
  5. Stevens-R-Miller

    Stevens-R-Miller

    Joined:
    Oct 20, 2017
    Posts:
    664
    Word. You can throw a brick at the internet and the odds are it will hit a player controller script. I have never found one that is as truly universal as I'd like, but this one on the Unity Community Wiki is a workable place to start.

    Interestingly, it is prefaced with this observation:
    I'm not sure if I agree, and I wish the writer of that comment had said who it was that recommended using the character controller over the rigidbody version. I think it really does depend on the needs of your particular game/project.