StartController.cs 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. using UnityEngine;
  2. public class StartController : MonoBehaviour
  3. {
  4. public Terrain terrain;
  5. public GameObject player;
  6. // Start is called once before the first execution of Update after the MonoBehaviour is created
  7. void Start()
  8. {
  9. // Расположение модели игрока на поверхности (только для BoxCollider-а)
  10. var terrainCenter = terrain.terrainData.heightmapResolution / 2;
  11. var height = terrain.terrainData.GetHeight(terrainCenter, terrainCenter);
  12. //var collider = player.GetComponent<BoxCollider>();
  13. //var playerCenter = (collider.size.y / 2 - collider.center.y) * player.transform.localScale.y;
  14. //var location = new Vector3(
  15. // terrain.transform.position.x + terrain.terrainData.size.x / 2,
  16. // height + playerCenter,
  17. // terrain.transform.position.z + terrain.terrainData.size.z / 2);
  18. //player.transform.position = location;
  19. }
  20. // Update is called once per frame
  21. void Update()
  22. {
  23. }
  24. }