DynamicLoadObject?

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

Smoke39

whatever
Jun 2, 2001
1,793
0
0
How can I change the models a weapon uses in the middle of a game? I saw this DynamicLoadObject thingy in the SetHand function of the translocator. I stuck

Mesh = mesh(DynamicLoadObject("Botpack.Rifle2m", class'Mesh'));

somewhere and I get "Error, Bad or missing expression in parenthesis." Anyone have a solution?
I should be able to release an early version of my mod soon after I figure this out.
 

Wormbo

Administrator
Staff member
Jun 4, 2001
5,913
36
48
Germany
www.koehler-homepage.de
OK, let's see what's wrong with it. :D
Code:
native static final function object DynamicLoadObject( string ObjectName, class ObjectClass, optional bool MayFail );
First parameter should be a string, that's correct, second parameter should be a valid class (class'Class', class'Mesh', class'Sound' and class'Texture' being the most common), that's correct, too. When MayFail is true it doesn't log an error if the object could not be loaded, but that's not important in most cases.

Hmm... that line looks correct.:confused:

Let's try something else...
Botpack is always loaded. Maybe you should try
Code:
Mesh = mesh'Botpack.Rifle2m';
instead. It should work the same way, unless you want to use a package not listed above yours in EditPackages.
 

Smoke39

whatever
Jun 2, 2001
1,793
0
0
Oops. Wrong line, it does work. It was complaining about this:

PlayerViewOffset = (5.000000,-1.600000,-1.700000);

I can never remember how to do those blasted things.
 

Smoke39

whatever
Jun 2, 2001
1,793
0
0
It seems like you can only change the PlayerViewOffset once. If there's no way around this then if I release an early version of this mod everything'll probably be on the right gountlet... Hopefully I'll be able to move the FireOffset around a little more freely.
 

Wormbo

Administrator
Staff member
Jun 4, 2001
5,913
36
48
Germany
www.koehler-homepage.de
Spotted the problem:
Code:
class Weapon extends Inventory

(...)

// set which hand is holding weapon
function setHand(float Hand)
{
	if ( Hand == 2 )
	{
		PlayerViewOffset.Y = 0;
		FireOffset.Y = 0;
		bHideWeapon = true;
		return;
	}
	else
		bHideWeapon = false;

	if ( Hand == 0 )
	{
		PlayerViewOffset.X = Default.PlayerViewOffset.X * 0.88;
		PlayerViewOffset.Y = -0.2 * Default.PlayerViewOffset.Y;
		PlayerViewOffset.Z = Default.PlayerViewOffset.Z * 1.12;
	}
	else
	{
		PlayerViewOffset.X = Default.PlayerViewOffset.X;
		PlayerViewOffset.Y = Default.PlayerViewOffset.Y * Hand;
		PlayerViewOffset.Z = Default.PlayerViewOffset.Z;
	}
	PlayerViewOffset *= 100; //scale since network passes vector components as ints
	FireOffset.Y = Default.FireOffset.Y * Hand;
}
As you can see Default.PlayerViewOffset is used here, so you will have to change this value. (Warning! This is kind of global. It changes default values for the class itself, so it will affect all players.)
 

Smoke39

whatever
Jun 2, 2001
1,793
0
0
I'm confused. I'm just gonna make it all on one gauntlet until I make my new models.
 

Ghost3021

Registered Hobbit
Nov 21, 2004
586
0
0
34
Behind you.
Smoke39 said:
How can I change the models a weapon uses in the middle of a game? I saw this DynamicLoadObject thingy in the SetHand function of the translocator. I stuck

Mesh = mesh(DynamicLoadObject("Botpack.Rifle2m", class'Mesh'));

somewhere and I get "Error, Bad or missing expression in parenthesis." Anyone have a solution?
I should be able to release an early version of my mod soon after I figure this out.

DOH!
Wrong quotes!!
Mesh = mesh(DynamicLoadObject("Botpack.Rifle2m", class'Mesh'));
should be
Mesh = mesh(DynamicLoadObject('Botpack.Rifle2m', class'Mesh'));

At least I think...that would be why it gave you a "Error, Bad or missing expression in parenthesis."
Hope that helps.
 

Smoke39

whatever
Jun 2, 2001
1,793
0
0
Do you realize how old this is? XD Coincidentally, I was gonna look into dynamicloadobject to load some textures for some weapons sometime soon. :b
 

Ghost3021

Registered Hobbit
Nov 21, 2004
586
0
0
34
Behind you.
15th Dec 2001, 03:24 AM

I didn't see the 2001
lol whoopsies...
the unrealwiki has all sorts of good stuff though...i frequently go there for reference :tup:
 

Ghost3021

Registered Hobbit
Nov 21, 2004
586
0
0
34
Behind you.
Well, recently the in-site search feature hasn't been working...but there's still some interesting things I like to look at when I forget (like #execs ... I can NEVER remember how to do them :p).
 

Smoke39

whatever
Jun 2, 2001
1,793
0
0
I always just copy #execs from other classes of mine and change the relevant bits. :b
 

Smoke39

whatever
Jun 2, 2001
1,793
0
0
This worked for my shotgun flashlight flare in its PostBeginPlay():

Texture = Texture( DynamicLoadObject("GenFx.LensFlar.Flarel~6", class'Texture') );