1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. 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.

DynamicLoadObject?

Discussion in 'General Discussion' started by Smoke39, Dec 15, 2001.

  1. Smoke39

    Smoke39 whatever

    Joined:
    Jun 2, 2001
    Messages:
    1,793
    Likes Received:
    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.
     
  2. Wormbo

    Wormbo Administrator Staff Member

    Joined:
    Jun 4, 2001
    Messages:
    5,913
    Likes Received:
    36
    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.
     
  3. Smoke39

    Smoke39 whatever

    Joined:
    Jun 2, 2001
    Messages:
    1,793
    Likes Received:
    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.
     
  4. Wormbo

    Wormbo Administrator Staff Member

    Joined:
    Jun 4, 2001
    Messages:
    5,913
    Likes Received:
    36
    Code:
    PlayerViewOffset=vect(5,-1.6,-1.7);
     
  5. Smoke39

    Smoke39 whatever

    Joined:
    Jun 2, 2001
    Messages:
    1,793
    Likes Received:
    0
    Oh yeah! :D I thought that was it. :)
     
  6. Smoke39

    Smoke39 whatever

    Joined:
    Jun 2, 2001
    Messages:
    1,793
    Likes Received:
    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.
     
  7. Wormbo

    Wormbo Administrator Staff Member

    Joined:
    Jun 4, 2001
    Messages:
    5,913
    Likes Received:
    36
    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.)
     
  8. Smoke39

    Smoke39 whatever

    Joined:
    Jun 2, 2001
    Messages:
    1,793
    Likes Received:
    0
    I'm confused. I'm just gonna make it all on one gauntlet until I make my new models.
     
  9. Ghost3021

    Ghost3021 Registered Hobbit

    Joined:
    Nov 21, 2004
    Messages:
    586
    Likes Received:
    0
    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.
     
  10. Smoke39

    Smoke39 whatever

    Joined:
    Jun 2, 2001
    Messages:
    1,793
    Likes Received:
    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
     
  11. Ghost3021

    Ghost3021 Registered Hobbit

    Joined:
    Nov 21, 2004
    Messages:
    586
    Likes Received:
    0
    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:
     
  12. Smoke39

    Smoke39 whatever

    Joined:
    Jun 2, 2001
    Messages:
    1,793
    Likes Received:
    0
    I use it every once in a while but it can be hard to navigate.
     
  13. Ghost3021

    Ghost3021 Registered Hobbit

    Joined:
    Nov 21, 2004
    Messages:
    586
    Likes Received:
    0
    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).
     
  14. Smoke39

    Smoke39 whatever

    Joined:
    Jun 2, 2001
    Messages:
    1,793
    Likes Received:
    0
    I always just copy #execs from other classes of mine and change the relevant bits. :b
     
  15. Smoke39

    Smoke39 whatever

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

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

    Ghost3021 Registered Hobbit

    Joined:
    Nov 21, 2004
    Messages:
    586
    Likes Received:
    0
    o_O how come it didn't load the mesh then?
    That's realy wierd :|.
     
  17. Smoke39

    Smoke39 whatever

    Joined:
    Jun 2, 2001
    Messages:
    1,793
    Likes Received:
    0
    I think it did:

    :b
     

Share This Page