Jump a player with translateLocal()

how to do jump a player with translate local ,i am giving translate local vec y pos +0.5, but after i want player come down to ground how?

launch:
https://launch.playcanvas.com/783013?debug=true

You could do it with the physics engine:

  1. Add rigidbody and collision components to an entity.
  2. Set collision component to a capsule.
  3. Set rigidbody component to have angular factor set to 0, 0, 0 to stop it falling over.
  4. Set rigidbody mass to 80 (human weight).
  5. Set rigidbody type to dynamic.
  6. Create a script called player-controls.js and apply to entity:
var PlayerControls = pc.createScript('playerControls');

PlayerControls.attributes.add('jumpImpulse', { type: 'number', default: 100 });

PlayerControls.prototype.initialize = function () {
    
};

PlayerControls.prototype.update = function (dt) {
    if (this.app.keyboard.wasPressed(pc.KEY_SPACE)) {
        this.entity.rigidbody.applyImpulse(0, this.jumpImpulse, 0);
    }
};
  1. Create a static rigidbody entity for the ground (with a wide and deep but thin box collision primitive).

Okay Thanks Man i will try this one, But Player body dynamic means can i able to use linear velocity ? now i am using translate local for left and right movement now dynamic means i want to change movement also… is it wright…

Sure. You can do:

var PlayerControls = pc.createScript('playerControls');

PlayerControls.attributes.add('jumpImpulse', { type: 'number', default: 100 });

PlayerControls.prototype.initialize = function () {
    this.velocity = new pc.Vec3(0, 0, 1); // You'd have to experiment with good values here
};

PlayerControls.prototype.update = function (dt) {
    this.entity.rigidybody.linearVelocity = this.velocity;

    if (this.app.keyboard.wasPressed(pc.KEY_SPACE)) {
        this.entity.rigidbody.applyImpulse(0, this.jumpImpulse, 0);
    }
};

Thank you , i will try this one @ Will