Sketch, the problem that you are seeing in doug's demo is entirely due to the weight distribution. If the weight was moved towards the front, you would get the understeer that you would be used to in most real cars.
Top Down Car Simulation (Demo & Code)
FlashThanks for the feedback sketch!
Yea, pTymN's got it...the biggest factor that affects power slides is the car's center of mass, so for the player's car in the demo, moving that circle in the rear closer to the car's center might give you what you're looking for.
Fixing the slice function to handle more than 3-4 partial slices is a BIG entry on the todo list. I just took a new job with a cross-country move to boot, so fixes/features are coming slower than I'd like. That's at the top though cause I think it will attract more people to use the library.
Not sure what you're asking in regards to the distance joint. You want it to be more springy, or soft? You can mess around with frequencyHz and dampingRatio.
Thanks again!
- Doug
Yea, pTymN's got it...the biggest factor that affects power slides is the car's center of mass, so for the player's car in the demo, moving that circle in the rear closer to the car's center might give you what you're looking for.
Fixing the slice function to handle more than 3-4 partial slices is a BIG entry on the todo list. I just took a new job with a cross-country move to boot, so fixes/features are coming slower than I'd like. That's at the top though cause I think it will attract more people to use the library.
Not sure what you're asking in regards to the distance joint. You want it to be more springy, or soft? You can mess around with frequencyHz and dampingRatio.
Thanks again!
- Doug
box2d distance joints seem to be too stretchy.
if you have a character hanging of a rope, and the rope is chains of bodies connected by distance joints. that rope frequently separates and passes by small or sharp objects it should wrap around.
it felt like yours were less separate-able but its probably hard to tell with a chain of only 2 or 3. so never-mind i guess.
if you have a character hanging of a rope, and the rope is chains of bodies connected by distance joints. that rope frequently separates and passes by small or sharp objects it should wrap around.
it felt like yours were less separate-able but its probably hard to tell with a chain of only 2 or 3. so never-mind i guess.
QuickB2 uses Box2D for the back-end physics simulation, so the distance joint behavior will be the same. The demo's have a pretty low time step with high iterations, so that probably limits the amount of stretching. But yea, if you had large mass differences, or chains, you would still see stretching at some point.
I use lots of smaller timesteps to get stiff distance joints.
Hi guys,
I'm porting the first example to Corona. It doesn't have some methods which default Box2D library has.
My problem is at the killOrthogonalVelocity method. I ported it to this one:
I think It's pretty easy language. So you can understand what I did. Do you see where my mistake is? Instead of getting rotation vector like "targetBody.GetXForm().R.col2.Copy();" I used simple trigonometry for it. I assume it is correct but when I try to turn my car it starts to spin.
Thank you!
I'm porting the first example to Corona. It doesn't have some methods which default Box2D library has.
Code: Select all
function killOrthogonalVelocity(targetBody:b2Body){
var localPoint = new b2Vec2(0,0);
var velocity:b2Vec2 = targetBody.GetLinearVelocityFromLocalPoint(localPoint);
var sidewaysAxis = targetBody.GetXForm().R.col2.Copy();
sidewaysAxis.Multiply(b2Math.b2Dot(velocity,sidewaysAxis))
targetBody.SetLinearVelocity(sidewaysAxis);//targetBody.GetWorldPoint(localPoint));
}My problem is at the killOrthogonalVelocity method. I ported it to this one:
Code: Select all
local dot = function (x0,y0,x1,y1)
return (x0*x1 + y0*y1)
end
local killOrthogonalVelocity = function(body)
bodySpeedX,bodySpeedY = body:getLinearVelocity()
bodySideWayX = math.sin(body.rotation/180*math.pi)
bodySideWayY = -math.cos(body.rotation/180*math.pi)
bodySideWayX = bodySideWayX * dot(bodySideWayX,bodySideWayY,bodySpeedX,bodySpeedY)
bodySideWayY = bodySideWayY * dot(bodySideWayX,bodySideWayY,bodySpeedX,bodySpeedY)
body:setLinearVelocity(bodySideWayX,bodySideWayY)
endI think It's pretty easy language. So you can understand what I did. Do you see where my mistake is? Instead of getting rotation vector like "targetBody.GetXForm().R.col2.Copy();" I used simple trigonometry for it. I assume it is correct but when I try to turn my car it starts to spin.
Thank you!
This is valuable for me.
Thanks....
Thanks....
Original thread: https://box2d.org/forum/viewtopic.php?t=1547