Magnitude

qewrqewr Member Posts: 54
edited November -1 in Working with GS (Mac)
Magnitude is one of the few things I actually don't know how to use, say I've got an actor (magnet or something) and another actor (I don't know paper clip :) ) How do you use magnitude to pull the paperclip towards the magnet?? thx

Comments

  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    Well what you could do it. Setup 2 game attributes. Magnet.X and Magnet.Y and a self attribute in the paperclip called distance2magnet

    Now in your magnet actor add at the top

    Constrain game.Magnet.X to self.position.x
    Constrain game.Magnet.Y to self.postion.y

    Now in your paper clip

    Constrain self.distance2magnet to magnetude(self.position.x-game.Magnet.X,self.position.y-game.Magnet.Y)

    When self.distance2magent is < 100
    --Accelerate Direction vectortoangleself.position.x-game.Magnet.X,self.position.y-game.Magnet.Y)
    Speed - ((self.distance@magnet/100)x5000)

    Try that out and see how that works for you. I have not tried this at all. But the logic makes sense. It should even be setup with the accelerate to start out slow and then get faster as it gets closer to the magnet.

    Good Luck Hope it helps

    Aaron

    Edit: Apparently TSB types faster than me. Looks to be close to the same. I did leave out the real type attributes. Mine will work better if your magnet is moving.
    ___________________________________________________________________________________
    TEMPLATES AND PROJECT HELP BY TENRDRMER. CLICK HERE!!!

    AppSolute Entertainment on Facebook
    AppSolute Entertainment on iTunes
Sign In or Register to comment.