Enemies field of view rendering and detection
Hi all!
Today I come with a big update/change on the development of the 3D platformer. After the demo, I have realized that the project as it was initially thought, it will require a lot of time on 3D art and level design which I honestly do not have. Therefore, I came up with an interesting idea to reduce the amount of art needed and to give a shift to the gameplay. Since we are in the prototype phase, it is good to explore different options and honestly, this would make a big difference in favor to gameplay.
I am moving towards a more stealth-based game. I want to keep some of the core mechanics, such as climbing, pushing, grabbing... but the levels will be much smaller and the strategy/stealth will play a major role. To realize this change, I started working on the enemies field of view. My idea is to add enemies with a similar system to the series of games Commandos or Desperados, but still keeping the AWSD movement for the player. I am still not sure what will be the behaviour of the enemies once they detect the player. I would like that the player can still react and hide, but not freedom to run across the enemeis. In any case, let's dive on the topic of the fields of view!
How does the field of view rendering works?
Rendering the field of view is done via the shader. In my case, the ground shader is in charge to draw the field of view. The most challenging part is the collision detection. You can find several tutorials were the collision is solved by raycasting multiple times and creating/adjusting a mesh accordingly. However, that can be expensive and innacurate. I opted to follow a different approach based on rendering the scene to a depth image from the position and direction of the field of view, which can also be expensive, but it is much more accurate and there are tricks to reduce the computational cost. This process is done for each different field of view and that is why it can be very expensive. However, you can wisely chose what is necessary to render. By properly filtering unnecessary objects in the scene, this rendering process should not be too expensive. These depth images are further used in the fragment shader to check if there is an obstacle between the fragment to draw and the origin of the field of view. In that case, we won't paint the field of view. The other constraints are rather simple, by defining a radius and angle for the field of view, we can easily obtain the cone-like shape.
In this video, you can see the current state of the field of view. You can see that the collision detection works quite well, it still needs a lot of improvements in terms of visuals, but it is a good starting point and sufficient for testing it. The enemy is very simple and quite buggy. It just follows the target and loses target quite fast when out of view, but it was useful to test that the detection works as intended.
I hope you enjoy this devlog and I hope to have a build soon with an interesting level were to test the stealth idea!
Thanks for reading and watching!
Get 3D game project
3D game project
3D game development project using the OpenTK framework
More posts
- Implementing a spawnable attackAug 02, 2024
- New enemy visuals and covering mechanicJul 26, 2024
- Implementing an inventory systemJul 19, 2024
- Graphics upgradeJul 13, 2024
- Prototype level designJul 02, 2024
- Implementing world events and cutscenes systemJun 21, 2024
- How game development process looks like when using a custom-made game engine.Jun 18, 2024
- Testing stealth prototype game mechanicsJun 17, 2024
- Demo of the prototype available to download!May 25, 2024
Leave a comment
Log in with itch.io to leave a comment.