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

Changing collider from polygon to circle (then back to polygon) in game?

Discussion in '2D' started by mhedges, Feb 26, 2020.

  1. mhedges

    mhedges

    Joined:
    Feb 23, 2017
    Posts:
    13
    Hello -

    I am porting an Asteroids-like game from one engine to Unity.

    When the player's ship gets destroyed, it is respawned at the center of the play field, but only if there are no rocks or UFOs within a certain range.

    In the other engine I simply had an invisible object with collision detection handling the logic. If a rock was colliding with the object, the ship wouldn't respawn.

    I wonder if in Unity I could just "swap colliders". The ship has a polygon collider during normal play. I wonder if I can center the ship upon collision, change the collider to a circle to detect any nearby rocks, and at the proper moment change back to a polygon collider.


    Thanks, regards.
     
  2. Tom-Atom

    Tom-Atom

    Joined:
    Jun 29, 2014
    Posts:
    153
    MelvMay likes this.
  3. mhedges

    mhedges

    Joined:
    Feb 23, 2017
    Posts:
    13
    Thanks for your reply!