Planet like gravity

markfirmanmarkfirman Member, BASIC Posts: 18
edited August 2015 in Working with GS (PC)

Hi all, I was wondering if someone could point me in the right direction. To put things into context - I'll explain the basics of my app.

I have a canvas, whereby the user can "place" atoms (such as hydrogen). When the user selects the hydrogen tool, and touches the screen a new actor called 'Hydrogen' is spawned at touch X and Y locations.

This hydrogen actor is programmed to essentially vibrate and wonder around the canvas until it interacts with another atom.

What I want to achieve is; when two atoms collide, one is destroyed whilst the other adjusts its size to reflect two atoms merging into one. I cannot seem to achieve this..

All hydrogen atoms spawned derive from the same actor..

Thanks in advance,
Mark.

EDITED FOR CLARITY

Comments

  • markfirmanmarkfirman Member, BASIC Posts: 18

    I should have clarified; the atoms colliding are the same actor and so how could I tell one to destroy itself but keep one alive?

  • SLOCM3ZSLOCM3Z Member Posts: 797

    You could have two SEPARATE atoms that act the same in every way except one is to be destroyed and the other to grow.

  • markfirmanmarkfirman Member, BASIC Posts: 18
    edited August 2015

    I'm afraid that wouldn't work. As what if the two atoms that collide are not separate actors and as such both are destroyed, or both get bigger. I cannot determine which atoms will or won't collide.

  • SocksSocks London, UK.Member Posts: 12,822
    edited August 2015

    @markfirman said:
    . . . . My problem occurs when creating a gravity field for the atoms. I know I can use Magnitude and test whether the atom is within a certain distance and if so to accelerate towards certain co-ordinates. However, what I want to achieve is; when two atoms collide, one is destroyed whilst the other adjusts its size to reflect two atoms merging into one. I cannot seem to achieve this . . . .

    This seems like a non sequitur to me ? The question seems to be 'how do I create a gravity field - because I need two atoms to collide, leaving only one' ?

    The two parts of the question don't seem related in any way ?

  • markfirmanmarkfirman Member, BASIC Posts: 18

    Ok - I may have not explained the question very well. Ignore the first gravity bit - I have managed to get this working. The second part is still relevant though. When I have multiple actors on-screen that are essentially duplicates of each other - when they collide, how can I make one grow and the other to be destroyed.

  • SocksSocks London, UK.Member Posts: 12,822
    edited August 2015

    @markfirman said:
    Ok - I may have not explained the question very well. Ignore the first gravity bit - I have managed to get this working. The second part is still relevant though. When I have multiple actors on-screen that are essentially duplicates of each other - when they collide, how can I make one grow and the other to be destroyed.

    You just need to employ any system that generates a switch, so when the atoms collide the switch is thrown, this is what generates the merged atom, so it doesn't matter if the switch is turned on once, twice or multiple times, it always returns a single universal result . . . does that make sense, hold on I'll make a very quick demo . . .

  • SocksSocks London, UK.Member Posts: 12,822
    edited August 2015

    Example attached

  • markfirmanmarkfirman Member, BASIC Posts: 18

    Thank-you very much for your help - from this I'll be able to continue with development. Thanks again.

  • Thunder_ChildThunder_Child Member Posts: 2,343

    @markfirman said:
    I should have clarified; the atoms colliding are the same actor and so how could I tell one to destroy itself but keep one alive?

    Two hydrogen atoms colliding would create helium so wouldn't you destroy both and spawn a new stable particle? :wink:

  • ArmellineArmelline Member, PRO Posts: 5,365
    edited August 2015

    I bet if you get it just right you can achieve the same effect by destroying/spawning after a random interval, leveraging GameSalad's code cycles. (Probably insane to try, though :D)

Sign In or Register to comment.