Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Making an event activate another event

I have this crate/box that I want to move on a switch to activate it, could I do anything? Or events just can't activate other events?

I don't want the player to step on it and activate it btw, just the crate
 
So let me get this straight...you want the player to flip a switch and then the crate will move? Is that the kind of switch you're talking about?

If so, when the layer flips the switch, just set a Move Route event in the switch's events that tells the crate to move.
 
Well no

There's a ground switch event that can 'open a door' if the crate event is pushed on top of it

I want to know how can I make the door open when I move the crate on top of that ground switch, if it's possible
 
Ohh, got it.

This is possible to solve, but the solution can be annoying depending on how in depth you go with it, such as if you include the player being able to step on the switch as well.

Basically what you will have to do is set a variable for the crate's X and Y coordinates every time the player pushes the crate. When the X and Y coordinates are the same as the coordinates for the switch, then make the switch animate to be pressed in and open the door.

For example, let's assume that the switch is at the coordinates (10,8). Then our event window for the crate would look something like:

Code:
 

(Activate upon Action Button)

 

-Move away from hero

-Variable 001: Crate X = (crate event's X coordinate)

-Variable 002: Crate Y = (crate event's Y coordinate)

If Crate X == 10

    If Crate Y == 8

       (animate the switch to press in)

       (open the door)

    end if

end if

 

Note that this is fairly easy to do when there is one crate and one switch, however if you start adding more switches and more crates, then things get ugly because you will have to implement all possible combinations of crates and switches. Therefore, I'd really only recommend to have one crate and one switch per map.

Hopefully that helps.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top