Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Thread: Creating a timer

  1. #11
    jimyB
    Guest
    Okay i delved more into the problem and the real cause is my Enemy class named "Badguy1". Surprisingly if i delete all the "badGuy1" pawns from my level the delay event works fine but if i add "Badguy1" pawns into my level the delay event doesn't seem to work. I have no clue on why this is happening , maybe you guys might know more about the issue, kindly help !

  2. #12
    jimyB
    Guest
    Here is my badguy1 and badguy1Controller classes. Thanks to the owner for providing this on the internet.

    Code:
    class Badguy1 extends UTPawn placeable;
    
    // members for the custom mesh
    var SkeletalMesh defaultMesh;
    //var MaterialInterface defaultMaterial0;
    var AnimTree defaultAnimTree;
    var array<AnimSet> defaultAnimSet;
    var AnimNodeSequence defaultAnimSeq;
    var PhysicsAsset defaultPhysicsAsset;
    
    var Badguy1Controller MyController;
    
    var float Speed;
    var int BumpDamage;
    var SkeletalMeshComponent MyMesh;
    var bool bplayed;
    var Name AnimSetName;
    
    
    var bool AttAcking;
    
    var () array<NavigationPoint> MyNavigationPoints;
    
    defaultproperties
    {    
        BumpDamage = 3.0;
        Speed=75
    	//AnimSetName="ZombieAttackBiteSeq"
    	AttAcking=false
    
    	defaultMesh=SkeletalMesh'Mypackage2.Zombie'
    	defaultAnimTree=AnimTree'Mypackage2.ZombieAnimTree'
    	defaultAnimSet(0)=AnimSet'Mypackage2.ZombieAnimSetFinal'
    	defaultPhysicsAsset=PhysicsAsset'EternalCrisis_Characters.Female.Human_Athletic_Physics'
    
    
    	Begin Object Name=WPawnSkeletalMeshComponent
    		bOwnerNoSee=false
    		CastShadow=true
    
    		//CollideActors=TRUE
    		BlockRigidBody=true
    		BlockActors=true
    		BlockZeroExtent=true
    		//BlockNonZeroExtent=true
    
    		bAllowApproximateOcclusion=true
    		bForceDirectLightMap=true
    		bUsePrecomputedShadows=false
    		LightEnvironment=MyLightEnvironment
    		//Scale=0.5
    		SkeletalMesh=SkeletalMesh'Mypackage2.Zombie'
            AnimSets(0)=AnimSet'Mypackage2.ZombieAnimSetFinal'
    		AnimTreeTemplate=AnimTree'Mypackage2.ZombieAnimTree'
    
    	End Object
    
    	mesh = WPawnSkeletalMeshComponent
    
    	Begin Object Name=CollisionCylinder
    		CollisionRadius=+0041.000000
    		CollisionHeight=+0044.000000
    		BlockZeroExtent=false
    	End Object
    	CylinderComponent=CollisionCylinder
    	CollisionComponent=CollisionCylinder
    
    	bCollideActors=true
    	bPushesRigidBodies=true
    	bStatic=False
    	bMovable=True
    
    	bAvoidLedges=true
    	bStopAtLedges=true
    
    	LedgeCheckThreshold=0.5f
    	
    }
    
    simulated function PostBeginPlay()
    {
    	super.PostBeginPlay();
    	//if (Controller == none)
    	//	SpawnDefaultController();
    	SetPhysics(PHYS_Walking);
    	if (MyController == none)
    	{
    		MyController = Spawn(class'Badguy1Controller', self);
    		MyController.SetPawn(self);		
    	}
    
        //I am not using this
    
    }
    
    function SetAttacking(bool atacar)
    {
    	AttAcking = atacar;
    }
    
    
    
    simulated event Tick(float DeltaTime)
    {
    	local AITestPawn gv;
    
    	super.Tick(DeltaTime);
    	MyController.Tick(DeltaTime);
    
    	
    	foreach CollidingActors(class'AITestPawn', gv, 200)
    	foreach VisibleCollidingActors(class'AITestPawn', gv, 100)
    	{
    		if(AttAcking && gv != none)
    		{
    			if(gv.Health > 0)
    			{
    				//Worldinfo.Game.Broadcast(self, "Colliding with player : " @ gv.Name);
                              gv.Bump(self,CollisionComponent,vect(0,0,0));
    			}
    		}
    	}
    }
    
    
    
    simulated function SetCharacterClassFromInfo(class<UTFamilyInfo> Info)
    {
    	Mesh.SetSkeletalMesh(defaultMesh);
    	//Mesh.SetMaterial(0,defaultMaterial0);
    	Mesh.SetPhysicsAsset(defaultPhysicsAsset);
    	Mesh.AnimSets=defaultAnimSet;
    	Mesh.SetAnimTreeTemplate(defaultAnimTree);
    
    }
    And badguy1Controller class

    Code:
    class Badguy1Controller extends AIController;
    
    var Badguy1 MyBadguy1Pawn;
    var Pawn thePlayer;
    var Actor theNoiseMaker;
    var Vector noisePos;
    
    var () array<NavigationPoint> MyNavigationPoints;
    var NavigationPoint MyNextNavigationPoint;
    
    var int actual_node;
    var int last_node;
    
    var float perceptionDistance;
    var float hearingDistance;
    var float attackDistance;
    var int attackDamage;
    
    var float distanceToPlayer;
    var float distanceToTargetNodeNearPlayer;
    
    var Name AnimSetName;
    
    var bool AttAcking;
    var bool followingPath;
    var bool noiseHeard;
    var Float IdleInterval;
    
    defaultproperties
    {
        attackDistance = 50
        attackDamage = 10
        perceptionDistance = 2000
    
    	//AnimSetName ="ATTACK"
    	actual_node = 0
    	last_node = 0
    	followingPath = true
    	IdleInterval = 2.5f
    
    }
    
    function SetPawn(Badguy1 NewPawn)
    {
        MyBadguy1Pawn = NewPawn;
    	Possess(MyBadguy1Pawn, false);
    	MyNavigationPoints = MyBadguy1Pawn.MyNavigationPoints;
    }
    
    function Possess(Pawn aPawn, bool bVehicleTransition)
    {
        if (aPawn.bDeleteMe)
    	{
    		`Warn(self @ GetHumanReadableName() @ "attempted to possess destroyed Pawn" @ aPawn);
    		 ScriptTrace();
    		 GotoState('Dead');
        }
    	else
    	{
    		Super.Possess(aPawn, bVehicleTransition);
    		Pawn.SetMovementPhysics();
    		
    		if (Pawn.Physics == PHYS_Walking)
    		{
    			Pawn.SetPhysics(PHYS_Falling);
    	    }
        }
    }
    
    
    state Idle
    {
    
        event SeePlayer(Pawn SeenPlayer)
    	{
    	    thePlayer = SeenPlayer;
            distanceToPlayer = VSize(thePlayer.Location - Pawn.Location);
            if (distanceToPlayer < perceptionDistance)
            {
            	// Worldinfo.Game.Broadcast(self, "I can see you!!");
                GotoState('Chaseplayer');
            }
        }
    
    Begin:
       // Worldinfo.Game.Broadcast(self, "!!!!!!!  idle  !!!!!!!!");
    
    	Pawn.Acceleration = vect(0,0,0);
    	MyBadguy1Pawn.SetAttacking(false);
    
    	Sleep(IdleInterval);
    
    	//Worldinfo.Game.Broadcast(self, "!!!!!!!  Going to FollowPath  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
    	followingPath = true;
    	actual_node = last_node;
    	GotoState('FollowPath');
    
    }
    
    state Chaseplayer
    {
      Begin:
    	
    	MyBadguy1Pawn.SetAttacking(false);
        Pawn.Acceleration = vect(0,0,1);
    	
        while (Pawn != none && thePlayer.Health > 0)
        {
    
    
    		if (ActorReachable(thePlayer))
    		{
    			distanceToPlayer = VSize(thePlayer.Location - Pawn.Location);
    			if (distanceToPlayer < attackDistance)
    			{
    				GotoState('Attack');
    				break;
    			}
    			else //if(distanceToPlayer < 300)
    			{
    				MoveToward(thePlayer, thePlayer, 20.0f);
    				if(Pawn.ReachedDestination(thePlayer))
    				{
    					GotoState('Attack');
    					break;
    				}
    			}
    		}
    		else
    		{
    			MoveTarget = FindPathToward(thePlayer,,perceptionDistance + (perceptionDistance/2));
    			if (MoveTarget != none)
    			{
    				//Worldinfo.Game.Broadcast(self, "Moving toward Player");
    
    				distanceToPlayer = VSize(MoveTarget.Location - Pawn.Location);
    				if (distanceToPlayer < 100)
    					MoveToward(MoveTarget, thePlayer, 20.0f);
    				else
    					MoveToward(MoveTarget, MoveTarget, 20.0f);	
    		
    				//MoveToward(MoveTarget, MoveTarget);
    			}
    			else
    			{
    				GotoState('Idle');
    				break;
    			}		
    		}
    
    		Sleep(1);
        }
    }
    
    state Attack
    {
     Begin:
    	Pawn.Acceleration = vect(0,0,0);
    	MyBadguy1Pawn.SetAttacking(true);
    	while(true && thePlayer.Health > 0)
    	{   
    		//Worldinfo.Game.Broadcast(self, "Attacking Player");
    
    		distanceToPlayer = VSize(thePlayer.Location - Pawn.Location);
            if (distanceToPlayer > attackDistance * 2)
            { 
    			MyBadguy1Pawn.SetAttacking(false);
                GotoState('Chaseplayer');
    			break;
            }
    		Sleep(1);
    	}
    	MyBadguy1Pawn.SetAttacking(false);
    }
    
    
    auto state FollowPath
    {
    	event SeePlayer(Pawn SeenPlayer)
    	{
    	    thePlayer = SeenPlayer;
            distanceToPlayer = VSize(thePlayer.Location - Pawn.Location);
            if (distanceToPlayer < perceptionDistance)
            { 
            	//Worldinfo.Game.Broadcast(self, "I can see you!!");
    			noiseHeard = true;
    			followingPath = false;
                GotoState('Chaseplayer');
            }
        }
    
     Begin:
    
    	while(followingPath)
    	{
    		MoveTarget = MyNavigationPoints[actual_node];
    
    		if(Pawn.ReachedDestination(MoveTarget))
    		{
    			//WorldInfo.Game.Broadcast(self, "Encontrei o node");
    			actual_node++;
    			
    			if (actual_node >= MyNavigationPoints.Length)
    			{
    				actual_node = 0;
    			}
    			last_node = actual_node;
    			
    			MoveTarget = MyNavigationPoints[actual_node];
    		}	
    
    		if (ActorReachable(MoveTarget))
    		{
    			distanceToPlayer = VSize(MoveTarget.Location - Pawn.Location);
    			if (distanceToPlayer < perceptionDistance / 3)
    				MoveToward(MoveTarget, MyNavigationPoints[actual_node + 1]);
    			else
    				MoveToward(MoveTarget, MoveTarget);	
    		}
    		else
    		{
    			MoveTarget = FindPathToward(MyNavigationPoints[actual_node]);
    			if (MoveTarget != none)
    			{
    				
    			//	SetRotation(RInterpTo(Rotation,Rotator(MoveTarget.Location),Delta,90000,true));
    
    				MoveToward(MoveTarget, MoveTarget);
    			}
    		}
    
    		Sleep(1);
    	}
    }

  3. #13
    RattleSN4K3
    Guest
    I didn't check the code but...
    Try to add a Log action after your touch event in order to know if the Trigger is touched always.

    As you say, it doesn't work if you have enemies on your map, it probably has someething to do with the trigger event itself which is only activated once at default settings.

    Try to set MaxTriggerCount of the trigger event to 0.

  4. #14
    jimyB
    Guest
    Yes Snake maxtriggercount is 0. Okay so if there was some problem with triggers i tried using the level loaded event instead and the same problem again.The delay sequence works fine without enemies but it just doesn't work when i put enemies into my levels. This has affected the whole objective of my game. Now i need to either compromise on my enemies or timers in the levels. Hell this just sucks !!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •