Forum rules - please read before posting.

[Partially solved] 2dCamera doesn't follow player if not on position.x = 0

edited October 2014 in Technical Q&A
------Edit Added
This issue raises only if I set the camera starting x position far from 0.
So if I set the camera start position x at 50 it search the player at 100, not sure why.
------

My default camera follows the player. The offset seems not working on my side, but not a big deal.

Important thing is that when I change the camera the new 2d camera has a bit weird behaviour.

I've the following, in the same scene
- Camera 1 (set as "follow player")
- Camera 2 (set as "follow player")

I do the following:
- I start with Camera 1
- I change to camera 2. I tried with both switch and crossfade.
- The camera doesn't follow player, but it follows something else on the edge on the screen.

I tried the following:
- Set constrains -> the camera stays at the edge of the constrain (leaving out the player if the constrain is far).
- Leave the camera completely free -> it moves in the empty space, very far from the player.

Any idea?

Thank you, as always.

Comments

  • Are you working in Unity 2D mode?  It's likely that you need to keep the camera in the centre of the screen, and use it's Horizontal and Vertical Offset parameters in the GameCamera2D inspector.  Since your perspective is Orthographic anyway, it'll still look the same in-game.
  • Hi. I seem to be having a similar problem to this.

    I am using multiple navigation meshes to run multiple rooms in one scene.
    To change rooms I am using hotspots to set the following ActionList running:
    0) Object: teleport the player, 1) Scene:Change Setting to switch the Nav Mesh and 2) Camera:Switch to change to a new Game Camera 2d for each room.

    In my first room I have a wide room and am using the camera with horizontal constraints to follow the player. No problems there. It follows the player as it should.

    In most rooms the camera fits perfectly so there's no movement necessary.

    In one room, my player object teleports in and if Horizontal Movement Constraints are not checked, the camera flies off to the left.
    If I check constraints camera returns to the room but regardless of whether I put a value in the minimum or maximum constraints, the camera will happily move to the left, but it will not move to the right again. i.e. The player can walk out of the camera's view to the right but it will not follow him, even if max constraint is set to 100

    e.g. minimum constraint -4 maximum constraint 0
    or minimum constraint 0 maximum constraint -4
    both create the same result: the camera shows only the left hand side of the room.

    In another larger room the camera follows the player but with a kind of 'left drag'. It's as if the player is half a screen left of where it appears on the scene.

    It would appear I have made some kind of mistake somewhere. Any ideas? Thanks.

  • To add to this: I have tried deleting the camera and creating a new one with a new name. It continues to behave in the same way, so it must be something else that I have done wrong. Any thoughts welcome.

  • Don't set a maximum constraint value that's lower than your minimum - is your new room to the left or right of the x=0 point in the scene?

    To recreate a problem like this, I'll need real values and settings.

    Create a duplicate of the scene, and then remove all ActionLists so that only those that move the player from room-to-room are left, then create a .unitypackage of the scene, it's graphics, and your Manager files). PM it to me and I'll see what's going on.

    Unity and AC version numbers too, please.

  • OK, so I was getting things in order to package the scene and I thought I should just try centering the rooms in question on the X axis of the unity scene. (I had them laid out following the geometry of the 'house' the game is based in)

    I did this, and the problem went away.

    I wasn't expecting this behaviour, but it has certainly solved my problem.
    Thankyou for your kind offer of looking it over and the AMAZING LEVEL OF SUPPORT generally. Bests.

  • OK. I've come back to this problem in another part of my scene, this time on the y-axis. It seems wise to get to the bottom of it properly this time...

    I'm using AC 1.66.8 on Unity 2018.1.Of2

    As before I have a large scene with several different locations within it. I'm teleporting the player as an object between them. The camera and location in question are centred on the x=0 but not y=0, because I have other locations stacked above it, also using a moving camera in the y axis.

    I have just introduced a ladder for my player to climb, and want the camera to follow him upwards. When I unconstrain the y axis the camera flies off downwards, and when I add constraints the camera won't move between them. It stays locked to the highest value, reagardless of whether that number is minimum or maximum constraint.

    Anything I can try? Thanks.

  • Try unconstraining the y-axis, and then raising the offset to bring the camera back up after flying off downwards. You may need to then incorporate this offset into your constrain values.

    Again, I would need some real values and settings - see my above post for the kind of thing I'm looking for.

  • OK. It was the offset. I hadn't fully grasped what it was for. Thanks. It works now.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.