deltaluca / nape

Haxe/AS3 Physics Engine
http://napephys.com
Other
542 stars 78 forks source link

X velocity of body decreases during flying #72

Closed Mihail-Afanasiev closed 11 years ago

Mihail-Afanasiev commented 11 years ago

I don't know if it is the issue or normal. I wanted to write this question on http://deltaluca.me.uk/forum/, but it is unavailable now. So what I have is some body from one circle shape. I use this code to launch it: body.velocity = Vec2.get(0, 0); body.angularVel = 0; body.applyImpulse(_launchImpulse, body.worldCOM);

Before it I need to get body's trajectory. I calculate it from physical kinematic formulas, but trajectory isn't precise. I checked and found that body's velocity x value decreases each frame. For example: { x: 124.56574752686234 y: -401.10189487813545 } { x: 124.47232321621719 y: -395.9010684569769 } { x: 124.37896897380503 y: -390.70414265563414 } { x: 124.28568474707467 y: -385.5111145486424 } { x: 124.19247048351436 y: -380.3219812127309 } { x: 124.09932613065172 y: -375.13673972682136 } { x: 124.00625163605373 y: -369.95538717202624 } { x: 123.91324694732668 y: -364.77792063164725 } and so on..

Besides body have some angular velocity after impulse, but why? I set it to zero before launch. I apply impulse to COM of body. So I set angularVelocity after applying impulse too and it doesn't rotates, but still decrease x velocity. I graduated physical lyceum and I can't understand why it happens.. Air friction mb)))

deltaluca commented 11 years ago

set space.worldLinearDrag to 0.

Mihail-Afanasiev commented 11 years ago

Thank you, Luca! It helped. Really "air friction"