It looks like you're new here. If you want to get involved, click one of these buttons!
The physics math is puzzling me.
I have two bodies, each of which will have their own unknown rotation to start, and I want to see both of them animate rotation towards an arbitrary angle that I can set on the fly.
It seems like I’d want to use angularVelocity and torque somehow but I can’t figure it.
Comments
@UberGoober Here's something I wrote a long time ago. I’m not sure if this is what you’re after. Adjusting the friction value in circ:init affects how the rotate/move.
I would use a tween, set your script to have a function or reference to the body.angle
Then your tween would go from a to b for that reference or function, passing the new value.
If not I think tweening might be something I’d stay away from.
I’d strongly prefer to only work with one system at a time for controlling where things are drawn.
@dave1707 your demo doesn’t seem to involve enforcing any given direction, just adjusting the matrix to match the given physics boy’s rotation.
I want to actually enforce a rotation of my choice.
Something like this:
How would I do that?
You are of course free to work as you please and are comfortable with.
So far for me the real power of Codea is through combining systems.
The physics system itself does not have ways to create point to point animations.
Physics bodies basically exist in their world and are influenced by gravity, impulses and each other. If you are a math wizard it might be possible to know the exact impulses to use to get the movements and rotations that’s you want.
You can also set certain body properties directly, like angle.
Tweens can be simplified into a function that turns one number into another number over a set period of time. It doesn’t have to be ‘x’ or ‘angle’, it can be any reference to a number.
So really it’s working with 2 data systems and draw is a separate singular system.
@skar, I’m not trying to create point to point animations.
Maybe the simplest way to ask this question would be “if I want to make a physics body rotate clockwise slowly, do I use
applyTorque
, and if so, how?”Can anyone here help me out by telling me how that function works?
@UberGoober Is this closer to what you want.
PS. There maybe more code here than you need. I pulled this out of another project so I just left it.
@dave1707 i think this definitely gets me headed the right direction. Thanks!
@UberGoober Here's another version with gravity turned off. I don’t know what you’re going to do so I thought I’d show you code with and without gravity.
Thanks again!