Results 1 to 14 of 14
  1. #1
    Redeemer
    Join Date
    Nov 2009
    Location
    Crete
    Posts
    1,044

    Default Reforming my Question - How to spawn an Archetype ( PointLightMovable )

    Since my original question has been asnwered I should reform it:
    How to spawn an Archetype ( PointLightMovable ).

    Light Function is a const and there 's no way of setting it in UScript but this:
    Code:
    native final function SetLightProperties(optional float NewBrightness = Brightness, optional color NewLightColor = LightColor, optional LightFunction NewLightFunction = Function);
    Any ideas about how I could possibly use the function and set a MatInst in a PointLightMovable in Uscript or any other functional way of doing it?
    Using archrtypes doesn't work in my case for several reasons. I just need to set a single MatInst in my light class.

    Thanks!
    Last edited by ThePriest909; 07-13-2012 at 03:25 PM.

  2. #2
    Redeemer
    Join Date
    Dec 2008
    Location
    Germany
    Posts
    1,553

    Default

    You can't change the Material a LightFunction is using. You can however change the lightfunction with that function. So you need to setup a lightfunction that uses your MatInst first.

    This also covers the script side of LightFunctions.
    Youtube - UnrealEverything

    2B || !(2B)

  3. #3
    Redeemer
    Join Date
    Nov 2009
    Location
    Crete
    Posts
    1,044

    Default

    Thanks for the link UE!

  4. #4
    Redeemer
    Join Date
    Nov 2009
    Location
    Crete
    Posts
    1,044

    Default

    So I tried the archetype way of doing the thing ( Link provided by UE above) however I have troubles spawning the archetype.
    Any idea about what I'm doing wrong?

    Here's what I tried:

    Code:
    /** spawn the !@^$#)#@!$^ dynamic light already */
    
    var	Koukou_PowerLight		MuzzleFlashLight; //My PointLightMovable class
    var	PointLightMovable		MuzzleFlashArchetype;
    
    simulated function PostBeginPlay()
    {
    	//Weapon Light 
    	MuzzleFlashLight = Spawn(class'Koukou_PowerLight',,,,, MuzzleFlashArchetype);
    	SkeletalMeshComponent(Mesh).AttachComponentToSocket(MuzzleFlashLight.LightComponent,MuzzleFlashSocket);
    	MuzzleFlashLight.LightComponent.SetEnabled(bIsShooting);
    
    	super.PostBeginPlay();
    }
    
    defaultproperties
    {
            MuzzleFlashSocket=MuzzleFlashSocket
            MuzzleFlashArchetype=PointLightMovable'01_Weapons.WP_Archetypes.Electric_Light_Arch'
    }
    The code compiles just fine but it won't spawn the archetype. At least that's what my log claims.

  5. #5
    Redeemer
    Join Date
    Dec 2008
    Location
    Germany
    Posts
    1,553

    Default

    Would be helpful if you said what the log says.

    Also you aren't following it exactly. I can't see where you spawn the LightFunction and assign it...
    Youtube - UnrealEverything

    2B || !(2B)

  6. #6
    Redeemer
    Join Date
    Nov 2009
    Location
    Crete
    Posts
    1,044

    Default

    Edit: Got an answer by the time I bumped this up so not bumping anymore...

    I don't spawn the light function. i just spawn the light archetype where I assigned the light function according to the tut.

    This Image Was Automatically Resized by using the Screenshot Tag.  Click to view the full version

    The archetype works fine when it's dropped in the editor or spawned by kismet I just can't spawn it in UScript for some reason.
    Last edited by ThePriest909; 07-12-2012 at 04:47 AM.

  7. #7
    Redeemer
    Join Date
    Nov 2009
    Location
    Crete
    Posts
    1,044

    Default

    Here's the full script ( just testing version no debugging.. I removed the "if" stuff and logs but in any case all I did with the logs was if MuzzleFlashLight==none then type in log light couldn't spawn return and try again). I'm not a programmer so I really can't say if I"m right about this.

    Light:
    Code:
    class Koukou_PowerLight extends PointLightMovable
        notplaceable;
    
    var(Light) const archetype LightFunction LightFunctionArchetype;
    
    function PostBeginPlay()
    {
      local PointLightComponent PointLightComponent;
      local LightFunction LightFunction;
    
      Super.PostBeginPlay();
    
      PointLightComponent = PointLightComponent(LightComponent);
      if (PointLightComponent != None)
      {
        if (LightFunctionArchetype != None && LightComponent.Function == None)
        {
          LightFunction = new () LightFunctionArchetype.Class(LightFunctionArchetype);
          if (LightFunction != None)
          {
            LightComponent.SetLightProperties(,, LightFunction);
          }
        }
    
        PointLightComponent.UpdateColorAndBrightness();
      }
    }
    	
    defaultproperties
    {
        Begin Object name=PointLightComponent0
            LightColor=(R=150,G=180,B=255)
    		Brightness=2.0
    		Radius=256
    		CastShadows=false
    		
    		//LightSgafts
    		bRenderLightShafts=true
    		OcclusionDepthRange=512
    		
    		BloomScale=2
    		BloomThreshold=0
    		BloomScreenBlendThreshold=0.5
    		BloomTint=(R=255,G=255,B=255)
    		RadialBlurPercent=100
    		OcclusionMaskDarkness=0.25
        End Object
    	
        bNoDelete=false
    }
    Weapon:
    Code:
    /** dynamic light */
    var	Koukou_PowerLight		MuzzleFlashLight;
    var	PointLightMovable		MuzzleFlashArchetype;
    var repnotify bool bIsShooting;
    var SkeletalMeshComponent SKMesh;
    
    /*****************************************************************************************************************************************************
    */
    simulated function PostBeginPlay()
    {
    	SKMesh = SkeletalMeshComponent(Mesh);
    	
    	//if (MuzzleFlashLight==none)
    	{
    		//Weapon Light 
    		MuzzleFlashLight = Spawn(class'Koukou_PowerLight',,,,, MuzzleFlashArchetype);
    		SkeletalMeshComponent(Mesh).AttachComponentToSocket(MuzzleFlashLight.LightComponent,MuzzleFlashSocket);
    		MuzzleFlashLight.LightComponent.SetEnabled(bIsShooting);
    	}
    }
    
    default properties
    {
    	MuzzleFlashArchetype=PointLightMovable'01_Weapons.WP_Archetypes.Electric_Light_Arch'
    	bIsShooting=false
    }
    The bShoting thingy is used by Weapon's StartFire and StopFire Functions in order to switch the ligh while player is shooting. I don't use the usual MuzzleLight methods since it's not meant to be a "usual" weapon...
    In any case the whole thing works fine if I spawn a usual light class. The problem came with the archetype light. I must be doing something wrong with spawning the archetype. I tried to use this:
    http://udn.epicgames.com/Three/Arche...ogrammatically
    Last edited by ThePriest909; 07-12-2012 at 05:30 AM.

  8. #8
    Redeemer
    Join Date
    Nov 2009
    Location
    Crete
    Posts
    1,044

    Default

    Spent the entire day on this... No luck.

    I ended up with:

    Code:
    class Koukou_Weapon extends UDKWeapon
    	dependson(Koukou_PlayerController)
    	config(Weapon)
    	abstract;
    
    var	PointLightMovable					MuzzleFlashLight;
    var()	const archetype	PointLightMovable	MuzzleFlashArchetype;
    
    simulated function PostBeginPlay()
    {
    	SKMesh = SkeletalMeshComponent(Mesh);
    
    	if (  SKMesh != none )
    	{
    		//Weapon Light
    		MuzzleFlashLight = Spawn(MuzzleFlashArchetype.Class, None, 'None', Location, Rotation, MuzzleFlashArchetype);
    		SkeletalMeshComponent(Mesh).AttachComponentToSocket(MuzzleFlashLight.LightComponent,MuzzleFlashSocket);
    		MuzzleFlashLight.LightComponent.SetEnabled(bIsShooting);
    	}
    	
    	if (MuzzleFlashLight == none)
        {        
    		return;
        }
    	super.PostBeginPlay();
    }
    
    default properties
    {
    	MuzzleFlashArchetype=PointLightMovable'01_Weapons.WP_Archetypes.Electric_Light_Arch'
    	MuzzleFlashSocket=MuzzleFlashSocket
    }
    And a log warning saying
    Code:
    ScriptWarning: Accessed None 'MuzzleFlashLight'
    Any info on how I could possibly spawn the Archetype would be most wellcome :\

  9. #9
    Redeemer
    Join Date
    Nov 2009
    Location
    Crete
    Posts
    1,044

    Default

    Bumping this up. All I'm asking is how to spawn a PointLightMovable Archetype.
    Thanks.

  10. #10
    Redeemer
    Join Date
    Nov 2009
    Location
    Crete
    Posts
    1,044

    Default

    Shameless Bump!

  11. #11
    Iron Guard
    Join Date
    Feb 2006
    Location
    In Potatoland
    Posts
    511

    Default

    Code:
    PointLightInstance = Spawn(class'PointLightMovable', self,, Location, Rotation, StaticMeshActor'SomeArchetypePackage.PointLightArchetype');
    should work just as you have it in your example there, but make sure whatever you're trying to spawn is actually spawnable (bStatic=False, bNoDelete=False)

  12. #12
    Redeemer
    Join Date
    Nov 2009
    Location
    Crete
    Posts
    1,044

    Default

    Thanks Farseer! Haven't tried it yet but may I ask why a "StaticMeshActor"?

  13. #13
    Iron Guard
    Join Date
    Feb 2006
    Location
    In Potatoland
    Posts
    511

    Default

    My bad, sorry, should be PointLightMovable instead of StaticMeshActor there.

  14. #14
    Redeemer
    Join Date
    Nov 2009
    Location
    Crete
    Posts
    1,044

    Default

    Okay based on your example I tried a
    Code:
    MuzzleFlashLight = Spawn(Class'Koukou_PowerLight', self, , Location, Rotation, PointLightMovable'01_Weapons.WP_Archetypes.Electric_Light_Arch');
    that get's me an error:
    Code:
    Error, Call to 'Spawn': bad or missing parameter 6
    So I turned parameter 6 back into a variable and compliles just fine... can't really understand why it compiles that way to be honest :\ My var reads
    Code:
    var()	Archetype	PointLightMovable	MuzzleFlashArchetype;
    However this won't work in game either. It gets me the same log error reading
    Code:
    ScriptWarning: Accessed None 'MuzzleFlashLight'
    The light Class itself spawns just fine with a simple
    Code:
    MuzzleFlashLight=spawn(class'Koukou_PowerLight',self);
    Last edited by ThePriest909; 07-24-2012 at 09:33 AM.


 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Copyright ©2009-2011 Epic Games, Inc. All Rights Reserved.
Digital Point modules: Sphinx-based search vBulletin skin by CompletevB.com.