Skip to main content

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

Neross

1
Posts
1
Topics
A member registered Dec 26, 2019

Recent community posts

(1 edit)

Bonjour à tous,

Voici le code d'un behavior de caméra permettant de la faire ce déplacer grâce a un clic + glisser de la souris.

class CameraBehavior extends Sup.Behavior {
    speed = 0.04
    dragOrigin : Sup.Math.Vector3;
    awake() {
    
  }
  update() {
    let mousePos = Sup.Input.getMousePosition();
    let mousePos3d = new Sup.Math.Vector3(mousePos.x, mousePos.y, 0);
    let cameraPos = this.actor.getPosition();   
    mousePos3d.unproject(this.actor.camera);
    
           if (Sup.Input.wasMouseButtonJustPressed(0))
        {
            this.dragOrigin = mousePos3d;
            return;
        }
 
        if (!Sup.Input.isMouseButtonDown(0)) return;
 
        this.actor.move(mousePos3d.subtract(this.dragOrigin).multiplyScalar(-this.speed));   }
}
Sup.registerBehavior(CameraBehavior); 


J’espère que sa en aidera certain. Je continuerais à partager quelques bouts de codes.