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 way to let several classes share one object

Hello! I was wondering if there were any parent class for a class that will only do one specific job and then relay the results to another class. I've found alot of cool and usable parent classes and was thinking there might be one for this as well.

The Problem: I'm currently having an actor class act as this kind of thing, I have a MovementCalculator-actor that I put in the game world, then classes who will use this MovementCalculator-actor have a pointer to it, during their BeginPlay() it will find the actor in the game world and start pointing to it.

Then to use it, for example I have units, who, when clicked, asks the calculator to calculate their movement, and then I have a Gameboard that reads all the movements calculated and activates the respective squares.

Now I was wondering if there were any other way in Unreal Engine to accomplish this without using actors, also preferably without making the entire class static, also no singletons.

Sorry if the English used is not perfect, I've been coding for a while and I'm a bit tired.

Product Version: UE 4.10
Tags:
more ▼

asked Dec 11 '15 at 09:29 PM in C++ Programming

avatar image

Tim0ntel
32 3 4 8

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

2 answers: sort voted first

With state i mean, does the movement speed object store any variables in it that change during gameplay and influence movement? Looking at your previous answer this is not the case. So my recommendation is to make a function library which implements these functions. If you do need state i suspect you should store the state in either the gamemode or gameinstance depending on when you need it. The function library can easily find those if you pass in the actor for which you need a movement calculation.

more ▼

answered Dec 11 '15 at 10:01 PM

avatar image

cageman
673 30 33 65

avatar image Tim0ntel Dec 11 '15 at 10:06 PM

Okay thanks, I'll try that then! :)

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

Does this MovementCalculator-actor keep any state? If the answer is no would just advise to make a blueprintlibrary of it which all objects can call when they need to.

more ▼

answered Dec 11 '15 at 09:33 PM

avatar image

cageman
673 30 33 65

avatar image Tim0ntel Dec 11 '15 at 09:37 PM

I'm sorry but what do you mean by state?

It has three objects to help calculate movement, but other than that its basically just some simple functions lumped together in a class.

(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