attach actor to another actor, clean way?

Discussions about Coding and Scripting
Post Reply
User avatar
'Zac
Experienced
Posts: 111
Joined: Tue Jul 29, 2014 9:35 pm
Personal rank: Who knows.
Location: NC

attach actor to another actor, clean way?

Post 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
Prophunt for UT99!!!
Image
Github
User avatar
papercoffee
Godlike
Posts: 10443
Joined: Wed Jul 15, 2009 11:36 am
Personal rank: coffee addicted !!!
Location: Cologne, the city with the big cathedral.
Contact:

Re: attach actor to another actor, clean way?

Post 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).
User avatar
Barbie
Godlike
Posts: 2792
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: attach actor to another actor, clean way?

Post 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.
Attachments
CarriedBarrel.unr
(7.56 KiB) Downloaded 44 times
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
User avatar
'Zac
Experienced
Posts: 111
Joined: Tue Jul 29, 2014 9:35 pm
Personal rank: Who knows.
Location: NC

Re: attach actor to another actor, clean way?

Post by 'Zac »

Ok the hasFlag variable, can't believe I missed over that. Thanks for the help guys and your example Barbie
Prophunt for UT99!!!
Image
Github
User avatar
Feralidragon
Godlike
Posts: 5489
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: attach actor to another actor, clean way?

Post 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.
Post Reply