Bounce off walls
sor3ns3n
Member, PRO Posts: 28
Hi, I am new to Game salad, just wondering how to set up a ball to bounce off a wall and continue going in the exact same direction?
so if a ball hits a wall at 45degrees, it then bounces off the wall at the same angle
I want a ball to continuously bounce off the walls
Any help would be greatly appreciated
Thanks
Comments
Like this? The attached demo uses the built in physics engine to handle the bouncing.
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
@jamie_c demo looks good - you could maybe also add a rotate behavior to the ball so it never gets stuck in one place...
Ye thats what i am looking for! Your square starts off well but then ends up in 1 place haha, i just want continuous bounce
@MusicBoutique where abouts do i add the rotate behaviour?
is it in the rule section to the square
or is it in its characteristics?
Just click on the ball and drag 'rotate' from the behaviors column into it. then set it for example to 400.
Still struggling, I have added the rotate function but it still seems to end up in one positions. It starts off going at say 45 degrees, bounces a few times, and then ends up bouncing completely vertical up down up down.
attaching modified @jamie_c demo ... seems to keep moving for me. The only thing is it gradually loses speed - maybe someone else will have an idea of how to keep velocity contant.
Maybe you could play with this. Should keep going at same speed.
https://www.dropbox.com/sh/e82tpis072iwoyg/AADT5ZlFeaZSsYuBaeNjVYaOa?dl=0
This is something I want to know as well , I cant find a nice way to do it without rotating I wonder how its done
Rule. If touch walls change attribute velocity x = -1* velocity x
change attribute velocity Y=-1*velocity Y
Change frictions in actors to 0.
No rotation is needed but its pretty boring bouncing.
Not sure this is what your asking @Icebox??
@Toque No i meant the same effect you have in your demo but without rotating the actor , if i multiply the velocity by -1 it will just bounce back and forth , i meant bounce off all walls with a constant speed without rotating dont know if i made sense
https://www.dropbox.com/sh/e82tpis072iwoyg/AADT5ZlFeaZSsYuBaeNjVYaOa?dl=0
No rotation....?
Haha hard to explain things we can't do eh??? :}
Edit:deleted this comment
@Toque Oh i just saw it , yes exactly thanks , i made it way too complicated
Usually I try wrong way first then over complicated way, then the google way, then ask. A mentor showed this method so I owe him all credit.
@Toque Yes, I was confused cause its just like jamie's demo , but his gets stuck at one place and yours continue to bounce off , so setting the friction to 0 does the trick , didnt know that cheers !