Announcement

Collapse
No announcement yet.

Archetype not being lighted anymore. (MAY/2012)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Archetype not being lighted anymore. (MAY/2012)

    Greetings.

    Well, I'm using archetypes (extends from GamePawn) to place mobs on my level, and my character has a pointlightcomponent on it that follows the player position.
    Until 07/11 release it works pretty well, the placed archetypes are lit and casts shadows, but from May/12 the light stoped affect their LightEnvironments and I have no idea why.

    The weird is that on "play from here" on UEditor it works...

    Any idea about what does changed?

    Thanks


    creasso

    #2
    Creasso, could you whip up some sample scripts that reduce the code down to your issue and provide them here? Preferably make them with the 07/11 so they can be tested in both that and the May build to see the different behavior. Thanks!

    I presume by 'archetype' you mean a custom class you created, not the archetype assets that can be created in the editor.

    Best.

    Comment


      #3
      Is the lighting for the map baked?

      Comment


        #4
        Here we go...

        @SolidSnake and GigaHobbit: Thanks by your answers, here is the code, and yes, it's baked and ready...

        The pawn code 07/11:
        Code:
        class VidaMobPawn extends GamePawn
        	placeable;
        
        var DynamicLightEnvironmentComponent ThisLightEnvironment;
        var VidaAIController Brain;
        var SkeletalMeshComponent InternalMesh;
        var(MobGraphics) SkeletalMesh MobModel;
        var(MobGraphics) AnimSet MobAnimSet;
        var(MobGraphics) PhysicsAsset MobPhysics;
        var(MobGraphics) AnimTree MobAnimTree;
        var(MobGraphics) bool bNeedChangePostureToRun;
        var(MobConfig) bool bCanRangeAttack;
        var(MobConfig) int Armor;
        var(MobConfig) float AttackSpeed;
        var(MobConfig) float BaseGroundSpeed;
        var(MobConfig) float WalkGroundSpeed;
        var(MobConfig) class<VidaProjectile> ProjectileClass;
        var(MobConfig) int DefeatPoints; // Bonus points earned by defeat
        
        // Combat variables 
        var int ArmorStatus;
        var int Concentration;
        var bool ArmorDepleted;
        var bool Loading;
        var bool bDying;
        var float DeathTime;
        
        // Movement variables
        var Vector PawnSightPoint;
        
        // IK related Variables
        var Vector IK_Lfoot_WorldNor;
        var Vector IK_Rfoot_WorldNor;
        var Vector LFoot_WorldLoc;
        var Vector RFoot_WorldLoc;
        var Vector Final_Rot_Adjust;
        var SkelControlSingleBone RootAlign;
        
        // Animation Variables
        var byte StandType;     // Iddle and preparations
        var byte CombatType;    // Melee Attack, RangeAttack, Idle or Hit
        var byte MoveType;      // Kind of walking animation
        var bool bReadyToMove; 
        var bool bReadyToAct;
        var bool bNewAttackAllowed;
        var bool bAttackSpeedSet;
        
        simulated event PostBeginPlay()
        {
        	super.PostBeginPlay();
        	
        	ParseEditorProperties();
        	
        	if(!bNeedChangePostureToRun)
        	{
        		bReadyToAct = true;
        		bReadyToMove = true;
        		MovementSpeedModifier = BaseGroundSpeed;
        	}
        	else
        	{
        		bReadyToAct = true;
        		bReadyToMove = false;
        		StandType = 1;
        		CombatType = 0; // Defines Iddle animation
        		MoveType = 1;   // Defines biped walk Animation
        		MovementSpeedModifier = WalkGroundSpeed;
        	}	
        	
        }
        
        function ParseEditorProperties()
        {
        	Mesh.SetLightEnvironment(ThisLightEnvironment);
        	Mesh.SetPhysicsAsset(MobPhysics);
        	Mesh.AnimSets[0]=MobAnimSet;
        	Mesh.SetAnimTreeTemplate(MobAnimTree);
        	Mesh.SetSkeletalMesh(MobModel);
        	HealthMax = Armor;
        	Health = Armor;
        }
        
        simulated event Tick(Float DeltaTime)
        {
        	super.Tick(DeltaTime);
        	PawnSightPoint = Location + vect(0,0,120);
        
        	if(bDying)
        	{
        		if(`TimeSince(DeathTime) > 3)
        		{
        			Mesh.SetNotifyRigidBodyCollision(false);
        			Mesh.SetActorCollision(false,false,false);
        			Mesh.PutRigidBodyToSleep();
        			Mesh.SetBlockRigidBody(false);			
        		}
        
        		if(`TimeSince(DeathTime) > 5)
        		{
        			Destroy();
        		}
        	}
        }
        
        simulated event TakeDamage(int Damage, Controller InstigatedBy, vector HitLocation, vector Momentum, class<DamageType> DamageType, optional TraceHitInfo HitInfo, optional Actor DamageCauser)
        {
        	// First damages armor
        	if(Armor >= Damage)
        		Armor = Armor - Damage;
        	else
        		Armor = 0;
        
        	// After, begins to kill the mob
        	if(Armor > 0 && Health > Damage)
        	{
        		super.TakeDamage(Damage, InstigatedBy, HitLocation, Momentum, DamageType, HitInfo, DamageCauser);
        	}
        	else
        	{
        		KillMob();
        	}
        }
        
        function KillMob()
        {
        	local array<name> NamedBones;
        	
        	// Empty Concentration
        	Concentration = 0;
        
        	if(Mesh != none)
        	{
        		Mesh.bUpdateJointsFromAnimation = false;
        		// Does an overall update
        		Mesh.ForceSkelUpdate();
        		// Builds an array from bone names to post use
        		Mesh.GetBoneNames(NamedBones);
        		
        
        		Mesh.MinDistFactorForKinematicUpdate = 0.f;
        		Mesh.SetRBChannel(RBCC_Pawn);
        		Mesh.SetTickGroup(TG_PostAsyncWork);
        		CollisionComponent = Mesh;
        		CylinderComponent.SetActorCollision(false, false);
        		Mesh.SetActorCollision(true, false);
        		Mesh.SetTraceBlocking(true, true);
        		
        		// Initializes all constraints
        		Mesh.PhysicsAssetInstance.SetNamedMotorsAngularPositionDrive(true, true, NamedBones, Mesh, false);
        		//HandMesh.PhysicsAssetInstance.SetNamedMotorsAngularVelocityDrive(false, false, NamedBones, HandMesh, false);
        		Mesh.PhysicsAssetInstance.SetAngularDriveScale(1.0f,1.0f,0);
        		Mesh.SetRBCollidesWithChannel(RBCC_Default, true);
        		Mesh.SetRBCollidesWithChannel(RBCC_Pawn, false);
        		Mesh.SetRBCollidesWithChannel(RBCC_Vehicle, false);
        		Mesh.SetRBCollidesWithChannel(RBCC_Untitled3, false);
        		Mesh.SetRBCollidesWithChannel(RBCC_BlockingVolume, true);
        
        		//SetPhysics(PHYS_RigidBody);
        		Mesh.PhysicsAssetInstance.SetAllBodiesFixed(false);
        		Mesh.PhysicsWeight = 1.0f;
        		Mesh.SetRBLinearVelocity(Velocity, false);
        		Mesh.ScriptRigidBodyCollisionThreshold = MaxFallSpeed;
        		Mesh.SetNotifyRigidBodyCollision(false);
        
        		//Registers Death Time
        		DeathTime = WorldInfo.TimeSeconds;
        
        		Brain.SharedMasterRef.FireUnit(Brain);
        		VidaGameInfo(WorldInfo.Game).MobsInGame.RemoveItem(Brain);
        
        		bDying = true;
        	}
        }
        
        simulated event bool HealDamage(int Amount, Controller Healer, class<DamageType> DamageType)
        {
        	local bool originalclassreturn;
        	originalclassreturn = super.HealDamage(Amount, Healer, DamageType);
        	if(Armor < HealthMax)
        	{
        		Armor = Min(HealthMax, Armor + Amount);
        	}
        	Loading = true;
        	return originalclassreturn;
        }
        
        simulated event OnAnimPlay(AnimNodeSequence SeqNode)
        {
        	if(SeqNode.AnimSeqName == 'ATTACK')
        	{		
        		SeqNode.Rate = AttackSpeed;
        		bNewAttackAllowed = false;
        	}
        
        	if(SeqNode.AnimSeqName == 'LoadShoot')
        	{
        		SeqNode.Rate = AttackSpeed;
        		bNewAttackAllowed = false;
        	}
        }
        
        // Events triggered by animations ending
        simulated event OnAnimEnd(AnimNodeSequence SeqNode, float PlayedTime, float ExcessTime)
        {
        	if(SeqNode.AnimSeqName == 'INSECT_IN')
        	{
        		bReadyToMove = true;
        		bReadyToAct = false;
        		MovementSpeedModifier = BaseGroundSpeed;
        	}
        
        	if(SeqNode.AnimSeqName == 'INSECT_OUT')
        	{
        		bReadyToMove = false;
        		bReadyToAct = true;
        		MovementSpeedModifier = WalkGroundSpeed;
        	}
        
        	if(SeqNode.AnimSeqName == 'ATTACK')
        	{
        		bNewAttackAllowed = true;
        		SeqNode.ReplayAnim();
        	}
        
        	if(bCanRangeAttack)
        	{
        		if(SeqNode.AnimSeqName == 'LoadShoot')
        		{
        			ShootProjectile();
        			CombatType = 4;
        		}
        
        		if(SeqNode.AnimSeqName == 'ShootCooldown')
        		{
        			bNewAttackAllowed = true;
        			CombatType = 3;
        		}
        	}	
        }
        
        simulated event PostInitAnimTree(SkeletalMeshComponent SkelComp)
        {
        	super.PostInitAnimTree(SkelComp);
        }
        
        function ShootProjectile()
        {
        	local Projectile Bullet;
        	local SkeletalMeshSocket SpawnPoint;
        
        	SpawnPoint = InternalMesh.GetSocketByName('ProjectileEmmiter');
        
        	if(SpawnPoint != none && !bDying && !Brain.CheckTargetDied())
        	{
        		Bullet = Spawn(ProjectileClass, , ,InternalMesh.GetBoneLocation(SpawnPoint.BoneName));
        		Bullet.SetRotation(Rotator((Brain.CurrentTarget.Location + Vect(0,0,80)) - InternalMesh.GetBoneLocation(SpawnPoint.BoneName)));
        		Bullet.Init(Normal((Brain.CurrentTarget.Location + Vect(0,0,80)) - InternalMesh.GetBoneLocation(SpawnPoint.BoneName)));
        	}
        }
        
        DefaultProperties
        {
        	Components.Remove(Sprite)
        	GroundSpeed=+00500.00000;
        	JumpZ=0;
        	DestinationOffset = 10;
        	bNewAttackAllowed = true;
        	ControllerClass=class'Vida.VidaAIController'
        	Begin Object Class=DynamicLightEnvironmentComponent Name=PawnLightEnvironment
        		LightDistance=8
        		ModShadowFadeoutTime=1.0
        		MinTimeBetweenFullUpdates=0.2
        		AmbientGlow=(R=0,G=0,B=0,A=0)
        		AmbientShadowColor=(R=0,G=0,B=0,A=0)
        		// LightShadowMode=LightShadow_ModulateBetter - Removed 07/11
        		// ShadowFilterQuality=SFQ_High - Removed 07/11
        		bRequiresNonLatentUpdates=true
        		bShadowFromEnvironment=false
        		bSynthesizeSHLight=true
        	End Object
        	ThisLightEnvironment = PawnLightEnvironment;
        	Components.Add(PawnLightEnvironment)
        	// Initialize default mesh properties except by the ones related to this specific mob graphic archetype
        	Begin Object Class=SkeletalMeshComponent Name=PawnSkeletalMesh
        		CastShadow=true;
        		bHasPhysicsAssetInstance = true;
        		bSkipAllUpdateWhenPhysicsAsleep = true;
        		bCastDynamicShadow=true;
        		bOwnerNoSee=false;
        		LightEnvironment=PawnLightEnvironment;
                BlockRigidBody=true;
                CollideActors=true;
                BlockZeroExtent=true;
        	End Object
        	Mesh=PawnSkeletalMesh;
        	Components.Add(PawnSkeletalMesh);
        }
        Usage (07/11):
        -Create a package, with a Smesh, Atree, aSet, Texture and MaterialInstance.
        -Go to ActorClasses browser, find VidaMobPawn, RightClick it and create an archetype on the package.
        -Edit the archetype properties filling the mobgraphics TAB (F4)
        -Also fill the Base Pawn Mesh field with the required informations (this mesh will be overriden, but will be the one used on visualization on the editor.
        -Optionally you can generate that custom thumb from your mob
        -Save the package
        -Drag monsters where you want.

        Your main character (any pawn) needs a pointlightcomponent on her class.

        Of course I also did some tests, and looks like the parseeditorproperties() function can't override the baseclass pawn mesh... It's a theory yet, but if you don't fill the baseclass mesh fields it works, the only problem is this way you don't have the mob model on the editor...

        Well, it's what I know until today, thanks by your ready response.


        creasso

        Comment


          #5
          Additional Info:

          -Did a test creating a single instance from the class through the AddVidaMobPawn here command on the editor window/Viewport.
          -Filled the fields just to that instance and worked pretty well (lit!)
          -Filled the baseclass mesh on the single instance to watch the mesh on editor and worked (lit!)
          -Tried create an archetype from this instance (right clicking on it on the level) saving it to the package and after, placed an saved archetype instance on the level. This made not just the archetype instance well like the manually created one stop being affected by the character pointlight.

          IMO: Probably something related to Archetype functionality itself or how my class behave with it.

          Best


          creasso

          Comment

          Working...
          X