I have just implemented the pinball movement for a bouncing coin/treasure/collectible item in my game. I wanted the gems to have multiple colors so I made separate sprites for each of them. But I'm having this problem where they stop in midair after bouncing once or twice instead of bouncing on the ground until the decelerate enough to stop.
Is using a qualifier for an effect like this a bad idea? Somehow I think that might be the reason for this issue, though it really shouldn't be.
Turns out using a qualifier kind of bugged the code for some wierd reason, not sure why. But the workaround was to create the bounce code for each coin, and it worked!
No idea why a qualifier caused it to bug out like that though. Any ideas?
Here's the solution.
Swap the conditions. (I changed the min speed to 20 since it looks better)
The reason this works is because of the way Fusion decides what objects to select.
Conditions that have black text apply to all objects of that type even if only one matches the condition.
Conditions in green or red apply to only objects that match that specific condition.
In order to make this work we need to make the collision condition last so it'll only apply to those objects colliding.
This is called object scope.
Here's what happens
Speed of "Object" < 20
-The text is black so any action called will apply to all objects of that type
Collides with the Background
-The text is red so it'll only apply to objects of that type that satisfy the condition. We narrowed it down.
If you put them in the other order the second condition will override the first and select all objects of that type again.
Originally Posted by -UrbanMonk- Here's the solution.
Swap the conditions. (I changed the min speed to 20 since it looks better)
The reason this works is because of the way Fusion decides what objects to select.
Conditions that have black text apply to all objects of that type even if only one matches the condition.
Conditions in green or red apply to only objects that match that specific condition.
In order to make this work we need to make the collision condition last so it'll only apply to those objects colliding.
This is called object scope.
Here's what happens
Speed of "Object" < 20
-The text is black so any action called will apply to all objects of that type
Collides with the Background
-The text is red so it'll only apply to objects of that type that satisfy the condition. We narrowed it down.
If you put them in the other order the second condition will override the first and select all objects of that type again.
Wow, thanks UrbanMonk! It worked.
Now, there is another strange issue I noticed, when the player is moving while the gems are bouncing, they just seem to keep on bouncing forever unless the player stands still. Any reason why this is happening? Maybe it has something to do with the pinball movement?
Ok so I found a hacky solution. It seems there is a bug in the pinball movement that causes it to behave differently when the screen is scrolling. Now personally I don't use the built-in movements because of this very reason, but instead of writing a custom movement for you I just patched this one. IT's not a perfect fix, but it's better than nothing.
Also I wanted to correct something I said earlier about object scope. Turns out I was wrong about the color thing. The red/green conditions doesn't mean that they'll select one object of a particular type after all, they actually mean that if they come first in a condition list that they'll be processed as soon as an event occurs ahead of all the other events in the event list.
Anyway it is true that some events apply to objects individually rather than all objects of a particular type. For example doing comparisons to object's Alterable Variables will apply only to the objects that meet the criteria.
With all that said here's what I did to minimize the bounce issue. IT doesn't remove it completely, but it's better than it was: