How do i make the avatars move?

Hello, all!

do i need a script code?? Help please :smiley:

Have you fully inspected the initial project you get when you first start using PlayCanvas? Here’s the source project that would have been forked into your account:

It has a script on the player’s avatar (a sphere):

That project uses physics.

If you want to move a character without physics, it’s much easier. Something like:

// Script Definition
pc.script.create('movement', function (app) {
    // Creates a new Movement instance
    var Movement = function (entity) {
        this.entity = entity;
        this.speed = 2;

    Movement.prototype = {        
        // Called every frame, dt is time in seconds since last update
        update: function (dt) {
            if (app.keyboard.isPressed(pc.KEY_LEFT)) {
                this.entity.translate(-this.speed * dt, 0, 0);
            if (app.keyboard.isPressed(pc.KEY_RIGHT)) {
                this.entity.translate(this.speed * dt, 0, 0);
            if (app.keyboard.isPressed(pc.KEY_UP)) {
                this.entity.translate(0, 0, -this.speed * dt);
            if (app.keyboard.isPressed(pc.KEY_DOWN)) {
                this.entity.translate(0, 0, this.speed * dt);

    return Movement;

@will, as i said before the codes are not working. WHEN I launch the game a whoe bunch of error codes pop up on the bottom of the screen, OR when I edit the script a bunch of red x’s are on the side of the screen. The code you have sent me does not work.

You’re incorrect. The code does work, as demonstrated in this project here:

It’s best not to jump to conclusions about the source of a problem until you are certain. In future, it helps to link to your project, otherwise it is impossible to diagnose what’s wrong.

@will, I just did the code and turns out It did work. Please forgive me. I was not paying attention. I just started making games trying to make my dreams a reality. I’m only 12 and working my best with all the time i’ve got.

Thanks for helping me out, you have earned my FULL respect and now i have leaned to pay attention to anything and everything!

1 Like

No problem James! I’m glad you got it working. It’s really exciting that you’re getting into making videogame development at the age of 12. It’s not an easy task, so don’t give up. :smile: