Last active
December 29, 2015 17:38
-
-
Save Buravo46/7705034 to your computer and use it in GitHub Desktop.
【Unity】2D用の、ターゲットのx,y座標とカメラのx,y座標を同じ値にするスクリプト。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class CameraChasingTargetScript : MonoBehaviour { | |
// Target Object | |
public GameObject targetObject; | |
// Use this for initialization | |
void Start () { | |
} | |
// Update is called once per frame | |
void Update () { | |
// 現在位置をPositionに代入 | |
Vector3 Position = targetObject.transform.position; | |
// Z軸修正 | |
Position.z = -8; | |
// 現在の位置に加算減算を行ったPositionを代入する | |
transform.position = Position; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma strict | |
// Target Object | |
var targetObject:GameObject; | |
// Use this for initialization | |
function Start () { | |
} | |
// Update is called once per frame | |
function Update () { | |
// 現在位置をカメラ座標に代入 | |
transform.position = targetObject.transform.position; | |
// Z軸修正 | |
transform.position.z = -8; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment