Bouncing Objects

For questions about using Classic.

Post » Mon Apr 16, 2012 6:48 am

I know this may not be new to many people. I need an object bounce off another object. Well let me explain a few things first.

I'm making a space fairing game. I have an idea of adding gravitational aspect to the game. So, I installed the custom plugin for gravitation behavior (I found it in the forums). It's exactly what I need but the problem arose when I wanted the ship to bounce off asteroids and other ships I couldn't seem to get it right.

First I tried adding ball behavior and it seem to completely ruin the controls. So I tried the physics behavior, that too failed.

So I'm here to ask you guys if you know how to write an event script in CC to make the ship bounce off an asteroid or a wall? (maybe you could tell me the maths behind it too so I can try working out how to bounce two ships that collides).
Posts: 44
Reputation: 563

Post » Mon Apr 16, 2012 7:13 pm

If it's colliding with a wall set the ship's angle to 2*wall's angle - ship's angle.
here's a picture explaining the maths: , where b is the wall's angle and a the ship's angle.
If it's colliding with an asteroid, you can first get the b angle, by using the system angle between points expression.
I'm not sure if that's the kind of "bounce" you wanted though.
Posts: 69
Reputation: 1,019

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests