我一直在試圖讓碰撞工作,但迄今沒有好處。二維碰撞檢測不起作用
這是我moveBall.cs,我把我的球對象。
using UnityEngine;
using System.Collections;
public class moveBall : MonoBehaviour {
float balSnelheid = 1;
void Update() {
transform.Translate (0, balSnelheid * Time.deltaTime, 0);
}
void OnCollisionTrigger2D (Collision2D coll) {
if (coll.gameObject.name == "Brick") {
Destroy(coll.gameObject);
}
}
}
而這是我放在我的Player對象上的movePlayer.cs。
using UnityEngine;
using System.Collections;
public class movePlayer : MonoBehaviour {
public float snelheid;
// Use this for initialization
void Start() {
Screen.showCursor = false;
}
// Update is called once per frame
void Update() {
if (transform.position.x + Input.GetAxis ("hor") * snelheid * Time.deltaTime < 2.9) {
if (transform.position.x + Input.GetAxis ("hor") * snelheid * Time.deltaTime > -2.9) {
transform.Translate(Input.GetAxis("hor") * snelheid * Time.deltaTime, 0, 0);
}
}
if (transform.position.x + Input.GetAxis ("hor") * snelheid * Time.deltaTime > 3) {
transform.position = new Vector3(2.9f, -4.7f, 0);
} else if (transform.position.x + Input.GetAxis ("hor") * snelheid * Time.deltaTime < -3) {
transform.position = new Vector3(-2.9f, -4.7f, 0);
}
}
}
如果任何人都可以給我一個提示/解決方案,將幫助了我很多!
究竟正在發生,而不是要發生什麼?沒有描述,圖片沒有告訴我多少 – 2015-01-09 19:32:19