I want to make a body with ragdoll effect. How this can be achieved in box2d. I want to body keep straight even it fall down it can stand up itself.
There are lots of basic ragdoll tutorials.
To make it stand you could do the following:
1.
Make the joints springy. Make the joints have a target angle and a motor torque to resist rotation and move them back into a standing position.
2.
Use a force to lift the character up.
if (headBody.position.y < normalHeadHeight) {
headBody.applyForce(b2vec2zero, b2vec2(0,100));
}
This will lift the character up off the ground if their head goes below its normal height.
Notes
If you want it to look more like the character is really alive and moving under their own free will it will take a lot more work.
Related
So I've been struggling with this for a lot of time, I'll keep it short.
I'm working on my first P5JS game, and it's like Mario, but instead of horizontal endless runner, its vertical. So, I added an image as the background like this in setup function:
bg=createSprite(300,300);
and in the draw function:
background("black");
bg.addImage(bgImage);
bg.velocityY=5;
The velocityY constantly makes the image move downwards, but because it is an image, after a while the black background comes up again.
Like so:(the road is the image and the black color is the background.)
So how do I make it so that after the image has gone away, it comes back in, and it seems like it never even left?
Well, you could have two images, whenever one is fully invisible (img.y < height)
just teleport it back up to the top img.y = img2.y - img.height.
Also i believe that's the math to do so, but i'm not completely sure about it.
Also there might be a function for tiling in the library.
I have shelled box, and I used a shelled cube to "cut" a lid or door into it. Something like this :
I want to add a lid along the border of the cut. That stays inside the body and allows the lid to sit agains it. I found no way to add an sketch into the curved surface..
I can add an sketch to the flat surface of the cut.. but if I would cut the doot using a cylinder or another "curvy box" like the main one.. them I'd be unable to find a flat surface where lay my thing..
How can I do that? A lid of 2 mm deep, that enters 2mm into the hole, along the cutting path. Any idea ?
EDIT:
As mentioned, I managed to do it on ONE surface, just because is flat and hand drawing most of the thing.. here is how it look like, not totally bad, but I guess there is a way to just go along the border of the cut ..
I also managed to draw a profile and use "SWEEP" to have the lip around ONE edge, but no along them four and the corners get rather tricky ..
I'm writing with cocos2d-x, and have a problem:
For example, there are two sprites: a human and his clothes. I use fade (cascade opacity) to make it disappear, but during this the user can see the parts of the human body which were supposed to be hidden by the clothes. How to avoid this? How can I use render for that? Is there a way to overwrite pixels when render in cocos or OpenGL? Can anyone give an example?
You can use CCClippingNode to do the job.
CCClippingNode::create(cocos2d::CCNode *mask) (2.x type)
CCClippingNode::setInverted(bool)
It is used to create a clipping region. And you can use it to cover the body. Add the body in the clippingNode by addChild and use cloth as mask.
Im trying to raycast from the bottom of a box downwards. When the box is in the floor, I'd imagine the raycast fraction value would be zero, but it always gives me 0.0149998665. To be honest, It is not logic-breaking at all, but it OCD's me alot, and I'm just wondering why this happens?
Added a little sketch to make it easier to visualize:
Polygons (and edges) in Box2D are kept at a tiny distance apart to help stability in the contact constraint solver. http://www.iforce2d.net/b2dtut/gotchas#smallgap
I recently made a game with game maker and I've tried converting it to html5, but it's got some big errors... here is the game in html format: http://ivatrix.com/Game/index.html
First off, text is meant to appear in the top left like how you can see in this screenshot: http://gyazo.com/baa386fe06cfac9439c83b6e5192efd8 the text only appears after you create a combo.
Secondly, when you click on an orb it's meant to scale down to half it's size then scale up to 1.5x it's size, but instead it's shrinking until it's 1px large then infinitely increasing in size. Draw code is here:
if sl=1
{
if (s=0.6 or s=1) then d=d*(-1)
s+=d
if(frozen=1)
{
draw_sprite_ext(sprite_index,global.skin,x,y,s,s,0,c_blue,1)
}
}
And then there's other small errors like some text won't display, particle effects don't seem to draw, the game always returns saying there is no match on the board. That's all I've found so far.
Does anyone have any idea what I can do to fix this?
Thanks.
Since no one has provided an answer and I've found one myself, I'll put it up here so others in the same boat can benefit as well. Practically, the source of all my problems with floating point numbers being irregular, for example instead of it being 1 it could be 1.000000003, which meant if you were to check if that variable was equal to one, it would return false. Further information here: http://help.yoyogames.com/entries/77891197-HTML5-Issues-And-Differences
So for an example in my case, I changed the line
if (s=0.6 or s=1) then d=d*(-1)
to
if (s<0.6 or s>1) then d=d*(-1)
And now the problem is fixed.