1. juk3b0x

    juk3b0x Wood Hoarder Plugin Developer

    As i already mentioned, I am writing a plugin that enables Animal-Catching (and gathering Wool from them, for example)

    I am having an Issue with the Destroy() Command for an Entity

    I want to prevent people catching an Animal and afterwards being able to harvest their dead Bodies.
    So I Want to destroy the e.Entity in case of successful catch.

    I tried UnityEngine.GameObject.Destroy(e.Entity)

    and I am getting this Error:


    So, can I get around that?

  2. juk3b0x

    juk3b0x Wood Hoarder Plugin Developer

    Ok solved already.

    First you CAN destroy an entity, by destroying the whole GameObject.
    with the code

    Code (Text):
    but this does not help, because the Sheep (for example) does not disappear then.... Despite the fact, that the sheep is unharvestable then, it will flood the console with
    Code (Text):
    damageEvent.Entity = null;
    So that is not desireable.

    If you want to get rid of an Animal, just teleport it off the island

    Code (Text):
    OnEntityHealthChange(EntityDamageEvent e)

    if (your if statement)
    e.Entity.Position = new UnityEngine.Vector3(-1000,-1000,-1000)
    then after the default Despawn Time the Corpse (or live-sheep) will just disappear.