PDA

View Full Version : Two questions, Should be quick :-)



DeapaWaspo
06-02-2009, 06:53 AM
Sorry to bother, but your help is much appreciated...

Questions
1.) I've made a custom Volume which my Players spawn inside of. The problem is that when they spawn the Volume's Touch event registers that something is inside of it, just not a Player with a controller. I have to move out of the Volume then back in for it to realize it has a player inside of it. Its like it thinks the object inside of it is still the spectator camera before the initial spawn. How can I make Touch wait for the Pawn to have a controller assigned to it so the volume registers the player initially. Here is the code.


var(Team) int OwnerTeam;

event Touch( Actor Other, PrimitiveComponent OtherComp, vector HitLocation, vector HitNormal )
{
local MOMPawn MP;

Super.Touch( Other, OtherComp, HitLocation, HitNormal );

MP = MOMPawn(Other);

if ( MP.Controller != None )
{
if ( OwnerTeam == MP.GetTeamNum() )
{
MP.bInBuyZone = True;
WorldInfo.Game.Broadcast(MP, MP@"is in the Volume" );

}
else
if ( OwnerTeam != MP.GetTeamNum() )
{
MP.bInBuyZone = False;
WorldInfo.Game.Broadcast(MP, MP@"went into the wrong Volume" );
}
}
}

event UnTouch( Actor Other )
{
local MOMPawn MP;

Super.UnTouch( Other );

MP = MOMPawn(Other);

if ( Mp.Controller != None )
{
if ( OwnerTeam == MP.GetTeamNum() )
{
MP.bInBuyZone = False;
WorldInfo.Game.Broadcast(MP, MP@"has left the Volume );
}
}
}


Where its getting caught up is the if ( MP.Controller != None ), when the player spawns it for some reason doesnt have a controller right away. Why, and how do I make it?



2.) Every time I or a bot dies then respawns it gets a new Pawn assignment. I have a custom Pawn named MOMPawn and I have a Broadcast that tells me what Pawn is triggering an even. Naturally the first spawn I get assigned MOMPawn_0 but after I die then respawn it changes to MOMPawn_1 then MOMPawn_2, so on and so forth. Is this normal? It seems like creating new instances of the same pawns would be hard on memory. Or am I completely looking at this wrong?

EDIT: As of this moment I am uploading a video example to youtube of my second question. I will repost once the video is up.

DeapaWaspo
06-02-2009, 07:55 AM
Here (http://www.youtube.com/watch?v=izeSc869P_8) is the link to the video. I recorded at a high resolution but youtube fuzzied everything. But if you look in the lower left of the UT3 screen you can see that the left portion of the Broadcast will change from MOMPawn_0 up to MOMPawn_4 just from me suiciding and respawning.

EDIT: Doh! Click HD to watch it in high def and no more fuzzied... :-)

Solid Snake
06-02-2009, 06:04 PM
1) Because scripts are concurrent, as soon as the pawn is spawned the volume probably picked this up via it's native code and then the volume Touch function then runs. Try adding in a time variable to your logging to confirm if this is the case. If that's the case, then perhaps you could retrigger the Touch function within Volume once the pawn has been assigned to a controller.

2) Yes, the game type doesn't reuse pawns from within a pool. Certainly in memory constricted environments such as the XBox360 or Playstation3 this would a 'bad' thing, but certainly from the PC point of view this doesn't have much or any real impact. I remember working on a PS2 game with Unreal Engine 2 and we had to have actor pools for just about everything. You could introduce a pawn pool, but it might take a bit of work to reset the pawn before it can be reused again.

DeapaWaspo
06-02-2009, 06:22 PM
Thanks for the reply :-)

1.) How would I set up a time variable? I'm not quite sure I understand how to do that. And if what you said dose happen to be the case how would I refire the touch event like that? At what point does the player have a controller assigned?

2.) I think I got lost with this. So UT3, just the basic game no modifications, will make a new instance of a pawn everytime it spawns? That just seems horribly inefficient to me. I guess what I'm wondering is, is it my game type that I've made that is causing this or did Epic make it this way for a reason or just overlook it?

Solid Snake
06-02-2009, 08:45 PM
1) You can aquire the time using the variables found within WorldInfo. I believe WorldInfo.TimeSeconds or WorldInfo.LevelTimeSeconds is stored within there. This variables holds the number of seconds since starting the level. There are other time variables within WorldInfo that you can look up as well.

If you are using a custom gametype, then within the RestartPlayer function is where pawns are spawned into the world. The pawns are possessed by the Controller there, so you should be able to retrigger the volume from there.

2) Base game types will create new instances of the pawn here. I wouldn't say that it's inefficient because there may be some cases where the dead pawn may continue to exist after the player has respawned. An example of such a case us if the pawn has died, and the dead body needs to hang around for some time. If this is not needed for your gametype (dead bodies disappear instantly) then perhaps you can implement your own pawn pool if you wish.

DeapaWaspo
06-02-2009, 08:54 PM
1) I'll try this out now and see if I can get it to work.

2) That makes complete sense now. Thank you for clearing that up and helping me understand. I wasn't sure if it was just my game type causing that or what. It had me worried cause I didn't want to run in to memory problems down the road. Thank you for all your input.

DeapaWaspo
06-02-2009, 10:49 PM
Ok, Im trying to call the event in the RestartPlayer function from my gametype class. I cant seem to figure out how to call the touch event in my Volume class though.

Solid Snake
06-03-2009, 12:13 AM
Within Actor I believe there is a PhysicsVolume variable which tells you what PhysicsVolume the actor is currently in. So, as long as your custom volume is a subclass of PhysicsVolume you should be able to use that.

DeapaWaspo
06-03-2009, 12:21 AM
And just my luck... My volume is a subclass of the plain old Volume... I figured for my purposes a PhysicsVolume wouldn't be necessary and a normal volume would suffice. I guess not. :-(

EDIT: It was easy enough to just subclass the PhysicsVolume and use the PhysicsVolume var in Actor like you said. Works like a charm. Thank you Snake. However for future reference, is there a way to call one class's event or function from another class? Just in case later on there isn't that magic variable.

Xyx
06-16-2009, 09:15 AM
Just like this?

OtherObject.SomeFunction(someValue);