- Home /
Problems making a smash bros like camera
I am trying to make a camera that acts like the camera in super smash bros.
It will keep all players on screen by moving horizontally and vertically, and by zooming in and out.
(edited for brevity. click the history button if you need to see it for some reason)
Any help would be appreciated. Thank you in advance.
I don't have time to test it, so I'm not sure if it's the only problem, but you shouldn't be using else if
in your zoom function. In the event that the first object tested is the highest x or y, it won't register because it was already counted as the lowest.
The else if statements should definitely stay. After all, if the player position is already smaller than the $$anonymous$$imum, there's no need to compare it to the maximum as well.
the "else if" usage is utterly meaningless, if even needed it would be "else" in that situation. however that's quite irrelevant as the script is just generally not really right, at all. this script is so bad it's best just to be deleted for the sake of the future readers. $$anonymous$$unchy has given a great answer below
Answer by Munchy2007 · Dec 20, 2015 at 04:49 PM
The Tanks tutorial has exactly this type of camera, you should be able to adapt it to your needs quite easily.
Answer by Zoelovezle · Dec 20, 2015 at 11:22 AM
My suggestion : You need to do tutorials provided by unity http://unity3d.com/learn/tutorials
public bool canFocus = true ;
//You could play with the zoomValue in inspector in play mode
[Range(1f , 100f)]
public float zoomValue ;
private Camera _camera ;
void Start()
{
if (!_camera)
_camera = Camera.main ;
}
void Update()
{
if (canFocus)
{
//call the function from below as per your camera ;
}
}
//Orthographic projection is used for 2D games
void FocusInOrthographicView()
{
//See your Main Camera setting If the projection is set to Orthographic use this
_camera.orthographicSize = zoomValue ;
}
//Perspective projection is used for 3D games
void FocusInPerspectiveView()
{
//Is the projection is set to Perspective use this
_camera.fieldofView = zoomValue ;
}
all these comments are correct but you could have stopped at "read the Unity tutorials" ;)
I just sent you five "reward points" for making such a big effort! $$anonymous$$erry Christmas
He had uploaded a script , i just wanted to correct it and give some hint over camera .....
Your answer
Follow this Question
Related Questions
How to make camera zooming with a range? [C#] 0 Answers
Making camera follow upwards 3 Answers
Pinch zoom 0 Answers
Issue with my camera controls 0 Answers