is there a way to use clamp with physics using math.clamp
?
not using this:
if (this.playerPos.x < -9.0) {
this.entity.rigidbody.teleport(8.8, this.playerPos.y, this.playerPos.z);
}
so not limiting with if (this.playerPos.x < -9.0) {
is there a way to use clamp with physics using math.clamp
?
not using this:
if (this.playerPos.x < -9.0) {
this.entity.rigidbody.teleport(8.8, this.playerPos.y, this.playerPos.z);
}
so not limiting with if (this.playerPos.x < -9.0) {
Yes, you can clamp a pc.Vec3 axis and then pass that to the teleport() method.
var position = new pc.Vec3().copy(this.entity.getPosition());
// sample limits 0 - 20
position.x = pc.math.clamp(position.x, 0, 20);
this.entity.rigidbody.teleport(position);