How would I go about

Hey, I have a question on how I would implement a certain feature, right now I’m drawling blanks on ideas so I figured why not start a topic n ask others…

I’m making Super Mario Bros And I want to implement the camera the way they do it but I’m not really sure how to start it out. Click the Link above to see the orginal, Here is a screenshot of my WIP

Here is the webplayer https://dl.dropbox.com/u/36346467/WebPlayer.html

What I thought I could do is put a collider on the camera and and set it up so if the player moves outside the collider the camera moves with him. This would cause alot of problems with other colliders in the scene and be very messy. I thought about making the camera a child game object but this also doesn’t seem to be a very good idea plus the camera follows the player even when he jumps.

So what are some ideas you guys have?

Why would that cause problems with colliders in the scene? The camera collider should be a trigger, and it should be on a different layer to scene colliders.

Mario’s camera is actually pretty complex, though. The camera has different behaviours depending on context, which I assume is set based on triggers or zones within the level. So that could be worth checking out, too.

Ok, so we can actually do this pretty simply, angrypenguin is right that the real one is likely more complex than this. We can make the assumption we have an orthographic camera. (A given.) So let’s just set up some zones. Basically, we can tie the camera to follow our character only in the “x” direction. Then we imposed screen edge limits that override this base functionality so that if we’re near an edge, the camera stops. Not too difficult to code just those behaviors.

Edit: We could code for “y” as well based on triggers, but probably not necessary.

Zones? What do you mean? Setting up a collider for a zone? Go on more about your idea please. The Screenshot is an actual screenshot of my WIP. try the webplayer demo…

@angrypenguin Would the collider on a differen’t layer be able to collide with the character controller on the default layer? If i set up the collider as a trigger it could work… I’ll think on it more when i wake up… Any more suggestions?

EDIT: I know the camera is complex that is why I want to work on it before I work on anything else, without the camera the other core mechanics wouldn’t be useful…

Well, considering we’re using a 2D orthographic camera, we could actually use coordinate positions to keep the camera from passing certain points.

rotationY += -movementLookX;
rotationY = Mathf.Clamp (rotationY, -70, 70);
camera.transform.localEulerAngles = new Vector3(rotationY,0,0);

That’s a snippet of the first person camera control, it limits your vertical view so you can’t look too high or too low. A similar system could be applied to the camera’s x-coordinate.

I think I get what your saying I could make a certain distance where if the player moves past it the camera moves with the player at a similar speed…
I am very tired I’ll think about this more in the morning… I was working on what I have above all day trying to get the animations and what not just right, Its been awhile since I’ve worked on a project in unity I’ve been studying C++ so Im having some trouble adjusting back to Unity…

If you need any help, feel free to shoot me a PM on the forums.

Will do…I’ll work on it tomorrow morning… Does anyone else have any idea of how I could set up the camera I’d like to keep my options open with more than one concept…

anyone else with any other idea before I start working?

This wasn’t that hard. and I didn’t even use either method you guys suggested… here is the method I used…

if(position.x > mainCamera.orthographicSize){
			Debug.Log(mainCamera.orthographicSize);
			mainCamera.transform.position += new Vector3(cameraMoveSpeed * Time.deltaTime,0,0);
		}

Really I could have made

mainCamera.orthographicSize

a variable and then used that in the condition check, I just might i’ll see what happens…