#💻┃code-beginner
1 messages · Page 568 of 1
oh
is that a question
Your question is somewhat vague so yes
here or #⚛️┃physics
it's a problem with your code either way
okay i think it has to do with the entire collisionable tilemap being labeled as ground
can I split existing tilemaps up? or do I have to redo them
running my game on WebGL causes a strange issue. The game loads, then the camera is zoomed in. All assets are on a canvas layer.
please ping me if anyone gets a response, I will be unable to respond immediatly
You'll need to provide a better explanation/demonstration of the issue. Provide screenshots/videos if you struggle to explain in text.
this should give you exactly what you're looking for
i don't think it gives the exact data of the object you collided with, but you can figure that out by spawning a very small ball there that is a trigger, then getting the gameobject from the OnTriggerEnter()
you could also use this: Camera.ScreenPointToRay()
that's half the solution; ScreenToWorldPoint returns a 3d world position converted from a 2d point on the screen. then you need to shoot a raycast from the camera to the world position. this will determine if anything was hit . . .
why would i use it over Camera.ScreenPointToRay() for this purpose?
actually, it looks like there's an overload for Physics.Raycast() that accepts raw rays, so ig you could use either the ray or world point
you can use either or. depends on what return value you want . . .
i think the point is just to get what it collided with, so it's probably not useful retaining a ray nor a world point in this context
i'm saying, you can use either method to get/check if an object collided . . .
so it'd look something like this @tame oriole :
Ray ray = Camera.ScreenPointToRay(mousePosition);
RaycastHit hit;
// shoot a ray to where we clicked and see if it collides with anything
if (Physics.Raycast(ray, out hit, distance) // distance = 100 in this case
{
// tell us what we collided with
Debug.Log("Hit object: " + hit.collider.gameobject.name);
}
now, of course, this will only work on objects that have collisions (i'm not sure if this will count triggers) so you'll need to add some sort of collider shape to any objects that you want to be able to interact with in this way.
also, i'm not going to tell you how to get the mouse position yet because i don't know which input system you will be using (the legacy Input class or the new Input System Package). That part you should be able to figure out from tutorials
ScreenPointToRay has a parameter. you need to pass in a position (the screen point) . . .
This is the top level of my solution - can anyone explain what these mean or how to learn more? What's the difference between assembly and firstpass and editor firstpass, and why is odininspector and ink in their own categories..?
Assemblies are their own isolated "projects" in the solution. In the end they all get compiled into separate dlls. So rules between different dlls apply to them as well. I'd assume that Odin and I'll are actual dlls in your (unity)project too.
I've tried different methods to allow a character's avatar to 'sit', including reparenting to an empty node to the chair or couch to get the right height and rotation.
Is there a more efficient way to do this?
The regular csharp assembly is usually your own code that is not included in any custom assembly(doesn't have an assembly definition file anywhere in the parent folders). Editor is editor only code(usually code that is put in an editor folder).
First pass I'm not sure, but it follows the same logic.
Oh, so first pass is for plugins.
I want to implement Jumping (new input system) without rigidbody, I know we can use transform.translate(vector3.up * someSpeed)... but anything else i gotta take in my mind? Like creating my own gravity, then doing a ground check
Both of those things yes
or maybe I can disable the isKinematic while its jumping and enable it again once it touches the ground? Isnt this smarter
Definitely not. You either have a physics based controller or a fully kinematic one. Mixing the two is a recipe for disaster
ohh, but how is it a disaster
in what ways could it be bad
It’s mixing two mutually exclusive methods
You want physics but do not want to use physics. And thats a paradoxon within itself. If you disable physics for a certain part and move everything manually, you can miss a lot of collisions you might want to check for. What happens, if you jump into a collision, an enemy, against a ceiling and so on. You will start to try to cover evertyhing, physics is already doing for you, just to workaround the physics engine for jumping. maybe you can explain, why you want to avoid rigidbodies for jumping
because using rigidbody is making my movement jittery
{
if (movement != null)
{
Vector3 currentPosition = rb.position;
Vector3 moveVector = new Vector3(movement.x, 0f, 0f);
Vector3 newPosition = currentPosition + moveVector * moveSpeed * Time.fixedDeltaTime;
//clamp player
newPosition.x = Mathf.Clamp(newPosition.x, xMinClamp, xMaxClamp);
rb.MovePosition(newPosition);
}
}```
thatswhy i made my player isKinematic = true.
Its an endless runner game
Than there is something wrong with how you use it. not the fact you are using it itself
I am calling the function in FixedUpdate
thatswhy maybe
you rather wanna explain what "jittery" means and what code parts are running while its jittering
The player movement feels jittery
When its not kinematic
When I make it kinematic, it runs smoothly
I do want to use rigid body as well for collisions and applying some physics
Wait, are you runing that code with MovePosition and you tried to isKinematic = false and it was jittery?
yes
Its for kinematic only taking interpolation into account
Or you move it correctly with rigidbody physics and do not have to turn it off randomly
what I mean is, I do have to create a jump for my player
without using rigidbody
How do I create my own gravity?
okay, you ignore it, got it. 😄 well, then you have to calculate your own animatino curve in runtime, that lerps your y position of the MovePosition to go up fast and back to the floors hit point. You do you
Im sorry but what is animatino curve
but its just an example to visualize in your head, you need to calculate the path of your jumping to physic calculations, as you want to do it yourself.
alright
anyone know whats wrong? i keep doing.. that when I press space, and if I press left or right i go flying in the opposiite direction
this is the code
hello guys what would you recomend as a pathfinding for 2d top down rpg grid walk style for my enemies? i just want it to follow player within a radius and if player goes out of radius enemy goes back to spawn point and back roaming
i was trying to add waaljumping
nvm its fixed now
i mistyped something
You could try setting rigidbody to Interpolate
Can also be a good idea to match your physics timestep with your target frame rate.
Assuming it's 60, you'd set your timestep to 1/60, or 2/60 (etc) if you use interpolation.
!ide
If your IDE is not autocompleting code
or underlining errors, please configure it.
Select one:
•
Visual Studio (Installed via Unity Hub)
•
Visual Studio (Installed manually)
•
VS Code
•
JetBrains Rider
• :question: Other/None
Having a weird issue with Unity 6 this morning. I can't seem to run simple coroutines. I've tried rebooting computer, deleting library folder, restarting unity, it simply won't complete this very simple code. I created a new scene and only put these scripts in it and it still wont complete. https://codefile.io/f/cmz5zA1qd9
Can you verify Start is called at all?
so why not debug the value of IsInitialized ?
Or that
or was that too rude?
Like, did you verify it's actually not called or do you assume it doesn't because the Test class is not called?
That way it can be determined what the root cause is. For example, maybe you didn't include the script at all
Because of the comments I put in, it says Begin Initialization in the console. After that, nothing. When I trace the code with a breakpoint it's almost like the coroutine in Test.cs never begins
That's because you call it wrong
this Test.Initialize(); is not calling a coroutine
-Test.Initialize();
+yield StartCoroutine(Test.Initialize());
I'm surprised this worked at all, if it did
The extra StartCoroutine might not be needed, actually. I don't remember
If you yield the coroutine you wait for it to finish. This way you don't need to extra boolean and while loop
Also, side note, you can make your Start method a coroutine.
public IEnumerator Start()
{
if (!IsInitialized)
{
...
Oh for pete sakes you're probably right. I forgot I did change the way the initialization is managed in the code before I went to bed and didn't test it because I thought it was such a minor change. I changed it from the scripts starting their own initialization coroutine in start, to the game manager initializing them in it's initialization coroutine one by one. That didn't work this morning so I copied the code into these simple scripts and now, I feel like an idiot lol
Either way the root reason is the fact you call the Coroutine wrong. Enumerations are not invoked with a simple method call, but have to be iterated. In your case it likely got to the yield return null; part and then paused and waited for something to continue it. However, nothing does that
So to comment on my previous point, you do need to wrap it in StartCoroutine then because then Unity handles the iteration
You can also verify this by putting a log before the yield statement. You'll see it gets called, but whatever comes after does not
he knows how to start a coroutine as shown by his code, no need to belabour the point
I know, this is just extra explanation as to why it would break specifically
Yes and it's working fine now 😛 I apparently need coffee this morning
Brain is still asleep methinks
pro tip: you need coffee every morning
Don't forget that coffee is the source of good code
https://paste.mod.gg/seoydkgszyrr/0
https://paste.mod.gg/tqrzxmnyeank/0
I've encountered a jittering problem that appears only in the Game View. It doesn't occur in the Scene View. My player movement and camera systems are implemented with separate scripts, and I suspect the issue might be related to how the camera follows the player or processes rotations.
- The jittering happens when rotating the camera or moving the player.
- It is more noticeable during rapid movements or rotations.
Any help would be nice.
A tool for sharing your source code with the world!
A tool for sharing your source code with the world!
You also can omit StartCoroutine when starting it inside another coroutine, but it has to be yielded.
yield return MyOtherCoroutine();
trouble with that is you cannot Stop it if you need to
yep, it's situational
interesting, not tried it, would stopping the outer coroutine also stop the inner one?
Probably not since they don't rely on eachother. That would also make for weird edge cases
I forgot how it works exactly, I had a testbed checking all cases with them at some point. Move on to UniTask now.
Hey I did learn something though! I didn't know you could yield return StartCoroutine() lol
Better to delegate cancellation with something like CancellationToken if you need things to cancel as a group
I suspect you are correct, would lead to some very strange internal situations
Try deselecting any selected scene objects. Sometimes the inspector view can considerably slow down the game view, especially when updating serialized values.
(Or did I misunderstand the issue and this also happens in standalone builds?)
i tried but still jittering happens during i rotate my camera
Seems that killing outer coroutine does not affect the one that it starts.
I will try it now and tell you the result.
I tried it on build project and same jittering problem.
Are you using a Rigidbody based controller?
hmm, I would love to see the code stack that the leaves behind, i'll need to look into it
Since your rotation code is directly modifying the player's Transform, it will cause the Rigidbody interpolation to break
You should never directly modify the Transform for a Rigidbody
Rotate via the Rigidbody instead
like rb.MoveRotation
I saw that solution on some forum sites but never tried yet
Or even just setting rb.rotation instead of transform.rotation
If you use MoveRotation it needs to be in FixedUpdate
And the mouse accumulation needs to be handled properly if you're using mouse controls
It's slightly trickier
I use player Input system for getting mouse input
I'm brand new to game dev and was wondering if a good game to start to make would be a tower defense game? for a beginner, I do have a bit of coding experience.
Sounds like a great first project
sure, just make sure you !learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
would i need to make my own assets or is there a place i can find free ones?
Asset Store
you can make your own or find some online
you can use sites like sketchfab, CGtrader, etc as well
ok thanks
gotta watch those for commercial use
of course 💯
tbh, 99% of the time as a beginner you don't need assets, placeholders like cubes, spheres and capsules will do just as well
sounds good
Isn't splitting the MusicManager into 3 separate classes here just overengineering? I can't think of a single benefit
what is this from?
I'm using chatgpt to try to understand what i need to improve in my code to make it more SOLID
because I swear the more it's explained to me the less I understand it
consider not using the infinite sludge generator
I think it's fine as long as I'm not taking it at face value
it will produce an enormous amount of plausible-looking text
I hope you don't believe that GPT 'knows' what SOLID even is
I'm starting to believe no one does because everyone seems to think differently
Let's not get carried away by the GPT'ness alright, I think @rancid tinsel 's original question is still valid :D
Which would be fine if I wasn't being graded on how subjectively "solid" my code is
gpt specializes in misunderstanding
anyway, all three of these are restatements of "it controls the music"
My unpopular opinion is that Manager classes are code smells and by simply not naming anything "-Manager" you're more likely to end up with a cleaner architecture.
you could just use one class to control music, I don't see the need to split it into 3 more classes for 3 simple items which can be shoved into 1 class
trying to break that up into small pieces would be nonsense
it is basically like cutting chocolate into small chunks and eating them 1 by 1, it is insanity
chickenshit abstraction, in my opinion
that's my opinion too - I feel like the issue might be that SOLID only works in bigger projects
and that wasn't taken into consideration when designing the course
it sounds like you're doing some kind of school project here
you have to have a coherent definition for "single responsibility"
You can always find some weird angle to split an existing object with
until you have 4,000 classes that all do nothing and a game that doesn't work
but hey, the code is Clean (tm)
gonna need a dictionary for 4,000 classes
and it will cost roughly 1,000 dollars
That sounds like multiple responsbilities! Time for a DictionaryFactoryDelegateStrategy!
I've been told that code I wrote had multiple responsibilities: 1. determine sentence type 2. verify sentence based on their type 3. manages unity components, which makes me think that I'm meant to use classes like methods?
been told by whom?
Professor's assistant
"manages unity components" is an insanely vague statement
I think it was in regards to setting TMP text in the same class that also handles the actual values
iirc
Is this maybe a case where they expect you to adhere to a model-view-component pattern perhaps? I can imagine if that's been taught that it could be expected from you in the project assignment.
that part I agree with to an extent, you'd probably want to pass the value to some sort of UI manager that then displays it
right?
I don't think that one has been taught, it doesn't ring a bell
Yeah I just read about it and it doesn't sound like anything we've covered so far
could be wrong but seems more focused on software rather than games? (like front end, back end?)
I don't know what your game is actually doing here
but I can imagine your game getting some input from the user, then handing the string off to a text validator
and then displaying something in your UI based on what the validator said
you don't want to shove the validation logic directly into the UI components
sort of, it takes input in the form of "nodes" and then tries to piece those together to then make some sort of string
because then you have to have a UI component to be able to do anything with text validation
like making a sentence with blocks essentially
i can show the script in question actually one sec
A tool for sharing your source code with the world!
its a bit of a mess because I was struggling to figure out the logic when writing it
so it was essentially the first working version
oh looking at it again its actually taking the value from the TMP component, and then using it to parse
Ahh, yeah it's true it's not really best practice to just do a GetComponent call for a UI component, hope it's there so you can get the value.
You'll want a separate class that has direct references to the UI elements, and an instance of your SentenceParser class that it uses.
Ideally you'd want to be able to use your sentence parser regardless of whether you've got a dropdown selection, an input field or just directly feeding it options.. For instance.
Definitely, I think hardcoding was just the only solution I came up with at the time for the parsing logic which is also why the rules are methods instead of their own classes/child classes
btw, how does the unity inspector tie into all of the SOLID and clean coding stuff? from what I understood, it breaks encapsulation because you can change variables outside the class
idk if that is something that I need to worry about for the project but I'm just curious
The Unity inspector just exposes serialized values for you to edit visually through the Editor. Conceptually there's no real difference between you setting a value through the inspector vs you defining that value directly through variable declaration in code.
Well the main difference is two different copies of the script can have two different values.
Sure, but in terms of "Clean code"
from what I understood, it breaks encapsulation
Encapsulation is a code concept. The Editor environment is a thing of its own and doesn't really apply when you talk about SOLID and clean code.
You'll just want to make sure that when you're writing your systems, they encapsulate their functionalities from other systems in code.
Is this a common issue? I'm using SimpleTilemap (https://github.com/kkukshtel/SimpleTilemap). More specifically, I'm testing the Standard Sample with Map Size X = Map Size Y = 1000
Also, each tile is rendered with two triangles, and that makes up for 6 vertices total. Isn't that a waste? I mean, couldn't it just use 4 verts or am I missing something?
dunno whats up in that screenshot but geometry needs to be made of triangles (defined as a set of 3 indicies)
4 verts should be enough however so not sure what its doin
Hmm it seems like that strategy arises from this error:
Failed setting triangles. The number of supplied triangle indices must be a multiple of 3.
UnityEngine.Mesh:set_triangles (int[])
So was that a good solution or is there a way to save the 2 extra verts?
Each triangle is defined by a set of 3 vertices
The author is wasting vertices - you would have to modify the code yourself. But first debug it
You can re-use vertices
so two triangles can use the same vertex index
but you still have to specify all three indices
Yes exactly
(you could use the "triangle strip" mode, but that would be pretty awkward for a bunch of disconnected quads)
Are there any alternatives? Any 2d tilemap library that allows for fast runtime tile modifications
but if the library never sets indexFormat to 32bit you will soon go wrong too...
Also. If I wanted there to be gaps between the tiles (only graphically) is it still viable to reuse the vertices of two adjacent squares? So that adding a row of n squares requires only n+1 extra vertices
you can never re-use vertices from adjacent squares since theyw ill have different UVs
you can just reduce 6 to 4 per square
hello! i wanted to ask what is the most effiecient way of developing player movement with animations?
is it with using input system or normally with coding
is it with using input system or normally with coding
What? These are not mutually exclusive things.
And what do you mean by "efficient"?
Ohh right, thanks
Though I have not used it Unity has its own tile map system - have you not tried it?
Yes. SetTilesBlock (being the fastest way to change batches of tiles) is not fast enough for my use case
I have an infinite tilemap that calls SetTilesBlock on the chunks that the player sees and hides the ones off-camera. I managed to optimize a lot of other stuff, and the bottleneck ended up being that method
I wonder if it'd be smarter to use multiple tilemap renderers
(and thus multiple discrete tilemaps)
how to sync rb character with look direction from cinemachine?
i record a clip showing my problem: https://youtu.be/7rtu4l7SXIc
How to sync rigidbody character with look direction from cinemachine cam?
How exactly?
Instead of storing everything in one enormous tilemap, you'd have a grid of tilemaps
So instead of translating a world position into a cell position, you'd need to figure out both the tilemap and the cell position within that tilemap
This way, different chunks are completely independent
You don't have to mangle a single enormous tilemap every time you want to hide or reveal a part of the map
I have no idea what goes on under the hood, but I imagine that some operations have a cost proportional to the total number of tiles in a tilemap
Hmm I'm not saving anything yet. I just change the already existing tiles because tilemaps do have infinite tiles, you just modify them. Currently I'm showing 128000 tiles at most and I update only batches of them at a given time
https://paste.mod.gg/qqnwvnpsqiro/0 how "clean" is this? I just wrote it with the intention of it: A. not caring about what string is passed into it, and B. only being in charge of managing the dictionary, which includes adding, removing and checking
A tool for sharing your source code with the world!
is there anything else i should add/consider?
im not 100% sure on it being a singleton
if you want a global dictionary, why not just make a static dictionary
does it need to be aware of unity lifecycles at all?
These methods are pointless
I'm pretty sure Add already doesn't throw on existing keys. If it does, you can just use the indexer
Remove also doesn't throw. Even better, it returns false if the key didn't exist so this code just limits the ability to know if it was removed at all
could you elaborate?
Elaborate on what? Using the indexer?
you're probably right, I haven't done that before so I'll look into it
Exceptions
ArgumentNullException
key is null.ArgumentException
An element with the same key already exists in the Dictionary<TKey,TValue>.
yes please if you could
WordDictionary.Instance.wordDictionary["foo"] = true;
Yeah then the indexer can just be used instead
Alternatively there's also this: https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.dictionary-2.tryadd?view=net-9.0
This doesn't throw but rather return a bool
oh so instead of removing/adding it, id set it to false/true instead?
no, that is an addition
- dict.Add(key, value);
+ dict[key] = value;
it also works as a replace
you're already setting it to true/false
Note that if this code ends up doing more that justifies the point of these methods, then you could totally use them. But if this is just an alias (and just exists to check for a key) then note there are existing methods in the Dictionary and you basically limit your ability to communicate with the dictionary this was for no reason at all
what does the value symbolize in the dict?
if it's always gonna be true, no point in having it, may as well just use a set instead
On the topic on improving the code, consider updating the error log:
-Debug.LogError($"SELF ERROR: WordDictionary already exists, deleting {this.gameObject.name}.");
+Debug.LogError($"SELF ERROR: WordDictionary already exists, deleting {this.gameObject.name}.", this.gameObject);
Reason is in the event you end up with a duplicate, you can click the error message and navigate to the gameobject.
Then you can remove it if needed. Maybe also do it for the actual singleton with a regular log message in case that one is the bad actor
i mean, is it really gonna be an error
No, should be a warning
thats neat i had no idea
if you have the singleton able to initialize starting from many scenes, it'd be a normal part of the operation of the singleton
so it wouldn't be a warning/error/unexpected scenario at all
Not sure I follow
if you only have 1 instance of the singleton throughout all your scenes (not at runtime), then you wouldn't be able to use that singleton from other scenes when testing, when the scene holding the singleton hasn't been loaded
would it not be normal to have that singleton be able to load from any scene, where the Destroy part is normal and expected?
Usually your singletons would always be loaded, either in an additive scene or with DDOL
i think he means if you have it DDOL'd, and change to a scene that also has it
at least thats how i understand it
and if it's with ddol, you would need to start at the scene that has the singleton, instead of being able to just test the scene you're working on
in which scenario the one from the next scene is going to throw the error and destroy
So how would that be fixed?
just have it in every scene where it needs to be accessed
and let the Awake singleton logic handle that
But then you have a copy pasted bunch of instances everywhere
how's that an issue?
I mean I personally don't have instances in specific scenes. I usually have a provider that makes them. But even then copy pasting them everywhere makes no sense
Because imagine having a lot of scenes and having to place your singletons everywhere
Or editing them, and having to edit them all
is this more what you meant or am I still not following
I usually just have an additive scene in the background that contains my provider
we have prefabs for that
Placing them in literally every scene is silly
just to clarify - AddWord will be used most likely only to populate the dictionary at the start, and RemoveWord will be used to get rid of words in there if theyve been guessed already
No, not at all
and you'd have to load that scene from every other scene anyways...?
Sure, that's why I asked how it could be solved
oh wait you can add in the inspector nvm
I just don't think you should place your singletons in every single scene lol
Additive Scenes be the way to go 👍 nice and simple
Oh like that
Yeah that's what I mean
The scene basically has a system similar to .NET's IServiceProvider, if you know what that is
yeah you need to provide more detail about what this is going to be for
sounds like you're in an https://xyproblem.info here
it's going to be for a game where you type a certain category of words, and if they match whats in the dictionary, the player gains points, some visual stuff happens and its removed from the dictionary to avoid repetition
true actually
wait but why wouldn't you use a dictionary? im still confused on that
or if you're going with a dictionary, set them to false instead of removing them
what is the point of using the singleton pattern if there are not multiples thereof
a dictionary is a mapping from keys to values
the keys are words here, what are the values?
ig if its... still in the dictionary..
so i could just use anything else
If all you want to know is if the word is in the collection or not, a Dictionary isn't adding anything. HashSet already tells you this. Dictionary requires you to map it to some other information, which it sounds like doesn't exist
that's not the value, no
HashSet makes more sense for just checking for membership in the set
the value here is true, what does that mean
Dictionaries map one value to another value. If the entire purpose is to prevent re-use, simply remove the item from a set, and check for the presence of it instead of a dictionary
you could say the value is whether or not the word has already been guessed, which is what i'm suggesting here
so if im following youre not necessarily saying you cant use a dictionary, its just that there are things better suited for what im doing?
It's pointless to have Dictionary<string, bool>. It's just a waste of memory to store things there with false
yes
Multiples thereof? I don't understand
Point here is accessing the single instance?
ill look into hashsets then and report back if im struggling with anything
HashSet literally works the same as a Dictionary. You just don't give a value when adding entries
Just please use case insensitive comparisons. You can set it on the HashSet constructor as a parameter
The whole point of the Singleton pattern is to ensure there is one and only one instance when there could probably be multiples
Huh? A singleton pattern doesn't ensure that multiples are gracefully destroyed
If there are multiple, that's an error
Nothing about a singleton pattern ensures this is done
depends on how you make the singletons imo
instead of manually placing singletons in every scene.. which could be error-prone or just repetitive.. its possible to use them in an additive scene to help make life easier and scenes cleaner for those working w/ it..
duh
if (instance == null) instance = this;
else Destroy(gameObject);
i use singletons in persistent scenes.. (or u could just call them static classes)
The difference between "having a static instance variable" and "the singleton pattern" is gracefully having additional instances of an object self-terminate.
Yes, that's what the code does. I'm not sure what you mean
Is the issue logging that multiple instances exist?
this is the same difference between the singleton pattern in general and the singleton pattern used in unity
That's how it takes care of multiples. It destroys them
Considering Unity doesn't guarantee order, I don't see the issue with logging an error
Unity adds on the DDOL layer to the Singleton Pattern
What if it destroys the wrong one?
it removes the static guarantee from the singleton pattern
There is no "wrong one", it just needs to ensure that there is one
Fair. Although with Resources.Load and a prefab, you could re-enforce that
There's definitely a wrong one when the available singleton is suddenly not in a persisting scene and it gets destroyed by Unity
A good singleton pattern would not even care about this. Instead of defining the instance in the scene you'd have a general provider do it for you and ensure the right reference is returned when you ask it for an instance
did i understand correctly that a hashset never allows for duplicates? as in, if its already in there it just replaces whats in the same "location"
Yes
The HashSet compares hashcodes. So if the hashcode is the same, it will be a duplicate
Technically, that's a property of any set, but the HashSet uses the hashcode of the object to ensure no duplicates
And this is such a broad term that you really can't say that it would not allow duplicates
so HashSet is generally the one you want to use
For example with your strings, casing already matters
ah right
That's why I said you need to make it case insensitive
You can also modify the hashcode returned. It's a good idea to do this in some cases
But because of that different classes/structs/types will return a hashcode differently. It also means modifying a value in a class or struct might not suddenly make it unique
But whatever, too much explanation. Just make it case insensitive in your case and it will be unique 😄
it doesn't replace it, it just doesn't do anything
Yeah, if the two objects are the same, there's no difference between replacing it and doing nothing
Here's a class that when used in a HashSet will never allow for more than 1 entry to be added
public class Foo
{
public override int GetHashCode()
{
return 0;
}
}
It will allow multiple entries
it will just be VERY SLOW
because every pair of objects will have a hash collision
HashSet also uses .Equals
The HashCode is used first to rule out things definitely not being equal, quickly
Such a HashSet would essentially be O(n) for insertion and removal
Yes the contains check is totally pointless here for a HashSet
What you can do though is something like this, which is occasionally helpful:
if (myhashSet.Add(x)) {
Debug.Log("Item was added");
}
else {
Debug.Log("Item was a duplicate");
}```
btw i just came across string.ToLowerInvariant - is it good practice to use that over just string.ToLower?
Probably yes
oh thats interesting
Yes. For some reason the better practice is ToUpperInvariant according to my analyzer
i know i wont need it in my case but i can definitely see that being useful
Strings should be normalized to uppercase. A small group of characters, when they are converted to lowercase, cannot make a round trip. To make a round trip means to convert the characters from one locale to another locale that represents character data differently, and then to accurately retrieve the original characters from the converted characters.
huh, TIL
Heh, well there you go
I just went ahead and turned that part of the analyzer off since I never understood why it required this
iirc the most notable (ig) culprit is the turkish lowercase i
why do my raycast don't work? why do it returns me almost the same point as the ray creator?
show code and related setup
public class rotator : MonoBehaviour
{
public Vector3 collisionpoint;
public GameObject checker;
public Ray ray;
private RaycastHit hit;
void Update()
{
ray.origin = transform.position;
ray.direction = -transform.up * 225;
Debug.DrawRay(transform.position, -transform.up * 225f);
if (Physics.Raycast(transform.position, -transform.up * 225f, out hit))
{
collisionpoint = hit.point;
}
}
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
Probably because it's hitting something at almost the same point as the ray creator
like, collision of my player?
Try logging the object you hit to see
yes, that is 100% a possibility considering you aren't filtering out anything for the query
now it returns me only 0, 0, 0
have you tried logging what was hit
yes
so what does it say was hit?
if (Physics.Raycast(transform.position, -transform.up * 225f, out hit) && hit.collider.CompareTag("Ground"))
let me check
this does nothing to control what the raycast hits
the length of the raycast is also not what you think it is
the length of the direction vector is irrelevant
there is a separate parameter for the maximum length of the ray
you're not using a layermask so it's possibly hitting part of the player itself for example
ray returns me none gameobject that was hit
Then it hasn't hit anything
What do you mean "none gameobject"?
it returns me none
how have you confirmed that
You need to make sure there was actually a hit wherever you're checking. The fact you're just expsoing a public Vector3 and blindly reading it isn't good
That means you didn't hit anything
but yeah how are you confirming that
ok, it returns me my ground block, but vector3 changes only if i touch another ground
like, when i'm moving on one platform, the hit.point isn't changing
and when i go to another platform, hit.point changes once and then don't change
i am really sorry to pissing you off (if it is)
hit changes every time you call Raycast, regardless of whether it actually hits anything
urm... what? void Update don't make it changes constantly?
Every time this line runs:
if (Physics.Raycast(transform.position, -transform.up * 225f, out hit))
hit will change.
Regardless of whether it actually hits anything
Again, hit will change literally every time you run the raycast
check your spelling
capital H
you've had this issue before, haven't you?
show it
i told you the fix
forgot
like, while raycast is true?
you have an axis Horizontal, you're trying to use the axis horizontal, those are not the same
No, I said what I mean. Every single time you call Physics.Raycast, it will change hit
nope, always. you can also just run raycast on its own and it'll change whatever is after the "out" (the raycasthit)
ty these capitals are makin me sick
things need to be spelled correctly, yes
If this is a common occurrence for you, you should know by now to check that before asking here
now it changes constantly when it just hits something, not only ground. There is a question... WHY?
I don't know how many times I have to say it, but hit will change every single time you call the raycast function
No matter what
In fact, it MUST assign a value to hit. The compiler demands it.
(for spherecast, but, same thing)
the layermask value will make it hit certain layers
As far as the function knows, hit is completely uninitialized, and MUST be assigned to by the time it exits.
for exactly the same reason that this is illegal:
int x;
x = x + 1;
im lf a system to save player data when quitting and loading at rejoining. What concepts do u think I should learn first to make it?
how to save and load data
ok, u've simplified it all lol
https://docs.unity3d.com/ScriptReference/PlayerPrefs.html < (i think this is what is typically used)
you asked what concept to learn first, that's it.
You can start by reading about PlayerPrefs -- it's extremely basic and not suitable for many tasks
but it's enough to store some numbers and read them later
please don't use playerprefs for saving data. it's garbage
ok that's enough for me rn
You naturally bang into problems when you want to save, say, an entire list of numbers
and that naturally leads to more complex solutions, like JsonUtility and files
i sure do love when developers refuse to learn the right way to do things and bloat my registry with save data!
well, its not like its going to be used on any big projects anyway. for a beginner, its probably fine
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
is this normal?
instead of solving your previous issue the correct way, you've gone and created a new axis that appears to be backwards
i do find it interesting how PlayerPrefs is incredibly platform-specific
the registry in windows, a plist on macOS, ...
show your axis setups please
Show the config for your custom axis called horizontal
did you make another axis
idk
the most valid fix would have been to spell Horizontal correctly instead of creating an entirely new axis
english is not mt first language ok😔
but you were already told the correct answer before you went and did that
im.. not sure what that has to do with anything
your language doesnt have capital letters?
many languages don't lol
as russian, i understand you
what? The crylic alphabet has capital letters
the remark is unrelated to capital letters
hey, i am really sorry that you had to repeat this multiple times. I think it pissed you off. I am really sorry
Just a dumb question: Can a player get prejudiced by hackers in a 100% offline game or it's alr?
doesnt the horizontal have to start with a big H?
"prejudiced" is a weird word to use here
if your game literally never communicates with another computer, then no, it can't possibly be a problem
that's what I was trying to mean, thx
we have seen examples of "offline" games being influenced by cheaters
i mean, it could be a problem with like, people not liking the behavior, but it's not going to have an actual effect on the game
This
Like, it's fast and easy, but even during development (assuming you switch in production) you just pollute your registry data with unneeded crap
Do it correct, write a simple file in a temporary folder or something. It's not hard to write
tbf 99.99% of game players don't even know what a Windows Registry is
is there a simpler way to play a sound automatically when a particle system is triggered to play or do i have to get the audio source component and play it in script manually?
some people found out when KSP2 decided to vomit huge amounts of data into PlayerPrefs
whoops
What's causing the particle system to "trigger"?
if you're turning on the entire game object, then I suppose you could just put an audio source on the same object
script 
okay, but what are you actually doing?
public float speed = 50.5f;
private float defaultSpeed = speed;
What is wrong with this??
the PlayerPrefs was probably still one of the less broken things about KSP2. the whole game was a mess, especially on launch
you are not allowed to initialize one instance field with another instance field
fucking why????
why are you yelling
I'm typing
please, yell with caps
this is how the language is specified. I presume it's to prevent dependency cycles
its an evasion skill, the ship barrel rolls and the child particle system is just being called to play when it starts
its always active, but not set to looping or play on awake
why is the gameobject field not showing up in inspector?
i guess i should use SetActive and play on awake then?
make sure you have no compile errors. also configure your !IDE
If your IDE is not autocompleting code
or underlining errors, please configure it.
Select one:
•
Visual Studio (Installed via Unity Hub)
•
Visual Studio (Installed manually)
•
VS Code
•
JetBrains Rider
• :question: Other/None
Please configure your ide first
you have compile errors
also, very importantly! even if this did work, it would not do what you wanted
speed is a public field, so it's going to get serialized by Unity
this means it shows up in the inspector, and that you can set the value there
If you could initialize the defaultSpeed field with the speed field, this would happen before Unity applied the inspector values
so defaultSpeed would always be 50.5, even if you changed the number in the inspector
and yes: save defaultSpeed in the Awake method
Oh, I removed the message because it will overwrite the inspector's value which I overlooked
also ideally it would be defaultSpeed that is serialized then speed would be assigned the value of defaultSpeed in Awake. the naming implies that it is the source of truth for what is default
this isn't what they wanted?
idk maybe im tired but "defaultSpeed" sounds like what 50.5 is there lol
This would make more sense, yes
Question, I'm trying to set up a physical mic in a room of my game, and the best way I've found is by using a second audio listener, but the script is using the players audio listener and not the 2nd one for specifically the mic. What's the best way of doing this?
are you using GetComponent or setting it in the inspector
do not cross post
Operator '<' cannot be applied to operands of type 'Vector3' and 'int'
how do i fix this?
i let them know to post it here, tbf
don't try to compare if a Vector3 is less than an int. you probably want to only compare one axis
but probably vector3.magnitude
or this
there's a method that runs when the player's quitting the game instead of joining?
did you look at the docs?
idu what is a int?
there are beginner c# courses pinned in this channel. stop what you are doing and start by learning the basics.
im followinmg them rn
https://docs.unity3d.com/6000.0/Documentation/Manual/execution-order.html < OnApplicationQuit
no, you're learning how to use unity right now. learn the absolute basics of c# first
"what is an int" should not be a question you need to ask by the time you're coding in unity
the docs' interface is kinda confusing to me, I have difficult to find the stuff I want
wait ur so smart bc i kinda understand unity but i dont understand c#
most of the time it's the opposite to me lol
are there any unity c# courses tho?
just learn the basics of c# on its own then learn how to use it in unity
finding the right docs is literally typing 3 or 4 words correctly into google
but thats to boring for me
then you're going to fail.
!learn is a good source to learn, but if you dont understand c# then idk how well that teaches it
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
I always struggled with searching things on google lol. It just refuses to show me what I want
well im following the beginner course and they explain pretty well
then you are doing it wrong
but i just got a error and they dont tell u how to fix it
"what is a int"
you're missing the absolute basics
lol no. i'm blocking you now because you're just refusing to bother putting any effort into actually learning
alr
for example try
'Unity 2D Raycast' to find the docs on Raycast2D in Unity
Supposing that I dont know what raycast is, how would I search for what I want to make that uses it?
just google the error and there will be plenty of people explaining it
An int or an integer is a real number, it cannot do decimals and has a range of -2,147,483,648 to 2,147,483,647
I even tried to type here the functionality of raycast but i just cant put it into words
so -10 is a int right?
even the most basics of google searches could teach you this, I would highly recommend you learn
sure
you forget to mention int is actually an alias for System.Int32 which is a 32bit data variable
Operator '<' cannot be applied to operands of type 'Vector3' and 'int'
why does it say this
i just dont understand'
hint: you've been told why 😉
because that is not possible, use the magnitude of the vector or whatever box said above
this is also undoubtedly incorrect
how so?
well they just gave -10 as the int they are likely using. they are trying to compare if something is less than that. the magnitude cannot be less than 0
I've tried searching on google for a method that runs when the player quits the game and found OnApplicationQuit. Is that right?
ah, my brain was not braining
ok fair enough
i kinda fixed it
sometimes, did you read the full doc page?
yes and becuz of that I got some doubts and decided to double check asking here
ok, so what doubts?
If that is the condition you want to check, probably
i think I've understood it by reading it like 10x
That is a valid was of doing that, although I don't even know what you are using this for as that would check the Global X Position of the object is less than -10.
what are you trying to do?
yeah but for some reason it kinda shakes at -10
just make it stop at the border
So you read and understood the bit that says why OnApplicationQuit may not be what you want?
i think so but im gonna test it to make sure
good plan
Then you've got code somewhere that makes it kinda shake at -10
ok, it worked, nice
hey can one of you guys help me with this code
the rotation part just is not working
`using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerControler : MonoBehaviour
{
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
// basic controls
transform.Translate(Vector3.forward * Time.deltaTime * 20 * Input.GetAxis("Vertical"));
transform.Rotate(Vector3.up, Time.deltaTime * 20 * Input.GetAxis("Horizontal"));
// keeping upright
transform.rotation = Quaternion.identity;
transform.rotation *= Quaternion.Euler(0, transform.rotation.y, 0);
}
}`
this
transform.Rotate(Vector3.up, Time.deltaTime * 20 * Input.GetAxis("Horizontal"));
// keeping upright
transform.rotation = Quaternion.identity;
transform.rotation *= Quaternion.Euler(0, transform.rotation.y, 0);
is complete nonsense
damn i was told that was how to keep stuff upright
there is so much wrong with it I don't even know where to begin
If you've just set transform.rotation to the identity quaternion, which I believe is 0, 0, 0, 1, then why do you want to rotate it by 0 degrees on the next line?
even ignoring the fact he's using a quaternion.y as a euler.y
transform.rotation is a Quaternion. transform.rotation.y is NOT an euler angle rotation around the y axis. SO using it in Quaternion.Euler is invalid and nonsensical.
Yeah, there's that, but in this case it's always 0 so even if you thought it was euler it still is doing nothing
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
in order to allow wall climbing in my game, im writing a raycast that checks for a climbable wall in range, but i need it to be able to still detect the wall is 'in range' if a player is looking slightly to the left or right of the wall. if i just make the raycast longer, it means the wall can be climbed from further away, which i dont want. how should i do this?
Use a SphereCast
i didnt know this was a thing, thank you ill try to figure it out from here and come back if i need help
There is also BoxCast and CapsuleCast. But I think SphereCast makes the most sense for your use case.
is there any way to make it a half sphere? i dont want it casting in the other direction cause it would let you climb the wall while facing away
no idea what you mean by that
Why would you care about the other direction
you're not casting it in the other direction
you're casting it in the direction you're facing
sorry i misunderstood. i thought it cast outward in all directions from the point of origin
nope
does scriptually fading a 3d object's material cause any issues
yes i made up a word
Imagine casting a ball in a straight line through the scene.
issues like what?
i heard messing with materials at runtime can be problematic
Why would that be problematic? It's a perfectly normal thing to do.
The problematic thing to do is to mess with material assets.
As long as it's an instanced material, you're fine
If you're doing myRenderer.material, it is instanced
(The video looks off centered due to it showing my left eye, but it's not when using a headset)
I really need some advice, I'm getting increasingly frustrated trying to make a bullet system which isn't terrible (for a bullet hell game like Touhou). But it all ends up too unflexible, slow or boilerplate as hell. Like I'm currently trying an approach where I make scripts in C# (cause it's easier to get working in Unity, sure it requires recompilation but it could be acceptable), but even after many days of thinking and coding getting anything done is a horrible pain.
For example to test this system out I wanted to make a simple demo scene where the boss shoots out a circle of differently colored stars, each star deccelerates, stops, explodes into another circle of stars which move outwards and bounce off the screen edges once before eventually leaving the screen and despawning.
This is nothing special or even complicated for todays standard of bullet hell games, in a good engine I imagine that's like 30 lines of script at most, in my stupid boiletplate madness it's like 300 and still unfinished. How do people manage to get around these problems? I just don't get it.
Thanks for reading my ramblings and for any tips 🙏
This is a pastebin of the unfinished bullet behaviour... I think it becomes pretty clear what I'm talking about with "boiletplate": https://pastebin.com/YGxKadLi
is there a reason why you're using state machines for the bullets, just curious?
have you tried using separate prefabs or SOs for each bullet type?
Well in my research they were recommended, and logically it seemed like a great way to create complex behaviour in simple and manageable bits. But it just turned into way too much boiletplate which I'm not entirely sure how to improve or manage better.
Each bullet script has it's own SO, simply so I can assign which scripts to use in the inspector.
Also all bullets share the same prefab for better object pooling. Another small (but surprisngly good) optimization I use is batching, basically instead of having thousands of bullet prefabs with MonoBehaviours, I have a big list of BulletObject classes which are all updates together in a single monobehaviour, and the positions are simply saved to the game objects. This sounds like it shouldn't increase fps that much, but it's a big improvement.
no, that makes sense. i run most, if not, all of a GameObject's MonoBehaviours through one controller, and place groups of the same prefab in a list and run their code through an Update on the script that manages the list . . .
since this seems unflexible, slow, and/or boilerplatey, have you thought of a different approach?
i mentioned SOs because you can create them with different behaviour and plug the SOs into a variable on a Bullet script that reads or uses the data
i have the idea that each bullet would contain an SO of their desired behaviour and even spawn new bullets (per your example) that had different SOs for their behaviour . . .
!ask anyone here have experience with Vuforia?
!ask sounds like something you ought to ask the asset developer though (if it's an asset)
:thinking: Asking Questions
:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #🔎┃find-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.
-# For more posting guidelines, go to #854851968446365696
(the last would be most appropriate if the others are exhausted)
SOs mainly hold parameters though, no? How can you write custom code for them to run unless you implement Lua or something (which I tried but it got boiler platy too and was very slow)
you can put code in there too (:
explain pls
a ScriptableObject is just a way to create your own kinds of Unity objects
(with no extra implications, unlike with, say, MonoBehaviour)
public void What : ScriptableObject {
public void DestroyGame() {
Application.Quit();
}
}
e.g., a while back, i created a turret with a Reload, Track, and Seek MonoBehaviour. each have their own SO field for their behaviour
the Reload script can use various reloads like AutoReload SO, QuickReload SO, DelayReload SO, etc., to effect how it interacts when reloading
the Seek script can use a LOS (Line of Sight) SO, FOV (field of view) SO (uses an angle), or Radial SO (uses a radius) to easily change how the turret searches for a target . . .
They are sometimes used as "bags of data", sure, but there's no reason they have to be
nah, you can place code in SOs, you just have to run it manually . . .
(just like any other function written anywhere else!)
oh you mean like that
I tend to use [SerializeReference] instead of scriptable objects, because I don't like creating an entire asset instance for every unique configuration of something. But the idea is the same
well thats pretty much waht my terrible system does, it just also allows each SO to create as many instances of the class as needed without having to instantiate SOs (as its kind of slow, and due to the specific nature of each one you cant really object pool super well)
(The goal is to be able to serialize a parent type, and then plug in any derived type you want)
well since I'm creating scripts I couldn't think of any better way. Is there a good way to make scripting in the inspector?
Ok question I saw a lot of tutorials just having all the items you can pick up as inactive game objects within the player then when you take it out it makes it active but that sounds kinda bad
Whats the sorta half decent solution like cloning everything?
you don't or shouldn't instantiate SOs, just pull/use their data . . .
"creating scripts" is a bit vague here
well, you might want to store some state -- it'll have to live somewhere
well each bullet and pattern have scripts to generate a set of bullets and define the behaviour of such bullets
it uses scripting cause trying to parametrize this quickly turns into a nightmare as behaviours can get very specific and relatively complex
Actually I guess the objects would have to exist so making inactive objects sounds like it would be the solution nvm then
if so, you're better off instantiating a C# object that references the SO . . .
if you look at the top 7 lines in the pastebin of nightmares you can see I kinda do it, I just use SO to act as an asset file for the script
(should have mentioned, BulletScript is a derivative of SO)
how do you know how to create or get that C# object, though?
if all you have is a list of BehaviorSOs, you don't know exactly what types of obejcts you're working with
🧵
the behaviours are a field on the object. they just read and/or pass data to it and run its method(s) . . .
suppose I have BehaviorSO with two children, FooSO and BarSO. Both of these types need to track some kind of state (maybe how long until the bullet splits)
if all I know is that I have a field that holds a BehaviorSO, I don't know whether I actually have a FooSO or a BarSO
so I can't do anything that'd be specific to one of those two types
Absolute beginner here and reached my first hurdle....All I want to do is rotate an object by 1 every frame. Just to see that I know what i'm doing.
I've created an empty game object, and applied to it a regular rigidbody, probably not necessary, but then I went and read the documentation on how to rotate using the Transform.rotate function.
I then, try adding a new component to my empty object, a script named "rotate".
All I add to the script under the update section is "Transform.rotate(0,1,0);"
I encountered an error, and think I may have possibly just installed something incorrectly.
Here's the script
public class Rotate : MonoBehaviour
{
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
Transform.rotate(0,1,0);
}
}
And attached is the error.
What on earth have I missed?
Is your code editor not highlighting this error?
It is not
If your IDE is not autocompleting code
or underlining errors, please configure it.
Select one:
•
Visual Studio (Installed via Unity Hub)
•
Visual Studio (Installed manually)
•
VS Code
•
JetBrains Rider
• :question: Other/None
It'll help you avoid making the typo that caused the error, too (:
did you check if Transform has a rotate method?
configuring your IDE would easily help solve this issue as well . . .
if this says "Miscellaneous Files", that means that Visual Studio doesn't understand that you have a project
What is .rotate
damn
well that makes sense
Ok heres another question
So when I did roblox I would like modualize everything like if I had a pick up script I'd make a single script with some modules that would just single handely handle everything
But so far in unity I feel like most things revolve around making one script then attaching it to like every pickupable am I missing something or.. is this just how things work?
Like can I just have one script not attached to anything handle every single pickupable object or am I really just suppose to have a script per item
transform.Rotate(0,1,0);
MonoBehaviours do not exist unless they're on an object
So what I'm doing is the correct way?
🤦♂️
You should make a script that generically handles something and then put that script on everything that it should
It just feels so wrong cuz its nothing how roblox is so its flustering me
Components add features to objects
and then modify the public fields of it
ok so I am doing it right
I'm making one generalize script and just slapping it onto objects that need it
This fixed it. I feel very stupid. Thank you 🤦♂️
No problem 😄
Honestly it seems a bit weird for functionality to be on something completely different than the object that's doing it. You can look at an object and not get the full picture of what it's doing
that seems like a very quick way to making a frustrating developer experience
I'm trying to imagine how this would work
Well lua's power is dictionary tables so it wasn't that bad
How would the game know what is actually a pickup-able item?
surely you need to attach the "pickup" feature to the item
I would loop through every item thats a item in a single script and create a event
sounds weird
But how do you tell it which objects to loop through?
You'll have to specify it somewhere
loop through every object with a tag item
So, if you want to see what an item does, you'd need to go somewhere else and just check the code for what that tag does?
Seems incredibly annoying
Compared to just "Click on object -> See pickup script"
https://docs.unity3d.com/6000.0/Documentation/Manual/GameObjects.html
This explains the design philosophy of Unity's GameObjects.
so it look something like
for i, v in CollectionService.GetTagged("Item") do
v.Prompt.Triggered:Connect(function()
--Pickup function
end)
end```
yeah in roblox its considered bad practice to put a script into every object that would need it lol
that's so alien to me
Yeah that seems miserable
I guess that you know that you need to find the "item system" when you see the "Item" tag
which is very ECS-like
its not that bad once you get use to it its how I started I found it enjoyable
Like handling guns in my roblox game is a single script and thats it
Imagine if you wanted to change something, you'd need to either remember where you put it or Ctrl+Shift+F for "Item" to find it, as opposed to just right click edit on the object you're currently looking at
thats why unities way is so alien to me
nah theres services
hold on
most scripts just look like this
and you store them in these places
but yeah you would have to find your script
Roblox provides many more "things" than Unity does, too
Unreal gives you a bit more to start with but most engines will be like this (apart from source engine which is basically HL2)
I think roblox is pretty good learning if your getting into networking since roblox doesn't do everything for you + letting roblox do everything for you will end badly
I'm pretty good at networking cuz of roblox
mostly because roblox gives you so little recourses you kinda gotta optimize networking in every way you can lol
Unreal has a lot of opinions about how games work too
sorry, what?
i just need to find someone who does or does not understand how to use Vuforia
cause i swear i've tried literally everything to make this stupid API work
lmao
so i'm pretty sure i don't understand how to use it, but no tutorial online uses SIMULATOR mode
ok i'm going back to coding lol
I refuse to acknowledge lua as a programming language because their arrays start at 1
your computer
thats how numbers work
Literally everyone who uses computers ever since the dawn of math
welp, you're coding, so you gotta get used to it
arrays only start at 1 sometimes in VB-land
i don't think C# allows that at all
nah roblox would probably be the craziest experience to anyone on unity like how unity is the craziest thing ever to me rn
If it's an asset you need help with, you should see if the developer has a support server for it, you're unlikely to find people here who know that specific asset
ah, i see
why do arrays start from 0? Pointer maths yay!!
I had to do some coding in lua and I literally wrote helper methods to access arrays with 0 indexing because that's the only way it makes sense
sorry, afk, but there can be a few ways . . .
Method 1:
pass the bullet stats to the method called on the SO. it grabs/uses the necessary stats when running the code
Method 2:
the script or C# object housing the SO field has the stat to track for when to split and passes that when calling the SO method
surely there is someone here who knows how to use it
Like, which of these looks more natural:
for (int i=0; i < myList.Length; i++){
myList[i].xPos = i * offset;
}
or
for (int i=1; i < myList.Length-1; i++){
myList[i].xPos = (i-1) * offset;
}
1-indexing is an abomination and should be destroyed
the upper 1 looks human readable
who would even make arrays start at 1
complaining about 0-based indexing is like complaining about having to count in base-2
Yeah because 0-indexing actually does make sense. 1-indexing "because it's natural" is a lie, it's much more natural to use 0-indexing. So much math just works with 0-indexing
idk in my brain it makes sense that the index and length are the same thing
plus I don't gotta do length-1
you literally are taught in school
0, 1, 2, 3, 4, 5
it's natural because you've done it for years, tbh
0 being a number
yes I did say length and index being the same not that 0 isn't real lol
if you think in natural numbers
if you think in whole numbers, it's 1, 2, 3, 4, 5
which is probably where the justification comes from
oh god we're on Natural Numbers discourse
I think some people say it's natural because almost all of your life you're taught to count from 1. Then suddenly in programming it's from 0 because that's how a computer counts
💥
I think in real numbers
ok heres the real like answer to this discussion
your biased is probably based on the language you use the most lmao
0 is included
true
I used lua so I like arrays starting at 1 cuz I coded in lua for 3 years
er, it's the other way round
but its ok you can make fun of me for letting a corporation take 70% of my games income lmao
roblox cuts are insane
whole numbers include 0, natural don't, real numbers include all decimal numbers (irrational and rational)
we should start arrays in decimal numbers...
indexes like 0.5, 1.3, 3.1
true
technically quantum indexing works like that (if you really boil it down)
can't forget surreal numbers
Whether they do or not, you'd have to post all of the necessary data before most would commit. This is the Unity beginner coding channel though.. so don't expect much help with fixing assets made by others. You'd probably want to contact support from the developers of that asset. Else if it isn't off topic, you'd just post the actual problem you're having.
https://dontasktoask.com/.
On the bright side though I did get a sucessful roblox game so my hope is I can reuse my community for a unity game I make to give it a better chance
Arrays should be indexed by vibe.
myArray[springtime] = 4
what game is it
Its really ass and I really don't wanna say it LMAO
I got like 5k group members and 1.3k discord users tho
it's bad yet successful, interesting
do be how roblox games work
I'm still curious, you can DM me it if you want
It was a portfolio piece then algo picked it up and it got popular
its not insanely popular I average like 300 ccu at my prime lol
some good games average less :C
Real numbers includes every number that does exist, so 0 being one of them, but technically I do not want to include pi so rational numbers would be better
I’m new
I know I'm super happy about it I don't wanna sound ungrateful lol I make like 1k usdish a month from it
Just my ideas go beyond the capabilities of roblox so I'm trying out unity
roblox pays you?
yes 30% of my earnings
barely unless it's CRAZY popular
I mean i'm happy with 1k usd a month but yeah its barely anything compared to there cut
indexing at 0 and 1 both make sense for different contexts
in computing 0 tends to make more sense to not have a lot of off-by-one issues
for example the arithmetic/geometric sequence formulas are a_n = a_0 + nd/a_0r^n instead of a_n = a_1 + (n-1)d/a_1r^(n-1)
alrighty then
does anyone with experience with Vuforia understand how to use it's SIMULATOR mode? I cannot for the life of me get the unity project to render the ImageTarget nor any of it's children in Play mode (neither in the AR camera nor the Scene view) but I can clearly see them in Edit mode:
(left is in Edit mode, right is Play mode)
it turns off their Mesh Renderer when I hit play mode but i don't want it to do that. It feels weird that the API would expect the user to manually program the ImageTarget's MeshRenderer to forcefully stay visible, so i wanna double check that i'm not being stoopid
IM NEW
I think roblox your more likely to get players than if you made a unity game cuz you have there egosystem and algorithum but also they do take 70% of your revenue so theres a trade off
hi new I'm niko
a lot less people on roblox than the general gaming landscape, but both got their own costs (literally)
True but having a algorithm feeding you to 100's of million of people helps a lot lol
Well it also depends if you advertised your unity game (correctly and if at all) and if people like it based off of that advertisement, best part about unity is you can build your game and post it on itch.io or some other website to build your reputation which will help with getting players in the future.
that is true, I forgot how much a really good looking thumbnail wins you over with the algorithm
yeah thats what i'm saying I don't have to do the leg work or costs of advertising
the algorithum does it for me
thats the main difference
not saying its worth losing 70% of your income but generally I'd say getting players on roblox is probably easier than a steam game
especially if your new
I agree
I mean fuck dude standing in like simulator have like 6k ccu rn
Not sure about that.. Rust, Pokemon Go, Rim World and whatnot were pretty popular and are games made by Unity. The market is probably a lot different though. Roblox being isolated and all would have you not having to worry about competing with triple A titles, if anything.
ok rust and pokemon go have triple A devs
for something Pokemon Go they had huge advertising and backing from a triple A company
for some other games, like Liar's Bar (although I'm not 100% sure), their success is from word of mouth and/or YouTubers playing it
look at battlebit, that got insanely popular even with a single dev, so you can do it
You just have to make something good enough that people don't even notice that it's in Unity, like Hollow Knight or Cuphead
ah yeah people will turn if they see the unity logo for some reason
roblox has like 88 million users a day
it seems really hard to get your fresh new game out there on other platforms in general. Roblox isn't a guarantee either, but seems a bit cheaper than off the platform.
well probably because they see all of the bad games made with unity so thats probably why
theres like a big part of the market there your forgetting about the markets steam can't get into
Mobile
roblox is mobile console and pc
true, Battlebit had the "Made with Unity" logo and people kept playing
That's because it was actually good and people were looking at it for a while so it kind of slid past that
Oh yeah for sure
It's always been about marketing and hype. I've seen folks begging others play their games some half-a-decade-ago on Reddit before 😅
Success is mostly a lottery, but it's a lottery you can only get a ticket for if you make a game worth playing in the first place
Thats what I tell everyone game deving is a shit load of luck
theres a lot of ways to sway it in your favor but
my game got popular cuz some random ass other small game said this game is cool then it got me 20 ccu then the algo picked me up and brought me to 300
now i'm at 50 but
My game survived like 6 months so I'm happy for a first game
Get a streamer to notice it
nah its near the end of its life spand i'm fine with that it wasn't suppose to be a popular game anyways
That’s how I got an old sc2 custom map to explode. TotalBiscuit found me
That falls under the aforementioned "luck"
I mean if it does get a 2nd resurgence thats cool but
Your hidden gem will be discovered after several years and only by means of some other game cloning it's fundamentals or that was "inspired" by it..
this is roblox in a nut shell
amongus.png
Yeah, but making a decent quality game that appeals to a lot of people for a solo project will make that luck factor less lucky
yes you can sway it in your favor but theres still a lot of luck involved
Sure
theres plenty of insanely fun games i've found that people just don't seem to notice
you can make it appeal to a lot of people, but you still gotta get that game out there somehow
Thing is there’s a lot of bland games being pushed out there that might look ok but don’t quite grip anyone effective to promoting you
which is why a lot of new game devs quit
they make a game it doesn't get players then quit
kinda gotta keep on that grind
also having roblox kinda like punch you over and over sucks too but YOU KNOWWWW gotta make sacrifices lmao
What’s this about Roblox ?
the entire conversation
yes
If anything else do it cuz you enjoy making games not for the glory
If something pops off then be grateful
I need money to make cooler games
shit ain't free D:
but yeah i'm happy my game is popular
Or you just got to get really good at everything
And don’t aim higher than your manpower allows
I mean.. you're making the game because you enjoy doing so as a hobby or dream and not because you're wanting to make millions, riight!??
isn't that's what niko is doing?
I mean I'd like to make money so I can do this as a job one day so I can make things I like and other people like
It doesnt hurt to have some adequacy in all the components. If nothing else showing off a solid demo that showcases your broad skillset will attract collaborators
but not really the ultimate goal no
trust me if I wanted money idk if game deving would be my first go too 
not with coding at least
if you wanted money, you would've made a brainrot super popular simulator game on roblox
lol the industry is just over saturated it’s not worth it for like 99% of people
Get a job in boring dev. Web dev pays great and that could seed your project vision
It’s also easy as shit. Lot of free time cuz the work is too easy
Hey, is there a way to translate this shader to a shader graph?
I followed a tutorial on how to do a Stencil Shader for a Portal which i want to show on my Apple vision Pro, but the AVP does not support shader (the coded ones) so i need to translate this into a graph. Has anyoen done that before?
Shader "Custom/StarfieldStencilShader"
{
Properties
{
[IntRange] _StencilID ("Stencil ID", Range(0, 255)) = 1
}
SubShader
{
Tags {
"RenderType"="Opaque"
"Queue" = "Geometry"
"RenderPipeline" = "UniversalPipeline"
}
Pass {
Blend Zero One
ZWrite Off
Stencil
{
ref [_StencilID]
Comp Always
Pass Replace
Fail Keep
}
}
}
}
yes I happen to be in a place where I have a small community so games released by me have a starter following so I have a slightly easier time making a 2nd game than most people
You’re on your way then
Mostly banking on the fact at least 5% of my discord will look into my game which would be a W lmao
Just don’t lapse and you’ll keep building more followers
If you don't get a response here, you ought to try #archived-shaders
Oh did not see the separate channel thanks xD
swapping game engines is a big risk for me anyways so but I think in the long run I'll enjoy this more
I’m just working out a demo for now, maybe try and get a small team going
But not being able to pay for time is a setback.
Unless you need something that engine can do better idk why bother. Unity can do a more than enough for small time devs
I'm coming from roblox to unity lol
and yes unity can do a ton more than roblox
and also not take 70% of my income
win win
Roblox idk anything about but it sounds like similar to sc2’s custom maps system
wat
what is SC2
Is anyone here older than 10? 
I don't know every game based off of their abbreviation instantly
Yeah like I said idk anything about Roblox other than it has some creation engine
the only platform that I would say is similar to roblox is what Fortnite is doing rn
which is why roblox gets away with everything cuz theres zero competition in how they do games other than fortnite recently
If it’s compartmentalized its own engine and exposed creation tools to the public then it’s just like sc2 mapping
There was some interesting games you could make with that editor.
I mean.. thats like saying unity is like sc2 mapping lol
Unity’s a full engine
so is roblox except for the fact I can't release games off of there platform
idk I think thats a really weird comparision

Sc2 custom maps worked the same way. You used the sc2 engine to make games that were only playable inside of itself
ohhhhhhhhhhhh okay
They're both closed systems where you publish games only playable within the game's ecosystem, rather than any sort of standalone
yeah ig
The only difference is Starcraft doesn't let you charge for games built in it
It wasn’t limited to maps for the standard sc2 game although you could do that too
Yeah, that is different
People have made entirely different genres within the SC2 engine. There are card games, roguelikes, RPGs, all sorts of things
Halo Infinite???
You have to jump through hoops to do so, but the same for making anything other than a platformer in Roblox
yeah roblox is trying to pivit into charging usd for games which is kinda weird
Idk if anyone remembered Bloodline champions but I made a custom map for it not dissimilar
isn't their cut on a game that costs robux to pay like 90%??
idk about that I'd say making a obby is still hard like making a td is lol roblox isn't that barebones
Battle net was shit and the fact one potato pc in the lobby brought everyone down
you get 30% of profits
okay, I guess they've changed that since the last time I tinkered with that system
Holy exploitation
