locked
Erratic collision between two simple rects RRS feed

  • General discussion

  • Hi,

     I'm trying to do a simple collision with two Rects, using Rect.Intersect. Whilst the collision is detected, sometimes it's too late (in which case tunnelling occurs), and other times it's perfect or too early. The only catch in my situation is that I'm trying to detect collision with a storyboard. Is this an issue?

    The animation is a simple transformation of the RenderTransform:

    <Storyboard x:Name="Storyboard1">           
           <DoubleAnimation x:Name="daStoryboard"  Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" Storyboard.TargetName="rectEnemy" d:IsOptimized="True"/>
    </Storyboard>

    (The extra parameters are added at runtime)

    The animation runs fine, but then when I run it, the collision is delayed as demonstrated by this image:

    The object stops at that position, which obviously intersects slightly. However, sometimes the collision runs perfectly, or stops a bit earlier. Is there a way to fix this issue without slowing down the Storyboard? I'm checking for collisions in the CompositeTransform.Rendering event. (If it makes any difference, this is for Windows Phone)

    Thanks

    Thursday, August 4, 2011 1:37 PM

All replies

  • Hi,

    The object stops at that position, which obviously intersects slightly. However, sometimes the collision runs perfectly, or stops a bit earlier. Is there a way to fix this issue without slowing down the Storyboard? I'm checking for collisions in the CompositeTransform.Rendering event. (If it makes any difference, this is for Windows Phone)

    Could you please provide more information about your code? Actually, to troubleshoot this issue, we really need the source code to reproduce the problem, so that we can investigate the issue in house. It is not necessary that you send out the complete source of your project. We just need a simplest sample to reproduce the problem. You can remove any confidential information or business logic from it. Then we can find the issue more conveniently and provide further suggestions for you.

    I would recommend that you can use Windows Live SkyDrive to share the sample project.

    Tuesday, August 9, 2011 6:59 AM
  • hello..I am beginner to Wp development.I have created a storyboard in which i am moving an ellipse in some specified direction.Can you suggest me how can i collide this storyboard ellipse to another ellipse.
    Tuesday, November 26, 2013 2:13 PM