Magnet system, please I need help!

GuaveMediaGuaveMedia Member, PRO Posts: 1,262
edited August 2012 in Working with GS (Mac)
Hey,

I wanna have a magnet function in my game. So when the magnet is collected, the coins get constrained to the main character and because of that also collected of corse. My coins physic moveable is now turned off because of memory usage reduce. What I tried was:

when magnet collides with main character
set magnetON? to true

in the nuts prototype I had:

when magnet is true
change physics moveable on (otherwise false)
constrain self.distance to magnitude(playerX,playerY)

when magnet is true
self distance < 768 (iPad)
move to playerX, playerY ..relative to scene

The problem I have is that the nuts do not move at all and when the magnet is turned off, they are anywhere^^...
I know how to solve the position problem but not the other issue, I tried a few things but nothing seems to work at all.

Thx, really appreciate any help!

Alex

Comments

  • simo103simo103 Member, PRO Posts: 1,331
    edited August 2012
    hey Alex .. you can't change the physics moveable during gameplay .. so you will need it on and then try a magnitude measurement to turn the magnet to true or whatever rule you want to trigger the movement.

    I haven't tried something like this for a while but in the old days actors would seem to move a bit even when they shouldn't ... so if that happens another option would to be to keep the Moveable OFF actor and then switch it out with an identical actor with moveable ON at the time the magnets effect should take place.
  • GuaveMediaGuaveMedia Member, PRO Posts: 1,262
    Mhmm when having around 35 coin actors that would cause much more memory when having 20 levels.

    Can you explain the second option more detailed. Can't follow it right now,
    Thx
  • GuaveMediaGuaveMedia Member, PRO Posts: 1,262
    edited August 2012
    Got it almost to work, I just have one issue left. I checked "run to completion" on in my move to behavior because when the effect is turned off the coin's position would be the last position on his way to the main character and not the starting one.

    When the player fails, my scene doesn't reset with the behavior, I worked out my own system but when this happens, the "run to completion" is still active even though the effect is turned off. How can I get this to work?

    Thx


    ( EDIT )

    I got it to work :) If anyone needs a magnet function like that just contact me, I will do a template for it then.

    Alex
Sign In or Register to comment.