当我碰到另一个物体时,我试图让一个物体改变方向,但由于某种原因,当物体击中物体时,原始物体静止不动。
using UnityEngine;
using System.Collections;
public class playerController : MonoBehaviour {
public float c =0;
public float a =0;
public float d =1;
private Rigidbody rb;
void Start ()
{
rb = GetComponent<Rigidbody>();
}
void OnTriggerEnter(Collider other) {
a = 0;
c = -1;
d = 0;
}
void fixedUpdate ()
{
transform.Translate (c*1f, a*1f, d*1f);
}
}
答案 0 :(得分:3)
试试&#34; FixedUpdate&#34;而不是&#34; fixedUpdate&#34;。