コード例 #1
0
    public void Thrust()
    {
        print("ThrustCostInterval: " + _thrustCostInterval);
        var radians = (transform.rotation.eulerAngles.y) * Mathf.Deg2Rad;
        var dir     = new Vector3(Mathf.Sin(radians), 0f, Mathf.Cos(radians));

        _rb.AddForce(dir * _thrustSpeed, ForceMode.Acceleration);

        if (_thrustCostInterval < Time.time)
        {
            _energy.Drain(_cost);
            _thrustCostInterval = Time.time + 1.0f;
        }
    }