Working on scripting and physics

This week I finally got the game to run, although it’s still in a rough shape.   

The first thing I did was to add the scripting library. This didn’t take very long, with only a few compilation issues. Here, there is still some cleanup required to remove the unused platform specific calling conventions. Additional components were also added to support passing and receiving standard strings, which continue being used now for simplicity, and another one that implements calling script functions by passing them as a string.  

Next, I worked on getting the game running. This required enabling some previously disabled systems and debugging the resulting errors, which overall was not too hard.   

first level of the game
(the untextured barrels are normal and a weird effect of the game without played at the lowest setting)

After getting the game working, the first interesting problem was that movement did not work. This was caused by a conversion error in the scripting system which resulted in engine functions always getting false boolean values from the scripting system, even if the value true was specified in the script. The solution was to substitute the GetArgDWord function with GetArgByte if the parameter was a boolean value.  

Next, I worked the bugs in the physics system. The first was that none of the objects could be picked up. This was caused by a call to the NewtonFreezeBody function with a wrong parameter. Now that objects could be picked up, the first apparent problem was that these started to shake as soon as the player interacted with them. The solution here was to adjust the torque values passed into the physics system, which I was lucky to find in the HPL1R project (https://github.com/zenmumbler/HPL1R). Next was the bug of the player being pushed around by some physics objects in the scene. I still don’t really understand the cause of the problem, but the solution, which I got from the HPL2 sources, was to change the value of the normal vectors for some collisions checks.  The final bug I solved this week was that of slider joints (a physics construct mainly used for drawers). The problem was that, in the physics library, the code to initialize some matrices was commented out, resulting in weird and inconsistent behavior.   

Overall, I was lucky with the bugs mentioned above as a solution was already available somewhere else or it came relatively quickly. This streak ended on the last bug. The problem is that the notebook item, which in the original game appears on the desk, does not appear. I’ve worked for quite a lot of time on the issue, but I still don’t feel like I really understand what is going on. The hardest part is that the problem presents itself only for one object in the first level and another in the second while other work correctly without issues. I’ve tried looking at the resource files for these objects, but I didn’t find anything particular about them. Two things I found were that if the objects are frozen, they appear, but much smaller than they should be and without any thickness (the notebook in the above picture is an example), and if rotation and scale are taken away in the initial loading of the objects they appear and interact regularly with the physics, but they cannot be picked up.  I don’t yet have an idea of how these things are connected but I’m extremely curious to find out.  

For next week I don’t have any plans yet, but hopefully I can finally figure out the bug I described above but it’s getting a little frustrating and maybe I’m going to give it up for a bit. 

Thanks for reading.  

Leave a Reply

Your email address will not be published.