Download

State Design Pattern for a roleplay game

Hey,

my name is Max and i started working with the Unreal Engine 4 a few days ago and i have some Questions.

We are currently working on a roleplay game and i have to implement a class selection now(e.g Mage,Warrior…). After searching a little bit i found out that some people use the state design pattern for that kind of problem.
Would you recommend this? Another problem is the class creation it looks like that i can only create classes by the add code function in the editor. When i add a class in VS 2013 the engine dont recognize it. Do my classes have to inherit from Actor or other classes to work?

PS: My english isnt the best so please dont be too hard to me :stuck_out_tongue:

If you’re adding the class file within Visual Studio itself, make sure that you don’t save it to the directory that appears by default - instead, navigate to your project’s Source/ProjectName directory, where the other source files exist.

Edit
Alternatively, you can use the “Add Code To Project” option in-editor, which will help you set up some boilerplate to get you started. :slight_smile:

Also make sure that you are making the editor aware of your new class by labeling it with the UCLASS() macro. Also if you will to expose other parts of the class like functions or variables you have the UFUNCTION() and UPROPERTY() macros which will allow you to do so. Here is some documentation on those macro’s and what functionality they provide you.

Class - https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/Reference/Classes/index.html#classspecifiers
Function - https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/Reference/Functions/index.html#functionspecifiers
Variables - https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/Reference/Properties/index.html
Structs - https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/Reference/Structs/index.html
Interfaces - https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/Reference/Interfaces/index.html