0
화면을 두드 리거나 화면을 스 와이프하는 것을 결정하려고합니다. 왼쪽, 오른쪽, 위, 아래에서 스 와이프를 결정하고 싶습니다. 지금 왼쪽 또는 오른쪽으로 스 와이프하면 내 플레이어도 바뀝니다. 어떤 일이 일어날 지 모른다. 그것은 하나 또는 다른 것이어야하며, 왼쪽이나 오른쪽으로 돌리거나 움직여야합니다. 제 질문은 어떻게 5 가지를 모두 결정할 수 있습니까? 화면을 두드리는 것만으로 왼쪽, 오른쪽, 위, 아래로 스 와이프합니다. 는 여기에 내가 검색의 조금이 코드를 발견 내 코드스 와이프 또는 탭 확인
using UnityEngine;
using System.Collections;
public class PlayerMotor : MonoBehaviour {
private CharacterController controller;
private Vector3 moveVector;
private float speed = 2.0f;
private float verticalVelocity = 0.0f;
private float gravity = 12.0f;
public Touch touch;
private void Start() {
controller = GetComponent<CharacterController>();
}
private void Update()
{
moveVector = Vector3.zero;
if (controller.isGrounded)
{
verticalVelocity = -0.5f;
}
else
{
verticalVelocity -= gravity * Time.deltaTime;
}
if (Input.GetMouseButton (0))
{
if (touch.position.x == touch.deltaPosition.x && touch.position.x == touch.deltaPosition.x)
{ //3px accuracy, stationery :P
moveVector.x = transform.forward.x * speed;
transform.Rotate (new Vector3 (0, -90, 0));
}
else if (touch.position.x != touch.deltaPosition.x && touch.position.x != touch.deltaPosition.x)
{
if (Input.mousePosition.x > Screen.width/2)
moveVector.x = speed;
else
moveVector.x = -speed;
}
}
moveVector.y = verticalVelocity;
moveVector.z = transform.forward.z * speed;
controller.Move (moveVector * Time.deltaTime);
}
}
하는 경우는 (currentSwipe.y> 0 currentSwipe.x> -0.5f currentSwipe.x <0.5F) Be : if (currentSwipe.y> 0 && currentSwipe.x> -0.5f && currentSwipe.x <0.5f)? 그렇지 않으면 ')' – Lynnstrum
이 클래스는 PointerClick에서 사용해야하고 주위를 스 와이프하고 다음을 클릭해야합니까? – GuardFromUA