Multi-Resolution Game Development With GameBuilder Studio Check it out!
NEW Version 0.9.7 has arrived! New Blazing Fast Particle Engine & More Game Actions. Check it out
How to trigger a magnetic 'coin' effect upon collision
  • I am stumped and could really you some help,

    If the main character in a game collides with an object which is to then trigger a bunch of other objects on screen like 'coins' to all go directly to the main character like a magnet for a short period of time, like 3-5 seconds?

    Does anyone know this trick? I would really like to know thank you!
  • 3 Comments sorted by
  • @BenFromOregon Here is a very simple way to do this. When the hero collides with the power up object to auto collect coins set a global property called whatever you want ("AutoCollectCoins") to 1. Then for the coins that need to be auto collected and animated to the heros' position, add a Rules component on the coin entity that checks for the "AutoCollectCoins" property being set to 1 and use the distance(Hero.Spatial.x, Hero.Spatial.y, Coin.Spatial.x, Coin.Spatial.y) (it uses the Pythagorean theorm) helper method in an expression to determine if the coin is within a certain threshold/distance of the hero position. If it is then stop the coin from automatically moving across the screen and trigger an Interpolate action to animate the coin from its current position to the hero's current position. Then when the coin collides with the hero it can be automatically destroyed and points can be increased.

    After a certain amount of time you can have that "AutoCollectCoins" property turned off by setting it back to 0.

    Does this make sense?
  • Wow thank you Lavon, it worked like a charm. 

    For understanding what all the helper methods are there for in more depth, would I look to action script  material related to games via book/online? Thanks again!
  • @BenFromOregon great, glad you were able to get it working! You can find some explanations on the different helper methods available in an expression in our documentation section

    We try to keep that updated with the latest information.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion