Little Question about States

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

nighthack

New Member
Sep 8, 2001
21
0
0
www.megabrain.f2s.com
Is there any difference between a function declared in a state and the same function outside the state when the function appears only once in the class?

What i want to know is if it is importent where the function is Implemented.

A little xample:

In Projectile.uc you have the state flying and some related function like touch, processtouch, explode and hitwall.

When flying is the only state in the class, normaly only touch has to be in there. No im unsure: does it matter if processtouch is declared outside the state, or is it definivly important to put it in? And what about the other functions? When does it matter that the functions need to be declared inside or outside a state?
 
If i remember correctly, functions in states only get executed if the relevant actor is in that state -- very powerful. Allows you to stipulate that the same function have different behavior depending on context (state).

Also, functions that are not in states are considered global to the class i believe ... So if a given function is called for a class, the current state if any will execute its version of the function if it exists; if not, the version that resides outside of states is executed. You can also force this to happen as well, but i don't remember for sure how, it might be by using 'Global', as in 'Global.ProcessTouch()' ... HTH
 

ca

CHiMERiC Grandmaster
Oct 11, 1999
84
0
0
www.unrealscript.com
All classes actually have a default state, so technically there are no global functions. Technically, but not practically. Basically you can define a function global by not placing it within a state and it will become the default function called whenever a class isn't in a specific state (after a gotostate('') for instance). When you define a function inside a state then that version will be called instead of the global one if the object is currently in that state. Pretty simple really, and it can be really useful for gameplay code as it allows you to change the behaviour of an object dramatically based on any number of variables with very little overhead. Just think of how inheritance works - in this case your are creating a special case version of a function to override the global one.

Hope that makes sense...I'm a bit tired to be explaining these things really... :)