To avoid a lot of spawns that are expensive i made a bow that reuses always the same arrow, setting it to hidden/not hidden and setting the location to the muzzleflashsocket every time the archer fires.
The problem is that sometimes the arrow doesn't appear. It works for a lot of shots, then it doesn't work for some (5/10) other and then it works again.
I made some tests and the result are:
- the arrow isn't none, it exists, i have and if statement that recreates the arrow if it is destroyed in some way
- the arrow isn't hidden
- the arrow coordinates seems to be corrects, i log the coordinates and the visible shots have same coordinates than the issued shots if the pawn doesn't move
i tried to set the location to the pawn insted of the muzzle flash socket to see if there could be problem with the position of the socket but the behavior is the same.
This is the code that simulate the spawn of the arrow:
Edit:Code:local vector StartTrace, RealStartLoc, AimDir; // This is where we would start an instant trace. (what CalcWeaponFire uses) StartTrace = Instigator.GetWeaponStartTraceLocation(); AimDir = Vector(GetAdjustedAim( StartTrace )); RealStartLoc = GetPhysicalFireStartLoc(AimDir); if(Arrow == none) { `log("SPAWN NEW ARROW"); Arrow = Spawn(class'MyProjectile', Self,, RealStartLoc); } Arrow.SetLocation(RealStartLoc); //SIMULATE SPAWN Arrow.SetHidden(FALSE); //reset the collision of the arrow Arrow.SetCollision( true, false ); //input movement if( Arrow != None ) { Arrow.Init( AimDir ); }
if(Arrow == none && bDeleteMe == TRUE)
{
`log("SPAWN NEW ARROW");
Arrow = Spawn(class'MyProjectile', Self,, RealStartLoc);
}
seams to solve the problem. I need to understand who set the deletion of the arrow and override that function.



Reply With Quote

Bookmarks