move and rotate joints

My player’s legs are sprites which are attached to the body with a pivot joint. Is it possible to move the legs or rotate the joints to provide a walking animation? [import]uid: 74852 topic_id: 12650 reply_id: 312650[/import]

Yes, the API can be found here. :slight_smile: [import]uid: 52491 topic_id: 12650 reply_id: 46398[/import]

Actually I have looked in the API before posting here ;).

Unfortunately I’ve found no way to rotate a joint. I can set the rotation limit etc. but not the rotation itself.

Can you please point me in the right direction ;)? [import]uid: 74852 topic_id: 12650 reply_id: 46408[/import]

I can’t tell you specifics because I’m not totally certain about how you’re doing everything, but this thread, first post, sounds like it may be a good starting point - hopefully :slight_smile:

https://developer.anscamobile.com/forum/2011/02/04/rotating-physics-body [import]uid: 52491 topic_id: 12650 reply_id: 46612[/import]

As per the link provided by Peach, you can use motors to provide rotation on jointed physics objects. Using that method you can make a car with wheels that moves along the ground realistically.

However, it sounds like you are trying to simulate a humanoid character walking on two legs. I believe this would be very difficult to achieve with Corona’s physics engine, or any engine for that matter, due to timing, balance, and feedback required just to prevent a biped from falling over, let alone walk convincingly.

You might have better success using some invisible “helper” objects that keep the character upright and moving along the ground (like a couple giant wheels attached to the base of your character) then perhaps use motors on the leg joints to make them move back and forth in a synchronized way but not used to actually move or balance the character. [import]uid: 9422 topic_id: 12650 reply_id: 46700[/import]

@XenonBL:

This sounds like a good idea. I’ll give it a try :). [import]uid: 74852 topic_id: 12650 reply_id: 46702[/import]

I should add, even with the approach I described it’s still going to be a challenge to pull off realistic looking walking. The easiest approach would probably be to create a single physics object for the character and do the leg walking animation by flipping through pre-rendered sprite frames, the way most 2D games do it. But I assume there’s a good reason you want to do it physically via jointed leg objects. [import]uid: 9422 topic_id: 12650 reply_id: 46734[/import]

I think I have several good reasons:

  • The player should be able to act like a ragdoll
  • The different limbs should be “breakable”
  • The user can change the players appearance and choose from different legs. If I do the walking with animated sprites, I will have to provide many animations for every different leg sprite. If I do it with joints, I will be able to do it programmatically only once.

I hope that I’ll get good results with my approach, otherwise I’ll have to do with animated sprites nontheless. [import]uid: 74852 topic_id: 12650 reply_id: 46782[/import]