Skip to content

Commit

Permalink
Added a dead layer to stop collision with dead entity + Fix player sh…
Browse files Browse the repository at this point in the history
…ooting himself + stop enemies damaging player when their dead
  • Loading branch information
djomphe committed Mar 24, 2018
1 parent 4a3046f commit ac581d2
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 27 deletions.
4 changes: 3 additions & 1 deletion Assets/Prefabs/Monsters/caster.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -3976,7 +3976,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
cam: {fileID: 0}
owner: {fileID: 0}
owner: {fileID: 114797700088756246}
weapon: {fileID: 0}
--- !u!114 &114427805709667976
MonoBehaviour:
Expand Down Expand Up @@ -4450,6 +4450,7 @@ MonoBehaviour:
physical: 1
_hitReaction: {fileID: 114231165420594996}
_bloodPrefab: {fileID: 0}
collidersList: []
dead: 0
animator: {fileID: 0}
--- !u!114 &114805298428655826
Expand Down Expand Up @@ -4510,6 +4511,7 @@ MonoBehaviour:
DEATH_ANIM_DELAY: 6
attackDelay: 1
shootingDelay: 0.8
shootingOffsetMultiplier: 0.07
nearPositionMultiplier: 3
farPositionMultiplier: 10
--- !u!114 &114908394068785786
Expand Down
7 changes: 4 additions & 3 deletions Assets/Prefabs/Monsters/leshen.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -2826,7 +2826,7 @@ MonoBehaviour:
_guid: cf79633b-a5be-4829-9797-43de519b544d
--- !u!114 &114018787029677460
MonoBehaviour:
m_ObjectHideFlags: 11
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1501085806012814}
Expand Down Expand Up @@ -3108,7 +3108,7 @@ MonoBehaviour:
_guid: 8ee29471-c189-4464-8872-015f44e4f10c
--- !u!114 &114314007360087782
MonoBehaviour:
m_ObjectHideFlags: 11
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1501085806012814}
Expand Down Expand Up @@ -3380,7 +3380,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
cam: {fileID: 0}
owner: {fileID: 0}
owner: {fileID: 114668012487698022}
weapon: {fileID: 0}
--- !u!114 &114585753729335208
MonoBehaviour:
Expand Down Expand Up @@ -3500,6 +3500,7 @@ MonoBehaviour:
physical: 1
_hitReaction: {fileID: 114007497159397736}
_bloodPrefab: {fileID: 0}
collidersList: []
dead: 0
animator: {fileID: 0}
--- !u!114 &114705389032269200
Expand Down
7 changes: 4 additions & 3 deletions Assets/Prefabs/Monsters/mutant.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -1564,7 +1564,7 @@ Animator:
m_AllowConstantClipSamplingOptimization: 1
--- !u!114 &114027895956250906
MonoBehaviour:
m_ObjectHideFlags: 11
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1472075138058696}
Expand Down Expand Up @@ -2408,7 +2408,7 @@ MonoBehaviour:
_guid: 752f2f27-a9fb-4502-a566-b184781875d0
--- !u!114 &114512362482547492
MonoBehaviour:
m_ObjectHideFlags: 11
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1472075138058696}
Expand Down Expand Up @@ -3195,7 +3195,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
cam: {fileID: 0}
owner: {fileID: 0}
owner: {fileID: 114958696687542796}
weapon: {fileID: 0}
--- !u!114 &114698866331627416
MonoBehaviour:
Expand Down Expand Up @@ -3359,6 +3359,7 @@ MonoBehaviour:
physical: 1
_hitReaction: {fileID: 114594373648699612}
_bloodPrefab: {fileID: 0}
collidersList: []
dead: 0
animator: {fileID: 0}
--- !u!114 &114960644629237764
Expand Down
7 changes: 4 additions & 3 deletions Assets/Prefabs/Monsters/ours-garou.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -2400,7 +2400,7 @@ MonoBehaviour:
_guid: dda5460f-f9a6-4c40-8927-872e7567c551
--- !u!114 &114058009765666486
MonoBehaviour:
m_ObjectHideFlags: 11
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1875396115993318}
Expand Down Expand Up @@ -2868,7 +2868,7 @@ MonoBehaviour:
_guid: 13c44770-3e9d-4c34-8e15-ca2ab4a0891d
--- !u!114 &114490321288022450
MonoBehaviour:
m_ObjectHideFlags: 11
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1875396115993318}
Expand Down Expand Up @@ -2990,6 +2990,7 @@ MonoBehaviour:
physical: 1
_hitReaction: {fileID: 114561487528165766}
_bloodPrefab: {fileID: 0}
collidersList: []
dead: 0
animator: {fileID: 0}
--- !u!114 &114532916993377186
Expand Down Expand Up @@ -3952,7 +3953,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
cam: {fileID: 0}
owner: {fileID: 0}
owner: {fileID: 114528635372685660}
weapon: {fileID: 0}
--- !u!114 &114876211735411704
MonoBehaviour:
Expand Down
7 changes: 6 additions & 1 deletion Assets/Scripts/BaseAI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,11 @@ void DetectPlayer()
{
if (hit.gameObject.tag == PLAYER_TAG)
{
if (hit.gameObject.GetComponent<Living>().dead)
Living living = hit.gameObject.GetComponent<Living>();
if (living == null)
continue;

if (living.dead)
continue;

if (hit.gameObject == target)
Expand Down Expand Up @@ -298,6 +302,7 @@ void StayAwayFromPlayer()

void MoveNearPlayer()
{

//FindClosestEdge
//SamplePathPosition
if (target != null)
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/Livings/Living.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void UpdateLife(float life) {

if (curLife == 0f) {
dead = true;

gameObject.layer = 18;
if (OnDeath != null)
OnDeath.Invoke();
}
Expand Down
5 changes: 4 additions & 1 deletion Assets/Scripts/Livings/ShootingController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,10 @@ void RpcFire(NetworkInstanceId bulletId, NetworkInstanceId weaponId)
{
GameObject bulletObj = ClientScene.FindLocalObject(bulletId);
GameObject weaponObj = ClientScene.FindLocalObject(weaponId);


for (int i = 0; i < owner.collidersList.Count; i++)
Physics.IgnoreCollision(bulletObj.GetComponent<Collider>(), owner.collidersList[i], true);

Bullet bullet = bulletObj.GetComponent<Bullet>();
bullet.OwnerTag = gameObject.tag;
bullet.spec = weapon.Bullet;
Expand Down
6 changes: 6 additions & 0 deletions Assets/Scripts/MeleeWeaponHitPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ public class MeleeWeaponHitPoint : MonoBehaviour {

private void OnTriggerEnter(Collider col)
{
if (owner == null)
return;

if (owner.dead)
return;

if (col.isTrigger)
return;

Expand Down
30 changes: 18 additions & 12 deletions Assets/Scripts/Spells/Bullet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,36 +123,42 @@ public void UpdatePosition()
/// </summary>
private void OnTriggerEnter(Collider col)
{
if (lastLiving != null) {
Vector3 dir = transform.position - col.transform.position;
dir.Normalize();
lastLiving.HitReaction(col, dir * rigidbody.mass, col.ClosestPoint(transform.position));

Destroy(gameObject);
}

if (col.gameObject.tag == OwnerTag)
return;

if (col.isTrigger)
if (continuousDamage)
return;

if (col.gameObject.layer == 18)
return;

if (continuousDamage)
Living living = col.gameObject.GetComponentInParent<Living>();
if (living != null && living.dead)
return;

if (lastLiving != null)
{
Vector3 dir = transform.position - col.transform.position;
dir.Normalize();
lastLiving.HitReaction(col, dir * rigidbody.mass, col.ClosestPoint(transform.position));

Destroy(gameObject);
}

if (explodeOnHit)
Explode();
else
{
Living comp = col.gameObject.GetComponent<Living>();
Living comp = col.gameObject.GetComponentInParent<Living>();
if (comp != null) {
comp.TakeDamage(Damage, DamageType);

lastLiving = comp;
}

if (destroyOnHit)
Destroy(gameObject, 0.02f);
if (comp == null || !comp.dead)
Destroy(gameObject, 0.02f);
}
}

Expand Down
2 changes: 1 addition & 1 deletion ProjectSettings/DynamicsManager.asset
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ PhysicsManager:
m_ClothInterCollisionDistance: 0
m_ClothInterCollisionStiffness: 0
m_ContactsGeneration: 1
m_LayerCollisionMatrix: ff1ffcffff1ffcffff1ffcffffffffffff1ffcffff1ffcffffffffffffffffffffdefcffff19feffff19feffff1ffcffff1ffcffc880fcffc881fdffc861fcffc840fcffc806fcffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
m_LayerCollisionMatrix: ff1ff8ffff1ff8ffff1ff8ffffffffffff1ff8ffff1ff8ffffffffffffffffffffdefcffff19faffff19faffff1ff8ffff1ff8ffc880f8ffc881f9ffc861f8ffc840f8ffc806f8ffc801f8ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
m_AutoSimulation: 1
m_AutoSyncTransforms: 1
m_ClothInterCollisionSettingsToggle: 0
Expand Down
2 changes: 1 addition & 1 deletion ProjectSettings/TagManager.asset
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ TagManager:
- VRSpell
- ItemVR
- BodyColliders
-
- Dead
-
-
-
Expand Down

0 comments on commit ac581d2

Please sign in to comment.