|
@ -1,4 +1,5 @@ |
|
|
using System.Collections; |
|
|
|
|
|
|
|
|
using System; |
|
|
|
|
|
using System.Collections; |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
using UnityEngine; |
|
|
using UnityEngine; |
|
|
|
|
|
|
|
@ -11,7 +12,6 @@ public class PlayerController : MonoBehaviour |
|
|
// Start is called before the first frame update
|
|
|
// Start is called before the first frame update
|
|
|
void Start() |
|
|
void Start() |
|
|
{ |
|
|
{ |
|
|
StartCoroutine((FlipOnAxis())); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void SetMovement(Vector2 input) |
|
|
public void SetMovement(Vector2 input) |
|
@ -27,12 +27,15 @@ public class PlayerController : MonoBehaviour |
|
|
|
|
|
|
|
|
float rotateTo = RotateObject(HorseX, HorseZ); |
|
|
float rotateTo = RotateObject(HorseX, HorseZ); |
|
|
|
|
|
|
|
|
HorseZ *= Time.deltaTime * walkSpeed; |
|
|
|
|
|
HorseX *= Time.deltaTime * walkSpeed; |
|
|
|
|
|
|
|
|
HorseZ *= walkSpeed; |
|
|
|
|
|
HorseX *= walkSpeed; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
transform.Translate(HorseX, 0, HorseZ); |
|
|
transform.Translate(HorseX, 0, HorseZ); |
|
|
LeanTween.rotateY(model, rotateTo, 0.1f); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Vector3 dir = Quaternion.Euler(-90, rotateTo, 0) * Vector3.forward;
|
|
|
|
|
|
//model.transform.forward = dir;
|
|
|
|
|
|
//LeanTween.rotateY(model, rotateTo, 0.1f);
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -40,7 +43,7 @@ public class PlayerController : MonoBehaviour |
|
|
{ |
|
|
{ |
|
|
float to = model.transform.rotation.eulerAngles.y; |
|
|
float to = model.transform.rotation.eulerAngles.y; |
|
|
//Debug.Log(to);
|
|
|
//Debug.Log(to);
|
|
|
if (Input.GetAxisRaw("Horizontal") != 0 || Input.GetAxis("Vertical") != 0) |
|
|
|
|
|
|
|
|
if (receivedInput.x != 0 || receivedInput.y != 0) |
|
|
{ |
|
|
{ |
|
|
if (zInput > 0 && xInput == 0) |
|
|
if (zInput > 0 && xInput == 0) |
|
|
to = 0; |
|
|
to = 0; |
|
@ -63,18 +66,18 @@ public class PlayerController : MonoBehaviour |
|
|
return to; |
|
|
return to; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public IEnumerator FlipOnAxis() |
|
|
|
|
|
|
|
|
public void MoveObject() |
|
|
{ |
|
|
{ |
|
|
if (Input.GetAxisRaw("Horizontal") != 0 || Input.GetAxis("Vertical") != 0) |
|
|
|
|
|
|
|
|
UpdatePosition(); |
|
|
|
|
|
if (receivedInput.x != 0 || receivedInput.y != 0) |
|
|
{ |
|
|
{ |
|
|
LeanTween.rotateX(model, -90, 0.1f); |
|
|
|
|
|
|
|
|
model.transform.Rotate(-90, 0, 0); |
|
|
} |
|
|
} |
|
|
yield return new WaitForSeconds(0.5f); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
// Update is called once per frame
|
|
|
void Update() |
|
|
void Update() |
|
|
{ |
|
|
{ |
|
|
UpdatePosition(); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |