So I've been fiddling around with the Light and shadows demo and wanted to add controls to the plane so I could fly it around. Here's part of my script:
this.actor.moveOriented(0,0,0.1);
if (Sup.Input.isKeyDown("LEFT")) {
this.actor.rotate(new Sup.Math.Quaternion(0, 0, -0.01));
}
if (Sup.Input.isKeyDown("RIGHT")) {
this.actor.rotate(new Sup.Math.Quaternion(0, 0, 0.01));
}
if (Sup.Input.isKeyDown("UP")) {
this.actor.rotate(new Sup.Math.Quaternion(0.01,0,0))
}
if (Sup.Input.isKeyDown("DOWN")) {
this.actor.rotate(new Sup.Math.Quaternion(-0.01,0,0))
}
Now this all works up to a point. The plane rotates around and will fly up and down, but when the plane is rotated to say 90 degrees, pressing up still makes it go upwards, whereas I want it to go sideways. Like an actual plane would!
I've spent much of the day with the TypeScript API browser trying different things but still no joy.
Any suggestions?
Thanks!