PDA

View Full Version : Issue with location of a spawned item



daimaku
07-28-2011, 08:58 PM
hi i'm trying to spawn an item when my enemy die, the spawn is working right, but the issue is that i'm using the last location of the enemy to spawn the item, but when the item is spawned the item seems to be geting the location of the player and updating it, i have tried many things but the result is the same, here is a video too show the problem

http://www.youtube.com/watch?v=dqoFJPvGeuM

and here is the code that i'm using to spawn the item



function bool Died(Controller Killer, class<DamageType> damageType, vector HitLocation)
{
local vector SpawnLoc;
local class<actor> NewClass;

SpawnLoc=Location;
SpawnLoc.Z=20;
NewClass = class<actor>( DynamicLoadObject( ***ame.FA_Key, class'Class' ) );
if( NewClass!=None )
{
Spawn( NewClass,,,SpawnLoc );
}
return super.Died(Killer, damageType, HitLocation);
}


this code is in my enemy custom pawn class and is extending from UTPawn, any idea on why the spawn items is acting this way ?

thanks in advance for all the help.

cRichards
07-28-2011, 10:57 PM
It looks like your script is doing exactly what you coded it to do, literally. In your world, that's where 20 units on the Z axis is.

Object
07-29-2011, 12:11 AM
why are you using dynamic load object for this? the spawn command will work without it.

and richards is right about the loc, instead of spawnloc.z=20 it should be spawnloc.z-=20 or spawnloc.z+=20

daimaku
07-29-2011, 12:30 AM
it's not doing what i'm coding, this function is in the enemy's pawn class, but the spwan is near the player not the enemy, the key must be near the bot that is diying.

i'm using Spawnloc.z=20 because i want the item to be spawned close to the floor.

i'm using the dynamic load object because the items will be stored in an array and i'm implementing the spawn of items from an array at the same time.

any idea on why the location value is taking the value closest to the player and not near the enemy ?

Wormbo
07-29-2011, 12:34 AM
"Floor" isn't necessarily at 0. Locations are map-global, so if your floor is at -256 stuff will spawn in mid-air. Floor at 256 spawns stuff in the ground, if at all.

daimaku
07-29-2011, 12:11 PM
yes i know that Wormbo, i'm trying to put all my "floor" at 0 to use that code, but it will change in the future, i'm using it for testing purposes, the real problem is the behavior of the spawned object linked to the player location

cRichards
07-29-2011, 01:08 PM
exec function FacePalm();

daimaku
07-29-2011, 02:49 PM
i have solved the issue, the problem was the scale of the spawned item, i have used a scale too big to see if the item was spawned in the level, but when i change it for a reasonable scale the item was spawned at the correct place and doesn't move anymore when the player is moving, thanks to all for your advices.