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


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Activate Entity
Cgturner Offline
Junior Member

Posts: 28
Threads: 7
Joined: Sep 2010
Reputation: 0
#1
Activate Entity

I have a scenario where a dog's head is created and falls out of a window, then, once you interact with the dog's head, the door behind you slams closed and is locked. I also have it set so that if you interact with the door after it is locked, an enemy is spawned behind you, but the enemy never spawns. The game runs fine, all except for the enemy spawning.

Here is my code:

void OnStart ()
{
    SetEntityPlayerInteractCallback("cellar_wood01_1", "InteractGrunt", true);
}

void InteractGrunt (string &in asEntity)
{
    if (GetSwingDoorLocked("cellar_wood01_1") == true)
        ActivateGrunt();
}

void ActivateGrunt()
{
    SetEntityActive("servant_grunt_1", true);
}

I have the correct callback function attached to the door in the level editor, but the function still doesn't work.
10-18-2010, 05:28 AM
Find
jens Offline
Frictional Games

Posts: 4,093
Threads: 199
Joined: Apr 2006
Reputation: 202
#2
RE: Activate Entity

Have you tried adding a message or sound to InteractGrunt to see if it triggers when you touch the door?

You should not do SetEntityPlayerInteractCallback("cellar_wood01_1", "InteractGrunt", true); AND add InteractGrunt to the door in the level editor. You only do one of them, either use the SetEntityPlayerInteractCallback function or enter a name in the level editor for the interact callback.

The callback is autoremove, so it will be removed on the first interaction, you are sure it is not possible to interact with the door earlier so that when you interact to trigger the grunt the door does not have a callback as its been removed?
10-18-2010, 05:42 AM
Website Find
Cgturner Offline
Junior Member

Posts: 28
Threads: 7
Joined: Sep 2010
Reputation: 0
#3
RE: Activate Entity

(10-18-2010, 05:42 AM)jens Wrote: Have you tried adding a message or sound to InteractGrunt to see if it triggers when you touch the door?

You should not do SetEntityPlayerInteractCallback("cellar_wood01_1", "InteractGrunt", true); AND add InteractGrunt to the door in the level editor. You only do one of them, either use the SetEntityPlayerInteractCallback function or enter a name in the level editor for the interact callback.

The callback is autoremove, so it will be removed on the first interaction, you are sure it is not possible to interact with the door earlier so that when you interact to trigger the grunt the door does not have a callback as its been removed?

I've added a debug message to the callback function, and the message is displayed, but the enemy still isn't spawned. I set autoremove off, but still nothing.
10-18-2010, 05:48 PM
Find
jens Offline
Frictional Games

Posts: 4,093
Threads: 199
Joined: Apr 2006
Reputation: 202
#4
RE: Activate Entity

Then you add a debug to if (GetSwingDoorLocked("cellar_wood01_1") == true) to see if it actually is true.


And check the name of the enemy and make sure he is inactive in the level editor.
10-18-2010, 08:02 PM
Website Find
Cgturner Offline
Junior Member

Posts: 28
Threads: 7
Joined: Sep 2010
Reputation: 0
#5
RE: Activate Entity

Alright, I set a debug message to if(GetSwingDoorLocked("cellar_wood01_1") == true). The message is displayed when interacting with the door, even if the door isn't locked. I don't understand what would be causing the debug message to display if the door itself isn't locked, and I also don't understand what's keeping the enemy from spawning. I've tried using a script area instead, and that works, but I'd really like to be able to make this work with the entity itself.

EDIT: It works perfectly with a collide callback, but then the player would have to run into the door, interacting wouldn't do anything in this case.
10-19-2010, 05:33 AM
Find




Users browsing this thread: 1 Guest(s)