なぜ私の衝突が私のコンソールに「私は敵を撃った」という印象を与えていないのか分かりません。プレイヤーは剛体のコンポーネントを持っています、敵はありません。衝突検出に関する問題
私の敵はtag
敵です。敵は変換を使用して移動しています。私のプレーヤーは剛体のコンポーネントを持っています、私の敵はありません。何か案は?
using UnityEngine;
using System.Collections;
public class PlayerMovement : MonoBehaviour {
public float moveSpeed;
public float maxSpeed = 5f;
private Vector3 input;
private Rigidbody rb;
// Use this for initialization
void Start() {
rb = GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update() {
input = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical"));
if (rb.velocity.magnitude < maxSpeed) {
rb.AddForce(input * moveSpeed);
}
}
void onCollisionEnter(Collision other)
{
if (other.transform.tag == "Enemy")
{
print ("I hit enemy");
}
}
}
敵オブジェクトにはコライダーが取り付けられていますか? – TheDjentleman