I got an issue with the damage changing for my player.
When i change value here inside impactcolissiondata it works.
What i did is my playerStats script that is attached to player object. When player levels up he gets lets say+ 100 damage
This method is called inside another method when player level UP
Reference is inside awake
This is my Rifle prefab and that is what is inside the shootable script
This is mine projectile prefab
And before you ask yes i tried disabling enabling internal impact
And yes i tried also damage processor like multiplier x100 it didnt work
And yes i tried also edit simple damage inside method like this
Same thing and yes I debug.log in update to see when I level up what is damage amount I check it shows it is 110 but still does 10 damage.
Next picture is inside game when i press Play Under Items
And yes i tried those with overrride and modify and damage is never 15. I tried change it there also but no effect.
That is mine pickup prefab
Let me know if you have more questions. Thanks a lot!
C#:
public class ImpactDamageData : IImpactDamageData
{
[Tooltip("The Layer mask to which deal damage.")]
[SerializeField] protected LayerMask m_LayerMask =
~( 1 << LayerManager.IgnoreRaycast
| 1 << LayerManager.Water
| 1 << LayerManager.SubCharacter
| 1 << LayerManager.Overlay
| 1 << LayerManager.VisualEffect);
[Tooltip("Processes the damage dealt to a Damage Target.")]
[SerializeField] protected DamageProcessor m_DamageProcessor;
[Tooltip("The amount of damage to apply to the hit object.")]
[SerializeField] public float m_DamageAmount = 10f;
[Tooltip("The amount of force to apply to the hit object.")]
[SerializeField] protected float m_ImpactForce = 2;
[Tooltip("The number of frames to add the impact force to.")]
[SerializeField] protected int m_ImpactForceFrames = 15;
[Tooltip("The impact radius.")]
[SerializeField] protected float m_ImpactRadius;
[Tooltip("The name of the state to activate upon impact.")]
[SerializeField] protected string m_ImpactStateName;
[Tooltip("The number of seconds until the impact state is disabled. A value of -1 will require the state to be disabled manually.")]
[SerializeField] protected float m_ImpactStateDisableTimer = 10;
[Tooltip("The Surface Impact defines what effects happen on impact.")]
[SerializeField] protected SurfaceImpact m_SurfaceImpact;
What i did is my playerStats script that is attached to player object. When player levels up he gets lets say+ 100 damage
C#:
public void SetDamageExternally()
{
IImpactDamageData impactDamageData = _impactDamageData;
// Modify the damage amount
impactDamageData.DamageAmount += 100;
}
C#:
public void AddExp(float expToAdd)
{
GlobalValue.SavedCurrentExp += expToAdd;
if (GlobalValue.SavedCurrentExp > expToNextLevel[GlobalValue.PlayerLevel] && GlobalValue.PlayerLevel < maxLevel)
{
SetDamageExternally();
//If player reaches required exp to level up,he gains a level and his HP gets restored fully on "DING"
GlobalValue.SavedCurrentExp -= expToNextLevel[GlobalValue.PlayerLevel];
GlobalValue.PlayerLevel++;
StartCoroutine(LevelUpPopUp());
GetComponent<GiveLevelToPlayer>().GiveLevelPlayer();
//player will get 6% more MAX HP each level
var health = _attributemanager.GetAttribute("Health");
health.MaxValue = Mathf.FloorToInt(health.MaxValue * 1.06f);
health.Value = health.MaxValue;
GlobalValue.MaxHp = health.Value;
}
if (GlobalValue.PlayerLevel >= maxLevel)
{
GlobalValue.SavedCurrentExp = 0;
}
}
C#:
private void Awake()
{
instance = this;
//getting component from the Player
_impactDamageData = new ImpactDamageData();
}
This is mine projectile prefab
And before you ask yes i tried disabling enabling internal impact
And yes i tried also damage processor like multiplier x100 it didnt work
And yes i tried also edit simple damage inside method like this
C#:
var inventory = InventorySystemManager.GetInventoryIdentifier(1).Inventory;
// Get the character Inventory Bridge from the Inventory.
var characterInventoryBridge = inventory.gameObject.GetCachedComponent<CharacterInventoryBridge>();
// Get the active character item in slot 0
var characterItem = characterInventoryBridge.GetActiveCharacterItem(0);
var itemAction = characterItem.GetItemAction(0) as ShootableAction;
var genericShootableImpactModule = itemAction.ImpactModuleGroup.GetModuleByID(0) as GenericShootableImpactModule;
var simpleDamage = genericShootableImpactModule.ImpactActions.ImpactActions[0] as SimpleDamage;
// Set the new damage amount.
simpleDamage.DamageAmount += 100;
C#:
Debug.Log(_impactDamageData.DamageAmount);
And yes i tried those with overrride and modify and damage is never 15. I tried change it there also but no effect.
That is mine pickup prefab
Let me know if you have more questions. Thanks a lot!