Camera Position ahead of player

Hey, I currently have my SKCamera node centered over my player perfectly in the screen, I am wondering if anyone can help in how I can place the camera node just ahead of player? This is the code I have currently : In GameScene : var screenCenterY:CGFloat = 0 In didMove function screenCenterY = self.size.height / 2 In didSimulatePhysics var cameraYPos = screenCenterY cam.yScale = 1 cam.xScale = 1 Self.camera!.position = CGPoint (x: player.position.x, y: cameraYPos I’m trying to position the player on the left of the screen whilst the camera stays in the middle?? New to Xcode - any help / suggestions are much appreciated. I assume my problem is that I am referencing the player position, whereas I should be taking the coordinators for the middle screen only? My player position has already been defined in the player class at (x: 50, y:250) Thanks, AJ

Replies

If you want your camera to always be at a certain location relative to your player, you can take a look at SKConstraints: https://developer.apple.com/documentation/spritekit/skconstraint
Try just camera position in Y pos, based on player pos + the "offset" you want

Some like this

Code Block swift
camera.position.y = player.position.y + 20


This mean 20 pixels ahead from player y pos.

Hope this help 😎