#archived-code-advanced
1 messages ยท Page 198 of 1
If I invoke the tests from the command line, it'd probably kick back a bad return code if there's a compilation error, right?
what's the bigger picture app / game?
cool
well it sounds like you should try to do no automation
on the local editor, you can grab the generated code via a REST API, then write it to a .cs file in your assets folder, then import that file
if you see build errors, delete the file (or whatever it is you want to do)
Yeah thats the thing, I want to bypass the "if you see build errors" part
you're not going to succeed in getting this working on a server in the time span of a hackathon. stick to what you can test and run in your local editor
Oh, well thats true
you can try duplicating out the filesystem of your project, then running it from the command line
but that is going to be extremely slow
why do you want to bypass the build errors part? have you tried this?
what's the worst that could happen? it can be quite fast if you write the file to an asmdef'd folder
but certainly not fast enough to interactively find 1/1,000 complex snippets that interact with the uniyt api
if you're finding that doing this by hand is giving you stuff that doesn't compile on average
well... i have bad news, RNNs really blow
there's a reason none of this is a real product yet
Yeah, that is probably the harsh truth
you're using a constructor in a UnityEngine object What do you mean by this? Doesn't that mean im just using a constructor?
if you can find an existing natural language to AST transformer
you can do something interesting with that
for example there's probably a limited structured programming language with limited API
that someone has already trained, or does something more bespoke
and then you can use that to text/voice code a specific subset of in-editor behavior
if you want to brute-force 1,000 code snippets, you can, you will need to do a realistic scope of IT
use AWS lambda with a game-ci container. you'd have to ask for a quota limit increase to have a much longer runtime of a lambda function
then your backend would dispatch 1,000 requests, each with a different snippet, and they will run concurrently
this is as close to interactive as i can expect you to get. it couldn't be the user's project though, which would be pretty limited - or you'd have to somehow retrieve the user's project and update cloud storage with it
@dark cypress does that make sense?
Yeah, thank you
It sounds like my current approach isn't really feasible so I'm going to climb back up to 40,000 ft and reasses
really depends. you can use parsec to run the editor inside the cloud, store the project on AWS EFS, then lambda against it
you would just have to turn into a pro backend engineer in like 48 hours or however long this hackathon lasts
lol
you'd also need $100-10,000 to run the thing
but hey, for a cool demo
i guess fake twitter followers are cheaper ๐
Yeah, its 50% as a proof of concept, 50% to maybe get noticed and maybe intern somewhere
natural language to code generation is an interesting topic.
the hearthstone paper from google is the most promising
firestone (python) isn't structured
i had an undergraduate research assistant who was doing something similar with my card game, which has a structured programming language
he got way way better results than google did, but then ran out of time and didn't want to do a masters
so that's that
this would be card text -> code that implements card text for a hearthstone like game
since my game was the hearthstone ruleset, and people had already authored 4,000 cards with code in the structured form, it was working for many, many card texts
card game text is already pretty algorithmic
structured meaning it looks like data / it is almost completely context free
Oh that is pretty sick
you can certainly try. spellsource is open source with a nice unity client and active player base. here's the card editor demo (does not contain the dynamic generation feature, that is obsolete essentially) - https://www.playspellsource.com/card-editor/
there are probably 30k hearthcards cards you can rip. if you theoretically coded all of them, plus the 4,000 already coded cards, you would have a dataset large enough to hit 90% (i think we got 95% for simple card texts and 60%, comparable to google, for complex ones, whereas they got 40-60%)
there's also a professor in australia trying to do something similar
and a guy who took a sabbatical from zoox to do this
but i think he transitoned to trying to build a bot
@dark cypress suffice it to say, it's an exciting research topic and it is definitely possible to make something that works
for real
with technology today
otherwise the people who have had the most luck historical for this problem domain are in biotech
exhibit A the protein folding challenges from deepmind
Yeah I was just checking it out. So you trained on hearthstone cards, with the intent of going from a creative text description, to the code chunks that comprise the mechanics? Am I understanding that right?
and people who try to generate a chemical signature from a functional description
spellsource has thousands of cards. the training at the time this was done, which was around 2017, took tokenized representations of card text and found a mapping to an AST of a card implementation (i.e. a json file, but not in character form)
Sorry, what is AST?
at the time 100% of hearthstone's card catalogue was implemented
an abstract syntax tree
in the card editor, if you figure out how to load a card, you'll see that it has a tree-like structure
as with any blockly / scratch document
but it is context free. it's not like you're writing code.
@dark cypress so why did our approach work with so little data? well one, the google people already demoed it. they didn't go into detail why it was working comparaitively very well in python, i'm not sure they knew, they used an RNN. at the end of the day card dtext and the code that represents it is quite regular
our approach worked better because the code that implements our cards is context free. you can permute the JSON in that link, and it will still be valid "code"
there's a paper that mapped text to a tree and vice versa, in a biotech domain, which we used
and it worked well because, unlike proteins, this is context free
So like, the logic that parses "rarity" for example, was that hand crafted to give it meaning?
that insight became a key reason why there's a company that is succeeding to do this with small chain peptides
well let's work through the linked example. we trained a function
public static CardDesc generate(String fromCardDescription, int baseManaCost, int baseAttack, int baseHp, Rarity rarity, ...) {
var tokens = tokenize(fromCardDescription);
CardDesc cardDescription = transformer.transform(tokens);
return cardDescription;
}
var dygraGemOfMadness = generate("While your hand is full, allies are Immune on your turn.", 5, 4, 5 ...);
dygraGemOfMadness.aura.class == AttributeAura.class;
dygraGemOfMadness.aura.condition.conditions[0].value == 10;
the transformer doesn't return text.
it returns an object
in a "CardDesc" there are only 11 distinct types
something like that
if you permute the fields of the type it's always valid
look at the JSON. it's a tree. look at the blockly document. it's a tree.
do you see what i am saying?
there happens to be a HandIsFullCondition
stuff like that made this work a lot better
@dark cypress so i guess my point is this is all possible, very possible. if you're wondering why no one has done this, (1) card games are really hard to engineer, (2) the tender eyes of sauron in this field, from groups like openai or deepmind, focus on different things
would it be really cool? yes
oooh I think I understand, you're going from fromCardDescription, into the transformer, and populating the "aura" field with appropriate values?
well
the transformer creates something
that is like
it's a dictionary
it's making a dictionary of dictionaries
does that make sense?
Yeah I mean its nested, I get that
the transformer does not create characters
and it happens that the keys of the dictionaries are all regular
But thats where the ML is happening? In the Aura generation?
there are only 11 sets of keys
no in the transformer
the transformer has figured out how to read word by word from the description
and start filling out the dictionary with values
Right but in the card object you receive, the aura field is the result of the transformation? Thats the magic? lol
because it happens that as you read a card text, it already "fills in" this stuff
yes
the aura field is the result of the transformation
like "Deal 5 damage" -> the transformer reads "Deal" and knows it's making a DamageSpell
how i can start by the 00:00 second (Discord API)
then it reads 5 and knows that it always puts numbers into values
Got it, thats super cool
and it HAPPENS that in the natural language, it's of course not context free
but regardless of "where you are" if you shoved 5 into a dictionary you JUSTcreated
pleaso someone look in #archived-networking
into a "value" field, which makes sense for spells and conditions and auras and... etc.
I didn't read far enough down the json, I thought you were just generating randomish values for baseAttack, for example ๐
it will be the right thing to do 90% of the time
so i say context free, i really mean a very finite context
the RNN worked well too
it picked up on these things, character to json characters
that's why we went ahead and did something more sophisticated
Yeah thats really cool man, to go from language to something that is conforms with formal game rules/terms
the game rules are really constrained and that's why it works
you can't freehand code in the card JSON
right
it's 99% of the time context free - it looks like a cheap lisp
anyway that's the most realistic demo
it would blow anyone's mind seeing that
because then it would run on a phone
you know, something people actually use
something normals can use
hand a normal a unity editor, you might as well just make a design fiction
it might as well be a movie
Yeah, thats the goal... become the new Printing Press
anyway, i doubt you need my thesis research advising
$1b of azure compute, and OpenAI has very sophisticated AI Design Fiction
you could also just make a movie, it would be just as impactful for normals
OpenAI is what I'm currently using, they keep giving out free credit like candy
well as you discovered
most of the time it doesn't really work
because there isn't much open source Unity code for them to steal
if it was stupid questions, stupid Q&A, it works great
there are thousands of people writing dumb questions into reddit right this very second
odds are some normal person's dumb question, that sounds unique and not possibly in a dataset to them, is being written right now
Yeah I noticed their responses have a very reddit feel sometimes. Lots of fluff surrounding the actual point or argument, when there is one
well there's no shortage of creative writing. you could also punch random keywords into google books, grab a copy of it from libgen like they did
and copy paragraphs of creative writing if you desire
Thats a good point about Unity-specific code being relatively uncommon, I have been wondering if I"m degrading its ability by putting it in a Unity-specific context, like ECS, when really its just the fields and code I want to generate
for example, you might THINK there was never a character named "Hockerbocker"... but
so if you asked me, "tell me a story about a guy named Hockerbocker"
I am Admiral Winston Hockerblocker.โ LaserSword's head jerked as if he hadn't heard the man corโ rectly. โExcuse me? Sir, what did you say your name was?โ โAdmiral Winston Hockerblocker.โ That was when the hysterical laughter hit ...
Yeah, generating an environment, or maybe a cutscene, from a lore dump is pretty much my end to end goal
The more interactive the better of course
I'll ping you if I can get the whole process functioning
okay, let's see what gpt3 generates for that prompt
compared to what i got by copying and pasting from google:
Hockerbocker was a man known for his love of pranks. He was always playing jokes on his friends, and they never knew when he was going to do something next. One day, Hockerbocker decided to play a prank on his best friend. He waited until his friend was asleep, and then he snuck into his room and put a whoopee cushion on his chair. When his friend sat down, he let out a huge fart. Hockerbocker laughed so hard that he fell out of hiding and was caught. His friend was not amused.
Hey guys, I have a question about collision detection in unity...
I have 2 rigidbodies, which are supposed to collide during an animation. However it seems the animation has a very fast movement between 2 neighboring frames which sometimes result in a missed collision enter.
(See images below for an illustration).
How can I fix this issue without editing the animation?
(To clarify, the collision in the illustration is missed when the sword enters the NPC's back -- which is the behavior I'm trying to fix)
- The NPC's rigidbody's detectionMode is set to
continuous dynamic
@undone coral do you think its possible with current technology to formalize that story into something Unity can portray?
I guess I should read up on abstract syntax trees. But I'll be happy if I can just get a spinning cube
Imho, most anything is possible with time and effort.
But using AI to pull context, and using it to generate environments, is already being done in plenty of 3D tools. No reason you couldn't extend it to Unity if you wanted to.
If I understand the question correctly anyways.
Yeah, originally I was asking about retrieving compilation errors lol but the discussion expanded
Personally, I would probably run the AI outside of Unity for a myriad of reasons though, and make it purely visual on the Unity end.
Its funny that I ran into someone here who has basically done exactly what I'm trying to, it doesn't seem like people are talking about it in my gamedev social circle
I'm thinking we might be behind the curve a bit
That would give you a more plug and play friendly AI driven API that can work with other engines, and let you access funding from things like the epic mega grants ;)
If that's an area of interest mind you
I'm using Unity to spawn the OpenAI requests because Unity has an ezpz python interpreter, lol
Eventually I'll pull it up to be more of a github actions/CI kind of thing
but I don't know how to into Continuous Integration yet. So i'm trying to prioritize my learning so I can get a vertical slice, THEN upgrade individual aspects
What kind of projects do you work on?
We work on about 20 projects a month, lots of XR, lots of custom experimental things. OpenCV, AI integration stuff. We have a lot of government work, health care, games, entertainment that kind of thing
But I feel we are greatly under utilizing AI
Is it like you're doing work for 20 different clients? Or you have 20 different projects?
Mostly because we just can't keep up with the work, and so always short staffed and no time for research
A good problem to have, ha
no
many, many fun games look like card games in disguise though
every blizzard game is prototyped as a card game - then again they mostly make strategy (or strategy adjacent) games
i wouldn't try to generate the numeric parameters of overwatch guns, but i could generate spells for those guns
I suppose the numeric parameters would be the humans job anyway, the game "design" aspect
well nobody would notice really either way
Wrangling the spell descriptions into functioning code is the way more skilled part, yeah? Not that designers aren't skilled, but programmers are rarer
the differences between all the cs:go guns are very small, in the whole space of numbers
i think yeah, there are way more card texts you want to prototype
that would be interesting to expressively and succinctly program
however no real point for game designers - the spellsource card editor is easy to use... on PC
the purpose is really to support people trying to do stuff on phones
in my view
nobody develops games on phones yet
it's not realistic to ever make something like a roblox game on a phone, so it can't be this unconstrained thing
Dreams is close, but still that uses a playstation controller
and kids that have infinite time
exhibit a: http://supernauts.com/
Supernauts is a new game for iPhone and iPad where you can build your own unique world!
Sorry, yeah, clients. Some have 7 or 8 simulations on the go. It's a lot of work :D. I wish we had more time to drill into deeper experimental projects.
that isn't going to be a successful format for phones
Well, I dont know, I mean if the world uses in-engine controls to edit the world, all you have to do is make the game playable on mobile
Not that in-game content creation is what we've been talking about
But normal people will suffer through pretty atrocious controls to implement their creativity, I think
nah ๐
not on phones
very hard to compete with tiktok
I don't agree with that at all, sorry.
how many adults play minecraft PE?
have you tried its virtual joysticks?
after that i can't think of a big mainstream game on phones that expects you to build something
It always stands out to me when someone makes bold absolute statements based on personal assumptions.
i think they'll use a PC
Its mainly for the sake of conversation ๐
yeah i'm just trying to really refine a good audience here
spellsource is a card game where the players author the cards, and targets portrait mode mobile
it's tough. you wanna be able to do that on phones
I guess I'm trying to highlight the difference between a PC-specific level editor, and ingame editing you can do, like Fortnight. Do people not build forts in the mobile version?
what mobile version ๐
epic has delisted fornite from the apple and google stores for a while now
they also experimented with getting rid of the building in that game
you could read their reasoning online
obviously the truth is that playing fortnite on an iphone / android sucked, and so they'd rather those audiences do it on a switch or even better a PC
or maybe it's because "app store fees"
๐
i'm not saying anything controversial by pointing out that FPS controls are absolutely horrendous on mobile devices
i undersatnd people play them, but that doesn't make the controls good
supernauts was designed by the best people in the world, at its time
for making mobile games
they couldn't figure it out
it was just too cantankerous
it's 2022 and facebook is repeating the same mistakes, with a cloud rendered supernauts like experience
nobody learns
if you want an audience for natural language to code
yeah, card games
it makes sense
because people want to play those on phones
exhibit A: Marvel Snap
ben brode basically did everything rigth in terms of making a better mobile card game
Yeah my original point was how people will suffer through bad controls, so I'd wondering what kind of decline there was in basebuilding on mobile fortnite vs PC. 50% drop? Who knows
completely original approach, borrowing from all ther ight things (like texas hold'em), portrait mode, 1 value cards, etc.
Well maybe not "gamers" but normal people as in, the ones that maybe don't even have a PC
and don't know how bad of an experience they're having
i couldn't speculate. i don't know if anyone over 21 played fortnite on mobile regularly
certainly kids will suffer through bad controls, for a while
if you have a brave idea on how to make good controls for older kids, get a roblox dev grant for $1m
clone a game, they want you to, desperately
Well Im going to see if I can fire up this pipeline, thanks for the AST primer
is it possible to get the contact points between two static colliders? trying to build a spline between the terrain and the ocean. Any ideas is appreciated thanks!
only with custom trickery that doesn't have anything to do with colliders
Would love to hear more, trying to think of as many approaches as I can.
well, one would be rendering a top-down-view utility texture that captures a depth map of the terrain and extracting the iso-line at sealevel (contour of the land at the elevation of the water), then convert that into a spline
i don't know any other method that doesn't rely on a depth map in some form or other
if the colliders/meshes are static you can also just analyse the mesh by a slow CPU process and "bake" the contour, but it would essentially too be a depth map calcuation
it would be a process that would only need to happen once during the initial generation of the world.
i'd go with a depth sampling approach
generating that spline is an interesting problem, probably requires reading some papers
Can someone help me to understand why I have errors, please?
Not sure what is advanced about this
NREs aren't advanced issues I'm afraid
1st error happens on line 43 of HealthBar (so L70 in your link), matBlock was null
2nd and 3rd errors happen on L19 of GameHandler, which point to a closing brace in the link - not slovable as is
Next time, post one link per class, don't shave off lines
#๐ปโcode-beginner question regardless. No need to continue here.
okay
I'm looking to write my own Android native plugin to use in Unity, is there any material regarding project setup?
I looked around and several articles I could find were years ago, and presented completely different project setups (some uses Android Studio, some uses CLI only; some creates a no activity project, some creates an empty activity project and changes post build; etc)
Also I'm wondering how to speed up the iteration, these articles didn't touch on that and all just assume code works, build and integrate into Unity, which is obviously not the case. The plugin I'm making is not really tightly coupled with my Unity project or Unity in general, I'd like to be able to test the plugin in isolation, and only build/integrate into Unity once it's done.
That's not really what I'm asking, and yeah I'm aware how to integrate into Unity.
The whole iteration question.
If every little change you make in the plugin, you have to build it, update it into Unity, run the Unity project in the actual device to test it, that's obviously ridiculously painful.
Yes that's what I was thinking, and I'm asking if there are materials that walk through all the steps.
Yeah and I'd like to avoid learning everything about Android just to do that because I obviously don't know what I need to know.
Sure, I would appreciate if you can give me the things I need to look for
Like which template, etc.
Hey man, I've done the searches and the articles all went with different setups and they configured the projects in vastly different ways
I wouldn't be asking here if those articles gave any explanation on why they chose what they chose or the difference between them, I'd basically have to go read Android dev from scratch.
Well, thanks regardless.
for some reason the player still rotates to the direction he is moving to even tho I turned off all the rotation??? I'm so confused rn. My goal is to make the player only rotate to the direction he is aiming at and be able to still walk around while doing it. https://paste.ofcode.org/ZydnHEGj2mJzdZj4EdBGYN
Please post code in a paste website according to the rules in #854851968446365696
This is unreadable, even on PC
I'm only using "controller.Move(direction * speed * Time.deltaTime);" to move while aiming but it still rotates to the direction It's moving too
well that's not how you calculate a direction
close, but you are only normalizing the transform.position
you need to normalize the result of the subtraction
not one of the operands
Any tips on how I would do this?
putting parenthesis around the subtraction part
or you could just do the subtraction and then use aimDirection.Normalize()
so remove the "transform.position"?
if you did that, what would you be subtracting?
the subtraction is correct, the normalization is not
those are two separate concepts, and im saying to do the subtraction first, then normalize the result
How did this get past #archived-code-advanced
Hi guys.
I need some advice about WebP.
I'm working in an android project with unity, and I would like to know if WebP is useful to decrease size build.
Is it correct?
To my knowledge, Unity already compresses textures internally when doing a build
Yes, I know.
But webp compress more than png/jpge, I don't know if is more effective than png/jpge using crunch.
Textures are compressed to a platform specific format, you can change these however you want in the import settings
Afaik unity doesn't support webp and webp is a very different format from what it is being compressed to on device
Texture format in your unity project (i.e. not built project) don't really matter except as a maximum level of quality available
So, probably don't work in android project?
Probably doesn't work in any project
In your Unity project, always use the highest quality version of the textures you have.
Let Unity compress the textures for each target platform, you can change the settings if you need more granular control.
Not really, your source files should be the highest quality version you have, you shouldn't be putting your source files in Untiy
I would like to use high quality, but my boss doesnt. ahhaha
That's just stupid, it'll inflate your build times by a lot
:art: WebP made easy for Unity3d. Contribute to netpyoung/unity.webp development by creating an account on GitHub.
Ok, I appreciate yours helps.
Thanks.
Does anyone know what is the programmatic way to reset the position of a GraphView to (0,0)?
(or the hotkey, so maybe I can dig through the code)
I think there is a "placematContainer" that is related, but not sure how
having a problem with a compute shader where i am using an appendstructured buffer, but when i try to append to it, the editor will instantly crash with a d3d11 error. Anyone tackled this problem before, or know how to solve it?
welcome to unity! hahahahaha when you go deep in shaders almost ever crash.
check if your video driver is updated.
check editor log too, it can to give a advice.
ok, will do
I have a dog-like shape made of character joints (constrained). I'd like to "activate muscles". I think the right way is by applying torque to the rigid body of each character joint. am I in the right ball park?
i found several walking demos on yt but no code yet, and some that only use articulated joints (eg industrial robots)
any Math eater here around can help me with Player's level and Health guided by Animation Curve? ๐
I've made a Stats system that use AnimationCurve to define the value on level up, but the value have too many decimals and the game design should be based on stats with value like 8 16 20 24 32 ... and so on.... but I'm lost
'cause actually the player starts with a value of 4 at lvl.1 and 4.0085 at lvl2 ๐คฆโโ๏ธ
Example:
I mean, I could set the curve at 100.000 but I really dislike the idea
or.. I could make the AnimationCurve with 100,000 as last point and divide the keys by the game levels ๐ค
Or ... I could throw myself out of the window ๐คฏ
I'm kidding ๐
Could you send any code and maybe a screenshot of the animation curve?
Post it in a code dump, the bot is removing weird code
And mine is weird for sure xD
https://pastebin.com/E73f191i
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Hi, i have a problem with my 2d triggers, they seem to detect collision even though they are far appart, they are set to look for collisions with a tag, and only those gameobject have that tag. and they think they collide, even though the collider(green box) is far appart... any idea why this is happening?
in inspector looks like that
while for NPC's looks like that
***bad discord! ***
I see an If statement ๐
is it so bastard also in private?
Weird bot, I could post it one time ๐ค
"Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastepaste.com/, http://pastie.org/ "
so you're looking to round it to the nearest multiple of 4? I'm confused.
I would assume that you would have the curve's range be 0-1, then you multiply the curve's value by some scale factor (it sounds like 100,000 is what you want) and round the result to the nearest "nice" number.
Indeed that would be much more reasonable, and even more manageable in Inspector ๐
Anyone has a good way of refactoring this abomination? https://paste-bin.xyz/65476
The goal is to see if object the script is on can see the player. First use box cast, but if that hits the corner of a wall and fails to hit the player, use a ray cast just to check. If that doesn't work, return false.
I'd probably do this @calm ocean
https://paste-bin.xyz/65478
Nice, thanks
In this case all you need is a line:
baseHealth = 16
healthPerLevel = 4
// line equation
health = level * healthPerLevel + baseHealth
So i am using this script. I was wondering how i change to generate in 2D. Y up instead of along the z axis.
https://github.com/silverlybee/dungeon-generator/blob/main/DungeonGenerator.cs
Yesm
new Vector3(i * offset.x, 0, -j * offset.y)
thats x and z
as example
you just need to change these
probably
Anybody with Steamworks.NET experience? How do I find out when a lobby was invalid when calling SteamMatchmaking.JoinLobby? LobbyEnter_t is being called like the lobby existed.
These are the parts of the code that make up joining the lobby
OnLobbyEnter is called and returns a callback with the same lobby id, yet the lobby should not exist
I suppose I should supply custom lobby data and see if I can retrieve that? I do try to get a host address, but I was wondering if there was another way
how would you achieve transform.RotateAround without using RotateAround
@fast pagoda oops, meant without*
ah ๐ makes sense
i have no idea then lol
Hello everyone, it seems the OnEnter and OnExit have some limitations in Unity... https://forum.unity.com/threads/oncollisionstay-exit-problem-solved.400583/
Anyone have an idea how to bypass this limitation? OnStay won't work for this current issue... I need to know when the object starts and stops touching another object
Ray/sphere casts?
Sorry, I should clarify. This post isn't 100% relevant, I'm not trying to get jumping working -- I have multiple objects moving at high speeds that collide with eachother
So what is the actual issue you have?
OnEnter is being called, but on occasion I encounter a Unity limitation, where if there is a lag spike then OnExit WON'T be called. I need to know when the collision starts and stops
Right now I'm trying to figure out if I can use OnStay with some trickery with the execution order https://docs.unity3d.com/Manual/ExecutionOrder.html but I'm afraid I'll run into a dead end here
I don't mean to be that guy, but I feel like the bigger issue is that you are getting big lag spikes.
However with that said, the solution kind of depends on what you are doing in OnExit
Well we are using FEEL, which does a freeze-frame when there is a large collision to simulate impact. Unfortunately I think this is causing Unity to skip OnExit.
Currently in OnExit I am just removing the current colliders from a list where I am tracking them
I see I see. My guess would be because it is setting time to 0 or something. You could try contacting the FEEL devs to see if they have some idea of what is causing this since they know how they are doing the freeze-frame.
I think my suggestion would be to loop through the colliders in the list to check if they are still colliding and if not, remove them.
i am using the code from this page https://forum.unity.com/threads/windows-api-calls.127719/ ..
..to make my window transparent and click Thru (the transparent parts). What do i need to pass into these to either Turn off the Click Thru, or disable both.
SetWindowLong(handle, -20, 524288);
SetLayeredWindowAttributes(handle, 0, 0, 1);
rotation around a point can be represented as a compound matrix, a product of 3 matrices. The first one is a translation from the point of interest to the origin, the second one is the rotation itself, and the third one is a translation back from the origin to the point. Combine these using multiplication and you get the desired result
mhmmm
public static void RotateAround(Transform transform, Vector3 point, Vector3 axis, float angle)
{
var rotation = Quaternion.AngleAxis(angle, axis);
var localPosition = transform.position - point; // step 1
localPosition = rotation * localPosition; // step 2
transform.position = point + localPosition; // step 3
}
yeah that applies it immediately I guess
Oh transform.RotateAround also modifies rotation. In that case, add a fourth step:
transform.rotation *= rotation;
hmmm yes, math that I don't yet understand
rotation around a point can be
im trying to make a vr game but nobody is responding in the virtual-reality section so can anybody help me in here because i have a problem
Don't cross-post
alr i just need help tho
That's not a reason to post your thing everywhere
im just trying to get help sorry for posting it in 2 sections
You didn't ask a question in #๐ฅฝโvirtual-reality
"I need help" is not a question
You posted in 4 different sections now
Guys is there a way of casting a float/int to bytes without unsafe code?
In Jobs (so no byte[] array)
Sorry, you were too quick ๐
without byte arrays... no I don't think so
well
I mean you can do it yourself
it's tedious
but through bitwise operators you could
Yeah I know, it's not terrible really, just need a stackalloc array and pointers, but it's a bit annoying
something like:
public void ToBytes(int input, out byte b0, out byte, b1, out byte b2, out byte b3) {
int tail = 0xFF;
b0 = (input >> 24) & tail;
b1 = (input >> 16) & tail;
b2 = (input >> 8) & tail;
b3 = (input) & tail;
}```
so I thought maybe there's a hidden c# method that could give you the byte at a given offset of the type directly
Yeah alright, I'll probably do that to avoid having to have unsafe compilation turned on for this assembly, thanks.
I'm working on a script that spawns random enemies as the player runs around, but this seems to have issues with navmeshagent. Previously, when I was just using simple positioning of the enemies, I had them using non-kinematic rigidbody so I could pick a place to spawn them, and then iteratively move the model up by small amounts until a raycast down hit the ground, then spawn the enemy there and let it fall to the ground the .1 or so it was above it. This doesn't work though with navmeshagent though, as it's kinematic and apparently being just a tiny bit above the ground makes the it not able to control the navmesh agent.
Is there a logical way to tell it to basically apply gravity so the agent can fall but stay otherwise kinematic?
I'd have thought having a navmeshagent enabled would immediately stick it to the ground. Has that changed, and if you have a kinematic component and move it above ground manually, the navmesh agent turns off or something?
i've been working on a wave spawner for a tower defence game for a while now but i just cant seem to get it right, i was really close until i noticed the enemies dont always spawn properly, the issue seems to have something to do with the amount of enemies getting spawned. (sorry for the spaghetti code haha)
the problem seems to be right here
You really should avoid the use of InvokeRepeating
It's terrible for performance and debugging
It looks a bit weird, does EnemyInfo correspond to a single enemy entity? Or is it an enemy type? Because using InvokeRepeating like this, it looks like that each EnemyInfo is spawned multiple times.
If that's the case, then enemiesAlive++ should be inside SpawnEnemy, for a start, no?
You only check for enemiesAlive == 0 once, if it's not true, the coroutine ends, is that really what you want? I'd expect you'd want something like while (enemiesAlive > 0) { yield return null; }
oh yeah my bad, theres a few other scripts
the enemy scriptable object
and the enemyInfo
i've also tried using for and while loops but that's just caused more bugs that i cant figure out how to fix. invoke repeating is just my most recent attempt, it also fits well with some variables i wanted to add
i didnt think of using a while loop there my bad, thank you i'll use that instead :D
Why are you setting CurrentPoint = Points[0] repeatedly in update? It's pretty much always the 0th point this way.
at first it was for debugging purposes, im probably going to remove it as soon i have a few of the maps stuck in place
https://gyazo.com/8179bef922ee7e59b3bec959539b5255 heres what happens so far
it mostly works but there should be 3 of the red ones but it only spawns 2
Hello? IS there a way to get the real width & height from a stretched RectTransform?
@sly grove Apparently bit shifting isn't possible with floats... oh well.
it is with unsafe code ๐
or BitConverter
yeah but at that point I might just use pointers ๐ฆ oh man, annoying stuff
Hi, I noticed that my unity game for the iOS App Store has a section in the UnityFramework.framework/UnityFramework binary called il2cpp. I was curious what this was and if there was some way to remove it, as it takes up 16mb.
Not sure what the cutoff between code-general and advanced is, but this feels advanced-ish? I've got a script that generates random enemies. To find a new position, I pick a random (x, charPos.y ,z) position near the player, and use NavMesh.SamplePosition to find the nearest spot that hits the navmesh. Then I Instantiate(prefab, hit_from_sample_position, Quat.identity, enemyParentsGameObject) but it still complains that I can't use setDestination because it doesn't think it's on the navmesh, even if I use Warp() to place it?
I am making a third person shooter character, but for some reason the character doesn't walk to the direction the camera is facing even tho I did put it in the code. When I use WASD it only walks to a specific XYZ direction and doesn't get impacted(rotated) by the camera look position. Like it thinks that the camera is facing one Z axis all the time even tho the player is looking at a completely different direction. Anyone know what I did wrong? https://paste.ofcode.org/Pz2KXwCEpyDkGFXwKpcZup
I'm also not even sure if it's a script problem
so confused rn
This is inside the characters inspector
Hello guys!
Can anyone tell me why when I play a particle inside my unity device, it breaks the textmesh for the UI? Has anyone had a similar bug?
It's essential https://docs.unity3d.com/Manual/IL2CPP.html
use pastebin, discord is a bit bugged
However if any code unrelated to UnityEngine is executed, we can start to see some significant performance gains.
thats a quote from that website https://www.lucidumstudio.com/home/2017/12/5/lucidum-studio-async-code-execution-in-unity
what does that mean? the code is afaik unity engine related or not ?
async void InstantiateAsync(){
// Example of long running code.
await Task.Delay(1000);
GameObject.Instantiate(this.gameObject);}
I tried this, and it didnt work !
if(rot1 != Quaternion.Inverse(Quaternion.Euler(bag.targetRotation))) doesn't work
define "doesn't work"
whats the context?
well if I understood the context, async tasks are better, performance wise, than coroutines or unity delays or w/e
it didnt stop, the update function kept running
i added a debug to learn if its still working, and it was
by comparing a rotation, you're basically trying to get 4 float variables to be identical, which is kinda hard
what is the right way to do it then ?
whats your logic here? whats the feature you're doing?
there is always a better, more logical way to do it
well, the 2 handed gun is suppose to rotate in a specific rotation to the backpack of the player , became a child to the bag and that is it
I dont need to keep lerbing it's position on update
so that's an animation right?
it was said that i can launch a task with unity engine unrelated code but instantiating an gameobject looks to me like unity engine related code
yeah , kinda
Ah yes, definitely weird
Animations have duration, if I was coding that feature, I would just put a delay before stopping the update or whatever you're trying to do.
I don't care about the animation itself, the main thing is the duration.
There is no point having to create a condition for a rotation (in that situation)
you could get the angle, between the rotation and the "target" rotation, and see if it's like very close, but comparing Quaternions, that's not good
which angle ? how ?
i never calculated an angle between 2 quaternions but i'm pretty sure it's straightforward
For Vector3, you can use Vector3.Angle(euler1, euler2);
from google (for quaternions)
it's definitely not straightforward, ๐คฃ
just use the Quaternion.eulerAngles
yeah, looks pretty odd
is there is a way to run a delay for like (3 sec) after that i could just stop it ?
it only takes 1 -2sec to lerb
Yea, using a Coroutine or an Invoke
what about update?
could you give me an example of the timer variable ?
something like this
public float duration = 5f; // 5 seconds target duration
private float _timer = 0f;
private void Update()
{
_timer += Time.deltaTime;
if (_timer > duration)
{
DoSomething();
// assuming you just want to destroy the object
// at the end of the duration
Destroy(gameObject);
}
}
Algum brasileiro?
thank you !!
@brazen hamlet I literally just told you that this isn't Unity related. Go find a C# discord, there are a few.
Hey, is it possible to implement such thing:
When my custom behaviour is assigned to an object one of its public attributes should be randomly generated and be kept forever, although be editable. I couldn't think of a way to implement that yet
can you elaborate an example
Sure
why would you want that specific thing
So basically I want some items to get disabled / destroyed if they were collected by the player before. For that I decided to make some kind of unique identifier for objects and store them in a list. If the identifier is found in that list, the object should get removed and be uncollectible
just use an ID generator
Kinda new to data storage in unity, if there are better practices than using json serializeable for everything tell me about them please ๐
I don't see any relation to your first question tbh
he wants to put a random ID on an item..if you picked up that item allready you cant do it again
but a simple enumeration like hardcore 1 2 3 4 5 6 7 would do it
if 7 was picked up.. dont do it
i mean, the keywords from its initial question were:
Behaviour assigned Object public attributes randomly generated although editable
I am able to make a generation algorithm but I don't know how to integrate it in a way I described
again.. is it online, or singleplayer
The unique identifier I mentioned is a thing I want to be generated
Single
allright so data security is unimportant
why do you not give your item an identifier
you got pickaxe id = 1 ... i cant pick something up if i allready picked up the one with id = 1
is the storage the problem?
I do, I just want them to be generated and inserted into the field based on my ID generation algorithm instead of typing a new id into the field manually
make a static private int counter
in your scriptable object or mono
and onreset counter + 1
or onvalidate
The goal is to automate the process of me making an id and putting it into the field
should the ID be random ?
I would like the id to be a human readable string, so I wanna use my own algorithm
Generated by my algorithm
well onValidate gets triggered when something in the editor changes
or
when the script gets added
you can call the generator once in onvalidate
Hm, I will look into that method
or onreset or on enable
but onenbale is in both editor and runtime once
onvalidate is only editor
I am not going to edit id at runtime so I think OnValidate is what I am looking for
yes you could assign the ID inside OnValidate
Thanks for help
if you wanna have a random unique ID, i would recommend using GUID
How do I get it?
Thanks
Hey I have this idea for my game and I was wondering how I could get it to work. Im using Unity 2019.4.31f1
Basically I want the player to be able to type to the NPCs and using some kind of AI text recognition they could respond in unique ways based on parameters like their personality and mood
But I'm a big noob and have no idea if that's even possible ;-;
Possible yes, but you will have to learn a ton of things
I was thinking of starting off simply and just checking to see if some key words are in the string and then responding with some premade responses
Hi guys.
I would like some advice on simplifying mehs collider. My problem is this: I have a complex 3d model and I want to create, starting from its mesh, a simplified but quite accurate collider that encloses it and use it instead of the mesh collider to improve performace. How to achive this?
I hypothesized that I could work on the normals of each vertex, creating a new mesh with only the neighboring vertices having different normals. But I'm not sure it will work.
Thank you!
Cant you just hit convex in the mesh collider ?
If a convex shape doesnt work for you, you can try https://github.com/Unity-Technologies/VHACD
I don't think so. Think what a hit convex collider of a tree model would look like. There would be a lot of empty space inside the collider around the trunk of the tree.
That's interesting. Thank you.
that can work but its a different concept than ai text recognition. if you were to do it that way, i would see if there exists a library that maybe has those connections between words and knows what sort of conetation words have. then use them to decide which premade sentence to choose from. using the mood/personality, you can also use these connections and conatations and sqew them to a specific direction more.
if you were to do it without a library of some sort it would be super hard coded, but you can still do it. just kinda depends how complex you want this system to be.
(also take this with a grain of salt im not that experienced with this stuff)
That sounds like it could work I'll look into stuff like that
And this conversation feature is gonna be like the main focus of the game so I'm willing to spend as much time as possible on it
instead of writing 100 useless word try to teach people dude! if this is not advance then help me resolve it.
can anybody tell me how these rendering layer masks work
i have a outline effect that should show up on specific rendering layer masks, but it doesnt work..
if i choose "Unused 8" it wont work
am i missing something?
Ok thanks
i wanna know if someone can explain how quaterions work in unity
and i dont mean rotations but their multiplication
this should hold
i end up with a different result
any explanations?
Does anyone know how hard on performance 2D boids are?
Both for CPU (C#) and on GPU (Compute Shader)
If I only have 10-15 on screen at once that shouldnt hurt the CPU too much right?
Does anybody have experience with webviews inside their mobile games?
Completely depends on your implementation
How do you mean? They wont have to interact with anything other than each other btw
Think of a quaternion as an orientation
looking at the raw numbers wont really help you much
with euler angles, there can be multiple different sets of values that equal the same orientation
with quaternions, each set of values only corresponds to a single orientation
What are you expecting?
Those are quaternion values from a matrices
you can use a quaternion to transform a vector much like you could with a matrix
if you have a certain orientation, let's say transform.rotation
you can multiply it by a vector to get that vector rotated by that orientation
Quaternion isn't an orientation, it's a rotation. So going from Quaternion A to B doesn't really make sense, but you can construct a third Quaternion, C that represents a rotation to go from A to B
a rotation is an action that results in an orientation
If you make good code they will perform fine, but if you make unoptimized code they might be slow. It's super hard to say how well it would perform. Since you have low numbers though, it's unlikely that they will impact performance
by multiplying vectors with quaternions it acts like rotating it by that amount
also they avoid gimbal lock
i am trying to generate 600 cell which is a 4D object and i need precise quaterion calculations for that
there's a 3blue1brown video that describes the math
omg please just let me send the link dyno bot
How to think about this 4d number system in our 3d space.
Part 2: https://youtu.be/zjMuIxRvygQ
Interactive version of these visuals: https://eater.net/quaternions
Help fund future projects: https://www.patreon.com/3blue1brown
An equally valuable form of support is to simply share some of the videos.
Special thanks to these supporters: http://3b1...
thx
for those who want answer unity treats quaterian components in different order
heres what it normally looks like
and this is what unity does
fwiw, it looks like Unity's naming matches the standard quaternion notation, but the order is different.
Unity's vector4s are (x, y, z, w) while standard quaternion notation is w + xi + yj + zk. They flipped it around so that the names of the vector indices match
How would I go about generating a triangle pattern, for eg. See image. Where all of the dots will have their respective vector2 positions, the amount of dots will vary
Im think I should make an algorithm for x and y, but I have no idea how I'll calculate it
I'm not understanding the question maybe, but you are just multiplying out the X and Y based on the number of instances needed.
You'll do a lot of this with procedural meshes :)
Can you elaborate on the multiplying x and y?
Sure, X always increases by 1 per column. And is offset by 0.5 per row.
Same with the Y.
That gives you the staggered dots you see in your image sample.
Where that gap depends on how you want the triangles and spaces to go.
But each row is one less than the row above. And each row is offset by 0.5. so now you can loop through and draw the points row by row, and just move ahead 0.5.
I'm basing this on your diagram though mind you.
How would you do it for a triangle like this
Ignore coffee spil
Take T4. You know the 4 is the number on the bottom row, 10 is total but doesn't matter.
So row one, draw 4 dots 1 space apart.
Row two offset 0.5. draw 3 dots 1 space apart.
Row three is now offset by 1. Draw 2 dots 1 space apart.
Row four, now offset 1.5, draw 1 dot.
I'd start at #5 and work my way up.
@wooden cedar and what about this one
But if it like doesn't have enough to fill the row
Same thing, start bottom left.
It does
Well, you can't resolve ever number to a base square root.
So the option you may want is starting at #1. Which is just a for loop.
In this example:
Row one is always a max of 1 dot.
Row two is always a max of 3 dots.
Row three is always a max of 5 dots.
In your other examples I believe each row was only increasing by 1 dot.
But you know the row size you want. So as you go through your if statement, increment a max row size, and that determines if you should start another row. In this case though it is incrementing x and y by 1 for each row.
Hmmm, thanks
I need to render 4 billion objects on the screen at once. They're little 3D objects that will be stacked next to eachother in several 3d cubes of 1000x1000x1000 objects each. It's ok if they don't render in realtime (my client uses Unity to create videos).
I won't be starting work on it for a day or two here, but I've been mulling it over in my head for a bit and I'm certainly intimidated ๐ . I've got a plan that I think might work, but I'd appreciate any thoughts if someone thinks they've got a better idea.
I'm planning on creating a component that captures an image of the object from the angle the camera's currently at and then repeats that image onto a simple 3D plane. I'll be able to get a decent approximation of perspective this way, though the parallax will be fixed within each plane. But... even if each plane handles 100x100 objects, that'll still be 100,000 planes ๐ , which is probably way too many. So I think each plane would have to be pretty big but that'll make the fakery more obvious.
You should look into GPU instancing and the flyweight pattern (https://gameprogrammingpatterns.com/flyweight.html)
I figured that 4 billion objects was too many, even if each one was instanced. Even giving the GPU 4 billion locations to render an object to would take up a lot of vram.
well, yeah lol
Though maybe I'll be able to support 100,000 planes outright using instancing ๐ค. Is that what you meant? How were you imagining applying instancing?
all im saying is
if you're rendering lots of objects that have the same geometry, then you definitely need to be using instancing
but if your client doesn't care about it being realtime, why use unity?
4 billion is a crazy number of objects. 1920 * 1080 = ~2 million pixels
Gotcha. Yeah I'm sure instancing will be involved here... definitely an extreme thing. I need more than just instancing to pull this off though.
And he's got pretty good reasons for using Unity honestly ๐คทโโ๏ธ. Though we'll see if we're able to make this particular dream (the 4 billion objects) a reality.
I'm not super familiar with this, but look at this:
https://youtu.be/RPtMVYG9voM?t=1976
(at 32:56)
that effect is almost definitely done using some magic on the GPU
i don't exactly know what it's called, but i think that's similar to what you're potentially gunning for
some GPU accelerated particle system, just the particles are cubes and not squares
Stop posting the same question in multiple channels.
can anyone help me with this?
Begin MonoManager ReloadAssembly
- Completed reload, in 0.124 seconds
Microsoft Media Foundation video decoding to texture disabled: graphics device is Null, only Direct3D 11 and Direct3D 12 (only on desktop) are supported for hardware-accelerated video decoding.
Shader 'Nature/Terrain/Standard' uses 17 texture parameters, more than the 16 supported by the current graphics device.
(Filename: Line: 0)
Shader 'Nature/Terrain/Standard' uses 18 texture parameters, more than the 16 supported by the current graphics device.
(Filename: Line: 0)
Shader 'Hidden/TerrainEngine/Splatmap/Standard-AddPass' uses 17 texture parameters, more than the 16 supported by the current graphics device.
(Filename: Line: 0)
Shader 'Hidden/TerrainEngine/Splatmap/Standard-AddPass' uses 18 texture parameters, more than the 16 supported by the current graphics device.
(Filename: Line: 0)
WARNING: Shader Unsupported: 'Hidden/Nature/Terrain/Utilities' - All passes removed
WARNING: Shader Did you use #pragma only_renderers and omit this platform?
UnloadTime: 42.950600 ms
Hello, I have a question that is heavily related to math & am trying to find a solution and then implement it in code, maybe unity has something built in but most likely not, if you have any ideas please @supple crescent Thanks!
So I am working on a spline system, that uses what I believe are Bezier curves, this is an asset where you can apply points to the spline and it will build out the curve, currently I am trying to find a way to get a close approximate to a perpendicular line running through one of these points that make up the spline. I have access to the current point and last point in the spline. but im not sure how to get a tangent line for this.
you can use geogebra to get the maths right
it can print you the curves
then you can implement it in unity
this is a procedural based system, but I will look into this as it might be a great testing environment, thanks!
its free and simple
3d or 2d? In any case, you just need to get the perpendicular vector using one of the axis or an arbitrary vector defined by you
3d, and I was just reading about vectors
I have a vector built from the two points but now I am looking into getting the perpendicular vector
perpendicular to what
๐
in 2d its easy, you can just calculate it directly from 2 points
in 3d, you need an extra vector to define perpendicularity
well the point of the perpendicular line is to create those points, I need to find a way to make it perpendicular off of the vector created from the two points
I suppose it could be in 2d space since I dont care about the y axis
its 4 float3's on both cpu and gpu
Vector2.Perpendicular
and if you need a 3d variant, from your 2 points, use Vector2.Perpendicular to get the perpendeciular vector in the plane its lying, then use Vector3.Cross between that original vector and your new vector and that will get you a vector coming out of the plane
In the 2d case:
- You have a bezier curve
b - You have a point on that curve
p - Find the tangent
ton curvebat pointp. (There's a formula for this if you look it up) - Follow what @rocky mica just said
^^ Yeah this will get you the actual value, if you use points a and b directly you will get a rough aproximation depending how far away points b and a are
K I typed this somewhere else but didn't feel like doing it all again so I'll just send the screenshot. Can someone give some advice
Hold on I'll send the original message so you get the full idea
Hi, I'm working on a game and I'm trying to program a way for the player to type to communicate with the NPCs. And I want the NPCs to recognize the connotations in the worlds and respond with either a rude of friendly response. Any ideas??? I'm stuck ๐
Hey guys I've been trying to fix a problem for 2 days, I hope someone can help me here.
I'm trying to make a game using planet gravity physics. I'm stuck in rotating player.
Lets say I pressed "Left Arrow" and wanted to player to go left and turn left at the same time. The problem is "transform.TransformDirection(moveDir)". When I make the player turn to the left, player starts the move its left side instead of the world position. If I only use moveDir for positioning, it goes out of the world. How can I make this work?
Nevermind I was able to fix it by running the text updater script multiple times lol.
Probably gonna screw me over later but the game is low res and low poly so performance shouldn't be too bad ๐
Maybe you are using bilinear filtering for the texture?
Yes, sounds like texture filtering
Dunno, I never changed it
Look up how filtering works
I believe there is a pixel-perfect camera package
Maybe that helps
Hey yall,
Do you have any idea why this code is called more than once whenever I call ShowAd() from my gameManager?
https://pastebin.com/NQ8qj34f
Is anyone here familiar with 2D Boids? I basically have it working except for one problem, their turning is too fast which makes them sort of freak out
Anyone know how to reduce their turning speed?
not entirely sure what you mean by turn left and go left at the same time but perhaps detach the reference point from direction the player is facing to something like the direction of the north pole
you then handle positional movement based on north pole direction and turning becomes a secondary animation that mostly just displays information about where you last moved from
How do I check if a Query is empty?
What do you mean by query?
Query userQuery = databaseReference.Child("users").OrderByChild("username").EqualTo(_username);
I want to check if the _username already exists in the firebase database
That's a firebase api question, so I'm not personally sure.
You probably should ask in a firebase forum, or go through some of the provided Unity firebase examples.
aight
Hi, I have a short video with audio on loop using Unity's Video Player. Webm file (Video: VP8, Audio: Vorbis). I change the speed of the video dynamically. The video processing is find, but the audio gets out of sync and if the video slow down by 0.5f the audio stutters and throws warnings like
AudioSampleProvider buffer overflow. 1028 sample frames discarded
I had a look at google and found a few threads / bug reports but there were either no solutions or blamed low device specs (this is definitely not the case for my pc build)
Does someone has experience with this behavior?
is anyone available to help me out?
Just ask your question and find out?
[Subsystems] Discovering subsystems at path D:/RoForce/RoForce_Data/UnitySubsystems
Forcing GfxDevice: Null
GfxDevice: creating device client; threaded=0
NullGfxDevice:
Version: NULL 1.0 [1.0]
Renderer: Null Device
Vendor: Unity Technologies
Begin MonoManager ReloadAssembly
- Completed reload, in 0.149 seconds
Microsoft Media Foundation video decoding to texture disabled: graphics device is Null, only Direct3D 11 and Direct3D 12 (only on desktop) are supported for hardware-accelerated video decoding.
WARNING: Shader Unsupported: 'Hidden/Nature/Terrain/Utilities' - All passes removed
WARNING: Shader Did you use #pragma only_renderers and omit this platform?
UnloadTime: 0.930400 ms *FIXED Turned of server build
anyone know what this is i have direct x 12
I have a camera that I adjust on-the-fly to enforce aspect ratio. I just moved the rect x position lef and right on the picture before setting it back in the middle in order to demonstrate my issue. The parts of the screen not being rendered are no being cleared. I've tried running GL.Clear() with color black but it didn't do the trick :L.
LODs
https://pastebin.com/dqz7Adwe
what does flyweight pattern help me ? why is that supposed to be made ?
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
its copy pasta from wikipedia
The first sentence of the wikipedia article:
the flyweight software design pattern refers to an object that minimizes memory usage by sharing some of its data with other similar objects.
but isnt that just pooling with extras?
its not at all like pooling. you are creating a single shared data structure between multiple objects that use the same data
its more like using scriptable objects in unity
ahhh
I am not sure if I have asked already before in the past but... can Unity serialize a HashSet?
the documentation lists out what unity can serialize here: https://docs.unity3d.com/Manual/script-Serialization.html
The only collections are arrays and lists
Thanks
you just need asset store packages
that allready made it
as unity just doesnt want to do so
doing it yourself with ISerializationCallbackReceiver is easy. The docs example is for a dictionary, but doing it for a hashset would be extremely similar. https://docs.unity3d.com/ScriptReference/ISerializationCallbackReceiver.html
dictionary lite is good for serializing dictinoarys
Yeah, I already did that ๐ I have never used that interface, so I learned something new
even though I must have 2 data structures for the same data... one for runtime, and one for serialization
But I guess it is not the worst
Does anybody have an idea if NetworkObject instantiation parenting works as expected? I'm instantiating GOs on the server and parent them to another NetworkObject inside that scene, but clients that sync up with the host don't parent the child GOs to the correct parent. Instead, they are placed at root and I get the exception that "parenting is only allowed on server", even tho I'm not even parenting them on the client. What's going on here?
Anyone know why I'm getting A Native Collection has not been disposed, resulting in a memory leak even though I'm disposing all the NativeArrays I'm using?
https://forum.unity.com/threads/solved-a-native-collection-has-not-been-disposed-resulting-in-a-memory-leak.548929/
You are disposing them incorrectly?
https://pastebin.com/tKzHAGSH
i got those methods that i just use to trigger during development .. is there a way to get "kicked out" in realease?
is that something with that #if stuff?
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
or during non editor time
they dont get called from anywhere else
yea using a preprocess instruction like
#if UNITY_EDITOR
this code will not be build into release
#endif
what is that exactly doin?
its tell the compiler that if the directive "UNITY_EDITOR" is defined, it won't read the code inside the block
when unity is building, it removes the UNITY_EDITOR definition, and thus its not in the build
more info here if needed https://docs.unity3d.com/Manual/PlatformDependentCompilation.html
gotcha
don't forget to also remove the using UnityEditor; if you have it, else it can't be build
personally for this kind of stuff i don't put the using, i just do something like
[UnityEditor.ContextMenu]
so it's already in the block that will be removed
that's a nice way of handling it, i always do the:
#if UNITY_EDITOR
using UnityEditor;
#endif
but your way is more organized
Im trying to make this weird extension for the hell of it and its almost working
https://paste.ofcode.org/3bqATHAFRKznkKyaWnrYmUj
Only problem is that Im getting an error
operator == cannot be applied to types V and V
Any ideas?
that's not an extension btw, let me check your problem
Oh yeah your right, forgot that not everything in my Extensions class is an extension
what is it supposed to do ? i'm not sure I understand, don't you need to use only generic type "T" and V is too much?
Say you have a struct containing a float and a string
You could go through a list of that struct and find the struct where the 'Name' variable is 'John' or whatever
Not at all useful, just trying to push my limits
I guess the issue is that V doesnt implement the operator '=='
you need to add a constraint on V to say "it should require a '==' operator" i'm not sure how you could do it though ๐ค
try V : IComparable
Unfortunately not
V should be a struct as well then no?
V is any variable in the struct
'Constaint cannot be special class object'
Maybe its not possible lol, thanks anyway
but you definitely missing a constraint on V thats for sure
What is sort order referring to here?
https://docs.microsoft.com/en-us/dotnet/api/system.icomparable.compareto?view=net-6.0
Hello there folks... I was wondering if anyone could point me in the right direction for something I'm trying to do. I'm trying to draw a box polygon on screen with the mouse using two endpoints. I can get the endpoints from the mouse clicks properly with ScreenToWorldPoint(), but when I try to create the 4 vertices, the scaling seems to be really far off. Is there some other scaling system I'm missing or something?
I finally finished this abomination of an extension, I feel like Dr Frankenstein
https://paste.ofcode.org/XwtHAH6RVGSp2txyj5vrWK
Try changing resolution, if scaling is different on different res then you might need to get the points with respect to screens width/height.
Hi, any ideas why the Unity framework on iOS is dynamically linked and not statically linked? It's about 80mb, so statically linking it would significantly improve startup time and app size.
I've looked at https://docs.unity3d.com/Packages/com.unity.collections@1.0/manual/allocation.html and I can't see what I'm doing wrong. I'm calling .Dispose() on all the arrays when I'm done using them, and I can't see what more to do.
Can you show your code?
Bot is wrecking code upload lately. Post it in a code dump site from #854851968446365696
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
there's other stuff between there, but I don't think it's relevant, just getting data from the job
Are you sure your job.Complete() completes in 4 frames?
I don't know how many soldiers you have
If this is a really long job, you could probably go over the 4 frames and get the error.
Or your fps is really high
//declaration, so you know
List<string> x.recipe
public Dictionary<char, Item> x.keys = new Dictionary<char, Item>();
foreach (var item in x.recipe)
{
Item curr;
x.keys.TryGetValue(char.Parse(item), out curr); //error here
items.Add(curr);
}
i get an error herewhen the x.recipe is for exmple "XXX", that says: FormatException: String must be exactly one character long. that shouldnt happen, because i am iterating throught each one character in the string. However if the string contains only one letter, "X" for example, it works. can you guys help me here?
x.recipe can't be a string, because it would give a different error message (can't char.Parse a char)
don't use var just because of things like this
still same after changing var to string
100% is not
Also, I'm highly sceptical of it working in an IEnumerator. I don't know where you read that that is allowed.
But I usually just use the NativeArrays in DOTS, so I might be wrong about that.
hmmm I'd thought of that but I didn't think it would take that long
You can just profile it
but that seems the most likely answer
yeah I will
ok so it looks like on average the job takes around 1ms
should I change from tempjob to persistent?
Nah, you are not going to reach 1000 fps.
Where did you read you were allowed to use IEnumerators for the jobs?
I didn't read it anywhere
that's just how it was after restructuring my project
idk what the better option is
oh wait
let me try something
That would be my guess. Because I have never seen jobs in an IEnumerator, it needs to be on the main thread.
https://docs.unity3d.com/Manual/JobSystemJobDependencies.html
so should I just run it in Update() or something, and just have a flag in an IEnumerator?
Well the problem is that I know Jobs from DOTS: https://docs.unity3d.com/Packages/com.unity.entities@0.51/manual/ecs_generic_jobs.html
You are trying to do it without DOTS.
yes
So yeah, my guess would be do it in Start
Or update on a key or whatever
It needs to be on the main thread

Rip ๐
I've been deceived
now I'm at a complete loss, I have no idea what could be causing it
Show the error and the code again ๐
Also why are you Disposing with an argument?
https://docs.unity3d.com/Manual/JobSystemSchedulingJobs.html
ah, I was just trying something from the manual as a last-ditch effort
it didn't seem to make any difference
Not in an IEnumerator but maybe on the main thread it does
I removed it and still getting the same error
now it seems to be mainly coming from a particular array... let me try to figure out what's wrong with it
is there an issue using NativeArrays with length 0?
No clue
or maybe it's too big? idk
Whats the error you have now?
same error, just for this line
NativeArray<SoldierData> _closeSoldiers = new NativeArray<SoldierData>(len, Allocator.Persistent);
well, I had it as tempjob before but I think it was the same thing
I'll try to switch it back and see
same thing
Well I don't know then ๐คทโโ๏ธ
Not cleaning NativeArrays correctly could mess you up in between runs, so you can try to restart Unity.
Other then that if you use it on the main thread, it looks fine.
alright, I'll try the good old "turn it off and on again"
no luck :/
yeah, hold on
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
NativeArray<SoldierData> _closeSoldiers = new NativeArray<SoldierData>(len, Allocator.TempJob);
if (len > 0)
_closeSoldiers = unit.closeSoldiers.ToNativeArray(Allocator.TempJob);
That seems janky, otherwise it looks good to me.
yeah, I agree...
Anyhow, gotta go, good luck with it ๐
alright, thanks
bruh... I just changed it to NativeArray<SoldierData> _closeSoldiers = unit.closeSoldiers.ToNativeArray(Allocator.TempJob); and that fixed everything... I'm so confused
I had it the other way bc at one point I was getting errors since I had forgotten to create a new list on startup, so I thought I had to do it like that, and when I fixed the list I forgot to change it...
seems like when you did new NativeArray before the if previously then overwrote the reference with the ToNativeArray line, the new array was probably the one throwing the error
yeah, that seems about right
man, it was so simple... I've wasted so much time
anyhow, now I can get back to optimizing
oke guys im trying to do onclick function
if photon is connected to master and joined lobby it just activates and disactivates gameobjects
if not it connects and do somethings
here is the script to better undestand
but it just says like this in the console log
Hi guys.
I have a problem using asset bundles loaded from PAD in Android.
the meshs dont load completely.
It seems something related to dependencies, but I dont know how to debug
asset bundles was generated using AssetBundle Manager from Package Manager.
Someone?
none will download your malware
post it properly
ah yes .txt malware
use a pasting site or a screenshot
you dont know much about OS when you think that the file extension has any meaning
I doubt you can get malware through embedded txt files but still, paste site would be a better idea
as soon as its on your pc everything is possible
can a .txt file execute itself?
ofc
its just a name of the file
it has no meaning about whats inside
just when you name it .txt you say programs "when you read .txt then this file will work probably"
yes but it won't change its own extension
it would require the user to manually change it to an exe
wouldn't it?
text.txt.exe
double extensions are a different story
if you have disabled displaying extensions then yes
depends if you hide the extension
its per default hided
and i dont change my settings for someone who is too lazy to read the read me
@buoyant vine bro no comment
my comment for that #854851968446365696
@lavish sail dont loseur time talkng to him
and if ur not answeringmy quest or someone else's quest stu
<@&502884371011731486> @golden lagoon wont follow read me and post properly and uses "stfu"
nah
why so much agressivity
and seeingedited messages is illegal in discord
not really lol
!warn 877774018747453440 Don't insult community members. Read #๐โcode-of-conduct
! Harvy.#7247 has been warned.
yes it is
thanks bro
@golden lagoon There's no off-topic here either
:page_with_curl: Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastepaste.com/, http://pastie.org/
no downloads
its not large
with what do u think bro
u can just expand it
and read
it
dumm
y
:page_facing_up: Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.
```
nah ur not gonna show me how tro do dat
@golden lagoon Read the #854851968446365696 how to post code.
nah
anyway it's #archived-networking stuff
im done
wrong channel
i posted it 3 times now
ye bro ik
i read it
but
this guy
is
@golden lagoon And stop spamming
nah im done
he looks like he has alot of free time doing nothing wasting my expensive time
its my fault to even answer him
My Bad...
i just gotta go search somewhere with real programmers abouta solution idk why im even here
you need to go to #archived-networking
well they need to fix their attitude, really
How can I define an AssemblyInfo.cs file for the predefined assembly? I'd like to make its internals visible to the also-predefined Editor assembly.
Hey guys. #854851968446365696 says to use the pastebin for "long snippets". I hope this isn't a "long" snippet but here goes:
I have some class which I have thousands and thousands of at runtime:
class WorldObject : MonoBehaviour {
private int MyValue;
}
Now, I also want just a few of them to be networked. Not all of them, because that would be a lot of networked objects :
class NetworkBehaviour : MonoBehaviour {}
class NetworkedWorldObject : NetworkBehaviour{
private int MyValue;
}
To preserve the functions and properties between the two, I would ideally have NetworkedWorldObject inherit WorldObject. However, it's already busy inheriting NetworkBehaviour.
Is there any way I can get NetworkedWorldObject to inherit both of these classes? I've looked into the idea of interfaces but I don't think that I can use that here, since both NetworkBehaviour and WorldObject need to inherit MonoBehaviour -- which is just kicking the can down the road.
interfaces: https://www.geeksforgeeks.org/c-sharp-multiple-inheritance-using-interfaces/
maybe composition instead. Extract the shared properties and methods into a separate object that NetworkBehaviour and NetworkedWorldObject have as a field
I'm trying to load and use the opencv library in Unity via a custom plugin dll and opencv_world460.dll (which I also compiled myself from source). However, when attempting to load opencv_world460.dll Unity throws an error stating: "Plugins: Failed to load 'Assets/Plugins/opencv_world460.dll' because one or more of its dependencies could not be loaded."
To track down the problem I ran the dependency tracing tool "Dependency" on opencv_world460.dll. As far as I can tell, the tool is able to resolve all of the dependencies required the run this dll on my machine. Obviously Unity is still unable to find or load one of them for whatever reason. The attached image is the dependency list for opencv_world460.dll.
Does anyone have any suggestions about how to track down specifically which dependency is failing to load? My best guess is there's a problem with all of the api-ms-win-crt dll's being forwarded to ucrtbase.dll. In the meantime, to test this theory, I'm going to go download the redistributable containing those actual dlls and install it to see if that has any impact on the problem.
Have WorldObject not inherit from either, and rename it to BaseWorldObject. This class will have properties, fields, etc that the new WorldObject and NetworkedWorldObject will inherit from. In all instances, they will all inherit from a MonoBehaviour but depending on the context, will be networked or local. So you can have: MonoBehaviour > BaseWorldObject > WorldObject and NetworkBehaviour > BaseWorldObject > NetworkedWorldObject and still retain the fields and properties BaseWorldObject implements.
Wait no that wont work lmao
I forgot that C# doesn't support multiple inheritance so that wouldn't work lmao. Ideally, all objects that pertain to the same design scope should be under the same type. For example: networking bullets (which is actually a bad idea, but this is just an example) will spawn on the server as a networked entity. They wont actually have any visuals, other than information about collisions, direction, damage, etc. On the client(s), you will extract the information needed from the networked bullet and generate visuals when needed. I really don't know why you want to selectively network objects or not through inheritance. This should be done contextually based off of certain conditions in the scene (is it visible? behind something? Not spawned yet? etc) for if an object should be synced with clients or not.
that's what interfaces are for
AssemblyInfo.cs isn't special, it's just a file where assembly-level attributes are put by default. You can just create that file or put them anywhere in the source code for the assembly though: [assembly: InternalsVisibleTo("xxx")]
Use multiple MonoBehaviors on the object, WorldObject can hold the value, and NetworkBehaviour can reference the WorldObject behaviour to get it
Thank you!
by predefined I assume you mean without an asmdef?
How to hide public variable in inherited class? If u use new you can still see hided one in Inspector
I need to hide it only in inherited class
Ok, thx
or make the property in the base class abstract
so the inherited class is responsble for the hiding
But I can't create an abstract property
public class BuildingStuff : MonoBehaviour
{
[SerializeField] private BuildingSO _buildingParams;
public virtual BuildingSO BuildingParams
{
get => _buildingParams;
set => _buildingParams = value;
}
}
public class AttackBuilding : BuildingStuff
{
public new AttackBuildingSO BuildingParams
{
get => (AttackBuildingSO)base.BuildingParams;
set => base.BuildingParams = (AttackBuildingSO)value;
}
}
SOLUTION
I was too close
Hey guys, how can I call classes with tags, like for an example with Mirror where you type [Command] [Client] etc. My idea is to create a tag like this (Command("method name", object, object 1)} and when this tag sits above a method, I can then go to my command console and type the method name and it will call it from the console. I cannot wrap around my head how this works, what is this called and where do I find resources to learn more about it?
They're called attributes. You need to use reflection to loop through all the classes/methods etc and check if they have the attribute attached.
You can definitely set something like that up, basically your console can just scan for all the methods with that attribute at startup
could you point me to somwhere where I can learn more about attributes? I am failing to find something useful.
hey, anyone has experience with firebase here?
When reading values from the reatime DB from a different device than the one this value was uptaded, i recieve different values than what i can see on the DB, any clues or tips as for what could be causing ths? Im using this in unity so might aswell ask here ๐
hey, is there is a way to optimize temporary unity on play time ?
i'm trying to test a multiplayer game on the same laptop, and it doesn't take long before the laptop gets over heated and everything starts to lag, is there is anyway i could minimize the loads on the graphics temporarily?
Worked a lot with the JavaScript SDK for work, never saw that happening
Is the value changing like, A LOT ?
Not a lot, but it is behaving weirdly, basically sometimes, the value i saved in the DB and i can see in the firebase console, when i go and grab it, i get something different
Uhm closest thing I can think of is viewing the value from the browser sometimes hanged up when trying to display collections too big. Still seeing the value updating in orange from the console ?
yeah i see the value being updated into orange. then i disconnect, connect back to it, get the same value, but i recieve something different
is there a way i can directly debug the Realtime db, something that lets me see what calls are made and to what end? or similar
Something wrong with the code probably then
At work I used to monitor that with the rest of logs from the app
it was just another type of log
nothing special
I remember they have a CLI lib to watch access and performance though, but didnt use that much
worked only when you deployed locally IIRC, so just to test and debug yeah I'd say
there's a database:profile command there, might be worth a try, can't remember what feedback it generates
and double check from the web console, might have some journaling page (pretty sure there was one for Cloud Firebase but not sure for RTDB)
that feedback is only bandwidth and speed data i think
Yeah you might be right, we used it to check during stress-tests, nothing more
here is the code just in case its something obvious i cant see this is the one that reads the value
this is the one that writes to it
I'm more used to JS syntax but LGTM
after writing the data. i just disconnect, see that the change in the db. then connect back, and print that first value i get from it (where you see the print("Direct ..."))
Somehow its different lol and theres nothing else calling it to change before that runs
I got only obvious questions like "you sure user ID is the one you're expecting?", "Code only called once?", "Logs look what you're expecting ?" ๐
but yeah looks like you covered that
no problem i can answer, in my db there is only one userID which is the one im running tests on.
the code is indeed only being called once, and as for the logs well thats how i know i got an issue ๐
Man I got no clue
Thats fine, ill let you kow if i find a solution and what my issue was, thank you very much for the help!!
yeah you got me curious, good luck !
Hello, on my system when I create a compute shader with a product of numthreads higher than 1024. E.G [numthreads(2, 1, 1024)]. I get a shader compile error that it can't exceed 1024. Is the limit of 1024 true for all GPUs? Or can some have that limit as : 64,128, 512, etc.?
Eventually log the value in the snapshot before parsing the string to int, just to make sure, maybe there's some gotcha there
gonna check that now
this is the value of the snapshot
this is the currrent value on the DB lol
how are they different lol, kill me
Not using a staging and prod DB, and forgot to switch config from one to another ?
Hum, i dont understand that, can you elaborate?
you have only 1 db, not using another one for test and somehow forgot to change which one you're talking to ?
I dont quite get that, from my understanding i only have one DB, the one i see in my FB Console
alright all good, just making sure
right now i still have the code paused there, if i refresh my FB console page the value is still 40 not 80, where is it geetting that from?ยฟ so confused lol
Issue seems related to yours: https://github.com/firebase/quickstart-unity/issues/913
(I only read first message)
Looks like subscribing to ValueChanged method instead gives correct value for him, you could try that
man you absolutly nailed it
looks like there's some caching on mobile device ? (I worked on backend team and I can't remember any caching for us)
Kinda seems like it, explains why this issue only happens when moving from one device to another
Thanks mate, I ended up doing this as you said.
Anyone experinece with setting up unity CI/CD pipeline in azure devops? Trying to do build a project from a docker container there but it complains about not being able to output to /dev/stdout. I can get this working with gitlab ci stuff so I guess there are some differences to azure runs containers when it comes to permission and such.
+ xvfb-run --auto-servernum '--server-args=-screen 0 640x480x24' unity-editor -projectPath /__w/1/s -quit -batchmode -nographics -buildTarget -customBuildTarget -customBuildName car-collision-comparsion -customBuildPath /__w/1/s/Builds// -executeMethod BuildCommand.PerformBuild -logFile log.txt
/usr/bin/xvfb-run: 159: /usr/bin/xvfb-run: cannot create /dev/stdout: No such device or address
/usr/bin/xvfb-run: 83: /usr/bin/xvfb-run: cannot create /dev/stdout: No such device or address
I am trying to change solid color of camera in unity via script. basically i want to do rgb computation from 0 to 255 basically 0 being all black and 255 being white. basically i want to be able to click a button that each time i click one it adds 1 grayscale level each time. this is what i have so far: https://youtu.be/Ka5XXGG0aPU
what someone be able to help with adjusting rgb values that every time ihit the button it increments rgb value by 1
Start with Color.black and have an event that adds
Color.white/256
Because white is 1 so if you wanna increment from 0-255 you just gotta divide it by 256
oh ok. are there any docs or tutorials you can also refer me to this as well?
i think i get what you are saying
but just in case