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.

reading states from other actors

Discussion in 'Programming' started by pospi, Mar 13, 2004.

  1. pospi

    pospi New Member

    Joined:
    Jun 30, 2003
    Messages:
    298
    Likes Received:
    0
    Hey all,

    I just need some quick help...

    I have the usual weapon class with its two classes for primary and secondary fire. I'm wondering if it's possible to read a state from the secondary fire class actor into the primary fire class actor, and how to do this?

    Also if anyone knows of a good resource on referencing actors, that would be great cos i don't really know what i'm doing with it. I wish it was as easy as referencing classes!

    cheers
     
  2. Loqa

    Loqa New Member

    Joined:
    Dec 13, 2001
    Messages:
    117
    Likes Received:
    0
    FireMode[m] = Spawn(FireModeClass[m], self);
    In PostBeginPlay of Weapon shows that the FireMode array holds the spawned FireClass
    GetStateName() function tells you the state of any actor

    Every variable that holds a spawned class is an Actor reference. It is easier than referencing classes.
     
  3. pospi

    pospi New Member

    Joined:
    Jun 30, 2003
    Messages:
    298
    Likes Received:
    0
    Hooray!

    however, if this is the case i will only have access to that variable from within the weapon class.. how do i reference from the other fire class?

    I remember seeing somewhere the function to return an actor's owner, or parent.. i'm not sure of the correct terminology.. but anyway can i do something like

    Code:
    this.owner.FireMode[1].GetStateName();
    
    to return the state from the other fireclass?

    I guess i just need to know the correct function or variable to return an actor's owner, but i cant find the damn thing no matter where i look :)

    cheers
     
  4. [SAS]Solid Snake

    [SAS]Solid Snake New Member

    Joined:
    Jun 7, 2002
    Messages:
    2,633
    Likes Received:
    0
    Type casting my also be an issue. Remember that Owner is an Actor/Object (I can't recall) and it won't know what FireMode[x] is. So something like Weapon(Owner).FireMode[x].GetStateName(); is required.

    Typecasting/Referencing is quite a hard concept to explain, and it is really an understanding of OOP which really helps here. I think the Wiki has a good explanation on what it is.
     
  5. TaoPaiPai

    TaoPaiPai Commisaire Van Loc

    Joined:
    Jun 13, 2000
    Messages:
    1,626
    Likes Received:
    0
    the firemode has a variable weapon
    so it would be
    weapon.firemode[x].getStateName();

    This variable is a reference to the weapon which is a real actor in the level.
    Which actor contains in turn other reference to other existing actors.
     
    Last edited: Mar 13, 2004
  6. pospi

    pospi New Member

    Joined:
    Jun 30, 2003
    Messages:
    298
    Likes Received:
    0
    awesome! that seems to work, thanks very much.

    and yeah, i remember typecasting from java and C. it gets horrendus pretty quickly
     
  7. Loqa

    Loqa New Member

    Joined:
    Dec 13, 2001
    Messages:
    117
    Likes Received:
    0
    In Uscript typecasting is pretty easy, just remember to test that it is actualy the class you are casting to, like this:

    if(Weapon(AnActor)!=none)
     

Share This Page