例えば対象物がシーン上のオブジェクトPlayerだとして、オブジェクトをPlayerと同じ傾きにしたい場合、オブジェクトにアタッチしたスクリプトで以下のようにする。
1 | using System.Collections; |
2 | using System.Collections.Generic; |
3 | using UnityEngine; |
4 | |
5 | public class TestObject : MonoBehaviour |
6 | { |
7 | private GameObject player; |
8 |
9 | // Start is called before the first frame update |
10 | void Start() |
11 | { |
12 | // プレイヤー情報を取得 |
13 | player = GameObject.Find( "Player" ); |
14 |
15 | // 傾きをプレイヤーと同じにする |
16 | transform.rotation = player.transform.rotation; |
17 | } |
18 | |
19 | // Update is called once per frame |
20 | void Update() |
21 | { |
22 |
23 | } |
24 | } |
コメント