Change screen fov(field of view) with html,or javascript?


does anyone know how to make a field of view scroll bar to change to viewport for the entityheres the code I’m using`var fov = pc.createScript(‘fov’);

fov.prototype.intalize = function() {
entity.addcomponent(‘camera’); =‘entity’);
//this add s the camera to the entity//

fov.prototype.update = function() {


fov.prototype.intalize = function() {
var fov = this.entity(‘player’);
this.scrollX = 2;
this.screenY = 3;
this.screen.window = this.scroll.x.y;
entity.scrollbar = (‘createscrollbar’);


Just to check, are you trying to make scroll bar that you can slide to change the field of view of the camera?


Yes exactly thts what I’m trying to do


Break the problem down first. You effectively have 3 tasks:

  1. Work out how to change the camera FOV from code
  2. How to create a UI slider
  3. How update the FOV value from the slider

Start with task 1. Can you write the code that can change the FOV up and down using the keyboard arrow keys?


hmm idk I guess I can try I dont think so because I’m still new to coding


It seems you have the script called field.js right? so why are you creating the script as
var fov = pc.createScript(´fov´); This would not work since the script is not following the called name. the variable would have to the same as the script name so this is what it would look like instead:
var Field = pc.createScript(´field´);see what i mean @Marquise_Edwards ?


oh yes I do see so just change it to fov instead of field


If you are getting stuck with this, then start with something simpler and build from the foundations.

Have you gone through all of the Computer Programming course at Khans Academy that I linked to you before?


Oh khan is really good i also seen you post that and i tryed it out because i was always getting stuck and never learning from codecademy so i tried it and im much much much better (Altho im not) so thank you


um I made it to funnctions then stopped because I felt I know enough basic for rn


Please finish the course. More of PlayCanvas will make sense once you understand Javascript objects and object oriented design even if it’s just the syntax.


ok fine I’ll do it but theres like a feeling telling me I already know everything basically I gues I just already most of things I’m supposed to know later in programming and life


What makes you think that?


well theres a something in our body called a brain which lets us think lmao:rofl:


Brains are funny things. On the one hand they help us do many really cool things. On the other, they have all these funny methods that cause them to fool themselves - making it seem like they are doing something for one reason when, in fact, the the reason is different or at least more complicated that it seems at first.

I’m also new to Playcanvas and Javascript. I pretty much had to jump into this to get a project done without having a base knowledge of of either. It wasn’t pretty. Many long hours struggling with things. Our group managed to get our project done, but it wasn’t very time efficient, and I strongly suspect that some of our solutions weren’t the best - even if they did work.

yaustar is, IMO, correct in advising you to break your problem down into sections. Heck, sometimes you end up needing to break the sections down into sections. It is VERY easy to think you’ve got a handle on things when you actually don’t. For instance, I recently thought I was doing everything right in identifying and copying materials. But it wasn’t working. The key was subtle. When you call a material directly from a material file, you identify it as an asset.resource, not a .material. Go figure! There are lots of confusing situations like that that probably make a lot more sense and/or are easier to figure out if you have a stronger Javascript foundation than a newb like me. (BTW, console.log() is your friend in trying to figure out why something isn’t working. That’s what helped me understand I wasn’t identifying the “material” quite right.)

Anyway, I strongly suggest taking yaustar’s advice to heart - both the idea of breaking a problem down into smaller parts as well as getting a solid foundation in the fundamentals of javascript. While I still have project and other commitments and can’t just stop and go through the course, I will probably start trying to set aside an hour a day on javascript training.


huuh as tuff as this sounds I have to come to conclusion tht you are right I will set aside all distractions which is kinda hard because I’m not used to learning code every day but I will if thts what it takes to become shinobi heh jk in naruto terms becoming hokage.So I will do the hard stuff fist and then it will all been worth it because it will pay off later on.Which will be kinda ard for me but I can do it.Becuase I have goals and a future to look forward to.So yea I will do the training lol


I wouldn’t rule out dabbling in PlayCanvas while you dive deep into building a foundation in Javascript. I just wouldn’t start ambitious projects without first building that base.


so what are you trying to say then because I already alot about playcanvas and the tools


I’m suggesting that you focus on Javascript but still spend a little time experimenting with and trying to do new things in Playcanvas. It doesn’t have to be 100% one or the other.


hmm ye ik but i cant do simple games if i do i always wannnaa go for something better or bigger but then i get confused 0or bored and then giveup and make a new one and do it over again its a bad habit for me