attaching the weapon on the player body when not used

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

ZitherMan

New Member
Oct 11, 2001
24
0
0
I wanna put his rifle on his back when changing weapon. Is there any way doing this without put it there when making the model? I'd also like to put his gun in his holster, i will actually make a new player so if it's easier to model it straight off i will do that.
 

Papapishu

我是康
Jun 18, 2001
2,043
0
0
43
void
www.vovoid.com
Try the HasFlag used in the playerreplicationinfo.
This is intended for ctf games, but it reffers to all kinds of decorations.
Just do a decorationclass that looks like your object, and set your players playerreplicationinfo.hasflag = MyDeco;
and playerreplicationinfo.hasflag = none;
if you want it to disappear...
This way you can't use it for ctf, and you can't have more than one thing at a time, and it's carried on your back, but it's easy and built-in...
Another thing I haven't tried is the attach function in the actor class.
You just type: MyThing.Attach(something); and it should stick (I think)...
Else you might do something like this:
Subclass decoration or effects and use the tick function.

Code:
class MyThing extends decoration;

var vector ObjectOffset;

simulated function Tick(float DeltaTime)
{
	local vector X,Y,Z;
	
	GetAxes(Owner.Rotation,X,Y,Z);
	SetLocation(Owner.Location + ObjectOffset);
	SetRotation(Owner.Rotation);
}

defaultproperties
{
  ObjectOffset=(X=10,Y=-20,Z=0)
  Mesh=LodMesh'MyPackage.YadaYada'
  Texture=texture'MyPackage.BlahBlah'
}

This makes the object's location and rotation be updated as often as possible, and the location is calculated with the extra vector you've added as an offset from the player's pivot point, thus if you want it to be a knife, place it a bit lower and to the left and it'll stay there (I think) ;)
 

butto

Red Orchestra Coder
The attaching method would work best. You just have to set the object's location in the right place relative to the player and then use MyItem.SetBase(MyPawn). To detach it, set the base to None. The problem is that the item might end up in funny positions when the player is animating unless you animate the item with all the same animations that the player has and use some sort of scheme to play the item's animations too when the player's animations are played.
 

Shiit

Shiit
Dec 19, 2000
168
0
0
Hm. Epic should've added an option to attach models to polygons by number. That would've made stuff like this easy. Ohwell...
 

Papapishu

我是康
Jun 18, 2001
2,043
0
0
43
void
www.vovoid.com
Yeah.
I think they should have thought more about the model system.
They should have made the playermodels as skeletal characters to begin with.
Things like casting shadows and IK-collision might have been overkill a couple o years ago, but it wou'ld have been nice to be able to use it...
Then have a system for the IK like head-arms-legs-body in different formations, and that the different parts were called "leftleg" "rightleg" e.t.c. so that you could take out different pieces of the body and attach stuff to it and make it stay nomater what...
That would also have the advantage that the coder himself could code movements of the players on the fly... redefining the skeleton thusmaking the game more alive...
Like make a mutator that makes the player model use both hands with double enforcers and change hands according to the settings, for example, place the translocator on the left hand, and maybe even using two weapons at the same time :)

The possibilities would be unlimited :)
 

Blödsinn machen

cannon fodder
Dec 4, 2001
68
0
0
Switzerland
dwmade.stormpages.com
i haven't tried this myself, but if you want a gun to be attached to a player you might spawn it at his location and look at the code in UT_ShieldBeltEffect which has the effect use the same mesh as the player and performs the same animations with bAnimByOwner. Also if you've got the BoomBall mod it has the "Nuke" attached to the back of a player, so check out the code...