#archived-code-advanced

1 messages Β· Page 133 of 1

modern meadow
#

I only use GameInput.Instance if I want to read the Vector2 values from somewhere

#

Ah, and I forgot to actually do something with the running state changed event lol

ebon abyss
modern meadow
ebon abyss
zealous sorrel
#

Don't know if this is the right channel, but I can't figure out what I need to include in the asmdef file (Assembly Definiton Asset) for my scripts folder in order to get my project to compile when I started using FilePath and MenuItem attributes.

I can see that MenuItem is under UnityEditor.CoreModule (I think)
and FilePath is the same but those UnityEditor.CoreModule is not available in the list of references

^^also the error happens only when I do a release build, in the editor everything works fine and in visual studio everything's ok as well

long ivy
#

they're automatically referenced (unless you changed some asmdef settings), so there's nothing to reference. Your build is failing because UnityEditor doesn't exist in builds

zealous sorrel
#

alright I might have to go over separating my code for release/in-editor, I'm trying to make a scriptable singleton for the first time

long ivy
#

if you have scripts using editor-only namespaces that aren't in an Editor folder or subfolder, you need scripting defines to conditionally include them, ex #if UNITY_EDITOR

#

ScriptableSingletons are editor-only so that's a bad sign already

zealous sorrel
#

aaaah I see, i have completely misunderstood the use case for scriptablesingletons then
I'll try to rework my class then and I'll be more mindful of when I'm using editor namespaced classes

thanks ❀️

paper grotto
#

I'm trying to set up an attribute-based property drawer. I'm trying to make a binding that takes the type of the property and sends it to a BaseField<Type> element. Currently I'm using DataBinding and SetBinding() so I'm able to use converters. Oddly enough I'm getting a "Index outside of bounds of array" error. The log shows the error was thrown by Unity's binding system, so I'm definitely doing something wrong, but I don't know what. Can someone please help me?

compact vault
#

does anyone know a quick way to import audio files that aren't native to the project?
this is the current way i've been doing it.
i've never actually worked with file stuff and this is extremely slow guh

compact vault
shy nebula
compact vault
#

i dont think so. i dont usually have to do too much code optimisation

#

how can i set up parallel loading?

shy nebula
#

async tasks are what i would go for

compact vault
#

i'll look into that, thank you cat_thumbsup

compact vault
#

i swapped the coroutine out for a task. i tried to use the background thread although im not sure if that's the correct thing to use. (i also cant run most of the code on anything other than the main thread)
the code is a little quicker, it's taking roughly 1 minute with 200~ items.
is there anyway to optimise more or is this the point where I just hide it with a loading screen?
(code so far for reference: https://paste.ofcode.org/3xv9ATazqyNJ7fdNX5HUCt)

#

to be honest, I'm not expecting anyone to put in more than like 20-100 items. at this point I'm just looking to learn (and just in case for the extreme scenarios)

untold moth
#

I'd also recommend profiling the process to see where the main bottlenecks are.

compact vault
untold moth
#

Main thing to confirm is wether your initialize method is being executed in one frame or not.

compact vault
#

it executed in 1 frame cat_thumbsup

fallow echo
#

I'll mention that you can rewrite the load file to be like 10 lines of code...

#
UnityWebRequest request = null;
if (ogg) request = ogg request;
else if (mp3) request = mp3 request;
if (request == null) log error and return;
await request and add to the list;
#

pseudocode because lazy, sorry πŸ˜„

echo coral
#

Something something UniTask

compact vault
compact vault
echo coral
#

Awaitable exists already in Unity as a Task replacement but UniTask is just better imo

fallow echo
#

UniTask won't help you with this... it's a slightly cheaper async task thing, with some tradeoffs (it is cool though)

echo coral
#

yea i just wanted to say πŸ˜†

compact vault
# echo coral Awaitable exists already in Unity as a Task replacement but UniTask is just bett...

oh yeah im giving this a read now and i can definitely see some useful features here. like pulni said im not sure if it helps here unless im missing something from a quick skim (definitely saving this for other projects though πŸ‘€ )

GitHub

Provides an efficient allocation free async/await integration for Unity. - Cysharp/UniTask

fallow echo
#

basically - if you're fine with streaming audio - you can set it to streaming, otherwise - sadnes

compact vault
#

haven't made any changes just yet (still juggling a few things one second) but here's the full script if it helps at all (or if anyone is just interested in general)
https://paste.ofcode.org/huAVsL68Ku4hnUQEhArke4
(small change, shortened the thing pulni mentioned earlier)

fallow echo
compact vault
fallow echo
#

btw a small caveat of using async void or not awaiting tasks - you won't see exceptons if they happen inside these - they'll be kinda silently ignored
you could add a listener to TaskScheduler.UnobservedTaskException that print them, but that also doesn't always happen (I think)
so just keep in mind in case an async thing is not working but also has no errors πŸ˜„ (you can always do a manual try-catch inside the async thing which will catch it, but yeah)

compact vault
compact vault
compact vault
stuck plinth
fallow echo
#

I'll have to check to confirm. I think that's only true if the exception happens before the first async part, but could be wrong.
In any case, exceptions happening in tasks and not showing in Console in Unity has happened to me more than once, so still worth keeping in mind

stuck plinth
fallow echo
stuck plinth
#

i don't mean to nitpick but it's a common point that people use to justify their fear of async so i think it's worth clarifying πŸ˜› also if you turn on -warnaserror:4014, that'll cover most of the cases where you could "lose" a task!

cinder dirge
#

How can i save native array, native hash map, etc.. efficient for a save-load system ?
I don't want to convert to array

stuck plinth
#

iirc Unity added some convenience methods for converting between NativeSlice and spans recently ish

echo coral
fallow echo
echo coral
#

I used to use discard but better to use Forget() if using UniTask

#

No idea if Awaitable is different or has an equivilent but i dont use it

stoic linden
#

hey, I quitted gamedev many years ago and slowly maturing to start solo project. Whats current industry standard language for coding server side (HTTPS/Rest + WebSocket)? I mean custom server, not looking on using any libs

#

Would it be Go? or C#? Not intrested in C++

scenic forge
#

I doubt there's an industry standard, and it is very likely requirement dependent. For high performance scenarios, some technologies might be ruled out, but otherwise case by case factors matter much more, such as what technologies your team is already familiar with, what technologies you can potentially hire for, what technologies there are existing infrastructure to host on, etc.

#

If you are building a backend that handles less than 10 RPS, I doubt it even matters what technology you choose.

austere jewel
#

This server doesn't have an area for non-Unity questions, you should ask elsewhere

plush hare
#

Anything real time you want UDP

#

Sockets in managed languages are awful btw. If you want speed, you want to interop into C++. Sorry.
Especially If you're going to do a custom job like you're talking about.

regal lava
#

Websockets + WebRTC what all the cool kids are doing if we're talking client hosting with a relay

#

Rather, websockets for the lobby and client discovery while the mesh is through WebRTC so TCP/UDP

stoic linden
# plush hare What kind of server? Is it a game server or something else?

Game server for mobile game yeah, but for an idle game where you send your "hero" on some adventure and after X hours you get something in return. There will be no real real-time gameplay, maybe in future I'd implement some mechanism during the "adventure time" where you'd get mobile notification and you have to click something that will affect the rewards at the end

stoic linden
stoic linden
regal lava
#

Not entirely sure of Unity's netcode for gameobjects transport layers, but fishnet library has support for it

stoic linden
#

Hmmm, but if it would be Websockets + WebRTC then that might be it. I can start off with Websockets and then add WebRTC if I have a need for p2p

#

Would using REST also be acceptable? For example if a player wants to do something like send the player on an idle adventure or something? (text based)

regal lava
#

Websockets is TCP so if you're making something turn based like checkers, sure. But otherwise I'd look into UDP if you're making some more action packed ;p

stoic linden
#

Mostly its going to be text based, but also plan to add more action side activities.. bit complicated but thats my idea πŸ˜› but maybe UDP... but it would be an overkill for most of the activities

compact ingot
#

Also you should make a clear and specific list of what data you need to sync, when and how often, list any security and persistence requirements for that data, required model for authority and user management, then maybe someone can recommend a tech stack

stoic linden
#

right, I will think about it and write something up later

compact ingot
#

If you want to make some thing custom, look at zeroMQ et al (framework for inventing protocols, as minimal as you like)

#

anything prefixed/suffixed with β€šwebβ€˜ will be very heavyweight and carry a lot of features you may not need but which may add convenience at the (significant) cost of performance

stoic linden
#

so I did a quick summary of main features I planned

Mobile idle game
A map where you have multiple instances - each instance have different mods, drops
You can send a player to the instance to fight for X time
Multiple players can be in single instance (as solo or team up from instance board) - slight server side interaction - eg. influence rng of loot
You can get a popup when inside an instance where you can decide what to do - boss encounter -> fight or not?
Crafting/ upgrading items - mixing up crafting materials to get certain items
Marketplace between players
Farming/ mining - possibly not an text based but action based, where you can controll your character just like other popular 2d mining/farming games
Leaderboards with profiles - I can see other players achivements and their outfits etc

Edit: I know thats not exactly what you mentioned, but might tell the idea

hybrid tundra
#

okay, I have theoretically finished other more important things with the NDA porting

#

so I have more time to understand things

#

what is Total Resident, Total Allocated, Allocated memory in table, and why all these 3 values differ?

#

because Total Resident/ how much memory of the allocated lurks in the RAM = 1.29 gb
allocated memory in table = 1.82 gb
total allocated/total memory in snapshot/how much memory I have allocated from the system = 5.10 gb

#

so if I understand correctly, the RAM (the Total Resident on device) is the only one needed to check regularly, right?

#

because its the one which must not proceed the max available RAM

dapper urchin
#

Has anyone used Bresenhams Line Drawing algorithm? If so i'd like to ask a few questions.

hybrid tundra
#

I guess we can't do anything about the Native part

#

so the only way to reduce the leak is to "attack" the elements in the list?

#

like NetAIController, FXCollection, etc.?

echo coral
#

45 mb is hardly anything to worry about

#

But fxcollection having 15k objects sounds high but I dont know what that does

hybrid tundra
#

if you check the top bars

#

6.46 gb -> 6.63

echo coral
#

ah but the managed size max is 74mb which is still probably fine

hybrid tundra
echo coral
#

Gotcha, probably leaking managed objects somehow. Do you use anything that needs disposal?

hybrid tundra
#

so its way better than before

#

but its still leaking

#

oh I wrote it down badly

#

so I mean this is one map loading and returning to main menu

#

but if I do this like 30 times

#

the memory will still be overloaded, and crash happens

echo coral
#

Then FXCollection and String going up by 15k+ may be the first places to look

hybrid tundra
#

or its also increasing the Native?

echo coral
#

ha yea that is what i said initially 😐
managed code should not affect native memory allocation

#

native includes native code, libs and other things such as NativeCollections and burst code

hybrid tundra
#

so I can't do anything with the Native part?

echo coral
#

expand it and lets see

#

Should include things such as audio data

hybrid tundra
#

ahh its so time consuming to make screenshots each time from a fully different computer and make that screenshot somehow passed into this other machine

#

ok checking it

echo coral
#

you can use discord on the web btw if that helps

#

if its allowed

hybrid tundra
#

I could use also app, but I don't want to place my personal stuff everywhere

#

but yeah, maybe browser version would be a good idea

#

faster at least

#

@echo coral

echo coral
#

Implying they come from jobs or other code using native collections

hybrid tundra
#

ok then it won't add much

#

I mean based on these, I believe I can't free much from this

#

the base memory allocation should be decreased further

echo coral
#

Yes unless you are using them yourself or have packages using them it's hard to know.
In the editor it can sometimes notify you of leaking native collections

untold moth
#

This is not necessarily from jobs. It's likely the names of the allocators unity uses under the hood.

hybrid tundra
#

ALLOC_CACHEOBJECTS_THREAD: TLSF Memory Block 152

#

ALLOC_CACHEOBJECTS_THREAD: TLSF Memory Block 150

#

etc.

untold moth
#

Ah, okay, it's under reserved

#

The fact that it's going up, probably means that your peak memory consumption is going up at some point. You should track that peak and investigate it.

#

Other than that, It seems like you have some material and material property block leaks. I'd look at code that duplicates or creates materials(possibly due to accessing material properties of the renderer) and consider if you can eliminate it. Some objects are leaking too, which could be related to the materials in some way too.

hybrid tundra
#

0.5 MB is also not much

untold moth
#

If the objects are related as well, it's like 1mb leak in total. And it's not clear at what point exactly this happens. It could be load related or time related. But anyways it will accumulate eventually

hybrid tundra
#

I mean that won't really solve anything

#

and I will still have other tasks in this 2 weeks

untold moth
#

If that's the only leak you have, it would definitely solve it

hybrid tundra
#

but its not

#

as you can see

untold moth
#

I can't

hybrid tundra
#

6.46 gb -> 6.63 gb

untold moth
#

That's the only leak we can clearly see in that capture.

hybrid tundra
#

its on the screenshot

untold moth
#

This is the reserved memory

#

It could be related. It's hard to tell without looking at the peak

hybrid tundra
#

constantly

untold moth
#

Well then share info from a peak

hybrid tundra
#

there were huge textures, which were already fixed

#

16 pieces of 8K textures constantly loaded into memory

#

I just tried to avoid solving that, because solving those took like a week

echo coral
#

manually created Materials do need to be destroyed manually too btw

hybrid tundra
#

and the solution is not optimal, but at least it works

#

@untold moth to check the current peak, there's a moment, when player returns from gameplay to the main menu, and there's a huge spike in memory, and then it stays around that

#

I tried to stop the game around that moment using Pix

#

but then I can't make Memory Profiler snapshot

#

if I stop the game using Pix

untold moth
#

If you're at the stage of using pix, I'd use it's memory metrics/tools to investigate the leak.

#

Other that that, I'd make profiler captures in the actual game, rather than the menu, as it's more likely that something is leaking there and just adds to the reserved memory in the menu scene.

hybrid tundra
#

according to Pix

#

if I understand it correctly, of course

#

there's much more memory reserved, when I return to the main menu

#

more than in the actual game

#

but most of it disappear, when I start a new gameplay map again, although not everything, hence the leak

#

what I can see is that there're still gameplay-related stuff staying inside the main menu from the gameplay

#

and its still originates from AssetBundles

#

but I have zero idea how to fix that, because I already made a manager weeks ago, which collected the Addressables handles and releases them, when I return to main menu

#

how to figure out which assetbundle could be that?

#

(its probably not directly referenced inside the assetbundle)

#

okay, it seems Duplicate Asset Isolation bundle stays in memory

echo coral
#

probably because many others depend on that if you didnt move assets after that was generated

hybrid tundra
#

not just Release

#

and this ReleaseInstance should be called, where InstantiateAsync was called

echo coral
#

thats for InstantiateAsync() GameObjects

hybrid tundra
#

yeah

#

but the project contains InstantiateAsync as well πŸ™‚

#

and I called simply Release on those

#

so this is what I'm adding now

echo coral
#

i probably mentioned this in the past but yea this should be corrected
Why unity cant make this be automatic I wish i knew

hybrid tundra
#

the bundle is still loaded in memory

#

how else should I do this? I placed this handle collection after each Addressables.LoadAssetAsync

#

and InstantiateAsync

#

what else should be there?

hybrid tundra
#

even when 1 asset is loaded, the whole bundle will be loaded?

echo coral
exotic trout
#

also if assetbundle b is dependent on assetbundlea you can't unload assetbundlea while assetbundleb is still loaded

echo coral
#

correct but in this instance addressables does this for us

exotic trout
#

ah fair, my sinful ass has exclusively good experience in raw assetbundles 😭

echo coral
#

I do much prefer addressables over the manual way but they really should have improved their functionality too
LET THEM REFERENCE INTO THE GAME FFS

#

I care because any legacy or semi old system that uses Resources really fucks things up

#

It was also a mistake not storing the address in the asset meta file

hybrid tundra
#

currently I just wish those 3-4 uncompressed bundles were the reason I had some elements loaded in memory from a compressed bundle

exotic trout
#

i would love to know if a given object was sourced from assetbundles or build resource files

#

so badly

exotic trout
#

at runtime πŸ˜›

#

i do weird stuff with unity dw

hybrid tundra
echo coral
#

perhaps the group needs to be split into multiple bundles (via the group settings)

echo coral
hybrid tundra
#

okay, so I ask again, just to be sure.
When an addressable bundle is the reference source of some assets in Memory Profiler, how to make it release from memory?
Things I already did:

  • created a manager which collects handles from Addressables.LoadAssetAsync and Addressables.InstantiateAsync, it releases all handles when needed. (LoadAssetAsync handles with Release, InstantiateAsync handles with ReleaseInstance((GameObject)handle.Result).
  • I also call Resources.UnloadUnusedAssets and GC.Collect after releasing these handles.
  • There's a LoadSceneAsync in the project, but I have checked it multiple times that it doesn't get called at all, with debugger, connected to the NDA build.
  • I have setted the Uncompressed bundles to have LZ4 compression, because I have read that when an asset is loaded from an Uncompressed bundle, the whole bundle gets loaded into memory.
  • I ran the "fix duplicated assets" (or it has some kind of similar name).

What else could be there?

echo coral
#

Make sure you are releasing the correct amount of times (e.g. asset "foo" is loaded 3 times so it must be released 3 times to fully unload)

#

If your manager only loads once from addressables it should not be an issue

hybrid tundra
#

hmm ok

#

collecting ideas for tomorrow

#

what else could be there?

echo coral
#

I think splitting up large groups into smaller ones OR changing the pack mode to produce more bundles per group will help

hybrid tundra
#

I wasn't the one who created these bundles

echo coral
#

the asset bundle group settings

hybrid tundra
#

Oh and I also ran the "fix duplicated assets"

#

a week ago

stuck plinth
undone coral
echo coral
#

with addressables it wont help and will make things worse

undone coral
echo coral
#

yes but right now its addressable related

#

this topic has been ongoing for like 2+ weeks

undone coral
undone coral
#

i think the user is pooling particle effects and everything looks normal to me

#

you load something, you play some gameplay, you instantiate stuff into pools

#

the addressable has nothing to do with it

#

am i wrong? hmm...

#

@hybrid tundra so i think if your gameplay populates pools, well, those will take up memory

undone coral
# hybrid tundra

i don't think this is a big mystery. you are loading a scene, it has a class in it that is a pool, you keep instantiating objects in this pool. i mean you should see it in the hierarchy when you're playing in the editor

untold moth
hybrid tundra
hybrid tundra
bold bronze
#

I am making my own fps engine from scratch. I have the gun model attached to the palm bone of the first person hand model. I am trying to implement ADS but I don't know how I would go about centering the gun reticle to the center of the screen. Does anyone know how to go about it?

#

The only idea I have is to switch to IK and just lerp the gun model to the center

untold moth
untold moth
# hybrid tundra I don't really understand what you mean

Basically, you have a box to fill up with stuff. When you play the level scene, it's not enough to hold all your stuff, so you take another box and put stuff into it as well. However when you load back the main menu, you free up the boxes. You still have 2 boxes, but now you don't know what was in them, so you can't troubleshoot it. The next time you load, you have 3 boxes with stuff. But when you load the menu level you're left with 3 empty boxes again and have no clue why you needed the extra box in the first place. Makes sense?

hybrid tundra
hybrid tundra
#

I know exactly which assets were loaded only for the gameplay

untold moth
hybrid tundra
#

and shouldn't be in the main menu

hybrid tundra
humble leaf
#

Can you start using threads?

untold moth
untold moth
#

And, yeah, I think by now it's a good idea to create a separate thread.

fathom ferry
#

Hello πŸ™‚

I'm trying to fix all the memory leaks I have in my game.
Most of those are coming from events not setted to null / badly unhooked.
I'm taking care of those

BUT, I also see clones of DepthOfField and ScreenSpaceAmbiantOcclusion.

I'm using HDRP, on 2022.3.62, with Cinemachine, Timeline
Do you have an idea what could create those clones / how can I clean them ?

#

Note: Those were detected by Memory Analyser, on a PS5 build.

hybrid tundra
untold moth
fathom ferry
#

except; I have a leak of those

#

(^this is not my game)

fathom ferry
untold moth
fathom ferry
#

would a Volume in the scene do a Clone of its overrides ?

untold moth
fast palm
#

Hey everyone ^^
I'm currently experimenting with AR Foundation for mobile AR, and I’m trying to accurately align the virtual and real world in specific locations, like precise rooms or outdoor spots.
The goal is to overlay both worlds properly, so that my 3D content fits naturally into the environment β€” whether I'm indoors or outdoors.
So far, I’ve tried:

  • Photogrammetry, to get furniture positions and rough geometry
  • AR Tracked Image Manager in Unity, to spawn prefabs based on markers
    Right now, I represent furniture with basic cubes, using a shader that hides my virtual objects when they’re behind those shapes (kind of like fake occlusion).
    But I’m still struggling to accurately recreate real-world volumes in Unity, and get a satisfying overlap between real and virtual. Things never feel 100% aligned.
    Has anyone here tried something similar? Or found a good workflow or tool to make this easier?
    The idea is to have a marker that spawns a prefab, and that prefab should properly interact with the space around it.
    Thanks a lot πŸ™‚
austere jewel
harsh grotto
#

time for this to be flooded with beginner questions πŸ˜„

humble leaf
#

πŸ‘€

kindred wyvern
#

Is it ever acceptable to use a lambda for runtime functions?

#

'Cause it seems like an easy thing to abuse.

queen plover
#

When two general codes love each other very much...

austere jewel
#

I'm unsure what you mean by runtime functions though

#

If you're not creating a closure they're ideal

kindred wyvern
#

Using it not as a tool for simplicity (or as a paradigm) but generating instructions based on context-dependent stuff.

zenith ginkgo
silent fjord
#

inb4 begginer q's

austere jewel
#

I got in before people started posting that repeatedly

zenith ginkgo
#

We got what we asked for, be thankful hehe

flint sage
potent moat
#

Lmao

untold moth
#

It might actually turn out that no one is gonna use this channel.πŸ˜…

sturdy edge
#

dunning kruger. those who know their stuff, dont think their code is advanced shrug. Or that those who know their stuff, rarely need help

flint sage
sturdy edge
#

those who don't know the basics, won't know what sort of issue they have. should probably bring that up in #531949462411804679

stable spear
#

Does CreateExternalTexture() take ownership of the nativeTex, or does it expect the plugin to manage it's lifetime externally?

tough tulip
hot gale
#

I'm having a strange issue where for some reason, my server isn't hitting any colliders when firing out raycasts while using AdditiveScenes loaded via Async

#

left, Server; right, Client;

#

the white dot is placed either at the maximum length of the ray, or where it hits something

#

does anybody know what might be causing this?

sturdy edge
#

you can edit your message

tough tulip
hot gale
#

All of those are verified

#

Because the Ray is still placing the white dot as its maximum distance

tough tulip
#

like Additive sync, or single sync/async

hot gale
#

This didn't start happening until I was using Additive Scenes

#

No collisions work on the server side either

tough tulip
#

not client as well?

hot gale
#

Client is still able to collide and raycast normally

#

But the server game object for the client just acts like the walls don't exist

tough tulip
#

which unity version?
doesn't look like intended

hot gale
#

2020.3. Something

#

It doesn't seem to be an issue with the Ray or the network

tough tulip
#

if you're able to reproduce it in a new minimal project, you can file a bug report

hollow garden
#

new coding channel pog

broken socket
#

Oooooh nice

mellow saffron
#

what should i do in here to get
let's say BoxCollider2D?

flint sage
#

Idk getcomponent probably?

mellow saffron
#

I USE POLYMORHISM

#

AND I DID ALL WHAT I WANT

untold moth
#

Is it a redundant way to cast a type? πŸ˜…

sage fox
#

Does anyone know how to get the information shown in transitions in code? i want to know what the next state will be. So, if i am in State A and I want to know the next state will be B etc.

I tried to use Animator.GetNextStateInfo but it doesnt seem to give me the Info of state B when I am in State A but only does this just before entering state B

untold moth
#

Although, I feel like this api is limited to the Editor only.

sage fox
#

So how would I go about getting all the transitions? I am trying to do this in c# and the documentation says that GetNextStateInfo should give me the info of the next state but it does not do so

untold moth
#

are you trying to write an editor script?

#

Because AnimatorTransition seems to be in UnityEditor.Animations namespace.

sage fox
#

No, its not an editor script.

untold moth
#

Then you can't use that

sage fox
#

That link you have sent me seems to have what I need.

untold moth
#

But you can't use that at runtime lol

#

in the build I mean

#

Why do I need to repeat myself 3 times?

sage fox
#

Yeah I know I'll try to find a workaround

untold moth
#

There's no workaround. You just can't use it at runtime.

#

What are you even trying to do?

sage fox
#

I get it, I meant I'll try something else not using that.

#

Just trying to create a game mode using overrides but it is tricky.

untold moth
#

What overrides?

sage fox
#

Using the animator override controller

plain abyss
#

Oh hey this channel is new

sage fox
untold moth
#

I don't see how getting next state is related to override controller though..?πŸ€”

lucid echo
#

hey, having a problem with HDRISky, i have this script but it doesn't apply to the sky, any help appreciated πŸ™‚

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;

public class SceneSettings : MonoBehaviour
{
    HDRISky HDRISkyExposure;

    [SerializeField] CubemapParameter[] cubemaps;

    void Start()
    {
        HDRISkyExposure = GetComponent<HDRISky>();

        int randomnumber = Random.Range(0, cubemaps.Length);
        HDRISkyExposure.hdriSky = cubemaps[randomnumber];
    }
}
vivid nova
#

Hi,
Is there any workaround to allow calling a constructor with parameters for a templated type? (In C++ the compiler would check if the parameters are correct when instntiating the template).
So far It seems you can only instantiate template types that have a default constructor.

In particular in my case all the possible template types have to inherit from a specific parent and use its same constructor parameters. But it seems like I can't add a "new" constraint with type parameters

#

something like this perhaps (where Cell's constructor takes FortuneSite and Polygon as parameters)

#

Maybe it's doable with some reflection magic?

pure dock
# mellow saffron

you need to cast to BoxCollider2D or check if it is one first, then return . . .

upper umbra
#

Idk if this be belongs here but my friend really needs to fix his voxel engine and I want to help him
could somebody help figure this out

so the red line on the floor is the normal voxel grid
but if I move the chunk, about in the middle of the line and then place a cube on top then it will be set in its own rounded position

Do you happen to know which offset from the 3d position would be needed if I could fix the placed cube correctly on the grid of the chunk, which is right in the middle of the grid?

shadow seal
#

Why are built blocks separate cubes?

#

Is the chunk also made up of separate cubes?

agile yoke
# vivid nova Hi, Is there any workaround to allow calling a constructor *with* parameters for...

C# doesn't support constraints like that unfortunately. There's a couple workarounds:

  • enforcing a parameterless new() + enforcing inheriting from a base class and then putting an abstract void Init(FortuneSite, Polygon) in that
  • Creating the instance via reflection / Activator.CreateInstance
  • Requiring whoever creates the Voronoi instance to also give it a function/delegate that it can call to construct a new object of the required type
upper umbra
agile yoke
# agile yoke C# doesn't support constraints like that unfortunately. There's a couple workaro...

The first and third option still let the compiler check that your types line up, which is nice; the second one doesn't.
The first can be annoying / awkward when you also want to use the types outside of this context, because then you'd probably just want normal constructors.
The third is often nice, but depending on how your code is structured exactly it can sometimes be rather annoying too.

shadow seal
upper umbra
#

yes

#

"why wouldnt you do it like that lmao" he said

shadow seal
#

Lets see some of the workings then

upper umbra
#

what do you mean with that?

shadow seal
#

The scripts pertaining to the creation of chunks and blocks?

upper umbra
#

he says that he only rounds up the position of any placed voxel, but he knows that he needs some kind of offset to fix it when placing at a chunk

regal olive
#

Is it possible to add additional data to store with all Mesh assets (not gameobjects)? For example, baked SDFs or some custom LOD format.

hot gale
#

Does anyone have any advice for using Contact Filters?

#

I have a top down 2d game with one room on the bottom floor, one room on the top floor, and a stair case

regal olive
#

I'll give that a shot

#

Is there some way I can trigger a call to AssetDatabase.AddObjectToAsset whenever a mesh is imported (without using a ScriptedImporter)?

silk trench
#

How long has this channel existed? I could've sworn it wasn't here yesterday

#

Oh wow it literally did get added yesterday

#

Anyways

#

I have an idea for a "better ground check" with capsule colliders and I want to get my fellow professionals' feedback

hard lily
#

In my opinion this channel should be renamed to general-code #2

#

@silk trench Just throw the idea out and then ask for feedback, you are more likely to get answers or people willing to do it

silk trench
#

Basically, instead of like a Physics.CheckSphere at the bottom of the player or a ray that gets casted down, the player will have a simple OnCollisionEnter that gets the points of which the collision happened (a Vector3) and if it's above some threshold, then we're grounded

#
private void Update()
{
    if (IsGrounded && Input.GetKey(KeyCode.Jump))
    {
        ourRigidbody.AddForce(0.0f, this.jumpForce, 0.0f);
        IsGrounded = false;
    }
}

private void OnCollisionEnter(Collision other)
{
    float bottomOfPlayer = this.transform.position.y - 1.0f;
    float threshold = 0.125f
    foreach (ContactPoint contact in other.contacts)
    {
        if (contact.point.y < bottomOfPlayer + threshold)
            IsGrounded = true;
    }
}```
#

That's most likely more performant than a raycast since it relies on callbacks instead of checking every frame

#

And you don't have to check if the player's velocity is less than zero or anything because it uses the actual collider on the player

#

What do y'all think?

vestal heath
#

We can’t say if you don’t show us how you determine if a player has jumped

#

+it’s all nice and dandy but you’d have to make sure that your side collisions don’t set you to grounded… which will be tricky to do

silk trench
silk trench
#

Because the curved part of the collider is only 0.5 units tall, so you just normalize the slope height using the max height in the Lerp

vestal heath
#

I mean, you can also just stop the check for grounded if isGrounded becomes true

#

Checking 1 bool even every frame isn’t bad

silk trench
#

Are you referring to character controllers?

vestal heath
#

if (!isGrounded)
// check

#

I refer to β€žmore performant coz it relies on callbacks”

silk trench
#

That's just one benefit though

#

Like in the character controller I'm making, you can hold space to bunny hop, but if I use Physics.CheckSphere to check if my player is grounded, all of the tutorials I've seen have the center of the sphere at the bottom of the player

#

Which allows for the player to be considered grounded when they're really not

#

So this fixes that in a sense

vestal heath
#

I mean

#

sure it works

silk trench
#

I'm trying to get critiques about this method

#

So let 'em rip

vestal heath
#

My only concern are all the edge cases you’ll have to cover

#

And then trying to add a new obstacle, platform, whatever, may be so tricky to do

#

But I dont know your game

silk trench
vestal heath
#

I just dont really see the point of reinventing the wheel if you dont have to

#

Being different just for the sake of being different is not better

silk trench
#

No that's not why I'm using this

vestal heath
#

Well, for example, let’s say you’ll want to add wall climbing to your game

#

Like in Celeste

#

Suddenly your method becomes invalid

#

you want to consider your player β€žgrounded” when stuck to the wall too

silk trench
#

So then increase the threshold?

vestal heath
#

Let’s say you have an obstacle that doesn’t allow your player to jump, idk - a sticky puddle.

vestal heath
#

How are you gonna handle side collisions

#

Your wall is at 90* and your box is at 90*. You can climb your wall, you can’t climb your box

silk trench
#

You could probably just increase it to be right at the curve at the top of the player collider

vestal heath
#

I’m not saying your method is bad… but is it good? Case by case basis, basically

silk trench
silk trench
#

But I'm wondering for just like a 3D game using a capsule collider, what would be a problem (if any) using this method?

vestal heath
#

But dw, that’s everything in programming. Idk if you work alone or with designers but if the latter, you don’t wanna create potential rabbit holes for them to explore

#

They have a weird 6th sense to find them and abuse them and then complain if things are breaking because they dont use them the way they were intended to πŸ˜›

silk trench
#

Lol very true

untold moth
#

@silk trench donno if it was mentioned yet, but you'll also need to use OnExit to determine when the collider leaves the ground.

silk trench
#

But I am now just realizing

#

that that only works for when the player jumps

untold moth
#

What if the ground is uneven?

vestal heath
#

^

#

Edge casessssss

silk trench
#

That's simple though, you add a collider variable to the class, and if we become grounded, then set the collider to the collision's collider

#

and if OnExit is called, we check to see if it was our collider variable

#

if so, we're not grounded

untold moth
#

There's also the case of ground changing angle. If you want to adjust speed for the slope, you'll need some way to determine the new hit normal.

silk trench
#

I was thinking about that and I'm not too sure

#

other than using a ray of course

#

Well I could just stop worrying about every little bit of performance and use a ray on top of it

untold moth
#

And I don't see a way aside from OnCollisionStay. Which is probably not a lot better than just raycasting everyframe. Needs testing, but the performance difference is probably negligible.

silk trench
untold moth
#

To get collision info every frame.

silk trench
#

oh you mean for normals

#

My bad

untold moth
#

Yes

silk trench
#

Yeah

vestal heath
#

Hey, want better performance? Drop Unity and start using C++ or at least Unreal

#

You’re welcome

silk trench
#

I'm not really using this method because of the performance though, that's just something that I thought would be a nice side product

vestal heath
#

? Are you trying to tell me Unity games are as performant as any other engine using C++ natively?

silk trench
#

No of course not lol

#

But I'm definitely not going to deal with C++'s runtime errors just to get a bit of performance

vestal heath
#

Then stop worrying about a single bool check in Update lol

#

(Also, c++ >>> c#)

vestal heath
#

(Fight me)

silk trench
#

OKAY LITERALLY FIGHT ME RIGHT NOW 1V1 BEDWARS HYPIXEL

#

YOU WONT

#

I'll represent the C# programmers and you, the C++ programmers

vestal heath
#

Insta win for me, gg ez

silk trench
#

damn it

#

i forgot c++ users were gods

silk trench
#

therefore c++ is being moved into c# and c# is doing whatever the hell bitshift ops do

#

I totally forgot

vestal heath
#

It… shifts bits

silk trench
#

Ah, right. I'm so silly...

vestal heath
#

And this is old way of programming not really used anymore unless you write some very custom low level libs lol

#

Comes up at interview

silk trench
#

Ew

vestal heath
#

And I sometimes see it in my codebase

silk trench
#

Never had a programming job (or a job) but that's definitely something I don't wanna do

vestal heath
#

Funfact, pretty much all collision layers i’ve seen in my life are bitshift int 🀷

silk trench
#

Huh

vestal heath
#

Unity included

silk trench
#

So then Game Engine development is out of the picture for me?

#

Goodbyeeeee EA job interview

vestal heath
#

Nah, as long as you dont deal with physics libs lol

silk trench
#

Man that sucks

#

Physics is the stuff I'd want to get into

vestal heath
#

I work in AAA and never had to use bitshift

#

I see bit operations sometimes

untold moth
#

I'm using bit shifting frequently to define LayerMasks in code

vestal heath
#

But i dont even worry about them

silk trench
#

Yeah I was thinking about that

vestal heath
#

Yeah thatms what i mentioned

#

int layer = 1 << 8

silk trench
#

I don't understand how you could store virtually a list of ints into a single int

vestal heath
#

And that’s in all physics libs I’ve ever seen in my life lol

silk trench
#

Which is what I assume it's doing? Don't quote me on that though

untold moth
#

in other words bits

#

bit shifting just toggles one of them on

#

you can have 32 bits toggled on/off

#

32 bools

silk trench
#

Right

#

But how do 32 bools store multiple integer values

austere jewel
#

You cannot store ints in an int, it's basically storing a list of bools in an int.
Though, you can use those 32 bits to store other data like shorts, or something compressed

austere jewel
vestal heath
#

Yeah they dont lol

silk trench
#

I guess I'm not fully understanding how layer masks work in the first place

austere jewel
silk trench
#

Oh dude you've got everything

austere jewel
silk trench
#

Β‘Gracias!

#

How long did it take you to set this site up?

austere jewel
silk trench
#

Huh that's pretty neat

vivid nova
vivid nova
austere jewel
#

I kinda think if you're dealing with performance issues with C# and switching to C++ to solve them you're probably doing something wrong.
Unity providing HPC# with the job system and burst compiler now makes performance easier to achieve in many hot paths

#

That said, I'm really looking forward to free performance boosts elsewhere as Unity upgrades their .net version, their ancient version of mono, and boehm gc

vivid nova
#

I just have styling and safety issues. Const correctness, inter-class friendship, and the elephant of templates

#

the day a language has both C++ levels of const correctness and templates, and on top of it compile time reflection, that day I'll be a happy man

austere jewel
#

I definitely look forward to every improvement made to C# generics, and there's powerful things Unity doesn't have access to yet that enables you to template and create all sorts of things with little boiler plate, like Source Generators. C#'s also been improving on other things, adding more readonly, parameter modifiers, records, etc. The language only gets better over the years so for me C# gets closer to a dream language as time goes on; but it's partly because I've always liked the level of specificity and abstraction it tends to work with. People who like C++'s level seem to like rust and go, java to kotlin, people who like JS and its ilk might be happier with python. You become attracted by what's in your niche and previous experience imo

digital verge
#

Hey

#

I'm try to Spawn some gameObjects using Coroutines using If statement

#

The condition for If statement is true after few moments the game starts

hard lily
#

You can't post codes that big, it gets auto deleted @digital verge

#

Or is it someone else doing it?

cursive horizon
digital verge
#

The Coroutines is not starting

#

Can anyone help me

flat marsh
#

Do you actually start it? And assuming you do, it will check the condition once when you do and exit out of it, as it doesn't loop

livid kraken
digital verge
livid kraken
digital verge
#

Thanks

stable spear
#

Is it possible to render text (e.g. from TextMeshPro) directly into a Texture2D, without having a RenderTexture + hidden camera?

kindred tusk
stable spear
#

hm. Maybe I could read the mesh and project it onto the texture myself?

kindred tusk
#

The mesh is not tight to the characters, it relies on a shader with a distance field input texture.

#

Why not just use TMP directly instead of the texture?

stable spear
#

trying to make a complicated interface on a flat surface in VR (user interfaces using laser coming from controller), and there's a lot of stuff I want to do that is not easy to imagine with TMP

tough tulip
#

isn't that what world space canvas is for?
UI does work with the far interaction pointers

stable spear
#

you talking about the XR interaction toolkit stuff?

tough tulip
#

no world space canvas is a unity stuff

stable spear
tough tulip
#

far interaction pointer is well whatever sdk you're using. I assume ovr or mrtk

stable spear
#

*world space canvas UI components

tough tulip
#

It does work with MRTK if you have it in your project. Even if not you can add your own logic from EventSystem to detect clicks, hover

remote oar
#

Hi, i have a question about networking.

I have added RSA encryption from client-to-server , but im not sure if you should add it both ways. The Server-to-client communication is not encrypted. Should i add it in both sides?

tough tulip
remote oar
#

ok thanks

kindred tusk
#

TMP has UI elements.

#

Also... TMP is flat by default... I don't see why that would be an issue?

stable spear
#

well, one example is I want to do scrolling text. This means text that is cut off from the top or bottom (or sides) partially renders

#

I haven't found the right knobs to push to get TMP to do that

kindred tusk
#

it's not hard

#

If you want the text to scroll you just need to move the text object up and down

stable spear
#

hm. I'll try that, thanks

polar drift
#

is there a way to force-add code to a build? i've got a package with some code in it that is used in builds, but doesn't seem to work unless i have an extra script referencing the package code inside the main project

polar drift
#

just tried applying that attribute to all top level structs and classes in the package, still no luck.
im using a modified version of a package that adds DualSense controller support to the input system ("modified" because my fork supports IL2CPP builds). i can probably just keep a tiny script in the main project and not attach it to any objects for now 🀷 thanks though!
https://github.com/ryanslikesocool/UniSense

pale wolf
#

I'm curious when saving would people here prefer doing reflection, attibritues or just an ISave interface with a function like SaveYourself (or maybe some combo...)
It feels like there's enough pro/con to each that I still don't know what I'd pefer

#

This is like making a "save game" function I mean

flint sage
#

Interfaces are really the best for this

pale wolf
dusk juniper
#

@remote oar Just checking, you're doing a public-key setup and not a pre-shared-key, right?

remote oar
#

If you know what I mean

dusk juniper
#

Yup, perfect. Just checking

remote oar
#

Private key is only used for decrypting

dusk juniper
#

I'm doing something similar in my login system. C# apparently makes it stupid easy.

remote oar
#

Yeah I'm having some issues as well regarding the buffer size as rsa can only encrypt 256 bytes max which is unfortunate

#

My packets can be longer

#

Trying to combine them now somehiw

#

Split them up

dusk juniper
#

Oh, I actually missed that. That's good to know.

remote oar
#

Yeah keep it in mind

#

Normally rsa is only for small data to be sent

#

But once you have big data, it will say bad length

#

So you'll have to split the packets up and combine them somehow

#

And encrypt each packet

#

At least that's how I want to do it

dusk juniper
#

Yeah, in my game I'm not too worried beyond encrypting passwords before sending to server, and hashing them on the server side. So a 256 character limit isn't the end of the world. But yeah, the packet splitting seems like a reasonable solution.

remote oar
#

I see

#

Maybe you could consider it in the future to prevent man in the middle attacks or preventing players sending packets (which can lead to hacking)

dusk juniper
#

Yeah I'm not opposed to the idea.

remote oar
#

BTW if you're using a 128 byte rsa key you can only use 128 bytes

#

I'm using 256 so it's best to generate a larger one

dusk juniper
#

I actually don't know what my key length is, I'm using the RSACryptoServiceProvider defaults at the moment.

remote oar
#

Sec

#

Sorry 2048 bit key I meant

#

Change the second parameter to true when you're encrypting and decrypting with this example

dusk juniper
#

Hrm. Okay, so I missed that I can specify key size in the constructor, I'll patch that. And I don't really understand the importance of the last comment, the fOAEP bool I'm not sure about.

remote oar
#

Yeah me neither but when it was false the encryption and decryption did not work for me

#

For some reason

dusk juniper
#

Oh, it's working for me

#

I also base64 the byte data before sending it, I don't know if that matters.

byte[] data = Encoding.UTF8.GetBytes(password);
byte[] cipherText = session.Provider.Encrypt(data, false);
string encryptedPwd = Convert.ToBase64String(cipherText);
remote oar
#

Not sure tbh

#

Maybe its also because you're only sending strings

#

I'm sending slot of different data types

#

Alot*

dusk juniper
#

Could be a factor

remote oar
#

Yeah aslong as it works for u it's fine I guess 😜

regal olive
#

Hi there

#

I need some help with an architectural design decision

#

Is this channel right for something like this?

kindred tusk
#

I think so

tough tulip
#

depends on the context.
if you want an architectural design help for printing hello world, maybe not.

kindred tusk
#

Provided you mean software architecture

regal olive
#

okay

#

so my question is the following:
I am building a shop for my mobile game, in this shop are some packages you can buy via InAppPurchase and some you can buy with InGameCurrency. I want to build it modular, with scriptable objects defining the different packages you can buy. So far so good doesnt sound that complicated. But I dont get my head around, how to impleted that you can ether define a package to be purchasble with InAppPurchase or to be buyable for currency in a clean way. Should i even put these two together or are these seperate systems? It somehow makes sence in my mind to put them together, because they share the same properties except the way you buy them. But maybe i am wrong

#

If someone has time here, i would also hop into a call to discuss about it πŸ˜„

kindred tusk
#

Just have a checkbox or enum field to change it

#

SO is essentially config, so unless you are going to have completely different code paths handling them you'll probably benefit from using the same class.

#

i.e. if you have a top hat in one and a baseball cap in the other, you're going to be checking for those in the hat selection screen. Separating them would mean extra code in the hat selection screen, and any other such screen.

regal olive
#

ok thanks πŸ™‚

#

I dont realy like checkboxes or enums for changing how code handles SO, but i dont have i better idea.

kindred tusk
#

Better change that attitude if you want to get the most out of them

regal olive
#

Yes shure they are

gray pulsar
# regal olive ok thanks πŸ™‚

Will you ever have packages that can be bought with either in game current or IAP? "Costs 10 gems or $2.99"? You could include two cost fields in the SO for each type of cost, with some kind of "not valid" value for each (maybe -1)

kindred tusk
#

in the last week or two

regal olive
# kindred tusk Better change that attitude if you want to get the most out of them

i am totally with you, what i meant was that i dont like to have a switch like an enum or bool in an scirptable object that tells the code to use/not use parts of the SO, like it would be in this case. The IAP Package needs informations like price and so on and the packages buyable by currency need the information which currency and what amount of currency. and this Bugs me because it feels a bit messy

#

but maybe i have the wrong attitude here to

humble leaf
broken socket
#

It's been 2 days ago

#

yeah 2 or 3 πŸ˜›

kindred tusk
#

However you can use SO inheritance, but I don't think it's a good fit for this problem

kindred tusk
sage radish
austere jewel
#

With serialised reference theypractically do

sage radish
#

Someone just has to make a generalized package for it and put it on GitHub

rocky zephyr
#

You can have scriptable objects with plug-ins. Obviously not unity β€œcomponent β€œ but of your own design.

lone hare
#

Does anyone know if its possible to run a game via the console?
So in other words, i have a game that doesn't have support for dedicated servers yet and only has the possibility to host games as both a client and a server. So i was thinking if its possible to just run the game in a console window and instead of using user interface inputs, you write in the console what input you want to do? For example to host a server normally i need to press on a host server button and then adjust the settings i want for the server. Would it be possible to someone run this in a console window and call the host button click function and then changing the settings from the console and hosting a server this way instead of having to use the gui in the game to do so? Or am i just saying nonsense right now πŸ˜›

sage radish
wise bobcat
#

hello

unkempt nova
#

I'm looking at the docs for SerializeReference, but I don't understand its purpose. Could someone translate to Idiot for me please?

#

i.e. what's a use case?

#

Does it just let you reference things that don't derive from UnityEngine.Object?

vestal heath
#

it serializes your field as a ref type rather than value type

cursive horizon
#

hahaha, helpful

cursive horizon
unkempt nova
#

Ah, ok. Thanks for the use case

balmy field
#

I was hoping to write an edutainment kind of game. Do any of you know if there is a way to have a in app/game runtime c# compiler

hexed meteor
#

Hey guys, can someone tell me why this throws a transform out of bounds error at line 28

unkempt nova
#

Think there's an asset that'll do it using Roselyn

hexed meteor
#

It has me stumped, I don't get it at all

cursive horizon
hexed meteor
#

how do I debug it ?

cursive horizon
#

i is larger than the number of children so you need to find out why

#

maybe it's because it persists between loops? I forget

hexed meteor
#

okay so I did the debugging

#

and nothing happened

#

I still got the error and and I'm not a little bit wiser

#

thanks for the help though!

long ivy
#

what do you think is happening on line 28?

hexed meteor
#

get child of index i of the gameobject the script is attached to

long ivy
#

you remove a child on every loop

hexed meteor
#

and set its parent to the childRotator of index i

cursive horizon
balmy field
cursive horizon
hexed meteor
#

@long ivy oohhh... hang on I think I get it now

#

that's right

#

duh I'm a dumbass

#

thank you!

velvet silo
#

I moved it over to physics

wraith snow
#

hey all, anyone got like quick and dirty way to make a save file with nested objects?

compact ingot
# wraith snow hey all, anyone got like quick and dirty way to make a save file with nested obj...

You can use System.Runtime.Serialization like so:

IFormatter formatter = new BinaryFormatter();  
Stream stream = new FileStream("MyFile.bin", FileMode.Create, FileAccess.Write, FileShare.None);  
formatter.Serialize(stream, myObject);  
stream.Close();
  • Also there is Message Pack https://msgpack.org/index.html, if you want the resulting files to be smaller and serialization to be faster.
  • Other than that... if your objects can be mapped to JSON, just use Newtonsoft.JSON
  • Or keep your game state in a SQLite database and use the data-file as your save-file
wraith snow
#

@compact ingot im just serializing poco classes, do I need to tag with [serializable]

#

I'll move to a db later

#

when the game is nearer completion

#

i just need a persistent state first

compact ingot
#

quickest/easiest way to save objects with primitive types, arrays, dictionaries and such is Newtonsoft.JSON

plain abyss
#

This is like, the opposite of advanced code. This is barely even beginner

frozen imp
#

!warn 219192399103131649 You've been told already to not cross-post.

thorn flintBOT
#

dynoSuccess Dallen#5711 has been warned.

plain abyss
#

Then maybe you should read it and stop wasting everyone's time

#

make a vector3

#

question answered.

shadow seal
#

If only you'd thought of using the world's biggest repository of information rather than spamming your beginner question everywhere

plain abyss
#

I did.

frozen imp
plain abyss
#

But since I didn't literally write your code for you you haven't accepted it

#

Piss off

frozen imp
#

Keep it civil, please.

plain abyss
#

That's not going to work on me. I don't need to prove myself to some kid who can't google how to make a vector

frozen imp
#

@scenic cedar Cleanup your bio as well, or you will be removed from the server.

plain abyss
#

It's actually a drawing of me I got done by a professional animator I met at a convention, but still, keep shooting off and not solving your problem. You've also chosen to post this in #archived-code-advanced where all the helpful people reside, and started shitposting, preventing any of us from wanting to help you.

Have fun googling, and remember to post in #πŸ’»β”ƒcode-beginner when you have no idea what you're asking about

#

There is, and there is

shadow seal
#

It's a lie

frozen imp
#

!ban 219192399103131649 Ignoring warnings.

thorn flintBOT
#

dynoSuccess Dallen#5711 was banned

plain abyss
#

And there was much rejoicing

dense aspen
#

missed it

humble leaf
winged mirage
#

k

hot gale
#

Hey guys, I have an FOV mesh for a 2D game to simulate a fog of war; does anyone know the best method to smooth out the shape of the mesh when moving around? Due to the fact it sends rays at intervals, and the walls are square, it sometimes creates little diagonal sections that go through the walls

long ivy
misty crescent
#

Why can't I make an API call in my Unity game server when running in a docker container?

flint sage
#

From the container to the outside or from the outside to the container?

tough tulip
misty crescent
misty crescent
flint sage
#

And what are you failing to connect to?

misty crescent
#

error code: UNITYTLS_INTERNAL_ERROR, verify result: UNITYTLS_X509VERIFY_FLAG_NOT_TRUSTED
this is the error I get..(the API calls are happening via AWS SDK)
is this a TLS verison mismatch?

tough tulip
tough tulip
misty crescent
#

so my API call to AWS fails (btw, this works just fine in editor or on an ec2 instance, only container is the issue)

tough tulip
#
  • create a new class AcceptCertificate inheriting from CertificateHandler
  • override ValidateCertificate boolean method and return true. it also takes in some parameters don't forget to implement them just for function templates to match
  • uwr.certificate = new AcceptCertificate();
misty crescent
#

uwr.certificate = new AcceptCertificate(); I run this right when my game starts so I can start making my API calls?

flint sage
#

That's not a great idea, you'll accept any ssl/tls certificate

misty crescent
#

yeah, thought so

tough tulip
#

yes that's a point too^
but the error message is straight forward. there's nothing much you can do in code

misty crescent
#

hmmm

misty crescent
tough tulip
#

you have to request ssl/tlsl for aws. I don't use aws but I know lots of people who do

misty crescent
#

But just a question (Just to get this working for now)
UnityWebrequest doesn't have a property called certificate. So I can't set it

tough tulip
#

it exists for instance

misty crescent
#

But how does this work? I'm not doing UnityWebRequest.get..

I'm calling the AWS SDK's methods

tough tulip
#

can you modify the sdk?

#

if you have the source. if not then maybe use your own method?
again the correct solution is to fix your ssl/tls

misty crescent
#

also, just a conceptual question
Why does this issue not exist on my editor/ec2 instance (This is my server build)
But only does when I deploy my build into a docker container?

tough tulip
#

no idea. if you're interested into digging more just go through the certificate data. that gets validated.
but again since you don't have access to sdk it's a closed box and I can't really say what's happening underneath

flint sage
#

Look at the certificate chain

silk sable
#

So I was wondering, I am making this top-down 2D shooter against zombies type game, and I have these guns that I want the player to be able to pick up, and drop whenever they want, I also have UI to sync with that.
I already implemented this twice both working but what worries me is the way I organized it.
Earlier I used to have one script that did everything on the gun, but now I've separated it into the scripts the gun holds, one for when the gun is on the ground and one for when it's in the player's hands (they both enable and disable each other when needed).
I don't know if either of those are the most optimum way of implementing it and I'm spending a lot of time worrying about that so I wanted to know what you guys think about it

elder dome
#

I would spawn a prefab when you drop the gun with the appropriate data and scripts related to picking it up, and have a simple PlayerWeapon component on the player that gets fed data when you pick the prefab up.

#

Assuming it’s one of those games where you’re constantly cycling through guns because of ammo and whatnot

silk sable
#

That sounds like a pretty good idea, I think i'll implement that thank you

undone coral
undone coral
#

not "your" certs the root certs

#

they don't exist

#

apt install -y ca-certificates on ubuntu

#

i don't think a unity binary will run on alpine at all, but if it does, apk add ca-certificates && update-ca-certificates

undone coral
#

it will eventually stop responding due to an exception or a memory leak

#

does anyone know what the implementation of the render loop is? in pseudocode

render all the active cameras
did the time to render exceed the budget allowed by target framerate?
if so, skip rendering for some time
otherwise, wait
undone coral
#

so your gun script might look like

shoot a bullet ( size, speed )
look at ( world space position )
drop ()
pickup ()

your game logic script, which it will be apparent covers many concerns besides guns, will look like

whenever the player clicks left mouse button,
  query the currently equipped weapon
  decrement its ammo
  gun.shoot a bullet ( the bullet size, the bullet's speed)
  if the player has run out of ammo, drop it

whenever the player runs into a pick-up
  is it a gun? equip it automatically (gun.pickup) and fill its ammo
  ...
#

the place where those events are handled doesn't matter, you can call it whatever you want and put it anywhere that makes sense to you.

#

you can do it cumbersome and try to do it in an Update loop or using c# events

static oyster
#

has anyone of you worked with UnityAtoms before? I mean, I like the micro-component modular approach, but doesn't that end up being counterproductive on performance and legibility?

undone coral
#

programming visually, like authoring a state machine in the editor, is a mistake

#

does that make sense?

sage lynx
#

Hi there, is this the appropriate channel to ask about some problem regarding custom undo actions for an editor? Not sure if that should go into #↕️┃editor-extensions

flint sage
sage lynx
#

Thank you :)

frigid yoke
#

I'm changing between windowed and fullscreen by setting Screen.FullScreenMode to exclusive then doing a couple of wait for end of frames and then setting the res along with the screenmode. If I set my windowed game to certain resolutions (720 for example) and then go into fullscreen the monitor does not resize, the game window jumps over to my other monitor and all hell breaks loose. Does anybody know a good way to fix this? I'm on 2019.4.19f

#

I found a few people with similar issues and they set the fullscreenmode first and then set the res directly or did what I am doing with the coroutine, it still really doesn't like certain resolutions though and once its in limbo its hard to get it back working on the original monitor

verbal merlin
#

hi everyone, has anybody tried to add nft to their games?
would it be worth it?

queen plover
#

Are NTFs those weird crypto related things?

broken socket
#

For now all games trying to implement them are scams

undone coral
valid tapir
#

Is there a way to either AddComponent faster or Activate Gameobject faster? Maybe even using Jobs etc.

junior sorrel
#

Hello,
I'm working on a game that has minigames and I'm trying to figure out how to store persistence data for each level.
I already am using scriptable object to store information about each minigame like(Tutorial texts and so on) but would it be a bad idea to store persistence data in it too when game loads

undone coral
silk sable
#

also there are many properties to my guns (around 15) so should I be copying from a holding script that has to be able to hold all this data ?

sly grove
#

135 GameObjects being activated each frame?

#

Can that be cut down?

valid tapir
#

Well I wanna be able to shoot through 50 zombies with full bodie parts.

#

I am trying to cut that down which worked rn while I dropped the number from thousands, its now rocking over 300fps casting each frame on around 700 "fake" zombies for testing.

silk sable
valid tapir
#

I wonder if Instantiating Fake Colliders through Jobs would be faster than Re enabling colliders

silk sable
#

component wise

valid tapir
#

well I tried two types, AddComponent<CapsuleCollider> and now GameObject.SetActive(), currently SetActive is looking worse as it has to disable/enable all components on the object each time

sly grove
#

What if you just enable the colliders?

#

from a collection of cached references

valid tapir
#

now I am lost, gotta check in actual project, it was first thing I tried but for some reason it was still updating the Physics.SyncColliderTransform and Physics.SyncTransform which took tooooo much time and was hell of a spike at each fixedUpdate

#

In this project it does not seem to do the same thing, thats why, maybe animator updates it dunno gonna check now

floral mesa
#

anyone here have any decent setup for Integration testing with unity?

#

decent as in not misusing the Unit tests Framework for integration tests

undone coral
#

some stuff like shooting bullets, enemies do too - so make a BulletShooter script for that sort of thing

#

think about separating the visual / scene-interacting stuff into small pieces, and the logical stuff into big pieces

wooden cedar
silk sable
#

For my gun system, I thought I had this brilliant idea.
Basically I have a gun class that does everything a gun does, and I wanted an array of those stored in my weapons manager.
Then I have this gameObject with a weapon script that loads the desired weapon when asked for it.
Only problem is you can't create an array of monobehavior because you can't create them using the new keyword.
So I hope there is some kind of alternative method to achieve basically the same thing since i'm new to some of these concepts

hushed fable
#

Granted that does use Unity Test Framework, but not sure what the issue with that is. I don't think integration testing should fundamentally be that different from unit testing.

spiral juniper
#

is this the channel to ask a performance related question?

sly grove
#

if it's related to an advanced programming topic.

winged mirage
#

this is the script that I'm using for making my player object float up and down
https://paste.ofcode.org/6gCvaQhztaznd7dHPuM292
This is the script I'm using for moving my player
https://paste.ofcode.org/DP3MSTUawPmSp4uYMhVZ6Q

basically,what I wanna do is make the player float while moving . But what happens here is that, the player doesnt float up and down when I move it. When any of the keys WASD is pressed up, the player snaps back to the original position where it was before.What do I do?

livid kraken
#

@winged mirage just combine the float vector and the move vector and then call move on the cc

#

advanced code btw

misty crescent
stiff lagoon
#

Hey guys. I have a code gen during build time, I generate assemblies for specific targets as a pre build step. So for now the only working solution to get that in the build is to generate that stuff right in the project Assets folder, or subfolders, which I don't want, cause it produces pretty noisy output, don't want to pollute the project folder. So I'm trying to make this work when generating these say in Temp folder.

The thing is, I don't see a public API which would allow to tell the build toolchain what managed dlls it should reference and include in the build. Is there a way to do so?

I'm trying to hack it some way through reflection adding it to this dictionary UnityEditor.Scripting.ScriptCompilation.EditorCompilationInterface.Instance.PrecompiledAssemblyProvider.m_EditorPrecompiledAssemblies but looks like its not enough.

Maybe anyone have any clue where to look or what I am missing?

flint sage
#

I wonder if it just takes everything references in library/scriptassemblies

stiff lagoon
#

Last time when I tried to put the dll to that folder it wasn't picked up by the toolchain. Looks like it cache it somewhere during the build and just don't reload on the fly after prebuild step

regal olive
#

Hi, does anybody know what is required to handle abilities going off on the same frame?

Let's say for example one character hits another with an ability that does damage based on the target's current HP, but on the same frame the target uses a self-heal. I would assume that the game would randomly choose the order, so it could do the damage before the heal or after the heal, which if done in a multiplayer P2P environment could desync things.

I think it would be best if any abilities that happen on the same frame act as if other abilities hadn't gone off to prevent inconsistencies.

stiff lagoon
#

nope, managed

sage radish
#

But are you building with IL2CPP?

stiff lagoon
sage radish
#

It happens before IL2CPP starts and it gives you the folder of assemblies it will convert

#

It's an interface you implement in any editor script

stiff lagoon
#

Oh nice, thank you. I guess that's what I was looking for

#

I'll try that, thank you very much

sage radish
#

But it's not documented if it allows for adding new assemblies. But if it's giving you a folder path, I would assume it's going to read all the files in that folder.

stiff lagoon
#

Yep, that's what I think. I hope it calls that callback before reading the assemblies, so I can just sneaky copy my stuff there

sage radish
regal olive
#

Using Photon so there's a relay server.

#

Best thing I can think of right now is getting the stats at beginning of frame, then waiting until end of frame to execute the ability.

sage radish
#

Aren't you always going to get desync issues if the clients are all simulating the game individually?

#

Even just one client getting a message a little later than the others could have major consequence.

#

Or is this not a realtime game?

regal olive
#

No, so inputs are only sent once every 6 seconds.

#

I'm doing it this way so I don't have to deal with rollback and stuff.

#

Also makes the game have a different dynamic.

#

Was going to do it realtime but didn't want the game to be about APM while still being about quick thinking.

sage radish
#

So when you talk about things happening in the "same frame", you're talking about within these 6 seconds?

regal olive
#

Not exactly, so inputs are sent, then the actions happen over the next 5 seconds, just before the next "turn" starts.

#

So the actions are realtime, but the inputs aren't.

#

If that makes sense.

sage radish
#

It sounds like you have to make sure all the clients agree on the exact order of the inputs, which is easier to do if you have one masterclient calling the shots, which Photon has.

regal olive
#

Well the inputs are literally just saying what ability you are setting up, which can happen on the next turn or several turns later. So syncing the inputs are not the problem for me.

#

That works perfectly fine.

#

I'm just trying to futureproof things so I don't have inconsistent abilities.

#

The way the game works is 90% done, just a matter of getting the ability casting working and then creating content.

#

So right now I can have a unit damage another and both get damaged correctly on the clients. No desync.

sage radish
#

Maybe the word "inputs" is confusing me. Can these be considered higher-level "actions" each client is making, as opposed to lower-level hardware input?

regal olive
#

So actual input (as in navigating menus) isn't replicated, my definition of input here is just the abilities that are being used, the targets involved and how many turns it will take for the ability to trigger. Sorry if I made it confusing.

#

This info is sent every 6 seconds.

#

And the next turn won't start until your opponent's input is received.

sage radish
#

So there's no worry that there's any desync regarding what abilities are supposed to go off on what turn, but the worry is for abilities that go off on the same turn?

regal olive
#

The worry is for abilities that go off on the same frame, because the order that they happen in may be out of my control. I think that getting the stats at the beginning of the turn, then waiting until the end of the frame may be the solution though.

#

If you have one ability go off 2 seconds into the turn, then another 3 seconds in, that's fine. But if I have 2 abilities go off on 2 seconds and the order affects the outcome of the other, that's the potential issue I see.

sage radish
#

So it doesn't matter exactly when each client chooses an ability? Say you choose an ability with a delay of 2 seconds, you could choose that ability anywhere within the 6 seconds and it will always go off at the same time in the next turn?

regal olive
#

Yep, the time you select the ability doesn't matter, only that you selected it by the end of the turn timer.

sage radish
#

How exact can these delays be? Are they always integers or can they be any fraction?

regal olive
#

Well, the turn delays are integers, the actions that actually happen on the turns are made up of AbilityEffects that do different things based on actual time, so that would use floats.

sage radish
#

It sounds like you can resolve any possible desync issues if all the clients agree 100% on the abilities and their delays at the start of each turn. I don't know how you're implementing the delays, but you could use Script Execution Order to define an explicit order the abilities update their timers.

#

What what that order should be is more of a game design question

regal olive
#

I don't want there to be an order though, that's the thing. I want abilities to go off based on what the unit was like at the beginning of the frame, regardless of what abilities go off that same frame. So that's why I'm thinking WaitForEndOfFrame is my friend here.

#

I didn't think about that until after I posted the question haha

#

I get the unit info when the ability executes, then after all abilities have the correct info, they do their thing independent of each other.

#

That way, an ability that depends on a target's health, for example, won't be affected by a heal that happens the same frame.

#

That's my theory anyway.

#

This is obviously a fringe case, but it's important.

sage radish
#

But won't you have to combine them somehow? Like a heal and damage happening at the same time, the order will matter. For example, if you heal at max health, your health won't change and then you take damage. Versus taking damage first and then healing.

regal olive
#

That's what I want, yes.

sage radish
#

But you said you didn't want an order

regal olive
#

Sorry, let me elaborate.

#

So the damage happens based on the full HP. The heal also happens based on the full HP, regardless of the other ability. The order doesn't matter because they're both doing their thing based on the unit's health at the START of the turn frame. So no matter if the computer decides to do the heal first then the damage first, or the other way around, the outcome will be the same.

#

No healing is done because the HP was full, and the damage done is based on the HP being full.

#

Even if the heal happens second.

#

Did I explain that right?

sage radish
#

I understand. As a player, I'd be kinda annoyed that my heal wouldn't work in that case, but assuming it's rare that abilities go off at the same time and it's all being played back in realtime, I probably wouldn't notice.

#

Like, isn't part of the game anticipating what your opponent is going to do, so it's valid to setup a heal even if you're at full health?

regal olive
#

You wouldn't really notice, the ability would go off the same frame, so the floating heal number would just show a 0 and the damage number would show a red damage number at the same time

#

Yes it is.

#

But I guess you could also say that understanding ability timings and interactions is another higher level aspect of the game.

#

I don't expect my game to be completely unflawed, but I think this is the best way of handling it.

frigid yoke
#

Does anybody know a fix for exclusive fullscreen mode not working at certain resolutions and jumping to the other monitor in a dual monitor setup? I've tried setting the mode and then the res one after another, the modes is set in the player settings, I've tried coroutines with waits inbetween, nothing seems to work but only at certain resolutions. I have a 2k monitor and its fine with everything until a few options before 720p at which point it freaks and starts showing on both screens with no input and will minimize each time you try to interact with it

regal olive
#

I don't want to get into having abilities having different priority levels for same-frame stuff because that's just a headache to learn as a player and would feel inconsistent.

#

At least the player should know that if two abilities happen at the same time, they happen based on if no other abilities have been used that turn. It's not perfect, but it's consistent and easy to understand.

sage radish
#

Are the players choosing the exact ability delay, like with a UI slider?

regal olive
#

No, the delay is static.

#

Different abilities have different delays.

#

Some are telegraphed to the opponent, some are hidden.

#

It's basically a twist on Pokemon Triple Battles.

#

I'm pretty happy with how it's turning out.

#

Thank you for discussing this with me, it's really helped me evaluate what I'm trying to do.

safe python
#

Hi guys,
I'm working on a multiplayer project in Unity using Photon and Agora.
The issue I'm facing is if I disconnect and reconnect my bluetooth headsets while playing, the overall game volume gets reduced.
I've tried to check if audiosource volumes are getting affected upon disconnect/reconnect but that doesn't seem to be the issue.
The phone volume also remains the same.

Any help would greatly appreciated. Thanks

elder dome
vocal dagger
#

Im using asmdefs from unity and installed a nuget packet called "System.Runtime.CompilerServices.Unsafe" from rider...
However when i import it in my code and unity refreshes, unity tells me its unknown ( the package and its classes im using ). Any idea how i make this work ?

#

Any help welcome

sly grove
strange osprey
#

is there anyway to expose the PxController::setUpDirection(). function

#

to rotate the character controller

sly grove
#

Oh - PhysX CC?

strange osprey
#

thats the built in character controlelr

#

yea

sly grove
#

Only way to expose it would be to modify the core Unity C++ source code I think, which means paying them for source access.

If you had source access you might find that Unity does that automatically if you rotate the Transform, but unknown without seeing the code

strange osprey
#

so I can rotate the controller?

#

or only if i have source code

sly grove
#

what happens if you rotate the transform? Doesn't it rotate?

#

or does it never tilt?

#

I forget how it works

#

Ok yeah I don't think you can tilt it

#

unfortunately

rare sentinel
#

Asking here because it could be somewhat advanced :
Do you think action games like witcher, dark souls, etc uses melee colliders attached to weapons/claws/arms/any hurting part or just "area of damage" in front of the player/monsters ?
And if they use the first method, what about fast animations that can "miss" the target if it happens to be positioned between 2 frames of the animation ? Do you think they interpolate the collider to cover the whole swing area ?

flint sage
#

Depends on the game and on how recent it is

#

It hasn't been that long until it was possible to do that

#

But yes, more recent games do do that

rare sentinel
#

I just ran into the problem where I missed my target in my project, so I'm wondering if I should interpolate my colliders too. I really don't know the impact on performance of creating "virtual" colliders.

plain abyss
#

I know that Mortal Kombat 9 had attached to limbs during the animations. Because of this, certain characters that had drastically different costumes (such as Human Cyrax and Robot Cyrax) actually had different frame data. I also know that Zelda: Ocarina of Time had similar due to a speedrun tech called "Infinite Sword Glitch" that keeps your sword "active" while you're not swinging it, letting you damage enemies by rolling into them or grabbing a ledge near them that makes them contact your sword's model.

I'd say attaching hitboxes to animations is more common in professional games than doing an area-based hitbox

vestal heath
#

Depends on what game that is, a lot of games shifted to ray based collision detection

#

The witcher, mordhau, m&b i think

hard lily
#

What I do is I change the size or enable / disable more colliders if I need to cover more space between frames.

#

Lingering hitboxes feel great on swords as they swing, like expanding the collider to cover the entire sword when it smears (if it's a 2d animation) kind of feels right.

rare sentinel
rare sentinel
hard lily
#

Something like that, a sword slash could be a circle on frame 1 to 2, then a circle + a capsule on 3 to 6 and etc

rare sentinel
#

Ok, this seems pretty long to setup no ?

hard lily
#

You can always have them activated as capsules then, stretch if needed in the animation. That is easier to set up since you don't have to swap back and forth enabling / disabling them.

#

Precisely at his forward smash and aerial attacks. If you click the gif you can check frame by frame

rare sentinel
#

Yeah but I don't even know how to automate that.

spark niche
#

Hey folks, got a little question about memory allocations and resource loading.

If I call "Resources.load" on a resource that has already been loaded, am I going to incur additional allocations?

To give you my specific example, I am attempting to load a SpriteAtlas from my resources folder. The purpose of this load is simply to read some data from the atlas (E.g Num of sprites) for another process, and not to assign the atlas to any sprites etc. It is almost guaranteed that at the point where I call Resources.Load, the atlas will be in use by gameobjects in my scene. So when I call Load at this point, will I be creating an entirely new instance of the Atlas, or will Resources be passing me a pointer to the existing instance being used by my gameobjects? (I'm hoping the latter)

If anyone knows, I'd apprecaite the info πŸ™‚

somber tendon
rare sentinel
#

But your version is probably better for complex weapons like a whip

#

Well I could use multiple capsules too

glass glade
#

Hi, i have an object which is being aligned to terrain every frame by following, where hit.normal is the local terrain normal

Transform object = ...;
object.rotation = Quaternion.LookRotation(object.forward, hit.normal);

now i am trying to rotate the aligned object around its local up over time. I tried using

object.Rotate(Vector3.up, Time.deltaTime * 90f, Space.Self);

but it's not working correctly. Do you have any ideas on how to fix this? πŸ™‚

fast mural
#

maybe instead of Vector.up use object.up?

glass glade
#

Already tried that, not working either :/

rare sentinel
#

Hmm maybe object.rotation * Vector3.up ?

glass glade
#

Also not working 😦

regal olive
#

im having an issue with accelerometer input

#

is there anyone who could help? i am trying to make it so that when the user walks, the capsule (which represents my player), moves in space just like the user

#

the issue is that whenever i stop my phone (after moving it), the capsule just keeps going

#

i cant use friction though, because it will slow down my capsule when it walks too

#

i know im asking for much, but if anyone could get in a call with me that would really be helpful

#

i have an idea

rare sentinel
sly grove
# regal olive i cant use friction though, because it will slow down my capsule when it walks t...

the way to stop something from moving is either directly set its velocity to zero or apply a braking force ( a force opposite the current direction of motion ). Those would be my suggestions. Friction is an example of a braking force that is more or less built-in, but you can apply your own braking force in FixedUpdate. For example when there is no phone accelerometer change happening, you can apply a braking force.

harsh current
#

I'm getting error cs0029 in this operation:
_isUpPressed = true;

#

that variable is of type BoolReference, defined as follows:
` public class BoolReference
{
public bool _constantValue = false;
public BoolVariable _variable;

public BoolReference()
{}

public BoolReference(bool value)
{_constantValue = value;}

public bool Value
{
  get
  {return _variable == null ? _constantValue : _variable._value;}
  set
  {
    if (_variable == null)
    {_constantValue = value;}
    else
    {_variable._value = value;}
  }
}

public static implicit operator bool(BoolReference reference)
{return reference.Value;}

}`

#

And BoolVariable is as simple as this:
public class BoolVariable : ScriptableObject {public bool _value = false;}

#

so, how can I overload the assignment operator for implicit conversion, in that case? Any hints?

sly grove
#

you only have the other way around

harsh current
#

ohh, that was stupid. πŸ˜„

#

thank you for the quick answer

distant kernel
#

hi guys, i've made my 2d tile map procedurally using meshes. adding collision in a 3d sense was no problem but i want to make it so my 2d sprite character can't stand on certain tiles. whats the best way?

sly grove
distant kernel
#

im just using microsoft paint at the moment xD

sly grove
#

cool

#

once you import it to unity

#

you will use the sprite editor

distant kernel
#

ohhhh i see

#

i am using texture UVs

#

does that still apply?

sly grove
#

oh are you not using Unity's Tilemap?

distant kernel
#

no im procedurally creating meshes by assigning vertexes into quads

#

thats why i posted in the advanced one, couldnt get any answers from the 2d chat

sly grove
#

then you'll have to figure out some way on your own of generating 2D colliders

distant kernel
#

yea ok ill keep hunting then, thought i'd ask here

sly grove
#

maybe generate a PolygonCollider2D dynamically

distant kernel
#

generate a square of some sort

#

then check for collisions basically yea

sly grove
#

You should be able to generate a PolygonCollider2D from a list of points

distant kernel
#

hmmm thats a shout, ill keep that in mind on my google hunt

distant kernel
#

thank thank

solar parcel
#

hey guys, i've encountered a problem with my player's movement, i have a script that when i press space, the player dashes in the direction of my joystick (a coroutine gets called and it linearly interpolates between the destination and the current position by Time.deltaTime), here's my code:

public class PlayerMovement : MonoBehaviour
{
    [SerializeField] float movementSpeed;
    [SerializeField] float dashSpeed;
    [SerializeField] float dashDistance;
    [SerializeField] float dashCooldown;

    Timer timer;
    Rigidbody2D rb;

    void Awake()
    {
        rb = GetComponent<Rigidbody2D>();
    }

    // Supposed to be called in update but for the sake of debugging I put it here
    // Dashes diagonally 
    void Start() => StartCoroutine(Dash(new Vector2(1, 1)));

    IEnumerator Dash(Vector2 direction)
    {
        for (float t = 0; t < 1; t += Time.deltaTime * dashSpeed)
        {
            rb.position += Vector2.Lerp(rb.position, rb.position + direction * dashDistance, t);
            yield return new WaitForEndOfFrame();
        }
    }
}```
now the bug happens when i set dashSpeed to anything higher than about 2.5. if i set it below that the player will dash diagonally with no issues, but if i set it to something like 3 the player will only move a little bit and then stop abruptly. not sure why this is happening, if i print t during each iteration of the for loop i get 0, and then 0.3 in the console. never goes above that.
stable spear
#

@solar parcel you're abusing Lerp

fast mural
#

could it be that t goes over 1?

fresh salmon
#

Yeah it's likely that t >= 1 in the first few frames, hence the max value being reached for the lerp and the sudden stop

lucid bronze
#

Try putting an f after the 1 in t < 1, maybe it's reading 1 as an int?

solar parcel
#

hmm, what if i try doing t += 1 / Time.deltaTime * dashSpeed ?

stable spear
#

@solar parcel
try:

IEnumerator Dash(Vector2 direction) {
  Vector2 startPos = rb.position;
  Vector2 endPos = rb.position + direction * dashDistance;
  for (float t = 0; t < 1; t += Time.deltaTime * dashSpeed) {
    rb.position = Vector2.Lerp(startPos, endPos, t);
    yield return null;
  }
  rb.position = endPos;
}
#

er, one sec

#

I missed the dashSpeed

dire sparrow
#

Speaking generally, which one is better to use: Using your custom solution or ENet

fast mural
#

also a bit incorrect, since you yield and wait for the end of the frame, and enumerator will continue in the next frame and then add deltaTime (from new frame) to t; but I guess frames are similar so... not a big problem