Add stick spawners
This commit is contained in:
parent
3cc381f6e1
commit
adf6e245c2
60
Assets/Prefabs/Environment/Stick Spawner Spawner.prefab
Normal file
60
Assets/Prefabs/Environment/Stick Spawner Spawner.prefab
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!1 &9114811099361258697
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 9114811099361258696}
|
||||||
|
- component: {fileID: 9114811099361258703}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: Stick Spawner Spawner
|
||||||
|
m_TagString: Generator
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &9114811099361258696
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 9114811099361258697}
|
||||||
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
|
m_LocalPosition: {x: -1.5553083, y: -10.38626, z: 28.331787}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_RootOrder: 0
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!114 &9114811099361258703
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 9114811099361258697}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 8df7bcbf7138e33448643b71967f880c, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
Terrain: {fileID: 0}
|
||||||
|
Seed: 0
|
||||||
|
Regen: 0
|
||||||
|
ShowInEditor: 0
|
||||||
|
SpawnableTrees:
|
||||||
|
- {fileID: 8593229712972662916, guid: 083f2630e3468274594f4435b3e82c1d, type: 3}
|
||||||
|
Chances: 01000000
|
||||||
|
HeightMin: 7.5
|
||||||
|
HeightMax: 9
|
||||||
|
TreeChance: 0.9
|
||||||
|
CampSize: 4
|
||||||
|
CampMiddle: {x: 0, y: 0, z: 0}
|
||||||
|
RandomNudge: 6
|
||||||
|
Denseness: 10
|
||||||
|
MinimumAdjacency: 4
|
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: dce6ed08bb6da0a438a43d72fdf944da
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
146
Assets/Prefabs/Environment/Stick Spawner.prefab
Normal file
146
Assets/Prefabs/Environment/Stick Spawner.prefab
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!1 &4217889580631076249
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 4276445544797834170}
|
||||||
|
- component: {fileID: 4840816957815971449}
|
||||||
|
- component: {fileID: 7281790343140834684}
|
||||||
|
- component: {fileID: 4314463863449130335}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: Sphere
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &4276445544797834170
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 4217889580631076249}
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0.5, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 5375417352542439262}
|
||||||
|
m_RootOrder: 0
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!33 &4840816957815971449
|
||||||
|
MeshFilter:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 4217889580631076249}
|
||||||
|
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
|
||||||
|
--- !u!23 &7281790343140834684
|
||||||
|
MeshRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 4217889580631076249}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_CastShadows: 1
|
||||||
|
m_ReceiveShadows: 1
|
||||||
|
m_DynamicOccludee: 1
|
||||||
|
m_MotionVectors: 1
|
||||||
|
m_LightProbeUsage: 1
|
||||||
|
m_ReflectionProbeUsage: 1
|
||||||
|
m_RayTracingMode: 2
|
||||||
|
m_RenderingLayerMask: 1
|
||||||
|
m_RendererPriority: 0
|
||||||
|
m_Materials:
|
||||||
|
- {fileID: 2100000, guid: 5860e01ec4ea228429cd6af49cbfe209, type: 2}
|
||||||
|
m_StaticBatchInfo:
|
||||||
|
firstSubMesh: 0
|
||||||
|
subMeshCount: 0
|
||||||
|
m_StaticBatchRoot: {fileID: 0}
|
||||||
|
m_ProbeAnchor: {fileID: 0}
|
||||||
|
m_LightProbeVolumeOverride: {fileID: 0}
|
||||||
|
m_ScaleInLightmap: 1
|
||||||
|
m_ReceiveGI: 1
|
||||||
|
m_PreserveUVs: 0
|
||||||
|
m_IgnoreNormalsForChartDetection: 0
|
||||||
|
m_ImportantGI: 0
|
||||||
|
m_StitchLightmapSeams: 1
|
||||||
|
m_SelectedEditorRenderState: 3
|
||||||
|
m_MinimumChartSize: 4
|
||||||
|
m_AutoUVMaxDistance: 0.5
|
||||||
|
m_AutoUVMaxAngle: 89
|
||||||
|
m_LightmapParameters: {fileID: 0}
|
||||||
|
m_SortingLayerID: 0
|
||||||
|
m_SortingLayer: 0
|
||||||
|
m_SortingOrder: 0
|
||||||
|
--- !u!114 &4314463863449130335
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 4217889580631076249}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 673e6bd2603d0304881fd68d9ff50b29, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
HideOnPlay: 1
|
||||||
|
Renderer: {fileID: 7281790343140834684}
|
||||||
|
--- !u!1 &8593229712972662916
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 5375417352542439262}
|
||||||
|
- component: {fileID: 5825517555167498412}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: Stick Spawner
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &5375417352542439262
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 8593229712972662916}
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: -11.869743, y: -14.758989, z: 24.027588}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_Children:
|
||||||
|
- {fileID: 4276445544797834170}
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_RootOrder: 0
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!114 &5825517555167498412
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 8593229712972662916}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 83369664773682f4b8451edd700d0483, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
StickPrefab: {fileID: 2086008818391599545, guid: 58a0b048688a1f944ae319d8ee9c5c34,
|
||||||
|
type: 3}
|
||||||
|
StickSpawnChance: 0.6
|
||||||
|
StickSpawnMinDistance: 15
|
||||||
|
StickSpawnAngle: 70
|
||||||
|
StickSpawnTimer: 1
|
7
Assets/Prefabs/Environment/Stick Spawner.prefab.meta
Normal file
7
Assets/Prefabs/Environment/Stick Spawner.prefab.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 083f2630e3468274594f4435b3e82c1d
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
14102
Assets/Scenes/Yee.unity
14102
Assets/Scenes/Yee.unity
File diff suppressed because it is too large
Load Diff
@ -13,6 +13,7 @@ public class Lorax : MonoBehaviour {
|
|||||||
public bool ShowInEditor = true;
|
public bool ShowInEditor = true;
|
||||||
public List<GameObject> SpawnableTrees;
|
public List<GameObject> SpawnableTrees;
|
||||||
public List<int> Chances;
|
public List<int> Chances;
|
||||||
|
public bool DisableOnStart = true;
|
||||||
|
|
||||||
[Header("Generation Details")]
|
[Header("Generation Details")]
|
||||||
public float HeightMin = 7.5f;
|
public float HeightMin = 7.5f;
|
||||||
@ -86,7 +87,7 @@ public class Lorax : MonoBehaviour {
|
|||||||
Chunks[CurrentChunk] = new GameObject("Chunk " + CurrentChunk);
|
Chunks[CurrentChunk] = new GameObject("Chunk " + CurrentChunk);
|
||||||
Chunks[CurrentChunk].transform.parent = transform;
|
Chunks[CurrentChunk].transform.parent = transform;
|
||||||
if (Application.isPlaying) {
|
if (Application.isPlaying) {
|
||||||
Chunks[CurrentChunk].SetActive(false);
|
Chunks[CurrentChunk].SetActive(!DisableOnStart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Random.value > TreeChance) {
|
if (Random.value > TreeChance) {
|
||||||
|
49
Assets/Scripts/StickSpawner.cs
Normal file
49
Assets/Scripts/StickSpawner.cs
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class StickSpawner : MonoBehaviour {
|
||||||
|
|
||||||
|
public GameObject StickPrefab;
|
||||||
|
|
||||||
|
public float StickSpawnChance = 0.5f;
|
||||||
|
public float StickSpawnMinDistance = 5f;
|
||||||
|
public float StickSpawnAngle = 70f;
|
||||||
|
public float StickSpawnTimer = 2f;
|
||||||
|
|
||||||
|
private GameObject Player;
|
||||||
|
|
||||||
|
private float LastSpawn;
|
||||||
|
private bool CanSpawnNew = true;
|
||||||
|
private Item SpawnedStick = null;
|
||||||
|
|
||||||
|
void Awake() {
|
||||||
|
Player = GameObject.FindGameObjectWithTag("Player");
|
||||||
|
LastSpawn = Time.time + StickSpawnTimer * Random.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Update() {
|
||||||
|
if (!CanSpawnNew) {
|
||||||
|
if (SpawnedStick.Grabbed) {
|
||||||
|
CanSpawnNew = true;
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Time.time > LastSpawn + StickSpawnTimer) {
|
||||||
|
LastSpawn = Time.time;
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var dir = transform.position - Player.transform.position;
|
||||||
|
if ((Vector3.Angle(Player.transform.forward, dir) > StickSpawnAngle) || dir.magnitude > StickSpawnMinDistance && Random.value <= StickSpawnChance) {
|
||||||
|
Debug.Log("Spawned");
|
||||||
|
CanSpawnNew = false;
|
||||||
|
var Stick = GameObject.Instantiate(StickPrefab, transform.position + Vector3.up * 2, Random.rotation);
|
||||||
|
SpawnedStick = Stick.GetComponent<Item>();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
11
Assets/Scripts/StickSpawner.cs.meta
Normal file
11
Assets/Scripts/StickSpawner.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 83369664773682f4b8451edd700d0483
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Loading…
Reference in New Issue
Block a user