Table of Contents

Turning or Steering (method 2)

Good for vehicle steering or turning ships and planes. Doesn't use relative speed so functions are faster, and the seperate rotation and speed are handy for drifting effects.

Code

car = orxObject_CreateFromConfig("CarObject");
 
...
 
if(orxInput_IsActive("Right")){
  orxFLOAT rotation = orxObject_GetRotation(car);
 
  orxVECTOR speed;
  orxObject_GetSpeed(car, &speed);
 
  rotation += 0.01;
  orxVector_2DRotate(&speed, &speed, 0.01);
  orxObject_SetRotation(car, rotation);
  orxObject_SetSpeed(car, &speed); //SetSpeed is less expensive than SetRelativeSpeed
}

Config

[CarObject]
Graphic = CarGraphic
Position = (300, 200, 0)
Speed = (0, 30, 0)
 
[CarGraphic]
Texture = car.png
Pivot = (38, 30, 0)