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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

CharacterController Players Walk Through Each Other

Discussion in 'Scripting' started by 420BlazeIt, Apr 16, 2016.

  1. 420BlazeIt

    420BlazeIt

    Joined:
    Aug 14, 2014
    Posts:
    102
    I am making a multiplayer FPS and my characters are using CharacterController.
    My problem is that they walk through each other.
    When both players are moving they walk through each other but if one of them stops moving then they can't walk through each other.

    Imagine 2 players. Player A and Player B.
    Scenario 1: Player A and Player B are both moving toward each other so they walk straight through.
    Scenario 1: Player A is standing still so Player B can't moving through Player A.

    I just need to make it so Players can't walk through each other at all.
     
  2. Laperen

    Laperen

    Joined:
    Feb 1, 2016
    Posts:
    1,065
    Hope someone comes along to prove me wrong, but from personal experience, what you are intending to do may well be impossible with the CharacterController

    To make sure it is not the fault of the character controller, check if the collision layers both your characters are on can interact with each other.
     
  3. 420BlazeIt

    420BlazeIt

    Joined:
    Aug 14, 2014
    Posts:
    102
    Yes they can interact with each other because the following code works.

    Code (CSharp):
    1. void OnControllerColliderHit(ControllerColliderHit hit)
    2. {
    3.     if (hit.gameObject.tag == "RedTrigger" || hit.gameObject.tag == "BlueTrigger")
    4.         print("123");
    5. }
     
  4. Laperen

    Laperen

    Joined:
    Feb 1, 2016
    Posts:
    1,065
    Then let's hope someone comes to prove me wrong, other wise you either need to switch over to using RigidBodies, or use some sort of hack to get around this limitation in the CharacterController.
     
  5. 420BlazeIt

    420BlazeIt

    Joined:
    Aug 14, 2014
    Posts:
    102