5 years ago

Working on adding a local co-op mode to my latest game, Clive vs Hives Reinfected. It has been quite a fun but also slightly tedious experience. I will go into more detail on certain struggles and solutions in the article... #cvhr

https://gamejolt.com/games/clivevshivesr/509134


One thing that is quite hard upfront is getting controller inputs to work properly, some programs will let you do this fairly easily off the bat. Other programs may force you to download a plugin or code it completely yourself.

Another small but pretty manageable struggle is getting multiple HUDs for each player. This may vary in difficulty depending on your HUD layout, and you may need to change it accordingly.

Finally, one of, if not the hardest thing I have found while making a co-op mode is that you need to program a way for enemies to choose which player they actually target, it probably sounds simple to someone who doesn't make games but it is really not. How I did it was this:

coop1.png

Each enemy has 3 variables. Player 1 Distance, Player 2 Distance (this can be done with more players, you just need to add more values) and Preferred Player. Basically, P1Dist and P2Dist will, every frame, have to update their value to [insert equation that calculates distance between specified player]. Then, the code needs to compare which is the closer, and set the Preferred Player value to that player (1, 2, 3 e.t.c). You must then set it up so that the enemy will attack whichever is the preferred player (how you do this will depend on how enemies work in your game, but that is the general gist of it).

Thank you for reading, I hope you learned something handy that you can use in future for your own multiplayer experience!



2 comments

Loading...

Next up

Biblios: Tome of Darkness will be coming to Steam, Itch, and Game Jolt on the 2nd of September, 2024.

Devlog 5 | Campaign Intro and Original Soundtrack

Clive vs Hives 2 released on Game Jolt and Itch https://gamejolt.com/games/cvh2/769843

Quests inspired by @WhitethornGames ' Spray Paint Simulator entered your quest log!

Bring color to the world! Restore worn-out surfaces with a fresh coat of paint & watch them come back to life.

Play the free demo to get started: https://bit.ly/spraypaintsimdemo

New Campaign - "Escape from Delta Base"

Happy #WIPWednesday! Are you working on a game? Making some art? Practicing a song? Something else? Tell us in the comments!

Biblios: Tome of Darkness Now Available on Steam, Itch, and Game Jolt

Devlog 6 | New Weapon, Powerups, and Secrets

@WhalesAndGames is a Jolter to Watch and an indie studio who creates positive, polished games and art brimming with whalistic personality! Follow @WhalesAndGames before the quest ends on May 20 and you'll get Coins!

Devlog 7 | Cities, Dungeons, and Monsters