private void Update() { if (finger != null) { Camera camera = overrideCamera ? overrideCamera : Camera.main; Vector3 lastPosition = finger.GetLastWorldPosition(Mathf.Abs(camera.transform.position.z), camera); Vector3 currentPosition = finger.GetWorldPosition(Mathf.Abs(camera.transform.position.z), camera); float swipeSpeed = (currentPosition - lastPosition).magnitude / Time.deltaTime; if (swipeSpeed >= minSlashSpeed) { OnSlash(lastPosition, currentPosition); } } }
void Swiped(LeanFinger finger) { if (DateTime.Now < signDoneChangingAfter) { Debug.Log("still changing"); return; } Debug.Log("--------------------------"); Debug.Log("SWIPED"); var swipeStart = finger.GetStartWorldPosition(0); var swipeEnd = finger.GetLastWorldPosition(0); var heading = swipeEnd - swipeStart; var distance = heading.magnitude; var direction = heading / distance; RaycastHit2D[] hits = Physics2D.RaycastAll(swipeStart, direction); foreach (var hit in hits) { if (hit.collider == signBoxCollider) { signDoneChangingAfter = DateTime.Now.AddSeconds(1); isSignBack = !isSignBack; Debug.Log(isSignBack); if (isSignBack) { signSpriteRender.sprite = signBack; } else { signSpriteRender.sprite = signFront; } Debug.Log("hit sign"); } else { Debug.Log("No collisiion!"); } } }
public void Check_Swipe(LeanFinger finger) { int mytouch_index = -1; //-1のままはおかしい for (int i = 0; i < LeanTouch.Fingers.Count; i++) //同時押しでも指を見分けるため { if (finger.Index == LeanTouch.Fingers[i].Index) { mytouch_index = i; break; } } float distance = Get_distance(finger.GetWorldPosition(0), finger.GetLastWorldPosition(0)); //Debug.Log("distance " + distance); if (distance >= Swipe_distance) { Set_My_touch(time_Manager.Get_time(), finger, mytouch_index); judge.Main_judge(1, my_Touch[mytouch_index]); } }