Update() public method

public Update ( ) : void
return void
Example #1
0
        private void Update() // TODO: разбить на методы
        {
            _rocketLauncher.Update();

            var deltaTime        = Time.deltaTime;
            var invertHorizontal = _invertHorizontal ? -1 : 1;
            var invertVertical   = _invertVertical ? -1 : 1;
            var verticalInput    = Input.GetAxis("Vertical");
            var horizontalInput  = Input.GetAxis("Horizontal");
            var rotateAngles     = new Vector3(
                invertVertical * _longitudinalRollSpeed * verticalInput * deltaTime,
                0f,
                invertHorizontal * _lateralRollSpeed * horizontalInput * deltaTime
                );
            var cachedTransform = transform;

            cachedTransform.Rotate(rotateAngles);
            Vector3 newPosition = cachedTransform.position + cachedTransform.forward * _speed * deltaTime;

            newPosition = Vector3.Max(_fromBounds.Value, newPosition);
            newPosition = Vector3.Min(_toBounds.Value, newPosition);
            cachedTransform.position = newPosition;

            TryAttack();
            ManipulateAcceleration();

            AfterInputAdjusted?.Invoke(verticalInput, horizontalInput);
        }
Example #2
0
 private void Update()
 {
     _rocketLauncher.Update();
     TryFindAndAttack();
 }