TestMobjLocation
Jump to navigation
Jump to search
Note: This feature is for ZScript only. |
bool TestMobjLocation()
Usage
Checks if the Actor is clipping into actors or geometry at its current position. This can be used to check if a newly spawned actor can actually fit in the place where it was spawned.
Note, this function returns true only when the actor's position is overlapping geometry or other actors; for collision see CheckMove.
Return value
- bool - returns
true
if the calling actor has enough space. If the actor is clipping into other actors or geometry, returnsfalse
.
Examples
This function will spawn a specified monster 64 units in front of the calling actor and make it friendly on spawn. If there's no space for the spawned monster, it'll be destroyed and a message will be printed:
void A_SpawnFriend(class<Actor> cls)
{
actor mo = Spawn(cls, pos + (RotateVector((64, 0), angle), 0)); //spawn specified actor class 64 units in front of the calling actor
if (mo)
{
if (!mo.TestMobjLocation())
{
Console.Printf("Not enough space for a %s", mo.GetTag());
mo.Destroy();
}
else
{
mo.bFriendly = true;
}
}
}
See also RotateVector.