Quantcast
Channel: Community | MonoGame - Latest topics
Viewing all articles
Browse latest Browse all 6821

Odd behaviour bounce

$
0
0

@MuntyScruntFundle wrote:

Yes folks, another bonce problem.

The code I have for calculating bounces is working 99%. Just every now and then one or both colliding objects decide to head off in an incorrect direction.

I have read somewhere (a while ago) if you're performing collision testing with many objects you need to run the collision code, then check that there are no other collisions around these objects before continuing your loop. I can't remember exactly what that article was so I'm not sure if it applies here. And the tree created for checking this would probably pop my head.

I haven't watched for hours, but I know this is happening between two objects heading towards each other without the interaction of any 3rd object. It's seemingly random and not reliant on any particular angle.

Could someone please have a quick look and tell me what I'm doing wrong, or at least not accounting for?

Many thanks...

` m1.Position = m1.LastGoodPosition
m2.Position = m2.LastGoodPosition

                    Dim n1 As Vector2 = Vector2.Normalize(m2.Position - m1.Position)
                    Dim n2 As Vector2 = Vector2.Normalize(m1.Position - m2.Position)

                    m1.Direction = Vector2.Reflect(m1.Direction, n2)
                    m2.Direction = Vector2.Reflect(m2.Direction, n1)`

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 6821

Trending Articles