Make ball actor bounce off wall at 45 degrees and slow to a stop.
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
Comments
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.
Sorry yeah that would be 90 degrees wouldn't it....yeah 90 degrees
Thanks Tatiang!
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.
>
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:
Whereas in reality it should be doing this:
@Socks Eh. Brain not working. 45, 90, oops.
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
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.
You may well be suffering from FlappyBirdism, if left untreated it can turn nasty, best get yourself to a vet.
That's Awesome Socks!
Just what the doctor ordered...!!!
Thanks a million!
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
Thank you so much Socks....that's superb!
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.
It's a start though and thanks agains for your input....your a star!