Make ball actor bounce off wall at 45 degrees and slow to a stop.

ZombiebrainsZombiebrains www.zombiebrains.co.ukMember, PRO Posts: 296

Hi folks...

I'm working on my next app and would like some help.

I have wall actors making a golf type course and need help getting the ball to bounce off at 45 degrees and slow down.

Whats the best and quickest method for this.

I got the ball bouncing with a collide attribute but it tends to go where it likes?

Any help would be appreciated.

Thanks all

It takes a Zombie to know a Zombie!!!

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    45 degrees or 90 degrees?

    I would assume 90 degrees... this thread should help: http://forums.gamesalad.com/discussion/56905/calculating-angled-bounce-math. I posted a link to a page that describes the process and someone else posted a calculation that was working for them.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • ZombiebrainsZombiebrains www.zombiebrains.co.ukMember, PRO Posts: 296

    Sorry yeah that would be 90 degrees wouldn't it....yeah 90 degrees

    It takes a Zombie to know a Zombie!!!

  • ZombiebrainsZombiebrains www.zombiebrains.co.ukMember, PRO Posts: 296

    @tatiang said:
    45 degrees or 90 degrees?

    I would assume 90 degrees... this thread should help: http://forums.gamesalad.com/discussion/56905/calculating-angled-bounce-math. I posted a link to a page that describes the process and someone else posted a calculation that was working for them.

    Thanks Tatiang! :)

    It takes a Zombie to know a Zombie!!!

  • SocksSocks London, UK.Member Posts: 12,822
    edited April 2014

    @Zombiebrains said:
    Hi folks...

    I'm working on my next app and would like some help.

    I have wall actors making a golf type course and need help getting the ball to bounce off at 45 degrees and slow down.

    Whats the best and quickest method for this.

    I got the ball bouncing with a collide attribute but it tends to go where it likes?

    Any help would be appreciated.

    Thanks all

    You're probably already aware of this, but balls don't bounce off walls at 90° (or 45°/45°), the angle of incidence is reflected about the normal to produce the angle of reflection - so the only ball to bounce at 90° is one coming in at 90°, a ball coming in at 20° is going to bounce out at 160° . . . one coming in at 85° is going to bounce out at 95° . . . and so on.

  • ZombiebrainsZombiebrains www.zombiebrains.co.ukMember, PRO Posts: 296

    @Socks said:

    >
    How do I get that physics into GS? is it simple?

    It takes a Zombie to know a Zombie!!!

  • SocksSocks London, UK.Member Posts: 12,822

    @Zombiebrains said:
    How do I get that physics into GS? is it simple?

    I expect so, not given it any thought . . . . let me press some buttons.

    On the subject of a ball bouncing at 90°/45° this is what it would look like:

    image

    Whereas in reality it should be doing this:

    image

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    @Socks Eh. Brain not working. 45, 90, oops.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • ZombiebrainsZombiebrains www.zombiebrains.co.ukMember, PRO Posts: 296

    @Socks said:
    image

    Hi Socks

    Thats great and that fits in with the advice Tatiang said earlier but how would I get this working...is it difficult as I cannot seem to find any templates using this method

    It takes a Zombie to know a Zombie!!!

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

    Why not let GameSalad do the work? It has a physics engine that handles this stuff. Actors bounces off angled walls just fine! (Don't they?)

  • SocksSocks London, UK.Member Posts: 12,822
    edited April 2014

    @RThurman said:
    Why not let GameSalad do the work? It has a physics engine that handles this stuff. Actors bounces off angled walls just fine! (Don't they?)

    That was my thought too ! Although you need to turn the friction on your colliding bodies off - if you don't the friction eventually adds up to your angles not reflecting perfectly . . . but of course in the real world this is what would happen, so friction off = mathematical precision, friction on = the angle of reflection doesn't match the angle on incidence exactly but better represents real world bounces.

    . . . . . . . .

    Demo file:

    Link: https://www.mediafire.com/?kn0onns9t9rpooq

    Click anywhere on the screen to aim the ball.

  • SocksSocks London, UK.Member Posts: 12,822

    @tatiang said:
    Socks Eh. Brain not working. 45, 90, oops.

    You may well be suffering from FlappyBirdism, if left untreated it can turn nasty, best get yourself to a vet.

  • ZombiebrainsZombiebrains www.zombiebrains.co.ukMember, PRO Posts: 296

    @Socks said:
    Click anywhere on the screen to aim the ball.

    That's Awesome Socks!

    Just what the doctor ordered...!!!

    Thanks a million! :)

    It takes a Zombie to know a Zombie!!!

  • ZombiebrainsZombiebrains www.zombiebrains.co.ukMember, PRO Posts: 296

    Whats the best was to add a power shot thing...like hold down the mouse button to power up the speed of the ball?

    Would that take a lot of time to do?

    It takes a Zombie to know a Zombie!!!

  • SocksSocks London, UK.Member Posts: 12,822

    @Zombiebrains said:
    Whats the best was to add a power shot thing...like hold down the mouse button to power up the speed of the ball?

    Would that take a lot of time to do?

    Hold to increase power:

    Link: https://www.mediafire.com/?ty9e91mim4q56n7

  • ZombiebrainsZombiebrains www.zombiebrains.co.ukMember, PRO Posts: 296

    Thank you so much Socks....that's superb!

    Thank yo for talking the time to show me..:)

    It takes a Zombie to know a Zombie!!!

  • SocksSocks London, UK.Member Posts: 12,822

    @Zombiebrains said:
    Thank yo for talking the time to show me..:)

    No problem, I think a power bar would be better than the colour change I threw in.

  • ZombiebrainsZombiebrains www.zombiebrains.co.ukMember, PRO Posts: 296

    It's a start though and thanks agains for your input....your a star!

    It takes a Zombie to know a Zombie!!!

Sign In or Register to comment.