Advertisement
Guest User

Untitled

a guest
Jun 12th, 2020
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. using System.CodeDom.Compiler;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.AI;
  6.  
  7. public class MapEvolve : MonoBehaviour
  8. {
  9.  
  10. public NavMeshSurface champSurface;
  11. public NavMeshSurface minionSurface;
  12.  
  13. public GameObject tempTerrain;
  14.  
  15.  
  16. void Start()
  17. {
  18. NavMesh.RemoveAllNavMeshData();
  19. champSurface.BuildNavMesh();
  20. minionSurface.BuildNavMesh();
  21. }
  22.  
  23. void Update()
  24. {
  25. if (Input.GetKeyDown(KeyCode.Delete)) {
  26. ChangeTempTerrainStateAndBake();
  27. }
  28.  
  29. }
  30. void ChangeTempTerrainStateAndBake() // simple toggle for temporary terrain, placeholder for more complex stuff in the future, if i ever make this work
  31. {
  32. if (tempTerrain.activeInHierarchy == true)
  33. {
  34. tempTerrain.SetActive(false);
  35. NavMesh.RemoveAllNavMeshData();
  36. champSurface.BuildNavMesh();
  37. minionSurface.BuildNavMesh();
  38. }
  39.  
  40. else if (tempTerrain.activeInHierarchy == false)
  41. {
  42. tempTerrain.SetActive(true);
  43. NavMesh.RemoveAllNavMeshData();
  44. champSurface.BuildNavMesh();
  45. minionSurface.BuildNavMesh();
  46. }
  47. }
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement