• Please make sure you are familiar with the forum rules. You can find them here: https://forums.tripwireinteractive.com/index.php?threads/forum-rules.2334636/

Code Attaching mesh to vehicle

all the art is completed (textures, skirt smesh, destroyed smesh). The custom cannon(pawn), custom tank and mutator all work flawlessly.

The only thing that I can't seem to figure it out is how to work with attachtobone. I simply want to attach the skirtsmesh to the body of the tank

This is frustrating because everything else works so well.

:S
 
Upvote 0
I think this is the difficult way to do it, for a whole slew of possible attachments.

Code:
[FONT=Courier New]// ROPawn.uc[/FONT]
[FONT=Courier New]// ...[/FONT]
 
[FONT=Courier New]var  array<ROAmmoPouch>  AmmoPouches;[/FONT]
[FONT=Courier New]var  class<ROAmmoPouch>  AmmoPouchClasses[3];[/FONT]
[FONT=Courier New]var  ROHeadgear          Headgear;[/FONT]
[FONT=Courier New]var  class<ROHeadgear>   HeadgearClass;[/FONT]
 
[FONT=Courier New]// ...[/FONT]
 
[FONT=Courier New]simulated function PostNetBeginPlay()[/FONT]
[FONT=Courier New]{[/FONT]
 
 
[FONT=Courier New][SIZE=2]// ...[/SIZE][/FONT]
 
[FONT=Courier New]  Super.PostNetBeginPlay();[/FONT]
 
[FONT=Courier New]  if (Role < ROLE_Authority)[/FONT]
[FONT=Courier New]  {[/FONT]
[FONT=Courier New]       if (HeadgearClass != None)[/FONT]
[FONT=Courier New]            Headgear = Spawn(HeadgearClass, self);[/FONT]
 
[FONT=Courier New]       for (i = 0; i < ArrayCount(AmmoPouchClasses); i++)[/FONT]
[FONT=Courier New]            {[/FONT]
[FONT=Courier New]                 if (AmmoPouchClasses[i] == None)[/FONT]
[FONT=Courier New]                      break;[/FONT]
 
[FONT=Courier New]                 AmmoPouches[AmmoPouches.Length] = Spawn(AmmoPouchClasses[i], self);[/FONT]
[FONT=Courier New]            }[/FONT]
[FONT=Courier New]  }[/FONT]
[FONT=Courier New]}[/FONT]
 
[FONT=Courier New]// ...[/FONT]

/edit

Try attaching it to the 'hull' bone?
 
Last edited:
Upvote 0
Take a look at this tutorial. It might help. It shows how to look at the bones of a mesh.
http://www.psyonix.com/NewVehiclesTutorial/
He's adding the skirt meshes to existing vehicles.

Here's some junk I came up with. Remember, it's mostly junk, but it may help.

Code:
[FONT=Courier New]Class Skirt extends RODummyAttachment;[/FONT]
[FONT=Courier New][/FONT] 
[FONT=Courier New]#exec... (exec calls here)[/FONT]
 
[FONT=Courier New]simulated function PostNetBeginPlay()[/FONT]
[FONT=Courier New]{[/FONT]
[FONT=Courier New]     local Pawn P;[/FONT]
 
[FONT=Courier New]     Super.PostNetBeginPlay();[/FONT]
 
[FONT=Courier New]     P = Pawn(Owner);[/FONT]
 
[FONT=Courier New]     if (P == None || P.DeleteMe == True)[/FONT]
[FONT=Courier New]     {[/FONT]
[FONT=Courier New]          Destroy();[/FONT]
[FONT=Courier New]     }[/FONT]
[FONT=Courier New]     Else if (P == instigator && P == ROVehicle.PanzerIVF2Tank)[/FONT]
[FONT=Courier New]     {[/FONT]
[FONT=Courier New]          P.AttachToBone(Self, 'Hull');[/FONT]
[FONT=Courier New]     }[/FONT]
[FONT=Courier New]}[/FONT]
_________________________________________
[LEFT][FONT=Courier New]class PanzerIVHTank extends PanzerIVF2Tank;[/FONT][/LEFT]
 
[FONT=Courier New]var MozP4H_Skirt skirt; // Using the above class, Skirt.[/FONT]
 
[LEFT][FONT=Courier New]function PostBeginPlay()[/FONT]
[FONT=Courier New]{[/FONT]
[FONT=Courier New]     MozP4H_Skirt = Spawn(MozP4H_Skirt, self,, self.Location, self.Rotation);[/FONT]
[FONT=Courier New]}[/FONT][/LEFT]
Self is the actor (tank) to which the skirts are attached... just one way to do it. BUt, you need a pawn to attach the thing to and to determine the initial variables from (P.location, P.rotation, P.AttachToBone, etc.)

The check to see if the pawn is the insitigator, "P==Instigator" is probably unnecessary since P is the owner anyway.

If that doesn't work, you may want to try:
Code:
     [FONT=Courier New]Self.AttachToBone(class'MozP4H_Skirt', 'Hull');[/FONT]
 
Last edited:
Upvote 0
You've got to define your variables (self, location, rotation) by getting them from the tank they're going to be attached to.

erm, no, you dont have to.
self is no variable in the common sense, its a reserved word specifying the class you are in atm, in this case
MozP4HTank
rotation and location are variables inherited from the parent classes so no need to define them, you would only get an error if you'd do so.

Moz, if you want to i can give it a go. If you send me what you have atm, i'll try it (especially the models)
 
Upvote 0
erm, no, you dont have to.
self is no variable in the common sense, its a reserved word specifying the class you are in atm, in this case
MozP4HTank
rotation and location are variables inherited from the parent classes so no need to define them, you would only get an error if you'd do so.

Moz, if you want to i can give it a go. If you send me what you have atm, i'll try it (especially the models)

could you PM me your email?

Also, my RO isn't working right now so I'll give you all the art to so you can enjoy it.

edit: or I could just check your website for it (I haven't had breakfast yet)
 
Last edited:
Upvote 0
erm, no, you dont have to.
self is no variable in the common sense, its a reserved word specifying the class you are in atm, in this case
MozP4HTank
rotation and location are variables inherited from the parent classes so no need to define them, you would only get an error if you'd do so.

Show me.

The error he was getting is a direct result of those parameters being invalid. The first rule in eliminating such errors is to check your variable definitions.

The parameters 'location' and 'rotation' are totally empty, just look at the code and the error it gave.

By deriving (which is just anothe means of definition) 'location' and 'rotation' from the actor the skirts would be attached to, it would work, assuming the skirts and the panzers allign perfectly when their vectors are zero.
 
Upvote 0
Show me.

The error he was getting is a direct result of those parameters being invalid. The first rule in eliminating such errors is to check your variable definitions.

The parameters 'location' and 'rotation' are totally empty, just look at the code and the error it gave.

By deriving (which is just anothe means of definition) 'location' and 'rotation' from the actor the skirts would be attached to, it would work, assuming the skirts and the panzers allign perfectly when their vectors are zero.

what should i show you? that every actor inherits location and rotation?
open wothgreal click a random class below actor and click the class inheritance browser.
For the skirts, yes, he would have to set both, but thats done with the spawn call.
 
Upvote 0
Wait....

Note the error is a type mismatch with the third parameter?

Code:
[LEFT][FONT=Courier New]//===================================================================[/FONT]
[FONT=Courier New]// PanzerIV Ausf H Tank[/FONT]
[FONT=Courier New]//===================================================================[/FONT]
[FONT=Courier New]class MozP4HTank extends ROTreadCraft;[/FONT][/LEFT]
 
[LEFT][FONT=Courier New]#exec OBJ LOAD FILE=..\Animations\MozP4H_anm.ukx[/FONT][/LEFT]
 
[LEFT][FONT=Courier New]// DOESN'T ****ING WORK[/FONT]
[FONT=Courier New]var     class<MozP4HSkirt>             BodySkirtClass;[/FONT]
[FONT=Courier New]var     array<MozP4HSkirt>               BodySkirt;[/FONT][/LEFT]
 
[LEFT][FONT=Courier New]function PostBeginPlay()[/FONT]
[FONT=Courier New]{[/FONT]
[FONT=Courier New]if (BodySkirt == None)[/FONT]
[FONT=Courier New]   {[/FONT]
[FONT=Courier New]   BodySkirt = Spawn(BodySkirtClass, self, Location, Rotation);[/FONT]
[FONT=Courier New]   Bodyskirt.SetBase(self)[/FONT]
[FONT=Courier New]   AttachToBone(actor'MozP4H.MozP4HSkirt', 'body' );[/FONT]
[FONT=Courier New]   }[/FONT]
[FONT=Courier New]}[/FONT][/LEFT]
 
[LEFT][FONT=Courier New]defaultproperties[/FONT]
[FONT=Courier New]{[/FONT][/LEFT]
 
[LEFT][FONT=Courier New]}[/FONT][/LEFT]

The third parameter of the Spawn call is the tag:​
Code:
[LEFT][FONT=Courier New]BodySkirt = Spawn(BodySkirtClass, Self, Tag, Location, Rotation);[/FONT][/LEFT]
The only required parameter is the first, the class actor.

Thus the type mismatch.

So I was totally barking up the wrong tree anyway lol
 
Upvote 0
Hi,

looked at your code yesterday and changed quite a lot (you dont like OOP and inheritance, right? :p)

I'm still having an error with referencing the mesh.
Btw. afai see it, the attaching of the DummyAttachment happens as soon as it spawns, so you basically just have to spawn it. No need to attach it. The attach code is in the PostBeginPlay of the DummyAttachment already.

I will keep trying, i hope to have some time for it tomorrow :)
 
Upvote 0
ok, just to keep you up with the progress: i got the skirts attached. Still having problems to get the textures on it.


Edit: Done, maybe the position is not 100% correct, but that can be changed easily

skirts.jpg

















Oh, and Moz, i kill you for having some weirdo first texture on the skirts...
 
Last edited:
Upvote 0