[SOLVED] Cannot get gun to follow camera

I am having trouble getting the gun to stay on my screen when looking around.
Having problems programming it into the code.

https://playcanvas.com/editor/scene/896782

Your first-person-movement.js creates a new camera entity, it doesn’t use the one you add in the hierarchy.

Comment out line 19 and also put back your camera to Perspective projection and it will work:

FirstPersonMovement.prototype.initialize = function() {
    this.force = new pc.Vec3();
    //this.camera = null;

Are you wanting me to replace that line with the one you commented?

No to comment out line 19 from your script, it’s the same line I am showing above:

Oh, is that the problem with it

1 Like

Still trying to figure out what you want me to do

Ok I see that is fixed it in the editor but when I press run it is still weird

https://launch.playcanvas.com/896782?debug=true

Here, I’ve fixed it for you:

https://playcanvas.com/project/675520/overview/first-person-game

Thank you so much that is very helpful!

1 Like

It is still broken on mine but on your copy it is exactly the same
Very confused

I’ve just done two changes to the original project you posted:

  • commented out line 19
  • set the camera projection to Perspective in editor:

I have it set as that

would you like to be admin for a moment instead of forking it to figure out what is wrong with it

I have the exact same thing could you try fixing it again. I could make you admin for a minute to fix the original project!

Sorry, I am not able to that right now.

Ok but do you know what is wrong with it

https://playcanvas.com/editor/scene/896782

Sorry to keep bothering but I still cannot fix it could you please help.

Nev mid I have big-brain Idea You forked my game and fixed it so I will fork the fork

1 Like