mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2025-02-16 12:58:27 +00:00
change way of specifying which object should be ignored when raycasting - peds can not damage other peds in the same vehicle
This commit is contained in:
parent
a2cc2c33b4
commit
71d18bbe6d
2 changed files with 4 additions and 6 deletions
|
@ -18,8 +18,7 @@ namespace SanAndreasUnity.Behaviours.Peds.States
|
|||
{
|
||||
get => new WeaponAttackParams
|
||||
{
|
||||
RigidBodyToIgnoreWhenRaycasting = this.CurrentVehicle != null ? this.CurrentVehicle.RigidBody : null,
|
||||
RigidBodyLayerToIgnoreWhenRaycasting = Vehicle.Layer,
|
||||
GameObjectToIgnoreWhenRaycasting = this.CurrentVehicle != null ? this.CurrentVehicle.gameObject : null,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -75,8 +75,7 @@ namespace SanAndreasUnity.Behaviours
|
|||
|
||||
public struct WeaponAttackParams
|
||||
{
|
||||
public Rigidbody RigidBodyToIgnoreWhenRaycasting { get; set; }
|
||||
public int RigidBodyLayerToIgnoreWhenRaycasting { get; set; }
|
||||
public GameObject GameObjectToIgnoreWhenRaycasting { get; set; }
|
||||
|
||||
public static WeaponAttackParams Default { get => new WeaponAttackParams(); }
|
||||
}
|
||||
|
@ -654,7 +653,7 @@ namespace SanAndreasUnity.Behaviours
|
|||
m_lastRaycastWeaponAttackParams = parameters;
|
||||
|
||||
|
||||
if (null == parameters.RigidBodyToIgnoreWhenRaycasting)
|
||||
if (null == parameters.GameObjectToIgnoreWhenRaycasting)
|
||||
return Physics.Raycast(source, dir, out hit, this.MaxRange, WeaponsManager.Instance.projectileRaycastMask);
|
||||
|
||||
|
||||
|
@ -671,7 +670,7 @@ namespace SanAndreasUnity.Behaviours
|
|||
|
||||
var validHits = s_raycastHitBuffer
|
||||
.Take(numHits)
|
||||
.Where(h => h.collider != null && (parameters.RigidBodyToIgnoreWhenRaycasting != h.rigidbody || parameters.RigidBodyLayerToIgnoreWhenRaycasting != h.collider.gameObject.layer));
|
||||
.Where(h => h.collider != null && parameters.GameObjectToIgnoreWhenRaycasting != h.transform.gameObject && !parameters.GameObjectToIgnoreWhenRaycasting.transform.IsParentOf(h.transform));
|
||||
|
||||
if (!validHits.Any())
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue