// Fire raycast to check if player has jumped onto a platform public void CheckPlatformLanded() { RaycastHit hit = new RaycastHit(); if (Physics.Raycast(transform.position, -Vector3.up, out hit, 10)) { // If the player lands on an encampment, stop the player being able to move through isAllowedToMove // Then start the event that tracks input. playerPlatform = hit.transform.gameObject; if (hit.transform.tag == "encampment") { isAllowedToMove = false; // Display the stances background NOTE: Must be improved to take into account the length of the stance attack. stanceBackground.SetActive(true); stances = hit.transform.gameObject.GetComponent <StanceScript>().GrabStancesAsString(); if (ShowStance != null) { ShowStance(stances); } // Here detect where the next platform is going to be, // And then fufcking do something about it johnny. platforms = pm.GrabPlatforms(); // Making a list of the platforms to remove the platform the player is standing on. removePlayerPlatformList = new List <GameObject>(platforms); for (int i = 0; i < platforms.Length; i++) { if (platforms[i].name == playerPlatform.name) { removeIndex = i; } } removePlayerPlatformList.RemoveAt(removeIndex); platforms = removePlayerPlatformList.ToArray(); // Remove the platform the player is on. // Reset search variables. closestPlatform = null; distanceToNextPlatform = 100; foreach (GameObject go in platforms) { if (Vector3.Distance(this.gameObject.transform.position, go.transform.position) < distanceToNextPlatform) { distanceToNextPlatform = (int)Vector3.Distance(gameObject.transform.position, go.transform.position); closestPlatform = go; } } attScript.Attacking(hit.transform.gameObject.GetComponent <StanceScript>()); } } // If the player misses a platform reset everything. if (!(Physics.Raycast(transform.position, -Vector3.up, out hit, 10))) { // If the event has a listener fire the event. if (Reset != null) { Reset(); } transform.position = new Vector3(0, 1, 0); } }