Example #1
0
        public void CalculateCameraOffset(Vector2 direction)
        {
            Vector2 offsetTarget = Vector2.Scale(cameraOffsetMax, direction);
            Vector2 offset       = VectorHelpers.MoveToward(
                cameraOffset, offsetTarget, cameraOffsetAcceleration * Time.deltaTime
                );

            cameraOffset = offset;
        }
Example #2
0
        // smooth the movement
        private void Accelerate(Vector2 direction)
        {
            Vector2 currentVelocity = GetPlayerVelocity();
            Vector2 targetVelocity  = Vector2.Scale(direction, maxSpeed);
            Vector2 velocity        = VectorHelpers.MoveToward(
                currentVelocity, targetVelocity, acceleration * Time.deltaTime
                );

            SetPlayerVelocity(velocity);
        }
        private void Accelerate(Vector2 direction)
        {
            Vector2 currentVelocity = absoluteVelocity;
            Vector2 targetVelocity  = direction * maxSpeed;
            Vector2 velocity        = VectorHelpers.MoveToward(
                currentVelocity, targetVelocity, acceleration * Time.deltaTime
                );

            absoluteVelocity      = velocity;
            objRigidbody.velocity = GetRelativeVelocity(absoluteVelocity);
        }