Frictional Games Forum (read-only)
[SOLVED]Now I see you... Oh wait a minute, I don't - 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 (https://www.frictionalgames.com/forum/forum-35.html)
+--- Thread: [SOLVED]Now I see you... Oh wait a minute, I don't (/thread-6383.html)



[SOLVED]Now I see you... Oh wait a minute, I don't - rmdashrf - 01-26-2011

Hi

I was wondering how to make an object "disappear" or alter its state when the Player is not looking at it. I'm assuming there is some sort of callback?

(For an example, watch 0:36 to 1:00 in this video: http://www.youtube.com/watch?v=4bZOvt72S5g&feature=related)

(Also the "paint the man cut the lines" level where there are bodies that hang in the hallway but disappear after you look away).

Thanks in advance!


RE: Now I see you... Oh wait a minute, I don't - Tanshaydar - 01-26-2011

Code:
/**
* Callback syntax: MyFunc(string &in entity, int alState) state: 1=looking, -1=not looking
*/
void  SetEntityPlayerLookAtCallback(string& asName, string& asCallback, bool abRemoveWhenLookedAt);

void  SetEntityActive(string& asName, bool abActive);



RE: Now I see you... Oh wait a minute, I don't - Tottel - 01-26-2011

I'm guessing

void SetEntityActive(string& asName, bool abActive);

In combination with an area which is triggered when you have looked at it, and then look away again.

I haven't done this before, but you can probably use this then:

void SetEntityPlayerLookAtCallback(string& asName, string& asCallback, bool abRemoveWhenLookedAt);

I haven't used this Callback before; what I would do is make a new variable that adds one when you look at the object. When you look away, it adds another one.
Make a check if the variable is 2. If so, SetEntityActive();

But there's probably a simpler method with that callback. Feel free to experiment. Smile


RE: [SOLVED]Now I see you... Oh wait a minute, I don't - Frontcannon - 01-26-2011

I've done exactly this with the skull scene in my custom story, here is the script (sorry, it's a bit complicated):

Code:
//those are in OnStart()
AddEntityCollideCallback("Player", "CollideSkullRoom", "SkullRoom", true, -1);
AddEntityCollideCallback("Player", "CollideLookAt", "ActivateLookAt", true, 1);

void SkullRoom(string &in asParent, string &in asChild, int alState)
{
    for(int i=2;i<30;i++) SetEntityActive("human_skull_"+i, false);
    for(int i=31;i<50;i++) SetEntityActive("human_skull_"+i, true);
    SetEntityActive("key_tomb_1", true);
    
    AddTimer("skulldrop", 0.2f, "SkullDropSound");
    AddTimer("removeskulldrop", 1.5f, "RemoveSkull");
    
    PlaySoundAtEntity("stomp", "scare_wall_stomp.snt", "prisoner_cage_1", 0.0f, false);
    
    AddDebugMessage("MAGIC!", false);
}

//SkullRoomActive is an area with a LookAtCallback which calls SkullRoomLookAt
void ActivateLookAt(string &in asParent, string &in asChild, int alState)
{
    SetEntityActive("SkullRoomActive", true);
}

void SkullRoomLookAt(string &in entity, int alState)
{
    if(alState == -1)
    {
        SetEntityActive("CollideSkullRoom", true);
        AddDebugMessage("keep not looking..", false);
    }
    else
    {
        SetEntityActive("CollideSkullRoom", false);
        AddDebugMessage("don't look!", false);
    }
}