#archived-code-advanced
1 messages · Page 56 of 1
that should make the safety system happy, ye
Thanks
i have a question about inheritance
i have FunkyA, but i want a more specialised SpecificFunkyA that effectively inherits from FunkyA and SpecificABase
the only way i can think of doing it is by having ABase and SpecificABase to be interfaces rather than classes
but i want to specify functionality in them
obviously made up names but i hope ive gotten my point across
If you need this inheritance is the wrong tool for this job
What you want is a GameObject that has a FunkyA and a SpecificABase as separate components
A class can inherit only from one class, but it can additionally implement multiple interfaces. I would suggest changing at least one class to an interface.
composition is much better than polymorphism in Unity
I'd want to implement some functions in SpecificABase so this wouldn't be an option
Composition is always an option
I could potentially make SpecificABase into a ISpecific interface and then just have my SpecificFunkyA inherit FunkyA and ISpecific
But it feels like a cop out as then can't add functionality to the now gone SpecificABase
maybe - hard to say with these placeholder names etc
Yeah yeah ok I'll give the actual concrete examples will be easier 1 sec
i got
ConstructObject : MonoBehaviour
ConstructCore : ConstructObject
these optionally have a ConstructMovement they reference
i need the ConstructCore to have* a ConstructCoreMovement : ConstructMovement and the ConstructObject to have a ConstructMovement
this is all fine for now
however i want a HoverMovement : ConstructMovement
and then consequentially a CoreHoverMovement : HoverMovement, ConstructCoreMovement which is the issue - i cant inherit from both
a Construct being the player controlled "thing" i guess made up of parts
Seems like you could/should have these separate components:
ConstructIdentity
ConstructMovement
HoverMovement : ConstructMovement```
whats the ConstructIdentity thing
maybe should be called ConstructObject
just
whatever the basic things it needs to be recognized as a "Construct"
not sure what a construct is in your game so I'm kinda guessing at what you need here
right sorry shouldve gone higher up
i got a Construct which references a ConstructCore
this core can then in a tree structure reference ConstructObjects with some other stuff
each of the objects in this structure may have a ConstructMovement, which gets sent up to the top level in some priority based system
i need the movement on the core to have additional core specific functionality
1s
ill hack it to get it running and send a clip
(currently i have the HoverMovement just implement ConstructCoreMovement and have it sort of figure out which its on but thats not good at all)
the idea being the crystal is a core which needs a core movement which will provide the animation / logic for making it fly into something else
the rock is an object which just wants a normal movement, and because its not a core i dont want the core specific logic for making it fly into something else
and as you can see each object or core in the scene can have its own movement, which using some priority or other logic the construct will choose between
but obv i want the core movement disabled when its in something
extra complications come from wanting runes to be able to provide movement for the construct but thats a later issue
but back to the original thing, hopefully this gives a bit more context
i mistyped here, i meant to write have not inherits thats prob why i was confused at your reply
mb
composition over inheritance (:
if it helps this is the issue - i need CoreHoverMovement to be a HoverMovement and CoreMovement
current solution is for HoverMovement to inherit CoreMovement and have it figure out if its a core or not but thats dodgy
ty so far everyone for help, i realise this is alot of spam dont mean to fill up the channel
yeah, this is why inheritance falls apart in a lot of situations
for more specifics
HoverMovement handles making the object float, move, and aim
CoreMovement requires some functions for implanting the object and has some functionality
you have Animal and Flyer and Walker
and then, oh no, I need an animal that can fly AND walk
yeah
and Flying and Walking dont affect each other
the only way i can think of doing it with composition is this
CoreAttacher is just generally "the extra things a core needs to do that is Movement specific"
the issue is then it seperates the HoverMovement and the HoverAttacher - I could have the HoverAttacher point at a JumpingMovement for example which is bad and wrong
Is there any way to run an Update() method constantly in the Editor? I need to check if the position of a movable transform has changed. If it has, do something
Yeah so I had that idea originally by using ExecuteInEdit mode which is ideal. I also thought it would be a great idea to put it under a new class, so the main class didn't have to make use of a constant update method. The functioanlity will only be related to this new class
The problem I have is, I need the Serializable list to drag and drop Transforms. Without inheriting from MonoBehaviour, this is fine. However, I need Mono so I can make use of the Update() method. Problem then is I can't view the List in the Inspector for some reason :/
ExecuteInEditMode only applies to MonoBehaviours
You could have the Update() method bail out early if it's in edit mode
Hmm yes i see. Is it possible to serialize in with Mono?
There's a lot of baggage that comes along with MonoBehaviour. It needs to be attached to a GameObject, you don't get inline editing, etc..
you can't just make a class a MonoBehaviour with no other changes to how you treat it
Yes I see. I took this root as I thought there's no way to ExecuteInEdit for just a method such as Update() - I don't want to always execute all parts of the class
@eager verge - Not sure why you deleted your message
You might be getting errors, you need to install the Android Logcat package so you can see them on your computer while the game is running on your phone (works via the USB debugging feature).
In the meantime, code review:
Disposable types like Stream, MemoryStream should be used inside a using statement to ensure that the object is properly freed, even if an exception occurs.
You can use responseStream.CopyTo(memoryStream) instead of the loop to copy stream contents
Hey thanks. Okay, i would check that and related out.
When did i delete my msg?
A few minutes ago, you posted a link to your code of yesterday
Something like
Can anyone help with this? <link here>
oh yeah i see. I didnt do that. Maybe the server did?
Yeah maybe, seems like the last Discord update made it slower, I sometimes have freezes when I type
i was just complaining about that in #531949462411804679
it does seem to be happening in other places too
but i swear it started when i joined here (it IS a very large server...)
Got it working nice. Thanks a bunch! This is what I have - Not sure if it can be done in a better way:
OnEnable() is in the Editor class of GridController. The other two methods are in GridController. I unsubscribe CheckObstacles every time, so I don't subscribe it more than once.
does anyone know how to call plugin (C++) or even burst code the exact moment a camera has finished rendering?
was just giving a go with composition going off that latest diagram #archived-code-advanced message
but i am running into an issue with what is the CoreAttacher in that image not having access to the internals of the ObjectMovement class
does it need to?
sorry didnt finishthat message - was gonna ask your opinions on it all
Can ObjectMovement not expose whatever it needs to expose via public Methods / Properties?
ObjectMovement has stuff for IsTransitioning, IsActive etc
and some SetTransitioning and SetActive functions
which i want to keep relatively internal
the SetTransitioning one specifically
in this case of the hover its relatively benign in that they are all i need - they could prob be public
but in the future i feel i may need more access to specific features of the ObjectMovement, and moreso the specific internals of the matching ObjectMovement
e.g. a LegObjectMovement and a LegCoreMovement
if c# has a friend thing would that work?
All of that can be handled through ObjectMovement's public API
by which I mean its public members
right yes, however i may want my hover core movement to change the hover height or some other private variable, which i dont want any other class to get to
or in the leg one, i may want some private methods and functionality to enable and disable specific legs, which i want to keep internal and private and called by the other movement functions
in which case the core movement for the legs (as i would probably want a core to be able to have this moveset) would need access
to me inheritance solves these issues 1 for 1, but the the multi inheritance issue from before comes back
oh
i can make it a nested class
but idk if i would then be able to add it as a component
Doesn't LegMovement inherit from CoreMovement?
well LegMovement would inherit ObjectMovement cos it would be able to go on anything
but id need a CoreLegMovement for handling Core specific movement stuff like attaching and detaching from whatever
which would inherit CoreMovement
but i need CoreLegMovement to access internals of LegMovement, which makes sense to be an inheritance thing but then ye
before you get too deep into this
oh see I'm not sure I understand what CoreMovement is vs ObjectMovement
it sounds like you are discovering that platformer movement code is tightly coupled
all of the movement behavior and input for platformers, it's all tightly coupled
yeah
right yes sorry - ObjectMovement basically allows you to call Move() and Aim() on a thing and controls an object, (makes it hover, or walk, or hop) and control as youd expect
CoreMovement is tightly joined with a specific ObjectMovement, and is for allowing a Core to attach / detach from some other object
currently its just these 2 bits but may need more in the future
e,.g. this
it is not possible to make this decoupled and extensible. you would disguising a tightly coupled method by spreading it out meaninglessly over bits and pieces of classes, and recreating the idea of a method by putting order and/or various state flags on these different classes
@desert scroll does that make sense
mb sorry, dont see what youre suggesting
based on the screenshot i saw, it looks like you move a character with with a joystick, who has the capability to become physics-driven-joined to other objects
yes effectively
and you want to seemlessly transition between different kinds of movement too, like hovering, X and Y
this is all very, very tightly coupled
i assume you want this to feel good
you can certainly put a class on an object that says what kind of movement it will have
and some movement types can be used by a core, hence this debate currently
but the actual behavior will probably live in one class
that is what i'm saying. it is indeed a tightly coupled big giant class
what do you mean 1 class
you will write a class called TomsterPlatformerMovement
and it will deal with the translation of inputs to movement and physics in your game world
and the different kinds of objects it can move
really? i dont think so
e.g. this is hover
i am trying to tell you it is already one class
you havev just spread it out, for only increased bugginess and complexity, across multiple classes
i'm not saying you can't do this
you can. you can make your code worse
i am not stopping you, and you can prove to me that you can do an already hard thing even harder
are you saying they should both be in the same class and have an if statement around each them?
and thats less error prone?
i am not writing this for you
i am saying you are already doing that
but in different classes, for the aesthetic experience of having multiple classes
no but, im just trying to understand your view point as i am sure you have a valid set of reasoning i just dont get it yet
which is a legit instinct to follow in all cases EXCEPT when you are trying to make movement for platformers
you have spread out your if statements across classes
using the type system
for no gain
you will almost certainly have a if (movement is HopMovement hopMovement) somewhere
you are checking types somewhere, i am confident
right?
nope
if you are not going to have an is in this approach
you are going to reinvent is
which is even worse
to deal with bugs
you are already in some sort of jeopardy
i don't even know what issue it is you are trying to fix yet
it isn't clear
like is there something broken?
that you are trying to improve?
i can explain that in a sec, just want to understand youre on about with the is issue
this bit specifically
wdym
what i am trying to say is because this is tightly coupled
if you are going to spread stuff out across a class hierarchy
somewhere, something is going to need to leak a little out of your abstraction
one way that can happen is using is
like you and i don't decide if it's tightly coupled, the problem does
does that make sense?
you cannot will this thing to not be tightly coupled
unless it is not important that the movement feels good
yes i get what you mean, but i dont think this is tightly coupled in the way you think
the issue youre referring to is solved directly with inheritance and interfaces right
then all you need is an interface saying theres a move() function and the top level doesnt care how it happens
the issue itself is an aside to all of this
what is the issue?
I have a Movement class that looks like this
and then a HoverMovement, HopMovement, in the future many other movements
you're saying there are no bugs?
not in any of that na
1 sec lemme explain the issue im having
okay
the ConstructObject has a derived class of ConstructCore which wants extra functionality out of this Movement class, concretely a way of attaching and detaching
this is obviously gonna be dependent on the matching ConstructObjectMovement
initially my approach was for ConstructCoreMovement to inherit ConstructObjectMovement
however here is the issue
i sent this earlier too
i want a CoreHoverMovement
a class with the functionality of the HoverMovement
but promises extra functionality that the Core can use
you can create a class CoreHoverMovement that contains two fields, one referencing a CoreMovement and the other a HoverMovement
so a core still needs a ObjectMovement to be able to move around, just also wants to be able to call Attach and Detach and have this be specific to the type of movement it has
may have a hopping Core, whose attachment is to jump in the air then dig into the thing
or hovering Core, which is the video i showed
and i suppose you can put in a bunch of logic in it
you can make things easier by making this simpler and not trying to spread out this behavior
which is kind of my point
yeah so thats the approach ive changed over to, and that goes back to this intial quesiton this second time round
well. like i said
here
what is coupled with what sorry?
okay
let me put this differently
you are writing a giant method, whether you like it or not
containing what
it doesn't have to be a giant Update method, in fact it can be evented
the thing that translates user inputs into movement in your game
right ok
you are writing a giant method
it's already happening
right now, you have spread out your method into bits and pieces
that is 1 way to describe inheritance, but yeah sure
into this elegant hierarchy
no
i am only talking about your problem
i am not describing inheritance
right the core / object thing?
i am only talking about what you have done to approach translating player inputs into game movement
yes
you have celebrated in the elegance of this approach
but it is not complete
and in order to complete it you are going to have to finally, maybe now, use a thing in an ordinary method that doesn't exist in a class hierarchy
and you have no idea how to do that and neitehr do i
right
if i were you... use a method.
what
who knows what idiosyncratic reason you've managed to get this far
do you see what i mean?
it's just good luck
...there are methods at the bottom
it was always not the way to do platformer movement
theyre just seperated into meaningful sections, it just felt like semantics was holding me back
and it is only because the physical objects in my game all have distinct movements
if 1 character in my game was able to do all of these things then yeah sure
but ive got control of 2 distinct things, they have 2 distinct behaviours and therefore 2 distinct classes
it doesnt make sense to have this in 1 class?
i do want to understand what youre saying, im sorry if it seems like i dont
its just to me it seems like youve come in and said oop bad and said good luck
i appreciate your help tho
i think your game looks really cool btw
that's why i'm so excited to see you thrive lol
yeah
i feel you
i'm trying to think out to solve this well lol
1 class may be an exaggeration, but it is certainly mean to be a call to action
like what can you do / what tools do you need
to express what you need in the body of method
so that it's a lot simpler
in the right ways
that's not saying much
but method overloading has its limitations
in my experience doing that approach, you wind up with composing two classes into one class, and creating way more overloaded methods
to deal with all the edge cases
it's like writing an if statement across the type hierarchy
methods already have if statements
if you can do all the movement functionality imperatively in a function it's easier
this is why i personally use async wherever possible, it is even better than the mindfuck of the reactivex (unirx) code i used to write and advocate for
right so the less convoluted way would be for the hover movement class to also have the core functionality (attach detach), and if statement what type of object / core it has (so cant attach if only an object and not a core)?
doesnt that introduce a type check which is like rule number 1 dont do ever
the dreaded is check you mentioned
the thing is, yes - this is exactly what inheritance is surely
and that is the point?
it is yeah
maybe what is going on here, like trying to combine these two complex movement behaviors
like if you did it with delegating between two instances
i don't know... you'll end up moving a lot of code around and maybe actualyl it will get better
maybe you do need a "class with a bunch of static methods that can be used for composing movement behaviors in the framework you already have"
so i would maybe just shuffle out the valuable part of the hover and core movements into something stateless, and then you can use it where you need in a corehovermovement
without it needed to actually inherit from either coremovement or hovermovement
does that make sense
i understand what youre saying
as an additional thing, in the future i may need this CoreHoverMovement to have different functionality based on what it is attaching to
whatever is really valuable and tricky in your game maybe move into stateless methods, which you can do with refactoring flawlessly in your IDE
yeah
e.g. carefully move to the centre of some contraption
howevever that would be handled as an if statement in the Core half of the hover code
yeah
so that would also move into "a stateless method" and core and hover and whatever else can provide the state for it. sometimes what i do in my code that works like this is create e.g. an IPositionContext which instead of implementation-detail leaking things like Move and StopMoving it has Begin and End
if that makes sense
and i have a RigidbodyMovingContext : IPositionContext and a TransformMovingContext : IPositionContext
and an IPosition doesn't require you to know how any of that works. it is methods that are always called at the same times in your larger method or whatever
that's basically virtuals
the difference is you don't have to inherit anything
a more concrete error i hit a while ago which spurred my initial frustrated cry for help
i have a canUse boolean on the base ObjectMovement which basically says whether the movement can be enabled or used or whatever, and could be to do with not having enough objects in your construct or whatever
however core movement needs to override and extend this to also block it if the core is attached
my issue was when getting canUse on a hover that is just for Objects it would try and get the CoreMovement version of this function (because ObjectHover extended CoreMovement) and it would throw issues
i realise that may not be immediately understandable but just thought id give the context
however core movement needs to override and extend this to also block it if the core is attached
this makes sense to me as a pain point. like you are doing the gradual overriding thing
this is totally valid
my issue was when getting canUse on a hover that is just for Objects it would try and get the CoreMovement version of this function (because ObjectHover extended CoreMovement) and it would throw issues
yeah i think a library of stateless functions will solve this
a lot lotta games have that
looked something like this
in the CoreMovement when it derived ObjectMovement
another thing is that a CoreMovement has to reference a single ConstructCore, whereas an ObjectMovement does not have any requirement of referencing any objects and is derived class dependent
so i may have some SnakeMovement in the future which references multiple Objects, which obviously can not be a CoreMovement
thats another one of the reasons for the approach ive gone for
if i had a big array of static methods eg
HoverMove
HoverAim
HoverJab
HopMove
HopAim
that just feels like incredible messy
what if i need a Hover thing to keep reference to some particle generator?
passing state to a static function feels like a complete regression
Hello, I've been learning how to save files using this video playlist by Trever Mock. https://www.youtube.com/playlist?list=PL3viUl9h9k7-tMGkSApPdu4hlUBagKial
In his videos he has 3 separate save slots using folders with a Json file inside, where he loads all of them at the same time to show the statistics on the menu screen.
The system I'm creating in my game is a bit different, because I am making a diary app: I have several diaries that each contain their own daily entries. When I open a diary, I want to load the most recently written page but if I press some arrows I can flip through previously written pages. Every diary page can be decorated with images and writings, so I need to be able to load only the decorations of the page you're looking at. Every page has a save file whose name is the date of when the page has been created.
How can I create a saving system where I load the diary page files by taking them from a folder? I don't want to load all of them at the same time, but only the file of the page I'm currently looking at when I open the diary and flip through the pages.
i apologize that went completely off the rails, if youre still unsure then nw
hmm
Save & Load System
Why even if I use RuntimeHelpers.PrepareMethod, in the profiler I can see Mono.JIT in that specific method?
https://gdl.space/uzicaxibun.cs
can anyone help me in detecting entities near my cursor using overlapsphere
correct me if I'm wrong but seems like
[Preserve]
is only for guarantee this certain block that had been marked with it won't get stripped,
so if that's the case then what's the whole point of it?
since let's say if I'm using Reflection, but the actual code I wrote did get preserved, but not the reflection itself inside somewhere else
because currently my issue is some of my code that used Reflection got stripped after build
I am curious, has anyone found a use for Records (or RecordValues) that's not covered by scriptable objects?
Only unreachable code will be stripped. If your Reflection code is in a MonoBehaviour that's included in the build, then it won't get stripped, for example.
Wouldn't say it's advanced. But you are sending in a scalar as the end point where you are supposed to send in a point in space. Then you are checking first if you hit something to do an overlap sphere which might be ok or not depending on your setup.
For iOS, can you create a dynamic library of the code of a Unity Game? and then load it in runtime? For Windows I create an asset bundle of the dll and then do assembly.load. But I dont know how to do something similar for iOS.
All the code needs to be in the app when it's installed. It's signed specifically so apps can't dynamically execute new unknown code, as a security measure.
But for example, Interpreted code such as lua works, right? so If I download lua code from the app I could execute it. The problem the code is in c# and not lua.
Yes, interpreted languages work. C# can be interpreted, but usually isn't due to performance. And you definitely can't load it into the same runtime as Unity, because on iOS that would be the IL2CPP runtime, which doesn't include a .NET interpreter.
[General Question] How do people go about making AI for gridbased combat? Do you train a neural network?
Behaviour Tree or FSM.
FSM?
Finite State Machine
Ahh
I don't think that's a common thing to do. I don't think the general approach differs greatly for grid based games, other than they might be more likely to use influence maps to help with pathfinding and decision making.
If this is a general question why is it not in #archived-code-general 🤔
Neural Network is way to much unpredictable and inefficient to be use as a reliable AI.
Point taken
That's what I was thinking
Thank you both for sharing your knowledge ☺️
What is more, is that lots of approach are made to "win" which is not what you want in a video game setup.
I think it all depends on how complex your AI will be. If there are a multitude of combination of actions you might want to look into utility and goal based AI as well.
What's the best way of doing 2D pathfinding nowadays? Haven't dabbled with this in years... 🤔 Search results are very.. inconclusive.
I'd start with the AI Navigation package
if NavMeshAgents wind up not fitting your use-case, then you can look into something weirder, I guess
ok, thanks. So the only solution is to have all the code I need in project, before I build it? I cant add c# code after (for iOS) ?
Yes.
Hi. I have a project and recently switched to using dlls I created from my scripts. My problem now is I have missing components everywhere after I deleted all my scripts and just rely on just the dlls. Is there a way to fix this or do I have to re-add all the scripts to my prefabs and objects all over again? (I would assume this is because the metas are pointing to the scripts which are missing).
You can either replace the scripts by hand or search and replace the GUIDs in the .prefab/.unity files.
Is there any way to change a component to an inherited version of itself? I had a bug script, and I want to retain the inspector properties, of which there are many, when changing it to an altered, inherited version. Previously, you could change the Script field in debug mode, but they seem to have blocked that off (asking again, because I didn't get an answer in another channel and I would really like to get the bottom of it)
Shown here:
Unity 2022.2.11
Might be able to add the script and just copy the values from the older one.
Does this happen with all scripts?
Technically you could open its asset file, find the GUID that matches GUID in .meta of your old component, and then change it to the GUID from .meta in your new component. It's kinda troublesome tho.
Perhaps you could somehow automatize it with a script that searches the GUID references and replaces them for you.
Would that change all references or just the component on the desired object?
It would change the component and keep all the references that exist in both components. You can make a back-up file if you're not sure.
Being able to paste from parent to child class would be a nice QOL feature
Records are just syntactic sugar to write a very common type of POCO, and you get bonus language level features like with.
So yes, whenever you want to use POCO rather than scriptable objects, there's a good chance records is a good fit.
i need to check out records
public class BaseClass<T>
{
}
public class SubClass<T> : BaseClass<T>
{
}
public class Test<T> {
BaseClass<T> baseobj = new BaseClass<T>();
void Test() {
FieldInfo fieldInfo = this.GetType().GetFields()[0];
// how to create new instance of SubClass<T> using fieldInfo here?
}
}
can someone help me? 
this guy uses OnDrrawGizmos to update procedural geometry as you change the value in the inspector. the system uses jobs. it works in play mode but breaks all the time in non-play mode . what's the proper way to do that sort of stuff?
you need to construct a generic type first
@elder pagoda see examples here https://learn.microsoft.com/en-us/dotnet/api/system.type.makegenerictype?view=netframework-4.7.2
actually ignore you already should have the type in the field info
just pass it to activator
no im wrong you still need to construct generic type
since its T, you need to provide concrete generic arg
I'm trying to create a multiplayer game with a Peer-2-Peer connection using a host and clients:
Connecting the players is done using unitys lobby service
And then for actually sending the packets I'm using the relay service
But I want to do make a responsive gun (with actual bullets), ofcourse using the relay makes for a delay of 0.25s, which is way to much
So I'm trying to figure out a solution, the things I've got going are:
- UDP Hole Punching
- Spawning the bullets on the clients
- Client-side predictions
But I've encountered a few problems:
For: Spawning the bullets on the clients
I believe unity netcode for gameobjects doesn't allow clients to spawn gameobjects?
For: UDP Hole Punching
I've found a way to create a hole and connect a client to the host
But how can I let the host reply using the hole (that the client made)
This drawing explains my problem (see below)
(In purple) Unity uses the ip-address send with the package (I think) and replies using this
While I want to use the (in red) ip-address which has a passthrough
For: Client-side prediction
I think it will get really messy and feel "laggy" in a different way
As the idea of the game is to have lots of all different kinds of physics-based bullets
Trying to predict them client-side will be wrong a lot of the time
So the server will have to correct the client way to much
i feel like these are two completely unrelated problems
direct peer-to-peer will not ensure that your latency is below a threshold
it might reduce the latency, sure, but you are absolutely going to have to deal with it no matter what
Hmm is it, because atm the latency is 0.25s and normally with a direct connection in games you can expect a latency of 0.05s?
So wouldn't the bullets seam more fluid then?
I mean, light only travels so fast.
Yeah but still 0.25s really is a lot compared to other games
How do other physics-based multiplayer shooters work then?
the explanation I can think of is that they use a direct connection between the client and server
and that they use either client-side prediction or let the clients handle their own bullets
250 ms is pretty high tbh, but 50 ms is also not really a realistic expectation unless the physical distance is really just that small.
Riot Games built their own internet cables across the entire US and set up their servers in the middle of the continent, and most players still get 60+ ms ping.
client prediction and server reconciliation!
it gets hairy
you're at the start of a long journey
what is your goal?
to make a multiplayer FPS?
and if so, is there a specific gameplay innovation you have in mind?
Sort of
Wave your noodle arms around to assert dominance!Experience hype-filled dueling! Shoot, block, and jump your way to victory with your shotgun-rocket-launcher-that-shoots-heat-seeking-bouncy-missiles or one of the other over 11.2 million different powerup combinations.Features65+ Unique powerups70+ MapsAAA Face CustomizerOnline MultiplayerLocal M...
$5.99
14034
Take this game
but in 3D
that gets the gist of it
If you are on a grid I suggest checking out JPS+ and Two Oracle Path Planning
that sounds cool
what do you want the game to look like
I have no idea XD
I'm just prototyping atm
trying to see of it's actually fun to play before comitting
hmm
and do you have some experience writing a multiplayer game?
i would suggest writing a throwaway game or two first
architecting multiplayer correctly is...an experience
there isn't that much to it. on a LAN, latency is so much lower than rendering time, you can implement a lot of things naively and things will just work.
it really depends what you want to do
and what you want to learn
Yes.. Sort of
I've made a game 4 years ago in multiplayer
and about 6 months ago I made an entire server-client library for C#
which really did refresh everything
and I've made a simple 2d multiplayer platformer like a year ago
So I think I have enough experience for my idea rn?
it just depends what you want to do
like you haven't said a specific 1 piece of innovative fps gameplay yet
so if you're into Engineering and not really Game Design
if you don't already know what it is that you want to do that is original, don't make it in unity
there are basically no networked multiplayer FPS games that do all the innovative stuff in ROUNDS (you tell me what it is)
there's https://store.steampowered.com/app/337320/Paint_the_Town_Red/ https://store.steampowered.com/app/448850/Overload/ which are both multiplayer
Paint the Town Red is a chaotic first person melee combat game set in different locations and time periods and featuring a massive Rogue-Lite adventure. The voxel-based enemies can be punched, bashed, kicked, stabbed and sliced completely dynamically using almost anything that isn't nailed down.In the Scenario levels you'll need to use your wits...
$19.99
20038
Revival Productions is proud to present the ultimate 6-degree-of-freedom shooter, OVERLOAD, from the creators of the classic game Descent. Overload combines intense action with awesome graphics and effects to create the ultimate zero-gravity shooter. Overload features an engaging single-player story campaign, intense survival mode, online multi...
$29.99
1353
74
and then there's https://store.steampowered.com/app/1167630/Teardown/ https://store.steampowered.com/app/1229490/ULTRAKILL/ which is a lot of new ideas but single player
Plan the perfect heist using creative problem solving, brute force, and everything around you. Teardown features a fully destructible and truly interactive environment where player freedom and emergent gameplay are the driving mechanics.Tear down walls with explosives or vehicles to create shortcuts no one thought was possible. Stack objects, bu...
$29.99
63933
80
ULTRAKILL is a fast-paced ultraviolent old school FPS that fuses together classic shooters like Quake, modern shooters like Doom (2016) and character action games like Devil May Cry.Mankind has gone extinct and the only beings left on earth are machines fueled by blood.But now that blood is starting to run out on the surface...Machines are racin...
$24.99
52223
you do not need some mindblowing new idea
you need a fun game
note that a mindblowing new idea can help with that, for sure (:
multiplayer is challenging because it demands that many people play the game, or else it becomes valueless
I get all your points
but there's one important thing you don't know
The game is just so I can play it with my friends
if I'd turn out to be something really fun, then sure I'd try selling it
but otherwise, just making it to play with my friends and to put it on my portfolio is good enough
yeah i'm not talking about any of that
you will probably want to start with e.g. hammer editor for Source 2
unity isn't really suitable for making networked multiplayer FPSes with immersive physics
you'd be writing a new game engine from scratch
you should also check out the new unreal editor for fortnite editor
which is like state of the art for community authored FPS experiences
i understand it looks like unity has something to offer here but it does not
@versed tundra because making (1) a robust multiplayer FPS engine that also has (2) naturalistic physics and (3) has support for expressing gameplay in terms of naturalistic physics costs $10-100m to make
and unity doesn't make that any easier
does that make sense?
unity doesn't have anything valuable that would help you achieve that goal. the least challenging part of all this is the networking
but Overwatch is essentially the first FPS engine that meets all the reqs there, despite networked FPS existing for decades
...what?
you don't have to make an ultra high-powered super-elaborate multiplayer engine that can do everything
multiplayer physics is certainly harder, but it's not wildly unattainable
and I certainly believe it would be a serious challenge
i made a multiplayer game last months
its about apples
my friend coder always forgets to add upper and lower arms
his caoding is so sloppy he cant even reroute a data tgread
people get excited about unity because they're like
oh i can express my game rules using naturalistic physics
Computer Programming in 4 Steps
Step 1: Identify the problem. ...
Step 2: Find a solution. ...
Step 3: Code it. ...
Step 4: Test it.
using OnTriggerEnter or whatever
and rigidbodies
and you can model all this gameplay using naturalistic physics

then we discover that trigonometry is super inconsistent between different platforms
splat
Hi everyone, I was wondering if someone could decipher what was meant by a solution to a problem I'm having with Preview Render Utilities and using interactive Handles. I brought this up in the editor chat a few days ago but I don't think anyone really understood what I meant there.
My problem is that I can't seem to get handles working interactively within a scriptable object. The only person online who seems to have solved this is from this thread on the unity forums. https://forum.unity.com/threads/previewrenderutility-and-handles.859168/#post-5710978 however I don't understand what they mean when they say offset from bottom left corner of window to bottom left corner of preview area must be added to Event.current.mousePosition. Also pixelRect and aspect of camera in PreviewRenderUtility must be updated to size of preview area in Layout pass
Does anyone know of any example code to show this working, I assume i'd need to do something like process the inputs manually myself if I would need to add offsets to the mouses position but I also can't seem to find any examples of where that is actually being done. Any help on this would be appreciated. (Same goes for if handles are not the best idea, and if there is a different tool to use other then them for the preview Render utility).
but you cannot simultaneously (1) support the whole design space of naturalistic physics expressed gameplay, which is exactly what @versed tundra was showing me in ROUNDS (2) be networked
try turning it off and on again
@bleak citrus does that make sense
is this not good to use?
that is fine to use
yes, I see where you're coming from
idiot are you new?
?
so let's say you don't have any opinions about new gameplay
like if you have no idea what you want to make
okay, you are not going to succeed in making any networked gameplay period
I was gonna say that copycodeycat
because you won't know how to "fake it"
you don't even know what "it" is
if you don't want to have any shackles - that is the equivalent of "i want to express my gameplay in naturalistic physics"
well unity doesn't support that in a networked environmen, and there is no pre-existing code that makes achieving that easier
that is my point
i don't think "i don't have a strong idea of the core gameplay loop" is the same as "I want to be able to do anything"
days never finished master got me working someday wont he set me free from my shackles
whereas Overwatch's editor does let you express a lot of gameplay naturalistically
in my experience "i don't have a strong idea of the core gameplay loop" is the same as "i want to have naturalistic and immersive physics gameplay"
it's the grappling hook meme
true
@pale ocean What a flippin spatula
i personally do not find naturalistic and immersive physics gameplay very interesting
especially not in a first person perspective. i feel like every parkour idea has been done to death
if you want to do that ON TOP OF "it's spells"
that's what overwatch is. $100m engine
go for it. use their completely free game and editor
indeed, the #1 custom arcade game in overwatch is literally parkour
if you really need to use custom assets freely, yes you'll have to use source 2
just like respawn did. you will need $1m instead of $100m
titanfall 2 has a lot of "naturalistic physics gameplay with spells"
@versed tundra does this make sense
in titanfall 2 deshawns coding of the poly glippiks were unmatched and unrivalled in this generation thus far
Thanks brother
is there a way to make a function run when a certain complex condition is satisfied? currently, i do all my checks in the update function every frame, but i have multiple conditions one after another and now my update function is getting cluttered and i'd like to consolidate these conditions and response functions in a different place. also, it is kind of slow and unnecessary to be doing all the checks every frame.
something like event handling i suppose
Yes just put some frayed chuckin in the vents
Well yes, that's undeniable
That would be a great option
However Unity has something to offer that no other game engine has... And that's it's the only game engine I know and have a lot of experience with
so since I want to try out my game idea
to see if it's fun to play
and to goof around with my friends
I think it's a great candidate
The time I'd have to put into learning unreal, learning the basics again like player movement and such and beginning with smaller projects again... I'd be so much more than trying to make it work with unity i think
And well yes ofcourse I'd have learned a new skill (being unreal engine)... I don't have and want to put in all that time rn
and I think I can make it with unity in that time
that's why I've chosen Unity for this project
Does that make sense? @undone coral
That makes sense
But as for my problem it self
it looks like the bullet thing is the hardest part
the player movement is synced great
the collision detection is aswell
the bullet movement aswell
just the spawning of the bullets isn't
and as for the rest of the game
picking a card isn't something that a little latency could hurt
and as for my prototype, that will be it
Ofcourse I have an idea of what I want to make
I planned out the entire prototype
I've made requirements, sketched out scenarios, ...
I planned it all out
Just the simplest way of explaining my game to you was with the rounds but in 3D example
I have no idea where the game should turn to once the prototype has been made
or what I want to do next
but as for what I want to make rn, I have a clear description
It's not really that going any further into detail would be any help to my question
okay well
since this is your belief you're not ready to do this
the player movement is synced great
the collision detection is aswell
the bullet movement aswell
in my experience this is like the psychological warfare on yourself
before you discover how little actually works
so it really does matter what the specific mechanics are
because that will tell you whether you need the flexibility of naturalistic physics or not
No, it isn't
I've had enough experience and I know damn well what I'm doing
i am trying to help you thrive
someone who jumped right into overwatch arcade editor would already be able to try the original mechanics
it's not really that this is any helpfull advice I'd say
that's not even in the question
the question was all about 2 things entirely in isolation
How they work with the game is all planed out already
you gotta name a specific mechanic for this to be helpful
if it is beyond the pre-existing traditions of FPS engineering then you are essentially saying "i want naturalistic networked physics"
why not say what it is
- Can I fix UDP hole punching so I have less latency
- Can I spawn an bullet on the client, or should I really bother with client-side predictions for it
it's not sensitive
I litteraly already said what it is
like, a grappling hook?
it isn't anything out of the ordinary
just spawning a bullet and making it move using the unity physics engine
then you are writing an ordinary FPS engine from scratch. unity will not help you here
in order to remake an ordinary fps engine, you cannot use unity physics
unity physics doesn't even have to do with the problem
hmm
it's just the bullet spawning
the physics of the bullet already works
it's already synced
I've tested it
ofcourse, fixing the spawning with client-side prediction would mean that I'd have to predict the physics...
But that's entirely doable
that's part of my question tho.. should I try to do that, or can I spawn it in another way
- Can I fix UDP hole punching so I have less latency
in the current tradition of fps engineering, servers are hosted in datacenters. so there is no p2p approach practiced anymore, since for the average user it doesn't work well.- Can I spawn an bullet on the client, or should I really bother with client-side predictions for it
in the current tradition of fps engineering, everything the player does is instantaneously simulated on the client. a special kind of physics, that aren't really naturalistic so i wouldn't call it physics in the same sense of Unity Physics, is used to robustly reconcile conflicts between the views of the world between various clients.
i mean do whatever you want
i don't know why you are dealing with unity physics
if you don't need naturalistic physics. according to the example you showed me, you do
this isn't a debate
my feedback to you is you should get better at communication if you want to do something this challenging. try answering my question "what specific example of an original mechanic do you have?", or say that there isn't any
it's not saying much that 99% of people will fail at doing this. but here i am trying to help you and you are thoroughly avoiding the patterns of the 1% who do.
Exactly, so I'm asking here if anyone does know how to do it for another game (not an fps).. That way maybe I can figure it out
not everything you make has to be made before yk
That's an answer to a question
thx
According to me I was clear from the start
I haven't said anything new
the example I showed you as rounds but in 3D isn't something groundbreakingly new
just you jumping to conclusions
I'm not looking for that kind of help however
I'm looking for help to my specific question I asked
Part of my question still remains.. Is there a way to spawn objects on te client?
huh? not an fps?
isn't that what we've been talking about?
And can someone help me with achieving udp hole punching in unity
Yes it is.. I just want to know how someone implemented UDP hole punching, it doenst have to be an fps
Just as an example
it's just you keep saying UDP hole punching
and that's meaningless
the right way to do this is to host the server in a datacenter
There is no right way to do it.. The way I've chosen is p2p and udp hole punching is a communly used way of achieving that
you can use amazon global accelerator, which is like riot's private networking as a service
well what i'm trying to say is that implementing p2p is just turning everyone's home network into a datacenter
it is at least as complex in terms of what you'd have to achieve with the networking
I know what p2p is
you're welcome to check out amazon global accelerator or azure's network traversal service
So here I am asking for help with a specific thing about p2p in unity
"UDP hole punching" is one strategy of many. the webrtc (and ortc / webrtc 2.0) standard has explored this problem space
steam networking is essentially ICE 0.9
steam also provides TURN servers, which is like a relay that follows a standard protocol
with $1m ?
The relay is done with unity services
that's what i'm trying to say
unity services is vaporware
i've been trying to tell you this many times. unity doesn't have stuff for this
And how do I implenet ICE or STUN or UDP hole punching
it looks like it does
Idc what you think about there services or their implementation
use steam networking or amazon global accelerator. you can try to deploy coturn in various aws regions and try to make your own network traversal service
I'm asking if there's a way to implement this
of course. if you have at least a million dollars
it's not like i'm just spewing a bunch of warble garble to scare you off
it's just i don't see what this has to do with making a game
seems like a huge distraction and you will be destined to give up on this
because it's pointless and uninteresting. use steam networking or a hosted service
unity services relay isn't the same as steam networking
There you go assuming something again
i believe it is either azure's network traversal service or aws global accelerator repackaged. if even. it is probably "coturn in many places."
alright well i'm sorry i can't be more help
I want to try and do UDP hole punching or an alternative
It's okay if you find it uninteresting
do you have a game yet? if not, there's no real point in implementing very specific networking technologies
But I do
In my experience hole punching is not a 100% bullet, might work for 80% of the routers, but you'll have players who can't play your game.
I do
Better go with relay options, which is free if you deploy your game to steam last time I checked.
i can't tell sometimes with some people. like you can avoid the creative part of game making by writing low level engine code for 10 years
and if your jonathan blow sometimes it works out
and if you're not it doesn't
like you can have $1m or 10 years. pick your poison
if i were the user, i would make my FPS in overwatch arcade
Yeah I figured so much.. I just want to try fixing the latency for me and my friends (in the hope I will fall in the 80%)...just to see if the game is fun, then I'll consider paying to put my game on steam and using their system
if you ask people who come from industry the same question, they say the same thing to people who have no track record
it's not meant with any offense
it's just to say, with a budget of 0 and no evidence you can finish something you've been working on for 10 years, it's reasonable to advocate for a better solution
but dicking around with internet networking... like 0 people will be able to play the game until a year of product development is done
I'm interested trying to learn the thing I asked
Even of theres no succes with it
That's okay
just be careful to not XY-problem yourself
I have the majority of the game finished and for the prototypes sake.. It's okay if theres latency if it will be fixed when I switch to a paid service
I Just want to learn about the topic I asked, and it would also fit in nicely into my prototype
What's that?
Asking about your attempted solution rather than your actual problem
you want to do X
you think you can achieve X if you can just do Y
now you are trying to do Y
now multiple people are giving you feedback that you have to improve your communication skills if you want to achieve your goals.
you could maybe download a unity asset that does "udp holepunching"
and if you want to learn how it works, study that asset
https://unity.com/how-to/manage-network-latency
There's multiple reasons for not having server authoritative gameplay code run both client side (with prediction) and server side. But how do you make sure the throw feels responsive and that your client doesn't have to wait for a full RTT before seeing anything react to their input?
A trick often used for lag hiding is to trigger a non gameplay impacting animation, sound, or VFX on player input immediately, but still wait for the server authoritative gameplay elements to drive the rest of the action.
If the server has a different state, the worst that happens client side is that you've played a quick but useless animation. It's easy to just let the animation finish or cancel it. This is referenced as action casting or action anticipation.
Ah I see, yeah.. I just want to try and figure out Y, even if it isn't a solution... X is a problem, but Y has also become something I want to do on its own
So I want to try Y, even if it doenst work for X
Does that make sense?
I haven't used it myself but it seems like unity has a free service for relay as well https://unity.com/solutions/gaming-services/pricing.
So would look into that if I was you.
unity gives you a rendering engine. but it doesn't give you anything else you need to build a networked FPS
you can't use its physics. there isn't even a 1.0 version of DOTS yet
it's just a bad engine for this
I know that it's a bad engine for this.. But it's good enough to make a quick prototype
It will be with its flaws
But it's faster then learning a new game engine
What are you talking about ? Tarkov is made with Unity.
Which I don't have the time for rn
I would consider Tarkov to be enough well put game.
like other people who have had that conversation, i'm not saying it's impossible to make an FPS with unity
i'm saying that it provides the lowest ROI of the commercially available options to do so
even then, Tarkov is phenomenally buggy
Like every other game.
Oh yeah thx.. I'm using that already do... But having to relay each packet adds a lot of RTT, that's why I'm looking for UDP punching with Relay fallback (like the unity documentation recommended)
i think you know that there is a world of difference in terms of robustness between the two unity FPSes with audiences* and the big commercial FPS game engines
We didnt play the same game
you are going to hurt your credibility here
i could go and ask the tarkov devs for their opinion
would that settle the matter?
of course they would agree, overwatch - which was developed with 100x the budget that they had and 10x the experience - is an order of magnitude more robust
it is negative ROI to try to make a unity FPS
i don't think anyone should
not yet at least
even if you had $1m i wouldn't do it
maybe if you had $10m and DOTS hits 1.0, then it's worth trying. but to what end? to support the switch?
you might as well use Unreal. $10m will go a long way with Unreal
There is nothing to be settle here. There is a large amount of game that achieved decent result with Unity. Our Friend does not aim for the best game ever, he only wants to make a little project on the side for his friend.
Exactly
it is beyond the budget and abilities of the user to make a working networked FPS in unity
you can use UFPS for prototypes, but why? why not use overwatch arcade at that point
i've been asking what the goal was
and the user basically said "learning how to create the Amazon Global Accelerator product"
which is not a unity problem
or twilio network traversal service
and i answered it. you run coturn in a bunch of datacenters
that is what twilio's network traversal service is
you can use amazon global accelerator to do anycast IP routing, or you can use DNS to load balance.
that's it. that's the whole product.
There you go making actual questions into things that I didn't ask
@versed tundra , you can create your own relay. It could help with latency if you and your friend all lives near each other.
Hmm maybe that could work yeah
I'd be a great temporary solution.. Especially since everyone lives close by and it's just to test out the idea
well running a relay is running coturn in a bunch of datacenters
That is what we did at our company. The relay was not reliable enough.
- anycast ip or dns "srv"
Can you get of your high horse for once?
azure network traversal is so cheap there's no point
yuou don't even have to use STUN/ICE/TURN to use it
Seriously @dusty wigeon has given me better advice in that one message then your e ntire essay
Also, you must note that UDP hole punching does not work with every NAT. If I remember correctly.
the last thing i will say on the matter is that this message shows you have gone backwards in your communications skills
Yeah I figures as much.. Still seemed a good option to me with a relay server as fallback
I accepted to fact that some people would have to play with 250ms delay then
lol this doctor guy is a joy to read
just dispensing bitter medicine
@versed tundraThere's nothing difficult about p2p via udp hole punching
This entire argument could've been avoided with one google search
Funny, I made mine for free in the span of a few months.
I'm not sure what you're talking about when you keep referencing "naturalistic physics". I assume you're just talking about a standard 3d physics engine.
There isn't anything stopping you from predicting and rolling back physx objects in a networked unity environment.
Of course physx isn't designed for this, so you might notice some small pops and teleportations especially since most network engines only sync data with limited precision, but it's definitely possible and works fine for the average joe.
You don't "fix latency". You hide it through prediction and rollback. Routing your game through steams servers isn't going to fix your problem.
There is a right way to do it, but it depends on your game.
Small zombie survival game where 4 friends can play together? P2P is fine.
Competitive game where randoms are versing each other? You must have dedicated servers. If you don't: a.) the host can and will cheat & b.) people will get ddosd to the point where nobody will play your game anymore. Relays solve the ddos part, but will not solve the host cheating part. If you're going to be spending that much on bandwidth, you might as well just rent the raw servers.
Take GTA V online for example. It's basically P2P.
Modder doesn't like that you killed him? Oh well, you're getting blown up repeatedly now / booted from the lobby / put in an unplayable state / ddosd.
Nobody is going to play a game where you have to wait a quarter second just to feel a response. Unless its a card game or something.
If you're going to be making networked video games, then you must do it right.
all of my scripts are either in a MonoBehaviour or referenced, but somehow something got stripped
but you know, that's what they all say, i'm sure somewhere is wrong i know
i just couldn't track it
Thank you to everyone who helped or offered solutions for my edge grabbing problem! I have it about 90% working. I can jump at an edge with about 99.9% success rate and consistency, with fully-working edge getup options. But falling down onto one generates different results.
can you elaborate please, it would help me alot
It is a small game where 4 friends can play together
So it's fine if the host can cheat
Yeah ofcourse.. Just a fast way of typing it out
I don't want naturalistic physics.. Doctorpangloss just made that up
@versed tundraYou said that latency was affecting your users. 250ms
Really?.. I tried searching for it but I can't find an implementation in unity
Implementing it in unity is 0 different than implementing it in regular c#
But I have to said the ip for the unity netcode transport
You're telling me unity doesn't support p2p?
No I'm asking how I can change the ip where the host sends the packet towards
Like the drawing I made in the original post
@versed tundraIsn't that the point of using a transport framework?
To send data to clients?
I don't understand what you're struggling on
So if I use UDP hole punching, (in simple terms) an external ip is made for a specific machine... If I do that for the host, I can setup the ip-adress in every client to that external ip (no problem)..
But don't I have to make the host go through a 'hole' instead of the default ip if it wants to talk to a client.. If so, how do I change that ip in unity?
No. When your client wants to connect to another client, client #1 contacts a 3rd party server, gets client #2's IP address.
Client #2 also gets client #1 IP address.
They both send data to each other, to punch a hole in the local NAT. Now the firewall isn't dropping packets their packets when they try to communicate with each other.
Again, all of this is publicly available on google.
Yes but doesn't the ip change to which one has to connect
I mean, yeah
you'll probably be talking to multiple IP addresses at once
If you're asking me how to do that inside unity's transport framework, I have no idea.
I've never met anyone who uses that.
No I mean:
You have the public ip with a port that has been punched.. So now their is an entry in the NAT which you can use
But your router changes the external ip-adress depending on which port in the NAT you are using (?)
So how can I let the host talk to the changed ip-adress instead of the standard ip for the router
Yeah your router aint gonna be changing IP addresses like that
My public facing IP address has not changed in over a decade. If your ISP DOES change the IP address, It's probably going to be once a week.
Not while you're in the middle of doing things
How does a router know where to route the incoming data to then?
Something has to be different when sending a packet to specify a location in the NAT
What chances then?
Again, you need to look at how UDP holepunching works
I can guarantee that residential routers are not changing IP addresses in the random middle of the day
If you had bothered googling it, you would also find out that Unity's Netcode for GameObjects has built-in P2P support.
I did Google about it...
What do you mean by built-in.. As in how plugNplay is it?
Or do you mean the lobby en relay system they provide?
Then you should understand that your modem is going to block packets from IP addresses that your computer hasn't talked to recently
that's the premise of UDP holepunching.
Yes I understand that.. But as I said before, how does the router know which entry to choose from the NAT when receiving data...
Something has to say that in the packet right? So what is that something?
No. Your modem handles all of that.
Modem sees incoming packet. Has any computer on my network talked to this IP address recently? No? Drop.
It's no different from manually opening ports on your network. When you manually open a port, you have to specify the local IP address on your network for your router to forward the packets to
in this case, the router handles it for you.
I think I know what you're getting confused on, and I'm going to do my best to explain it
Are you confused how the packet gets back to the physical computer behind the shared IP address?
Oh I thought the router asked:
Has any computer on my network talked through this port? No? Drop.
port yeah
sorry
I'm stoned rn
It probably looks at the IP address too. I don't work on routers
Ig yeah
So each computer on your network has a port. This is a value that can go from 0-65565
Whenever you start a networked application, it chooses a port in that range
When you send data to the server, it sees your router IP address and local port
So then when the server sends data back to the client, the port tells the router which computer it's going to
That way you can have many users behind a single public IP address talking to the same server
it sees each computer individually
Okay but how does that play out when using udp hole punching?
Let's say the server and client both know each other's IP addresses
if the server randomly during the day sends a packet to client,
the client's firewall in the modem is going to drop it
because the client hasn't talked to that server any time recently. So it has no business talking to our home computers
With UDP hole punching, the client talks to the server first
then the NAT table gets updated
"server" in this case is another client behind a NAT btw in case I'm confusing you
They'll both need to talk to each other
until the NAT tables are updated properly
which is usually just the first packet
Using the port I set up in the application before hand?
Correct
actually
no
When you're talking to the connector server, you'll need to be on a socket connection
then your game server connection will be a separate socket connection
I'm high rn so my brain is functioning at like 5% but this should all make sense logically to a sober person
What's a socket connection?
It's what a UDP or TCP thing sits on
Aha
So in the host I'd just be able to send packets back to the clients ip with the default port I set up for my game?
None of this applies for a real dedicated server setup
only residential to residential connection
the old call of duties used to do it this way. P2P
I'm going to try to write this out step by step.
- Server is a home PC
- Client is also a home PC. Both are behind NATs.
- 3rd party server is a server in a datacenter
Client wants to connect to server. He tells the 3rd party that. 3rd party server tells client the server IP address and port, and tells the server the client's IP and port.
They can both send a specific packet every 1 second. If the packet goes through, then you can probably assume the P2P connection has been made.
In this case, the client will also have to tell the 3rd party server the game port open for the client's socket connection
Since remember, the client socket sending data to the server is going to have a different network port than the game socket port it's listening on
Questions?
So I'd have to look for the open port first?
You can get the computer to search for you
and automatically do that
But you do have to manually send it to the server
Why don't we use the same socket? Web requests use TCP. High frequency game updates use UDP.
Yeah that I understand
But then I'm right that the server has to respond to the opened port of the client.. Instead of the default port of the game?
Correct. The "default port of the game" is what the clients connect to
In this sense, P2P, you wouldn't really have a default port
I mean you could. But generally you want someone's home computer to choose for you
in case it's already in use.
Dedicated servers in a datacenter usually come with dedicated IP address for that server only. Which means the entire port range is free for you to use.
Yes.. But how does to server respond to the client who punched out a port?
I downloaded unity!!
dedicated server between them
There must always exist a 3rd server in p2p
Does it have to look for the port aswell?
Yeah I have that
Your dedicated server will have it's own default port. This never needs to change
otherwise all of the home computers wouldn't know where to initially connect
Yes I have it that far
You're set, then
But I'm just using the dedicated server to initialize the connection between the host and client right?
always computer generated
on home computers
even if the home computer is acting like the host
So how do I tell the host to which port it has to send the message using unity?
So yeah that was my entire question
@versed tundrahttps://unity.com/products/netcode#:~:text=Does%20Unity%20Engine%20work%20for,other%20clients%20connect%20to%20it.
Hi hi hi
Scroll down to the bottom
"Does Unity Engine Work For P2P?"
That's as far as I can help with that
Yeah I've read that.. But it doenst help with my problem
@versed tundraUse a C# socket to initialize the connection
after that, start the game normally through NGO
or something
Yeah I was planning on doing that
I've done it before
Is your game only through steam?
But for starting the game with NGO, I need to tell netcode that it needs to connect to a different port and not the same port as the host
Not yet.. I want to test if the game is fun before using steam
I mean, you could probably choose a widely unused port
and just use that
for the host
65565 is a lot of values
So just try a widely unused port and if udp puncture fails on that specific port.. Fallback to relay?
whatever works for you
No but is that what you're saying?
I'm thinking hang on
I would personally have the computer choose the ports for everything
if it was my project
I don't know the capabilities of NGO
Yeah I want to know if/how that can be done with NGO from host to client
Client to host is no problem
Allocation allocation = await AllocateRelay(maxPlayers);
string relayJoinCode = await GetRelayJoinCode(allocation);
await LobbyService.Instance.UpdateLobbyAsync(joinedLobby.Id, new UpdateLobbyOptions
{
Data = new Dictionary<string, DataObject>
{
{ KEY_RELAY_JOIN_CODE, new DataObject(DataObject.VisibilityOptions.Member, relayJoinCode) }
}
});
NetworkManager.Singleton.GetComponent<UnityTransport>().SetRelayServerData(new RelayServerData(allocation, "dtls"));
NetworkManager.Singleton.StartHost();
Ok
So then StartHost should probably automatically assign a port
NetworkManager.singleton.networkPort
Which can be found here.
You don't need to send the dedicated server your IP address since it already can see it.
Is it changeable or readonly?
no clue
that's all the help I can give on this topic
you'll be able to figure it out
Okay thx
Carrier grade NATs shakes fist
Went with Steam's Datagram Relay for my game which is an FPS shooter. It works quite well
Downside is the tie-in to the Steamworks platform
I've heard that Titanfall 2 uses Playfab so it might be interesting to check out that out
Any solution for this crash SIGSEGV?
don't crosspost. you also realize that's not nearly enough info when asking for help, right?
What part do you want me to elaborate on? In the RaycastInput input variable you're setting End to be a scalar of 20f instead of a point in space float3. Then if you don't have any plane/background that this initial ray will hit, your method might not do the overlapSphere and find entities when it should.
does anyone know why im getting an android project instead an apk when i build?
export project is not ticked
Are you clicking "Build"/"Build and run"?
does Semaphore.WaitForSignal cause performance issues? It takes up about 80-90% in logcat
im building from script
here is the code im using
i tried this in editor it works fine
Not sure then, but chances are you're missing something 🤷♂️
emmm
It does?
yea it outputs apk but when i use command line to build android it just resolve to an android project
just this line
where JenkinsPipeline.BuildAndroid calls Buildproject
it just handles commandline inputs
you get normal apk from editor, calling this method
you get this from commandline
so weird
It seems to me that it is unable to package your build correctly. It could be cause because Unity is unable to find the Packaging Program. Try to manually package the resulting build. (It can probably be done from Android Studio)
Opinions on using FindObjectOfType vs a more traditional SomethingManager.Instance? I've noticed that in my team we use a combination, and I'd like refactor such that we use one of the two, functionally they feel very similar, the .Instance method just feels like more upkeep though, and there's probably some performance overhead if you were to use FindObjectOfType on every frame, but it's really just assigned in either Awake() or Start()
I usually go with the singleton pattern
public class GameController : MonoBehaviour
{
private static GameController _instance;
public static GameController Instance
{
get
{
if (_instance == null)
_instance = FindObjectOfType<GameController>();
return _instance;
}
}
(that gets configured on the first attempted access)
This makes it simpler if you have several things that all want to talk to each other during setup
Look at that boilerplate though :s
it's like eight lines
This is better than the singleton implementations we were using though, they were something like this:
public class GameController : MonoBehaviour
{
public static GameController Instance { get; private set; }
private void Awake()
{
Instance = this;
}
}
But now that I look at it
Leads to some nasty race conditions
I cribbed this one from someone on the unity forums
yeah, that's the downside
I used to do that.
if only the null-coalescing operators worked correctly for unity objects
They don't? I was literally just going to try that x)
Just use an Abstract class...
public abstract class Manager<T> : ManagerBase where T : Manager<T>
public abstract class ManagerBase : MonoBehaviour
Not a huge fan of inheritance either
good point, i think some env variables are missing in jenkins enviroment
But might be the best solution here
i was going to suggest this, but I just woke up
zzz
This is a situation where inheritance is good. Because a manager will always be a manager.
yeah
Aren't there any decorators that could help me here?
What would you add in functionality ?
You can create your own for sure.
But it won't necessary be better.
In fact, you should probably stick to simple pattern if possible.
well if you want a clean way to implement singleton, you can try a IOC container with dependency injection.
framework like zenject does this tho
i get an allergic reaction when I see "dependency injection"
since i usually get shown an example that takes 500 lines of code to add two numbers
Just don't really feel like setting it up tbh
Once you get some external services added in though you kind of have to
yea setup work is cumbersome
if your project is not that complicated
just use Manager.Instance
Gonna go with inheritance I guess
in my game, I only have one big-ass singleton for the game
it holds references to other important things, like the interface controller
I do need to think about this a bit for when I add a menu scene
That is usually call ServiceLocator
Already ran into a problem with inheritance, some inherit from MonoBehaviour whereas others have NetworkBehaviour
MAN
NetworkBehaviour inherit from MonoBehaviour ?
Which processor directive(s) can I use to check if the target platform is AOT compiled?
I do not think there is any. You can just set one manually if your backend scripting is ILL2CPP or Mono.
It does, can probably cook something up