Newbie physics questions

IgnisIgnis Member Posts: 72
edited November -1 in Working with GS (Mac)
Hello all,
I'd like to introduce myself to the Gamesalad forums; I've been "lurking" for some time, contemplating when I should actually attempt making a game or two, and finally I took the leap! My first impression is that this is FUN... just simply enjoyable, even with the minor frustrations which just provide a new challenge to overcome.

So, if some veterans will entertain some rookie Gamesalad questions, I'd appreciate it. Setting the stage: right now I'm just tinkering around with the engine and some physics, getting my feet wet in the most sensible method (trial and error). My first experiment is basically a twist on the "pachinko" idea, but imagine that the "pegs" are moveable objects... the user can select them individually and modify them (shift them left and right, etc.). This part I was able to accomplish in a short time, but I have encountered the following issues...

1) How can I ensure that the "pegs" NEVER move when contacted by a ball, under any circumstances? The most obvious solution would be to check the boolean "movable" to "no" for the peg actor... BUT if I do that, they are permanently locked in place in all states, which means that the user cannot move them. My first thought was to set the density of the peg to a something like 1000000 and the density of the ball to 0.0000001, but oddly, the balls still nudge the pegs very very slightly. Shouldn't an incredibly dense object be effectively unmoved by a featherweight object? What am I doing wrong here?

2) How would I make two actors basically "stick" to each other? Using the same example above, let's assume that some pegs are "sticky pegs" and when the ball contacts them, I want the ball to virtually lock onto the peg and never move. Almost like a super-powered electromagnet. :) I have accomplished the sensory aspect (easy enough), but for some reason I cannot get the ball to outright stop. My first idea was to simply apply a "0" to all velocity attributes on the ball (angular, linear X and linear Y)... this works somewhat, but the ball very very slowly slips from the peg, which seems odd because there is no gravity applied to the scene. Likewise, I placed the ball's downward acceleration in the "otherwise" portion of the sticky-sense rule, i.e. "when ball is NOT in contact with sticky peg, accelerate downward". Still, to no avail, the ball eventually slips from the peg. :( My second idea was to change the ball's "Physics > Movable" to "0" when it contacts a sticky peg. I figured, this would just lock the ball in place permanently! But Gamesalad doesn't like that idea or doesn't allow it... for some reason, it doesn't seem to allow that boolean change in a rule (or perhaps I'm going about it all wrong and I need to create another actor attribute or something?)

Anyway, any help is appreciated! This forum seems to be a great support group for GS developers, sharing ideas and solutions to tricky hurdles. I look forward to learning more and getting a rough idea out there for critique.

-Brent

Comments

  • KamazarKamazar Member Posts: 287
    Vwelcome to ze lair of GameSalad! Your problems are actually really easy to fix (in theory, at least, most of my advice is never tested, so this is just a disclaimer incase I get you even more frustrated and make myself look like a dumbass). Anyways...

    You can have the pegs be set to be moveable unless they collide or overlap with the ball (the physics attribute ARE changeable via rules). I don't know what the balls are doing, so I'm not sure if a timer or some other type of rule would be more appropriate at making your pegs movable again AFTER the collision with a ball, but if you give me more details, I can help you out.

    Again, getting the balls to stick, just set the "movable" boolean variable to false when it collides with that peg. Should work (keyword, should, I got lucky being promoted to "sous-chef", lol)
  • JGary321JGary321 Member Posts: 1,246
    Kamazar said:
    Vwelcome to ze lair of GameSalad! Your problems are actually really easy to fix (in theory, at least, most of my advice is never tested, so this is just a disclaimer incase I get you even more frustrated and make myself look like a dumbass). Anyways...

    This holds true for all advice we give =)
  • IgnisIgnis Member Posts: 72
    Thanks for the tips Kamazar... unfortunately, there still seems to be some error in communication between the ball and the pegs. I know when this is resolved, I'm going to kick myself because it's probably something obvious like one boolean setting not checked...

    But, anyway, regarding the non-moveable pegs (when touched by a ball), I placed a rule on the peg actor, stating that its Physics > Moveable boolean should be "false" when it collides with a ball (I also tried "0" and "no", thinking maybe it was a matter of semantics and only "false" would work). The ball still knocks the peg around slightly, and to confirm this, I ramped up the ball's density to 100000 and then it really sends that pesky peg flying across the screen!

    After that, I tried adding a rule to the peg, such that it would be non-moveable (default) *unless* it's selected by the user (as I mentioned before, the user can click a peg to select it, then manipulate it):
    (Rule: "If peg's custom attribute 'user-selected' is 'true', change Physics > Moveable to 'true'")
    Oddly, the peg became totally locked in place, even when selected. It's almost like GS really doesn't want that Moveable boolean to be changed by a rule, but I'm sure that it's some error on my part, not GS...

    As for the sticky-pegs, same thing... GS doesn't like my approach to changing the Moveable boolean to "false" upon collision of those actors. One workaround I considered was a destroy-respawn, in this case, destroy the original ball and then instantly replace it with a new ball of the same image, but a different actor that is set to non-moveable by default. That seems a bit redundant however, and hopefully I can find a more direct way.

    Thanks again for the advice; if you have any more ideas, please let me know...
  • fuzzeemicfuzzeemic Member Posts: 47
    I'm fairly certain you can't change the moveable flag at runtime. I asked the same question...
    I tried the same as you and never got it to work. I worked around it.
  • IgnisIgnis Member Posts: 72
    fuzzeemic said:
    I'm fairly certain you can't change the moveable flag at runtime. I asked the same question...
    I tried the same as you and never got it to work. I worked around it.

    I appreciate it fuzzeemic; based on my limited trials thus far, this seems to be the case since that change attribute is not responding in two separate cases.

    May I ask what your workaround was?
  • firemaplegamesfiremaplegames Member Posts: 3,211
    You can NOT change any Physics attributes at run time ( you can change them, but it has no effect)

    You also cannot change Graphics attributes at runtime either: Visible, Tiled, etc.

    A quick way to make the ball not move the pegs is to set the density of the pegs really high, like 10,000 and set the density of the balls to be really small, like 0.1. That should behave for the most part. It might wiggle here and there, but should be pretty stable.

    The other way is to have two separate peg actors. The normal one has Movable set to False. When you click it to change its position, first destroy it, and spawn the other peg in its place. The second peg will have Movable set to true. You can drag that one around. When you release that peg, destroy it and replace it with the non-movable one.

    Do the same thing for the ball. have two versions, a movable one and a non-movable one.
  • IgnisIgnis Member Posts: 72
    Thank you FMG, it's nice to have a definitive answer on this (no changing physics!). Now I can tinker with your suggested workarounds or consider other options as well.
  • jweaver911jweaver911 Member Posts: 439
    Man...These guys are good. Now if only i could get them to give me a few pointers on my problem in the other thread ;)
Sign In or Register to comment.