Added TerrainGenerator (Hit Terrain y))

This commit is contained in:
DerTyp187
2021-10-01 10:41:11 +02:00
parent 15203c52ad
commit 8692827990
4 changed files with 80 additions and 0 deletions

View File

@@ -963,6 +963,10 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1118460100164241581, guid: 613866d46c759a848b2a462973745a74, type: 3}
propertyPath: m_LocalPosition.x
value: 36.7
objectReference: {fileID: 0}
- target: {fileID: 5179206290616997027, guid: 613866d46c759a848b2a462973745a74, type: 3}
propertyPath: m_Name
value: House
@@ -1208,6 +1212,7 @@ GameObject:
- component: {fileID: 1861247504}
- component: {fileID: 1861247506}
- component: {fileID: 1861247507}
- component: {fileID: 1861247508}
m_Layer: 0
m_Name: GameManager
m_TagString: Untagged
@@ -1271,6 +1276,18 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
storageBuildings: []
--- !u!114 &1861247508
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1861247503}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3f1735c997ccb39408dfa8bf3790319f, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1001 &7029954222161724659
PrefabInstance:
m_ObjectHideFlags: 0
@@ -1387,5 +1404,9 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8390537189371922023, guid: 6a86db7765f277243b912c20f451dc47, type: 3}
propertyPath: m_LocalPosition.z
value: -18.4
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 6a86db7765f277243b912c20f451dc47, type: 3}

8
Assets/Scripts/NPC.meta Normal file
View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3cbe760ab4339094882e9b35d42a7d39
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View 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);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3f1735c997ccb39408dfa8bf3790319f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: