- Home /
How does rigidbody works?
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.
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~!
Answer by AllTheGoodNamesWereTaken · Jun 12, 2017 at 08:45 AM
Did you already watch the tutorial on Colliders and Rigidbodies?
Your answer
Follow this Question
Related Questions
Prevent a fast moving ball from passing through a wall 2 Answers
Can you have an OnTriggerX event with Sleeping rigidbodies? 1 Answer
how can i rotate a rigidbody smoothly,how to rotate a rigidbody in a smooth way 2 Answers
rigidbody problem !!! 0 Answers
Rigidbody (2D) stays in fixed angle even when colliding 1 Answer