Results 1 to 4 of 4
  1. #1
    MSgt. Shooter Person
    Join Date
    Jul 2011
    Posts
    35

    Default Help please. Test enemies spawn outside of world?

    Ok so I'm using the UDK Game Programming With Unrealscript Beginner's Guide and it was working great. It had me create some test enemies and they worked fine. Then all of a sudden I test the code to see where I stopped at the day before, I like to go back and remember what I did the previous day, and then my test enemies were spawning but I would only see a flash of them and then they would disappear. I checked the log and got this

    Code:
    [0022.65] Log: Octree Warning (AddPrimitive): CylinderComponent_3 (Owner: AwesomeTestMap.TheWorld:PersistentLevel.TestEnemy_0) Outside World.
    [0023.79] Log: Octree Warning (AddPrimitive): CylinderComponent_4 (Owner: AwesomeTestMap.TheWorld:PersistentLevel.TestEnemy_1) Outside World.
    [0025.53] Log: Octree Warning (AddPrimitive): CylinderComponent_5 (Owner: AwesomeTestMap.TheWorld:PersistentLevel.TestEnemy_2) Outside World.
    [0026.38] Log: Octree Warning (AddPrimitive): CylinderComponent_6 (Owner: AwesomeTestMap.TheWorld:PersistentLevel.TestEnemy_3) Outside World.
    Here's the code that deals with the testenemy.

    Code:
    class TestEnemy extends AwesomeActor
    	placeable;
    
    var Pawn Enemy;
    
    var float BumpDamage;
    var float MovementSpeed;
    var float AttackDistance;
    
    var bool bFreeze;
    
    function Tick(float Deltatime)
    {
    	local AwesomePlayerController PC;
    	local Vector NewLocation;
    
    	if(Enemy == none)
    	{
    		foreach LocalPlayerControllers(class'AwesomePlayerController', PC)
    		{
    			if(PC.pawn != none)
    			{
    				Enemy = PC.Pawn;
    			}
    		}
    	}
    	else if(!bFreeze)
    		{
    			if(VSize(Location - Enemy.Location) < AttackDistance)
    			{
    				Enemy.Bump(self, CollisionComponent, vect(0, 0, 0));
    			}
    			else
    			{
    				NewLocation = Location;
    				NewLocation += (Enemy.Location - Location) * MovementSpeed * DeltaTime;
    				SetLocation(NewLocation);
    			}
    		}
    }
    
    function Freeze()
    {
    	bfreeze = true;
    }
    
    DefaultProperties
    {
    	BumpDamage=5.0
    	MovementSpeed=256.0
    	AttackDistance=96.0
    
    	bBlockActors=true
    	bCollideActors=true
    
    	begin object Class=DynamicLightEnvironmentComponent Name=MyLightEnvironment
    		bEnabled=true
    	end object
    	components.add(MyLightEnvironment)
    
    	begin object class=StaticMeshComponent Name=PickupMesh
    		StaticMesh=StaticMesh'UN_SimpleMeshes.TexPropCube_Dup'
    		Materials(0)=Material'EditorMaterials.WidgetMaterial_X'
    		LightEnvironment=MyLightEnvironment
    		Scale3D=(x=0.25,y=0.25,Z=0.5)
    	end object
    	Components.add(PickupMesh)
    
    	begin object class=CylinderComponent Name=CollisionCylinder
    		CollisionRadius=32.0
    		CollisionHeight=64.0
    		BlockNonZeroExtent=true
    		BlockZeroExtent=true
    		BlockActors=true
    		CollideActors=true
    	end object
    	CollisionComponent=CollisionCylinder
    	Components.Add(CollisionCylinder)
    }
    Then this is the enemy spawner.

    Code:
    class AwesomeEnemySpawner extends AwesomeActor
    	placeable;
    
    var TestEnemy MySpawnedEnemy;
    
    function SpawnEnemy()
    {
    	if(MySpawnedEnemy == none)
    		MySpawnedEnemy = spawn(class'TestEnemy', self,, Location);
    }
    
    function EnemyDied()
    {
    	SpawnEnemy();
    }
    
    function FreezeEnemy()
    {
    	if(MySpawnedEnemy != none)
    		MySpawnedEnemy.freeze();
    }
    
    function bool CanSpawnEnemy()
    {
    	return MySpawnedEnemy == none;
    }
    
    DefaultProperties
    {
    	begin object Class=SpriteComponent Name=Sprite
    		Sprite=Texture2D'EditorResources.S_NavP'
    		HiddenGame=true
    	end object
    	Components.Add(Sprite)
    }
    I'm not sure if anything else could effect the test enemy. Gameinfo just calls the enemyspawner after checking if there is a spawner that isn't right next to the pawn, I think the distance was 1300. But that code works properly. I just get that error whenever the test enemy is supposed to spawn.

  2. #2
    Boomshot
    Join Date
    Aug 2011
    Posts
    2,920

    Default

    In TestEnemy you have the line...

    Code:
    NewLocation += (Enemy.Location - Location) * MovementSpeed * DeltaTime;
    ... which should be...

    Code:
    NewLocation += Normal(Enemy.Location - Location) * MovementSpeed * DeltaTime;

  3. #3
    MSgt. Shooter Person
    Join Date
    Jul 2011
    Posts
    35

    Default

    Thanks. Sometimes when I get to copying the code I skip a bit. Could you tell me what normal does though? Why does leaving that out cause the error?

  4. #4

    Default

    Normal will Normalize the vector, making X, Y and Z have a value between -1 and 1. So your TestEnemy will only move a bit at a time


 

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.