Working on meteor shower
parent
1988e671e5
commit
6590654c59
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a4ca53f5f677a134ab21b8ce6abfff16
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,178 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &1423745118134693202
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 7931252305845676974}
|
||||
- component: {fileID: 6622665570321301229}
|
||||
- component: {fileID: 1476813267534383213}
|
||||
- component: {fileID: 4247345913643518399}
|
||||
- component: {fileID: 395240331964147678}
|
||||
- component: {fileID: 6138991760020901714}
|
||||
- component: {fileID: -4553228673610520739}
|
||||
m_Layer: 0
|
||||
m_Name: ChaosRune
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &7931252305845676974
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1423745118134693202}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -0.86752474, y: -0.19581793, z: 4.865039}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!33 &6622665570321301229
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1423745118134693202}
|
||||
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!23 &1476813267534383213
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1423745118134693202}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
m_StaticShadowCaster: 0
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_RayTracingMode: 2
|
||||
m_RayTraceProcedural: 0
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, 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
|
||||
m_AdditionalVertexStreams: {fileID: 0}
|
||||
--- !u!135 &4247345913643518399
|
||||
SphereCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1423745118134693202}
|
||||
m_Material: {fileID: 0}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_LayerOverridePriority: 0
|
||||
m_IsTrigger: 0
|
||||
m_ProvidesContacts: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_Radius: 0.5
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &395240331964147678
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1423745118134693202}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
GlobalObjectIdHash: 3655965266
|
||||
InScenePlacedSourceGlobalObjectIdHash: 0
|
||||
AlwaysReplicateAsRoot: 0
|
||||
SynchronizeTransform: 1
|
||||
ActiveSceneSynchronization: 0
|
||||
SceneMigrationSynchronization: 1
|
||||
SpawnWithObservers: 1
|
||||
DontDestroyWithOwner: 0
|
||||
AutoObjectParentSync: 1
|
||||
--- !u!114 &6138991760020901714
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1423745118134693202}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: b07ebcf1dcb10584eb72e0a384385ba3, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
chaosRuneRadius: 1
|
||||
chaosRuneMagnitude: 1
|
||||
chaosRuneDuration: 5
|
||||
chaosRuneCooldownTime: 10
|
||||
chaosRuneApplicationRadius: 2
|
||||
lifetime: 10
|
||||
chaosRuneEffect: {fileID: 0}
|
||||
ChaosRuneType: 0
|
||||
--- !u!54 &-4553228673610520739
|
||||
Rigidbody:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1423745118134693202}
|
||||
serializedVersion: 4
|
||||
m_Mass: 1
|
||||
m_Drag: 0
|
||||
m_AngularDrag: 0.05
|
||||
m_CenterOfMass: {x: 0, y: 0, z: 0}
|
||||
m_InertiaTensor: {x: 1, y: 1, z: 1}
|
||||
m_InertiaRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_ImplicitCom: 1
|
||||
m_ImplicitTensor: 1
|
||||
m_UseGravity: 1
|
||||
m_IsKinematic: 0
|
||||
m_Interpolate: 0
|
||||
m_Constraints: 112
|
||||
m_CollisionDetection: 0
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0a08bdb749bc8d94eb0675c1ff256f88
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2073273cc98fce04e890d476f09e53c5
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,74 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &4534193173484108557
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 373034462500573541}
|
||||
- component: {fileID: 6440658106440455518}
|
||||
- component: {fileID: 1556918889048963796}
|
||||
m_Layer: 0
|
||||
m_Name: MeteorStrikeEffect
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &373034462500573541
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4534193173484108557}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -0.86752474, y: -0.19581793, z: 4.865039}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &6440658106440455518
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4534193173484108557}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
GlobalObjectIdHash: 1414638663
|
||||
InScenePlacedSourceGlobalObjectIdHash: 0
|
||||
AlwaysReplicateAsRoot: 0
|
||||
SynchronizeTransform: 1
|
||||
ActiveSceneSynchronization: 0
|
||||
SceneMigrationSynchronization: 1
|
||||
SpawnWithObservers: 1
|
||||
DontDestroyWithOwner: 0
|
||||
AutoObjectParentSync: 1
|
||||
--- !u!114 &1556918889048963796
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4534193173484108557}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: de3fc098854109c4ca330533f2298154, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
meteorPrefab: {fileID: 0}
|
||||
meteorCount: 10
|
||||
strikeDuration: 3
|
||||
strikeRadius: 10
|
||||
spawnHeight: 20
|
||||
startOnAwake: 1
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 485ac43964761ef428fc80e096af0abd
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4f96840b0b586f1488748f96d1aa2921
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,23 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ChaosRunePrefab : ChaosRuneBase
|
||||
{
|
||||
|
||||
[SerializeField] private GameObject chaosRuneEffect;
|
||||
[SerializeField] private ChaosRuneType ChaosRuneType;
|
||||
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b07ebcf1dcb10584eb72e0a384385ba3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0e06f4ab6aafccf4cb96cd1840c1f6a4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,125 @@
|
||||
using System.Collections;
|
||||
using Unity.BossRoom.Gameplay.GameplayObjects.Character;
|
||||
using Unity.Netcode;
|
||||
using UnityEngine;
|
||||
|
||||
[RequireComponent(typeof(NetworkObject))]
|
||||
public class MeteorStrikeEffect : NetworkBehaviour
|
||||
{
|
||||
[Header("Meteor Shower Settings")]
|
||||
[Tooltip("Prefab of a single meteor. Must have Collider + (optionally) Rigidbody + NetworkObject if you want networked meteors.")]
|
||||
public GameObject meteorPrefab;
|
||||
|
||||
[Tooltip("Number of meteors to spawn over the duration.")]
|
||||
public int meteorCount = 10;
|
||||
|
||||
[Tooltip("Total time (in seconds) over which meteors will fall.")]
|
||||
public float strikeDuration = 3f;
|
||||
|
||||
[Tooltip("Horizontal radius (XZ plane) around this object's position where meteors will land.")]
|
||||
public float strikeRadius = 10f;
|
||||
|
||||
[Tooltip("Vertical offset above this object's position from which meteors spawn.")]
|
||||
public float spawnHeight = 20f;
|
||||
|
||||
[Tooltip("If checked, the shower will start automatically on network spawn.")]
|
||||
public bool startOnAwake = true;
|
||||
|
||||
private Coroutine _showerRoutine;
|
||||
|
||||
public override void OnNetworkSpawn()
|
||||
{
|
||||
// Only run on the server
|
||||
if (!IsServer) return;
|
||||
|
||||
if (startOnAwake)
|
||||
{
|
||||
StartShower();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Public method to kick off the meteor shower at this GameObject's position.
|
||||
/// </summary>
|
||||
public void StartShower()
|
||||
{
|
||||
if (!IsServer) return;
|
||||
|
||||
if (_showerRoutine != null)
|
||||
StopCoroutine(_showerRoutine);
|
||||
|
||||
_showerRoutine = StartCoroutine(ShowerCoroutine());
|
||||
}
|
||||
|
||||
private IEnumerator ShowerCoroutine()
|
||||
{
|
||||
float interval = strikeDuration / Mathf.Max(1, meteorCount);
|
||||
Vector3 center = transform.position;
|
||||
|
||||
for (int i = 0; i < meteorCount; i++)
|
||||
{
|
||||
// pick a random landing point in the XZ circle
|
||||
Vector2 offset = Random.insideUnitCircle * strikeRadius;
|
||||
Vector3 spawnPos = new Vector3(
|
||||
center.x + offset.x,
|
||||
center.y + spawnHeight,
|
||||
center.z + offset.y
|
||||
);
|
||||
|
||||
// instantiate the meteor
|
||||
var go = Instantiate(meteorPrefab, spawnPos, Quaternion.identity);
|
||||
|
||||
// if it has a NetworkObject, spawn it on clients
|
||||
if (go.TryGetComponent<NetworkObject>(out var netObj))
|
||||
{
|
||||
netObj.Spawn(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// otherwise ensure it falls via physics
|
||||
var rb = go.GetComponent<Rigidbody>() ?? go.AddComponent<Rigidbody>();
|
||||
rb.useGravity = true;
|
||||
}
|
||||
|
||||
// attach our collision-forwarder
|
||||
var mb = go.AddComponent<MeteorBehavior>();
|
||||
mb.controller = this;
|
||||
|
||||
yield return new WaitForSeconds(interval);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Override this in a subclass or add logic here to handle when a meteor hits something.
|
||||
/// </summary>
|
||||
/// <param name="hitObject">The object struck by the meteor.</param>
|
||||
protected virtual void OnHit(GameObject hitObject)
|
||||
{
|
||||
Debug.Log($"[Server] Meteor hit: {hitObject.name}");
|
||||
// TODO: your custom hit logic here
|
||||
}
|
||||
|
||||
private void OnDrawGizmosSelected()
|
||||
{
|
||||
// visualize the landing radius in the editor
|
||||
Gizmos.matrix = transform.localToWorldMatrix;
|
||||
Gizmos.DrawWireSphere(Vector3.zero, strikeRadius);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Internal helper attached to each spawned meteor to forward collisions.
|
||||
/// </summary>
|
||||
private class MeteorBehavior : MonoBehaviour
|
||||
{
|
||||
[HideInInspector] public MeteorStrikeEffect controller;
|
||||
|
||||
private void OnCollisionEnter(Collision collision)
|
||||
{
|
||||
if (controller != null && controller.IsServer)
|
||||
{
|
||||
controller.OnHit(collision.gameObject);
|
||||
}
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: de3fc098854109c4ca330533f2298154
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in New Issue