How do I fix this event ?

Get help using Construct 2

Post » Tue Feb 10, 2015 10:21 am

So i am making a layout where inorder to access the 2nd side of the map you need to go through a portal and press Space on released.

Now i used the same coding for the other portal so its like this Portal A ----> Portal B with space release and then Portal B---->Portal A with space release.

Apparently these event are looping on space release. I even rename the sprite created two different sprite and created two different animation frame to have the condition to check.... IT still looping what gives ?

Another thing i need to point out is that yes i can go Portal A to portal B but apparently the game thinks to do Portal B to Portal B.

And yes i did test with two different button press and it work fine. My question is why is it not working with just space release for both ? even if the condition are different. Is it a bug ?
B
51
S
24
G
6
Posts: 391
Reputation: 7,820

Post » Tue Feb 10, 2015 11:16 am

Here's how I would do it:

On space release
Run once while true
-is overlapping portalA
+set position to portalB
-is overlapping portalB
+set position to portalA
B
25
S
6
G
6
Posts: 262
Reputation: 3,690

Post » Tue Feb 10, 2015 11:17 am

Your code runs all at once in order from top to bottom. If you're on A and you hit space release to go to B, you will go to B, but since the code is still running, you already let go of space once, but the code still sees it, so it says "Oh now you're on B so let's put you on A".

I'm not very technical with my words but at least I try to put it in laymans terms lol
B
25
S
6
G
6
Posts: 262
Reputation: 3,690

Post » Wed Feb 11, 2015 1:00 am

Eeerrrr I cannot do the once while true ? says that I cant have space bar as release ? that doesn't make any sense
B
51
S
24
G
6
Posts: 391
Reputation: 7,820

Post » Wed Feb 11, 2015 1:05 am

"Trigger once while true" and the on key release conditions are both triggers -- indicated by the green arrow -- and you can only have one trigger per event. This is also true of subevents to events with a trigger.
Moderator
B
113
S
41
G
20
Posts: 1,586
Reputation: 19,096

Post » Wed Feb 11, 2015 1:33 am

ok i solved it ... by adding in two Lever ....To go this far is pretty weird. Never the less it made my game look better lol
B
51
S
24
G
6
Posts: 391
Reputation: 7,820

Post » Wed Feb 11, 2015 1:40 am

Oh I was going to suggest this. Where you have a instance variable that holds what to Teleport to. So then you have to code it once and it would look at the instance to which teleport it suppose to go to. **EDIT Fixed it wasn't necessary for the variable

TeleportNew.png
You do not have the required permissions to view the files attached to this post.
B
23
S
4
G
2
Posts: 364
Reputation: 2,382

Post » Wed Feb 11, 2015 8:15 am

IDK, Trigger Once doesn't have a green arrow for me, and never has, so my explanation should hold up. I use it all the time.

Image
B
25
S
6
G
6
Posts: 262
Reputation: 3,690

Post » Wed Feb 11, 2015 8:57 am

Gearworkdragon wrote:So i am making a layout where inorder to access the 2nd side of the map you need to go through a portal and press Space on released.

Now i used the same coding for the other portal so its like this Portal A ----> Portal B with space release and then Portal B---->Portal A with space release.

Apparently these event are looping on space release. I even rename the sprite created two different sprite and created two different animation frame to have the condition to check.... IT still looping what gives ?

Another thing i need to point out is that yes i can go Portal A to portal B but apparently the game thinks to do Portal B to Portal B.

And yes i did test with two different button press and it work fine. My question is why is it not working with just space release for both ? even if the condition are different. Is it a bug ?

i wold say exactly what people above sayd, use 'trigger once while true' condition, and change from when released to when pressed on released its to hard for c2 to reconize sometimes better use the when pressed condition, always performs better.
Image
B
66
S
19
G
67
Posts: 1,310
Reputation: 42,077


Return to How do I....?

Who is online

Users browsing this forum: Elliott, hntr, wiredcleric and 9 guests