Frictional Games Forum (read-only)
Spawning entity where player is looking - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: Spawning entity where player is looking (/thread-15791.html)



Spawning entity where player is looking - Topsu - 06-02-2012

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.)


RE: Spawning entity where player is looking - lolboy9797 - 06-02-2012

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.


RE: Spawning entity where player is looking - Topsu - 06-02-2012

(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.


RE: Spawning entity where player is looking - Theforgot3n1 - 06-02-2012

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.


RE: Spawning entity where player is looking - Topsu - 06-03-2012

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. :/


RE: Spawning entity where player is looking - Theforgot3n1 - 06-03-2012

(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);
}