New game idea, little help (Steering and driving)

As far as masking goes, I think you don’t need to set a mask - just use an image which looks like churned up mud, but with some transparency to make it look right when it is added on top of the rest of the ground.

Here’s my understanding of the following lines (maths is not my forte, either)…

Calculate the amount of force to apply to the powered wheels needed to drive the vehicle. This is based on the current direction of the wheel with the motor and the speed the vehicle is currently moving. The actual maths is a form of rotation maths (the 180/pi gives it away.) In short, this works out which direction the force is applied to the drive wheels.
[lua] wheelRDirectionX = math.sin(motor1.rotation/180*math.pi) * TRACTOR_SPEED
wheelRDirectionY = math.cos(motor1.rotation/180*math.pi) * TRACTOR_SPEED
[/lua]

This takes the force (calculated above) and applies it to the wheels to drive the tractor. This is basically the simulation of the engine providing power to the wheels. In fact, what it is really doing is pushing the wheel objects in the direction they should be moving. Because the wheels are attached to the rest of the tractor they will cause the tractor to look like it’s driving in that direction.
[lua] motor0:applyForce(wheelLDirectionX,-wheelLDirectionY,motor0.x,motor0.y)
motor1:applyForce(wheelRDirectionX,-wheelRDirectionY,motor1.x,motor1.y)
[/lua]

This applies rotational (angular) force to the pivoted object connected at the joint. In effect, this simply turns the wheels by applying force to the pivot joint.
[lua] --Steering
local mspeed
mspeed = math.rad( steeringAngle - motor0Joint.jointAngle )
motor0Joint.motorSpeed = mspeed * STEER_SPEED

mspeed = math.rad( steeringAngle - motor1Joint.jointAngle )
motor1Joint.motorSpeed = mspeed * STEER_SPEED[/lua]

So, all in all, we have 3 bits of code: The first works out how much force should be applied in the direction the tractor is driving. The second applies the force to the wheels, causing the tractor to move. The third turns the wheels, if they are being steered. [import]uid: 8271 topic_id: 34974 reply_id: 139649[/import]

I’m glad this topic: https://developer.coronalabs.com/forum/2011/06/22/top-view-car-simulation-experiment helped you :slight_smile:

[import]uid: 5629 topic_id: 34974 reply_id: 139654[/import]

@ yagizgurgul Yes thank you! Couldn’t find it for the longest time, but it sure helps man.

I think I got that figured out now, did some calculating on my end and mostly figured it out with your help. Thank you very much! Now what I am working on is having the tractor drive with a button command, see what I can do! Thank you both for so much of your help in this department

Lastly, the masking. I understand what you are saying, but as far as getting it to display as the “plow” goes over it, not the whole thing changing is a bit puzzling!

Thank you once again! [import]uid: 28237 topic_id: 34974 reply_id: 139732[/import]

I think the “plowed” image of mud should be added underneath the tractor, then revealed as the tractor drives away. [import]uid: 8271 topic_id: 34974 reply_id: 139734[/import]

Ill look into that, thank you for all of your help! [import]uid: 28237 topic_id: 34974 reply_id: 139918[/import]