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
"Float" Chest open
Endrek03 Offline
Junior Member

Posts: 8
Threads: 3
Joined: Dec 2010
Reputation: 0
"Float" Chest open

Hey all,
I got my lever solution somewhat figured out -- It works for the most part, I'm sure I can tweak a few things.
So, after the player completes the Lever Puzzle, I want the character to look at a chest, which will then open slowly revealing the player has pulled the levers correctly.
To do this, I have used:
void ChestLookAt(string &in asTimer)
    AddPropImpulse("chest_kitchen_1", 0, 0.24, 0, "");
    AddTimer("FloatTime", 0.01, "ChestLookAt");

This adds the perfect propulsion to make the chest open somewhat slowly. Truth be told I would love to have it open even slower, but I have yet to figure out the exact math behind it. You'd think a lesser impulse with a more frequent timer would do the trick. . . but it seems to suck at getting over that initial opening harrumph. If anyone could help with this, that'd be great, but it's only a side thing; I'm okay with how much it opens now.

That being said, as you can see the Timer basically calls upon itself in 0.01 "impulses" to fake the chest being opened slowly at that specific speed. The problem is, in my limited knowledge of coding, I don't know how to basically cancel out that timer. The chest keeps opening, and if you, the player, try to close it it just keeps opening and opening.
I tried adding a secondary timer that after 1 second (The time it takes roughly for the chest to open), it would remove itself. I figured even if the script ran 1,000 times in 1 second it would still cancel itself just as fast. Of course, this is me at 4:30 AM thinking this, so I could be off. . .

. . .

. . . anyways.

Point being is is there an easier way to do this or something I'm missing? I'd like the chest to stop opening once it has opened, and that seems to require a way to cancel a script that continuously calls on itself.
(This post was last modified: 12-19-2010, 01:35 PM by Endrek03.)
12-19-2010, 01:35 PM
Frontcannon Offline
Senior Member

Posts: 538
Threads: 10
Joined: Jul 2010
Reputation: 2
RE: "Float" Chest open

I had the same problem two with a timer loop and AddPropForce, but I forgot how I solved it, but the thread isn't that old, you'll find it on here..

☺ Smoke weed everyday ☺
12-19-2010, 10:23 PM

Users browsing this thread: 1 Guest(s)