コード例 #1
0
    public void OnCollisionEnter(Collision col)
    {
        GameObject collidedGameObject = col.gameObject;

        if (collidedGameObject.tag != "Untagged")
        {
            Debug.Log(collidedGameObject.tag);
        }
        if ("Balloon" == collidedGameObject.tag)
        {
            BalloonController balloonController = collidedGameObject.GetComponent <BalloonController>();
            if (null != balloonController)
            {
                float balloonCharge = balloonController.GetCharge();

                // Move charge from balloon to VdG. The moving charge is the amount
                // to make the balloon charge positive.
                // For simplicity the balloon charge will always be of the same magnitude and only
                // changes its sign (+/-).
                this.ChargeStrength -= (2f * Mathf.Abs(balloonCharge));

                // invert charge of balloon (set it to positive)
                balloonController.SetCharge(Mathf.Abs(balloonCharge));
            }
        }
    }
コード例 #2
0
    public void OnCollisionEnter(Collision col)
    {
        GameObject collidedGameObject = col.gameObject;

        Debug.Log(collidedGameObject.tag);
        if ("Balloon" == collidedGameObject.tag)
        {
            BalloonController balloonController = collidedGameObject.GetComponent <BalloonController>();
            if (null != balloonController)
            {
                float balloonCharge = balloonController.GetCharge();

                // Move charge from Grounder to balloon. The moving charge is the amount
                // to make the balloon charge negative.
                // For simplicity the balloon charge will always be of the same magnitude and only
                // changes its sign (+/-).
                Debug.Log("Before" + this.ChargeStrength);
                this.ChargeStrength += (2f * Mathf.Abs(balloonCharge));
                Debug.Log("After" + this.ChargeStrength);
                this.UpdateGlow();

                // invert charge of balloon (set it to negative)
                balloonController.SetCharge(-1f * Mathf.Abs(balloonCharge));
            }
        }
    }