I have two block in my scene, block_A and block_B.
block_A has both the rigidbody(no gravity) and a box-collider while block_B only has the box-collider.
I add a SimpleMove script to the two blocks as below:
using UnityEngine;
using System.Collections;
public class SimpleMove : MonoBehaviour {
public float speed = 10f;
private Rigidbody body;
// Use this for initialization
void Start () {
body = GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update () {
if (body != null){
body.AddForce(speed * Time.deltaTime, 0, 0);
}else{
transform.Translate(speed * Time.deltaTime, 0, 0);
}
}
}
I put the two blocks in a line , and set the speed fields of the script so that they could move forward to each other.
[95395-屏幕快照-2017-06-05-下午70945.png|95395]
When the speed fields changes, the results are:
- block_A speed 0 block_B speed 10, block_B will cross block_A.
- block_A speed -0.1 block_B speed 10, block_B will push block_A to the left.
- block_A speed -0.1 block_B speed 100, block_B will cross block_A.
So I don’t understand these.Thanks if you can help me~!