need help with physics

hey all,

i use applyforce to physics body object, when the object is falling down i want to rotate object, how could i do this ?

any ideas ? [import]uid: 22024 topic_id: 5726 reply_id: 305726[/import]

UP UP.

no one ? [import]uid: 22024 topic_id: 5726 reply_id: 19699[/import]

Well, I suppose you could be verifying the direction the object is going with the vx, vy = object:getLinearVelocity, and if vy is positive, then the object is falling. And if it is, you could apply object.rotation = 10, or what constant suits what you need. Is this what you’re looking for? [import]uid: 13720 topic_id: 5726 reply_id: 19701[/import]

hell yeahh !

this is exactly what im lookin for. thnx mate !

cheers [import]uid: 22024 topic_id: 5726 reply_id: 19705[/import]

I’m glad I could help. :slight_smile: [import]uid: 13720 topic_id: 5726 reply_id: 19782[/import]

i have another question,

i got a table with objects but with unknown amount of objects.
if i call table[i]:getLinearVelocity() for every object in table, on enterFrame event, would it cause performance issue?

[import]uid: 22024 topic_id: 5726 reply_id: 19972[/import]

Haven’t used this yet, but I know you can get the lenght of a table with “table.length”. Then you could set this variable as your top of the for loop to get that linear velocity. Measuring the velocity for all the objects every frame… yeah, that could cost you a lot of hardware resources. :slight_smile: But I might be wrong. Try and see. [import]uid: 13720 topic_id: 5726 reply_id: 19979[/import]

ok, i found a solution, when objects collide with ground i set that object’s isBodyActive property to false and in the loop i check this property wheter true or false.

i think this would work without any issues. [import]uid: 22024 topic_id: 5726 reply_id: 19980[/import]

In this case, you should avoid setting that property instead of letting the engine set it acoording to it’s behaviour. But you can set your own property, say “object.isOnGround”, that you can verify in the loop.
What I’m sayig is whenever you can, especially if it’s not necessary, avoid using the properties that the engine uses frequently.

In your context, you can set an object the “isBodyActive” to false, but what if you need it active at some point? I don’t know, maybe later on you’ll want to verify it’s collision with something else. Could be this, could be another scenario… Anyway, that’s what I’d do. :slight_smile: [import]uid: 13720 topic_id: 5726 reply_id: 20012[/import]

i dont need that object anymore if collides with ground.

but this applyForce, getLinearVelocity things makes me think about coding my own physics engine instead of corona.

[import]uid: 22024 topic_id: 5726 reply_id: 20103[/import]