Hi,
I am trying to make 3d smooth tetris. However, objects are passing through others. I created a small project to simulate this.
Project can be downloaded from: https://dl.dropboxusercontent.com/u/2118263/object-passing-through.zip
Here are the notes:
- There is a plane, a static cube and a moving cube.
- Static cube has position = (4.5,0.5,0), rigidbody, box collider, freeze position, freeeze rotation, no gravity and “Finish” tag.
- Moving cube has position = (0, 0.5, 0), rigidbody, box collider, continous dynamic collision detection and Mover Script(below).
Moving cube was moving towards Static Cube, and onTrigger enter, i set the speed = 0 and log the position. The output is “Entered position @(3.6, 0.5, 0)” however I expect it to be exactly “Entered position @3.5, 0.5, 0)”. Can you explain why it cannot enter the trigger exactly @3.5.
Because of this problem, I also started to think about not using collisions. Any suggestions to make a 3d smooth tetris?
Thanks.
public class Mover : MonoBehaviour {
int speed = 5;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void FixedUpdate () {
rigidbody.MovePosition (rigidbody.position + Vector3.right * speed * Time.deltaTime);
}
void OnCollisionEnter(Collision other){
if (other.gameObject.tag == "Finish") {
Debug.Log ("Entered position @" + rigidbody.position);
speed = 0;
}
}
}