mirror of
				https://github.com/DerTyp7/fps-citybuild-unity.git
				synced 2025-10-31 13:17:07 +01:00 
			
		
		
		
	Merge branch 'NPC' of https://github.com/DerTyp187/fps-citybuild into NPC
This commit is contained in:
		
							
								
								
									
										40
									
								
								Assets/Scripts/NPC/TerrainGenerator.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								Assets/Scripts/NPC/TerrainGenerator.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,40 @@ | ||||
| using System.Collections; | ||||
| using System.Collections.Generic; | ||||
| using UnityEngine; | ||||
|  | ||||
| public class TerrainGenerator : MonoBehaviour | ||||
| {     | ||||
|     public (float y, bool isTerrain) GetTerrainHit(float x, float z) | ||||
|     { | ||||
|         float y = 0; | ||||
|         bool isTerrain = false; | ||||
|         Vector3 position = new Vector3(x, 50, z); | ||||
|          | ||||
|  | ||||
|         RaycastHit hit; | ||||
|  | ||||
|         if(Physics.Raycast(position, Vector3.down, out hit, Mathf.Infinity)) | ||||
|         { | ||||
|             if(hit.transform.tag == "Terrain") | ||||
|             { | ||||
|                 Debug.Log("Terrain Hit"); | ||||
|                 y = hit.point.y; | ||||
|                 Debug.Log(hit.point.y); | ||||
|                 isTerrain = true; | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 y = hit.point.y; | ||||
|             } | ||||
|              | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             Debug.Log("Terrain not Hit"); | ||||
|         } | ||||
|  | ||||
|              | ||||
|  | ||||
|         return (y, isTerrain); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										11
									
								
								Assets/Scripts/NPC/TerrainGenerator.cs.meta
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								Assets/Scripts/NPC/TerrainGenerator.cs.meta
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,11 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: 3f1735c997ccb39408dfa8bf3790319f | ||||
| MonoImporter: | ||||
|   externalObjects: {} | ||||
|   serializedVersion: 2 | ||||
|   defaultReferences: [] | ||||
|   executionOrder: 0 | ||||
|   icon: {instanceID: 0} | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
		Reference in New Issue
	
	Block a user
	 juliuse98
					juliuse98