UE3 - General Game crashes with more than one attachment

  • 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.

Fives

New Member
Jan 4, 2015
3
0
0
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:
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:

VendorX

Member
Aug 2, 2010
231
6
18
BXL/Paris
Doing stuff like attachment before Pawn.PostBeginPlay is very risky because of many different Pawn setups - try to do this after calling Super.

... if not, I believe there was a better place to do stuff like this, it was something like PostLoadBeginPlay (or something ...), which was called after either loading & starting a map, or loading a savegame map, but more important: for linking mesh with animation.
Don't forget to call Super before ...

... and always check the log ...
 
Last edited:

Fives

New Member
Jan 4, 2015
3
0
0
Thanks for the help. I tried calling it on the beginning but i get the same result every time even with PostLoadBeginPlay. The problem is that the log says nothing. It just stops at the point of the crash and writes only half of a line :/
 

VendorX

Member
Aug 2, 2010
231
6
18
BXL/Paris
So it's most probably problem with animation - by attaching additional SKM, animation tree goes to hell (probably because of duplicate bone names).

Q: why you trying to attach SKM?
 

Fives

New Member
Jan 4, 2015
3
0
0
I didn't attach SKM. But i finally found the error. It was because of the karma Physics. I created a new Accessory Actor without karma and now it works perfectly fine.
Thank you for your help ;)