FYI i am using unity 4.3 and im making a 2d game using the 2d mode in unity.
As you can see in the picture, every time i run the game it runs fine but after a few seconds the camera just rotate away. i have no idea why this is happening it will very helpful if you guys can help me. do i need a camera script? im using c#.
It’s rotating because it’s parented to a rotating ball.
I’d suggest you
Unparent the camera
Write a simple script that follows the position of the ball
Attach the script to the camera
A super simple script that can be placed on the camera is as follows:
using UnityEngine;
public class Follow : MonoBehaviour {
public Transform target;
void LateUpdate () {
if (target)
transform.position = target.position;
else
Debug.LogWarning ("You forgot to set the target", this);
}
}
You’ll need to set the target to the ball for it to work. If you need an offset, add a variable for it or just place this on an empty game object and parent your camera onto that game object and offset it via the inspector (change position).
I have fixed the problem but thank you. I now have a very big problem when I move my character forward and jump but a couple seconds latter the ball goes the opposite direction all of the sudden and the floats away randomly I am so confused