- Home /
Cube moving through rigid body
I have a cube which is moving. Whenever a rigidbody comes in contact to it, it moves the rigidbody out of its path.
However in some of the situations, the rigidBody is in the path of the cube and the cube moves through the rigidbody.
For example as here in the pic, the red is the movable cube and the grey is the RigidBody -
The cube is moving with the script -
transform.position = Vector3.MoveTowards (transform.position, patrolPoints [currentPoint].position, moveSpeed * Time.deltaTime);
Answer by Fallen117 · Aug 04, 2015 at 04:56 AM
Transform has this issue, it doesnt play well with the physics portion of the game.
Double check a few things though: kinematics are not selected,both cubes are perfectly on the some Y plane, either object isnt partially through the floor,
MovePosition is a much happier command to use.
Answer by $$anonymous$$ · Aug 04, 2015 at 07:06 AM
I think you should check with the "moveSpeed", it is calling in update(). so, even though it collides the moveSpeed is updating every frame. Make moveSpeed = 0; when it collides to blue cube, you can use OnCollisionEnter() for it.
Hope this helps you.
Your answer
Follow this Question
Related Questions
how do i make this lag less? 1 Answer
hit.normal cube 0 Answers
Resetting rigidbodies' transform values 1 Answer
Animation or smooth teleportation 0 Answers