1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. 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.

[UT2004] Variable Replication

Discussion in 'Programming' started by eLy, May 23, 2004.

  1. eLy

    eLy New Member

    Joined:
    Mar 18, 2003
    Messages:
    169
    Likes Received:
    0
    Hi,
    I'm having a little problem where i'm setting the default value of a global variable from another class. when i run this on a dedicated server the value logs 0.00 (locally it works fine)

    I've tested various ROLE and RemoteRole's and i can't quite figure out why it's not working.

    Code:
    class DynamicShockProjectile extends ShockProjectile;
    
    var float GlobalAngle;
    
    replication
    {
    	reliable if (ROLE == ROLE_Authority)
                 GlobalAngle;
    }
    
    
    simulated function getAngle()
    {
         ......
         [B]class'DShockComboVortex'.default.GlobalAngleTemp=GlobalAngle;[/B]
    }
    
    Code:
    class DShockComboVortex extends ShockComboVortex;
    
    var float GlobalAngleTemp;
    
    replication
    {
    	reliable if (ROLE == ROLE_Authority)
                 GlobalAngleTemp;
    }
    
    event PostBeginPlay()
    {
        Super.PostBeginPlay();
    
          ScaleInterp.Mid=1.6*default.GlobalAngleTemp;
    
          log("default.GlobalAngleTemp "$default.GlobalAngleTemp);
    }
    
    defaultproperties
    {
         ScaleInterp=(Start=0.400000,Mid=1.60000,End=0.200000,InTime=0.400000,OutTime=0.400000,InStyle=IS_InvExp,OutStyle=IS_InvExp)
    
         RemoteRole=ROLE_SimulatedProxy
         bAlwaysRelevant=true
         ROLE==ROLE_Authority
    }
    
    any suggestions ?
    thanks
    eLy
     
    Last edited: May 23, 2004
  2. Zengi

    Zengi New Member

    Joined:
    May 14, 2004
    Messages:
    36
    Likes Received:
    0
    I believe PostBeginPlay occurs before variable replication. There is another function to use though it has the word Net somewhere in there, hold on I'll look it up for ya.

    Ok goody found it, PostNetBeginPlay ( ).

    Now keep in mind this isn't guaranteed to have received the packet of info before it is called. However, PostBeginPlay has 0 % chance of that happening simply because its called before the info is processed.

    Instead its probably best to just set a small timer and do what you need to do there.
     
    Last edited: May 23, 2004
  3. eLy

    eLy New Member

    Joined:
    Mar 18, 2003
    Messages:
    169
    Likes Received:
    0
    hey Zengi, thanks for the reply.

    I have tried using PostNetBeginPlay() before ... no luck.
    but i'm gonna check out the Timer as you said, I haven't used that function before.
     
  4. DarkWithin

    DarkWithin New Member

    Joined:
    May 8, 2004
    Messages:
    5
    Likes Received:
    0
    for the Server, i think PostBeginPlay() should be okay
    but for the Client, try setting the value in PostNetReceive(), and bNetNotify=true
     
    Last edited: May 23, 2004
  5. Mr Evi1

    Mr Evi1 New Member

    Joined:
    Mar 22, 2002
    Messages:
    336
    Likes Received:
    0
    Default values of variables are not replicated.
     
  6. eLy

    eLy New Member

    Joined:
    Mar 18, 2003
    Messages:
    169
    Likes Received:
    0
    oh, this is so great.

    there's no way to do this ?
    argh, after 4 days of trying to find a new way to do this:
    http://forums.beyondunreal.com/showthread.php?t=135332

    I was so happy that somebody had a solution for me yesterday...
    just to find out that it's impossibile...again ?

    are there any other ways to simply read GlobalAngle (in DynamicShockProjectile) from within DShockComboVortex ? that's all i want..
    (...that work on a dedicated server...)

    well thanks anyway guys.
     
    Last edited: May 23, 2004
  7. dataangel

    dataangel New Member

    Joined:
    Apr 11, 2004
    Messages:
    184
    Likes Received:
    0
    Code:
    class'DShockComboVortex'.default.GlobalAngleTemp
    
    That gets the default for that variable for that class. Instead access the variable from an actual instance of the class.

    Code:
    var DShockComboVortex D;
    
    D = spawn(class'DShockComboVortex');
    
    D.GlobalAngleTemp
    
    Something like that.
     
  8. eLy

    eLy New Member

    Joined:
    Mar 18, 2003
    Messages:
    169
    Likes Received:
    0
    thanks dataangel, i actually have tried that too =)
    But it returned 0.00

    I'm assuming that is because D.GlobalAngleTemp gets accessed after DShockComboVortex has already fully executed.

    Or is there a way to have DShockComboVortex "wait" for me to set D.GlobalAngleTemp before it starts executing?

    that would probably be a good solution.
     

Share This Page