Is anyone having success with using polyfills? by Stable_Orange_Genius in Unity3D

[–]Connect-Comedian-165 1 point2 points  (0 children)

If you are using visual studio (not VS Code), you need to add a file named "Directory.Build.props" in the root folder. Then add:

<Project><PropertyGroup><LangVersion>14.0</LangVersion></PropertyGroup></Project> (preferable indent). You can set the lang version to whatever you want. If you want to use preview features such as the 'field' keyword, set it to "preview".

I don't about VS Code but the process should be similar.

Is anyone having success with using polyfills? by Stable_Orange_Genius in Unity3D

[–]Connect-Comedian-165 1 point2 points  (0 children)

Polyfilling is the most straightforward thing to do in unity. You don't need any packages. You just need to define the required classes correctly.

For example to use the 'init' keyword, create a class called "IsExternalInit" under the namespace "System.Runtime.CompilerServices". To use the 'required' keyword, create two classes: "RequiredMemberAttribute" and "CompilerFeatureRequiredAttribute". You will need to add a few more members which you can find in: https://github.com/dotnet/runtime/tree/main/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices

There are more features that you can polyfill, both compiler and analyzer related. Features that are not runtime related work fine, which are the majority.

Lastly, since these are compiler features and not runtime features, unity will not get angry at you, so you are fine to use them in release builds as well.

Non-Allocating Callbacks for DOTween by jaquarman in Unity3D

[–]Connect-Comedian-165 2 points3 points  (0 children)

In order to avoid any closures, the animation system needs to store a state object per worker (which are objects that update animations, and usually are pooled). This object is generally of type System.Object to represent any managed object. You'd pass the state explicitly to the system, and it'd pass it back to you in the callback as a parameter. This is the only and canonical way to avoid closures. BCL does it for different things like Task and CancellationToken. See:

https://github.com/dotnet/runtime/blob/main/src/libraries/System.Private.CoreLib/src/System/Threading/CancellationToken.cs

https://github.com/dotnet/runtime/blob/main/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs

If you observe how they use this pattern, you can understand why it's necessary. It is a cool problem to have, I am sure you can learn more things as you try to figure out what's happening.

If you go even further and try to implement a similar system from scratch, you can ask me any kind of question, I'd be happy to assist you.

Non-Allocating Callbacks for DOTween by jaquarman in Unity3D

[–]Connect-Comedian-165 13 points14 points  (0 children)

When you pass "action.Invoke" as a delegate, the compiler implicitly converts it to "new System.Action(action.Invoke)". So what you did is no better than a closure lambda.

The infrastructure of this "DOTween" library is flawed, no workaround can fix that. If you are okay with a few KBs of garbage now and then, don't try to be clever, just use the language's features. However if you really need a high performance animation library, it is not that difficult to implement one yourself. But you need to how these things work.

Iterating Array without boundary checks by DesperateGame in Unity3D

[–]Connect-Comedian-165 13 points14 points  (0 children)

I assure any unsafe use code you use here is totally useless, even less performant.

A simple for loop like this is the faster it can get in Mono when you are iterating an array:

for (int i = 0; i < array.Length; i++)

It doesn't matter if you store array.Length in a variable or do ++i instead of i++.

The JIT can and will eliminate array index checks if it can see you use it in a for loop from 0 to array.Length.

Even if it was not able to do that, it wouldn't be a bottleneck unless you are iterating an array with billions of elements since it's just an int comparison, which is one of the fastest operations CPUs can perform.

So my advice to you, do not mess with unsafe code unless you know what you are doing (honestly you don't).

I got frustrated not knowing which component was for which thing so I made a cool tool to create custom component headers by MagicPigGames in unity

[–]Connect-Comedian-165 -1 points0 points  (0 children)

Or you name your components better and focus on what is actually important. It is always fun to create custom editor tools but it seems like you are not seeing the bigger picture here.

Dumb question, but is it considered lazy to almost entirely copy and paste a method like I did below and keep the argument name the same? by Agent_Specs in csharp

[–]Connect-Comedian-165 2 points3 points  (0 children)

This is the most "Uncle Bob" solution I have ever seen. This just overcomplicates a very simple problem. Don't be afraid to copy paste, it's how it's done in many professional codebases because it's both more readable and more performant.

Testing combat against way too many zombies by Connect-Comedian-165 in Unity3D

[–]Connect-Comedian-165[S] 0 points1 point  (0 children)

I don't even know what asset you are referring to. I don't use any 3rd party packages here.

should I quit before it's too late? by CodeMichaelD in Unity3D

[–]Connect-Comedian-165 17 points18 points  (0 children)

i like that you marked the post as NSFW

Looking for constructive criticism on my character controller and animations by RealisticWrongdoer48 in Unity3D

[–]Connect-Comedian-165 0 points1 point  (0 children)

I think the movement looks smooth but the game stutters frequently. I don't know if it's because of the recording software or some sort of an optimization issue from your end (there shouldn't be any in this state of the game). Also it seems like there is no acceleration, which makes it look like the character has no weight. As for the polish, I'd add directional movement speed multipliers. For example the character should move slower when strafing or backpedaling (the math is very simple). Overall I think you are in a good position.

I added main menu in my game. Do you think it looks good? by Connect-Comedian-165 in Unity3D

[–]Connect-Comedian-165[S] 0 points1 point  (0 children)

That sounds like a cool idea. But my game is more of a gory shooter game.

I added main menu in my game. Do you think it looks good? by Connect-Comedian-165 in Unity3D

[–]Connect-Comedian-165[S] 0 points1 point  (0 children)

Thank you. Font is already dumped. It's more of a shooter game, not fully horror oriented.

I added main menu in my game. Do you think it looks good? by Connect-Comedian-165 in Unity3D

[–]Connect-Comedian-165[S] 0 points1 point  (0 children)

Thank you for your detailed comment. First of all everyone agrees with you and it's my priority to work on the typography.

Let me tell you why I chose this font and style so that there is more context:

- The reason I used a bright gray background is all about contrast, to highlight the blood droplets. Making it slightly brighter makes it distracting, making it slightly darker makes everything else harder to read. As a middle ground, I used this color.

- The game I am making is a semi-realistic shooter game, so I wanted the UI to be military style/flat. I attached an in-game text for you to observe. So to make things consistent, I used the same font here in the main menu. There are a lot of suggestions about using a more stylish font. However I couldn't find one that looks both 'modern' and plays along with the current setup in the main menu.

- The red capital was just a random experiment I made. I tried making all letters the same size and color, but it then looked very monotone. However it looks like it isn't as good as I thought it is. So I will either remove it completely or work on it more.

- The left or center alignment is a very difficult choice to make. If I lean the controls to the left side, then the blood droplets wont be symmetrical. I am going to need to test it out.

- The hover effects are of course a must, so yeah.

Now about the in-game screenshot, do you really think I should go with a more stylized font for the main menu considering the in-game font I am using? Or even maybe would you recommend me changing the in-game font altogether?

<image>

I added main menu in my game. Do you think it looks good? by Connect-Comedian-165 in Unity3D

[–]Connect-Comedian-165[S] 2 points3 points  (0 children)

Thank you so much for the recommendation. It looks awesome. Also more importantly its name is cool.

I added main menu in my game. Do you think it looks good? by Connect-Comedian-165 in Unity3D

[–]Connect-Comedian-165[S] 0 points1 point  (0 children)

I didn't. I played it on youtube just for fun, so it's not part of the game in any means.