Hi there.
I’m trying to make when my player (the one in the red square) moves to the another entity in this case the one in the blue square and the idea it’s to look at that entity but it’s not working. Thanks in advance.
Link to the project https://playcanvas.com/editor/scene/1075435
BtnMenu.prototype.onRelease = function (event) {
//A teletransportarse, ve al getentitydata y pilla el id, si el id es el mismo, manda la posición
//y de ahí debería teletransportarse
var id = this.entity.script.btnMenu.id;
for (var i = 0; i < this.EntidadInformaciones.children.length; i++) {
if(id == this.EntidadInformaciones.children[i].script.entityData.id) {
var position = new pc.Vec3(this.EntidadInformaciones.children[i].position.x,
this.EntidadInformaciones.children[i].position.y,
this.EntidadInformaciones.children[i].position.z);
this.Player.setPosition(position);
this.Player.rigidbody.teleport(position);
if(id == this.EntidadAver.children[i].script.entityData.id) {
var pos = new pc.Vec3(this.EntidadAver.children[i].position.x,
this.EntidadAver.children[i].position.y,
this.EntidadAver.children[i].position.z);
this.Otro.lookAt(pos);
this.Player.lookAt(pos);
this.Player.rigidbody.entity.lookAt(pos);
console.log("Player ", this.Player);
console.log("Otro ", this.Otro);
}