小编Pau*_*ger的帖子

OnCollisionEnter不会触发

using UnityEngine;
using System.Collections;

public class changedirection : MonoBehaviour {

    void OnCollisionEnter(Collision col)
    {
        if (col.gameObject.name == "soldier")
        {
            GameObject go = col.gameObject;
            Move move = go.GetComponent<Move>();
            move.direction = -1;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

碰撞的两个物体都是触发器,抱歉没有统一编程超过一年

collision-detection unity-game-engine

0
推荐指数
1
解决办法
2541
查看次数