void PushSnowBall(Vector3 moveDirection) { if (!snowBall) { return; } moveDirection.Normalize(); Vector2 pushDirection2d = Helper.RemoveY(snowBall.transform.position) - Helper.RemoveY(transform.position); Vector3 pushDirection3d = new Vector3(pushDirection2d.x, 0f, pushDirection2d.y); Vector2 moveDirection2d = Helper.RemoveY(moveDirection); //if the ball is in the push fov if (!(Vector2.Angle(moveDirection2d, pushDirection2d) < pushAngle)) { return; } //TODO make that readable float modifier = 1f - Mathf.Clamp01(Vector2.Dot(pushDirection2d, moveDirection2d) / (pushRadius + snowBall.radius)); snowBall.Push(modifier * ballPush * pushDirection3d.normalized); AimArms(); }
private void OnDragEnd() { if (_snowBallScript != null) { _snowBallScript.ActivateRb(); _snowBallScript.Push(_force); if (_distance > 0.8) { animator.SetTrigger("Throw"); animator.SetFloat("ThrowForce", Mathf.Clamp(_distance, 2, 3)); animator.SetFloat("ThrowX", _direction.x); animator.SetFloat("ThrowY", _direction.y); } } trajectory.Hide(); }