Page 1 of 1

attach actor to another actor, clean way?

Posted: Fri Feb 23, 2018 8:01 am
by 'Zac
hey ut99 community and brilliant minds, I'm working on a small mod/mutator that incorporates the need for one actor to take on the location of another actor, precisely like the CTFflag to a pawn when the pawn is carrying it. however, through class digging and codex clicking and scrolling, I cannot fully find how the CTFflag attaches smoothly to the player. the pawn class does include a carriedDecoration variable tho the only accessible way to change it is by changing it directly, tho I do not think that this is how the CTFflag attaches to the player. perhaps the evil setbase()? just need to be pointed in the right direction on how the CTFflag works and I can continue from there and rework it for my own use. thanks guys for your help in advance

Re: attach actor to another actor, clean way?

Posted: Fri Feb 23, 2018 10:05 am
by papercoffee
Well, did you look into the flag code?
Another idea... in Food Fight we have a game mode called Burger-CTF (you have to carry a burger to the enemy flag) The picked up Burger-Bomb is attached like the flag to the bag of the carrier. And the FF-source is free to use and available on our Moddb page (click banner in my signature).

Re: attach actor to another actor, clean way?

Posted: Fri Feb 23, 2018 3:25 pm
by Barbie
Have a look at CTFFlag Touch() function. The core of it is

Code: Select all

function Touch(Actor Other) {
	if ( (Pawn(Other) != None) && Pawn(Other).bIsPlayer && (Pawn(Other).Health > 0) )
	{
		Pawn(Other).MoveTimer = -1;
		Pawn(Other).PlayerReplicationInfo.HasFlag = self;
	}
}
Test map attached where you can carry a barrel.

Re: attach actor to another actor, clean way?

Posted: Fri Feb 23, 2018 5:02 pm
by 'Zac
Ok the hasFlag variable, can't believe I missed over that. Thanks for the help guys and your example Barbie

Re: attach actor to another actor, clean way?

Posted: Sat Feb 24, 2018 1:54 am
by Feralidragon
Lately I have been rechecking some of the UScript side of things, and I cannot believe how messy Epic's code was.
For instance, this HasFlag property, not only is not a boolean as you would normally expect from the name, it accepts any decoration to be used as a flag. :lol2:
It may come in handy for you now to do that attachment easier, but it doesn't make it any more right.

Having that said, attaching one actor to another "cleanly" can be done in a few ways, it all comes down to exactly the kind of actor you want to attach to what.
If it's a decoration to a pawn, like the flag, yeah, this solution probably suffices, however in other cases you have things like Physics=PHYS_Trailer for example which makes an actor fully attached to its owner actor, such as the shield belt effect for example.