I’m trying to do a simple top-down racing game and is struggeling to get the steering right.
At the moment I’m using a very simple steering and want to add some drifting to the car.
I’ve read some tutorials about it but haven’t found a good one that will be easy to implement in my code.
Mabye I will have to rewrite my code for the purpose but I want to know if it could be easy implemented in my code?
My code for steering is as follows
public void steering(){
/*
Handles the steering
*/
if (wleftBounds.contains(touchPos.x, touchPos.y) && startSeqDone==true){
//move left
direction += 0.04;
velocity *= 0.97;
carSprite.setRotation(carSprite.getRotation() + carRot);
} else if (wrightBounds.contains(touchPos.x, touchPos.y) && startSeqDone==true){
//move right
direction -= 0.04;
velocity *= 0.97;
carSprite.setRotation(carSprite.getRotation() - carRot);
}else if (accBounds.contains(touchPos.x, touchPos.y) && startSeqDone==true){
//move forward
velocity += 0.04;
velocity *= 0.99;
myx += velocity*Math.cos(direction);
myy += velocity*Math.sin(direction);
}
}
My question is how to implement drift/skid?