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

How to interact between objects move by Raycast and ones with Rigidbodies?

Discussion in '2D' started by UnbreakableOne, Jan 31, 2019.

  1. UnbreakableOne

    UnbreakableOne

    Joined:
    Nov 16, 2013
    Posts:
    168
    Hi,

    My character controller is raycast based but I want it to be able to push objects around, how these two can work together?

    My best guess is that I have to make pushable objects like player and raycast based but I want the physical simulation of for example how a bunch of boxes drop on top of each other.

    Thanks
     
  2. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
    @UnbreakableOne

    Assuming by this being posted here in 2D area, this is a 2D game.

    You can attach a RigidBody2D on your raycast based character controller.

    Then make it kinematic and set the full kinematic collisions on, and you controller will be colliding and interacting one way with other RigidBodies.
     
  3. UnbreakableOne

    UnbreakableOne

    Joined:
    Nov 16, 2013
    Posts:
    168
    Correct assumption, sorry I should've been more clear perhaps.

    My character does have RigidBody2D (to be able to detect triggers) on it and it is kinematic (that's why I can control it via script) but since each frame I'm controlling the object's position via my script, physic simulations do not happen automatically as they would on non-Kinematic ones.
     
  4. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
    @UnbreakableOne

    yes, I think I get what you are saying, but do you say that the Use Full Kinematic Contacts doesnt' work?

    I don't say that it can't not work (maybe your setup is such), I would just like to know if you already tried that.
     
  5. UnbreakableOne

    UnbreakableOne

    Joined:
    Nov 16, 2013
    Posts:
    168
    From what I understand it just produces contacts on collision, what I want is for the target dynamic rigidbody2D is be able to act on this, i.e. get pushed etc.