I Wanna Community

Fangames => Game Design => Programming Questions => Topic started by: IceFreaki on August 10, 2015, 12:21:39 PM

Title: Camera following player
Post by: IceFreaki 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!
Title: Re: Camera following player
Post by: Derf 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 :~)
Title: Re: Camera following player
Post by: IceFreaki 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!
Title: Re: Camera following player
Post by: Derf 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;