diff --git a/Assets/Scripts/Input/HerdController.cs b/Assets/Scripts/Input/HerdController.cs index a03bd15..5753057 100644 --- a/Assets/Scripts/Input/HerdController.cs +++ b/Assets/Scripts/Input/HerdController.cs @@ -16,9 +16,16 @@ public class HerdController : MonoBehaviour [SerializeField] private Transform SpawnPoint; - private List Herd; + [SerializeField] + private float WaitTime; + private List Herd; + void Start() + { + SpawnHerd(); + StartCoroutine(MoveRoutine()); + } //Recieved movement input from player private void OnMovement(InputValue value) @@ -51,7 +58,7 @@ public class HerdController : MonoBehaviour { Vector3 position = Vector3.ProjectOnPlane(Random.onUnitSphere, Vector3.up) * radius; - Quaternion rotation = Quaternion.Euler(0, Random.Range(-25, 25), 0); + Quaternion rotation = Quaternion.identity; if (SpawnPoint != null) position += SpawnPoint.position; @@ -81,6 +88,16 @@ public class HerdController : MonoBehaviour } } + public IEnumerator MoveRoutine() + { + foreach (PlayerController pc in Herd) + { + pc.MoveObject(); + } + yield return new WaitForSeconds(WaitTime); + + StartCoroutine(MoveRoutine()); + } private bool SpawnPositionValid(Vector3 position,Quaternion rotation ,Bounds bound) { diff --git a/Assets/Scripts/Input/PlayerController.cs b/Assets/Scripts/Input/PlayerController.cs index b5a2a66..5113a5c 100644 --- a/Assets/Scripts/Input/PlayerController.cs +++ b/Assets/Scripts/Input/PlayerController.cs @@ -1,4 +1,5 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; using UnityEngine; @@ -11,7 +12,6 @@ public class PlayerController : MonoBehaviour // Start is called before the first frame update void Start() { - StartCoroutine((FlipOnAxis())); } public void SetMovement(Vector2 input) @@ -27,12 +27,15 @@ public class PlayerController : MonoBehaviour float rotateTo = RotateObject(HorseX, HorseZ); - HorseZ *= Time.deltaTime * walkSpeed; - HorseX *= Time.deltaTime * walkSpeed; + HorseZ *= walkSpeed; + HorseX *= walkSpeed; 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; //Debug.Log(to); - if (Input.GetAxisRaw("Horizontal") != 0 || Input.GetAxis("Vertical") != 0) + if (receivedInput.x != 0 || receivedInput.y != 0) { if (zInput > 0 && xInput == 0) to = 0; @@ -63,18 +66,18 @@ public class PlayerController : MonoBehaviour 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 void Update() { - UpdatePosition(); + } }