Can an actor accelerate towards multiple points at once?

jb15jb15 Member Posts: 602
edited November -1 in Working with GS (Mac)
Can an actor accelerate towards multiple points at once?

I don't want to give my idea away, but here's how I can explain it:

I want one actor (I'll call it "marble") that accelerates towards a different actor ("magnet"). I've figured out how to have it accelerate towards one magnet--at a speed determined by the distance between the two actors (so the closer it gets to the magnet, the more it accelerates--or is pulled in).

But can I have multiple "magnets"? If this doesn't make sense, please let me know. I'm a little confused myself... :)

Comments

  • ApplaudAppsApplaudApps Member Posts: 308
    It can only move toward one position at any one time! Not sure what you mean...

    ps. marbles generally aren't magnetic ;)
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    Actors can only accelerate towards a single point.

    How you update / change that point is up to you
  • old_kipperold_kipper Member Posts: 1,420
    I am sure you can do it by interpolating towards a target that is averaging the magnet positions after weighting for the distance from your marble from each magnet. Exactly how you do the weighting I am not sure but one of the guys with a good grasp of math would produce a result far better than I can think of without some time with paper and pencil....
  • jb15jb15 Member Posts: 602
    ApplaudApps said:
    ps. marbles generally aren't magnetic ;)

    haha very funny! I just want to be really careful. Anybody know who I might contact to get help with the math in my game? I think I've seen services around the forums here, but can't find any right this second.
  • GamersRejoiceGamersRejoice Member Posts: 817
    One thing I've found is that if you use change velocity as your base and add accelerate on top of that it seems to work. So you could try having the initial actor change velocity towards that one. and another actor that changes the acceleration. This might not be the desired effect you want but it's something to try.
  • MagoNicolasMagoNicolas Member, PRO Posts: 2,090
    You Can make it accelerate to the closes object, not sure If there is a way to make it accelerate to both.
  • jb15jb15 Member Posts: 602
    Thanks for the offer tshirtbooth. I'm interested--although I'm on a very limited budget, so I may need to turn down your offer.

    How can we contact one another? You're "NEED HELP WITH YOUR PROJECTS? CLICK HERE" link is broken.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Here's a test you can do (I'm almost positive it works). Create an actor. Add one accelerate behavior 90 to scene. And another accelerate in the same actor set to 0 to scene. Then try playing around with the acceleration amounts. Set both to the same amount and it will go at a 45. Set one at a higher amount and it will change the angle of motion. Then try putting one in a timer (try after .5 seconds).

    you'll see that the actor is affected by both accelerate behaviors at the same time.
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    i have a variation of this working in my new game. Once I go pubic with the game I'll post a demo if someone else has not created one already.
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    I'm working on the opposite basically making it accelerate away from multiple blasts. The issue I have is trying to figure out how to make it consistent so that if theres three blasts it acts right or if theres only two it acts right and the hardest part so far is if there it three blasts but they are not all on the same side. So far I have not had luck making anything work well enough to say i'm on to something. I have tried moding TSB's blast tutorial but I cant make it work without setting up an individual rule for each blast which still causes problems cause it needs to know how many blasts there are.

    so jon I would definitely like to see what you got when you decide to release it.
    tenrdrmer(at)yahoo.com

    ___________________________________________________________________________________
    GS BubbleBall Template HERE!!
    Stacks Level Selection Template HERE!!
    Expanding Option Menu Template HERE!!
    Tenrdrmer's Menu # 3 HERE!!
    AppSolute Entertainment on Facebook
    AppSolute Entertainment on iTunes
  • AsymptoteellAsymptoteell Member Posts: 1,362
    You could just do multiple accelerates with the direction as vector to angle(marble.x-magnetx,marble.y-.y) and do that several times with different magnets. I think you can do multiple accelerates, just not accelerate towards.
  • jb15jb15 Member Posts: 602
    Thanks for the suggestions--when I use "accelerate" vs. "accelerate towards" I have to specifiy the angle (0-360). How do I convert two X points to a 0-360?
    EDIT: Is that the "VectorToAngle(x , y) thing?
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    jb15 said:
    Thanks for the suggestions--when I use "accelerate" vs. "accelerate towards" I have to specifiy the angle (0-360). How do I convert two X points to a 0-360?
    EDIT: Is that the "VectorToAngle(x , y) thing?

    Yep.
    You want vectorToAngle(self.position.x-game.Target.x,Self.position.y-game.target.y)
  • jb15jb15 Member Posts: 602
    Thanks. I used to think that calculus didn't apply to anything... :)
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    jb15 said:
    Thanks. I used to think that calculus didn't apply to anything... :)

    Yeah I really wish I didn't sleep through or skip nearly all of my trig classes now. LOL
  • jb15jb15 Member Posts: 602
    So far I've tried using just "accelerate", just "accelerate towards" and just "change velocity." None work.

    The only way I can achieve the desired effect is to use 1 "change velocity" and 1 "accelerate towards."

    EDIT: Actually, it's not exactly the perfect effect, becuase one of the "forces" of the magnet is constant--100. I need it to be a variable--relating to the distance of the marble from the magnet (the closer the two are, the stronger the force).

    This is great for two magnets, but what about if I need more?
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    you should be able to use multiple accelerates. cause even when using an accelerate down for a gravity effect I can still do accelerates in other directions at the same time although it does act a little buggy sometimes depending on how the accelerate is triggered.
  • jb15jb15 Member Posts: 602
    Right now, it isn't triggered--it's constant--and it flies off in the opposite direction.
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    Maybe what you need to do is work out a formula for the expression editor to control the accelerate direction. You know maybe something like a bunch of vector to angles and then add up the angles and make that the accelerate direction then you just need to figure out a way to do magnitude to determine the best way to do an accelerate feed.

    ___________________________________________________________________________________
    GS BubbleBall Template HERE!!
    Stacks Level Selection Template HERE!!
    Expanding Option Menu Template HERE!!
    Tenrdrmer's Menu # 3 HERE!!
    AppSolute Entertainment on Facebook
    AppSolute Entertainment on iTunes
  • jb15jb15 Member Posts: 602
    Do I do the average VecterToAngles? The median?

    Maybe I've already gotten as much information as I can here (You've all been VERY helpful)--but if someone does know how I would do this (or have a good guess), I would really appreciate knowing their thoughts.
  • mangaroomangaroo Member Posts: 419
    I was thinking magnetic field too - someone kindly posted a link to this video:

    http://www.youtube.com/user/GameSaladCookbook/#p/search/0/_p2s61XVZ0o

    shows you how to set up distance between...once that works you can set up an velocity towards the co-ordinates of the points - set up two individual rules
  • jb15jb15 Member Posts: 602
    Thanks for the video--I actually do know how to calculate distance, my question is: What two rules should I use to have an actor be pulled in two directions?
  • jb15jb15 Member Posts: 602
    OK--here's what I'm tyring to do:

    I'm trying to make a game kind of like this one:
    http://www.unit9.com/app/warp/

    Only I want the rocks/asteroids to be affected by MULTIPLE (at least 2-3) "gravity wells" (that's what their called in W.A.R.P.) at the SAME TIME.

    At this point, I'd be happy to pay (I have a PayPal account) for someone to make a template/example/work me through the process of doing what I'm trying to do. If you offer mathematical services, please let me know. I haven't been able to contact anyone yet--broken links.
  • mangaroomangaroo Member Posts: 419
    i think tshirtbooth offers his services for this sort of thing, perhaps make a request in the marketplace?

    if you know the distances set it so that once an actor falls into that distance accelerate towards the actor...

    EDIT: ok im working on something in my own template for you
  • mangaroomangaroo Member Posts: 419
    Is this what you were thinking of? my game is usually a running platfomer - sorry i only have one template to work with!

    after an intro to show u what the rules are usually like in my game i have two warps, one approaches faster then the other (my game is a running game - but it shows the warps working) - then next is both very close and u can see the player hovers between.



    Is this sort of what u were looking for?

    Template thread: - will be busy for a bit!

    http://gamesalad.com/forums/topic.php?id=21417
Sign In or Register to comment.