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
Cursed Castle : Princess and Shadow
2D Platformer
Status | Prototype |
Author | Tanpanama |
Genre | Platformer |
More posts
- Completed Inventory ScriptJan 08, 2018
- Devlog Week 13 - Adding New Decoration AssetDec 31, 2017
- Devlog Week 12 - Adding Enemy Character SpriteDec 31, 2017
- Devlog Week 11 - Creating Main Menu, Option, Credit, Story, Splash ScreenDec 12, 2017
- Devlog Week 9 - Storyboard & Cutscenes ConceptNov 27, 2017
- Devlog Week 8 - Adding Item in Inventory & Inventory UINov 19, 2017
- Devlog Week 7 - Added Inventory System & Discussion About AssetNov 13, 2017
- Devlog Week 6 - Main Menu, Option, Splash Screen Layout & Modified ScriptNov 06, 2017
- Devlog Week 5 - PrototypeOct 30, 2017
Leave a comment
Log in with itch.io to leave a comment.