# Fix My Physics?

This forum is currently in read-only mode.
0 Favourites
• 6 posts
• Hey, I've had this stuck for a few months and have not been able to figure out collisions.

It's a top-down 360 spaceship movement with a loose-drifting movement and I need the ship to bounce correctly.

I have 8 Variables for the ship.

Mass

MovSpeed = How much push the engines are giving

XPos = X Position

YPos = Y Position

XMov = The movement from the engines along the X plane

YMov = The movement from the engines along the Y plane

XMovEx = The movement from external forces along the X plane

YMovEx = The movement from external forces along the Y plane

I needs to make the ship bounce when it collides with another object. But not some arrbitrary amount. If a heavy & slow object pushes against the ship then the ship gets moved out of the way (Like a bulldozer) or if a extremely fast yet small object hits then the appropriate force would be applied to the ship.

If anyone can help me on this that'd be just outstanding!

I hope I made some sense.

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• Replace the collision event with

+ On collision between Ship and Red Square

-> Ship: set XMov to Ship('XMov') * -1

-> Ship: set YMov to Ship('YMov') * -1

I think that's what you want

Use -0.5 instead of -1 and you'll bounce back with half the velocity you hit it, and so on. Hopefully you can probably work it out from there.

• Any reason why you dont just use the built in physics engine ? It saves you a lot of time in the long run i find

• + On collision between Ship and Red Square

-> Ship: set XMov to Ship('XMov') * -1

-> Ship: set YMov to Ship('YMov') * -1

The only problem with that, while it's the closest thing I can code for a custom engine bounce, it doesn't actually allow for realistic rebounds, it will ALWAYS rebound in the exact opposite direction at which you came at the obstacle.

It's good enough for some things, but I would REALLY love a way to code in real bounces similar to the bounce object

I want to put time manipulation stuff in my game, and either this bounce thing getting solved or scaling physics values to pixels per second will make what i need to do possible

Just to clarify, say in my super speed demo i posted ages ago, you slow down time say, a thousand times slower, that would mean you have to make the player object move 1000 times faster to make it look as though the player's speed isn't affected. In a custom engine I can do this no sweat, but the player doesn't bounce properly, but if i'm using the physics object, the player bounces perfectly fine, but when i use the code to make the player speed up the same ratio that time has slowed down, he doesn't go the right speed at all

it's like:

Custom engine: speed = 200, times that by 1000, new speed would be 200000 pixels per second

Physics engine: speed = 200, times by 1000, physics value still listed as 200000 but travels at what appears to be a lot slower than what it should be. The value of the velocity has no doubt been multiplied by 1000, but it's like the velocity in physics uses a different ratio or something. Almost as if 400 velocity is NOT twice as fast as 200, if you get my drift. Correct me if i'm wrong

sorry bout the wall

• In my universe demo, I made custom physics with bouncing. It isn't entirely realistic, but it's close enough. All it needs is the normal angle of the surface against whom the bounce happens. With spherical planets like in that demo, calculating the normal angle is easy, but if the object is irrelugar, calculating normal angle is very difficult. With cubes, it is very easy, though. Interested?

• Actually that's quite interesting, sparking off all manner of ideas in my mind as we speak.

Although I'm hoping i don't have to have detectors everywhere.

I have the code to find the correct bounce angle but finding the normal of the colliding wall was always the problem.

One time I set up a complex loop that shot out detectors that stopped on overlapping solids then returned the average angle of a certain area infront of the player's direction of motion... but it didn't work out so well...

I'm thinking now, I could probably use squares and circles to find the normal thingy, and to find which side of the square the player hits i could probably use an angle between points thing.... hmmmmm

Is that what you did?