Still stuck

Published October 05, 2020
Advertisement

I am pleased to say that I've started a new position. I believe this is going to bring some balance back to my life and ultimately be a good thing for my projects, including this one. My career was pretty badly stuck before, but I've got a foot forward now and a direction to keep pushing in and that's all I can ask for at the moment.

So - collision is still not behaving. Changes include:

1 - GamePageViewModel has replaced the non-threadsafe List<T> lists for controllers, actors, obstacles and sprites with ConcurrentBags. Now GamePageViewModel.EvaluateMovement(), the entry point for collision detection is using the C# Parallel extensions. Instead of a simple for loop

for(var actor in actors_)
{
   if(!actor.Stationary)
   {
       collider.EvaluateMotion(actor);
       actor.Accelerate();
   }
}

We have the multi-threaded equivalent

Parallel.ForEach(actors_, (actor) =>
{
    if(!actor.Stationary)
    {
        collider.EvaluateMotion(actor);
        actor.Accelerate();
    }
});

This will hopefully deliver the same high framerate even in highly populated frames with lots of Actors, freeing up level designers to deliver dynamic experiences.

2 - Instead of checking collision only in the current frame (which often failed) I have created an uncertainty region where the actor could be in this frame based on its direction of travel and speed. This region is just another Game Logic rectangle and I can call uncertainty_region.Intersects(nearest obstacle), since Obstacles also implement the ICollidable interface. Most times this works in the X axis, although I would like to shrink this region just a little because it seems to trigger early. But I am hard stuck on the Y axis. When I make Bob jump, he goes up and then comes down, falls through the floor into the nothingness until he reaches the negative limit of type float and who even knows what his Y coordinate would become then.

I've merged the progress I've made so far into the master branch, because honestly I have changed quite a lot of the Game Logic library and the GamePageViewModel. I've just got to keep slogging away at finding out why these checks work in unit testing but not at runtime. In those odd moments of peace and quiet, such as the shower - I wonder if the fact that collision detection is being executed asynchronously with the UI thread may be part of it? Probably the answer is much simpler and I just haven't made the right Actor.Intersects() function yet. I'll keep plugging away until I have an answer. Would like to move on to new features soon.

  • Adam
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement