Results 1 to 20 of 20
  1. #1
    Deathless
    Join Date
    May 2012
    Location
    Barcelona
    Posts
    2,167

    Default How to acces a variable or function, from one a class to another one

    I've got a variable in a class wich extends from trigger from basically actor , called taken , that basically when you use that object it turns into true.

    see the class here

    class

    Code:
    class UsableActor extends trigger
    placeable;
    
    var bool taken;
    var() const string Prompt;
    var bool IsInInteractionRange;
    
    event Touch(Actor Other, PrimitiveComponent OtherComp, Vector HitLocation, Vector HitNormal)
    {
    
        WorldInfo.Game.Broadcast(self, "you touch");
    
        super.Touch(Other, OtherComp, HitLocation, HitNormal);
       `log( "Hello, world!" );
        if (Pawn(Other) != none)
        {
            //Ideally, we should also check that the touching pawn is a player-controlled one.
    	PlayerController(Pawn(Other).Controller).myHUD.AddPostRenderedActor(self);
    	IsInInteractionRange = true;
        }
    }
    
    event UnTouch(Actor Other)
    {
    
       WorldInfo.Game.Broadcast(self, "you no touch");
        super.UnTouch(Other);
    
        if (Pawn(Other) != none)
        {
    	PlayerController(Pawn(Other).Controller).myHUD.RemovePostRenderedActor(self);
    	IsInInteractionRange = false;
        }
    }
    
    simulated event PostRenderFor(PlayerController PC, Canvas Canvas, Vector CameraPosition, Vector CameraDir)
    {
        local Font previous_font;
    
        super.PostRenderFor(PC, Canvas, CameraPosition, CameraDir);
    
        WorldInfo.Game.Broadcast(self, "you touch");
        previous_font = Canvas.Font;
        Canvas.Font = class'Engine'.Static.GetMediumFont();
        Canvas.SetPos(100,100);
        Canvas.SetDrawColor(0,255,0,255);
        Canvas.DrawText(Prompt); //Prompt is a string variable defined in our new actor's class.
        Canvas.Font = previous_font;
    
    }
    
    function bool UsedBy(Pawn User)
    {
        local bool used;
        used = super.UsedBy(User);
        if (IsInInteractionRange)
        {
        taken=true;
         WorldInfo.Game.Broadcast(self, "MESSAGE HERE");
            //If it matters, you might want to double check here that the user is a player-controlled pawn.
            PlaySound(SoundCue'A_Weapon_BioRifle.Weapon.A_BioRifle_FireImpactFizzle_Cue'); //Put your own sound cue here. And ideally, don't directly reference assets in code.
            return true;
        }
        return used;
    }
    
    
    
    
    
    
    DefaultProperties
    {
      begin object Name=Sprite
            HiddenGame=true
    	HiddenEditor=true
        end object
    
        begin object class=StaticMeshComponent Name=MyMesh
    	StaticMesh=StaticMesh'NodeBuddies.3D_Icons.NodeBuddy__BASE_SHORT'
        end object
        Prompt="hello";
        CollisionComponent=MyMesh
        Components.Add(MyMesh)
        bBlockActors=true
        bHidden=false
       taken=false
    }

    And that variable i want to use it in the pawn class of my game


    Code:
    class GladiatorPawn extends Pawn;
    
    var() const DynamicLightEnvironmentComponent LightEnvironment;
    var() const int IsoCamAngle;
    var() const float CamOffsetDistance;
    var() const Name SwordHandSocketName;
    var() const archetype MeleeWeapon SwordArchetype;
    var AnimNodePlayCustomAnim SwingAnim;
    var float CamPitch;
    var bool taken;
    
    simulated event PostInitAnimTree(SkeletalMeshComponent SkelComp)
    {
        super.PostInitAnimTree(SkelComp);
    
        if (SkelComp == Mesh)
        {
            SwingAnim = AnimNodePlayCustomAnim(SkelComp.FindAnimNode('SwingCustomAnim'));
        }
    }
    
    
    simulated function bool CalcCamera(float DeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV)
    {
        local Vector HitLocation, HitNormal;
    
        out_CamLoc = Location;
        out_CamLoc.X -= Cos(Rotation.Yaw * UnrRotToRad) * Cos(CamPitch * UnrRotToRad) * CamOffsetDistance;
        out_CamLoc.Y -= Sin(Rotation.Yaw * UnrRotToRad) * Cos(CamPitch * UnrRotToRad) * CamOffsetDistance;
        out_CamLoc.Z -= Sin(CamPitch * UnrRotToRad) * CamOffsetDistance;
    
        out_CamRot.Yaw = Rotation.Yaw;
        out_CamRot.Pitch = CamPitch;
        out_CamRot.Roll = 0;
    
        if (Trace(HitLocation, HitNormal, out_CamLoc, Location, false, vect(12, 12, 12)) != none)
        {
            out_CamLoc = HitLocation;
        }
    
        return true;
    }
    
    
    
    function AddDefaultInventory()
    {
        local GladiatorInventory MWInventoryManager;
    
    
    
    
    
        if (SwordArchetype != None)
        {
            MWInventoryManager = GladiatorInventory(self.InvManager);
    
            if (MWInventoryManager != None)
            {
    
                MWInventoryManager.CreateInventoryArchetype(SwordArchetype, false);}
    
        }
    }
    
    
    DefaultProperties
    {
    
    	InventoryManagerClass=class'GladiatorInventory'
        Components.Remove(Sprite)
    	SwordArchetype=MeleeWeapon'GladiatorContent.Archetypes.MeleeWeaponSword'
        Begin Object Class=DynamicLightEnvironmentComponent Name=MyLightEnvironment
           bSynthesizeSHLight=true
           bIsCharacterLightEnvironment=true
           bUseBooleanEnvironmentShadowing=false
        End Object
        Components.Add(MyLightEnvironment)
        LightEnvironment=MyLightEnvironment
    
        Begin Object Class=SkeletalMeshComponent Name=MySkeletalMeshComponent
           bCacheAnimSequenceNodes=false
           AlwaysLoadOnClient=true
           AlwaysLoadOnServer=true
           CastShadow=true
           BlockRigidBody=true
           bUpdateSkelWhenNotRendered=false
           bIgnoreControllersWhenNotRendered=true
           bUpdateKinematicBonesFromAnimation=true
           bCastDynamicShadow=true
           RBChannel=RBCC_Untitled3
           RBCollideWithChannels=(Untitled3=true)
           LightEnvironment=MyLightEnvironment
           bOverrideAttachmentOwnerVisibility=true
           bAcceptsDynamicDecals=false
           bHasPhysicsAssetInstance=true
           TickGroup=TG_PreAsyncWork
           MinDistFactorForKinematicUpdate=0.2f
           bChartDistanceFactor=true
           RBDominanceGroup=20
           Scale=1.f
           bAllowAmbientOcclusion=false
           bUseOnePassLightingOnTranslucency=true
           bPerBoneMotionBlur=true
        End Object
        Mesh=MySkeletalMeshComponent
        Components.Add(MySkeletalMeshComponent)
    }
    And yes i want to use it in this class but whatever i try it's not wroking

    What's the way?
    or multiple ways?

  2. #2

    Default

    Try this (to call a function anyway):

    Code:
    GladiatorPawn(Pawn).YourFunction();
    YourFunction() would be the name of a function in the GladiatorPawn class

  3. #3
    Deathless
    Join Date
    May 2012
    Location
    Barcelona
    Posts
    2,167

    Default

    it doesen't work help please

  4. #4

    Default

    You need to elaborate more than just saying it doesn't work. "Doesn't work" could mean anything.

    What's the problem? Do you get an error? What is the error?
    I'm making a game!

    http://www.desura.com/games/modulated
    Click the link above to read more!

  5. #5
    Deathless
    Join Date
    May 2012
    Location
    Barcelona
    Posts
    2,167

    Default

    i do this GladiatorPawn(Pawn).AddDefaultInventory();

    and i get this

    'GladiatorPawn' Bad command or expression

  6. #6

    Default

    Trigger does not have a Pawn variable.

    You need to find the player pawn manually, through something like a foreach, or spawn the trigger from somewhere you can access pawn to act as a connection.
    I'm making a game!

    http://www.desura.com/games/modulated
    Click the link above to read more!

  7. #7
    Deathless
    Join Date
    May 2012
    Location
    Barcelona
    Posts
    2,167

    Default

    specify more please , the foreach looks to be the most erasonable way.
    an example please┐ ?
    i can provide information if you want

  8. #8
    Redeemer
    Join Date
    Nov 2009
    Location
    Caracas
    Posts
    1,819
    Gamer IDs

    Gamertag: daimakupikoro PSN ID: lone_vampire

    Default

    if you are getting a touch on the trigger with your pawn you can use this code

    Code:
    vent Touch(Actor Other, PrimitiveComponent OtherComp, Vector HitLocation, Vector HitNormal)
    {
    
        WorldInfo.Game.Broadcast(self, "you touch");
    
        super.Touch(Other, OtherComp, HitLocation, HitNormal);
       `log( "Hello, world!" );
        if (Pawn(Other) != none)
        {
            //Ideally, we should also check that the touching pawn is a player-controlled one.
            //this is the new line
            GladiatorPawn(Other).AddDefaultInventory();
    
    	PlayerController(Pawn(Other).Controller).myHUD.AddPostRenderedActor(self);
    	IsInInteractionRange = true;
        }
    }
    you can't use GladiatorPawn(Pawn) because you are receiving an actor variable called Other, try that and see if it work.
    http://vincenzoravo.vrs.com.ve http://www.slaughtermaze.com

    please don't fill my inbox with questions, ask in the forum, the answers will help you and others !!!

  9. #9
    Deathless
    Join Date
    May 2012
    Location
    Barcelona
    Posts
    2,167

    Default

    Quote Originally Posted by daimaku View Post
    if you are getting a touch on the trigger with your pawn you can use this code

    Code:
    vent Touch(Actor Other, PrimitiveComponent OtherComp, Vector HitLocation, Vector HitNormal)
    {
    
        WorldInfo.Game.Broadcast(self, "you touch");
    
        super.Touch(Other, OtherComp, HitLocation, HitNormal);
       `log( "Hello, world!" );
        if (Pawn(Other) != none)
        {
            //Ideally, we should also check that the touching pawn is a player-controlled one.
            //this is the new line
            GladiatorPawn(Other).AddDefaultInventory();
    
    	PlayerController(Pawn(Other).Controller).myHUD.AddPostRenderedActor(self);
    	IsInInteractionRange = true;
        }
    }
    you can't use GladiatorPawn(Pawn) because you are receiving an actor variable called Other, try that and see if it work.

    It works ! thank you alot

    How did you know , i always do this error , acces stuff from one class to another one , is there any tutorial teaching you this kind of stuff?
    because this will still happend to me

  10. #10
    Redeemer
    Join Date
    Nov 2009
    Location
    Caracas
    Posts
    1,819
    Gamer IDs

    Gamertag: daimakupikoro PSN ID: lone_vampire

    Default

    Quote Originally Posted by Neongho View Post
    It works ! thank you alot

    How did you know , i always do this error
    is easy you just need to see what parameters are received on the function, check

    Code:
    Touch(Actor Other, PrimitiveComponent OtherComp, Vector HitLocation, Vector HitNormal)
    there is no 'Pawn' variable
    http://vincenzoravo.vrs.com.ve http://www.slaughtermaze.com

    please don't fill my inbox with questions, ask in the forum, the answers will help you and others !!!

  11. #11
    Deathless
    Join Date
    May 2012
    Location
    Barcelona
    Posts
    2,167

    Default

    One other question maybe it's not of this topic , well only a little

    1If i wanted that object "TheUsable actor" , to be spawned in the map autoamtically , "any map" how would i do it without the editor

    So it would be place it through urnealscript

    2 If i wanted to destroy that object , make it dissapear , given an input how would i do it? "just the fucntion , or variable to change to make it dissapear"

    3 How do i get the player position ( guess what i wanna do a dropping system : ))

  12. #12
    Redeemer
    Join Date
    Nov 2009
    Location
    Caracas
    Posts
    1,819
    Gamer IDs

    Gamertag: daimakupikoro PSN ID: lone_vampire

    Default

    to spawn an object in runtime you need to use the spawn function, to destroy it you need to use YourObject.Destroy()

    and the last one, depends on why you are handling things, most of the time if you are trying to drop something from the player controller, you can use Pawn.Location.
    http://vincenzoravo.vrs.com.ve http://www.slaughtermaze.com

    please don't fill my inbox with questions, ask in the forum, the answers will help you and others !!!

  13. #13
    Deathless
    Join Date
    May 2012
    Location
    Barcelona
    Posts
    2,167

    Default

    i just need the palyer location one so that's 3

    yes i got to spawn it and destroy it , but i need the palyer loc , and assign it to the spawn location wich i guess both are vectors

    Another question jsut to get general information

    is there a way to get a new key , some functionality ?
    because if m not wrong you can0t drop weapons in UT game

    so i'd like to create my own key , any tutorial out theere?

    Pawn.Location.
    im a use that , it gets ticked all the time right?
    Last edited by Neongho; 06-27-2012 at 09:00 PM.

  14. #14
    Redeemer
    Join Date
    Nov 2009
    Location
    Caracas
    Posts
    1,819
    Gamer IDs

    Gamertag: daimakupikoro PSN ID: lone_vampire

    Default

    if you are talking about to assign a key to do an specific function you can use bindkey to call an exec function from the player controller.

    the pawn.location is ticked always.

    if you want to see some good tutorials please check this site

    udkc.info

    is a good one
    http://vincenzoravo.vrs.com.ve http://www.slaughtermaze.com

    please don't fill my inbox with questions, ask in the forum, the answers will help you and others !!!

  15. #15
    Deathless
    Join Date
    May 2012
    Location
    Barcelona
    Posts
    2,167

    Default

    Ok i have another problem in order to complete my dropping system , i have to call a function from the class " USABLE ACTOR " to the CLass " GladiatorController"

    UsableActor Function
    function spawnPickup()
    {
    WorldInfo.Game.Broadcast(self, "you spawned");
    }


    Player Controller exec Funct

    exec function additembykey()

    {
    GladiatorPawn(Pawn).addanitem();
    UsableActor.spawnPickup();
    }

    the first one works ,
    but UsableActor.spawn , well i jsut get the typical error of bad command or missing expression


    Can you place exec functions and keybind them on an actor class such ?
    Last edited by Neongho; 06-28-2012 at 09:05 AM.

  16. #16
    MSgt. Shooter Person
    Join Date
    Feb 2011
    Location
    Denmark
    Posts
    302

    Default

    If you want to start programming, you need to start using the UDN -> http://udn.epicgames.com/Three/ExecFunctions.html.

  17. #17
    Deathless
    Join Date
    May 2012
    Location
    Barcelona
    Posts
    2,167

    Default

    Im more likely looking on how to acces Usableactor Functions from pawn or controller , and call them .

    Also i created a function in my class UsableActor , but ican't acces gladiator pawn there , how is that?

  18. #18
    MSgt. Shooter Person
    Join Date
    Feb 2011
    Location
    Denmark
    Posts
    302

    Default

    Quote Originally Posted by Neongho View Post
    Im more likely looking on how to acces Usableactor Functions from pawn or controller , and call them .

    Also i created a function in my class UsableActor , but ican't acces gladiator pawn there , how is that?
    Aren't we lucky that we got the UDN & also this page might be good!.

  19. #19

  20. #20
    Deathless
    Join Date
    May 2012
    Location
    Barcelona
    Posts
    2,167

    Default

    If i use references , the varaibles doesen't change
    so it's useless also i can't call functions like the spawn function of the actor

    and the exec functions doesen't work " in the case you sue them for keybinding" in a class wich is not cotnroller or pawn

    Ah ok i did somethign like this Pickup = spawn(class'usableActor',,, Pawn.Location); using my reference usableActor PIckup
    Last edited by Neongho; 06-28-2012 at 01:55 PM.


 

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.