Scion2D C++ Game Engine | Ep.47 - Contact Listener (Part 2): Contact Listener Lua Bindings

Опубликовано: 06 Апрель 2026
на канале: JADE-ite Games and Programming
187
15

🎮 Scion2D Update – Finishing the Contact Listener and Adding Lua Bindings!

Welcome back everyone, my name is Dustin, and this video is a direct continuation of the last contact listener video.

In this video we will do the Lua Contact Listener bindings and we will also add the contact listener to the physics world.

We also quickly go over how to add new systems in lua without having to make any changes to the engine code.

We do this by creating the event manager, collision events, and the trigger system. Eventually we will move the events to the engine; however, this was just to show that we can add external capabilities using our lua scripts.

There was also some small challenges at the end of the video.
Challenge #1:
There is an issue with our implementation of ObjectData where it will not take into account touching multiple contacts at the same time.
We need to add a way to hold on to all the contacts that we are currently touching by adding them in on begin contact and removing them on end contact.

Challenge #2
Since we created the trigger system and added the hole triggers, the challenge is to set the transform of the player back to the start position if they touch those triggers.
You will need to use the physics set_transform(). However, the set_transform does not always work correctly with *box2d*, so I recommend adding a slight linear_impulse right after changing the transform.

Ok give those a shot and if there are any issues, just ask in the comments and I will try my best to help.

The code is available on GitHub and I have also started to work on the documentation for the Engine.

You can check out the docs here:
https://dwjclark11.github.io/Scion2D_...
The docs are still a work in progress, I will be adding more in as we go.

🔗 GitHub Repository
Explore the project here:
https://github.com/dwjclark11/Scion2D

💬 Join the Community
Chat, give feedback, or get help on Discord:
  / discord  

📺 Watch the Full Playlist
Catch all the videos in the series:
   • Build a 2D Game Engine in C++ | Scion2D Ga...  

👍 Like the video and subscribe for updates!
💬 Questions or ideas? Drop a comment below—I’d love to hear your thoughts and suggestions