Results 1 to 10 of 10
  1. #1
    legacy-Roy_Fokker
    Guest

    Angry Accessing PawnOwner

    i am playing around with TexRotator thing for hud.
    and i come up to this problem

    I can't Seem to be able to access PawnOwner in HudRotatingTex. But don't understand why (Still new to this whole scripting thing)
    I can get the texture to display fine, it just won't rotate

    i have 2 classes
    HudRotatingTex.uc
    Code:
    class HudRotatingTex extends HudBase;
    
    #exec OBJ LOAD FILE=TestInterface.utx
    
    var int i;
    
    var TexRotator test;
    
    simulated event PostBeginPlay()
    {
    	//-- Scripted Texture = Setup the RotatingTex Image -----------
    	test = new(None) class'TexRotator';
    	test.TexRotationType = TR_FixedRotation;
    	test.UOffset = 128;
    	test.VOffset = 128;
    	test.TexCoordCount = TCN_2DCoords;
    	test.TexCoordProjected = false;
    	test.Material = Texture'TestInterface.HUD.RotatingTexture';
    }
    simulated event Destroyed()
    {
    	test = none;
    }
    
    simulated function DrawRotatingTex(Canvas c)
    {
    	local color tempColor;
    	local byte tempstyle;
    
    	tempColor = c.DrawColor; //storing the values
    	tempstyle= c.Style;
    
    	c.DrawColor=WhiteColor;
    	c.Style=ERenderStyle.STY_Additive;
    
    	//-------- Draw the RotatingTex ---------------------
    	c.SetPos(0,0);
    	test.Rotation.Yaw = i;
    	c.DrawTile(test, 256, 128, 0.0, 0.0, 256, 256);
    	c.DrawText(i);
    	//--------- Done drawing ----------------------------
    
    	c.DrawColor = tempColor;//restore values
    	c.Style = tempstyle;
    
    	rotateTexture();
    }
    
    simulated function rotateTexture()
    {
    	i = PawnOwner.Rotation.Yaw; //-- This doesn't Work WHY WHY WHY???????
    }
    
    
    defaultproperties
    {	
    	i= 0;
    }
    HudDisplayTex.uc
    Code:
    class HudDisplayTex extends HudBase;
    
    var HudRotatingTex objRotatingTex;
    
    simulated function postbeginplay()
    {
    	objRotatingTex = spawn(class'HudRotatingTex');
    	objRotatingTex.postbeginplay();
    }
    
    simulated function destroyed()
    {
    	objRotatingTex.destroyed();
    }
    
    simulated function DrawHud(canvas c)
    {
    	super.DrawHud(c);
    	objRotatingTex.DrawRotatingTex(c);
    	c.DrawText(PawnOwner.Rotation.Yaw);  //--- This Displays Fine
    }

  2. #2
    Skaarj
    Join Date
    Sep 2002
    Posts
    16

    Default Re: Accessing PawnOwner

    Instead of:

    Code:
    i = PawnOwner.Rotation.Yaw;
    Try:

    Code:
    if(PawnOwner.Controller != None)
    {
            i = (PawnOwner.Controller.GetViewRotation()).Yaw);
    }

  3. #3
    legacy-Roy_Fokker
    Guest

    Default

    Nope doesn't work.

    the texture's rotation value doesn't change and i still get access none error when the rotateTexture function reaches that if statement (more specifically that line )

  4. #4
    MSgt. Shooter Person
    Join Date
    Aug 2002
    Posts
    434

    Default

    Maybe the owner isnt referenced?
    Code:
    objRotatingTex = spawn(class'HudRotatingTex');
    Code:
    class('HudRotatingTex', PlayerOwner) ?
    put some
    Code:
    if (PlayerOwner!=none)
    log("No player owner");
    arround to see if it's ever referenced.

    Are you sure this
    Code:
    test.TexRotationType = TR_FixedRotation;
    doesnt prevent the rotation?

  5. #5
    legacy-Roy_Fokker
    Guest

    Default

    yes, if you make HudRotatingTex as default hud gui you will see that it work

    reason i have it as fixed is because i don't want it to move unless the player moves (which is updated drawrotatingtex)

  6. #6
    Skaarj
    Join Date
    Sep 2002
    Posts
    11

    Default

    Originally posted by Doc_EDo put some
    Code:
    if (PlayerOwner!=none)
    log("No player owner");
    arround to see if it's ever referenced.
    Note: PlayerOwner!=none should be PlayerOwner==none

    If you want to check for unowned pawns. Prob just an oversight in syntax, but I thought I'd mention it.

  7. #7
    legacy-Roy_Fokker
    Guest

    Default

    Well i found a work around solution to the problem i was having

    its a sort of a hack,

    i changed the following lines
    In HudRotatingTex.uc
    Code:
    simulated function DrawRotatingTex(Canvas c, Pawn PawnOwner)
    rotateTexture(PawnOwner);
    Code:
    simulated function rotateTexture(Pawn PawnOwner)
    and in HudDisplayTex.uc
    Code:
    objRotatingTex.DrawRotatingTex(c, PawnOwner);

    As i said i think this is a hack/ work around the problem. If anyone can tell me why HudRotatingTex is not able to access PawnOwner i would be grateful

  8. #8
    MSgt. Shooter Person
    Join Date
    Dec 2001
    Posts
    38

    Default

    HudRotatingTex is derived from HudBase. PawnOwner is defined in HudBDeathMatch, however. So there.

  9. #9
    legacy-Roy_Fokker
    Guest

    Default

    i thought PawnOwner was defined in HUD

  10. #10
    MSgt. Shooter Person
    Join Date
    Jun 2003
    Posts
    117

    Default

    It is.

    The reason your code doesn't work is that the PawnOwner variable in HudRotatingTex is never set to anything, because it's not your active Hud. The active Hud is HudDisplayTex and its PawnOwner is set properly by UT, as you can see. There is only ever one active Hud.

    So the lesson is to only derive one HUD class. It makes sense to put all HUD related code in one file, because you can only have one HUD at any point in time (right?). If you still want to separate the code in different files, I suggest deriving your HudRotatingTex directly off Object, because it doesn't need to know anything about the Hud. Then, pass in the desired rotation using function parameters.


 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Copyright ©2009-2011 Epic Games, Inc. All Rights Reserved.
Digital Point modules: Sphinx-based search vBulletin skin by CompletevB.com.