Hello there.
Ok so, here's my usual premise:
1) If there is one thing I'm really bad at is programming, so I'm sorry for asking weird questions.
2) Also, I've recently decided to fully work on Construct 3, and now that I've more time I want to get more experience. This is also why I want to give my theories about how *I*, a very unexperienced programmer, would have solved it.
3) Yes, I've followed the first tutorials and I've also managed to start making a 4 directional game with sprites and all.
4) I know what a global variable is. I'm saying this for the next point.
5) Before to open this topic, I've actually searched on Internet and in the search section. The question is pretty common and I've found many answers, but I must say, sometimes I could understand only a half of it or are outdated. Many of these answers talk about using global variables to store the the coordinates.
-----
The title says it all. I have multiple rooms of which the character has to move onto. The player can go back if they want to, so it's important to keep the last position in that layout, and possibly the last direction of the character (if I'm moving down from layout 2 to layout 1, the character should face down in layout 1). For many it's pretty easy. For me, I'm just at level 1.
---- THEORY
I'm a Halo fan, and since Halo 3 there is this mode called Forge, which allows you to make your own Halo maps. In forge you have the access to make teleports. There are three type of teleports:
1) Only sender
2) Only receiver
3) Bidirectional (both sender and receiver)
For example, with a sender and a receiver, if the player has a collision with the sender, they will reach the receiver, from point A to point B. The player cannot go back, tough.
With two bidirectional teleporters, you can go to point A to B and vice versa.
Another important aspect of the teleports is to give a "channel" frequence.
If the sender is set to "alpha" and the receiver to "beta", basically you cannot teleport to the receiver, because they don't have the same channel.
If they have both the channel "alpha", however, you can move to the receiver.
My point is more or less the same. What I thought is pretty much this:
1) Make bidirectional teleport (or in this case an invisible wall to collide with the character)
2) In the bidirectional teleport, introduce a variable called "channel".
3) If the teleport1 from layout1 has channel = 1, and teleport2 from layout2 has channel = 1, and the player has a collision with teleport1, the player moves to teleport2. And vice versa.
Does it make sense?
I think there are two problems, however: What happens if the player teleports exactly to the point where the other teleport is? Wouldn't the character be stucked between the two teleports?
And let's not forget of the direction.
About these two factors, I'm not aware exactly of what to do. Plus the fact I'm now sure how to use the global variable to save the player's coordinates.
This is pretty much what I would have done, logic-wise. But I'm a beginner, so I don't know, I guess there are better alternatives.
The idea of using "go to next/previous layout" seems risky to me, and I actually want to be free to eventually change the channel number and consequently the point between these two layouts.
Also, I'm not sure of using "Go to layout" because I should do the same event over and over for each teleport, it doesn't sound efficient(?). You tell me what's best, I'm all ears.
Thank you for reading.