Teleports

Get help using Construct 2

Post » Mon Apr 29, 2013 1:46 pm

Hi, pls how to made tekeports in grid base game?
I have object teleport1 and teleport2 and when player is collison with teleport 1 -> set player position to teleport 2. And when player is collision with teleport2 -> set player position to teleport1 . I tryed to control with variable, but id does not work....

pls helpe me

thx for replies
B
24
S
4
G
2
Posts: 318
Reputation: 2,446

Post » Mon Apr 29, 2013 1:57 pm

It sounds like the events are running a loop, since reappearing at the destination triggers the collision event, sending the player back to the first teleporter, and on and on it goes...

I'd suggest adding a short timer to the player to prevent this from happening: reset the timer whenever the player teleports, and only activate the teleporters if the timer has elapsed a few seconds.GeometriX2013-04-29 13:57:13
B
56
S
15
G
10
Posts: 910
Reputation: 11,942

Post » Mon Apr 29, 2013 2:11 pm

Add sprites around your teleport. If the player touches the sprite the teleport will be active again. If the player uses the teleport it will be disabled until he touches the sprite around the teleport. This will stop your loop.
B
31
S
10
G
2
Posts: 310
Reputation: 5,426

Post » Mon Apr 29, 2013 8:58 pm

Yes i tryed it, but no effect, because i need after teleportation that teleport active only when i go away and i return again.... not after few seconds...
B
24
S
4
G
2
Posts: 318
Reputation: 2,446

Post » Mon Apr 29, 2013 9:49 pm

use the overlapping function(inverted) and keep the teleporter disabled until the sprite is not overlapping the object by having a global variable so that on the colision of a teleporter add 1 to the variable and keep the teleporter disabled until the variable > 2 and set the variable to 0 when the sprite is no longer overlapping the teleporter.

sprite on collision with teleporter
-variable=variable+1

if variable >2
-teleport disabled

if sprite overlapping(x) teleporter
-variable=0sosensible2013-04-29 21:52:51
B
39
S
10
G
7
Posts: 514
Reputation: 9,426

Post » Mon Apr 29, 2013 10:16 pm

I would take it a step further and put an instance variable on the teleport - for cases where more than one is desired. For that matter, I would even put an instance variable on the player called "teleporting" and set it to 1 when teleported. When a teleport detects collision with a player that is flagged as "in teleport", it sets its own instance variable to 1, resets the player's, then waits for the player to move off to reset itself (as mentioned above).
Jack of all trades, and master of some.
B
29
S
9
G
7
Posts: 174
Reputation: 7,601

Post » Mon Apr 29, 2013 10:45 pm

that would make it easier for people who do not have object families
B
39
S
10
G
7
Posts: 514
Reputation: 9,426

Post » Tue Apr 30, 2013 12:01 pm

Thx i made little error in my code.... -,- Now it is OK :P
B
24
S
4
G
2
Posts: 318
Reputation: 2,446

Post » Tue May 17, 2016 2:25 pm

Might make a tutorial
B
5
S
1
Posts: 2
Reputation: 350


Return to How do I....?

Who is online

Users browsing this forum: CavalierBubble, Evanetot and 25 guests