[SOLVED] Make entity constantly look at player

I am trying to make an entity that will constantly look at a player (I am going to make the entity chase the player but first I need to make sure it’s looking in the right direction). I tried using lookAt, but I might be using it wrong. Here is my code:

var Chase = pc.createScript('chase');

// initialize code called once per entity
Chase.prototype.initialize = function() {
this.player = this.app.root.findByName("playerEnt");

// update code called every frame
Chase.prototype.update = function(dt) {

What is it that I am doing wrong?

Hi @cyron! Please check the topic below.

@Albertos So I tried adding this.entity.rotateLocal(0, 180, 0); after this.entity.lookAt(this.player.getPosition()), but still nothing seems to be happening. What I had meant to say in the original post was not that it was backwards, but that nothing was happening at all.

Your script seems to be correct. Is the script attached to the entity?

1 Like


No, it isn’t.

It is now. It works.

Thank you!

1 Like