Ejemplo n.º 1
0
        private void MouseGrounded2DMovement_SmoothStep(float speedScale = 1f)
        {
            if (playerInput.MouseRight.GetDown())
            {
                targetPosition  = Camera.main.ScreenToWorldPoint(playerInput.Mouse.GetCurrentPosition());
                directionVector = (targetPosition - (Vector2)transform.position).normalized;
                isInMovement    = true;
            }

            // Check if the flag for movement is true
            if (isInMovement)
            {
                // Calcul the current speed
                float speed = Maths.BlendingSmoothStep(0.1f, 0.2f, 0.9f, 1.0f, Time.deltaTime) * maxSpeed;

                // Define the new move vector
                moveVector = directionVector * speed;

                // Check if the current gameObject position and the clicked position are equal
                if (Vector3.Distance(transform.position, targetPosition) <= deltat)
                {
                    // Set the movement indicator flag to false
                    isInMovement = false;
                    moveVector   = new Vector2(0, 0);
                    Debug.Log("I am here");
                }
            }
        }