I heard all physic engines have problems with high speed flying object, bullet for example, but it happens frequently when i throw a ball towards wall, Any rescue?
Thank you.
I heard all physic engines have problems with high speed flying object, bullet for example, but it happens frequently when i throw a ball towards wall, Any rescue?
Thank you.
Yeah, that is a common issue. The problem is when an object moves so fast that the distance it travels between each update call is greater than the width of the object it should collide with. If it’s for something small like a bullet you can use raycasting to see what it has hit. But since you mentioned it’s a ball, you will likely have to use something that covers a 3D volume instead. I don’t know if this is the preferred way but you can use Physics.CapsuleCast each update to see if there is something that it should have hit. You would just record what the last transform.position vector was from the last Update method and use that with the current transform.position along with the width of the ball and loop through any and all objects that happen to collide inside of there.
You could also use the current position with the (current position + ball’s velocity) to determine what area it may pass through in the next frame. … P.S. I am working with Unity 3 beta and I am not sure if Physics.CapsuleCast is available in previous versions. If not, or if there is a better suggestion, someone else please chime in, because I need to fix this for my current project too.
Thanks ShiftyMcCan,
I’m using Unity 2.6, the Physic.CapsuleCast is not available at this version.
Actually i know whether the ball will collide with the wall or not as soon as i throw it since simple motion like this can be resolved by Newton’s law, what I/we really want is the response of the ball colliding with the wall (especially when collide with wall corners).
Two methods can be used here but none of them are suitable :
Any suggestions? Thank You.
NT.
Thanks cerebrate,
It works, Thank you.
That is more or less what I was talking about in the first post. The only issue I see with this is that a ball is much smaller than a ray and there are cases where collision should happen but it won’t. For instance, if the ball shoots past a wall with the center point barely above the wall, the ray will not hit it since it is only checking if there are any obstructions between the center point of the object. Now, that is just a matter of taste with how accurate you want your simulation/game. With it moving that fast maybe the user won’t even see that issue and not think twice about it. But I guess if you wanted more accuracy you would have to wait for 3.0 for CapsuleCast.