User Tools

Site Tools


en:examples:objects:turning_or_steering

Turning or Steering

Good for vehicle steering or turning ships and planes.

Code

car = orxObject_CreateFromConfig("CarObject");
 
...
 
if(orxInput_IsActive("Right")){
  orxFLOAT rotation = orxObject_GetRotation(car);
 
  orxVECTOR relativeSpeed = orxVECTOR_0;
  orxObject_GetRelativeSpeed(car, &relativeSpeed);
 
  rotation += 0.01;
  orxObject_SetRotation(car, rotation);
  orxObject_SetRelativeSpeed(car, &relativeSpeed); //reapply the relative speed.
}

Config

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

en/examples/objects/turning_or_steering.txt · Last modified: 2018/02/14 08:47 (2 years ago) (external edit)