Unity2DでLineRendererを使って2点間の間に線を引いているんですがその線の挙動がおかしいのです
最初の、座標の絶対値が小さいときは図のようにマウスポインタを表す赤丸に線が届くんですが
下の方に行ったり上の方にすると全く意味の分からないところに線が届いてしまいます。
詳しく書くと下(上)への移動量が大きくなるにつれて挙動がおかしくなります
(つまり座標が下になるほどおかしくなるというわけでは無いのです)
C#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4 5public class TargetController : MonoBehaviour 6{ 7 Vector2 targetPos; 8 9 // Start is called before the first frame update 10 void Start() 11 { 12 13 } 14 15 // Update is called once per frame 16 void Update() 17 { 18 19 //ポインターの位置に照準を合わせる 20 targetPos = Camera.main.ScreenToWorldPoint(Input.mousePosition); 21 transform.position = targetPos; 22 23 } 24} 25
これがコードです
どなたかご教授お願いします
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。