Im creating a small game project to have better understanding of unreal. There are 5 levels and each level has an item which player has to get, to unlock an ability. Now some of theses abilites will give boost to players movement and all, others will help player clear the level by destroying the desired obstacle and disabling a trap in the level. since i dont have much expeirence with the engine and coding, im using blueprints and ended up making variables like mad man for these things, which i do not think is the right approach. which process or method would you guys recommend as the correct method and which method would you suggest as easy (it gets thing done at least). would be helpful if you have some resources related to this.
Thanks
not the best way but for a small project and a very simple way you can make each Ability an Actor that handles its own logic and can be spawned when you wish to use it
Can’t understand what is “mad man” variable.
Maybe you are saying:
var1 = true means level1
var2 = true means level2
And so on?
or
var1 = true means can destory obstacle1
var2 = true means can destory obstacle2?
(post deleted by author)
apologies, what i meant by that, is that i used too many variables as i didnt know how to implement these abilities
What is “implement these abilities”?
Now you have already know how to implement gameplay, for example, the gameplay of destroying obstacle.
You can follow this
BP_Ability1 contains gameplay of destroying obstacle1
BP_Ability2 contains gameplay of destroying obstacle2
The if your player is level1, then give him BP_Ability1.
The if your player is level2, then give him BP_Ability2.
5 abilities
Abilities:
- Bonus movement and jump
- Phasing
- Disable traps
- Destroy obstacles
- Additional health
Currently,
- The abilities are stored in the
Player_BP
, with a counter for how many times each can be used per level. - Each ability has its own custom event in
Player_BP
. - When the player picks up a
BP_Armor
, it activates the abilities and sets their usage limits
Questions
Is there a better way to handle these abilities?
your suggestion of BP_Ability1
, BP_Ability2
, etc., so they can communicate with other actors (like traps or obstacles)?
Are there any good tutorials or documentation for setting this up?
In big project, a arch design is, each ability(Gameplay ability, GA) has an ID and a blueprint.
The mapping of ID to blueprint is stored in a table.
The ID, GA blueprint, mapping table are made by game designer. Game programmer write cpp to provide tool for blueprint.
Your player should know which ID to use when input comes.
After you input ID to your ability system, beside looking up in table, you can add additional check(should cast GA?), or additional hook(before cast, after cast).
You can write a sub system to do the check, for example you maintain a tag system, if the GA receiver tag is enemy then … (destory the obstacle).
A reference is GAS by UE. It is more complex than I say above.
But your project is a small project, so current design is ok.
Thanks! I’ll stick with the current system for my project. Are there any resources or tools that can help me learn and understand GAS better, so I can improve in future projects?
Also, I’m struggling with implementing the phase ability, using the set location for it but i do not know how to prevent the player from getting outside the playable area? Could you assist with this
[upon activating phase, the player can move 500 unit in the direction he is facing.]
I think you could clamp the players world coordinates to the edges of the playable area.
For example:
- The player is located at (0,0,0)
- There is a wall at (300,0,0)
Upon using phasing, the player will move to (500,0,0). To avoid going past that wall, you can clamp the X coordinate of the player after a phase to the max value of the playable area, in this case 300.
(Edit: This solution works well for rectangular areas only)
vs
GAS might be an overkill for this. Actor Components could work well, though - one would say they were designed to do this. You spawn an actor component on an actor and the actor can use it. Each Actor Component represents an ability. Inheritance is supported so you can easily have a base class and extend it to specialise.
A combination of a custom collision channel which exterior walls Block and the phaseable geometry Ignore
s (or overlaps) and Set Actor Location
with Sweep
enabled. But a manual capsule trace would also work. There should be no need to manually punch any values - if you every redesign the level, you’d need to redo a lot of numbers.
Technically speaking you could just flip collision settings on the player capsule and achieve the same effect. How to tackle it depends on what other gameplay elements are needed.
this is what one of the levels looks like, now all the walls are static meshes, I dunno how I can use the clamp to calculate the max value for the rooms or playable area, if you can elaborate it would be helpful.
ill have to deep dive, to get this thing working, right now I don’t know if i clearly understand this concept.