[Behavior] Car physics

Post your completed addons to share with the community

Post » Mon Nov 18, 2013 5:50 am

@tnindie
Here is how I create a prismatic joint in the car physics with the Construct SDK(in this case, the left rear wheel):

var leftRearJointDef = new Box2D.Dynamics.Joints.b2PrismaticJointDef();
leftRearJointDef.Initialize(this.PhysBody, this.PhysLBWheel, this.PhysLBWheel.GetWorldCenter(), new Box2D.Common.Math.b2Vec2(1,0));
leftRearJointDef.enableLimit = true;
leftRearJointDef.lowerTranslation = leftRearJointDef.upperTranslation = 0;
leftRearJointDef.collideConnected = false;
this.LeftBackWheelJoint      = this.PhysWorld.CreateJoint(leftRearJointDef);

If you need more information than that, I suggest you read the Box2d documentation and/or the Construct Physics files.
B
38
S
13
G
9
Posts: 151
Reputation: 8,427

Post » Mon Nov 18, 2013 6:05 pm

@CodeMasterMike
thanks for your help
B
7
S
2
Posts: 44
Reputation: 668

Post » Sat Nov 30, 2013 1:11 am

Hey yall,

SO I was tinkering around and wanted to see if I could get the side view car to wrap around the layout. The idea is that the player is on a planet that eventually wraps around. I dont want to do a rotational style game, because the player wont see the actual curvature of the planet they are on, the distance will take some time to go all the way around on.

So, I tried a few things, including but not limited to trying to put the wrap behavior on all the parts. It just freaks out every time, usually the car gets to the the end of the layoiut and then rtolls off screen. It will sometimes appear on the next side but it will be tweaked out when it arrives.

What I really want is a totally clean and unnoticeable transition around the other side, so it just feels like you can drive all the way around a planet. ANyone have an idea how to do this with this carphysics behavior?ductape2013-11-30 06:53:16
B
2
Posts: 1
Reputation: 152

Post » Sat Feb 08, 2014 11:07 pm

Can someone explain why my car Breaks apart? I have made a small test file to exhibit the behavior (But see no where to attach it). When ever the car hits a jump at a decent angle it breaks apart and does all kind of weird things (spinning, wheels flying everywhere, etc)
B
1
Posts: 1
Reputation: 152

Post » Fri Mar 28, 2014 12:34 pm

I have used this to make a top-down car game, But I am stuck at a point.
My game have 2-3 cars.So instead of making 2 different objects, I just changed the sprite of body to different one, ( they both have same size). But as soon as I change it, the wheels coming out to the sides. I have tried many things, disabling collision etc. but none is success. Can anyone please help me.
Thanx in advance.
B
6
S
2
G
1
Posts: 77
Reputation: 708

Post » Fri Mar 28, 2014 1:09 pm

@Raganork Its not possible to change object like that in realtime, due to the way the physics works. Either use a physics on each car or change the image of the car with the physics instead.
B
38
S
13
G
9
Posts: 151
Reputation: 8,427

Post » Sat Mar 29, 2014 1:46 pm

Yes. I ran into the same snag but figured it was just something I did wrong...

I have a single sprite on the screen which is a picture of a car. I added the physics behavior to it. I wanted the car to go from the right side of the screen, and then wrap back in from the left side of the screen. Once the car leaves the screen on the right, it totally flips out -- sometimes you could very briefly see the car appear on the left side of the screen but it is totally flipping out (i.e. spinning, not useable, etc).. then you have to restart the level all over again.

If there is a simple solution to all a car with the physics behavior wrap from one side of the screen to the other, I'd love to hear it because I'm once again stumped. Thanks.
B
9
S
2
Posts: 111
Reputation: 1,010

Post » Sun Mar 30, 2014 6:02 am

CodeMasterMike wrote:@Raganork Its not possible to change object like that in realtime, due to the way the physics works. Either use a physics on each car or change the image of the car with the physics instead.


How can I change the image of car with the physics ? I want my car to be ready as soon as that layout gets load.
B
6
S
2
G
1
Posts: 77
Reputation: 708

Post » Sun Mar 30, 2014 12:59 pm

@Raganork

Easiest way I can think of at the moment, is to set a image of one car as a animation frame, so you'll have 2 different frames with 2 different images, and then when you want to switch image, you change the current animation frame. But there is surely other and better ways to do it.
B
38
S
13
G
9
Posts: 151
Reputation: 8,427

Post » Tue Apr 01, 2014 5:41 am

CodeMasterMike wrote:@Raganork

Easiest way I can think of at the moment, is to set a image of one car as a animation frame, so you'll have 2 different frames with 2 different images, and then when you want to switch image, you change the current animation frame. But there is surely other and better ways to do it.



I did the same, but that is causing the problem. Can't change the sprite. I am not getting why just changing the sprite is causing the problem.
B
6
S
2
G
1
Posts: 77
Reputation: 708

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 0 guests