Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use extended-wasd-controls with cameraRig + cameraHead ? #5

Open
Turtleted21 opened this issue Apr 28, 2021 · 2 comments
Open

Comments

@Turtleted21
Copy link

Hello
Your examples show how to use extended-wasd-controls with one camera.
My project is setting with 2 cameras entity, a cameraRig to move and a cameraHead to look. ( because can work in VR too )
How I can set extended-wasd-controls to control cameraRig/move with a joystick and cameraHead/look with another joystick ?

Thanks

@Turtleted21
Copy link
Author

Turtleted21 commented Apr 28, 2021

I created 2 components like this, it work :
` <script>

  // need to run javascript code after a-scene entities and components are loaded
  AFRAME.registerComponent('screen-controls', 
  {
    init: function () 
    {
        this.component1 = document.getElementById("cameraRig").components["extended-wasd-controls"];
        this.component2 = document.getElementById("cameraHead ").components["extended-wasd-controls"];
        this.joystick1 = new Joystick("stick1", 64, 8);
        this.joystick2 = new Joystick("stick2", 64, 8);
      },

      tick: function(time, deltaTime)
      {
        // console.log( joystick1.value )
        // console.log( this.component.movePercent )
        this.component1.movePercent.x   =  this.joystick1.value.x;
        this.component1.movePercent.z   = -this.joystick1.value.y;
        this.component2.rotatePercent.x = -this.joystick2.value.y;
        this.component2.rotatePercent.y = -this.joystick2.value.x;
        
        
      }
  });


</script>`

what do you think about my code?
thanks

@Turtleted21
Copy link
Author

ah it don't work, my move is "absolute", it don't take take into account the rotate coming from the joystick2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant