using System.Collections; using UnityEngine; public class FootPrint : MonoBehaviour { public enum FootSide { Left = 0, Right = 1 } public FootSide footSide; public bool footPrintsEnabled; public GameObject footPrintPrefab; public GameObject dustStep; public bool groundContact; public float groundDistance; public int decayRate; public Vector3 offset; private Quaternion reflected; private Transform mytransform; private float ry; public Transform playerTransform; public Color stepFootWedColor; public Color stepFootDirtyColor; private bool isFootPrint; private void Awake() { mytransform = base.transform; reflected = default(Quaternion); } private void Start() { footPrintsEnabled = true; } private void OnTriggerEnter(Collider grounder) { if (grounder.tag == "Terrain") { groundContact = true; } } private void OnTriggerExit(Collider grounder) { if (grounder.tag == "Terrain") { groundContact = false; if (Physics.Raycast(mytransform.position, -Vector3.up, out var hitInfo, groundDistance) && hitInfo.collider.CompareTag("Terrain") && !isFootPrint) { ry = playerTransform.eulerAngles.y + 180f; StartCoroutine(startFootPrint(hitInfo.point + offset, ry, reflected)); } } } private IEnumerator startFootPrint(Vector3 position, float ry, Quaternion rotation) { GameObject gameObject = Object.Instantiate(footPrintPrefab); if ((bool)gameObject) { if (ScriptsHandler.Instance.m_PlayerMain.m_underWaterlevel > 0f) { gameObject.GetComponent().material.SetColor("_Color", stepFootWedColor); } else { gameObject.GetComponent().material.SetColor("_Color", stepFootDirtyColor); } gameObject.transform.position = position; gameObject.transform.rotation = rotation; gameObject.transform.Rotate(0f, ry, 0f, Space.Self); isFootPrint = true; yield return new WaitForSeconds(0.5f); isFootPrint = false; } } private IEnumerator startFootParticles(Vector3 position, float ry, Quaternion rotation) { GameObject footPrint = Object.Instantiate(dustStep); if ((bool)footPrint) { footPrint.transform.position = position; footPrint.transform.rotation = rotation; footPrint.GetComponent().Play(); yield return new WaitForSeconds(5f); footPrint.GetComponent().Stop(); Object.Destroy(footPrint); } } }