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

Question Collider without RigidBody, supposed to work this way?

Discussion in 'General Discussion' started by Reloque, Jul 16, 2022.

  1. Reloque

    Reloque

    Joined:
    Apr 28, 2015
    Posts:
    207
    I've got a plane, with a collider, but no RigidBody.
    I've got a cube, on that plane, with a collider and a RigidBody. That cube also has a velocity of (2,0,0)

    Without putting a physic material on that cube, is it the expected behaviour that the collision with the plane collider removes all velocity? Even tough that plane has no rigidbody?
     
  2. Kreshi

    Kreshi

    Joined:
    Jan 12, 2015
    Posts:
    433
    I guess you have set your rigidbodys velocity just once (for example in Start) instead of setting it in every frame (for example in FixedUpdate). If you do it like that, the reason the cube stops moving is because you have "Use Gravity" activated for the cube which will create friction over time. You need a separate physics material if you want 0 friction :).
     
  3. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,321
    Colliders without a rigidbody are world colliders.

    Rigidbodies will interact with them. Whether this will remove all veolcity depends on how they collided.
     
    angrypenguin likes this.
  4. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,509
    Yes. A collider wouldn't be of much use if things didn't collide with them. Their specific purpose is to be collidable by Rigidbodies, CharacterControllers, and physics queries such as raycasts.

    A physics material just changes some default interaction parameters. Interactions still happen without one being set, just using the default parameters.
     
  5. DragonCoder

    DragonCoder

    Joined:
    Jul 3, 2015
    Posts:
    1,459
    Just to go sure (due to the wording), you placed the cube as a separate, free game object in the object hierarchy, not as a child object of the plane, right?
     
  6. Reloque

    Reloque

    Joined:
    Apr 28, 2015
    Posts:
    207
    That is correct. Seperate body. Not a child object.

    I was just wondering on how it is supposed to work. An object in motion, stays in motion, right. So in a 'simple but perfect' simulation. A cube, at (2,0,0) without gravity affecting it should keep moving, unless something does something to it.

    The collision with a plane, without any physics in it, halting it, was unexpected.
     
  7. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    9,744
    It likely halted because it hit at such an angle that one of the cube's faces was perfectly parallel with the plane or the cube has a constant velocity of 2,0,0 so it just ends up constantly pushing into the plane. It's a little hard to tell when we can't see the scene or the code.
     
    angrypenguin likes this.
  8. DragonCoder

    DragonCoder

    Joined:
    Jul 3, 2015
    Posts:
    1,459
    I see, well, as others mentioned, plain objects just with a colider count as static obstacles. They cannot move themselves. They are like a massive boulder or the ground. And thus stop your object due to friction and a bounciness of 0 (those are the default values https://answers.unity.com/questions/656590/none-physics-material-properties.html#:~:text=So for anyone still wondering,Dynamic Friction: 0.6).
    The zero bounciness might be surprising if you play with cubes but if you wanted to create an fps or RPG character for example, then that's be more typical since they ususally are not meant to bounce.

    Btw. if you want a collider to merely act as a trigger and not interfere with the movement, you can mark it as "isTrigger".
     
  9. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,509
    What do you mean "without any physics in it"? You said it has a collider. That is a physics object.

    Colliders determine the volume and surface of an object. They are what makes it "solid". Defining what areas are solid is a major component of a physics engine's role.

    Rigidbodies control the momentum and motion of an object arising from physical forces, which is another major component of a physics engine's role.

    The third major part is a solver, which determines when a Collider with a Rigidbody is contacting ("penetrating") any other collider, and then calculates how they should be de-penetrated and what effect that has on the Rigidbody's momentum.

    As best I can tell from your vague description those components are all doing exactly what's expected. It's worth pointing out that while you've detailed the Rigidbody's velocity, you haven't said where the plane is relative to the Rigidbody, which could make a huge difference. When a moving thing hits a solid thing straight on then yes, by default, it should stop. If you're trying to make one slide along the other then that will take some tuning, and I wouldn't be surprised if default friction brings it to a halt.
     
  10. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,321
    If an object has a collider, it has physics.

    Colliders without a rigidbody are world colliders, meaning each one of them represents a perfectly immovable object.

    And when a rigidbody hits an immovable object, it bounces off or stops moving. Depending on impact and material properties.

    Rigidbody --> ,movable object.
    No rigidbody, but with collider --> immovable object, part of the world.
     
  11. Marble

    Marble

    Joined:
    Aug 29, 2005
    Posts:
    1,266
    A collider without a Physics Material has some default, non-zero friction. If you create a Physics Material with 0 friction and apply it to both the colliders, that might be closer to what you were expecting?