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"

What is the equivalent tu Unrealscript STATES?

Hi guys,

I come from UDK, and as fas as I've read, Unrealscript STATES are something that we will not find in C++. What is the equivalent to such STATES in c++?

Thanks

Product Version: Not Selected
Tags:
more ▼

asked Mar 22 '14 at 09:54 PM in C++ Programming

avatar image

gastonb
38 3 4 6

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

1 answer: sort voted first

States aren't something natively supported in C++ in the same way that Unrealscript supported them. I'd tend to say the closest equivalent is the state machine design pattern, wherein you encapsulate the state-specific logic into a series of classes inheriting from a common parent, and have your object store a reference to the base class that you can then instantiate specific states into, to utilise virtual functions.

From a quick glance, http://gameprogrammingpatterns.com/state.html seems to have a reasonable explanation of the concept.

more ▼

answered Mar 22 '14 at 10:05 PM

avatar image

twiddle
1.5k 55 36 73

avatar image gastonb Mar 22 '14 at 10:07 PM

Thanks for your help. I was thinking Unrealscript would translate into c++ in a specific way that could be easy to move my STATES code into something similar.

avatar image twiddle Mar 22 '14 at 10:12 PM

Well the mechanism of Unrealscript states is essentially the same insofar as you are overriding functions based on the object's state. All this means is that you actually separate your state specific stuff into an independent object that the actor has a reference to, rather than it being in the same file, which IMHO improves readability and code organisation, and potentially allows for state classes to be shared between objects that aren't children of the same parent class.

avatar image gastonb Mar 22 '14 at 10:20 PM

Thanks twiddle.

(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