Newbie question: how to use setActorToFollow?

20 views
Skip to first unread message

Alex Rudenko

unread,
Nov 18, 2017, 6:58:32 AM11/18/17
to excaliburjs
I am doing the following:

game.input.keyboard.on("press", (evt: any) => {
  console
.log('here')
  ball
.once('update', () => {
    ball
.vel.setTo(50, 50);
 
});
});


game
.rootScene.camera.setActorToFollow(ball);



And I am expecting to the camera to follow the ball as it moves. But it's not working (the ball moves and leaves the viewport eventually). Could someone explain how to make it work?

Erik Onarheim

unread,
Nov 18, 2017, 11:05:17 AM11/18/17
to excaliburjs
Hi Alex, 

I can't fault you, the documentation is wrong here sadly. I've opened an issue to address this https://github.com/excaliburjs/Excalibur/issues/908

In order for `setActorToFollow()` to work the base camera needs to be replaced with a new implementation called `ex.LockedCamera`. I have a pen with an example here: 


Let me know if this works out for you.

Cheers,
Erik
Reply all
Reply to author
Forward
0 new messages