[Solved] Physics car tyre - remove lateral motion

Get help using Construct 2

Post » Mon Mar 17, 2014 1:33 pm

So basically I have tried to translate this tutorial to C2 event system.
https://www.iforce2d.net/b2dtut/top-down-car

It seems that in the example it just applies an impulse to the center of the object.
Code: Select all
void updateFriction() {
      b2Vec2 impulse = m_body->GetMass() * -getLateralVelocity();
      m_body->ApplyLinearImpulse( impulse, m_body->GetWorldCenter() );
  }

If I use that Mass * -getLateralVelocity it is just way too much force. Also I tried to set velocity to lateral x and y with all kinds of variations, but could't get it to work.

Here is Youtube video from working car
http://www.youtube.com/watch?v=PFKw1Ks3MfY
Last edited by Katala on Wed Mar 19, 2014 10:36 am, edited 2 times in total.
B
34
S
9
G
3
Posts: 517
Reputation: 5,246

Post » Tue Mar 18, 2014 11:12 pm

I think this should be the main idea.
Image
I assume that could then be manipulated with some kind of friction value.

So far I basically just managed to get some values out.
You can push the tyre around with right mouse and rotate with left and right arrows.
Web test
CAPX

Maybe @R0J0hound, @Yann or @keepee could point me to the right direction :)
B
34
S
9
G
3
Posts: 517
Reputation: 5,246

Post » Wed Mar 19, 2014 1:33 am

@katala,

i was trying to do something like this a while ago:
https://dl.dropboxusercontent.com/u/53374990/Forum/car%20physics.capx
the group with the wheel physics should be open.. use WASD to control car, if you drive forward there is a row of unattached wheels where you can see how they don't laterally move.

I'm still not sure whether the physics is right, or whether it just needs fine tuning. Things like the collision polygon of the car, and wheel positions affect handling quite a lot.
I was trying to go for a car that you could drift reliably without losing control, but it wasn't really successful
B
28
S
8
G
1
Posts: 469
Reputation: 4,683

Post » Wed Mar 19, 2014 5:56 am

I don't have time to check yet nor do I have time to download the 164.2 version, but following the reference page you posted, the lateral velocity formula should be:
Code: Select all
currentRightNormalX = cos(car.Angle + 90)
currentRightNormalY = sin(car.Angle + 90)
dot = currentRightNormalX * car.Physic.VelocityX + currentRightNormalY * car.Physic.VelocityY
lateralVelocityX = dot * currentRightNormalX
lateralVelocityY = dot * currentRightNormalY
B
67
S
22
G
14
Posts: 1,485
Reputation: 16,536

Post » Wed Mar 19, 2014 10:36 am

@keepee, This is awesome! It seems to behave quite right. I think for "easy" drifting there should be somekind of spin prevention system.

@Yann, This also works if I remove that +90 part.

Thanks a lot for helping me out! I can now continue to make some sort of weight tranfer and whatnot :)
B
34
S
9
G
3
Posts: 517
Reputation: 5,246

Post » Wed Mar 19, 2014 6:34 pm

@Katala
That's very weird and suspicious.
B
67
S
22
G
14
Posts: 1,485
Reputation: 16,536


Return to How do I....?

Who is online

Users browsing this forum: Lisa999, RandomlyMooN and 8 guests