How do I make picking up key open a door?

AdventureIslands

  • *
  • Posts: 728
I've been trying to figure this out myself for a while and I've tried to read the forums, but I just don't get how I can make door open when the player character picks up the key.

I downloaded the Counter behaviour from StencylForge and tried to follow this thread: http://community.stencyl.com/index.php/topic,1396.msg11066.html#msg11066 , but after some behavior editing I just can't figure this out.

What do I need to do so I can make this scenario:

"Player touches Key actor, this turns Locked Door actor into Open Door actor"

« Last Edit: June 24, 2011, 09:27:42 am by AdventureIslands »

Greg

  • *
  • Posts: 1260
It's tough to say based on the screenshots, but one problem could be the fact that you're spawning a new Actor but not killing the closed door Actor.  Could the open one be spawning behind the closed one, such that you can't see it?

Also, can you verify (using print blocks) that you're getting to the part that spawns the new Actor?  You're checking if "increments" = 1, what is increments?

AdventureIslands

  • *
  • Posts: 728
Err, I tried to make it after reading though this: http://community.stencyl.com/index.php/topic,1396.msg11066.html#msg11066 but I don't get it and I am not getting it to work.

I just want that someone could help me and explain how to get this to work in layman's terms.

I tried to put kill actor there, but it doesn't let me choose what actor I want to kill. Maybe because it's scene behavior?

Hectate

  • *
  • Posts: 4645
There could be a simpler way. I made a door that opened when the player grabs the key. It was as simple as changing the door's animation (to an "open" view) when the key was picked up.

Once that's done, you can just check to see if the door is currently open (either by a boolean specifically for it, or just by checking the current animation) and don't let anything happen if the player tries to enter the door if it's not.
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

dragonfrog

  • Posts: 39
I had a difficult time doing something very similar.  In your behavior that you attach to the scene, there are two problems.
1)  (Greg already said this) You need to add a block above the one that creates open door to kill the locked door.
2)  You're having "CounterAttribute" increase, but wanting "increments" to equal the done amount.  Under "Attrributes", create a block for "increments" and put in place of "CounterAttribute" and you should be all set.

See attached picture as a model.

Hectate

  • *
  • Posts: 4645
Just my 2 cents, but I still think using one door actor and telling it to play an "Open" or "Closed" animation (or "Locked", if you prefer) is the better solution.

But if it works, it works!  :)
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.