1. deer_SWAG

    deer_SWAG Shack Builder Plugin Developer

    Hi guys. I'm trying to remove an entity but it doesn't work properly. I don't know how to do it right.
    In OnPlayerChat
    Code (C#):
    ClientInfo _cInfo = ConnectionManager.Instance.GetClientInfoForPlayerName(name);

    EntityPlayer player = GameManager.Instance.World.Players.dict[_cInfo.entityId];

    RaycastHit hit;

    if(Physics.Raycast(player.GetLookRay(), out hit))
    {
        Entity e = hit.collider.gameObject.GetComponent<Entity>();

        if(e != null)
        {
            ConnectionManager.Instance.SendPackage(new NetPackageEntityRemove(e.entityId, EnumRemoveEntityReason.Killed));
        }
    }
    It removes entity but when i'm going far away and then going back the entity is showing again.
     
  2. OpenFunRus

    OpenFunRus Wood Hoarder Plugin Developer

    What Entity you try remove? Try to use EnumRemoveEntityReason.Unloaded

    And you remove Entity on Client, Need remove on Server
     
    deer_SWAG likes this.
  3. deer_SWAG

    deer_SWAG Shack Builder Plugin Developer

    Yeah. You are right.