Unity high speed collision detect

Hi all,
I move a game object by itween and need detect some collision. But the moving speed so fast , so that I can not detect the collision. Are there any way for this solution (don’t change the Fixed timestep). Thanks.

Absolutely. This should get you where need to be:

public LayerMask CastMask;
Vector3 oldPos;

void Start(){
    oldPos = transform.position;

void Update(){
    //Move the object forward here...
    if(Physics.Linecast(oldPos, transform.position, out Hit, CastMask)){
        transform.position = Hit.point;
        //I hit something! Put a script call here...
    oldPos = transform.position;

So, what I’m doing there is moving the object forward, then drawing a line from my previous position to where I am currently and if I’ve found any object in-between we can assume that I should have hit it. Then I store my current position for use on the next frame. Going this route is great, because it means you likely dont need a collider on the moving object (at least for this to work), and it also means your collision detection is driven using the layerMask at the top there. You just need to make sure you set up your layers and check only the applicable ones in the layerMask.

Hope this helps! = )

If you have a rigidbody component attached to your high speed game object, you can set the “Collision Detection” to “Continuous”. Continuous collision detection is recommended by Unity if you are having issues with high velocity objects. Using the Continuous setting will have a big impact on Unity’s physics performance so only apply it when absolutely necessary.

Depending on what you’re trying to collide with you may need to experiment with different collision detection settings. Please refer to the following Unity documentation: Unity - Scripting API: Rigidbody.collisionDetectionMode.

You’d have to do your own collision detection. The problem with this issue is that things don’t really “move” in your game - they jump between discrete points when the frame updates. This means that if they’re moving too fast, they can be on one side of an object in one frame, and jump to the other side when the frame refreshes. There’s nothing you can do about this - it’s just a fact of how computer simulation works.

What you can do is approximate where the object went in that last frame. The reason you’re not getting collisions here is that you’re only testing where the object actually is at any given moment. What you really need to test is all the locations the object was between the current frame and the last one. This is quite a lot more complicated, and you really have to estimate it, since you don’t know for certainty exactly how the object travelled between the two points you have - only that it did. What you’ll really need to do is create some sort of mathematical description of your collider, and “stretch” it between the points, so they it encompasses everything it would have hit in between. Linear interpolation is usually a reasonable approximation, and pretty easy to do, at least for box colliders.

Here’s an example of how it might work, and hopefully it illustrates the problem and the solution reasonably well. For other colliders, you may want to use a more complex method, or just sample the collider with a bunch of linecasts: