Two Character Controllers can jump one onto another

I have two character controllers, both with the same height 1.2m and the same step offset 0.5m, but colliding one onto another, CharacterController instead of stopping the movement at that direction, jumps over.
Picture showing whats happening:


CharacterController settings:
7381673--900791--upload_2021-8-2_12-57-47.png
If I reduce the step offset to 0.3m they cannot walk over themselves but neither over the terrain surface properly.
Does anyone have an idea on how to solve this or why it’s is happening?
Thanks.

The problem is in the step offset.
The character controler is “static”, it cant be moved by external forces, only by CharacterController.move() or sampleMove().
The best idea will be:
-Remove the character controller and add a rigidbody (and a capsule collider).
-In rigidbody constraints, freeze all rotations.
-Finally, in your movement code instead of characterController.Move(the movement vector you use), use Rigidbody.velocity = the same vector of the characterController.move.

Oh and turn off the gravity in the rigidbody.

This should make a similar movement, with the difference that the rigidbody will not stop instantly, the characters will “Slide” when the case that you said and that the characters will be able to push other characters.
Hope you understand this. :stuck_out_tongue:

1 Like

Some code:

Using System;
Using System.Collections.Generic;

public class Movement : MonoBehaviour
{
    public float speed;
    public float grav;
    public float jumpForce;
    Rigidbody rb;
    Transform tr;
    float X;
    float Z;

    void Start()
    {
        tr = this.Transform;
        rb = GetComponent<Rigidbody>();
    }

    void Update()
    {
        X = Input.GetAxis("Horizontal")* speed;
        Y = Input.GetAxis("Vertical")* speed;
        Vector3 vector;
        If(Physics.Raycst(tr.position, 1.1f))
        {
           If(Input.GetKeyDown(KeyCode.Space))
           {
               vector.y = jumpForce;
           }
        }
        else
        {
            vector = grav;
        }
        vector += X * tr.right;
        vector += Z * tr.forward;

        rb.velocity = vector;

    }

}

Oops
I forgot to put Using UnityEngine

Sorry

Hope you know you can edit your posts.

I know, but I cant

Also a question @MelvMay :

Can I do a tutorial in a thread I created for that;

Why not? There should be an edit button below each of your post

What’s “that”? You are free to do pretty much what you want in a thread as long as it’s yours and is in an appropriate forum.

Sorry for my english.
Im spanish.