OnDamage event or some equivalent

Hi, I have my own ability and upgrade system, which I am integrating with Opsive abilities and whatnot.
Currently I have a grenade ability that mostly uses Opsive systems, but sets the damage, radius, and force of the explosion object on the grenade when it detonates.

I have an upgrade to the grenade that will add a shock effect, basically doing extra damage to all targets hit, causing them to stagger, and arcing to nearby targets outside of the radius.

I struggled to find where I could pass a delegate to accomplish this. I suppose I could create an Impact Action, and my upgrade could add that impact action to the explosion when it spawns...?

Any help or direction would be appreciated.
 
This sounds like the perfect place within the impact module of the throwable action.
 
I'm still a little confused...
Should I create a new Impact Action, or pass a delegate (or otherwise listen to) the Call Impact Callbacks?

I tried listening to "OnObjectImpactSourceCallback" but it never fired in my script (I made sure "Call Impact Callback On Originator" was set to true).

If I have a reference to the grenade weapon, in a monobehavior attached to the grenade weapon, what would the syntax be to register to the OnObjectImpactSourceCallback event when the grenade projectile spawns the explosion object?

I looked at the event documentation, but I think I am still missing something.
 
You'd create a new impact action. The other option is to use OnObjectImpact (not OnObjectImportSourceCallback, that's not an event name that we use). The docs have a couple examples of OnObjectImpact.
 
How do I add an Impact Action to a module through script? I see I can add a whole module, but I would rather just add an action to a module that already exists.
 
Last edited:
Take a look at the ItemBuilder class - it gives an example of adding new modules.
 
Okay, looking at the ItemBuilder class, it seems that I can add a module, but not an action. I can work with that.
However, I have been unsuccessful in displaying the modules for the inspector in my own scripts...
I looked at ThrowableAction class for direction, but I think I have missed something.

1675104221874.png
 
Last edited:
Yes, I have been unable to get the Unity Inspector to display the Impact Actions in the ThrowableImpactModule class so I can modify them.
In my upgrade definition script, I want to set the Impact Actions for a ThrowableImpactModule, which will then be added to my grenade at runtime when upgrades are applied.

To demonstrate my GUI issue, I have a script
C#:
public class ModuleTest : MonoBehaviour
{
    [SerializeField] protected ThrowableImpactModule impactModuleToAdd1;
    [SerializeReference] protected ThrowableImpactModule impactModuleToAdd2;
    [SerializeField, ActionModuleGroup("7ba8c971c8e384f4697856e1ed4902f4")] protected ActionModuleGroup<ThrowableImpactModule> impactModuleToAdd3;
    
}

In the inspector, I see
1675191144039.png
Things may look a little different because I have Odin Inspector. However, I don't think that Odin is blocking the ImpactActions GUI from displaying...
 
The actions are not designed to be added to a separate MonoBehaviour - they are bound to the item and require that hierarchy. A good example of adding modules through code is ItemBuilder.AddThrowableActionProperties. It uses the AddModule to add a new module.
 
I gotcha.
just to confirm: the current best way to attach actions to items at runtime is to have hardcoded instantiations?

I have implemented and had some success with this pattern, though being able to specify item action values in a user script inspector would be nice (should that happen to make it on the roadmap).
 
Top