Hello
I did not want to continue writing my problems inside the https://forum.playcanvas.com/t/playcanvas-physics-extension/13737 topic to not make it dirty.
I am trying to use the physics extension above to create a boxCast underneath the player which I could get it to work however there is a problem with the raycast detecting the player entity constantly.
code of the isGrounded function:
PlayerJumping.prototype.isGrounded = function () {
let halfExtents = this.playerCollision.collision.halfExtents;
let start = this.playerCollision.getPosition();
let end = this.entity.getPosition();
this.jumpRaycastStart.copy(start);
this.jumpRaycastEnd.copy(end);
// make adjustment to start and end points
//this.jumpRaycastStart.y += -;
this.jumpRaycastEnd.y += 0;
const result = this.app.systems.rigidbody.boxCast(halfExtents, this.jumpRaycastStart, this.jumpRaycastEnd);
let colliding = false;
if (result && result.entity.rigidbody && result.entity !== this.entity) {
colliding = true;
}
else {
colliding = false;
//return;
}
console.log(result.entity.name);
console.log(result);
// debug
this.app.drawLine(this.jumpRaycastStart, this.jumpRaycastEnd, colliding ? pc.Color.GREEN : pc.Color.RED);
return colliding;
};
As recommended in the topic of Mr LeXXik I made sure the player only jumps if the raycast result does not return the player entity which is the current entity (this.entity) but the player entity is detected by the convexcast and because of that sometimes the player is not able to jump when pressing space. I do not want the player entity being detected by the raycast. I tried to debug the issue but I do not know what I am looking for to fix this.
Below is a video of what I mean: How do I eliminate the player being detected by the convexcast which makes the player not able to jump when pressing space?
Project link: https://playcanvas.com/project/926851/overview/jumpcast
Thanks