PERP in Unity

Messages
901
Reaction score
2,535
Points
790
Location
Netherlands
So over the past few years I've been working on and off on modules for a game like PERP in Unity3D/C#.

I kept off from creating a post for this as I was unsure where the project was going to be heading, but over the past few weeks I've actually made a few strides in combining these modules into something that is starting to represent PERP more with every update.

If you're interested in following progress, I'll be dropping screenshots here every now and then as stuff actually becomes visual / interactable. These updates are also posted to a Discord dedicated to the project: https://discord.gg/AdACWjmsQc

As it stands, it's mostly just code that is being done, with @Sneaky coming on board to port the Paralake Unreal Engine 4 map to Unity. Any help from people with modelling skills is welcome.
To help out with coding, you'll have to wait a bit since I want the framework to be fully refactored before I let people loose on it, otherwise you'd be wasting time with code that'll need to be changed later anyways, and in turn creating technical debt.

Some really basic screenshots
Screenshot_46.jpg
A simple development UI for the inventory

Screenshot_35.jpg
Chatting basically works identical to PERP's chat system, and has multiple channels that can easily be added by implementing a class, which contains checks the server executes to check e.g. wether you're a government employee or in range for local chat.

Some very early development videos (using assets for testing)
 
Update

Over the past few months I've been refactoring quite some code, and got around to implementing Half-Life 2 style movement, and rebuilding the prop system.

The new prop system is event-ish driven, and automatically networked. This makes implementing certain props really easy, such as the TV shown below.


For an example on how this system works, here is the (still nasty, yet to be refactored for final use) TV source code
You'll note that most code present is solely dedicated to networking and playing the video, and all the logic needed to ensure correct positioning, physics, relevancy, etc. on the client and server side is already taken care of, as it inherits a "Prop" class.

Along with the TV of course, you need a way to play a video. This has been done with a new Command system, this system features standard stuff such as a simple ACL and an easy way to define new commands; just create a new file, implement your command and the compiler will detect it and register it!

An example of a quickly put together !play command

I have also been working on implementing an HTML UI system, reviving the deprecated PowerUI library, which allows for Unity-native HTML drawing, eliminating the need for a headless browser such as Chromium or Servo. The UI you see in the video was written with HTML, and the TV does not depend on Chromium either, rather on native Unity engine components and a self-hosted service for parsing Youtube URL's.
 
Last edited:
Update

So I've been hard at work on using my new toy the HTML UI to build a simple inventory.

Most of the code for the inventory and prop system was already present, so it was just a matter of hooking them up using a Javascript to C# bridge.


There is still a lot of polish to be done, but hey, it's working!

For the technical people, here is some source code on how this is achieved.

Code:
function DrawInventory()
    {
        var items = inventoryModule.Inventory.GetPlayerItems();
        inventory.innerHTML = "";
        items.forEach(function(item) {
            var itemEl = document.createElement("div");
            itemEl.setAttribute("class", "inventoryItem");
            itemEl.setAttribute("data-item-id", item.ItemID);
            itemEl.addEventListener("click", function() {
                inventoryModule.Inventory.UsePlayerItem(item.ItemID);
            })
            var quantityEl = document.createElement("span");
            quantityEl.innerHTML = item.Quantity;
            quantityEl.setAttribute("class", "inventoryItemQuantity");
            var nameEl = document.createElement("span");
            nameEl.innerHTML = item.Name;
            nameEl.setAttribute("class", "inventoryItemName");
            itemEl.appendChild(quantityEl);
            itemEl.appendChild(nameEl);
            inventory.appendChild(itemEl);
        });
    }
    function OpenInventory()
    {
        DrawInventory();
        inventory.setAttribute("class", "inventory");
    }
    function CloseInventory()
    {
        inventory.setAttribute("class", "inventory hidden");
    }

Code:
namespace Era.Modules.Inventory.JSBridge
{
    public static class Inventory
    {
        public static InventoryItemStruct[] GetPlayerItems()
        {
            Debug.Log(NetPlayer.Instance.LocalPlayer.Inventory);
            return NetPlayer.Instance.LocalPlayer.Inventory.ClientGetItems();
        }
        public static void DropPlayerItem(string itemID)
        {
            InventoryManager.Instance.ClientDropItem(ItemDatabase.Instance.GetByID(itemID));
        }
        public static void UsePlayerItem(string itemID)
        {
            InventoryManager.Instance.ClientUseItem(ItemDatabase.Instance.GetByID(itemID));
        }
    }
}
 
Update

So in the past two days I have been working on implementing a weapon system to compliment the inventory system, so you can actually, like, ya know, equip and use weapons.

I'm pretty happy with how it turned out, and to test out it's versatility I decided to implement the one thing I was dreading the most: the physgun.

It's by far one of the most complex weapons I'd have to implement, so I decided to check out if my system was up to the task, or if I was going to run into bottlenecks.

This recording was made from an actual build of the game, and not the editor, so my apologies for the terrible quality.


The physgun currently consists out of nearly 600 lines of code, and has features you'd expect such as rotating, rotation snapping, etc. In addition to all the physgun code, I had to implement a whole lot of "authority" management code to ensure that the server actually allows you to physgun and manipulate objects (if you have the necessary permission, e.g. buddy or a general physgun permission for admins.)

After all that work and tweaking the system I could not be arsed to implement a beam today... so I guess you'll see that when I show some more stuff in the future?

@Sneaky has been making some good progress on porting Parkalele to Unity, and we hope to be able to show you the first build of us walking around in Paralake soon!
 
Update

Whadafack, Parkalale v4 in Unity?
Screenshot_26.jpg

The map
All credit for this goes to @Sneaky , the texturing is just some temporary stuff I decided to play around with. But yeah, basically we have the entire thing in Unity and we are working hard on making it playable!

Vehicle system
This weekend I implemented the first iteration of our vehicle system. It's nothing fancy, but you can now drive a VW Golf... RTU style (you will crash.)

The system is built so that any potential artists that want to jump on board, or assist us in porting TDM can easily configure a car in the editor, such as seat positioning, light positioning, etc. It's all done in the editor without any code required. I plan on making it just as configurable when it comes down to gears, sounds and emergency lighting.

HDRP
This week I will be attempting to implement Unity's HDRP pipeline, which basically boils down to the game taking on the graphical fidelity you'd expect from an Unreal Engine game, but without all the scripting hastle Unreal brings along. This will take a lot of work however, but I expect to have a build using HDRP out to testers within two weeks.

Calling testers and artists
Are you someone who knows their way around Blender, 3DS Max or any other modelling tool? Then we need you! Porting and creating original content takes a lot of work, and we can use all the help we can get.

If you want to help us out by jumping on test builds every now and then, also feel free to hop on our Discord. I crank out test builds fairly often around these days and all bugs that are found early in the development process can't bother us later.

You can join us on Discord here: https://discord.gg/AdACWjmsQc
 
all depends on your pc, but Unity will be far more optimised, so probably yes
 
Update

After long consideration we have decided to switch engine. This choice was not made lightly, as usually switching engines can mean the death of a project if mismanaged.

Our new engine made development so easy and fast-paced however that it seemed like the only logical choice.

From this point onwards, development will continue on Roblox.

You can see the game in action in our new trailer:

We are excited for the course this project is setting, and hope to have a playable version out to you guys soon!
 
The trailer looks dope! Can't wait to play this quality game, I wonder what the gun and drug system will be like! Also paralake V17 looks good!
 
Update (for real this time)

So the past week I've been working on phasing out PowerUI. While I was pretty happy with it earlier, I ran into some limitations that annoyed me a lot, such as the lack of a lot of modern CSS properties and a lack of support for modern versions of e.g. VueJS.

The replacement will for now be Chromium, however I have my eyes on Ultralight which will eventually replace Chromium once version 1.3 of Ultralight comes out. Of course that means pioneering the Unity integration for Ultralight, but hey that's what I've done this week with Chromium (at least a stable, maintained version of an integration that is.)

BYfY6PU.png


As there may be some concerns about performance, I have gone out of my way to make this integration as configurable as possible, you will be able to set a target FPS for Chromium (independent of Unity) in the settings menu, and tweak some more advanced features to ensure that it runs as smooth as possible on your PC.

So I guess that means there will be a major UI update soon. If you are interested in seeing how this was achieved, you can check out the source code of the Chromium integration at https://github.com/coderiekelt/UnityCefSharp. Because of course I open-sourced it :)

NPCs
Oh yeah, I made an NPC dialogue system that is easy for us to implement as well. Creating NPCs and dialogue for them is now as easy as riding a trycicle.

Screenshot_18.png


This was of course easily achieved with this code:
Code:
public class PoliceNPC : BaseNPC
{
    protected override NpcDialogue GetInitialDialogue()
    {
        NpcDialogue dialogue = new NpcDialogue();

        dialogue.SetText("Ah, fresh from the Police academy?");

        dialogue.AddOption("Yes, I'd like to go on duty please!", ShowDutyDialogue);
        dialogue.AddOption("No, I'd like to annoy people as a dispatcher.", ShowDispatcherDialogue);
        dialogue.AddOption("Pew pew pew.", ShowPewPewDialogue);

        dialogue.SetExitText("Hmmm... maybe this isn't for me. *leaves*");

        return dialogue;
    }

    protected void ShowDutyDialogue()
    {
        NpcDialogue dialogue = new NpcDialogue();

        dialogue.SetText("Alright, here is your badge and uniform. Your personal belongings are in your locker, they will be returned to you when you go off-duty.");

        dialogue.SetExitText("10-4, catch you later! *leaves*");

        ShowDialogue(dialogue);
    }

    protected void ShowDispatcherDialogue()
    {
        NpcDialogue dialogue = new NpcDialogue();

        dialogue.SetText("Well aren't you a cheeky one.");

        dialogue.SetExitText("Yes, indeed. *leaves*");

        ShowDialogue(dialogue);
    }

    protected void ShowPewPewDialogue()
    {
        NpcDialogue dialogue = new NpcDialogue();

        dialogue.SetText("What?");

        dialogue.SetExitText("Gun goes pew pew. *leaves*");

        ShowDialogue(dialogue);
    }
}
 
Back
Top