x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Best place for gameplay constants

I have a whole bunch of constant values for controlling gameplay (like costs of items etc). Where is the correct location to store these constants.

I initially thought it should be in the GameMode since they relate to the game rules and don't change. However, this makes accessing them quite inconvenient as you have to cast the GetGameMode node to access them.

Another way that would also ensure they were run time constant would be to have a static pure function that just returns the relevant value.

What is the best practise when it comes to this?

Product Version: UE 4.8
Tags:
more ▼

asked Sep 28 '15 at 04:10 PM in Blueprint Scripting

avatar image

thk123
646 44 59 91

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

I like to distribute balancing values into the objects where they are needed. Item costs into the base item blueprint, camera values into the camera blueprint, character values into the character blueprint, and so on.

At the same time, I don't like the hassle of having to edit so many files, so I make all balancing values configurable from outside the game. In UE, there are two ways to do this: Config files and Data Tables.

Configuration files

Config files are extremely useful for global values.

First you flag a variable as "Config" ...

alt text

and then you can add a line in the Config/DefaultEngine.ini that specifies your variable's default value:

  [/Game/ContentBrowserPath/YourBlueprint.YourBlueprint_C]
  YourVariable=VariableValue

where "/Game" means the "Content" folder, YourBlueprint is the name of the Blueprint containing the variable, and ContentBrowserPath stands for the path within the ContentBrowser to reach the Blueprint. YourVariable is the variable name and VariableValue its default value.

To make a change in a config file take effect, all you need to do is restart the editor.

Data Tables

Data tables are useful if you have a lot of objects that share a set of variables, but use different values, such as characters that all have different values for health, damage, armor; or weapons with range, ammunition count etc.

To define your values in a data table, you need to first setup a Blueprint struct containing the variables and an Excel sheet containing the same variable names as columns (but leaving the first column for the row names == object identifiers). You can then export your Excel file to csv and drag the csv file into the editor to create a data table for the struct you defined earlier.

You can then access each Data table row by a name identifier (for example the object name) and access its variables anywhere you need it.

alt text

Here's some further documentation on data tables:

To make a change in the csv file take effect, you need to reimport the data table (which is a simple button click).

This wasn't what you asked for, but I hope you find it helpful. :)

more ▼

answered Sep 28 '15 at 07:39 PM

avatar image

erinacea
1.8k 69 28 114

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question