Unreal 6 Verse GAS example?

I have been messing around with the Gameplay ability system with C++ and Unreal Engine 5.3. I often get frustrated with C++ and building and linking. I would make changes to the C++ class and then the Blueprint child class would have errors if not hot reloaded and those changes would not last the next time I open the editor . I would have to reparent the blueprint to a more generic base class and then back to my C++ base class to get things to show up.

I hope these issues would be fixed if I could use all the features of GAS with Blueprint and a simpler language than C++ which would be more agreeable in the Engine with changes to code than C++. I hope there is a verse sample with GAS for Unreal 6.

I have to create gameplayeffectcalculation in C++ for GameplayEffects. I hope I could just pass in a lambda expression such as I would do in C#.


This example is just an idea of what I would like.

GPT example.
Q: There is a class called GameplayEffect which takes a lambda function with target and source AttributeSets. The targets attribute set should be modified by calculation using the propetries of the source and target attribute sets. Show me an example of such a lampda expression for the GameplayEffect.

A: Sure, I can provide a conceptual example. However, please note that the actual implementation may vary depending on the specific details of your GameplayEffect, AttributeSet, and the calculation you want to perform.

Let’s assume you have a GameplayEffect class that takes a Func delegate as a parameter. This delegate represents a lambda function that performs a calculation using two AttributeSet objects and modifies the target AttributeSet.

Here’s a simplified example:

public class AttributeSet
{
    public int Health { get; set; }
    public int Damage { get; set; }
    // Other properties...
}

public class GameplayEffect
{
    private readonly Func<AttributeSet, AttributeSet, AttributeSet> _effectFunc;

    public GameplayEffect(Func<AttributeSet, AttributeSet, AttributeSet> effectFunc)
    {
        _effectFunc = effectFunc;
    }

    public void ApplyEffect(AttributeSet source, AttributeSet target)
    {
        AttributeSet result = _effectFunc(source, target);
        // Apply the result to the target...
    }
}

In this example, AttributeSet is a class that represents a set of attributes (like Health and Damage). GameplayEffect is a class that represents a gameplay effect. It takes a Func delegate that represents a function to calculate the effect.

You can create a GameplayEffect instance with a lambda function like this:

GameplayEffect effect = new GameplayEffect((source, target) =>
{
    // Modify the target based on the source and target attributes
    target.Health -= source.Damage;
    return target;
});

In this example, the lambda function decreases the target’s Health by the source’s Damage. The modified target AttributeSet is then returned.

Please adjust this example according to your specific requirements. Let me know if you need further assistance! :blush: