前提・実現したいこと
オブジェクトのy座標が0の時オブジェクトを十字キーで左右に動かせる機能を実装中に以下のエラーメッセージが発生しました。
発生している問題・エラーメッセージ
Assets\Player.cs(13,13): error CS0029: Cannot implicitly convert type 'float' to 'bool'
該当のソースコード
C#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4 5public class Player : MonoBehaviour 6{ 7 8 public Vector2 SPEED = new Vector2(0.05f, 0.05f); 9 void Update() 10 { 11 Transform myTransform = this.transform; 12 Vector2 pos = myTransform.position; 13 if (pos.y = 0) 14 { 15 if (Input.GetKey("left")) 16 { 17 pos.x -= SPEED.x; 18 } 19 else if (Input.GetKey("right")) 20 { 21 pos.x += SPEED.x; 22 } 23 } 24 } 25}
試したこと
unityの公式サイトなどで調べましたが難しくて理解できませんでした。

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/02/27 01:57