# Fix my physics?

### » Sun Nov 30, 2008 9:13 pm

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.
B
33
S
14
G
4
Posts: 251
Reputation: 4,049

### » Sun Nov 30, 2008 9:19 pm

B
33
S
14
G
4
Posts: 251
Reputation: 4,049

### » Mon Dec 01, 2008 1:22 am

Is this a custom physics engine you're making?
I've tried many times and it's the bounces that get me.
If there was a way to use the ball behaviour's bounce code in custom engines then i'd have no problem, finding normals from raster images is a pain in the bum

But with you're code, if it's a custom one, I think you'd only need one set of X and Y movement variables, because as soon as something hits it, you could just alter the one set of X and Y variables accordingly.

eg: Xcomponent = 50
then he runs into something: Xcomponent = -20

etc, so it would just look like he bounces off it, you would of course have to set the Ycomponent ones too obviously.

I'm no maths genius but for working out the weight of things and how they will affect your movement on collisions (this is assuming that somehow we got the bounces working) you would need a Mass variable for each object (if this is custom, if using the physics behavior, just use it's mass field) and then you can work out the momentum, which i believe is Speed * Mass
You can easily work out the Speed by using the system function distance(0, 0, Xcomponent, Ycomponent). Then again i could be completely wrong
I wouldn't know how to change your movement variables once they collide, but i'm pretty sure you'd have all the numbers there that you need, if i was you i would just play around with it until i got it right. Like i said i'm no maths genius, i'm sure there's someone here who is though and might be able to shed some more light on the whole thing.

P.S. Hi Devs Please help us find a way to get normals from raster images similar to the ball behaviour's bounce
B
3
S
2
G
5
Posts: 351
Reputation: 2,377

### Who is online

Users browsing this forum: No registered users and 0 guests