Devlog Week 10 - Camera Improvement


In this week, we already finish the camera script improvement. We already change the camera so it will follow the player anywhere the player go. In previous model we use 2 camera that follow each character, but now we already use 1 camera that will follow the character when player press T (when player change the character from princess to shadow or vice versa). We also attach the script in here : 

public class CameraController : MonoBehaviour {

public PlayerController player;

public bool isFollowing;
public bool progress;
public float xOffset;
public float yOffset;

// Use this for initialization
void Start () {
//player = FindObjectOfType<PlayerController> ();
progress = false;
isFollowing = true;
}

// Update is called once per frame
void Update () {
if (transform.position.x < player.transform.position.x) {

float selisih = player.transform.position.x - transform.position.x;
if (selisih > 8) {
progress = true;
//transform.position = new Vector3(player.transform.position.x + xOffset, player.transform.position.y + yOffset,transform.position.z);
transform.position = new Vector3 (transform.position.x + 24 * Time.deltaTime, player.transform.position.y + yOffset, transform.position.z);
} else {
progress = false;

transform.position = new Vector3 (transform.position.x + Time.deltaTime, player.transform.position.y + yOffset, transform.position.z);
}
} else if (transform.position.x > player.transform.position.x) {
progress = true;

float selisih2 = transform.position.x - player.transform.position.x;
if (selisih2 > 8) {
progress = true;

transform.position = new Vector3 (transform.position.x - 24 * Time.deltaTime, player.transform.position.y + yOffset, transform.position.z);
} else {
progress = false;

transform.position = new Vector3 (transform.position.x - Time.deltaTime, player.transform.position.y + yOffset, transform.position.z);
}
} else {

progress = false;
}
}
}

Get Cursed Castle : Princess and Shadow

Leave a comment

Log in with your itch.io account to leave a comment.