-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e7ed9e1
commit 0d0e178
Showing
6 changed files
with
101 additions
and
21 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
data/csharp_template/FP_controller/components/VFXController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using Unigine; | ||
#region Math Variables | ||
#if UNIGINE_DOUBLE | ||
using Vec3 = Unigine.dvec3; | ||
using Mat4 = Unigine.dmat4; | ||
#else | ||
using Vec3 = Unigine.vec3; | ||
using Mat4 = Unigine.mat4; | ||
#endif | ||
#endregion | ||
|
||
[Component(PropertyGuid = "19c5bafbe8a7932cdd4890d4a298a355b4d1dec7")] | ||
public class VFXController : Component | ||
{ | ||
// NodeReference для эффектов вспышки выстрела и попадания | ||
[ParameterFile(Filter = ".node")] | ||
public string hitPrefab = null; | ||
|
||
[ParameterFile(Filter = ".node")] | ||
public string muzzleFlashPrefab = null; | ||
|
||
public void OnShoot(Mat4 transform) | ||
{ | ||
// если не задан NodeReference эффекта вспышки, ничего не делаем | ||
if (string.IsNullOrEmpty(muzzleFlashPrefab)) | ||
return; | ||
|
||
// загружаем NodeReference эффекта выстрела | ||
Node muzzleFlashVFX = World.LoadNode(muzzleFlashPrefab); | ||
// устанавливаем положение вспышки на указанные координаты дула пистолета | ||
muzzleFlashVFX.WorldTransform = transform; | ||
} | ||
|
||
public void OnHit(Vec3 hitPoint, vec3 hitNormal, Unigine.Object hitObject) | ||
{ | ||
// если нода эффекта попадания не указана ничего не делаем | ||
if (string.IsNullOrEmpty(hitPrefab)) | ||
return; | ||
|
||
// загружаем ноду эффекта попадания из файла | ||
Node hitVFX = World.LoadNode(hitPrefab); | ||
// устанавливаем загруженную ноду в указанную точку попадания и разворачиваем ее в направлении вектора нормали | ||
hitVFX.Parent = hitObject; | ||
hitVFX.WorldPosition = hitPoint; | ||
hitVFX.SetWorldDirection(hitNormal, vec3.UP, MathLib.AXIS.Y); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
data/csharp_template/FP_controller/components/VFXController.cs.meta
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<asset version="2.18.0.1"> | ||
<guid>b23baaa53cabf948b0118226ccc00803ae73be91</guid> | ||
<type>component</type> | ||
<hash>faabea7a</hash> | ||
<runtimes> | ||
<runtime id="b23baaa53cabf948b0118226ccc00803ae73be91" name="VFXController.cs" link="0"/> | ||
<runtime id="19c5bafbe8a7932cdd4890d4a298a355b4d1dec7" name="VFXController.prop" link="1" type="4"/> | ||
</runtimes> | ||
</asset> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters