I need help with player movement

Hello, I am working on a game and I got a new player model. I tried using the first-person script but the camera doesn’t work and it blows up player.

I’m not totally sure what you mean, but I guess it has to with collision and a dynamic rigidbody.

This is what I mean:


The player is not supposed to be that tall.

Then you need to find out what is causing it. Based on the picture I think maybe the animation you use is causing the different scale. Can you check the result without animation?

I turned it off and the model is still huge

I assume it’s not huge in the editor?

If you share the editor link of your project, someone can take a look.

HEre it is:
https://playcanvas.com/project/1056210/overview/cybr-chapter-1

It looks like it’s because you didn’t assign the camera entity to the script attribute.

image

Because of that, the script is creating a new camera at runtime.

Not sure why that causes the scale different to be honest.

@Codeknight999 I have noticed that the scales on your asset are changed like below.

image

Have you tried changing the scale setting on your model.

Also, The reason it will not run properly is due to this error.
image

var Move = pc.createScript('move');

// initialize code called once per entity
Move.prototype.initialize = function() {

};

// update code called every frame
Move.prototype.update = function(dt) {
if(this.app.keyboard.isPressed(pc.KEY_W)){
    this.entity.rigidbody.applyForce(100,0,0)
}
};
if(this.app.keyboard.isPressed(pc.KEY_D)){
this.entity.rotatelocal(0,5,0)
};

// swap method called for script hot-reloading
// inherit your script state here
// Move.prototype.swap = function(old) { };

// to learn more about script anatomy, please read:
// https://developer.playcanvas.com/en/user-manual/scripting/

I notice that too, but the scale was changing at runtime. If a scale of 5 is good in the editor, then it should be good at runtime too?

1 Like

Thanks, I will look into this.