Esempio n. 1
0
    void FixedUpdate()
    {
        bool enableEngine = false;

        _lastAcceleration = Vector3.zero;
        if (_rotateLeftIntention)
        {
            transform.Rotate(new Vector3(0, -1 * GameParams.SPACESHIP_ROTATION_SPEED, 0));
        }

        if (_rotateRightIntention)
        {
            transform.Rotate(new Vector3(0, 1 * GameParams.SPACESHIP_ROTATION_SPEED, 0));
        }

        if (_accelerateIntention)
        {
            var vel = (aim.position - center.position).normalized * GameParams.SPACESHIP_ACCELERATION;
            vel = CheckForce(vel);
            rb.AddForce(vel);
            _lastAcceleration = vel;
            enableEngine      = true;
            //rb.velocity.Set(vel.x, vel.y, vel.z);
        }

        if (_shotIntention)
        {
            weapon.Shot();
        }
        ResetIntentions();
        engineFire.SetActive(enableEngine);
    }