Skip to main content
added 1327 characters in body
Source Link
House
  • 73.5k
  • 17
  • 188
  • 276

Just go really simple. Add a flag to the player that tells the camera when they're jumping. If they're jumping, don't follow them up.

The other situation you need to handle is when the player jumps up or down to different levels. In this case it would be pretty simple to start tracking again when the player touches down, or if the player goes below the starting position of the jump, the camera will start following again.

For keeping the camera in bounds, you have a few different options.

  • Create a bounds object that the camera tests before moving to ensure that it doesn't move outside. This is a quick and easy thing to implement, but only deals with the camera position, and not the view frustum. This means you might have to do a lot of tweaking to the bounds to make sure it doesn't see anything outside the bounds, and gets tricky-er if you have any kind of zoom. To implement this, you can create a number of objects with bounds, add them all to the same layer, something like CameraBounds, then, when testing a new position before moving there, do something like a physics overlap sphere (passing in the CameraBounds layer mask) to make sure the new position is inside one of your bounds objects.
  • Unity has a method called OnBecameVisible. You can place objects near the outside edges of your level. When these become visible to the camera, they tell the camera to stop tracking in that direction. This'll take some tweaking to get a smooth feel, but would ensure that no matter the zoom or camera position, you wouldn't see anything outside the level.
  • Finally, you have a predefined path. This is a path that the camera will "gravitate towards". The camera will also follow the character, but the farther it gets from the predefined path, the less effect the character's position has on the camera position. This will likely give you the best results, but is also probably the most work.

Just go really simple. Add a flag to the player that tells the camera when they're jumping. If they're jumping, don't follow them up.

The other situation you need to handle is when the player jumps up or down to different levels. In this case it would be pretty simple to start tracking again when the player touches down, or if the player goes below the starting position of the jump, the camera will start following again.

Just go really simple. Add a flag to the player that tells the camera when they're jumping. If they're jumping, don't follow them up.

The other situation you need to handle is when the player jumps up or down to different levels. In this case it would be pretty simple to start tracking again when the player touches down, or if the player goes below the starting position of the jump, the camera will start following again.

For keeping the camera in bounds, you have a few different options.

  • Create a bounds object that the camera tests before moving to ensure that it doesn't move outside. This is a quick and easy thing to implement, but only deals with the camera position, and not the view frustum. This means you might have to do a lot of tweaking to the bounds to make sure it doesn't see anything outside the bounds, and gets tricky-er if you have any kind of zoom. To implement this, you can create a number of objects with bounds, add them all to the same layer, something like CameraBounds, then, when testing a new position before moving there, do something like a physics overlap sphere (passing in the CameraBounds layer mask) to make sure the new position is inside one of your bounds objects.
  • Unity has a method called OnBecameVisible. You can place objects near the outside edges of your level. When these become visible to the camera, they tell the camera to stop tracking in that direction. This'll take some tweaking to get a smooth feel, but would ensure that no matter the zoom or camera position, you wouldn't see anything outside the level.
  • Finally, you have a predefined path. This is a path that the camera will "gravitate towards". The camera will also follow the character, but the farther it gets from the predefined path, the less effect the character's position has on the camera position. This will likely give you the best results, but is also probably the most work.
Source Link
House
  • 73.5k
  • 17
  • 188
  • 276

Just go really simple. Add a flag to the player that tells the camera when they're jumping. If they're jumping, don't follow them up.

The other situation you need to handle is when the player jumps up or down to different levels. In this case it would be pretty simple to start tracking again when the player touches down, or if the player goes below the starting position of the jump, the camera will start following again.