Hi, English is not my native language so sorry for the mistakes
I'm modding for the game Star Wars Republic Commando. I recently started using uscript to expand my possibilities. Now I wrote a little script to give a pawn some attachments in a more convenient way than the editor offers (I don't know if you know the editor of this game but it has a few quirks...).
So, now my problem: Everything works fine with one mesh as attachment but if i add another one, the game crashes. I can still play the level and even see the attachments. but if i come too close or shoot at the pawn it crashes.
This happens only if the second attachment is an actor with a mesh. e.g attaching triggers works fine.
I'd appreciate any help
Here's my code:
I'm modding for the game Star Wars Republic Commando. I recently started using uscript to expand my possibilities. Now I wrote a little script to give a pawn some attachments in a more convenient way than the editor offers (I don't know if you know the editor of this game but it has a few quirks...).
So, now my problem: Everything works fine with one mesh as attachment but if i add another one, the game crashes. I can still play the level and even see the attachments. but if i come too close or shoot at the pawn it crashes.
This happens only if the second attachment is an actor with a mesh. e.g attaching triggers works fine.
I'd appreciate any help
Here's my code:
Code:
class CloneTrooper extends Republic;
struct CustomAttachment{
var() class<Actor> ActorName;
var() name Bone;
var() vector LocationOffset;
var() rotator RotationOffset;
var() vector Scale;
var() const StaticMesh StaticMesh;
var actor IngameActor;
};
var(CustomAttachment) array<CustomAttachment> Attachment;
simulated function PostBeginPlay(){
local int i;
for(i = 0; i < Attachment.length; i++){
if(Attachment[i].ActorName != None){
Attachment[i].IngameActor = spawn(Attachment[i].ActorName,,, getBoneLocation(Attachment[i].Bone));
AttachToBone(Attachment[i].IngameActor, Attachment[i].Bone);
Attachment[i].IngameActor.setRelativeLocation(Attachment[i].LocationOffset);
Attachment[i].IngameActor.setRelativeRotation(Attachment[i].RotationOffset);
Attachment[i].IngameActor.setDrawScale3D(Attachment[i].Scale);
if(Attachment[i].StaticMesh != None){
Attachment[i].IngameActor.setStaticMesh(Attachment[i].StaticMesh);
}
}
}
Super.PostBeginPlay();
}
simulated event Destroyed(){
local int i;
for(i = 0; i < Attachment.length; i++){
Attachment[i].IngameActor.destroy();
}
Super.Destroyed();
}
Last edited: