Camera problem

Hi guys, I’m here again to ask for your help, so let’s get started right away
I am attaching the code, this does not work.

Basically I need the code for the camera that follows the character in all directions.

The game is in the old style RPG style.

There are two strange things:

  1. Your actions are in different events to your conditions and event 14 has X instead of Y
  2. You have numbers (640) where it should be =

It looks like you don’t want the camera to follow the player, but to use a “flick screen” approach where the camera jumps from screen to screen when the player reaches the edge.

Here’s a way to do that:


Event 12 just uses the X and Y position of the player to work out which room you’re in by dividing the player position by the width and height of each room. In this example the rooms are 1280 x 768 pixels in size. If the position of the player’s centre is less than 1280 then the room will be 0. If the player centre is 1290 then the room will be 1. The +683 and +384 set the camera to the desired place in the room - which may be exact centre for you.

You can probably do all this using the camera width and (camera width/2) rather than entering numbers.

(floor(player.X(Centre)/CameraWidth("",0))*CameraWidth("",0))+(CameraWidth("",0)/2)

Hello, I understand the error, in fact the code was taken from a tutorial but what I wanted to do is a different thing.

It is enough for me that the camera follows the character at the bottom and at the top in all directions.

Without the character disappearing from one side or the other.

In your opinion, is it possible to do?

Anyway thank you very much for the screens, they are really useful.

I still don’t get it, why the actions to make a camera to follow an object are not useful for you?, do you need the camera to jump from map to map as Zelda/Pokémon? :confused:

no my idea is this. wait I explain you better, then the codes to be inserted are simple, I need the camera that follows the character, for now I managed to set the camera that follows the character to the left and right the part that is missing is when you move to high and low.

Currently the character disappears this is the problem.

Are you simply saying you want the character centered on the screen? And the camera to follow the character?

If so it’s very easy. Insert a “no condition” event, and in the actions tab, under layers & camera pick the action “Center camera on an object” Pick your character and your good to go.

If I missed the mark, sorry, I misunderstood.

When you say ‘disappears’ do you mean they walk off the screen and the camera doesn’t follow?

There shouldn’t be any difference going side to side compared to up and down, unless there is an error in one direction, like in the event 14 you showed.

I would also suggest trying the “centre the camera on an object” action.

Make the camera to follow the player should be as easy as set the camera position = player position, for both X and Y coordinate. If the X following code is working and the Y isn’t working then probably there is a misspelling, are you using the action to set the camera X position twice or is there a Player. X() that you have forgotten to set as Player.Y()?

About the player disappearing, if it disappears because the camera doesn’t follow it in the Y axis then you just have to fix the following code. But if it disappears for no reason then maybe there is a background with a higher Z-order than the player’s one, covering it :confused:

You can send me your project too :slight_smile:

It was a stupid mistake, really trivial I managed to solve the problem with the following code that I am attaching to everyone in order to avoid this problem in the future.

I forget the most important thing, thank you very much for the answers.