I found this gif showing a character composed of a circle which allows movement and a rectangle (above the circle) allowing objects to be pushed.
I can’t understand how the two elements are linked to work like this.
why the rectangle remains permanently above the circle rather than rotating with it.
someone can code the same thing in solar2D (even on flat ground; what interests me is the composition of the character)
1 The character is the physics body (a circular body) and would normally be hidden.
2 The visible part (the girl) is an animation that is told when to play and follows the position of the circle.
I can demonstrate this later today when I get time, but I would simply put all my code on the ‘circle’ and have it draw, animate, and move the player image. The movement of the player image can be done in an enterFrame listener.
Warning: I’m a bit rusty, so someone else here may have a more elegant solution.
UPDATE Day job interfered. Will try to provide sample Thursday.
All you said is correct but it was not my question.
My question only concerns the green circle and the green square below.
How to compose (or link) those 2 object to have the same effect?
I guess there is a AngularImpulse on the circle to make it turn.
But how the square can remain above the circle without undergoing its rotation ???
Attach circle body to dummy object. Use high friction value.
Link circle body to square with Pivot joint (or optionally a wheel joint).
Use joint motor to turn wheel and thus move conglomerate.
I believe, this should keep the girl vertically aligned, but allow the wheel to drive your motion.
This will definitely take some experimentation, and your impulse idea might be better than motor and/or need to be added to get the initial push.
Again, I’ll do my best to give an example when time permits and if you don’t beat me to the punch.
Meanwhile, at the risk of distracting you, I do have a very old physics sampler I made when we had a weekly show called CoronaGeek.
My entire repository is here: GitHub - roaminggamer/CoronaGeek: Content from the Corona Geek Hangouts
The sample is in the folder: CoronaGeek\Hangouts\ICanMakeThat\PhysicsFun\physicsFun\
Has both pivot and wheel joints. Uses OLD subset of SSK which could be confusing. However, I want to offer the example just in case.