Pages: 1
Topic closed
How do you make an object bounce off another object cleanly without it going 180 degrees back every time?
don't post the answer like so -
when gf clicked repeat until <(timer) > [10]> go to [mouse-pointer v] end think [Scripts in your posts!] for (6) secs
Last edited by RCScratch (2012-06-24 17:53:03)
Offline
Tell that to a Koch snowflake.
Google it. It means you can't do that without knowing the shape of the to-be-bounced-off sprite.
I guess you could do it with sensors though.
Offline
If all of the walls are 90 degrees it is relatively easy, but, as Molybdenum said, for more complex scenarios you need to know the slope at the point of contact of both objects.
If you're not using velocity, it is much easier (storing your previous position before movement is a common way).
Finally, what form of input are you using? Keyboard? Mouse? If you want the sprite to follow the mouse unless it hits a wall, I have a some-what workable script on another thread that I could find for you.
Offline
If you are making an animation then you could just do this:
Sprite 1 (the moving sprite):
when gf clicked go to x (0) y (-100) glide (1) seconds to x (100) y (0) glide (1) seconds to x (0) y (100)Sprite 2 (the stationary sprite):
when gf clicked go to x (100) y (0) // The sprite would have to have an x co-ordinate of slightly more than 100 depending on its size.Hope this helps.
Offline
Topic closed
Pages: 1