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

Performance issue when creating corpse

Discussion in '2D' started by franciscochong, Sep 1, 2016.

  1. franciscochong

    franciscochong

    Joined:
    Jul 9, 2015
    Posts:
    30
    Hi im creating a game that when you kill an enemy i leave a corpse laying on the floor.

    Basically what i am doing right now is disabling the main gameobject and leaving a copy behind with only a spriterenderer and has nothing else, but i was wondering if it was better to leave the original gameobject but disabling only it's scripts/extra components?

    I have object pooling for both units / copies and when an unit is killed i would just reference its sprite from the spriterenderer and set it to the copy, seems fine at first then i see a fps drop.

    Also i have dspalette plugin for both unit and copies... disabling it helped a little, but i dont want to get rid of the component as it cost me money :C.

    If anybody has any ideas how i could achieve a performance enhancement, it will be greatly appreciated.
     
  2. Hyblademin

    Hyblademin

    Joined:
    Oct 14, 2013
    Posts:
    725
    Just want to make sure the FPS drop is from the corpses. If you destroy/pool all of them, does the frame rate go back up?

    How many corpses are there? I wouldn't think a few dozen or even a hundred would really have much impact if they're just SpriteRenderer's, unless perhaps they're all on screen.
     
  3. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    One of the funniest thread titles I've seen ;-D
     
    theANMATOR2b likes this.
  4. franciscochong

    franciscochong

    Joined:
    Jul 9, 2015
    Posts:
    30
    @imaginaryhuman i thought the same thing after i wrote it XD
    @Hyblademin well i made a test, since i had Dspalette on my main characters for color variation, i had to add it to the "corpse" copy so the unit and corpse colors matched, i removed the plugin completely and my fps went up to 60 on mobile it was runing at 40 ~ 50 and dropping to 20.
    I think i might be able to pull it off just deactivating scripts and components on the unit that "died" and just reactivating it when i pool it, will test