Search Unity

Using Unity for generating stuff in my own engine

Discussion in 'General Discussion' started by DuckJab, Jan 3, 2021.

  1. DuckJab

    DuckJab

    Joined:
    Mar 1, 2019
    Posts:
    9
    I've been using unity for my current project (been working for 2 years on it). The game is based on rollback netcode which is why I had to write my own systems (animation, particle, physics, etc.), unity's system don't work with this type of netcode. The way unity is written. It doesn't work good enough for me (it works, but not good enough). So I made my own engine and just made an implementation of unity classes so all my systems work in my engine (Monobehavior, gameobject, transform, vector3/2, etc.) So now I can use all my unity code in my own engine. But.....
    I also made a meta files and scene parser. So I can still use unity as level design tool + I can make prefabs of my entities (main player, npc, multiplayer enemy, local enemy, ai, etc..) and read it in my code instead of building entities in code.

    So... when my game is put out on the internet. Is it still a game that's made with unity (since unity is in my technology stack) or not?
     
  2. DuckJab

    DuckJab

    Joined:
    Mar 1, 2019
    Posts:
    9
    If anyone is interested on the topic. Rollback netcode is a peer to peer netcode type that allows you to play on very long distances without any lag. I play rollback games from EU to USA(west-coast) with 0 lag(it feels like offline play)

    Here is a full explanation
    https://ki.infil.net/w02-netcode.html

    We are used to server based netcode because of how popular fps/tps & mmo's are.
    But those are games where every player has their own camera. So even tough other players are not 1-1 mirror on your screen, it doesn't matter. As long as it feels good and fair. But in fighting games and platformers where you do share screen. This is horrible. You want 1-1 position sync. And doing this with a server is too laggy. Which is why most AAA studios use either delay based or rollback netcode.
     
  3. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,620
    You answered your own question. Yes. You're using the tool to make your game, whether or not you're using the runtime bit in particular.

    Aside from licensing, it's pretty academic though.
     
  4. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,770
    Hmm, so you wrote game engine around networking solution, instead of choosing appropriate network solution for your project? A bit odd choice.

    I am sure selecting, or even writing own network solution, would take you far less than 2 years.
    Isn't that old Unity networking is obsolete now?

    When you say Own Engine, what did you use to write it? I assume you still are using Unity?
     
  5. DuckJab

    DuckJab

    Joined:
    Mar 1, 2019
    Posts:
    9
    :D, The problem is rollback netcode is the best network solution in my case. Go to any fighting sub on reddit and ask whether or not they would play a fighting game without rollback netcode. The answer wil be 90% no. The fighting game community has played games with all sorts of different (server based, lockstep, delay based, rollback, etc.). The general consensus is. Use rollback netcode or we won't buy. It's much harder to implement but like I said. I can play poeple in WEST-USA from Europe without single ms of delay, it feels like I am playing offline. While in any other type of netcode I can't even play from West-europe to East-europe.

    To the engine thing. I had written an engine using c++ and glfw and interop using dllimport. I have a component called renderer that I attach to entities. And give it a sprite. It's abstracted well, I am planning on moving this to monodevelop/fna and replace the dllimport with spritebatch.draw(texture) method inside monogame/fna. I am still learning monodevelop/fna tough so that'il take time.

    (p.s. there are AAA games releasing with delay based netcode, besides smash, dbfz & tekken(this one uses mix of delay based and rollback). All AAA games are played less than indie games with rollback. because that wat the community prefers.

    Also 2 years is me working on this whole project. The gameplay, 3d models, sprites and the engine. Not just netcode
     
  6. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,770
    Just as interesting info you mind find, Unity DOTS networking solutions offer roll back and lag compensation. There is GDC technical talk, which describes details, how system works. Topic discusses solutions for packages transfer, lag, duplication, loses, prediction, etc.

    Now, regarding your engine, you really need look into Unity licence for more details.
    I am not convinced, if Unity allows you to grab its libraries, to create new software. As any other software would state as well.
    Unless you have appropriate licence and permission I think.
    I would expect, that for free licence as an example, you may be obligated to use Unity starting up splash screen and whats comes with it. Including telemetries. Bypassing otherwise, may be in breach of the licence.

    Even using Unity game engine to build a game, or application if you like, to allow crate games, without needing of using Unity Editor directly, is very thin line, in terms of licencing. There was one game with Unity diapute while ago, which allowed players to create own mni games withing, or something like that.

    But I am not a lawyer.
     
    Kiwasi likes this.
  7. MDADigital

    MDADigital

    Joined:
    Apr 18, 2020
    Posts:
    2,198
    We made our own rollback without needing our own game engine. The server chooses a accepted highest ping (default 100 ms).

    Than our ballistics engine which executes on server and client will rollback the state to match the ping of the current client and simulate a ballistics frame. We also group all ongoing ballistics so we try to minimise how many rollbacks we need todo (if all players shoot straight up its slot of bullets in air). Since our ballistics are deterministic (we share seeds) we do not need to network ballistics. The server only is authoritive when it comes to hitting players and dealing damage.

    Our game also is physics based for example throwing items, doors etc. This is solved with client side physics that are validated on the server for cheating (so a grenade can't magically teleport to a player and explode). We also have recursive ownership checking so if you open a door and another players items are stacked in front of the door you take ownership of the items when the door touches the items. This works well. There is one issue with that approach. If you throw a magazine to a teamate that is on a slow connection on your computer the magazine will travel past the grabbing hand of the teammate and after 100ms when the slow player have taken ownership of the item it will teleport to the player hand. We have chosen that this is acceptable since grabbing other player items mid air is a bit of a edge case.
     
    SamFernGamer4k and Martin_H like this.
  8. DuckJab

    DuckJab

    Joined:
    Mar 1, 2019
    Posts:
    9
    Rollback netcode is different from using rollback in your netcode algorithm.
    In rollback netcode players only share their gamepad data(ex. left dpad button and X button is pressed for frame 100).
    If player receiving this data sees this and is at frame 105. And sees he simulated the enemies input as no input pressed for frame 100. he goes back to frame 100. and the resimulates 5 frames. So there are no servers.
    This also means code has to be deterministic (which with dot's you can enforce, but this is for the same cpu architecture) So if you want a player with arm to play with player with 64bit cpu (android user vs windows user) this is not possible in unities build in physics & animation system. (you can do it with custom physics and animation system in unity tough)
     
  9. DuckJab

    DuckJab

    Joined:
    Mar 1, 2019
    Posts:
    9
    Rollback netcode is different from using rollback in your netcode algorithm.
    In rollback netcode players only share their gamepad data(ex. left dpad button and X button is pressed for frame 100).
    If player receiving this data sees this and is at frame 105. And sees he simulated the enemies input as no input pressed for frame 100. he goes back to frame 100. and the resimulates 5 frames. So there are no servers.
    This also means code has to be deterministic (which with dot's you can enforce, but this is for the same cpu architecture) So if you want a player with arm to play with player with 64bit cpu (android user vs windows user) this is not possible in unities build in physics & animation system. (you can do it with custom physics and animation system in unity tough).

    Altough I don't use any unity library. Like I said I do use unity in my technology stack to create levels.
    I don't have any problems with showing an Unity splash screen. Or sharing revenue on my 100% free game. My problem is. What if my engine's quality doesn't hold up to the standards of unity and they don't want my engine to have a Unity splash...

    Another thing is, I am planning on writing a propper level editor. (something that resembles Mario makers level editor) in monogame or c++.
    But still... I used unity while developping the game.
     
  10. MDADigital

    MDADigital

    Joined:
    Apr 18, 2020
    Posts:
    2,198
    You need to contact a lawyer and unity for this. We can't answer that.

    Unity animations are pretty much deteministic (if the domain that drives them are) . We have done alot of lag comp tests on our game. We send the clients collider state when it hits a player. We then compare this with the rollbacked state on the server and they match up perfectly eveytime. Though this is a VR game and only legs are driven by animation. Upper body is IK driven by the VR tracker points.
     
  11. MDADigital

    MDADigital

    Joined:
    Apr 18, 2020
    Posts:
    2,198
    Doesn't your solution suffer from the exact same problems classic rollback suffer from.

    In classic rollback client A ducks behind cover but on client B that is 100 ms behind client A he is not yet in cover and the bullet hits. On client A machine he now dies 100 ms after he ducked into cover.
     
  12. DuckJab

    DuckJab

    Joined:
    Mar 1, 2019
    Posts:
    9
    Yip it suffers from this. But even in the worst case. You need to consider that 100ms ping with server based netcode is not the same as peer to peer. When you have to sync two players using server. your total round trip is player a's ping to server + player b's ping to server. so if both players have ping of 100ms, this is a total of 200ms on server based netcode to sync 2 players actions.
    If you haven't ever played fighting games/platformer games, this is something that you need to keep in mind. With that said 100ms is so small of a time that most humans can't even notice it. I play poeple from eu to usa often using Fightcade (emulator with rollback netcode) and I don't notice a lot, even tough I notice a bit. Now if it's implemented badly you will notice it alot. An example of this is street fighter V. They have a terrible implementation and it has a lot of teleporting because of this. (
    ). A good example is Skullgirls. In that game I if both players have ethernet(wifi is bad for this type of netcode). You can't notice anything even at 250ms ping. And there is no lag and no input delay. It feels like if your playing offline with a friend next to you.
    This is why in the case of rollback netcode you want to build your engine(system if you're using unity/unreal) arount the netcode to hide such things to stil look natural.
    One example is don't update UI immediatly. For ex you punch and on your screen get a YOU WIN text for 5 frames. But then you rollback and apperantly the enemy was guarding so You didn't win, but got a YOU WIN for a split second.
    You need to design your UI to delay every change by amount of ms ping you have. Or another example In animation you can fade to the new animation instead of playing directly (you can do this in unity, but not in unreal for example).
     
  13. DuckJab

    DuckJab

    Joined:
    Mar 1, 2019
    Posts:
    9
    The animations might be deterministic. But have other problems. In rollback netcode you want to be able to run your game logic multiple times in singel frame. The problem here is animations are updated after c# code is executed.
    So if I run 5 ticks of code in single frame. In every tick position of my characters hand & rootmotion will be the position of the where the character was before the current frame. And after the code execution is done. Unity will update the root motion and the animation 5 frames amount.

    So if I rollback 6 frames and executed 6 frames in a single frame with exact same input the output would different to when I rollback 5 frames and execute 5 frames with same input. Which means altough the animation is deterministic for single tick execution. Its not for multi tick. This example is easy to fix by saving limb and rootmotion positions to a dictionary per frame, disabling rootmotion in game and using the saved values with custom rootmotion script. But it's just an example of a system you have to write to make it work
     
  14. MDADigital

    MDADigital

    Joined:
    Apr 18, 2020
    Posts:
    2,198
    How do you handle cheaters without a server? But yeah a server will mean more lag.
     
  15. MDADigital

    MDADigital

    Joined:
    Apr 18, 2020
    Posts:
    2,198
    Yeah I get it. This wouldn't work in a complex game like a shooter you have so much more moving parts. We choose only to rollback the important events, in our case ballistics which means we only look at dynamic object colliders and rollback these.

    Edit: since unity animation is deterministic at frame 100 on server and client colliders will match up

    Edit: it might would work for a shooter but the server needs to be very beefy to handle the load which increases hosting costs.
     
    Last edited: Jan 3, 2021
  16. DuckJab

    DuckJab

    Joined:
    Mar 1, 2019
    Posts:
    9
    Since you are only sending input data cheating is a bit harder. You can't just send the server a false position data for example, or I headshotted playe with id 5793. The type of cheat you can do is doesn't matter a lot & sometimes its easy to detect.
    Ex. you made a cheat that automaticaly guards if enemy is pressing uppercut. But this is easy to detect. You can detect where the input comes, if its not a gamepad/keyboard it's a cheat. But you can also know it by 2 other things. 1 if the player always presses 2 frames after enemy is pressing uppercut. It's humanly impossible to always guard exact with same amount of frame delay. You can fix this by adding a rng amount of delay. But even then you have to be within a margin because. In fighting games some moves come at 7frames, these are moves that do low damage and you can't start a combo on hit. But these moves are something a player needs to predict because no human can react to a 7 frame move. If always presses guard after a 7frame move; that's blatant cheat. Pressing couple of times by luck sure. But as I said these are prediction moves. You are close, to your enemy so you can exept a 7frame jab. So you are already guarding before the enemy did the move. With that said. Some AAA games have cheater problems tough.

    But if there is an anticheat detecting impossible situations. The only thing you can make is an AI. since it will react to actions within a givin amount of random delay. And it can't always do the most optimal thing because that would blatant.
    And after playing couple matches it would have it's own rank where the AI is playing against other players with the same amount of correct decision % and reaction speed
     
  17. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,770
    How you suppose to know that, either on the opposite client, or server?
    You would need send additional data, that "this is input device".
    But then, if input can be cheated, that info about input device also can be cheated.

    If you mean anti cheat on the same machine, where cheat comes from / is installed, that also can be tampered.

    More over, many cheats are just input emulations. Which adds another level of complexity in detection.
     
  18. DuckJab

    DuckJab

    Joined:
    Mar 1, 2019
    Posts:
    9
    Like I said. You can only manipulate input data since that's the only thing getting synced. In this case you can only write an AI. You can also write a one button execution for combos. But this can also be done with macro's wich is not cheating(it's a cheap tactic tough). But In the case of you AI. It will win until it reaches it's own, rank at wich it will have 50% win loss rate as al players when they stale in their rank. If you ever watch Pro players stream on twitch. The will catch some cheater here and there. It won't matter for them since they are playing as if they are playing any other player, and would have 50% chance of winning if it staled at it's rank. I have seen pro players murder these cheats with ease.
    And in a case where the AI only does 100% correct choices all the time. This is a clear cheat.
     
  19. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,770
    What you describe, it is much more sufisticated, than just
    I expected check during gameplay, rather based on results of the match.

    But sure, you can check rankings for comparison and even train AI. That assuming game is popular enough, to be wroth spending effort on such counter measures.