attach actor to another actor, clean way?

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

attach actor to another actor, clean way?

Post by 'Zac » Fri Feb 23, 2018 8:01 am

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: 9869
Joined: Wed Jul 15, 2009 11:36 am
Personal rank: coffee addicted !!!
Location: Cologne, the city with the big cathedral.

Re: attach actor to another actor, clean way?

Post by papercoffee » Fri Feb 23, 2018 10:05 am

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: 2107
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: attach actor to another actor, clean way?

Post by Barbie » Fri Feb 23, 2018 3:25 pm

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.
You do not have the required permissions to view the files attached to this post.
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett

User avatar
'Zac
Experienced
Posts: 105
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 » Fri Feb 23, 2018 5:02 pm

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: 5307
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 » Sat Feb 24, 2018 1:54 am

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.