Looking and shooting with controller

Hi I’m working on adding controller input to my game I can walk around and jump but i can’t shoot or look around. I was wondering if i can have the controller control the mouse or if i just need to find another method.

Thanks for your time
William Boersma.

You need another method. The browser can’t control the position of the mouse.

ok if i send you the code could you see how i could change it so i can take controller input as well?

I’m afraid I don’t have the free time to do one to one consulting for this.


just pointerlock your mouse then use the controller input

Hi @jus.co_ding_me_23 I got the looking part i just need to get shooting all i need is the x and y values for the center of the screen.
do you know what that is?


@yaustar Do you know what the x and y values for the center of the screen are?

@WilliamBoersma31 screen.width/2 and screen.height/2


it didn’t work can you take a look at my to see what i did wrong https://playcanvas.com/editor/code/749856?tabs=40420369

//var et = 2;
 //var er = 2;
  if (this.app.gamepads.wasPressed(pc.PAD_1, pc.PAD_R_SHOULDER_2)) {
      this.doRaycast(screen.width/2, screen.height/2);
1 Like

thank you
but it still doesn’t work

@jus.co_ding_me_23 how would I use pointer lock here?

inside the initialize function do

}, this);

if you do that then the controller imaginary cursor, (and the mouse’s real cursor) locks in the middle of the screen so there you go.
It might help with your situation @WilliamBoersma31

Then make your controller rotation. :open_mouth: