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 Kinematic collision

Discussion in 'Physics' started by witcher101, Sep 18, 2021.

  1. witcher101

    witcher101

    Joined:
    Sep 9, 2015
    Posts:
    516
    I have an object which is moved by using Vector2.MoveTowards()
    I want object not to be affected by collisions from other dynamic object but i need it to collide with other static objects.
    If i make my rigid body kinematic It doesn't collide with static walls.
    If i make it dynamic. It flinches when it collides with other dynamic object which i dont want. I even made its mass to be 1000000000 still it flinches a bit.

    How do i solve this???
     
  2. r31o

    r31o

    Joined:
    Jul 29, 2021
    Posts:
    460
    Use layermasks
     
  3. witcher101

    witcher101

    Joined:
    Sep 9, 2015
    Posts:
    516
    Thats not soln. I do want object to collide with other dynamic objects. I just dont want it to be affected by forces
     
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,512
    Rule#1: Don't modify the Transform on GameObjects that use 2D Physics. If it moves in 2D physics, use the API provided in the Rigidbody2D.

    You should describe what you mean by "collide" because saying "not to be affected by collisions" but also "collide with other static objects" is a contradiction.

    If you mean get a physics callback (or be able to read contacts) but no collision response then that is fine. This is what a Kinematic Rigidbody2D is for. Use its API (MovePosition) to move it. It'll contact other Dynamic Rigidbody2D. If you want it to contact other Kinematic/Static Rigidbody2D then set its "Use Full Kinematic Contacts" to true.
     
  5. witcher101

    witcher101

    Joined:
    Sep 9, 2015
    Posts:
    516
    fly.PNG
    Here i am using kinematic on char fly. Heres problem when i make it kinematic. fly goes through wall and Ironbeams which i dont want. I even checked full kniematic contacts but still it doesnt work
    So what i want it fly should be stopped from static physic objects. And dynamic physics object should collide and bounce of the fly but shoudnt receive any force when it collides with dynamic objects
     
  6. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,512
    You cannot have it "not go through walls" and then "not receive any force", the two are conflicting statements. The force is what stops it going throught the wall. There is no "one way force" in physics but only only certain things.

    You use queries to determine where you can move with Kinematics i.e. kinematic controllers. They don't respond to forces when they collide.