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.

UE1 - UT Dynamic Tally Scripted Texture

Discussion in 'Programming' started by Rajada, Sep 22, 2009.

  1. Rajada

    Rajada Member

    Joined:
    Jan 21, 2008
    Messages:
    213
    Likes Received:
    0
    I'm trying to create a new form of scripted texture that when triggered, increases a variable mathematically by one, then reports the number to a scripted texture. My first guess at this compiled, but displayed no numbers. My guess is the problem lies in the fact that I haven't told it WHEN to render (or re-render) the texture, but I can't seem to call that function successfully.

    Code:
    class ScoreKeeperTexture expands ClientScriptedTexture;
    
    var() Font Font;
    var() color FontColor;
    var() float YPos[3];
    var() float XPos[2];
    var string score;
    var int scorecount;
    
    
    simulated function PostBeginPlay()
    {
    	Super.PreBeginPlay();
    	SetTimer( 1.0, true );
    	scorecount = 0;
    }
    	
    	
    	function Trigger( actor Other, pawn EventInstigator )
    {
    
    scorecount++;
    SetTimer( 1.0, true );
    
    }
    	
    	
    simulated function Timer()
    {
    
    
    score = string(scorecount);
    
    
    	
    }	
    	
    	
    simulated event RenderTexture(ScriptedTexture Tex)
    {
    
    Tex.DrawColoredText( XPos[0], YPos[0], score, Font, FontColor );
    
    }
    
    
     
  2. Wormbo

    Wormbo Administrator Staff Member

    Joined:
    Jun 4, 2001
    Messages:
    5,915
    Likes Received:
    36
    The RenderTexture() function of an actor is automatically called by a ScriptedTexture if its Client property is set to the actor.
     
  3. Rajada

    Rajada Member

    Joined:
    Jan 21, 2008
    Messages:
    213
    Likes Received:
    0
    And it is definitely set correctly in the actor in the level, but it seems in scripted textures such as the scrolling tally it has a more dynamic function including variables like LastDrawTime. RenderTexture may be automatically called, but does it automatically call it again if the data has changed?

    I'm pretty sure it doesn't have anything to do with text's offset to the texture, I've tested that theory.
     
    Last edited: Sep 23, 2009
  4. Rajada

    Rajada Member

    Joined:
    Jan 21, 2008
    Messages:
    213
    Likes Received:
    0
    No ideas? Anyone? :p
     
  5. Wormbo

    Wormbo Administrator Staff Member

    Joined:
    Jun 4, 2001
    Messages:
    5,915
    Likes Received:
    36
    It should be called every frame when the texture is visible.
     
  6. Rajada

    Rajada Member

    Joined:
    Jan 21, 2008
    Messages:
    213
    Likes Received:
    0
    That's good to know, the problem must be elsewhere... but it seems like there shouldn't be any problems with the code itself.

    EDIT: Does the surface have to have any special flags applied? I only have made it unlit so far...
     
    Last edited: Sep 24, 2009
  7. Rajada

    Rajada Member

    Joined:
    Jan 21, 2008
    Messages:
    213
    Likes Received:
    0
    Is my string conversion incorrect? It compiles but that's the only thing I was not 99% sure was okay.

    Code:
    score = string(scorecount);
     

Share This Page