- Home /
Question by
dignitygames · Sep 18, 2016 at 02:54 PM ·
directionvector2touchscreenswipe
Swipe not 100% perfect
Hi i have created a basketball game and when the user swipes up the ball is slightly swinging to the left or right even you swipe straight up. Here is the code can someone tell me what is wrong please?
This is part of the script where i think i am going wrong. Thanks in advance.
private void CheckDirection() { m_secondTouchPos = new Vector2(Input.mousePosition.x, Input.mousePosition.y); m_currentSwipe = new Vector2(m_secondTouchPos.x - m_firstTouchPos.x, m_secondTouchPos.y - m_firstTouchPos.y); m_currentSwipe.Normalize();
if (m_currentSwipe.y > 0.0f)
{
float angle = Vector2.Angle(m_currentSwipe, transform.right * -1);
if (30.0f <= angle && angle <= 150.0f)
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612092957im_/https://answers.unity.com/themes/thub/images/avi.jpg)