Frictional Games Forum (read-only)
[CLOSED] Sticky Areas Not Working - 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)
+--- Thread: [CLOSED] Sticky Areas Not Working (/thread-54421.html)



[CLOSED] Sticky Areas Not Working - theyhunger - 04-13-2018

I have "used" the cogwheel puzzle from Dungeon - Justine but changed it so you need to find all three cogwheels instead of just one for the puzzle. In-game, the first cogwheel does stick to that area but the other two does not. I don't understand why it's not working so maybe whoever is reading this can help me out. If you need information on the, here are some screenshots. Thanks!

https://imgur.com/a/UmQTA

If that doesn't work, the Sticky Area goes as follows:
MoveBody (tick)
RotateBody (tick)
PoseTime (0.5)
AttachableBodyName (elevator_cogwheel01_1_Body)
AttachFunction (StartFixMachineTimer)
AttachSound (13_attach_wheel.snt)
AttachPS (ps_hit_metal.ps)


And the code goes as follows:
void StartFixMachineTimer(string &in asEntityName, string &in asBodyName)
{
AddLocalVarInt("CogsPlaced", 1);

if(GetLocalVarInt("CogsPlaced")==3){

//Just incase setting a stick on/off after something is stuck is not a good idea.
SetEntityActive("AreaCloseToMachine", false);

AddTimer("", 1.0f, "FixMachine");

//AddDebugMessage("Make some time until cog is in place...", false);
}
}

void FixMachine(string &in asTimer)
{
PlaySoundAtEntity("run1", "L03_machine_run", "AreaMachineSound", 2.0f, false);
PlaySoundAtEntity("run2", "L03_machine_extra", "AreaMachineSound", 2.0f, false);
PlaySoundAtEntity("start", "13_ignite", "AreaMachineSound", 0.2f, false);

RotatePropToSpeed("cogwheel01", 1, 1, -1, 0, 0, false, "");
RotatePropToSpeed("cogwheel02", 1, 1, 1, 0, 0, false, "");
RotatePropToSpeed("cogwheel03", 1, 1, -1, 0, 0, false, "");

RotatePropToSpeed("elevator_machine_cog_small_5", 1, 1, 1, 0, 0, false, "");
RotatePropToSpeed("elevator_machine_cog_small_4", 1, 2, -2, 0, 0, false, "");
RotatePropToSpeed("elevator_machine_cog_small_6", 1, 1, 1, 0, 0, false, "");
RotatePropToSpeed("elevator_machine_cog_small_7", 1, 2, -2, 0, 0, false, "");

RotatePropToSpeed("elevator_machine_cog_small_2", 1, 1, 0, 0, 1, false, "");
RotatePropToSpeed("elevator_machine_cog_small_3", 1, 2, 0, 0, -2, false, "");
RotatePropToSpeed("elevator_machine_cog_small_1", 1, 1, 0, 0, 1, false, "");

RotatePropToSpeed("elevator_machine_cog_small_8", 1, 1, 1, 0, 0, false, "");
RotatePropToSpeed("elevator_machine_cog_small_9", 1, 2, -2, 0, 0, false, "");
RotatePropToSpeed("elevator_machine_cog_small_10", 1, 1, 1, 0, 0, false, "");
RotatePropToSpeed("elevator_machine_cog_small_11", 1, 2, -2, 0, 0, false, "");

RotatePropToSpeed("cogwheel_large_3", 0.6, 0.6f, 0, 0, 1, false, "");
RotatePropToSpeed("cogwheel_medium_6", 1, 1, 0, 0, -1, false, "");
RotatePropToSpeed("cogwheel_medium_7", 1, 1, 0, 0, 1, false, "");

RotatePropToSpeed("cogwheel_medium_3", 1, 1, 1, 0, 0, false, "");
RotatePropToSpeed("cogwheel_medium_4", 1, 1, -0.8, -0.2, 0, false, "");
RotatePropToSpeed("cogwheel_medium_5", 1, 1, 0.3, 0.6, 0, false, "");

RotatePropToSpeed("cogwheel_large_1", 0.6, 0.6, 0, -1, 0, false, "");
RotatePropToSpeed("cogwheel_large_2", 0.6, 0.6, 0, 1, 0, false, "");
RotatePropToSpeed("cogwheel_medium_1", 1, 1, 0, -1, 0, false, "");
RotatePropToSpeed("cogwheel_medium_2", 1, 1, 0, 1, 0, false, "");

//AddDebugMessage("Cogwheel in place, starting machine!", false);

SetLocalVarInt("MachineFixed", 1);
}

P.S. the names of the Sticky Areas are just simply StickyArea_1-3.
The only difference between the three sticky areas is that the attachable body name is slightly different. It changes from elevator_cogwheel01_1_Body to elevator_cogwheel02_1_Body and elevator_cogwheel03_1_Body.

If you need any more info or screenshots, let me know! Smile


RE: Sticky Areas Not Working - FlawlessHappiness - 04-14-2018

The only thing that determines whether an entity can attach to the area is its name.

You need to be 100% sure that the attachable body names match the names of the entities.
I would recommend renaming them to something much shorter than what they are right now, to counteract mistakes.

Try naming the cogwheels "cog_1", "cog_2" and "cog_3", and at the same time, renaming the attachable body names in the sticky areas to the appropriate name.


RE: Sticky Areas Not Working - theyhunger - 04-15-2018

(04-14-2018, 10:51 PM)FlawlessHappiness Wrote: The only thing that determines whether an entity can attach to the area is its name.

You need to be 100% sure that the attachable body names match the names of the entities.
I would recommend renaming them to something much shorter than what they are right now, to counteract mistakes.

Try naming the cogwheels "cog_1", "cog_2" and "cog_3", and at the same time, renaming the attachable body names in the sticky areas to the appropriate name.

Thanks for the suggestion but it didn't work, I renamed the cogs to cog01-02-03, same for the attachable names but to no avail. :/


RE: Sticky Areas Not Working - Romulator - 04-15-2018

Open up your cogwheel in the Model Editor. Since it is asking for a Body, make sure you are referencing the Body of the cogwheel by name in your Sticky Area properties. It will be a green box of some sort surrounding the cogwheel. Then your code should be "<Cogwheel>_<Body>".


RE: Sticky Areas Not Working - theyhunger - 04-15-2018

(04-15-2018, 10:45 AM)Romulator Wrote: Open up your cogwheel in the Model Editor. Since it is asking for a Body, make sure you are referencing the Body of the cogwheel by name in your Sticky Area properties. It will be a green box of some sort surrounding the cogwheel. Then your code should be "<Cogwheel>_<Body>".

Thanks Romulator but I've decided to just use one of the cogwheels instead of three (I can use three for the elevator). Since the first one works, I'll just use that instead (so it will be like Justine). Thanks anyways! Smile


RE: [CLOSED] Sticky Areas Not Working - Ongka - 04-16-2018

Judging from the screenshot I'd say the problem is that the other two sticky areas are deactivated (red name).
If you've already checked the entity names I don't see any other reason as to why it would work with one but not the other.


RE: [CLOSED] Sticky Areas Not Working - theyhunger - 04-17-2018

(04-16-2018, 07:31 AM)Ongka Wrote: Judging from the screenshot I'd say the problem is that the other two sticky areas are deactivated (red name).
If you've already checked the entity names I don't see any other reason as to why it would work with one but not the other.

Thanks for the suggestion but I forgot to add the fact that it will activate when you get close to the puzzle area, here's what I mean:

void CollideAreaCloseToMachine(string &in asParent, string &in asChild, int alState)
{
if(alState == 1)
SetEntityActive("CogSticky", true);

if(alState == -1)
SetEntityActive("CogSticky", false);
}