Reflecting collisions

Post your own tutorials, guides and demos.

Post » Tue Sep 01, 2009 2:50 pm

For the project I'm working on, I need to make objects 'bounce' off a circle (reflect at their angle of incidence). I came up with a solution that works reasonably well, with a few odd glitches - pretty sure I could work those out. Unfortunately, it also crashes the runtime sometimes, which is a deal-breaker.

[I know, crashes are always bugs! Submitted to the tracker.]

Does anyone have an alternative method? Surely there's a neat trigonometry solution to this. Hell, I was kind of surprised it was possible to do without trig. :)

http://dl.getdropbox.com/u/906550/bouncetest-02.cap
B
5
S
2
G
4
Posts: 113
Reputation: 2,101

Post » Wed Sep 02, 2009 7:55 am

I don't have Construct installed in this laptop but I did tackle this issue once.

However..... on second thought .... I was reflecting from a flat surface. Still I'm pretty sure it involves ATAN2
:P I had this huge trigonometric expression only to figure out later that Construct had it built in.
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Post » Wed Sep 02, 2009 8:07 am

If that method worked, I guess it's time I learned more about trigonometry.

I've definitely had the 'oh, it's built-in!' experience with Construct - making this, I was kind of struggling until I found the 'Angle is clockwise from' system condition. :)
B
5
S
2
G
4
Posts: 113
Reputation: 2,101

Post » Wed Sep 02, 2009 5:12 pm

see my post near the end of this thread
theres a long explanation, and an example cap:
[url]scirra.com/phpBB3/viewtopic.php?f=2&t=4169&start=10[/url]
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Thu Sep 03, 2009 6:00 am

Wow. Okay, your way uses less events, detects more reliably, runs faster, and doesn't crash. Thanks, Lucid!
B
5
S
2
G
4
Posts: 113
Reputation: 2,101


Return to Your tutorials & example files

Who is online

Users browsing this forum: No registered users and 0 guests