Unityについてです。
下記のスクリプトのように、オブジェクトのy座標をbunsekiのy座標に揃えたいのですが、
うまく動いてくれません。何が原因ですか?
コード
float positionにはBunsekiのY座標がちゃんと反映されています。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Attack1 : MonoBehaviour
{
GameObject Bunseki; // Start is called before the first frame update void Start() { this.Bunseki = GameObject.Find("bunseki"); } // Update is called once per frame void Update() { this.Bunseki = GameObject.Find("bunseki"); float position = this.Bunseki.transform.position.y; transform.position = new Vector2(-6,position); Debug.Log(position); }
}
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/04/05 04:01