###わからないこと
unityで玉転がしを作りました。
ステージから落ちるとスタート地点へ戻るようにしました。
しかし、坂で落ちるとスタート地点に戻った後、謎の力で押されます。
平らなところで落ちるとそのようなことは起こりません。
using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerController : MonoBehaviour { public float speed = 3.0f; int count = 0; void OnCollisionEnter (Collision col) { if ( col.gameObject.CompareTag ("Goal")){ Debug.Log("GOAL!"); } } void Update () { Vector3 pos = transform.position; if (pos.y < -10){ count++; Debug.Log(count); pos.x = 0; pos.y = 1.5f; pos.z = 0; transform.position = pos; } if (Input.GetKey ("up")) { transform.position += new Vector3(0,0,speed*Time.deltaTime); } if (Input.GetKey ("down")) { transform.position += new Vector3(0,0,-speed*Time.deltaTime); } if (Input.GetKey ("left")) { transform.position += new Vector3(-speed*Time.deltaTime,0,0); } if (Input.GetKey ("right")) { transform.position += new Vector3(speed*Time.deltaTime,0,0); } } }
回答いただけるととてもうれしいです。
宜しくお願い致します。
###追記
The referenced script on this Behaviour is missing!
The referenced script on this Behaviour (Game Object 'player') is missing!
このような警告が出ていました。
あと、坂を上るだけで、落ちなくとも押されてしまいます。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/06/12 01:52