Hi, I am trying to make stations with multiple ‘coinboxes’ in a platform game.
I have seen the tutorial on youtube (Tutorial) and it works fine the first option with de tween but just for the the first set of coinboxes, but when I put another set later in the game it changes the position, like this:
This is how the first coinbox station looks and is how the others should look:
This can happen for the variable CoinboxPos?
How could I replicate the first set of coinbox so that this does not happen?
I hope you can help me.
Not sure of the exact reason for the issue (there are many possibilities). So we’ll have to knock them off, one at a time.
Firstly, in your second scene, is there a coinbox hidden behind the scenery? The first action (set CoinBoxPos) doesn’t specify which CoinBox to use, and suggests there may be another one not in line with the 4 on the screen. You can check this by clicking this icon :
and confirming there are only 4 CoinBox instances in the list.
If that’s not the problem, then another candidate are the tweens. They’re being added every processing frame that the conditions are satisfied. You should put a trigger once in their conditions (events 3 & 4), or do a check that the tween isn’t already playing.
Thanks for the suggestions.
This is what I did first:
I tried adding trigger to events 3 & 4 but with both triggers the tween did not work:
I tried adding a trigger only in one event as seen here, but the same thing happened that I mentioned at the beginning, the position of the coinbox is not maintained.
When i keep the for each and add a trigger once the tween works but not the position of the coinbox.
I checked if there were any other Coinboxes besides the 4 but no, there just 4.
I also tried using the inverted condition but the problem remained.
Any idea how check that twwen is not playing?
Ok. Is the second scene a new one, or are you using an external layout?
I’m not clear what you mean by this. Which condition did you invert?
Also, a trigger once in a Repeat does not act the way you would expect or hope. Here’s a link to a thread regarding it, with a work-around.
The boxes can be continually bumped because there’s are no conditions stop it. In the tutorial you linked to in the first post, the check is made that the box’s animation is 0, before adding the tween and changing the animation to 1. The second time round the animation check will return false, and it won’t create the tween.
In your case, use an instance variable (say called “hasBeenBumped”), and check it’s false (as well as the checking the player/box collision) before creating the positional tween and setting the instance variable “hasBeenBumped” to true.
Either check the tween has finished playing, or check the tween exists and invert the “Tween is playing” condition: