mohammad
mohammad

Reputation: 2212

How to prevent colliders from stopping each other while colliding

I am working on a 3D unity project, which I have a platform in it and a character who runs on that platform, I placed the character on the platform but it started to fall down so I solved the problems by following these steps:

  1. added a capsule collider to the object, it still fall through the platform

  2. added a collider to the platform, then it didn't fall down but now these two objects are soled to each other so the character is just moving her legs in the same place,

Is there any way to make the character move on the platform while still using colliders?

Note 1: I made the collider trigger in the image to make the same exact behaviour with out colliders.

Note 2: I tried to put each one of them on a different layer but I get the same problem.


code:

void Update () 
{
    rbody.velocity = new Vector3(rbody.velocity.x,0f,playerVelocity*Time.deltaTime);

    rbody.transform.rotation = Quaternion.identity;
                     .
                     .
                     .
}

enter image description here

Upvotes: 1

Views: 853

Answers (2)

NivekJump
NivekJump

Reputation: 31

Hi Friend you have 2 options...

  1. Change the mass of your RigidBody
  2. Use PhysicsMaterial and reduce the friction between the objects (Add a Physic Material to your Platform)
  3. Increase the force and movement speed in your script.

Upvotes: 0

Mariam Seleem
Mariam Seleem

Reputation: 56

Making the collider trigger is like adding no collider. Trigger is only used when you want the collider to detect something but not stop it from running into things. So I believe you should add a non-trigger collider to both the character and the platform but make sure that the colliders are not intersecting when you put the character manually at first. If that didn't work, tell me exactly the coordinates of the character and the platform and the sizes of their colliders and I will try to replicate your scene to figure out the problem. Hope this helps!

Upvotes: 1

Related Questions