Exemple #1
0
    protected void SetupPhysics()
    {
        if (body == null)
        {
            body         = GetComponent <FSBodyComponent>().PhysicsBody;
            shape        = GetComponent <FSShapeComponent>().GetShape();
            shape.Radius = minRadius;

            body.DestroyFixture(body.FixtureList[0]);
            body.CreateFixture(shape);
            CollisionPresets.SetFixtureCollision(body.FixtureList[0], collisionSetting);

            expansionRate = (maxRadius - minRadius) / expansionTime;
            gameObject.transform.localScale = new Vector3(2 * minRadius, 2 * minRadius, 1.0f);
        }
        body.IsSensor     = true;
        body.GravityScale = 0.0f;         //Explosions aren't affected by gravity
        body.OnCollision += OnCollisionEvent;
    }
Exemple #2
0
    // Update is called once per frame
    void FixedUpdate()
    {
        if (shape.Radius < maxRadius)
        {
            shape.Radius += expansionRate * Time.fixedDeltaTime;
        }
        else
        {
            shape.Radius = maxRadius;
        }
        body.DestroyFixture(body.FixtureList[0]);
        body.CreateFixture(shape);
        CollisionPresets.SetFixtureCollision(body.FixtureList[0], collisionSetting);
        gameObject.transform.localScale = new Vector3(2 * shape.Radius, 2 * shape.Radius, 1.0f);
        //print (shape.Radius);
        SetupPhysics();

        lifeSpan -= Time.fixedDeltaTime;
        if (lifeSpan <= 0.0f)
        {
            GameObject.Destroy(gameObject);
        }
    }