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

Can't get Continuous to work on my Rigidbody2D

Discussion in '2D' started by UnbreakableOne, Jun 9, 2018.

  1. UnbreakableOne

    UnbreakableOne

    Joined:
    Nov 16, 2013
    Posts:
    168
    Hi,

    To avoid problem of my fast bullets ignoring collision, I'm trying to get Continuous to work on them. I've tried everything I could to get it to work to register collision with other colliders with no luck so far and manual is not very helpful.

    I've tried everything I could before making this thread, like adding Rigidbody2D to both objects (the bullet and the target), changing interpolation method, etc.

    I also have another question, for past games I've written my own script for my bullets to raycast between current and past positions but I'm not sure if my approach is faster (and mobile friendly) or using Rigidbody2D's Continuous. Had anyone checked their performance?

    Thanks!
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,557
    What do you mean by this? No collision whatsoever, ever or intermittent collision tunneling? If no collisions ever then that's nothing to do with the collision mode.

    Those have nothing whatsoever to do with continuous col-det so ignore them.

    Continuous only works on non-triggers. Also ensure you're not respositioning the Rigidbody2D at all either directly or indirectly via changing the Transform in any way.
     
    harsha_kr likes this.
  3. UnbreakableOne

    UnbreakableOne

    Joined:
    Nov 16, 2013
    Posts:
    168
    [By the way I'm using 2017.4 on Windows.]

    No collision at all.

    I'm setting velocity of my bullets with changing Velocity property of Rigidbody2D.

    Any thoughts on this?

    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

    Also more questions comes to mind that can't find answers for in the docs:

    1) If I want my bullets to hit other objects with CCD, should the other object have Rigidbody2D as well (its ambiguous in the docs) ?

    2) And should the other one be marked as Continuous as well?

    Thanks
     
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,557
    I'll assume then that it's not to do with the above I posted.

    So this isn't to do with "Continuous" collision mode specifically then. Check that the collider layers are set to contact each other in the physics settings.

    There's no rule about having a Rigidbody2D, you should simply know what not having a Rigidbody(2D) means which is that it's a static (non-moving) colliders. You can add a Rigidbody2D and set it to be a static body-type too which would be more or less the same thing. What is important is that certain body-types can only contact specific body-types i.e. static do not contact other static which makes sense because they're not supposed to move. The detail in the manual should hopefully not be ambiguous in this regard here.

    No, continuous applies to that body only and selecting the option on one body is all that is required.

    It's impossible to answer questions like this as there are too many variables in such a set-up. The best way is to do a simple prototype and check the profiler to see if your approach scales. Any answer I give will be adjusted by the real world results on a specific device.
     
    Last edited: Jun 11, 2018