Solved Best way to kill a sphere

Discussion in 'Rust Development' started by miRror, Jun 18, 2017.

  1. miRror

    miRror Shack Builder Plugin Developer

  2. Colon Blow

    Colon Blow Airdrop Stalker Plugin Developer

    did you try typing :

    del assets/prefabs/visualization/sphere.prefab

    in your server console?

    Edit: sorry just reread it, didn't see the code you was working on :(
     
  3. Ryan

    Ryan Shack Builder Plugin Developer

    I'm not 100% familiar with this, but surely your list "entities" would have nothing in it prior to your foreach?
     
  4. miRror

    miRror Shack Builder Plugin Developer

    Code (Text):
            private class SphereTrigger : MonoBehaviour
            {
                private int _sphereID;
             
                public void Init(int sphereID, float radius)
                {
                    _sphereID = sphereID;
                 
                    gameObject.name = "SphereTrigger";
                    gameObject.layer = (int)Layer.Reserved1;

                    var collider = gameObject.AddComponent<SphereCollider>();
                    collider.radius = radius;  
                    collider.isTrigger = true;
                }
             
                void OnTriggerEnter(Collider col)
                {
                    BasePlayer player = col.gameObject.GetComponent<BasePlayer>();
                 
                    if(player == null)
                        return;
                 
                    Interface.CallHook("OnSphereEnter", player, _sphereID);
                }
            }
         
            private void CreateSphere(int sphereID, Vector3 position, float sphereRadius, float triggerRadius)
            {
                SphereEntity sph = GameManager.server.CreateEntity("assets/prefabs/visualization/sphere.prefab", position) as SphereEntity;
                sph.currentRadius = sphereRadius;
                sph.lerpSpeed = 0f;        
                sph.Spawn();  

                var component = sph.gameObject.AddComponent<SphereTrigger>();
                component.Init(sphereID, triggerRadius);  
            }
    If use var component ..., then all works perfectly, but without SphereCollider to delete a sphere is not possible.
     
  5. serezhadelaet

    serezhadelaet Shack Builder Plugin Developer

    Why you need to use worst Vis?
     
  6. miRror

    miRror Shack Builder Plugin Developer

    You know any method?
     
  7. serezhadelaet

    serezhadelaet Shack Builder Plugin Developer