Frictional Games Forum (read-only)

Full Version: Activate Entity
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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:

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