Facebook Twitter YouTube Frictional Games | Forum | Newsletter | Dev Blog | Dev Wiki | Support | Gametee


Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[SOLVED]Now I see you... Oh wait a minute, I don't
Author Message
rmdashrf Offline
Junior Member

Posts: 7
Joined: Jan 2011
Reputation: 0
Post: #1
[SOLVED]Now I see you... Oh wait a minute, I don't

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=4bZOvt72S...re=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!
(This post was last modified: 01-26-2011 01:22 AM by rmdashrf.)
01-26-2011 12:43 AM
Find all posts by this user Quote this message in a reply
Tanshaydar Offline
From Beyond

Posts: 3,085
Joined: Mar 2009
Reputation: 67
Post: #2
RE: Now I see you... Oh wait a minute, I don't

/**
* 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);

01-26-2011 12:57 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Tottel Offline
Senior Member

Posts: 307
Joined: Nov 2010
Reputation: 0
Post: #3
RE: Now I see you... Oh wait a minute, I don't

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
01-26-2011 12:59 AM
Find all posts by this user Quote this message in a reply
Frontcannon Offline
Senior Member

Posts: 538
Joined: Jul 2010
Reputation: 2
Post: #4
RE: [SOLVED]Now I see you... Oh wait a minute, I don't

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

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


╔═════════════════╗
☺ Smoke weed everyday ☺
╚═════════════════╝
01-26-2011 12:43 PM
Find all posts by this user Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)