- Home /
How to align camera when character goes off screen
My platform mobile game has a maximum of only 8 platform on screen. there are more above the screen. the camera can't see all of it. I want to make the camera follow the character when I reach a certain point.
There's a spawn point all the way at the top of camera that drops water. If the camera scoots up, how do I scoot the spawn point up with it too?
If anyone can help, I would appreciate.
screenshot of my game:
Answer by Olgo · Apr 15, 2015 at 02:59 AM
The spawn point, is it a gameObject? If so, I would make it a child of the camera at its current position. That way, it will always move with the camera, and always be the same height in relation to the camera.
To move the camera once the player reaches a certain point... there are many ways you could do this. The first and simplest way that comes to mind:
Look up "Camera.ScreenToWorldPoint"
http://docs.unity3d.com/ScriptReference/Camera.ScreenToWorldPoint.html
This allows you to choose a point on the screen, then convert it to a point in your game world. You could compare the character's position.y value vs the screen to world point's y value. If the character is above that point, move the camera up.
yes, the spawnpoint is empty gameobject that spawns a prefab water. it's placed slightly above the camera's view. If i move the camer up, the water will then drop halfway on the screen and that's not right.
In the Heirarchy view, drag the spawnpoint on to the camera, it will become a child of the camera, and maintain its position in relation to the camera as the camera moves.
Your answer
Follow this Question
Related Questions
Calibrating Accelerometer Values 1 Answer
New to unity -1 Answers
Mobile touch input conflicts 1 Answer
Isometric camera skybox not working. 0 Answers