[SOLVED] app not defined

https://playcanvas.com/editor/code/685133?tabs=30740340 script code sry for trouble but now it says app not defined asap

Hi @plok_cxz,

Use this.app instead of app and you will be fine:

    if(this.app.keyboard.isPressed(pc.KEY_W)) {
        this.entity.translateLocal(0,0,0.1);
    } 

it now works ty

also how do i make things go left is it -0.1

bc if so it doesnt work

Hello!

For to the left you can use:

    if(this.app.keyboard.isPressed(pc.KEY_A)) {
        this.entity.translateLocal(-0.1,0,0);
    } 

k

now it says Cannot read property ‘toString’ of undefined

Forward:

    if(this.app.keyboard.isPressed(pc.KEY_W)) {
        this.entity.translateLocal(0,0,-0.1);
    } 

Backwards:

    if(this.app.keyboard.isPressed(pc.KEY_S)) {
        this.entity.translateLocal(0,0,0.1);
    }

Left:

    if(this.app.keyboard.isPressed(pc.KEY_A)) {
        this.entity.translateLocal(-0.1,0,0);
    } 

Right:

    if(this.app.keyboard.isPressed(pc.KEY_D)) {
        this.entity.translateLocal(0.1,0,0);
    }

Can you show the error?

Hello @will! Can you help @plok_cxz ? :stuck_out_tongue:

Smart

Done

1 Like

i think i can now

it works now

Please try to send everything you want to say in one post.
You always can add something to a post with the pencil icon.

Please try to use the code that I sended you.
I think the problem is that you have to use a capital S instead of s.

1 Like

It’s pc.KEY_S not pc.KEY_s

Note the capital S

Great! (You always can send a reply but prevent a lot of post in a row). :see_no_evil: