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:
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.
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: