Frictional Games Forum (read-only)

Full Version: Spawning entity where player is looking
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is there any way to do something like this:

Players walks throught area1, it spawns a grunt, when grunt walks to area2 an entity is spawned in front of the player. (Where player is looking, right in front of him.)
im not sure if this will work but: add a line "AddEntityCollideCallback("Player", "blar", "bla", true, 1);"
you can try to change Player to the name of the Entity. yo can also use "StartPlayerLookAt" to make it look at an entity.
(06-02-2012, 08:03 PM)lolboy9797 Wrote: [ -> ]im not sure if this will work but: add a line "AddEntityCollideCallback("Player", "blar", "bla", true, 1);"
you can try to change Player to the name of the Entity. yo can also use "StartPlayerLookAt" to make it look at an entity.
But I want to spawn the entity where the player is facing, not spawn entity and make player look at it.

Also I know how to do the AddEntityCollideCallback things, the problem is how I spawn entity where player is facing.
I could be wrong, but I don't think it is possible to spawn the grunt at where the player is looking. You can only have a grunt spawn where you want him to WHEN the player looks at that location.

You should urge the player to look at a location by having some sort of light or escape route, and then spawn the grunt there. Try to predict where the player will look and be.
Oh ok, But what about I set few areas and when you look at one it spawns entity there and the other areas set innactive or are removed? Any tips for doing that?

Ofcourse at the direction player is looking at and like 1 meter away spawning entity would be best. :/
(06-03-2012, 02:24 AM)Topsu Wrote: [ -> ]Oh ok, But what about I set few areas and when you look at one it spawns entity there and the other areas set innactive or are removed? Any tips for doing that?

Ofcourse at the direction player is looking at and like 1 meter away spawning entity would be best. :/
Try to have the "Area1" about 1 meter in front of the Player, when he looks at it, by predicting movements and doing distractions, etc.
Code:
void OnEnter()
{
SetEntityPlayerLookAtCallback("Area1", "SpawnEntity", true);
}

void SpawnEntity(string &in asEntity, int alState)
{
SetEntityActive("servant_grunt1",true);
SetEntityActive("area2",false);
SetEntityActive("area3",false);
}