flame VFX done

This commit is contained in:
in0finite 2020-06-21 01:24:19 +02:00
parent ea6e45b593
commit c56dad1950
5 changed files with 23252 additions and 1 deletions

23220
Assets/Prefabs/Flame.prefab Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 5b0110178dbbb784cab63b7529b07cc1
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -101,3 +101,4 @@ MonoBehaviour:
explosionLeftoverPartsMaxDepenetrationVelocity: 15
explosionLeftoverPartsMass: 100
smokePrefab: {fileID: 100000, guid: c5d4e25823f45c946b9dd01264b40a1b, type: 3}
flamePrefab: {fileID: 100000, guid: 5b0110178dbbb784cab63b7529b07cc1, type: 3}

View file

@ -29,6 +29,7 @@ namespace SanAndreasUnity.Behaviours.Vehicles
public float explosionLeftoverPartsMass = 100f;
public GameObject smokePrefab;
public GameObject flamePrefab;

View file

@ -22,6 +22,7 @@ namespace SanAndreasUnity.Behaviours.Vehicles
public float TimeWhenBecameUnderFlame { get; private set; } = float.NegativeInfinity;
GameObject m_smokeGameObject;
GameObject m_flameGameObject;
@ -72,7 +73,7 @@ namespace SanAndreasUnity.Behaviours.Vehicles
if (this.IsUnderFlame)
this.TimeWhenBecameUnderFlame = Time.time;
// update vfx
this.UpdateFlameVfx();
}
if (this.IsUnderFlame && Time.time - this.TimeWhenBecameUnderFlame >= 5)
@ -104,6 +105,27 @@ namespace SanAndreasUnity.Behaviours.Vehicles
}
}
void UpdateFlameVfx()
{
if (this.IsUnderFlame)
{
if (null == m_flameGameObject)
{
Transform parent = this.EngineTransform != null ? this.EngineTransform : this.transform;
m_flameGameObject = Object.Instantiate(
VehicleManager.Instance.flamePrefab, parent.position, parent.rotation, parent);
}
}
else
{
if (null != m_flameGameObject)
{
Object.Destroy(m_flameGameObject);
m_flameGameObject = null;
}
}
}
public void Explode()
{
F.RunExceptionSafe(() => this.ExplodeInternal());