Pull Coins Into Player like a Magnet

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • Hi folks. Got a question that's been stumping me for a few days now and hope someone can give me some pointers without melting my brain. I'm currently doing a run and jump type of game similar to a subway surfer game, but obviously in 2D. I'm looking to achieve the effect where when you pick up a certain type of power up, all coins around you pull towards the player for a set amount of time, similar to a magnet. I've tried playing with Fusions built in magnet which didn't give me the effect I was looking for.

    I'm sure anyone who's played subway surfers knows this effect that no matter where you are on the screen, any coins the player misses will gently follow them no matter where they are and keep following you until they collide with the player. Naturally, being a run and jump kind of game, the player is constantly moving so I have no controls over movement other than just jumping.

    I've searched high and low through the forums using any keyword I could possibly think of and haven't found a single thing covering this, so maybe I was looking wrong. I saw this effect being used in a 2d platformer game off google play the other day as well but it said it was made with Unity so I would think it could be done in Fusion as well.

  • Ok, let's break this down.

    What does a magnet do?
    A magnet attracts or repels objects.

    What does attract mean?
    In this case, attract means to be pulled towards. In terms of game logic, If Object A attracts Object B, Object B moves towards Object A. Phrased another way, the position of Object B slowly moves towards Object A. Phrased yet another way the difference between the Object A's position and Object's B position approaches 0.

    So how do I implement an attract mechanic?

    Effectively you would slowly adjust Object B's X position towards Object's A's X position. Same thing for their Y positions.


    In a similar note, I have a magnet attraction and repulsion example on my Please login to see this link.. If you intend to use Clickteam Fusion physics, this example just might be applicable to you.

    If you are not using Clickteam Fusion physics or wish to custom build the mechanic, you could follow the above logic to implement an attraction mechanism. Once you have the basics down, you should be able to implement different attraction strengths and expand the mechanic.

    Let me know if you have any further inquiries.

    • Please login to see this link.

    Please login to see this picture.

    Edited once, last by Yves (March 12, 2022 at 7:54 AM).

  • Awesome! That example was exactly the effect I was going for. Thanks so much for the quick example too. I'm a better learner with visuals so seeing the idea in action really helps me understand it better. Honestly, until just now, I never even heard of the advanced direction object so I went ahead and installed it to see the example and will really dig in deeper to the event editor once I get more time, but just running it and playing with it for a minute tells me this is exactly what I'm trying to achieve.

    Thank you as well Prodigy for your input. I will definitely investigate the reference guide when I get a little more time. :)

    EDIT - I forgot to ask but is there any reference somewhere that explains what all these options are in the advanced direction object, and how to properly implement them? I just thought maybe it might help me better use this later down the road.

  • Right click the object, choose properties, in the left-hand sidebar the properties appear, click the tab with the yellow-speech-bubble, click the help button in this tab :D

    Please login to see this link.
    Please login to see this link.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!