- Home /
Rigidbody MoveTo considering collisions
I have a cube with collider and rigidbody on it. Rigidbody collision detection setted on "Continious Speculative" (as i need it to be for another purpose). Walls have colliders on them, and in usual conditions collision detections works ok.
So, the problem is I'm trying to move my rigidbody on fixed calculated distance at one frame (to destination point), considering collisions with colliders. After one fixed frame I disable rigidbody and object don't move anymore. But the problem is it stops before it reach the wall. If I try to move it in this direction again, it come closer. After few attempts it reach it's destination, but I need to do it in one frame.
Moving works ok with "Discreate" collision detection, but it's not considering collisions.
Metod I use to move rigidbody to certain position (vector is calculated for fixed update)
public void MoveIn(Vector3 direction)
{
this._rigidbody.velocity = (direction) / Time.fixedDeltaTime;
}
How can I solve the problem with early stopping?
Answer by Envans · Nov 24, 2020 at 02:32 PM
Try rigidbody.addforce because modifying the velocity directly does not yield good results sometimes.
Or you can even set the velocity to Vector3.zero instead of disabling it so it still detects collisions.
Thank you for answer.
Problem with AddForce (as I suppose) is that behaviour of rigidbody after disabling will be the same (yet I still have to disable it), cause it is will be only change in velocity calculations, but not collision detection.
Source
So, I guess it's not going to work, but I'll still gonna try, thanks.
Your answer
Follow this Question
Related Questions
Handling collision with fast Lerp 1 Answer
Car wheel not detecting ground 1 Answer
Rigidbody is behaving abnormally when transformed manually 0 Answers
Player getting stuck in corners 0 Answers