Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

10 years ago by Asim

I'm wondering how a push-button entity could be designed using Impact. A push-button that opens a door when the player walks over it. And closes the door after X seconds after he walks off of it.

The solution I've been able to think of is:
1. Place a trigger entity (Platform) on top of the platform tile. Link it to Door entity and two PlatformOff entites (described below).
2. Place two trigger entities (PlatformOff) 1 tile away from Platform on either side. Set these triggers as disabled. Link it to the Platform and Door entities.
3. When the Platform entity is triggered, it is itself disabled and the PlatformOff entities are enabled.
4. When the PlatformOff entities are triggered, they are themselves disabled and the Platform entity is re-enabled.
5. When the Door entity is triggered by Platform, it opens. When it is triggered by PlatformOff, it closes after X seconds.

The problem with this solution is that it is plain ugly. I'll have to place 3 entites and link them together for every push-button I need to create. Is there a more elegant solution, preferably using a single entity?

10 years ago by Joncom

Here's one approach...

- Give names to your doors.
- Add a "push button" entity to your level.
- In Weltmeister, define for it a property called "doors".
- This property should contain the names of the doors the button should open.
- While player is standing over this entity, tell doors to "stay open for x seconds".
- This way time will only start to run out after the player steps off the button.

10 years ago by drhayes

Joncom's got it. You can resolve the names of the door entities in your trigger's ready method using ig.game.getEntityByName so they point to the actual entities.

Use the check method on the trigger entity to see if it's touching the player. Be sure to set the type and checkAgainst properties on your player and trigger appropriately.

10 years ago by Asim

an interesting approach i must say.. :) its certainly what i hadnt thought of.. i ended up modifying this approach to suit my unique needs (which i accidentally left out of my initial post =/ ).. but thanks for giving me a different perspective.. here's what i did:

- in the check() method, set Flag to true.
- in the update() method, compare Flag to OldFlag. If they are different it means the player has just stepped on or off. Tell doors appropriately to open or close. And copy Flag to OldFlag.

this allows me to know the exact instant where the player steps off and i can run some use this event to run some animation (like pushbutton animating back to unpressed position)..

thanks joncom and drhayes..
Page 1 of 1
« first « previous next › last »