My player falls only once and translateLocal is with delay

  1. As you can see on the photo my player never fall down(He has rigidbody and collider component), he only falls when i set his starting position above the architecture at the very beginning, but the he is not falling at all… also when i put him above the water he falls right on the water.

  2. My translateLocal has delay like 2-3 seconds till it istart working, then working fine, but when i turn off collider component it works right away.(ofc i dont want to remove my collider cause i need it :slight_smile:

Here is a link for my game :

Thanks for the answers…

Hey @smokys,

Just had a look. Main issue here is you cannot use translate and rotate for dynamic rigidbodies; you will have to move them using the Physics engine, i.e using Forces and Impulses. Take a look at for more information.

Hope this helps!

1 Like

@DevilZ thanks, now it is working properly, but when i use force or impulse and i release running button my player keeps moving even though im not giving more impulses or force. i tried to set linearVelocity to 0 but it didnt help.

So detect was Released on the keyboard. Once the key is released, then set linear and angular velocity to pc.Vec3.ZERO, and not the number.

1 Like

Still no success :confused:

are these lines good?


I used wasReleased function

You’ve got the idea, but I’m not sure if set is a keyword to be used here. You would want to do
this.entity.rigidbody.linearVelocity = pc.Vec3.ZERO, and same for angularVelocity as well.


Thanks for that it works now :slight_smile: i have learnt something… the last thing, while holding run button, players speed is exponentionaly growing, should i set max linear velocity while running?

1 Like

Yes, that should work.

The thing is thath linear velocity looks like this while moving Vec3
{x: 0.00017046311404556036, y: 0.0006771385669708252, z: 0.00018634350271895528}

How should code looks like when i want to change for example Z axis?

edit: as i have noticed Z axis is exponentionaly increasing so i want to set Z axis only

So you would get the currentX and currentY values, and set linearVelocity equal to something like new pc.Vec3 (currentX, currentY, whatever value of Z).

1 Like

console log says: this.entity.rigidbody.linearVelocity is not a function

there is somewhere certain reason why it doesnt take as a function

Is this the exact dump from the console, or did you miss the t while copying it? :wink: If it is the exact dump, send the code that’s causing the issue.

I missed the T :smiley:

1 Like
var PlayerMovement = pc.createScript('plyerMovement');

//Rychlost behu hraca
var playerSpeed = 10;
var playerMaxVelocitySpeed = 2;

PlayerMovement.states = {
    //nacitanie stavu animacii
    idle : {
        animation: 'standing.glb'
    running : {
        animation: 'running.glb'
    dance : {
        animation: 'dance.glb'
    falling : {
        animation: 'falling.glb'

// initialize code called once per entity
PlayerMovement.prototype.initialize = function() {
    //rychlost prechodu animacie
    this.blendTime = 0.2;
    //nastavenie stavu 'necinny'

// update code called every frame
PlayerMovement.prototype.update = function(dt) {
    var currentX = this.entity.rigidbody.linearVelocity.x;
    var currentY = this.entity.rigidbody.linearVelocity.y;
    //Ovladanie hraca
        this.entity.rigidbody.applyImpulse(0, 0,playerSpeed*dt);
        this.entity.rigidbody.linearVelocity(new pc.Vec3(currentX,currentY, playerMaxVelocitySpeed));
        this.entity.rigidbody.linearVelocity = pc.Vec3.ZERO;
        this.entity.rigidbody.angularVelocity = pc.Vec3.ZERO;

//vytvorenie funkcie setState pre ulahcenie nastavenia animacii v kode
PlayerMovement.prototype.setState = function(state){
    var states = PlayerMovement.states;
    this.state = state;[state].animation, this.blendTime);

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

// to learn more about script anatomy, please read:

Ah, the screenshot has loaded now. What you are doing is trying to call the LinearVelocity as a function, which won’t work. In my previous post, I had said equate it to the new pc.Vec3, which means you use the equals to sign to assign the vector.

EDIT - I can’t see you declare and/or set the currentX and currentY values anywhere?

Those are the first lines in update function :smiley: it is working now finally, thanks you did a good help :slight_smile:

1 Like

But there must be something wrong with currentx/y

are u able to play? try to get yourself on platform

edit: maybe not wrong with the code but i should be still getting impulses even when in the air, because once he is falling you cant move forward anymore

edit2: fixed, probably.

Issue 2: if you try to go on a platforms you can see that its like invisible collider in the center and you actually cant get on the other side to the finish

Hmm, the second issue shouldn’t be due to the movement script. Will check it out after work.

Ah, I had not seen that, I was on mobile. Sorry for the false alarm.