Climbing a wall

I have trouble making a stable climbing system. The main bottleneck is the rotation. The player must take over the rotation of the object to be climbed and it must not matter from which side the player approaches the object. Who can help me?

    var playerPosition = player.getPosition();
    var objectPosition = this.climbableObject.getPosition();

    var targetDir = this.vec.copy(playerPosition);
    targetDir.sub(objectPosition).normalize();

    var dot = targetDir.dot(this.climbableObject.up);
    var angleInRadians = Math.acos(dot);
    
    var angleToObject= angleInRadians * pc.math.RAD_TO_DEG;

    player.setEulerAngles(angleToObject, angleToObject, angleToObject);

Could the player object face the ladder when climbing via the lookAt function (just remember to ignore the Y position of both the player and ladder)?

For a ladder that is possible but for a bigger wall the center is to far away. And i like to use it also when the wall (or ladder) is not straight up.

I would add something that would represent the orientation and centre position of the ladder itself like an empty entity.

That way, you can use it to correctly rotate the player object along the ladder.

1 Like

Yes, I think that’s the easiest way to do it. Only drawback is that I need a collider with a rotation point for each side of the wall.

It is possible to make a climbing system in playcanvas i think not sure but i think this code will work for you

 this.entity.y = this.entity.y;
this.entity.collision.on("collisionStart", this.onCollisionStart, this);
if (onCollisionStart === true && !Grounded) {
   this.entity.y = +1;

but sorry don’t forget the ending curly bracket ‘}’