http://bosukete666.blog.fc2.com/blog-entry-292.html?sp
こちらのサイトを参考にしたスクリプトですが、Update内の
(Mathf.Abs(Vector3.Distance(this.view_camera.transform.position, this.old_pos)) > 0)
の意味がよく分かっていない状況です。
ご教授願います。
using UnityEngine; public class BackGround : MonoBehaviour { public float speed = 0.9f; public GameObject view_camera = null; Vector3 old_pos; void Start() { Vector3 p = this.transform.position; this.old_pos = this.view_camera.transform.position; this.SetPosition(); } void Update() { if (Mathf.Abs(Vector3.Distance(this.view_camera.transform.position, this.old_pos)) > 0) { this.SetPosition(); } } void SetPosition() { Vector3 p = this.transform.position; Vector3 v = this.view_camera.transform.position; this.transform.position = new Vector3(p.x + (v.x - this.old_pos.x) * this.speed, p.y + (v.y - this.old_pos.y) * this.speed, p.z); this.old_pos = v; } } コード
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/01/21 09:15