Gravity question (how to make actor bounce)

Hello!

I just got GameSalad today and so far I'm having much fun with it.

I've read almost all of the manual, actually I'm at the part with scene attributes, where I read about the gravity attribute. I thought it would be cool to make my player jump, a bit like in Doodle Jump, you know?

I tried changing the value, but all it does is making my background image slide away (where the speed on how quickly it slides away depends on the value I set, the higher it is, the faster it disappears).

So this is nothing like what I would have hoped for. But obviously it's more work than that…

I've tried doing some research on here and searching various terms such as "gravity", "bouncing" or "jumping" but I couldn't find what I need, also all stuff I read is way too advanced for me. I also searched on the Youtube channel

Could anyone be so kind to explain me or link me to a tutorial perhaps, on how to make the player / actor bounce? :)

Thanks guys, would greatly appreciate it!


Ozzy

Comments

  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273
    Hi Ozzy - I personally never use the Scene gravity option. I use the Accelerate behavior in all the actors that I want to be affected by gravity. I would recommend heading over to www.gshelper.com - we have tons of free video tutorials on getting started with GameSalad. Also, the GameSaladCookBook YouTube channel also has great tutorials.

    Hope this helps.
  • SocksSocks London, UK.Member Posts: 12,822
    . . . all it does is making my background image slide away (where the speed on how quickly it slides away depends on the value I set, the higher it is, the faster it disappears).

    You need to switch 'movable' off on the actor you don't want to be effected by gravity.

    Most people don't bother with gravity and use 'accelerate' (downwards) instead.
  • Ozzy25Ozzy25 Member Posts: 15
    Hey, thanks.

    I'll make sure to check out those tutorials ;)

    I tried using the accelerate but now comes the second problem already. My player basically gets outside of the window / image. For every move (left, right, up, down) I have set an attribute self.Position X and self.Position Y (with > width or < width or > height or < height) so the player never gets outside the picture. This doesn't seem to apply when I use accelerate.

    I'd need the same function inside the accelerate box I guess, but the accelerate "rule" box doesn't have such a thing, I can't add any thing of this kind there.

    How would I do that? And even if I managed to make it not go outside the screen, I'm pretty sure my player would fall down on the "floor" and stay "sticked" there, no?

    Thanks for the help so far :)
  • SocksSocks London, UK.Member Posts: 12,822
    edited December 2012
    . . . I'd need the same function inside the accelerate box I guess, but the accelerate "rule" box doesn't have such a thing, I can't add any thing of this kind there.
    You need to place the accelerate behaviour inside a rule.
    I'm pretty sure my player would fall down on the "floor" and stay "sticked" there, no?
    Only if you want it to stick on the floor.

    Depending on the style of the game, I'd do what most people do and stick 4 walls on the edges of your playing area to prevent your actor from leaving the scene.
  • Ozzy25Ozzy25 Member Posts: 15
    edited December 2012
    Alright it seems to work now, although I two other little problems.

    First, my character bounces always higher and higher. That's when the bounciness is set to 1. If I set it to 0,9 or even closer to 1, then it stops bouncing after a short time. How do I make it bounce the same height all the time?

    And the second problem is that when I turn left or right, the movement seems to "cut" the bounce. For the controls I have this kind of stuff:

    I created a rule with: Actor receives event — key — right key board — is: down
    Move attribute: direction = 0,0° (this equals to going to the right) relative to: actor; move type: additive (also tried stacked, see no difference)
    Speed: 200

    How can I fix that? :)

    Thanks BTW!
  • Ozzy25Ozzy25 Member Posts: 15
    edited December 2012
    By the way: I saw some people having a similar question and they were told to create an actor at the top, so that the "player" (or whatever) doesn't go to high and "bounces" back to the ground. This would be useless if you have a change in ground height (for example if you have stairs or such a thing).

    So if anyone knows a tip on how to keep the bouncing constant, I'd really appreciate it :)

    And sorry for the double-post people!

    Ozzy


    Edit // I fixed the constant bounce problem. I set the bounciness to 0.95, it's good now! For the other problem I'll create another thread to not get it mixed up :)
  • SocksSocks London, UK.Member Posts: 12,822
    edited December 2012
    First, my character bounces always higher and higher. That's when the bounciness is set to 1. If I set it to 0,9 or even closer to 1, then it stops bouncing after a short time. How do I make it bounce the same height all the time?
    You could simply use 'sin' - that's my answer to everything, lol. : )

    Here, I've made you a quick endless bounce that is very efficient (only uses a single constrain rule) and always bounces to the same height . . . .

    http://www.mediafire.com/?vn14ad8dn3m25m3
  • Ozzy25Ozzy25 Member Posts: 15
    edited December 2012
    Just tested it, and very nice in fact :)

    I tried implementing it in my project, and I'm having a few problems.

    For example when I go hard left or hard right, then it like "sets back" the character to a few millimetres. I'm not sure if you get what I'm saying, it's like if it would lag haha :)

    Also, could you explain a bit what all these things do? :P

    I found out that by changed 384 in there >>>> 200*sin(( self.Time *200)%180)+384
    … that it would change where the actor basically lands. Could this make some problems if I have different floors later, on a different height?

    Also I liked how you changed the width every time it bounces on the floor, that gives a really nice effect :) I tried "implementing" this as well, but somehow the width is always stuck :/ I can't get to play the sound either?

    Sorry… I'm really a newb so I still don't exactly know how to use everything. But I really love that example, very much appreciated by the way :)

    Edit // I think I at least solved the width problem, was because I didn't see the "otherwise" I guess!
  • SocksSocks London, UK.Member Posts: 12,822
    For example when I go hard left or hard right, then it like "sets back" the character to a few millimetres. I'm not sure if you get what I'm saying, it's like if it would lag haha :)
    Try this: http://www.mediafire.com/?w2v4n482sh16x9d
    Also, could you explain a bit what all these things do? :P
    Take a look at the explanation of 'sin' in this thread: (post with the image)

    http://forums.gamesalad.com/discussion/52030/better-solution-for-an-up-to-down-platform#latest
    I found out that by changed 384 in there >>>> 200*sin(( self.Time *200)%180)+384… that it would change where the actor basically lands.
    AAA*sin(( self.Time *BBB)%180)+CCC

    AAA = height of bounce
    BBB = speed of bounce
    CCC = the 'floor' (where it lands).
    Could this make some problems if I have different floors later, on a different height?
    Yeah ! Lol. : ) I just thought it might give you some new ideas about how you might go about doing this, you could probably get it to work even with platforms of differing heights (although I've not thought about it so am not 100% sure).
    Also I liked how you changed the width every time it bounces on the floor, that gives a really nice effect :)
    I bet Disney/Pixar are worried about the competition.

    ; P
    I tried "implementing" this as well, but somehow the width is always stuck :/ I can't get to play the sound either?
    Both should be pretty simple to implement - on any kind of movement system.
    Sorry… I'm really a newb so I still don't exactly know how to use everything. But I really love that example, very much appreciated by the way :)
    It gets a lot clearer the more you use the software.
  • Ozzy25Ozzy25 Member Posts: 15
    edited December 2012
    Yeah I saw that file in the other thread! Tried it too but still "lagging". The constrain attribute is definitely the culprit, the "handling" from the new file works nicely with the accelerate behaviour, but as soon as I replace it with the constrain attribute, I get this lag (although I don't get it in your version, it just works fine with the red ball).

    Thanks for the AAA, BBB, CCC explanation :P That's exactly the kind of explanation I need haha!

    But I was wondering here:
    200*sin(( self.Time *200)%180)+384
    I removed the +384 this time, and now it was just like the very bottom was the floor, but how come it doesn't collide with my floor? My floor is at ⅓ of the height of the screen. I also made sure the collide behaviours come before the constraint attribute one.

    This would basically get rid of the future height / level problem, because I'd always land where my floor actor is :)
  • SocksSocks London, UK.Member Posts: 12,822
    I removed the +384 this time, and now it was just like the very bottom was the floor, but how come it doesn't collide with my floor?
    I don't know any thing about your project, so I have no clue !?

    How's that for an answer : )
  • Ozzy25Ozzy25 Member Posts: 15
    edited December 2012
    Haha yes good answer.

    Actually it was in the other thread where I had posted a screenshot of all settings, I thought it might help?

    image

    It's all that's been done in the game (plus some wall actors, and a floor).

    Still no clue? :P

    EDIT // I think the problem is the Accelerate behaviour inside both rules for the left and right move command. Since I replaced the other Accelerate, (that was at the very beginning), I thought I may have to replace these here by the Constrain Attribute behaviour as well? I tried but if I do that it won't move at all.
Sign In or Register to comment.