#๐ปโcode-beginner
1 messages ยท Page 624 of 1
From native code I somehow have to supply the correct MethodInfo when calling a generic and I have never understood how to generate that ๐
Native code
grandpa_simpson_hat_rack.gif
They say the exponent in decimal is a "decimal number". I don't understand how they store that or how they do math with it on a binary computer
Anyways guess I'm doing a type lookup then.
Huh
they're using it from native code for whatever reason
Can't post reaction gifs here so just plug the name into gif search. I ain't touching native code with a ten-foot-pole
ieee 754 binary floats store a sign s, mantissa m, and exponent e to represent a value of s*1.m*2^e
decimal uses m * 10^e instead
Alright but your CPU has operations defined for doing math with ieee 754 floats how do they do math for this
I'm programming a mod that is supposed to work for all Unity games to use Steam Audio with reflection using collision data by overriding AudioSource ๐
I could use C# for this, but then it wouldn't work with games compiled for il2cpp.
Maybe there is a better way to do this, but my current way is to just do everything on the native side of things.
congrats, your questions are off topic! modding discussions are not permitted here
Just wanted to explain. No further discussion.
At least it's not fuckin gorilla tag
manually
Lol...
So if they're doing the math in software doesn't that make decimal like thousands of times slower than regular floating point math?
the reason they are not permitted here is because you have to do things in non-standard ways, like calling FindObjectByType in native code. it isn't just about mentioning modding that is not permitted.
#1201856945791705108 message
eh, not really. a few extra machine cycles.
they still are simple operations
You have linked a channel inaccessible to me.
About software maths, there are CPUs that can only do software floating point and there definitely is a pretty significant difference in performance...
i don't see what that second point has anything to do with anything i have said. that is a separate discussion which i have not participated in.
#1161868835423526933 should be accessible to everyone
as for what i linked, it was a mod explaining why modding discussions are not permitted in this server because "The types of conversations modders have are often non-standard, often it's discovered someone's modding because they cannot do simple debugging or necessary basics, because they usually have access to an extremely limited subset of the engine."
it's not inaccessible; it's just not loaded. try clicking it
The mods response on modding discussion from the linked thread:
I was referring to the other ongoing topic, I just dislike putting things in separate messages to reduce pings in DMs. Just a habit.
Ohhhh yeah now I can see it, thanks!
(tip: you can reply without pinging, shift click the reply button or disable mention on the "replying to" banner)
At this point it's mostly in the case of "You aren't going to find much help for calling these functions from native code since it's not something most people have to do so we don't really have experience with it".
Oh yeah I know, but I used to send lots of separate messages in DMs that generate pings regardless, and people got annoyed so I developed the habit to combine multiple messages in one ๐
You might have to do some documentation binging on your own
Thank you, anyways
Hello, I have a problem with a raycast and maybe somehere could help me fix it?
Basically I have a script that shots the ray and returns hit game object, but the moment there is no object (player looks into sky and shots ray) it returns null and I get a bug report that no object is set to variable. Any ideas how I can fix it/bypass it
about this; floating-point is slow in general (compared to fixed point), yes, but decimal floating point would likely not be much slower than ieee 754 hardware floating-point
they're similar complexities
Or maybe a tutorial that could help me fix it
You should check if your raycast hits anything before attempting to do any code with it
Usually by wrapping it in an if
It is in if
Show !code, and the error you're getting
๐ 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.
Are there any metrics on how many cycles modern CPUs need to do floating point maths? Or does that depend on the values that are being worked with?
I see some charts pop up every now and then
I have implemented fixed point maths (because I have no idea about floating point) in hardware before, it did work in a single cycle but ate sooooo damn much space ๐ no wonder CPUs nowadays have so many transistors.
I have developed a certain distrust in Google for such things, ran into AI generated shit way too often by now ๐ฆ
You can omit AI crap
Please tell me, how? ๐ฎ
forgot the link params but you can easily just click here
I remember attempting to research something and all Google gave me was the same AI generated article in like 20 languages lol
Oh wow... why's that not the default?
Funny how "web" isn't the default for a search engine anymore
Easier way: include swearing in your search.
"Picture of an owl" -> AI crap
"Picture of a FUCKING owl" -> Only human made
cause AI crap ๐ ๐ค
or filter for stuff before 2020 or smth
That worked for a while but then articles claiming to be from before 2020 popped up that were definitely AI generated lol
all that stuff is still all in the LLMs no ?
too bad google is currently planning on adding ai bullshit to this too. i recently got one of their opinion rewards surveys about what kind of AI bullshit i wouldn't mind seeing in that view
shiit.. someone needs to make a google search that omits that crap..
we need AI to remove AI
There are models that detect AI generated text, but that's probably way to slow to run for each search result
its somewhat fascinating how 'everyone' invests in AI that nobody actually wants.
There's no money in not pushing for techbro VC buzzwords
Yeah..
Venture capital is a sickness
and those are all mostly crap
Oh well
i feel like the world is more and more made for those 0.5% of people who are suckers for that kind of exploitative marketing BS and the rest of the world has to run along.
I have heard they're quite good at identifying autism. Likely better at that than identifying AI
We need something like an adblocker, but for AI. A list of websites that contain AI shit and that are then automatically blocked.
by now that would basically mean turning off your PC
True ๐คฆโโ๏ธ
also not all AI is bad, i like my intellisense
๐ i dont seem to have this option, ive been searching every so often and the latest way to remove it was google labs. When i went there, the site isnt even set up yet!
gentle reminder, this is kinda way off topic
to call it "Intelligence" is being generous
Sure there are awesome uses, but talking about AI shit specifically.
We somehow drifted from floating point to AI
not really, its actually accurate, if you read it in the "CIA" sense of intelligence
What off-topic channels are here?
none
There aren't any
well, AI is a network of floats
Oh well lol
imagine replacing discord mods with some AI
Image unity documentation one day just says Unity Muse as default search
offtopic police bot AI
What about #763495187787677691?
I don't have access to this link
... nvm for some reason Discord suggested a channel from another server
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if(Physics.Raycast(ray, out hit, 30f, enemy));
{
var selection = hit.transform;
if (selection.CompareTag(enemyTag))
{
selection.gameObject.layer = 6;
}
}
!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.
Edited
Yep, just saw right as I sent
Wrong key
So, what's the error you're getting?
It returns null when I use it and ray doesn't hit anything
"Object reference not set to an instance of an object"
What line
second if
Ah, because you don't actually have anything in your if statement
Take a look at the first if statement. Compare it to your second.
Notably, the ends of the lines
when we open a if statement block, you probably don't want to end it before doing anything inside of it lol
; means "end this statement"
Isn't the second one nested in the first if?
You close the first if before doing anything else
The first if contains nothing
An if statement runs until it finds either a { or a ;, whichever comes first
not if you end it first with ; like digi mentioned
Oh I see it now
It does. If it gets to the { before it ends
But yours does not
it runs the statement that follows the if
{ ... } is a block statement that holds other statements
; is an empty statement that does nothing
traitor
so if you have if (...) doThing();, it runs only doThing()
if you have if (...) { ... }, it runs the entire block statement
if you have if (...);, it runs the empty statement which does nothing
if you have if (...); {} like here, the if runs the empty statement, then the block statement runs detached from the if
are you trying to search through code? if not, you're in the wrong place
you're just asking about using the editor, that would probably just go in #๐ปโunity-talk
Yeah ik I just didn't saw this one ; that I put here accidentally
Unity talk got you ! thanks
Thank you
how long does it take to get good enough to do this? : https://www.youtube.com/watch?v=4O0_-1NaWnY
See the code on GitHub: https://github.com/jdah/minecraft-weekend
NOTES:
- The water and lava textures are from the now defunct (?) Painterly Pack, my animation skills weren't up to the challenge.
- The depth sorting algorithm depicted is mergesort but it's mislabled as quicksort (oops!). I was initially using mergesort but ended up using quick...
very
also not really a relevant question to learning
you shouldn't set "make thing fast" as a goal
just "make thing" is already a significant goal
Specially without a game engine, though most game engines don't handle voxel graphics very well.
imposing a time limit on yourself when you're still a beginner will only stress you out and make you dislike the experience
Time limits are great if you know you can do something but want a bit of an extra challenge, as Chris pointed out it's bad if you just want to learn.
years
i want to get good at coding
If you commit yourself you will get good
english isnt language
Coding has many facettes, you can't be just "good at coding", there are so many subcategories.
don't worry about "getting good"
that's a moving goal
set a solid goal for yourself, like making a project
You'll never feel like you're really good at coding because coding is just such a huge space there's always more to explore.
!code
public void PlayRussianRoulette()
{
int chamber = Random.Range(1, 7);
Debug.Log("Spinning the chamber...");
if (chamber == 1)
{
Debug.LogError("๐ Bang! Quitting Unity Editor...");
/////////EditorApplication.Exit(0); // so we dont get banned :))
}
else
{
Debug.Log("๐
Click! You survived this time.");
}
}
๐ 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.
also this is literally just the rendering part, it doesnt including the complications of a game loop / ai and other such complexities, not saying mesh generating isnt complex but its not the "whole game"
kinda clickbait title
do you have a question
v.good
wanted to test if it can run functions
The !code command is just to show that help page lol
๐ 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.
if it could... do you think dyno would be running a whole instance of unity editor
I am learning react native. I wont work for coding but will enjoy making things for myself and community
It doesn't run anything it just brings up a bot showing how to post code
Imagine you could just make that bot execute arbitrary code lol
there are bots that can
there are repl bots, but dyno is not one of them
but you wouldn't be able to run unity library code in them
There'd be way too many bitcoin miners in that bot by now if you could just run code without restrictions
("i run code" that uses piston)
i don't think most public use repls have internet access
You'd hope so
the contained ones anyways. something like replit obviously does
Heck people have abused GitHubs actions system to run miners before
I've seen bots made by inexperienced people that had a "calc" command that literally just pushed everything into eval() ๐
I wonder if you can do something interesting with using Unity as a plugin..
idk how much Unity API Code it can run as plugin mode
https://docs.unity3d.com/Manual/UnityasaLibrary.html
Literally everything, if you know the APIs. It would certainly be possible.
hi not sure if this'd go here ot not since it's about the editor not coding, but for some reason my unity editor keeps making a really subtle static noise, and i know it's unity as when i close unity it stops, and when i mute the unity application in sound mixer it also stops. the sound is coming through my speakers so it's not a hardware thing, if it was i don't think muting the unity app would fix it. this happens in editor and play mode, regardless.
- also, it seems to randomly stop and start so it's not consistent
maybe..I havent looked into it fully to know. You can probably get it to run some basic stuff
I looked into once to implement unity as a 3D viewer
Well there are PDBs available, so you could call into pretty much anything inside Unity manually, even private functions and stuff. Not sure if you'd be allowed to distribute an application that does that, but it's certainly possible.
whats PDBs idk
*for windows. Linux elf binaries do not require an external debug symbol file
It's the closest you get to Unity source code without paying extra.
And with Unity source code you could do literally anything you want anyways. But that expeeeeeensive. I think you even have to pay another extra to be allowed to distribute modified versions.
right i just started unity and its telling me that i cant enter play mode because there are compiler errors
how do i fix this because ive litterally just installed it
fix your compile errors
check the console to see the compile errors, ten fix to to enter play mde . . .
It is entirely possible your template contains compile errors. Possibly due to out of date packages. Check the console and update the ones that are having issues
you sorta can without, you can do tons of things with native plugins
I have no idea about the way native things are supposed to be done tbh from a game developer perspective.
But I would assume it's well documented.
can anyone find the bad logic here? Im generating rooms for a tiny dungeon crawler and the grass variances works great but the edge generation does not. what did I mess up? see screenshot for problem, it only ever generates grass grass then 5 edge then remainder grass for what should be the entire lowest x position as edges
A tool for sharing your source code with the world!
!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.
its too long
so did you read the part about ๐ Large Code Blocks
A tool for sharing your source code with the world!
What is safeRoomWidth set to in the inspector?
i was wrong, its 5 width 5 height
beautiful, thank you for the assistance. new, stranger problem. why do you think this lower left corner is always generating without edge, even with the inspector fixed?
ignore the random grass tile off to the right, that will eventually be exit hall logic
What is safeRoomPosition.x set to
x = 3 y =3
youre the best, thank you
any advice on how to offset a second noise generation so the flower patterns dont match so closely with the grass?
I'm guessing you didn't write this code?
no, im going back and forth with GPT on the designs. ive been learning compute shaders and in order to not go insane im repurposing my old 2D assets I made into something that runs
If you use chatgpt, at least try to understand the code that it feeds you
Not to sound harsh
But if you read the variable names they are pretty self explanatory
i understand it at an execute level logic, so, this feeds into this, this 'should' do this, but i get lost in understanding if a function is overwriting another or if im simply implementing it poorly such as above with not catching the inspector hooks
its a learning process
i'll try to explain this the best way possible, but i'm bad at explaining so sorry in advance. I have two scripts, one that instantiates a new object and one that stores a bank of values. when instantiating, the code takes one of the values from the bank script. what i need is to be able to have the instantiating script choose a random number out of say 20, then pull that specific string and use it in the instantiation. that way, it would be a random value each time it is instantiated.
here is the current code:
public void CopyTask(string newTaskData, string taskText)
{
//do not fix or TOUCH AT ALL if this is touched everything breaks!!!
//do not optomise in fear of project collapse
GameObject newButton = Instantiate(buttonPrefab, buttonParent.transform);//creates new button
newButton.gameObject.GetComponent<buttonStringKeeper>().buttonString = newTaskData;
buttonStringKeeper data = newButton.GetComponent<buttonStringKeeper>(); //this and ^^^ could be combined but that could break so redundancy = better
newButton.transform.GetComponentInChildren<TextMeshProUGUI>().text = taskText;//gets text component and edits it
Button buttonComponent = newButton.GetComponent<Button>();//gets the component
if (data != null)
{
// Use lambda to capture the message dynamically
buttonComponent.onClick.AddListener(() => OpenOverlay1FromInspector(data.buttonString, newButton.gameObject)); //adds onClick with the string
}
else
{
Debug.LogError("ButtonData component not found on the button!");
}
//need to add listener with the button script buttonStringKeeper
//need to pull button string keeper string and use it when opening
}
this is the instantiating script^^^
public class TaskStringBank : MonoBehaviour
{
//STORE VARIABLES
//call copy script with value from here
public GameObject ModalController;
public void callCopyScript()
{
string taskText = "Walk to somewhere you would have driven - 1000";
string taskData = "Walking a short distance such as 3 miles instead of driving can help reduce emissions by between 500-1000kg of CO2 per year!|1000|google.com";
ModalController.gameObject.GetComponent<ModalWindowController>().CopyTask(taskData, taskText);
}
}
and this^^^ is the bank script. it is currently set up with one value. it is also the script with the function to call the instantiation. I cannot figure out the best way to do this, so any help would be great
So you just want to have a bank of taskTexts and taskDatas that you pick from randomly?
yes, it needs to pick the cooresponsing two taskText's and TaskData's with each time it is called though. it probably has a simple solution but i'm not very good at this sorry
Step 1: Create a class that contains both the text and data together, so that you can keep them together.
Step 2: Change your CopyTask function to take that one object instead of two strings
Step 3: Create a list of that class that holds all available options
Step 4: Random.Range from 0 to the length of the list, then get that index from the list to grab a random selection
Step 5: Pass that value to CopyTask
the reason i have them seperate is that the taskText is used to edit the TMPro child, where the taskData is used when the addlistener is called
And there's no reason you can't do that with a wrapper class
You would make a class with two string fields
and use that instead of passing the two strings directly
I have a script that holds a reference to all the entities in play. GameManager is gonna need a reference to it to check if the game is finished or not (check for remaining non-dead entities). I want to call this method whenever one entity dies from the entity script, and I am doubting what would be the proper way to do it, to send a reference of the list from the entity that dies as an argument (they all have a reference to list already) or to make a new reference to the list on the GameManager itself.
I don't think it would make much of a difference in this case, but I am kinda curious what would be preferred
Whenever something dies, invoke an event that other things can subscribe to. Have whatever object has the list of enemies subscribe to that event, remove that enemy from the list, and do whatever it must when the list is empty.
https://gamedevbeginner.com/events-and-delegates-in-unity/
thanks this is gonna take a bit of googling to figure out how to use them but the knowing the names and such really helps
I am not using events at all. I checked them a bunch of times and I never find the time to use them
Well, now you have the perfect time to use them
Like most of times I can do with a simple standalone reference
Just that it would take me to refactor everything to work with events???
There's kind of a few ways you could put that together but like if you went way further into this than you are currently you would probably have it in the gamemanager or some comparable manager because you'd want to handle stuff like this for more than just enemies. in the past i've done something like this but it depends on a couple things
GameManager
List<Enemy> allActiveEnemies
UnityEvent OnEnemyRegistered
UnityEvent OnEnemyUnregistered
private void Awake()
OnEnemyRegistered.AddListener(CheckLevelStatus)
OnEnemyUnregistered.AddListener(CheckLevelStatus)
public void RegisterEnemy(Enemy newEnemy)
allActiveEnemies.Add(enemy)
OnEnemyRegistered()
public void UnregisterEnemy(Enemy enemy)
allActiveEnemies.Remove(enemy)
OnEnemyUnregistered()
private void CheckLevelStatus()
Enemy
Awake()
GameManager.RegisterEnemy(this)
Death()
GameManager.UnregisterEnemy(this)
(this aligns mostly with what digiholic suggested)
Events are not an all or nothing system
It would be extremely weird and confusing if I use an event just for when something dies and not for anything else
nah
But then you'd know how to use them and could start using them more when it makes sense to
just do it tbh
this is using something i made so looks a little different but for example a tower defense game i made back in december had these kinda events in my gamemanager
public static ExtendedEvent OnGameManagerEnable = new ExtendedEvent();
public static ExtendedEvent OnGameManagerAwake = new ExtendedEvent();
public static ExtendedEvent OnGameManagerStart = new ExtendedEvent();
public static ExtendedEvent OnGameStart = new ExtendedEvent();
public static ExtendedEvent<bool> OnGameEnd = new ExtendedEvent<bool>();
public static ExtendedEvent<EnemyBehaviour> OnEnemySpawned = new ExtendedEvent<EnemyBehaviour>();
public static ExtendedEvent OnNewWave = new ExtendedEvent<EnemyBehaviour>();
public static ExtendedEvent OnWaveFinished = new ExtendedEvent();
public static ExtendedEvent OnIntermissionStart = new ExtendedEvent();
public static ExtendedEvent<EnemyBehaviour> OnEnemyKilled = new ExtendedEvent<EnemyBehaviour>();
public static ExtendedEvent<IHighlightable> OnHighlightChanged = new ExtendedEvent<IHighlightable>();
I don't think it would make me good to add events now tbh....
Like it should be something I do from the start
at the end of the day it's your call. this is an accurate answer to the question you asked tho
ondestroy?
You can add events whenever you want and I think an event bus is the idea here
I could, and I have no doubt it would be the right way to do it from the start
But everything that happens when something dies is already like well nested on all others scripts
I think it would cause more issues than anything handle that with an event now
Well this would be the most proper way. Otherwise just call the singleton reference directly
When I want to initialize my singletons. It is enought to start the game at the initialization scene and I can then unload it because I'll have my dols already with me on the next scenes right?
I'm looking back at some stuff I made couple months ago but I cannot see any reason why I wanted to keep init scene loaded with the DOLs in it.
What's the question? You can make a loading scene and do the manager/singleton instantiation there then load onto a main scene that will keep those managers loaded
meaning you don't need those managers in the main scene (but for development purposes I do it anyway)
Ah okay. So I understand correct. I somehow thought I needed the scripts that are dont destroy on load should stay on the initialization scene at the beginning of the game and never unload that scene to keep them active.
dont destroy on load just prevents the gameobject from ever being cleaned up (from deloading) until you unflag it as is
so if you aren't using additive scenes and just load/deloading scenes then you probably want to use it for your managers
Yeah I failed to understand that it seems. Thanks for the answer!
Also another quick question. Is marking PlayerController that is responsible for your player movement/interaction etc dont destroy on load making sense? If so how can I set all the serialized references in the next scene? Because probably the next scene will have different references to hold on my player.
Isn't this what you were asking for, though, a solution? Events are the easiest โ and honestly โ the most common method. Refactoring is a part of game design, but this is not a big task to take on . . .
Well, if you have stuff being serialized on each scene that's a little tricky. Initialize the manager in the scene where there are those dependent, but say the next scene have new dependencies that you want to serialize on the editor then you can just destroy the manager and recreate it on the next scene (still a singleton) but this means you lose those previous references. Otherwise you need to dynamically bind them as you enter the scene if you want to keep the persisting DDOL manager.
Well, I asked for between two choices and you guys told me to use a total different method that would take me like maybe a couple of hours where I could just place a single lane of code rn?
I get it, it's THE intended way
I am just not using that now
Understandable, but if you were going to use a single-line code rn, why not do that initially?
All right. Thanks!
im making a rocket launcher weapon and for an explosion, would it work if i increase the hit detector colliders size, played the particles, and destroyed the bullet all at once when it hits? and if it would, is that a good way to do it?
I asked if it would be better to send a reference, of the list through another script that already has the reference or add a reference to the script that is gonna use the method ๐คท
its totally valid to want to know how best to do something and decide not to do it currently ๐. I personally disagree on your take that it needs to be a all or nothing kinda implementation but you know how best to program for yourself so whatever floats your boat
@frigid sequoia Also, as another option, you can use an SO with a list field for your enemies and directly reference it in any script that needs the list . . .
@final kestrel not sure if this helps but in a lot of stuff i've made i tend to have a singleton manager that exists in DDOL (i tend to call it a GlobalManager). and a singleton that exists in the level scene/s (i tend to call this a GameManager, RoundManager etc. depending on the kinda game). Then either ither handles stuff depending on the scope of the thing they are managing
The script that stores the list is basically an SO, but not really
Handles just a tiny bit of other functions, but it's mostly for that
Good to know! Thanks. I'll look more into it.
Oh, I see. In that case, what I just suggested (using an SO with a list field) is a better option than passing the list around, and adding a script that has a reference is just stacking a dependency onto another script. That's what you want to avoid . . .
I mentioned using an SO because you can directly reference it from any script straight from the project folder. It avoids dependencies and you can check its status anytime . . .
we love so's
Your enemy manager script controls adding and removing the enemies while the scripts that need it will have their own field for it. It saves memory since each script will reference the same SO . . .
im pretty sure they were talking about instansiated enemies, no?
Yeah, the list of entities is a singleton basically
Is a single script on an object that hover over everything else, as well as the GameManager
Yeah, when instantiated, you add them to the list; when destroyed, you remove them . . .
I thought ideally we wanted to avoid storing runtime data on SO's
not that i don't do it just thought it wasn't the vibe suggestion wise
hello, I'm new to unity and I'm trying to use the unity version control but it won't let me enable it for some reason... would anyone know why?
This is basically the list of entities that I am handling, does a bit more than just hold the data, that's why I didn't make it a SO
Only if you don't know what you're doing. The list is manipulated during runtime, and nothing is stored permanently. This is mainly done to save memory when multiple objects need a reference to the same data . . .
Heard ty chef
I forget and the unity docs are a little vague, are Awake or OnEnable suitable for resetting and/or initialization runtime data on SO's or does it need to be handled by a monobehaviour etc.
I tested this a while ago but can't remember all the details; it's finicky. OnDisable and OnEnable are called in the editor every time your script(s) recompile, and I believe Awake is called when the SO is created (during runtime and in the editor) . . .
right yeah that sounds right
i wanna maybe say if you use both to call a function that handles all the usecases?
the docs really need to be more explicit on how they work
You can use preprocessor directives to prevent errors in the editor for SOs . . .
There's a significant area of confusion for the initialization methods with SOs. I'm unsure if they updated (fixed) the docs in Unity 6 . . .
good read
Prior to this a ScriptableObject instance ONLY ever called OnEnable once per booted application session (build or editor), so it was effectively useless for initialization. Now it can be used almost as a MonoBehaviour.
Unfortunately the documentation is not clear:
this caught me recently too
I rarely use scriptable objects more than just data storage so "loaded" confused me too
Hi just for be sure. If i have a base code with a method, and in another code wich uses that base had the sane method but with other things inside, it will override it?
virtual methods can be overridden , regular method tells you if you're trying to hide the original since both run the parent one
you add new and that hides the parent one
Depends on a lot of factors. You should probably show the code that you're asking about so we can answer in specifics
By "base" you're referring to inheritance or is it just a figure of speech?
//This class or any derivatives can be created and used.
public class MyBaseClass
{
//This ALLOWS derived classes to override this function.
public virtual void MyVirtualFunction()
{
}
}
public class MyDerivedClass : MyBaseClass
{
public override void MyVirtualFunction()
{
base.MyVirtualFunction(); //This runs the code in the virtual function. You don't have to run this if you don't want the code in the original function to run.
//My additional code.
}
}
//This class cannot be created or used, Only things deriving from it can be.
public abstract class MyAbstractBaseClass
{
//This REQUIRES derived classes to override this function.
public abstract void MyAbstractFunction();
}
public class MyAbstractDerivedClass : MyAbstractBaseClass
{
public override void MyAbstractFunction()
{
//There is no base implementation for this function so there's nothing to call beforehand.
//My code that runs.
}
}
Hopefully someone can point me in the right direction for this;
I'm trying to create a base ENEMY CONTEXT class that I can change for each enemy type prefab I give it to (HP, ATTACK, etc.).
The issue I am encountering is I also want to be able to create an array of attacks the enemy can use... but I'm not sure how to reference the data from those attacks. I want it to be plug-and-play and tried creating an attack class array but it doesn't show on the enemy GameObject.
It seems like Scriptable Objects might be the way to go from my research, but... well I got the array to show up, but I can't add anything that derives from the scriptable object. I'm sure I'm missing something obvious here and would appreciate the help if anyone can let me know what I'm doing wrong.
but I can't add anything that dervice from the scriptable object.
can you provide more context on this
Are the attacks things that you define beforehand and don't change during gameplay, or are they dynamically generated or mutable in-game?
They are all defined beforehand.
Then ScriptableObjects should be what you're shooting for. You'd define the attacks in an instance of an SO. You should be able to drag those into a list of a parent type just fine
I tried creating an Attack class that enherits from ScriptableObject. I then made some class that inherited from that (e.g. Punch or Kick). Then I put a serializable Attack array in my EnemyContext class, but I can't seem to add anything to it.
You might need to use SerializeReference instead of a normal Serializefield though:
https://docs.unity3d.com/6000.0/Documentation/ScriptReference/SerializeReference.html
What are you trying to drag into it? You need an instance of that attack, not a script file defining one
are you trying to add via drag n drop or by the little circle search menu
I thought part of the point of SOs was that they don't need to be instantiated? Do I still need to create a Game Object with the SO Attack?
you need to create a ScriptableObject
they are asset instances but not gameobjects
like a Material
You don't need a game object, but you do need an instance. Usually through the CreateAssetMenu attribute
https://docs.unity3d.com/6000.0/Documentation/ScriptReference/CreateAssetMenuAttribute.html
ScriptableObjects essentially let you define data in a file in your project, instead of in an instance that gets generated by code during runtime
Hmm. Probably where I am seeing trouble. I have a version of Unity where there is no option to just create a ScriptableObject. I thought it was enough to add the inheritance to the class.
click the link above
theres an example of it being used here https://docs.unity3d.com/Manual/class-ScriptableObject.html
No version of unity lets you just create a scriptable object. You have to do that
There is no unity version that allows you creating a ScriptableObject instance in the menu.
Chance are, you don't even need the child classes. If you define your Attack SO well enough, you just need multiple instances of it
my friend needs help with a unreal engine 5.5 problem, is there a unreal engine equivlent to this discord ?
Really depends on the context no?
Like, one of them would have the name Punch and the damage value of 10 and speed 3 while Kick would have 20 damage and speed 1 or something
So this isn't that then?
In this video, we are going to show you how to use Scriptable Objects to manage your data in Unity.
Download the Unity Royale Project here!
https://on.unity.com/33FplpG
Learn more about Scriptable Objects here!
https://on.unity.com/33PzcJR
Get Inspiration on what else to do with Scriptable Objects here!
https://on.unity.com/2RKXXkK
Chapters:...
why is that part just cut off like that wtf
Scroll back
It's that thing I said you had to do
Unity doesn't just do that. You have to tell it to do that
Probably. Do whatever you did to find this one to find that one instead
Ahh. I see now.
My brain is expanding.
Thank you.
@sour fulcrum @polar acorn Thanks again guys; I started making INSTANCES of the SOs and now everything has come full circle. This is exactly what I needed.
๐
in theory
The virtual/override rules apply.
ok, holup
using UnityEditor.Purchasing;
using UnityEngine;
public class mortem_rifle_script : EnemyBase
{
void chase()
{
Debug.Log("deberia estar persiguiendote");
chasing = true;
if (debeDisparar == true && reload == false)
{
if (distanciaAbsoluta > rangoDisparo)
{
animator.Play("Base Layer.MRifle_Walk");
transform.position = Vector2.MoveTowards(transform.position, objetivo.position, runSpeed * Time.deltaTime);
bullettimer -= Time.deltaTime;
if (bullettimer <= 0)
{
bullettimer = firingspeed;
disparar();
}
}
else
{
bullettimer -= Time.deltaTime;
if (bullettimer <= 0)
{
bullettimer = firingspeed;
disparar();
}
}
}
}
}```
public class EnemyBase : MonoBehaviour
{
public int health;
public Vector2 boxSize;
public float distanceRay;
public LayerMask groundlayer;
void update{
chase()
]
void chase()
{
debug.log("u need an chasing code in ur enemy")
}
}```
just a heads up that function and class names should be UpperCase and class names shouldn't contain underscores. Ideally that would be MortemRifle : EnemyBase
Looks like you have a function in your function
woops, i just edited this cuz i haven't implemented this yet in my code, i just wanted to make an example, let me fix it
Without virtual/override, the method called would depend on the reference type.
so i just put the sufix virtual on all the methods in my base, and then put override in the methods of my enemy?
So if it's a mortem_rifle_script reference, the chase method defined in it would be called. If it's the base class reference(even if the instance is actually the extending class), then the base class method would be called.
Only on the methods that you want to override.
got it, thanks :3
if I have an editor script added to a gameobject, will it strip it from the gameobject in the build?
Editor script attached as a component?? What makes it an editor script?
A tool for sharing your source code with the world!
im getting a null reference at line 20 and 24
the script component i attached to it gets deleted when i start the game for some reason
then you haven't assigned the variable upgrade1
https://unity.huh.how/runtime-exceptions/nullreferenceexception
or rather more specifically, the object with this component on it does not also have an Upgrade1 component on it
i did add the component but it just deletes itself when i start the game
then show its code
i commented it out in here
that is a single method that isn't even what would cause it to delete itself
What's.... the difference between these 2?
im instantiating all of these objects, would that be a problem?
the second is deprecated
literally how the fuck should i know if you won't show relevant code for that
okay now show the code i actually asked for
the code in upgrade1?
yes
A tool for sharing your source code with the world!
well there's nothing there that would cause it to be destroyed, so you're gonna need to investigate what could possibly be destroying that component
yes i am aware
i was asking if instantiating a copy of all of these could be what was causing this
But it pretty much still works...
Okay, I will use the other one then
obviously instantiating an object does not destroy it.
that's because you are on a version of unity where it is deprecated but not yet obsolete. if you were using unity 6 then it would be obsolete and you would have a compile error for it
Any particular reason why that method is no longer in use? Seems pretty alright
it could be directing to a different copy of upgrade1 than intended
I guess they touched the whole gameObject scripts
that doesn't make any sense
the FindObjectXXX methods were deprecated in favor of a group of methods that can optionally perform the sorting that the previous versions of the methods were already doing. FindFirstObjectByType does exactly what FindObjectOfType did, it gets all of the objects of that type, sorts them by instance ID then returns the first. There is an alternative FindAnyObjectByType that does not do that sorting though
The deprecation message should show you this information. Make sure your IDE is configured.
There is just a single one, so i guess I should do the FindAny
or use a better way to get a reference, even the unity docs suggest using the singleton pattern over the Find methods if you only have a single object of that type
I don't think it does, no
afaik there isn't one in 2022, only in 6
Ah, makes sense for a backport.
wasn't it introduced earlier than 6 tho
in 2022.2, which is also when 2023 was in alpha. so new addition for 2023, but backported to 2022.2
Oh, yeah, I should totally be using that as singleton, I don't know why I wasn't
In fact all these should, huh
Is there a way to make the whole Main Components and its children don't destroy on load from the inspector or do I have to make a script just for that?
gotta do that in code
A simple way is to slap a DDOL script on the parent . . .
idk man im just throwing random suggestions and seeing what sticks
Yep, that's what I am doing
I have a question, it's not gonna happen, but I am like curious to know how this goes. How does it work when you have stored data and release a new build? In like.... Let's say you just realized a particular weapon is way too strong and decide to tune it down but the player already has that as saved data on their character? I am guessing you would need to save all that kinda stuff as SO and the player just saves references to those that get updated as soon as used?
Else the player would find that... his wooden sword in particular is like damage 10 but all others wooden swords for now on are like 8?
It depends what and how you save. In most cases, it would just be IDs of items. So when they load a game after updating it would be using the new item stats(assuming the I'd didn't change).
Some games might have stat randomization or modification features. Depending on how they are implemented, the player might indeed retain stats from before the update.
Basically, it's all up to you
scriptableobject changes at runtime are not saved incase that was an assumption your having
The thing is... the player is intended to ultimately assembly a whole roster of players of different clases, with different stats, skills and equipment. I would need to store the whole roster as saved data, and be able to modify it later if needed
So for example if the player saves a warlock on the roster and that warlock has a summon imp skill; if I want to later modify the skill and affect all players it would need to be stored as an static SO and just give the player the reference to that right?
when you mean save do you mean in a single play session or multiple play sessions
You'd save an ID. You never need to save actual data(unless there's a specific reason to do that)
This does not even save at all yet, but if I want to do it, I have to set it up now. But I do mean over multiple play sessions
then yeah
if you launch a game, modify a scriptableobject and close the game the scriptableobject won't save that change
you need to compose a way to save stuff yourself (usually using Json)
Ok... and can I just add whole scripts to a SO no issue right?
i have no clue what that means with and without the context of this conversation
I mean, in the previous example. I would need to have a reference to what a warlock is through a SO (cause I intend to save the player having one of those). This implies several scripts attached, one for each skill for example. If I want to modify the whole logic of an skill I would have SO that has a reference to that script of the skill.
the word script does not make sense in this sentance
do you mean another scriptableobject? a monobehaviour? a base class?
because you don't put scripts anywhere
Also:
- You should avoid modifying SOs at runtime.
- I'm not sure what meaning you put into "save the player having one of those"). You don't save the whole player GameObject with references. That's not how it works
I do not intend to modify SO at runtime whatsoever
And I would need to save a player having X character on the roster. These all are the scripts that make a character for now. All these are mostly common to all entities. But a rogue in particular has X stats, a particular behavior script for him alone a skill script that is particular to them
I could save the rogue as a prefab and make the save date "Player has a rogue", but I would need to save like different instances of that rogue not being any rogue, but THAT particular rogue. It having stuff like equipment or a given name. That could not be saved as part of a prefab. So I would need to store all that as SO?
You'd need to create serializable data for each of the scripts and save it as json or something.
You cannot save gameobjects or scriptableobjects at runtime
I mean in the editor, not a runtime
based on the messages in this conversation i don't know if that is true?
In the editor you can save it however you want, whether it's a prefab, SO or just data saved in json.
I mean, it would be fucking great if could just plug the whole gameobject and save it, but I know that's not a thing sadly
Yeah, I also had the feeling we're talking about save game system
coding in something to send you to the next level while also saving what level you're on
thats why i asked this and that your original question was about how save data works in a new build
and for some reason its skipping from level 2 to level 4
and its triggering ontriggerenter twice i think?
anyone know why
you have debugs, is it triggering twice or not? if it is, print more logs about like what you collided with
Make your logs more verbose. Log the values that are being used/passed around.
alright
checked and now i understand whats happening lol
shouldve checked tag of the thing colliding w it
bc if anything enters its trigger then poof next level
yea thanks a lot for the advice lol
https://paste.mod.gg/bwyhoinprflu/0 upgrade 1 keeps getting unassigned (i think its because both the original and instantiated copy is running the lines in void start)
A tool for sharing your source code with the world!
Unassigned when? Where?
How do you know that?
Is it assigned in the first place?
May I already try making extremely simple games to practice? As I am only able to learn programming in c# and Don't have any idea how to program on Unity since I never had the idea of trying.
Here's a summary of what I know in c#
Basics of C#: Variables, data types, input/output, type conversion
Conditional Statements: if, else if, else, nested conditionals
Operators: Relational (>, <, ==, !=), Logical (&&, ||)
Basic User Input Handling: Reading and validating input (Convert.ToInt32, ReadLine)
Basic Debugging Skills: Identifying syntax errors and logical mistakes
Simple Programs: Grade average calculator, username-password validation```
I wanna apply these to Unity to at least experience programming in Unity while Learning c#
You would not be able to apply i/o operations from console applications
is this like some AI section of text you've written? Its worded quite AI like
May I already try making extremely simple games to practice
Yea no ones stopping you. Id say it might be better if you understand classes/instances first but its not impossible to learn in unity too
!learn
:teacher: Unity Learn โ
Over 750 hours of free live and on-demand learning content for all levels of experience!
Yepp I let chatgpt track my progress of learning
๐ค
Yea maybe dont do that. And also don't use AI generated anything here
no one wants to read AI written text and definitely dont want to be responded with it either
I learn with chatgpt, ask questions for deep explanations but I dont work with them since I know I would not learn
Well that depends right? Since it's just the list of what I currently know
Main issue with learning from ai would be not being able to validate what it suggests
Learn with an actual resource instead of a spam generator. Theres TONS of guides online for everything
no it doesnt depend lol. im telling you directly that no one wants to interact with AI text and its against the rules also
Yes I'm watching a course on YouTube and so far I think I'm learning any way, but in Unity, I wanna start learning since the lessons that I am learning is only about programming
the bot message above has a link to unitys learn site
#๐ปโcode-beginner message
For real? Then would I have to list down all of the things from my previous message by myself?
I learned this
This
This as well
sure
it's called writing
if your gonna be programming you'll be doing a lot of it
the biggest problem so far is AI will lie with confidence, they will confidently answer u with wrong answer like its 100% right
and they dont even know theyre actually lying
is that really such a shocker? if you cant put in basic effort to say you learned if statements then what kind of effort should people put to help you? Imagine if someone went straight to chatgpt to respond to your question
lets say u learnt to chapter 6 , and u ask chatgpt, it may confidently answer
yes, now you have learnt to chapter 3 so far
The unity discord server's #๐โcode-of-conduct prohibits posting ai content.
Good point, then language translations, grammar corrections by ai are discouraged?
do not let chatgpt represent ur learning curve, question, answer
i had failed damn hard with that
if its solely translating language, welp ppl will know, i mean we know english right?
but normally google translator should do....
moving on from the whole AI part, truthfully you've learned the absolute basics of c#. I suggest looking more into functions, classes/instances, and then you'd have an ok foundation to at least understand how things work in unity.
Alrightt, should I learn some in Unity since classes are in Unity right? I dont even know what to call them
you can say you learned if statements and variables, but at the same time you've had so little experience it's doubtful you'd be able to write these programs easily
class is a c# thing
Oh, how about rigid body things
C# is similar to java, its an evolution to that
in java, everything must wrapped into container, except using statements , same for C# i guess
Unity has components, which are classes yes, but you're going to be very confused if you don't understand how to access information on a class
the main container is class
Components, which you can learn along with the tutorial link above #๐ปโcode-beginner message
public class abcde{
//content
}```
๐ค did they say anything about knowing java, this would honestly just be more confusing to me if i was learning anyways
Because they say we can freely join game jams, and I kinda wanna join one for experience, but since I don't even know how to apply my knowledge in Unity, how would I do.
the best thing is really not to try and teach such concepts and let them go use actual guides imo.
go visit learn.unity.com
u should have the link already
or additional info for C#
New to Unity?
Learn With Pathways
Check out new courses
Get ready by:
Making a game first.
Making a game fast - productivity wise.
Making it on demand - impromptu.
hey guys if a script has name space in it do you guys know how I. an access variables from another script becuase it is not letting me
Is this the right place?
Add a using statement for the namespace it's in to the top of the script you're trying to use it in
using System.Collections.Generic; you mean this ?
Assuming the code you want to use is in the namespace System.Collections.Generic, yes
So I want to use variable from another script inside the script that has namespace in it. but if theres no way to do that I think I can figure it out based on what you said.
Once you add the using statement the namespace no longer has any effect
As script being inside a namespace, doesn't affect what it can access in any way.
At least not in regards to code outside the namespace.
You should share your code with the issue if you need proper help.
ok Ill share it but fyi Im aware that my script is not clean Ill clean it later lol. what was that website that you guys use to share
!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.
A tool for sharing your source code with the world!
so I just want to be able to access varibale from sonartaken script and use it inside the sonnar script
Click save before sharing the link.
Still doesn't link to your code.
Look at the url before sharing it. It should contain extra characters, not just the base url.
sonartakestuff = FindObjectOfType<Sonartake>();// this is not working
What do you mean by "this is not working"? Does it assign null?
this is what I get in my console
Ok, I am extremely confused, cause I turned all those scripts into singletons and make them don't destroy on load and now it's returning me this error. But... it doesn't make sense, cause it's working, and that could not work without a reference at all so....
Wtf?
Are they in the same assembly?
Open both scripts in visual studio and take a screenshot of the whole window.
Perhaps you're accessing the singleton before it's instance is assigned.
Yeah, that's the only thing that could be happening, but... the script is working, at the same time that is telling me it does not have a reference to the players... how?
I am extremely confused
Who knows perhaps you have several of these scripts and some of them initialize properly. You should debug it.
Mmm... Vs code is not gonna help much. Especially since it not configured correctly for unity.
try applying a null check for the instance and assign it this
this is visual studio code the blue one
Does it work if you put both scripts in the same path?
Oh, I think it's calling the OnEnable twice
Yes, that's what I said. I was talking about Visual studio(not code, the purple one).
Does that trigger by default at the start if the component starts enabled?
Yes, it should be
havent tried that and I dont think the project manager is gonna want me to do that lol
Well, there's not much I can help you with then. Unless you can tell me if both scripts are in the same assembly.
when you say same assembly you mean the same script or am i misunderstanding
No. In C#, code can belong to different assemblies. These would normally compile to separate dlls. Basically, separate modules of a program. Code in one assembly can't see code in another, unless the other assembly is referenced correctly.
If you have a project manager, maybe ask them for help. They should know enough about the project to tell you why the other script is not recognized in your code.
belive me if i had that option I wouldve done that but he is very busy and all the coders are becuase we got deadlines and exams coming up and I only need to access a boolean and clean my code and Im done. but its fine ill try to find a way to fix this and hopefully I will
You can also install visual studio and take screenshots that I asked for.
I thought it doesn't work on mac anymore but I might try that
When i start the game, a script thats a component of tmp text, before i start it it says it was assigned but if i check after i start it its no longer there
oh my god i just figured it out
Ah, actually it might indeed.๐ค
thanks, i made the same mistake as you lol
yep ^^ "Visual Studio for Mac has been retired as of August 31, 2024 in accordance with Microsoftโs Modern Lifecycle Policy. " https://learn.microsoft.com/en-us/visualstudio/releases/2022/what-happened-to-vs-for-mac
Hello, unity noob over here, I experimented a bit with RPC calls and was wondering if fusion + photon voice would be a good solution for a solo project by a beginner ( I have C# xp, just 0 experience game developing )
The project I'm making is based on proximity chat
What's a good way to expose the tag property of a gameObject, similar to how one would do layermasks for rigidbodies?
As in I could expose it as a public field and modify the values
I searched and came across editorGui.Tagfield but that's not exactly what I needed
For context I wanted to have a way to distinguish between ally and enemy projectiles, and they happen to be on the same layer so tags were the choice that came to mind
However I wanted to use a scriptableObject for the configuration and seting the tag instead of manually configuring each prefab
hello, does anyone knows what this error is? :
TransientArtifactProvider::IsTransientArtifact call is not allowed when transient artifacts are getting updated
Sounds like an internal Unity error. If it keeps happening restart the editor and see if it is fixed
silly question but how do i round of the edges for a square image
Not a code question. #๐ฒโui-ux
You cannot, you need to create an actual sprite. Alternatively, you can buy one of the procedural UI assets off the store.
animator.SetBool("Walk", horizontalMovement != 0);
animator.SetBool("Jump", !isGrounded && rb.linearVelocity.y > 0);
animator.SetBool("Fall", !isGrounded && rb.linearVelocity.y < 0 && !isWallJumping);
Can someone help me where my logic is maybe wrong?
so every animation works well, just the fall wont trigger
I set
Jump => Fall to true
and
Fall => Idle to false
https://unity.huh.how/debugging
Debug your values and verify the boolean is actually being set as you expect.
Okay got it nearly right now. now the jump is sometimes triggered after fall instead of idle. I try to fix it
thanks
!vscode
Hey, I'm new to unity, trying to make a small game prototype with some funky movement. I am kind of confused as to why I do not have code autofill (tab) or hints about what certain functions or lines of code do for VScode like most guides show? I have Unity Code Snippets installed and the Unity extension for vscode. Any ideas?
You can try following the !ide instructions here:
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
VSCode is finniky at best though. If you want something reliable, use Visual Studio or Rider.
Dang, I did everything in that vscode guide and it goes from this:
to this in a couple seconds:
And intellisense still doesn't work. Guess it's time to just switch to VS
Yeah, I don't use VSCode at all for Unity
switching to vs is probably the better solution, but you can also check out this list of troubleshooting steps for vs code: https://unity.huh.how/ide-configuration/visual-studio-code#if-you-are-experiencing-issues
Thank you, would have spent 100000 years trying to fix vscode. Everything works with an updated VS.
Thanks for the tip, I might try it at home with my other PC same issue there.
VSC isnt a "real" IDE, its basically a text editor with extensions to let you do IDE things
I was wondering if anyone could give me some suggestions on configuring 2d movement?
I've implemented the entire thing based on modular movements where every move is a scriptableObject to be executed by a state machine that has an array of said movements
My question is if there was an easier way/better way(s) of setting this up, since I've found that every small change in say, speed or direction values calls for a new scriptableObject
Code is in pastebin
https://pastebin.com/HJCcbc88
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.
Also i'm aware that if I want collisions it'd be best to use rigidbody.Move; I've just yet to refactor things
Do you really need the moves to be this configurable/modular, instead of just making concrete classes/functions for different moves? Do the moves always share a lot of common variables?
calls for a new scriptableObject
Wdym by this?
For some context I'm trying to make a shmup, and I figured the best way to have control over the movement was to decompose it into this form
If you are referencing a scriptableobject, you aren't creating a new one (hopefully) every time you read its variables
My bad I meant if I had say, a move that's linearly to the right, but now I want the same move except change in direction; currently I have things set up where these two need to be two separate scriptableObjects
No no that's not what I was doing
Yeah the direction being tied to each scriptable object instance feels weird to me
I set it up this way so that I could change directions whenever I wanted, move right first, then move circularly, then move left etc etc
what did you have in mind instead of this?
I also think it's quite cumbersome...
Idk, the caller passing in the direction as a parameter
But i don't know enough about your game to judge it
One idea is to make the MoveConfig abstract and split it into child classes that implement only the stuff they need
I haven't thought about doing it that way!
I even wrote a custom editor just to separate linear from circular and etc etc๐ proves to be completely unnecessary if I had split them into child classes
Thanks
does making a completely physics based camera as a gimmic work well, not just like its affected by physics but like almost like it moves back and fourth based on how fast you go and stop almost like a cartoon at sudden movements
I would so that with some math, tweens and/or animations, not with actual rigidbodies or anything like that
is this the wrong channel for that question?
im calling daddy gpt for the math ๐ i am not smart enough to calculate that shi
Or do you need collisions and physucal interactions with the camera?
maybe its not fully decided but one of my ideas was to have the camera move with the head which uh i now realize i should probably just write a normal camera script and acnhor it to the head and make the ehad do the calculations...
but yeah probably
maybe the head anchoring method would work better, either way im almost done with the rigidbody camera script and ill have to test it out... afterrr i fix my bad ahh player movement
Not sure where to ask, but I can't get grid snapping to work with rotation. Only XYZ movement. Or does unity not support that?
Ctrl works. Thanks. Couldn't find it for the life of me. (Or I am just bad at google)
Thanks, sorry.
Hello, I am trying to make the water tiles in my game add speed to the user when they interact with the water but every time I try to add a tile with a script to the tile palette it won't appear to place. I thought I was supposed to make a prefab and then I would be able to make them but I'm not quite sure what I am doing wrong
this is not how you make tile
Tiles arent meant to be GameObject / SpriteRenderer
drag the sprite tile from the project folder and put them in the Tile Palette
On that note if you want to use GameObject as tile (for interactions and whatnot) Then you use gameobject brush instead. These can't be put in tile palette but also they are nested in tilemap object but they are not part of the tilemap technically
I see, I was trying to add them straight to the palette(after the script was attached) but it kept saying invalid. So am I sup--ooooooh
Ok i will give that a try
It worked ๐ญ thank you very much
is it linearVelocity or just velocity when working with cameras, im getting told velocity but VS code doesnt aggree
!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.
Rigidbody.velocity is now Rigidbody.linearVelocity in Unity 6
There is no such thing as .velocity any more, anywhere
huh why does a camera have velocity anyway?
It was renamed to avoid ambiguity with angularVelocity, which has always existed
But technically the field velocity would imply it controlled both
Which it never has
https://paste.myst.rs/gtnn6dq2 with this code how can i make my asteroids spawn smaller versions of themselves 2 times right now it splits apart once but i cant do it after that
a powerful website for storing and sharing text and code snippets. completely free and open source.
You should have a script on the asteroid that detects when it's shot, spawns in the smaller versions of itself, then destroys itself.
You make the smallest asteroid do everything but the "spawning more" thing
So, a script with a field for "SmallerAsteroidPrefab" or something, and as long as that's not null, spawn two of that when it dies
https://paste.myst.rs/ibbsce08 could i use this script
a powerful website for storing and sharing text and code snippets. completely free and open source.
You could use whatever script you want
hi. i bought a game kit that uses a Timeline to define when creatures should be added
mostly it's a good metaphor, but there are times at which having it as code or data would be better (mostly during bulk editing)
is the timeline a UI only thing, or is there some way to get it as code/data?
But the easiest way is one on the asteroid itself
just to make sure, Player.Look is already affected by framerate and will be smaller the higher the framerate is? So I don't need to multiply the lookVector.x * mouseSensitivity by Time.deltaTime? Or do I still need to? Assuming this is in Update()
if it is mouse input then yes, it is already framerate independent. if it is joystick input then no, it is not
you do when it is being used for joystick input
Hmm, I see. Thank you very much! :D
intresting thank you
For anyone that took Unity programming pathway, how sufficient did you find the course?
gimmic, mostly testing it out but i thought that maybe it made for a unique concept if done right, im still coding it but still fixing logic etc becasue i suck lmao
right now its just seizure simulator since its like 80 lines which isnt enough for this really. and at the same time im bad at these kinds of maths so i might be cooked
also how do i call this function
Unity calls this function when there is a collision exited between a rigidbody +collider and another rigidbody/collider
ah so i dont need to add it to my update loop? great
na. Just like Update these are called by unity
i dont know if youre still here but how would i have it in different stages for the asteroids like the bigger one breaks into two medium ones and if you break one of the medium ones you get two smaller ones
By changing which prefab that script references
ohh ok thank you so youre saying i shouldnt do it like how i am doing it right now i should create two prefab varients
Does this always take so long to download?
or do i have only one for the smallest one
Yep.
do you know how long aproximatly?
I donโt know but I remember it taking too long last time I did it and I just went to sleep and let it do its thing. So Iโm not sure. An hour or more?
I'd assume the download would differ depending on your internet speed. Some may take 30 mins, some may take a whole day
anyone might be able to help me? i am trying to make drag&drop inventory system, but cannout figure out, why the OnBeginDrag doesn't work.
public void OnBeginDrag(PointerEventData eventData)
{
print("begin drag");
if(CurrentItem == null) return;
_dragHandler.StartDrag(this);
}
I have implemented the IBeginDragHandler interface
and I do have a Image component
on that MonoBehaviour
and nothing overlapping that image
and event system present
view the event system at runtime to see what it detects when you try to drag that object
the Selected: at the very bottom?
it has a preview window at the bottom of its inspector that will show you useful info like that
yea it's always nothing
even when i hover the mouse over my inventory slots
just wondering what's wrong, as I have nothing above the inventory slots, just started the project
that's the only UI I have
and if you actually set a sprite on the image does it work?
no, doesnt work aswell
but if i add a Button component under the inventory slot
it's interactable
changes color on hover etc
i thought it's possible to make IBeginDragHandler with just a Image, right?
it is. which component actually implements the interface?
InventorySlot
and your canvas has a GraphicRaycaster, yes?
yes
here is inventory slot if it helps with anything: https://pastebin.com/en0tjHTG
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.
the InventorySlot object doesn't have Image comopnent, the background and item icon has
but I have also tried adding one
same result
the object that actually has the component that implements the relevant event system interface has to be the one with a graphic that can be raycasted against. so if InventorySlot has the InventorySlot component then it must be the object with the image on it and there cannot be another image overlapping it (like Background and/or Item Icon) unless those are not raycast targets
okay got it, but it still doesnt work as i mentioned
this is inventory slot, with image as a raycast target
background and item icon has raycast target DISABLED on their images
it still doesnt print for whatever reason
there is absolutely nothing else covering/overlapping the inventory slot image
funny thing is, that when i add EventTrigger comopnent
to InventorySlot
and assign something random to just test if its working
then its working

yes my VS is saved ๐
are you sure about that
yes
did you make sure it actually compiled too?
yes
i have even restarted unity and PC
there is even a thing like that in inspector
why would EventTrigger work but not IBeginDragHandler
on same setup
and what is even more interesting, triggering this via EventTrigger, also prints my message in code
if you also implement IDragHandler does it start working?
okay so i guess IBegin/EndDragHandler require IDragHandler to work. which kind of makes sense considering you can't begin dragging without also dragging
plus you probably wanted full drag functionality and not just detecting when dragging has only started
so my idea was that i will handle
all dragging and dropping in
InventoryDragHandler instead
should I keep everything inside InventorySlot then? I wanted to kinda separate it to keep single-resposnbility
how would that separate object detect when you have stopped dragging
okay, so how would that detect when you've stopped dragging a completely different object
so basically i did only start drag in InventorySlot then activated drag handler and the ondrag started to work there
again, neither OnDrag nor OnEndDrag would be called on a separate object
you can still separate that functionality out to a different component, but that component just has to be attached to the object being dragged
i just had a issue, where when I was dragging a Image's rect transform
from a slot1
it was "under" slots10
so i wanted to set it as last sibling temporarily
when dragging it, and setting it back as a child to original slot
is that a good idea?

it works, tyvm
oh and btw @slender nymph, you don't even need Image on the InventorySlot component, just having the Image as a child works aswell
just wanted to lyk
!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.
how can i make my instantiated gameobjects faster for example i want the small and medium asteroids to be faster
a powerful website for storing and sharing text and code snippets. completely free and open source.
Nothing in this code seems to be moving them in the first place
Well, it wraps if it's off screen
So what actually moves the objects
oh i have this code: https://paste.myst.rs/rfb9zbgm
a powerful website for storing and sharing text and code snippets. completely free and open source.
Looks like they pull their speed from data.maxDirections in Start. You could just multiply that result by something to scale it up or down
oh ok thank you i guess i can just use a serializefield and adjust it for each of the prefabs
Yeah that's probably the best way
thank you
hi, im having an issue where my bullet prefab that holds the bullet script wont let me assign the enemy gameobject or the empty EnemySpawn onto it. i try and it says type mismatch. here is how i have it set up, any help would be appreciated. this is the code, im trying to enable the Enemy after disabling it when its hit by a bullet.
https://paste.myst.rs/6dazt4rj
a powerful website for storing and sharing text and code snippets. completely free and open source.
Prefabs cannot reference objects in scenes.
you need to set the reference on the instance of the bullet after you spawn it
Hmm ok thats what i figured, how would i go about doing that? this is where i instantiate my bullet in my player script. i have a empty gameobj for the bullets to go into on spawn would i do anything with that?
What type is BulletPrefab
GameObject
You should use the type you actually want instead, most likely Bullet.
Then, instantiate will return a reference to that Bullet and you can set its Enemy field
this is all im using besides my bullet script and my prefab
as suggested, do:
[SerializeField]
Bullet bulletPrefab;
...
Bullet newBullet = Instantiate(bulletPrefab);
newBullet.Enemy = foobar;
thank you ill try that
does anyone know how to rotate a capsule collider in Unity 2D? ๐ญ
Usually you can flip stuff by setting the x scale negative but not sure how that works with physics
otherwise flip the collider values in a script
damm i thought there was just a "rotate collider" button or something ๐ญ
Collider always aligns with the object axis. So if there's anything you need to rotate, it's the sprite. Or you could add the collider as a child and rotate that child object.
I'm general, you should keep visuals separate(separate gameObjects) from physics and game logic
why, when naming my script "game Manager" it became a funny gear?
Just a special icon for that special name. It doesn't do anything else
ah, okay, ty
Kind of a Unity Easter egg tbh
No just GameManager
fair enough
Ya got a canvas on the GO
rect transform even
Ah, you're just serializing other images onto this manager
Are those the right kind of Image?
Yeah wrong namespace probably
Make sure you have using UnityEngine.UI instead of using UnityEngine.UIElements;
oh
Don't need that SerializeField either if you set it as public
i'm sure that was an attempt to debug/fix but yes
chears
the field declarations there only apply when the class is initialized
so if you added that component before adding that "locked. damnit" it won't appear after the fact
oh i see
The values you put in code for a serialized field are just the default values
The inspector takes precedence
Hey, i feel dumb asking this as i have been programming in unity for a while, but im left confused. It seems i get the null from that but at the same time it is assigned?
what is the correct way to get a tilemap collision? I see there are multiple collider functions you can use OnCollisionEnter2D and OnTriggerEnter are 2 that i have tried, but none are working
here is my current code
private void OnCollisionEnter2D(Collision2D other)
{
Debug.Log(other.gameObject.tag.ToString());
}
This is attached to my player which has a rigid body 2d and a circle collider. My tile map has a tilemap collider and its tag is set to "World", yet when i play the game nothing happens. i turned trigger on (for both player and tilemap) when using the on triggerenter method
the code is running twice
once it works properly
the other time it throws an error
You might have multiple copies of the script in the scene
Oh, that would explain things
Only that im almost sure its a single copy, let me see
Is the player's Rigidbody dynamic or kinematic?
how you move the player, show code
void ApplyMovement()
{
float speed = moveSpeed;
if (inputHandler.SprintValue > 0)
{
animator.speed = sprintMultiplier;
speed *= sprintMultiplier;
}
rb.linearVelocity = new Vector2 (velocity.x * speed, velocity.y * speed);
//animator.SetFloat("Horizontal", velocity.x);
//animator.SetFloat("Vertical", velocity.y);
//animator.SetFloat("Speed", velocity.sqrMagnitude);
}
that function is called in fixedupdate
It's quite a big script, so there is no way i missed another copy
Also i don't see it anywhere
velocity comes from my input handler
private void Awake()
{
if (Instance == null)
{
Instance = this;
DontDestroyOnLoad(gameObject);
}
else
{
Destroy(gameObject);
}
moveAction = playerControls.FindActionMap(actionMapName).FindAction(move);
jumpAction = playerControls.FindActionMap(actionMapName).FindAction(jump);
sprintAction = playerControls.FindActionMap(actionMapName).FindAction(sprint);
RegisterInputActions();
}
void RegisterInputActions()
{
moveAction.performed += context => MoveInput = context.ReadValue<Vector2>();
moveAction.canceled += context => MoveInput = Vector2.zero;
jumpAction.performed += context => JumpTriggered = true;
jumpAction.canceled += context => JumpTriggered = false;
sprintAction.performed += context => SprintValue = context.ReadValue<float>();
sprintAction.canceled += context => SprintValue = 0f;
}
This is just getting the inputs from the input system and assigning a vector based on that for the player controller to access
looks fine there. Maybe ss both tilemap and player inspectors
Better to Use rb Move function
any reason y?
this was dynamic btw i changed it kinematic to see if it would do anything
ur player is kinematic
yup just comment on that its already back
is this the only tilemap you have?
yes
ahh your player is trigger
ah didnt realize trigger stops it from detecting
thought they both needed to be trigger
OnCollisionEnter needs both solid , OnTriggerEnter 1 can be trigger and other solid as long its dynamic
did you search in hierarchy t:EndTheTurn
ah ok makes sense
one more thing, what is the correct way to get the object form the collider? I thought i could just do an as but I cant so I'm not sure what is best practice
private void OnCollisionEnter2D(Collision2D other)
{
Debug.Log(other.gameObject.tag.ToString());
Vector3Int pos = new((int)other.gameObject.transform.position.x, (int)other.gameObject.transform.position.y, (int)other.gameObject.transform.position.z);
(other.gameObject as Tilemap).SetTile(pos, null);
}
no
GameObjects are never Tilemaps
Use GetComponent
Tilemap is a component on the GameObject
it is not the GameObject itself
ah i see
also note that Collision2D is not the same as Collider2D
Collision2D is a struct that contains information about the collision.
It works, the problem was that 'selectedcard' was null
so should i use the ontriggerenter function instead?
Only if you're dealing with trigger colliders
is there any reason not to turn on trigger for the tilemap?
Do you want it to be a trigger or a physical collider
If you want it to be a trigger, make it so
i cant say i know the difference other than it will trigger or not
Triggers are not solid objects
they exist merely to facilitate OnTriggerEnter etc
objects will not physically collide with them
ah ok, well in this case it doesn't matter since its instantly destroyed when the player touches it so there are no physics to be done with it.
is a trigger collider easier on the computer then since its taken out of physics?
but the player will be affected if it's a physical collider
it will bump into it
colliders / triggers are still physics
no triggers are not "easier on the computer"
better/worse performance was the wording i was looking for, but fair enough. essentially though its just a digging game where the player is falling down. Its gonna be fixed velocity down with a/d controls and blocks break as the player runs into them. so i dont care about physics since the rate of movement wont be changed by the world other than maybe changing the velocity by calculating what kind of tile is going through
if it doesn't make a difference on performance I will switch it to a trigger collider and just use on trigger enter
Perfect, got it all working. Thanks!
Guys, do you think it would be worth it to go through an online course that is paid to learn game development specifically in unity? Ignore the expenses.
:teacher: Unity Learn โ
Over 750 hours of free live and on-demand learning content for all levels of experience!
Let's talk about quality not accessibility
What is the correct way to implement global data in a game? This isnt just the settings menu where you change sound, im talking data alot of objects will look at and use for calculations/ some setting on how certain objects behave.
In my research i have seen 2 main methods and that is just make a static class which is what im familiar with outside of unity, or make a singleton script. Im not sure how to make a singleton script persist through scenes though so I dont know if that is relevant.
Just trying to learn best practice for future reference
Hi, I'm currently using the Meta Voice SDK and having issues, but I'm not sure why. Does anyone know why I'm getting these errors?
static class will just work but not be a monobehaviour. a singleton mono can be kept alive through all scenes by using DontDestroyOnLoad() on it.
but how do create it the first time?
doesn't change the answer
the only difference in paid courses is that they're paid
there's not really a difference in quality
have it in some scene or instantiate it manually via a prefab/manually. In its awake it can set a static field to this.
You can consider using the runtime initialize on load attribute to make it very early on https://docs.unity3d.com/6000.0/Documentation/ScriptReference/RuntimeInitializeOnLoadMethodAttribute.html
public static MyClass instance { get; private set;}
private void Awake()
{
if(instance == null) instance = this;
else Destroy(this);
}
it would contain data other objects would use in their start function. also my game transitions between scenes alot. so I was just thinking I didnt want to drag it into every scene/make an object for every scene because that seems bad. is there a reason to do it this way over a static class or is it just so you can use inspector on it?
How about a mentor? Would make a big difference?
Its as you just said, it depends if it actually needs to be a monobehaviour or not. If you do not need serialized variables on it and the mono event functions then no need.
You can also consider a scriptable object but you would need to explicitly load it on game start to make it exist and then need some static field to access it too.
perhaps, but imo you don't really need that either
it'd maybe make a difference in the journey, but not in the result
if you have the persistence and willpower to put in effort, you can learn without a dedicated helper just fine
just gotta utilize the resources you have, and free resources are plentiful
if you ever have a specific question that you can't find answers online for, you can always ask here for free
i see so the main reason to do it thatway is for the mono event function. If im just using it as a global storage bin then static class is no different
its literally just holding values for other objects
thanks!
another point; having a mentor falls into a similar hole as trying to get direct/dm support; it's only one person. they won't always be free, and 2 eyes on a problem can easily miss subtle details. community support, like this server, gets around this by utilizing a whole community to see your issue and potentially point out causes (or even unrelated issues)
(and that's assuming a mentor is fully competant, sometimes inexperience in a specific topic can lead to misdiagnosing problems)
I don't really consider myself slow enough to not follow tutorials, maybe I'm just exaggerating. Do you think I just need time?
@ruby zephyr my 2 cents may not matter much here, but as someone who has tried making a game multiple times and failed I can assure you it has never been becasue i couldnt figure out how to do something. What killed most of my games was just passion/time. if you have infinite time and you actually want to make a game then there is plenty of free resources everywhere. There is tutorials for almost everything and unity manual/ this discord has gotten me the rest of the way. in my opinion the only thing paying for tutorials would have done for me is burned money
oh, everyone needs time.
gamedev is not a single skill, it's composed of many different aspects
graphics, programming, design, audio, and then weaving it all together.
programming itself isn't a single skill either; it's decomposing a problem, designing a solution, debugging, understanding errors, being able to research effectively
so it will take time and patience. maybe you might be underestimating how much it takes.
but if you have the will to practice those skills, you will get as far as you want. (there's not really an end to a journey of developing skills)
also, if you aren't confident you'll be able to develop those skills enough to be a game, don't worry about that
if you want to learn now, start learning! whatever you learn will be transferable to other situations or projects or whatever, and maybe you'll find the confidence as you build your knowledge and experience
That's enough to encourage me, thanks! I guess I'll just finish all tutorials in Unity Learn, try, and Improve.
I would say paid courses or mentors can have an element that free resources do not, which is accountability. If you've given money to a person and there's an expectation that you will be somewhere at a time (physically or virtually), it's a push to keep going.
You don't need that push if you're super passionate and self driven to learn. But not everyone has that, and some elements of game dev can be boring to learn.
i mean, you can do that yourself with project planning
deviate from learning the actual gamedev for a sec to plan out your learning/development journey, set appropriate milestones
The extreme end of that is university. It's pretty easy to give up on your own plans, but dropping out of school is a bigger deal.
the thing that i find is the most helpful is just getting excited about an idea. just make sure your first project is simple that you can do it quickly but still interesting enough that you want to pursue it. you can definitely just watch tutorials to watch tutorials, but having an idea first i find to be helpful so you can learn different examples and methods from tutorials. Of course I come from a strong programming background so if you dont have that foundation I would definitely work on that. just getting your first win always feels nice!
as to accountability im making a game with a friend this time so we are keeping each other accountable but like listed above there are a few ways to do that.
wait i just noticed you said "all tutorials" lol
unity learn is really vast, and most likely they won't all pertain to what you want to make
choose the courses relevant to what you want to make
So what should I really stick to learning?
I was told to learn programming of c#, learn Unity hub's environmental, (tools, stuffs inside), and try to apply in game development
Currently I'm only learning basic c# and could not apply it to unity
learn about stuff relevant to your goal
if you don't know how to code, then yeah some basic c# before going to unity c# would be nice
there are also some resources pinned in this channel
Really?, like what, if I want a shooter game should I not learn how to make a horror game as well?
Lets say, I want to make a variety of Indie games
well, if you want a shooter game, you wouldn't need to learn about, say, dynamic audio cues
it's not like learning is a one-time thing
focus on your current goal
if you want to make a horror game, learn about that
if you want to make a shooter game, learn about that
I'd advise to look at ScriptableObjects as well
If I want to make different genre of games, I would then have to start, learning about the most basic one like for example platformer and then proceed to the next level?
i mean you wouldn't be learning about how to make a shooter game
you would be learning, say, first-person controls, basic inventory systems, HUDs, physics, modelling, sound effects
a lot of that would be applicable to a horror game too
but some wouldn't, like reloading mechanics. unless you can shoot the monster, idk.
and some skills would be more specific to horror games, like playing with dim lighting, or elaborate animations or cutscenes, or writing a story
if you're currently making a shooter game that doesn't have those elements, then no need to learn them yet
well, like above, you'd learn basic mechanics, and those basic mechanics can be made into a basic game
then you would have more complex mechanics, or multiple basic mechanics, that you can combine into a more complex game
etc
you don't need to make a game for each step
as you learn more, you'll be able to make more complex mechanics/games
Here's what I wanna do:
When you told me to learn the things that I just want, but then I wanna develop different genres as well which would mean I have to learn different mechanics,
I had a plan of learning the easiest components of games like,
- I'lll make a button to play,
- simple wasd movement
- and other more
So for every game I'd have to learn how to make something that they all have in common?
Then I'll learn how to make a character, make it move, and interact. Because this applies to many games.
_
_
I have actually never thought of that idea.
@ruby zephyr Even if there's nothing in paid learning resources that isn't out there in free tutorials, they're generally better in my opinion
Unlike scattered free tutorials they can be connected and cohesive learning paths that ramp up the complexity gradually over many projects
They also serve as examples and pre-compiled notes for you later
But since anyone can just start making and selling courses their quality also varies a lot, so it's best to research their offering and reviews before committing
it keeps increasing if im not looking at an interactable
Line 27 of your PlayerInteract script is trying to reference something that doesn't exist.
A good guess is that you're trying to do something with the object the player is looking at, which doesn't exist if they aren't looking at something.
Yep, gotta make sure when you Raycast your code is actually checking for a valid hit or not
so uhm what
also gotta say im just following a tutorial so uh ye
thanks in advance if yall reply ๐
You have a semicolon where it doesn't belong
There's a reason it's underlined in a green squiggle
after the distance))?
It's trying to warn you
ohhh
Yes
Don't you see the line that explicitly sets it to -2 ?
there are several free, high-quality courses that aren't just single feature guides
and single feature guides can also be more helpful in some cases as well
courses may be better depending on your learning style, sure, but there's still no difference between a paid course and a free one aside from spending money (and the commitment that comes with that)
i do
actually
nvm i just remembered this exists
There's so many resources out there it's hard to generalize
There's high quality free stuff and low quality paid stuff, but on average the balance goes the other way
Ideally when paying you get access to support or teaching assistants as well
I don't recommend everyone to buy courses outright, and hunting for bundles and sales is much better than ever paying full price, but if the premise is that money is no issue then there's not really a drawback to taking that shortcut
double check the axes you are getting input from
which
read your code and find out!
do you just not know what an axis is? or that axes is the plural of axis?
i just got confused
ok but i know its a plural
how about reading some unity docs?
Do you get any messages in the console
and this
holy
crazy how actually paying attention to error messages can help you fix issues
honest stupid mistake i swear
another stupido question what am i supposed to change
also my excuse is
i just got unity
today
It literally tells you
Well, do you want to use your own custom axis, or one of the ones unity provides?
finish a thought before sending a message. and consider going through the pathways on the unity !learn site to actually learn how to use the engine instead of trying to skip ahead to a finished product
:teacher: Unity Learn โ
Over 750 hours of free live and on-demand learning content for all levels of experience!
unity provided
So you might want to look up the names of those
And use the ones that actually exist
is the component pattern just... adding components? it seems so simple, so much so that it doesnt sound right
Yes. It's more complicated when you're not using Unity
It's a general programming practice that Unity was built around
it's the whole setup of having containers (GameObjects) and adding behavior to them with components
ah okay that explains it
Yeah, it seems easy because Unity was designed to make it easy
It seems like it's mostly just a difference in mindset - whether you're adding functionality to a neutral container, or putting neutral data into a functional container?
ah so its about intent i guess?
adding a rigidbody to a player would be component, but adding a playercontroller script would be decorator?
Seems like it? I dunno, I'd need to see some more concrete examples of a decorator pattern to really grok it
This Code should work but is there a more elegant way? My intuition thinks this should be possible without creating a int count variable
//Check is all Quest cleared
//Count how many are finished
int questCleard = 0;
for (int j = 0; j < _quest.Length; j++)
{
if (_quest[i]._questCout == 0)
{
questCleard++;
}
}
//All Clear?
if (questCleard >= _quest.Length)
{
TransformMotherCell();
}
you can use a linq method for that, like .All
So you need to check if they're all cleared? You could also check if any of them are not cleared, and if they aren't, exit early.
or that
If the code reaches the end of the loop, they're all cleared
That's a good idea
I often do that, where if you require everything to meet some criteria you return early if any are false.
then after the loop you know the condition was met.
๐ 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.
i've hit a brick wall
sounds painful
very
are there any cloud code experts here
cloud code + cloud save
js
I can write data but not read
๐ข
nvm got it working

just fyi you no longer need to use the js module since they added c#
any advantages?
