Cheo
Active member
Hello everyone, here are a few modifications to enable penetration for hitscan shots !
First of all, let's start with making penetrable surfaces by adding the following to the Surface Type script :
Next, we also have to edit the Surface Type Inspector in order to display these parameters and save them :
Let's then get to the Shootable Weapon script, create these parameters :
First of all, let's start with making penetrable surfaces by adding the following to the Surface Type script :
C#:
[SerializeField] protected bool m_Penetrable = true;
[SerializeField] protected float m_PenetrationMod = 0.5f;
public bool Penetrable { get { return m_Penetrable; } }
public float PenetrationMod { get { return m_PenetrationMod; } }
Next, we also have to edit the Surface Type Inspector in order to display these parameters and save them :
Code:
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(PropertyFromName("m_ImpactEffects"), true);
EditorGUILayout.PropertyField(PropertyFromName("m_Penetrable"));
EditorGUILayout.PropertyField(PropertyFromName("m_PenetrationMod"));
if (EditorGUI.EndChangeCheck()) {
Shared.Editor.Utility.EditorUtility.RecordUndoDirtyObject(target, "Change Value");
serializedObject.ApplyModifiedProperties();
}
}
Let's then get to the Shootable Weapon script, create these parameters :
C#:
[SerializeField] protected bool m_Penetrate = true;
[SerializeField] protected float m_PenetrationMod = 0.5f;
[SerializeField] protected int m_MaxPenetrations = 5;
public bool Penetrate { get { return m_Penetrate; } set { m_Penetrate = value; } }
public float PenetrationMod { get { return m_PenetrationMod; } set { m_PenetrationMod = value; } }
public int MaxPenetrations { get { return m_MaxPenetrations; } set { m_MaxPenetrations = value; } }