![]() |
|
|
#1 |
|
reading states from other actors
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 | |
|
Registered User
Join Date: Dec. 13th, 2001
Location: the low lands
Posts: 117
|
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 Quote:
|
|
|
|
|
|
|
#3 |
|
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(); 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 |
|
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 |
|
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 by TaoPaiPai; 13th Mar 2004 at 07:23 PM. |
|
|
|
|
|
|
#6 |
|
awesome! that seems to work, thanks very much.
and yeah, i remember typecasting from java and C. it gets horrendus pretty quickly |
|
|
|
|
|
|
#7 |
|
Registered User
Join Date: Dec. 13th, 2001
Location: the low lands
Posts: 117
|
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) |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|