Hello UE4 Community! I’m relatively new to the community, and to UE4 in general. I know how to do simple blueprint events and scripts, however, I can’t find any tutorials on how to go more advanced, at least in the path I’m trying to head. I’m planning on making a game similar to Bioshock or System Shock 2, where you have RPG style upgrades and the like, but also FPS and puzzle elements. The problem I’m running into is the lack of RPG guides, tutorials and anything relating to the subject. I’m looking for something to help with a simple upgrade system, e.g. “When blank happens change movement speed” and “When blank happens change damage variable”, things like that. A specific guide isn’t needed, just something to build off of, that I could easily turn into something like “When player has picked up blank amount of XP points unlock ability to press upgrade button widget. When button is pressed, change movement speed.” Obviously not that exactly, but you get the idea. If you could link me something or show me yourself, it would be very much appreciated!
I’m assuming you’re only working with blueprint, so I’m going to post the easiest way to do this with that. The simplest system would be to have a “IUpgrade” interface which has two methods: OnActivate and OnDeactivate. Both of these methods should take in your game-specific pawn blueprint. Each skill will be a blueprint derived from UObject that implements this interface. OnActivate will apply the “effects” and “OnDeactivate” will remove them. Your game-specific pawn should have “AddUpgrade” and “RemoveUpgrade” both of which take in the “IUpgrade” interface.The “AddUpgrade” method will add the upgrade to your game-specific pawn’s array of upgrades, if the pawn doesn’t already have it and call OnActivate." The “RemoveUpgrade” should do the opposite.
I know this is real old, but could you or someone explain this a little further? Where do the available skills get stored / how are they pulled in? Why does the interface take in the pawn blueprint, how is that used? Can you possibly post an example? Thanks!
Seems like the skills are stored in the player character BP, likely initialized with a function that “sets” what skills of all possible skills the player will have available at the start. The interfaces “AddUpgrade” and “RemoveUpgrade” will add and remove abilities from the “unlocked” abilities array or whatever the OP was storing the abilities data in. The interface doesn’t “take in” a pawn BP, the pawn BP (or character BP whichever you use) “implements” the interface. So you create an interface in the content browser and then you will “add” the interface in the class defaults of the player character/pawn BP. Once it is added to the player BP you can then script logic inside the interface like you would a traditional function. If you have more questions about interfaces and how to use them check out this tutorial that goes over how to set them up. It is video #24 in the list.
This is just me being slow… but I’m still not connecting the dots. Might need an example…
“likely initialized with a function that “sets” what skills of all possible skills the player will have available at the start.”
- I understand what you mean, but what controls whether a skill is active or not? The UObject bit confuses me, is that where the skill logic is? If my skill is “get player pawn and set max health X 2”, how does that become active or not?
“Once it is added to the player BP you can then script logic inside the interface like you would a traditional function”
- What do you mean by this? Interfaces cannot contain any logic.
Player A has health and speed “abilities”. Health is 100, speed is 10. When the player collects a “Double HP” token the token will use an overlap event to call an interface. The interface will be the “Health PickUp” interface implemented in the player character. Once the interface is called the “logic” inside the interface within the player character will do something like this:
Get player Health
Multiply player health x2
Set Player health
Player now has 200 health points instead of 100. As for what skill are “active” normally something like health I would expect to be “active” always, but something like a “flying” ability may be temporary. So when the player picks up a “flying token” that can fire off a different interface that instead of doubling health like we did in the prior example it instead sets the character movement state to “flying” from “walking”, waits for 10 seconds and then sets it back to “walking”. Now you have a “temporary” ability. Honestly there are a million ways to do a “skill system”. This is all theory, I have no idea what specific skills you want, what their effect will be, permanent or temporary etc so it is hard to explain with so little info. It is highly variable based on your game and its mechanics.