fixed something

This commit is contained in:
Sveske Juice 2024-04-21 10:11:44 +02:00
parent 710a99d37c
commit 71e74eb373
4 changed files with 72 additions and 23 deletions

View File

@ -22,3 +22,4 @@ MonoBehaviour:
- {fileID: 8300000, guid: ad2e8b18611ebba43823cd2f2381dc0b, type: 3}
- {fileID: 8300000, guid: b388d47fcdeb4434bb6b8f8617c8031f, type: 3}
- {fileID: 8300000, guid: 79ca1f1673c4d574d8424e518f9c3517, type: 3}
- {fileID: 8300000, guid: e850f3f8ab5051943a09bc30110ad96a, type: 3}

File diff suppressed because one or more lines are too long

View File

@ -48,7 +48,7 @@ ParticleSystem:
ringBufferMode: 0
ringBufferLoopRange: {x: 0, y: 1}
emitterVelocityMode: 1
looping: 1
looping: 0
prewarm: 0
playOnAwake: 1
useUnscaledTime: 0
@ -5041,6 +5041,10 @@ MonoBehaviour:
damage: 10
wallRebounces: 4
comingFrom: {fileID: 0}
OnReflect:
m_PersistentCalls:
m_Calls: []
splashPS: {fileID: 2459575551296835979}
--- !u!108 &8572678539923306418
Light:
m_ObjectHideFlags: 0

View File

@ -24,6 +24,8 @@ public class Projectile : MonoBehaviour
private Vector3 prevVel;
[SerializeField] ParticleSystem splashPS;
private void Awake()
{
projCol = GetComponent<Collider>();
@ -40,6 +42,15 @@ public class Projectile : MonoBehaviour
projCol.material = pMat;
}
void Start()
{
if (splashPS != null)
{
splashPS.time = 0f;
splashPS.Play();
}
}
private void LateUpdate()
{
prevVel = body.velocity;
@ -49,7 +60,7 @@ public class Projectile : MonoBehaviour
{
HealthComponent hitHealthComp = collision.gameObject.GetComponent<HealthComponent>();
if (hitHealthComp == null)
hitHealthComp = collision.transform.root.GetComponentInChildren<HealthComponent>();
hitHealthComp = collision.transform.parent.GetComponent<HealthComponent>();
// if (hitHealthComp == comingFrom) return;
if (hitHealthComp)
{
@ -66,6 +77,12 @@ public class Projectile : MonoBehaviour
body.velocity = newVel.normalized * prevVel.magnitude * bounciness;
OnReflect?.Invoke();
AudioManager.PlaySound("BulletBounce", transform.position);
if (splashPS != null)
{
splashPS.time = 0f;
splashPS.Play();
}
}
}
}