Author Topic: Camera following player  (Read 2583 times)

IceFreaki

  • Trial Wannabe
  • Posts: 4
  • OS:
  • Windows NT 10.0 Windows NT 10.0
  • Browser:
  • Firefox 39.0 Firefox 39.0
    • View Profile
  • Playstyle: Keyboard
Camera following player
« on: August 10, 2015, 12:21:39 PM »
Hey there~

So I'm using the Yuuutu Engine and I want the camera to follow the player.
I've got it working, kinda. The thing is, after the player dies, the camera snaps to the top left of the room.

I had this problem before years ago but I used a different engine where the bow would stay put where you died.
Back then I just made the bow be there in any difficulty and made it invisible and let the camera follow that thing. Worked like a charm.
But in Yuuutu's Engine the bow also seems to go to the top left or something.

Is there any way to fix that so that the camera stays where the player died?

Thanks for the help!
Boop

Derf

  • Guest
Re: Camera following player
« Reply #1 on: August 10, 2015, 03:09:16 PM »
Hey!

There's a board specifically for Game Maker questions now over here https://www.iwannacommunity.com/forum/index.php?board=51.0. You could have christened it as well!

Anyway, to solve your problem create an invisible object called "objCamFollow" or whatever you prefer. Make it invisible and make sure it spawns in every room you want the scrolling camera to work. Set the room to follow this object instead of the player. In the step event of this object put the following code:

Code: [Select]
if(instance_exists(player)){
     x = player.x;
     y = player.y;
}

That should work just fine for you :~)

IceFreaki

  • Trial Wannabe
  • Posts: 4
  • OS:
  • Windows NT 10.0 Windows NT 10.0
  • Browser:
  • Firefox 39.0 Firefox 39.0
    • View Profile
  • Playstyle: Keyboard
Re: Camera following player
« Reply #2 on: August 10, 2015, 04:18:17 PM »
Thanks a lot, works perfectly!
Didn't even notice the board, I'll make sure to post there next time I have a GM specific question~

One thing though, is there a possible fix for the GAME OVER to show up correctly when using that method?
It's not really that bothersome, but the GAME OVER sometimes is a bit offset.

Thanks again!
Boop

Derf

  • Guest
Re: Camera following player
« Reply #3 on: August 10, 2015, 04:29:07 PM »
No problem!

I'd put the following code in the game over object's step event:

Code: [Select]
x = view_xview+400;
y = view_yview+304;