Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Thanks! Without your question I probably wouldn't have figured out how to rotate anything at all.

Using your code, changing the left/right to the following made rotation and forward movement seem ok at fist:

 if (Sup.Input.isKeyDown("LEFT")) {
this.actor.rotateLocal(new Sup.Math.Quaternion(0, 0.01, 0));
}
if (Sup.Input.isKeyDown("RIGHT")) {
this.actor.rotateLocal(new Sup.Math.Quaternion(0, -0.01, 0));
}

but when using larger values or starting off with one huge rotation, the model gets squished together:

https://youtu.be/4GElYV1-BJo

Full code (assumes "CatTankHead" 3d model exists):

let mainCharacterActor = new Sup.Actor("CatTankHead");
// Tell our actor to dress in a 3d model
new Sup.ModelRenderer(mainCharacterActor, "CatTankHead");
// Summon a second person on stage, that'll be the camera
let cameraActor = new Sup.Actor("Camera1");
// Give the person a camera
new Sup.Camera(cameraActor);
// Place our actors. The main character actor is at the center of the stage
mainCharacterActor.setPosition(0, -1, -4);
// The camera person will be looking at the main actor from a distance
cameraActor.setPosition(0, 0, 5);
class CatBehavior extends Sup.Behavior {
  awake() {
      this.actor.rotateLocal(new Sup.Math.Quaternion(0, 0, 0));
  }
  update() {
    if (Sup.Input.isKeyDown("LEFT")) {
      this.actor.rotateLocal(new Sup.Math.Quaternion(0, 0.1, 0));
    }
    if (Sup.Input.isKeyDown("RIGHT")) {
      this.actor.rotateLocal(new Sup.Math.Quaternion(0, -0.1, 0));
    }


    if (Sup.Input.isKeyDown("UP")) {
      this.actor.moveOriented(0,0,0.1);
    }


    if (Sup.Input.isKeyDown("DOWN")) {
      this.actor.moveOriented(0,0,-0.1);
    }
  }
}
mainCharacterActor.addBehavior(CatBehavior);