#💻┃code-beginner
1 messages · Page 120 of 1
The thing whose color you want to change
Oh, unless you're just asking for code.. maybe show us what you've tried.
Here's an example of how to access a random color from an array of colorscs [SerializeField] private Color[] _availableColors; public Color GetRandomColor() { int count = _availableColors.Length; if(count < 1) return Color.magenta;//Lack of colors int index = Random.Range(0, count); return _availableColors[index]; }
why cant i assign my gameobject to my variable
public GameObject EnemySpawnerHideout1;
is that a prefab?
no does it have to be
no
it seems to only let me add a prefab to it
is the code in the prefab script?
show the whole object that has EnemySpawnerHideout1
oh yeah i see it the object im trying to add the variable to is a prefab
how else should i try to access this object?
explain what you're trying to do
so my enemyspawner deals with how many enemies are left and when my enemy that is a prefab dies i want it to tell the enemyspawner that it died
so your enemyspawner should pass itself when spawning enemy
Show what you're trying to drag to what you're dragging to, full view.
how?
the link i've sent has an example, make method in the enemy script where you want to pass the spawner
follow the instructions in the link, but related to your objects instead
if you have trouble, be specific about what you're having issues with
the link has multiple options
For starters, if you have a prefab selected, you won't be able to drag scene objects into it as a reference.
it has 4 steps, which one are you struggling with?
That would in fact be what they were asking that you said no to
i thought they meant the spawner lol
so how would i get the gameobject i just instantiated
Instantiate(enemyPrefab, new Vector3(Random.Range(spawnPoint1.position.x, spawnPoint2.position.x), Random.Range(spawnPoint1.position.y, spawnPoint2.position.y), 0), Quaternion.identity);
this is how i instantiate it if that helps
instantiate returns an object do you see the example
i am but its really confusing like what is MoveToTargetExample
An example of type you can put anything there
When you put something they know there, they use it verbatim
when you put something they don't, it's the most confusing thing
what the hell do you use in an example, you can't win
but like what type do i put the script name im trying to add stuff to
and what is instance
Severity Code Description Project File Line Suppression State
Error CS0246 The type or namespace name 'enemyHealth' could not be found (are you missing a using directive or an assembly reference?) Assembly-CSharp C:\Users\vinny\Shadow Brawl\Assets\Scripts\EnemySpawner2.cs 58 Active
enemyHealth instance = Instantiate(enemyPrefab, new Vector3(Random.Range(spawnPoint1.position.x, spawnPoint2.position.x), Random.Range(spawnPoint1.position.y, spawnPoint2.position.y), 0), Quaternion.identity);
[SerializeField] private EnemyHealth enemyHealth;
If EnemyHealth is the name of the type, use it to declare variables of that type:
EnemyHealth instance = Instantiate(...
Hi. I wanted to make a change to the slider settings. I did everything with Weight, but not with the other parts (Weight is also of the float type). What is the problem?
Error:
Cannot implicitly convert the "float" type to "Unity Engine.Rendering.PostProcessing.FloatParameter"
did that now its worse
do .value
Severity Code Description Project File Line Suppression State
Error CS0029 Cannot implicitly convert type 'UnityEngine.GameObject' to 'EnemyHealth' Assembly-CSharp C:\Users\vinny\Shadow Brawl\Assets\Scripts\EnemySpawner2.cs 58 Active
Just because you did it wrong, doesn't make it "worse" lol
.saturation.Override(...)
Your prefab needs to be declared the same type. Declaring a prefab as GameObject provides limited utility, and I don't advise doing it in 99% of cases
enemyPrefab should be of the same type
not GameObject
That is not how you use a method
but also, I'm looking at the UnityEngine.Rendering version of color grading, so it may be a different method, or even a property for that post processing... take a look at the autocomplete options and their descriptions
so make my prefab this???
[SerializeField] private EnemyHealth enemyPrefab;
but wont that mess with stuff
If that's the type you want
then yes
mess with what
You will need to re-assign the reference in the inspector, but other than that, no
well considoring now the enemy prefab is now a script i think its messing with stuff
EnemyHealth is the name of the script im triyng to reference
You think wrong
I feel like you've completely ignored the instructions, the resources, and are just stumbling your way through instead
shouldn't that be your EnemySpawner field anyway?
Yeah that's kind of been the theme for them
because your prefab should be declared as a type on the prefab object, not the thing you're trying to reference
well its midnight for me i dont understand a thing
Then post again when you're willing to read
He threw off the way I understood and translated: Did I get the name for Saturation right?
then go to bed, and read the resource when you're properly awake
all i want to do is keep track of the remaining enemies
why is this so dang difficult
case you lack basic c# understanding
It isn't, but you're going to need to understand how code works
you can't just program by successive approximation
alright im gonna go to bed and figure it out in the morning thanks
learn what you are doing and then you'll see that it's actually simple
code means things
it's not magic
up to ....saturation. is correct, just re-type the last ., read the options available to you, and if Override is one of them, pass the value you want to it.
If it's not there, look for other methods to set the value. You can't assign directly to that property.
you put them in a List when you spawn them with spawner
when enemy dies it removes itself from list
enemy can only have this list with reference thru spawner.
spawner needs to give itself as reference inside enemy script
Better solution: Enemy broadcasts message when it dies. Spawner listens for that message and temoves that enemy from the list when it gets it
ahh yeah but i thought mix that with events and their brain melts
Fair
Oh, I get it. Thanks
I have a question: I have 2 options how to make graphics settings:
- Create public sliders fields for each section of the graph and write everything in Void Update.
- Create your own Void for each section of the graph and then assign each Void to each slider.
Which option is better? Or it doesn't matter (in terms of professionalism and ease of use)
not strictly code but idk where else to ask, im tryting to add an event system game object to my heirarchy and I cannot find where it is, can anyone help?
(if I need to move this question I will)
#💻┃unity-talk next time. But event system is in + symbol of the hierarchy view (under UI)
Does your object have a public or [SerializeField] private field?
Will do next time and thank you so much!
I didnt actually have an object yet, Im on a new scene trying to make a menu
Imo, the latter is better.
Hi all, I am new to Discord and have a question about reading a JSON file. I have the class setup for the JSON file and I can successfully pull the data from the server, and can see that it came in correctly in the Inspector. But I cannot figure out how to properly access each list item (they are all within the same script attached to an game object), for instance, if I want to update the textmesh to "elevator #301"
Thanks so much
Nevemind, I found that I have to put index number. so elevatorInfo.equipment[0].equipment_name
Which subtype should be written after the dot in order for the toggle system to work? If the slider needs "value", then for toggle?
the
[Header("Crouching")]
Not separate
the variable isn't serialized, so it cannot appear in the inspector
you know about this? how to amek this in C# the function is float A float B pick A(if true that pick a if false pick b)
Hello, like everyone else, im making an fps shooter, and I’m wondering how I should go about making a body and animating it to go with my guns, im not trying to have fancy animations, but im wondering how my hiearchy is supposed to go, because I know unity animator and hiearchy doesn’t like eavh other, im wonderjng, should the hands be added under the gun, or as a parent., and how does getting a new gun work if that. If anyone has done this well and or has insight, please let me know, i need it. I want a simple body, i can animate it all myself, but i need to know how to do it in the hiearchy, full body. I have the model and everything
Do you mean
float x = (PickA) ? A : B;
?
wait
i will explane the node
example:
A is 1.0
B is 2.0
pick A = true
Debug is 1.0
if
pick A = false
Debug is 2.0
like this
How to find the class that destroyed a gameObject? My gameObject is destroyed when I start the game but I can't find what does it.
so that is what I have written. x will be A if PickA is true or B if PickA is false
dont cross post
you have to search the script that calls destroy and having reference to the gameobject
There is not any API for that? I searched for it but couldn't find it, I use a networking lib too
can you make an example about this? i can make all except select in
i know nothing on network behaviour....
Sorry, no, I do not understand Visual Scripting, it just makes no sense to me
i will description with word
A = max clip size
B is CurrentAmmo + Total Ammo
Picka = CurrentAmmo + Total Ammo >= MaxClipsize
step by step
bool A=currentXXX+totaXXX>=maxcliXXX;
if(A){
return maxXXX;input to A
}else{
return currentXXX+totaXXX;input to B
}
i can't understand
just take what I have written and do the symbol replacement
float x = (PickA) ? A : B;
PickA is bool?
A and B is float?
yes
i just assume the top link to the left hand side of >= and bottom link appears in the right hand side.....
float x = (CurrentAmmo + Total Ammo >= MaxClipsize) ? MaxClipsize : CurrentAmmo + Total Ammo;
i'll try
Try doing a project-wide search for the keyword "Destroy", if your using VS, you can use Ctrl + F and expand the search to "Find All"
Or just directly find reference to Object.Destroy
Thats also an option, though you may have to already know where at least one "Destroy" call is in your code
Or put one in temporarily, or if your IDE is good enough go to Object.Destroy via search
Im genius
yeah, like false does not exist
false is just !true
In a typical setup, whatever object the hand should control (as in, where the hand goes, so does the object in question), the object would be a child of that hand, so in your case, you may want the weapon object to be a child of your hand bone - whichever hand should grip the handle could have that object as a child, you can also use IK nodes to position the hands around the various parts of a gun (for example, youd hold a pistol differently than youd hold a rifle or grenade) - this way you only need to change the object that is a child of one hand, and the animations playing on that rig, provided that you have relevant animations for all the states that object could be in (such as idle, reloading, etc), Animator Overrides may help with weapons that share similar states as well - you can also use AnimationEvents if you have code that should happen at certain frames of an animation, like ejecting a magazine at a certain frame of a reload animation - that said, full body animations are kind of difficult with an FPS camera from my experience, especially for multiplayer (scaling and alignment/correct posing can be difficult to look good in both third and first person on the same rig with the same animation), so typically games will have just the arms in first person, and a separate full body animation that others see - and keep in mind, many ways to approach a problem, I use a similar approach for my game
hey can i get some good resource to get started with unity addressable for dynamically loading Scenes
check the asset store tab i think there was one like 3 links down haven't tried it myself but its something might lead you in the right direction
how can i get the gameobject Flag from a script in the Checkpoint gameobject
Flag has a tag "Flag" but there are 5 other Flag gameobjects as well so just searching by tag doesnt work
Flag is a child of Checkpoint every time
- reference it in your script
- transform provides bunch of methods but none of them find child by tag
this is what i have currently but i think it gets every Flag gameobject
well can i just get the child without a tag?
since you find it in awake so i guess this object is not spawned in run time, just reference in your script
also other component
wdym reference it in your script? isnt it referenced now?
https://unity.huh.how/references/serializing-component-references
mb, reference it in inspector
yeah but then ill have to drag n drop it everytime i wanna create a new checkpoint
which is kinda impractical imo
each checkpoint has to have reference to it's flag
just make a Checkpoint class and assign the flag in the prefab
then you can always get the checkpoint's flag easily
checkpoint.flag
open the prefab, drag and drop the reference, ctrl+s
lets say i have multiple scripts to control (close) a dialog, a popup
however, because theres multiple scripts calling it to close during runtime, is there any chance for me to find out which one called it to close
like the exact one
i have no idea how many script and function calling it
I have a fighting game where the name of the character selected appears when hovering over the button by using the name of the sprite for the image but my script isn't working. Here's the source code:
hello I'm trying to make a flight simulator, and I was wondering if i need a rigid body to make my plane flight, because I was thinking about just calculating all the 4 forces ( drag, thrust, lift, weight) and apply them to my plane. And I want to know if this will be enouth or if I need to use a rigidbody ?
Sure. You could use a breakpoint in the close method and then look at the stack trace.
Or if you prefer logs, refactor your close method to take the caller object. Then print the name of the caller object. Or add logs at every point where close is called with logging the relevant info.
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 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.
ty
Well, you'll still need to apply forces to a rigidbody. And without it you'd basically need to implement a lot of what physics system already does for you.
what do you mean?
Look below at the bot message.
Share your code properly if you want people to have a look at it.
//public class ChooseButton : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
{
[Header("Elements of Faction")]
public TMP_Text chooseText;
[Header("Elements of Leader")]
public Image imageOfLeader;
private string nameOfLeader;
string currentLeaderName;
public void OnPointerEnter(PointerEventData eventData)
{
nameOfLeader = imageOfLeader.sprite.name;
var pos = nameOfLeader.IndexOf("ChoicePic") + 1;
int length = nameOfLeader.IndexOf("ChoicePic", pos) - pos;
currentLeaderName = nameOfLeader.Substring(pos, length);
chooseText.text = currentLeaderName;
Debug.Log(currentLeaderName);
}
public void OnPointerExit(PointerEventData eventData)
{
chooseText.text = "Choose Your Character";
}
}```
like this? My problem: I have a fighting game where the name of the character selected appears when hovering over the button by using the name of the sprite for the image but my script isn't working. Here's the source code
oh ok I see
Define 'not working'
I try to move the mouse over the button but the name of the character doesn't appear in the textbox
does it debug?
no
are there errors in the console?
no, there's no message on console
Ok i get it, but im still confused on how my hiearchy works, and wdym seperate full body,
here's the image of the gameobject:
Do you have a PhysicsRaycaster attached to your camera?
no
add one, the IPointer interfaces need this to work
other buttons work, but this one doesn't don't know why
still doesn't work
I have physics2draycaster
how do i make an ui element clickable (left and right click) and hoverable?
wait a second, this is a different script, this is not ChooseLeaderButton
thanks!
it's the same, just changed the name
what?
I changed the name of the script to share it here, but the old name is in my project
the code is the same
the raycast target is enabled but it still doesn't work
yeah, well that was like 1 of the 5 things to check
and each one of those things have about 5 things each
I have an event that gets invoked when I change action maps and was wondering, should I make an interface for scripts that need to subscribe to this event? trying to figure out when / how to use an interface. is this where you would use an interface? or is it useless
I have: a graphic raycaster in the canvas, an eventsystem in the scene, raycasttarget enabled, no troubleshooting overlaps and a standaloneinputsystem on the eventsystem
don't know what I'm missing
no troubleshooting overlaps
What does this mean
looking at the webpage you shared, there's no raycasttarget enabled that overlap when hovering the mouse button over the character selection button
so what does it show in the event system when you hover your element?
ok, the problem was that the foreground image had the raycasttarget enabled, but now when hovering over the button I get a console error:
read the stack trace, re-read the error, look at the code it's talking about, and think about it
help in c# please?
I never put this object in?
Not a code question; and it's the render pipeline debug object. Ignore it
not code question really, DDOL scene is for storing the dontdestroyonload objects
Ok
why it giving me error
because that's not how you initialize a struct
i fixed, thx
I understand that the length variable is giving me the error due to being of value 0 but don't know how to change it, so when reading the name of the sprite of the character to get their name and make it appear on the textbox it just takes the name of the character and not the full name of the sprite
being of value 0
the name of all the images is ChoicePic followed by the name of the character, for example: ChoicePicAlex or ChoicePicJohnny
and only make Johnny or Alex appear in the textbox
Then why are you trying to calculate the length by finding ChoicePic at another index after the previous pos you found it at + 1?
var pos = nameOfLeader.IndexOf("ChoicePic") + 1;
- int length = nameOfLeader.IndexOf("ChoicePic", pos) - pos;
and then passing that value, probably -1 into Substring
that was code somebody gave to me so didn't know
do I just delete the line and leave everything the same then?
no, understand your logic and rewrite it so it makes sense
I'm lost, I've been looking at it and don't know what I'm doing wrong. The error is gonem, but the script still doesn't fully work. I've changed the section of the script and I get the name of the image but the name of the character doesn't appear in the textbox and the section ChoicePic isn't taken from the name:
This may be a stupid question but should i utilize more the drag & drop mechanic instead of just writing everything in code?
bcs rn when i Instantiate an object
I find them by code
Depends on whether you like reinventing the wheel or not
instead of using drag and drop
ok, that partially works now, the only thing missing is for the name to appear in the textbox
thanks
I kinda like it
I used this on this here
I've started to think about it, if its faster to instantiate since the object is already saved in the variable bcs of the drag & drop
And i don't have to look for it
If you are kinda catching my brain wave
This is great for modularity & the composition design Unity also promotes
But you should not use instantiation too frequently, use a pooling system for stuff that can get recycled
That would make more sense if i understand what a pooling system is that is
Basically predefine the objects
It's like you throw a killed enemy into a recycling factory, then the factory workers "recycle" that enemy into basically a new enemy without having to use materials for creating one from scratch
Oh yea
You don't need pooling until you start instantiating and destroying the same object dozens of times a second
Use it if you notice performance drop and can pinpoint that instantiation is the problem
No, it's overkill
Oh
Switching between 3 objects once every 15 seconds does not need a pooling system
Pooling is great for stuff like bullets which can be recycled easily
📝 noted
Also, if you expect to have many different recyclables (aka. pool types), I strongly recommend you to research into generics and create a PoolManager or similar that handles pooling of all kinds of different classes. Otherwise you'll enter into a what I call "pooling hell", where you'll be copy-pasting boilerplate pool code when you want to create a new pool type
Or just use one found in the Asset store or anywhere else, because I think there should be some prebuilt in there
VS related question
lets says i have:
text
-text1
--somestuff1
-text2
--somestuff2
if i collapse text1 and text2, then text
later i expand text, text1 and text2 will still be collapsed
is there a shortcut or something that expands all collapsed text inside a collapsed text ? (if this make sense)
exemple
so here after i collapse text1 and text2, then text, i press shift+mouse click on the "+" and everything shows
Alt + click..?
nvm didn't see it was Visual Studio related
i tested alt, ctrl, shift
what is the alt+click for then ? in unity i mean
curious
If you have Unity open, you can test it right now. Go into your project tab and hold alt while clicking the "Assets" folder once or twice
Well for example, my hierarchy looks something similar to this:
Player (rb, scripts, etc)
-> (skinned meshes)
-> (bone rig)
--> ... Right Hand Bone
---> ... (finger bones)
---> holder (empty transform)
----> Some Weapon Model
If I want to change which weapon the player is using, I change the child of holder, which is attached to the bone rig of my player hierarchy, it could be a weapon, apple, bottle, etc, you can play any animation you want since that only affects the rig (assuming your rig is an armature/humanoid), so in a setup like this, playing a "reload pistol" animation would force whichever weapon or object that is a child of holder to follow the right hand during the frames of that animation - I may have also misunderstood what kind of FPS experience your going for, as there are multiple ways to make an FPS, for example if you wanted to have your character "aim down sights" with a rifle, posing an animation with 1 full body rig may be doable, but difficult to carefully align what others see, and what the camera sees, some games will use 2 rigs to help with this, where the rig the camera sees is only of the arms to help with positioning, and the rig others see is only of the full body, to communicate players actions, you may see something similar in FPS tutorials as well, not sure if that helped clarify some things for you
Or click basically anything nested, whether that'd be array/list containers, hierarchy objects..
ty for the tip
its also exactly what i want, but in VS 
Worth trying
Ctrl + M + L seems to work but you can't control what it expands/collapses, it does it to every element in the script
yeah i already saw that on google, i was looking for a "mouse" solution soi can keep a hand on my mouse
ty for loooking tho
@wild cargo
this is the script that's on the instantiated object:
using UnityEngine;
public class Customer : MonoBehaviour
{
[SerializeField] private Sprite[] wrappingPaperOptions;
[SerializeField] private Sprite[] stickerOptions;
public Sprite wrappingPaperImg;
public Sprite stickerImg;
void Start()
{
wrappingPaperImg = wrappingPaperOptions[Random.Range(0, wrappingPaperOptions.Length)];
stickerImg = stickerOptions[Random.Range(0, stickerOptions.Length)];
}
}
this is what it looks like in the editor
Were there any exceptions logged in your "Player.log" text located at "AppData/LocalLow/StudioName/GameName/"?
You can get to appdata by just WIN + R and type "appdata" in there
i'll check rn
there aren't any exceptions, assuming the word "exception" is supposed to exist somewhere in the file
So assuming Start() still runs in the build, there are elements found in the list but some of them might be null..?
Because if the lists were empty it would return an IndexOutOfBounds exception
Maybe you're assigning a null sprite into the variable
change Start to Awake
They said it worked in the editor, not in the build though
With the Start()
exactlly, script execution order problem
i've thought of that but haven't tried it, ig i'll try rn
Probably not because the order should not change in editor vs. build
That's not true though
the one thing you can guarantee is that is not the case
How can I make, that VS2022 does open every script in the same window?
now the objects won't get instantiated :')
No, it is, because in my game for example I've changed the Script Execution Order somewhat heavily (don't judge me, I know it's bad practice), and the game runs fine without exceptions in the build
interesting thing is, again, works just fine in the editor, build acts differently though
Of course, when you hard code the order, not when you do not
Of course that works because you've specifically defined the execution order but if you don't do that the order is non-deterministic
So it's not alphabetical in those cases like I thought it was?
no
Wow ok
why not, you have just changed the execution time of the script slightly and as it has no external dependencies it will make no difference
🤷♀️ I have no idea, in the editor it works just fine, when i build it, it all goes to hell :')
should i change Start() to Awake() in my game manager too? or just the customer script ?
so what happens when you change Start to Awake in that script?
the objects don't get instantiated
How you connect Visual Studio to Unity?
It doesen't even show me word like "Gameobject" and it opens for every script a seperate window.
which objects?, that script does not instantiate objects
the objects that have that customer script on them don't get instantiated anymore
which will have nothing to do with the change you just made
Edit->Preferences->External Tools->External Script Editor
!ide
If your IDE is not autocompleting code
or underlining errors, please configure it.
Select one:
• Visual Studio (Installed via Unity Hub)
• Visual Studio (Installed manually)
• VS Code
• JetBrains Rider
• Other/None
what am i supposed to do then :')
And now? VS 2022 is already selected.
try here i guess
what else did you change?
that was all i changed, in the script i sent earlier, changed Start to Awake
What should this show me?
I already have VS 2022 installed and also with the Unity conponment
And also selected in unity
apart from that script? Because changing Start to Awake would not stop the GameObject from Instantiating
Ok i changed, Start to Awake in my game manager too, it seems to work now, thank you very much!
I suggest you look in the docs at Script Execution Order
as i said, at the time, the only change i had made was inside of the customer script (the one that i sent earlier), but doesn't matter now since it works after changing start to awake inside the game manager
i'll look into it, thank you
you may need to go to vs installer and install the addons there. If you got to your file explorer and search for visual studio installer.
are there more than just "Gamedevelopment with Unity"
there is a bunch of different one
I'm also have installed Gamedevelopment with C++ and .NET-Desktopdevelopment.
I cant select them to see what single conponments are inside because I would completly disbaling it by clicking on it.
How can I see what single conponments are installed in VS Installer, without disabling everything by clicking on it?
If this is the correct ide(a bit sus that it says "internal") that have the unity workload installed, then you just might need to regenerate the project files.
What Tab?
by clicking with tabulator, it will select, but dont show the insides.
What insides are you looking for?
IDK, but if I disable and enable it again, it shows me stuff to download, so I will lose my selections inside.
IDK what I need, I thought Game development with Unity is enough for Unity.
It is enough
I try to have as less as possible because I dont want stuff installed what I'm never gonna use.
Besides of the storage space, every plugins also needs updated what makes it even more anoying if you dont even need those.
You only need the unity workload
But is there a way to see what plugins are installed in what package, without deselecting everything by clicking on them in VS Installer?
hey, i have a question about reading variables from other scripts... The script where the variable is in is attached to different objects and those have different values for the variable. Anyone knows how to do this?
You can see all the components in stalled in the "individual components". And on the right in the "instllation details".
Use one of the Find functions or reference it in the inspector.
But if I click on it, everything gots disabled and by reenabling it, the configuration will be reset and is not the same anymore like I had might choose before.
It's not gonna reset anything if you cancel (click the x button) afaik.
But anyways, I don't understand what you're trying to achieve by messing with the workloads.
how do i use a find function for multiple objects
Wdym "how"? You call it.
For details and examples refer to the documentation page.
https://docs.unity3d.com/ScriptReference/GameObject.FindGameObjectsWithTag.html
don't use Find functions, they are really not recommended
there are multiple other ways of referencing your components
for example?
As a new dev, keeping references to game objects you need can be a little confusing. Learn how to store game objects for later use as well as allowing external scripts access to your goodies.
Instead of trying to find an object, shift your thought pattern a little and ask "should I already know where this object is?".
❤️ Become a Tarobro on ...
guys i dont understand whats happening(yes im new to this)
thats not how you share errors and ask for help
0 context, screenshots, 0 call trace
your weapon is not referenced
meaning it's null
you literally had it explained in the error
and thats why i showed you the error
i didnt clearly know what it meant
so i asked
but it literally says "object reference not set to an instance of an object"
i said the same
forgive my simple mind. i wouldnt understand a sentence even if it was said in clear comprehensive english
thx
add your object to the script
in the inspector
yea i fixed it. thanks
is there any way to fix a broken unity scroll rect? i accidentally tweaked the viewport and it completely broke, not undoable
essentially every property inside of content was set to NaN (thanks, unity) and it doesn't let me set it to anything else
how to make it so that i loop everything and trigger shoot in the same frame with different seed?
0.00001f doesnt make any sense unless your fps is > 1/0.00001=100000frame pre one second
and why you need different seed?
instantiate many object go in different direction
in one frame
oh right i've using the wrong value type then forgot about it
why does the game over screen not show? The player deletes but the ui never shows
first use comparetag
second please dont find object every frame, instead the player fire some method on GameOver to inform GameOver know he is died
third gameObject.SetActive()
also you can get the gameobject collides with by the collision parameter
where should i use compare tag?
in where you compare the tag (calling .tag)
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 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.
like that?
then you are calling CompareTag on the gameObject itself, not the collision
it should show tho if the player is tagged correctly and the script is attached
to the ui
also did you mean objectwithtag vs object(s)with tag
How would one go about having procedural sprites for abilities? For example creating a sprite for a "circle, firey effect, cold effect, 25px radius" kind of parameterization. The use case is something along the lines of a spell creator, where you can alter the size of the spell (bigger radius = more pixels needed for sprite for it to not look out of place), or add certain effects, each of which should hopefully apply (e.g. one adding a trail, one changing the color etc.). I assume i'd want to create this one and cache it, but what exactly am i creating so to speak, a sprite? A shader? I don't need a very low level breakdown, more so just a rough direction of what to look into
Sounds like shaders would be involved
What you would be creating for each spell is probably a material which holds the settings for the shader
would i just be applying multiple materials, 1 for each modifier
Each modifier could have its own shader pass, I guess yeah.
Or you can have a monolith shader that does it all
Hey, i have a simple script thats attached to a platform that makes the player the child of it, so that it moves with the platform. But for some reason, the scale of player drastically changes when this happens, even though the scale of the platform doesn’t change and i have no idea why
when you child the player to the platform the player will take on the scale of the platform
Is there a way to stop it doing that
yes, have the following construction
Empty GameObject
--- Platform as child
--- Player as child
Then the player won’t follow the platform though
since the platform moving shouldnt move the empty game object
yes it will if you move the Empty GameObject rather than the platform
You could just SetParent(platform, true), with the latter set to "true" it will keep the same scale as b4
where do you get that idea?
Idk knowledge..?
the second parameter is for position not scale
No, you're talking about Instantiate
no, preserve all scale, rotation and position
https://docs.unity3d.com/ScriptReference/Transform.SetParent.html
Anyways they could just write SetParent and the IDE would tell them the bool's pos regardless so
If true, the parent-relative position, scale and rotation are modified such that the object keeps the same world space position, rotation and scale as before.
Unfortunately that did something really weird that didn’t really help
What'd it do?
Use true instead because I wrote false not knowing it actually does the opposite of what you wanted
That is, if you tried the SetParent approach
im not really sure
the platforms all dissapeared
the cube player became a big cuboid
then fell
And you used true in the SetParent()?
Ill put my code in a sec
ive tried true and false
it should look like this:
player.SetParent(platform, true)
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 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.
void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.name == "player")
{
collision.gameObject.transform.SetParent(transform,true);
}
}
void OnCollisionExit(Collision collision)
{
if (collision.gameObject.name == "player")
{
collision.gameObject.transform.SetParent(null);
}
}
}```
this is the code i used thats attached to the platform object
Maybe use true in OnCollisionExit's setparent
Or maybe it's already true by default idk
You have to fix the scale of object you parent, no way around it
main "root" gameobjects should not be scaled at all
if i make the scale 1 on the parent it returns to being a cube
if they have a mesh, mesh should be child and be scaled like that
but id like it to be a cuboid
again, you make it child of parent and scale the child
you never scale the main object for graphics, ever
graphics are just for visuals, and should always be child of main obj
Box collider,s rigidbody etc. all go on the Main Object, unscaled
scale box/colliders with the gizmos in inspector
Let’s say I have a try catch function with three lines of code in the try. If only one of the lines of code in the try function produces an error, will the other two lines still run?
no
So nothing in the try will run if anything produces an error?
exactly
Great, thanks!
I am going to create a Quest Board System. What should I learn to do so? What is the most common way people do this.
Scriptable Objects
QuestManager + QuestData (SO) + Quest (MB/serializable class)
Thanks!
can someone teach me coding?
just search youtube
nah
nah
then no
lol
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 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.
hmmm okay.
50$/hour dm
wdym you can't override
weapon instance class :https://hastebin.com/share/tecologodo.csharp
bullet instance class : https://hastebin.com/share/ezavekipul.csharp
its having the same value as the weapon scriptable object
i overwrite the speed and range to randomspeed and range
nah
then no
which method shoot ?
When i use transform.position = new vector3(10,0,0) Am i moving the object 10 right or am i moving it to the coordinates 10,0,0
you're moving it to 10x
All you need to know
if (cantBeArsedToLearn) answer = "nah";
Console.WriteLine(answer);
world pos
k thanks
Then perish
answer was not defined
oh shooting is trigger through an event in my weapon handler class
yes it was, class variable
you override the range from SO in bullet script
at start
void Start()
{
Range = Weapon.RangeModifed;
speed = Weapon.shootSpeedModified;```
so you instantiate with random speed, and then your start method runs
i need it so it will work with normal weapon which not set random range and speed
then fix the flaw in your current logic..
oh i see so all of this run before start?
i kinda get it somehow
well yeah thats on object creation @woven crater
ah right make sense ...
You should make method from bullets itself
for Init the values
then you can pass maybe a bool or weapon type to determine if you're getting random or set values
thank
Is there a function i can use that finds the parent of an object?
transform property holds children and parents
yea
ok so yuo have code errors
also make sure to configure your IDE
!ide
If your IDE is not autocompleting code
or underlining errors, please configure it.
Select one:
• Visual Studio (Installed via Unity Hub)
• Visual Studio (Installed manually)
• VS Code
• JetBrains Rider
• Other/None
i use visual studio
if you forget braces or something you get tons of errors in editor should highlight like so
this is the code
is there a difference?
pretty big
huge difference
and you are obviously missing both an { and a }
click the VSCode link then
ive never coded before
make sure you did all the steps
alright
might need to install .NET SDK at the end
then you nead to !learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
Code wise, are components fields within a gameObject?
no
components are not fields
they are Components
How are they related to gameobject?
they must live on one
Like I can say gameobject.transform, so isn’t the transform component a field of gameobject?
no its a property you're using from the transform component
you can think of it as Components belong to a GameObjects but are seperate entities from it
Code wise, how does that work?
how long does it take to get decent at unity?
is there a way to get the name of an action map when accessed through the c# class?
I tried it like this
void SetInputListeners(InputActionMap actionMap)
{
switch (actionMap.name)
{
case InputManager.Actions.Exploration.name:
//subscribe to Exploration inputs
break;
}
}
but the Exploration.name isn't a thing
A field is a reference TO the component, not the component itself
Components are attached to gameobjects
Like when you say belonging, what does that mean?
depends on how quick you learn and how much effort you put
alright
AddComponent, GetComponent
ive heard unity charges you per download, it it true?
no
Not a code question
See here #archived-pricing-updates-talk
only if you earn more than a million dollars in revenue and have 1million downloads, its per unique install after (once per user)
You can choose if you want that billed or 2.5% revenue
So would transform in gameobject.transform be an instance of the Transform class and a field within gameobject?
It means, effectively, the GameObject owns the Components
im done
It comes inherited from Component
The instance of transform attached to the gameobject sure. The .transform field is just a reference though
i might rewrite the code
not a field within GameObject.
gameObject is a standard property of a Component referring to the GameObject that owns it
transform is a standard property within a Monobehaviour referring to the transform on the gameObject that owns both objects
you see here its a public get
but extern
meaning its going in external library
[NativeHeader("Runtime/Export/Scripting/Component.bindings.h")]
[NativeClass("Unity::Component")]
[RequiredByNativeCode]```
@thorn holly you can still traces of old componets you can do on MB like .light , thats why you get squiggles when making a field called light in MB
You did all the steps ?
show me if its configured then
i think i did
i installed visual studio
don't think, be sure
how to i know if i did it right?
when you open script from Unity in VS you will see all your errors underlined red
@rich adder I think I get it, so if you have an instance of a component, the gameObject property is simply a getter/setter reference to the instance of GameObject the component is attached to?
alright, ill look
close but not quite
its all an Object
GameObject is part of it
As in GameObject extends from Object?
GameObject is a class which inherits from UnityEngine.Object. gameObject is a Property which contains a reference to the instance of it's GameObject class
So when you make an instance of Object, does it also make an instance of GameObject and Component?
@rich adder
depends how you make that instance
it doesnt work
now look at the red lines and see what is missing
right
you just need to write proper syntax
how you arrange the code
what do i need to change
start with the first underline red
this is what i want:
do what you've been told to
yeah
If you make an object through the editor, then what happens?
what is the difference in these 2 lines?
the 2nd one is longer
I am dead serious
mate, even look at your code and the dam video...Com on.. you don't see differences?
not really
the red
if you don't get your glasses asap
no
you dont see ANY difference?
the color
They are being serious. Look at the lines above the scenemanagement one in you OWN code. They have something that line doesn't have
Not the color at all
man, programming is definitely not for you
@peak dock what does the first line have that the second line doesn’t?
then learn the basics of c# first
you can't get help if you dont understand the help
that line thing
how I add all the results into a list?
its getting better
no its getting worse
this is a sentence.
this is a sentence
what's the differences?
the dot
the period
how you can't see ANY difference between the tutorial code and your code
you must be blind then im sorry
man, just go and learn c#, this is going nowhere
so why didn't you see that in the code with ;
; these symbols actually mean stuff in coding..
iterate over the Collider2D[] and add each element to your list
Collider2D[] arr = Physics2D.OverlapCircleAll(...);
yourList.AddRange(arr);
so until you learn what they are, you will struggle HARD
@peak dock srsly just go do a c# course
oh thanks-
what does arr mean?
Also @languid spire if I make a new object in the editor, does that make an instance of Object, GameObject, and Component?
just tell me what to change please
and i will learn
oh okay-
that won't teach you anything
it will
depends how you make that instance
instead of making me guess
we are telling you
you already should know what to change by looking at difference between the video and your code
I answerd that above, it depends how you make the new Object
but you dont understand it
as i said, you cant get help
if you dont understand what we are saying
@peak dock you’re not going to learn anything from that. There’s a difference between following directions and understanding what you’re doing
can you use a nav mesh with most 3D environments
What if you make the object through the editor?
wdym make object through the editor?
what that mean "most 3D enviroment"
Sorry the inspector ig
i dont know what to look for
you cannot make objects throught the inspector (not mentioning custom inspecotr buttons to instantiate things)
So take a c# course so you do know what to look for
you mean AddComponent, it's the same in code or the Inspector
because you lack the basics of c#
C# BASICS google it
no
jezus fucking christ xd
its worse
fixing this masterpiece of a code
wear your glasses, zoom 200% on the video and on your visual studio
look on the differences
and make it 1:1
either show you put some effort into learning or find another place to get help... Don't be foolish
Man, close Unity and just go back to playing games
I’m confused. If I right click in the editor and make a new 3d object, what is happening in code? Is a new instance of GameObject being made? What exactly happens when I do that?
you guys are just jelous that im learining so fast
Hi Everyone! I'm quite new to game development as I'm an undergraduate pursuing a computer science degree. My school project requires me to come up with a pizza-making game to teach people about math. The gameflow is basically
Step 1: Chef explains step 1 via dialogue box, then the game will require user to execute some actions. After executing the action, step 2 will be triggered.
Step 2: Chef explains step 2 via dialogue box, then the game will require user to execute some actions. After executing the action, step 3 will be triggered.
This goes on for a few steps, maybe until step 5.
The logic I have come up with is basically a DialogueManager, which is used to manage the dialogues, then GameManager, to manage the flow of the game and GameUIManager, to manage the UI of the game. Basically GameManager will trigger the DialogueManager to start the dialogue for step 1, and at the end of the dialogue, the GameManager will be triggered to trigger GameUIManager to display the UI for step 1. At the end of the step 1, I have a step tracker, called currentStep, which will be incremented and thus Step 2 will be called. However, as I have coded the basic game flow, I realise there are some bugs which I am unable to fix it.
For step1, everything is executed properly. However, as the UI for step 2 is being displayed, the DisplayNextSentence() function starts to become a little wonky. Could anyone help me with this?
Yes, you can think of it as a new instance of GameObject and a new instance of Transform which is owned by the GameObject instance
well do you have any code?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class Dialogue
{
//public string name;
[TextArea(3, 10)]
public string[] sentences;
}
you might want to watch some dialogue tutorials on youtube, as your questions is so general to help you with all of it
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GameManager : MonoBehaviour
{
public DialogueManager dialogueManager;
private int currentStep = 1;
[SerializeField] public GameUIManager UIManager;
// Start is called before the first frame update
void Start()
{
Debug.Log("this is game manager");
dialogueManager.StartDialogueManager(dialogueManager.stepOne);
}
public void NextStep()
{
currentStep++;
switch(currentStep)
{
case 1:
dialogueManager.StartDialogueManager(dialogueManager.stepOne);
//execute step 1
break;
case 2:
Debug.Log("This is case 2 of NextStep()");
dialogueManager.StartDialogueManager(dialogueManager.stepTwo);
//execute step 2
break;
case 3:
dialogueManager.StartDialogueManager(dialogueManager.stepThree);
//execute step 3
break;
case 4:
dialogueManager.StartDialogueManager(dialogueManager.stepFour);
//execute step 4
break;
case 5:
dialogueManager.StartDialogueManager(dialogueManager.stepFive);
//execute step 5
break;
default:
dialogueManager.StartDialogueManager(dialogueManager.stepOne);
//execute step default
break;
}
}
public void ExecuteStep()
{
switch(currentStep)
{
case 1:
UIManager.StepOne();
break;
case 2:
//execute step 2
break;
case 3:
//execute step 3
break;
case 4:
//execute step 4
break;
case 5:
//execute step 5
break;
default:
UIManager.StepOne();
//execute step default
break;
}
}
}
i'd make dialogues as scriptable objects, some kind of dialogue manager
Wdym owned? Like I can’t just say in code GameObjectInstance owns TransformInstance
and integrate it with input system
this is awful code
yupp i did it already just that after putting everything together, something seems to be messed up
what if you have 30 steps?
holy shit ever hear of an array ?
oh theres only gonna be 5 steps at most
sure but make things the right way
maybe year 1 student
even a CS crashcourse tells you about collections and O notation xD
and all the variables stepOne stepTwo
yeahh i just started year 1
😮💨
if you say in code
GameObject go = new GameObject():
that will create an instance of GameObject and a instance of Transform which will be belong to that instance of GameObject
😦
adding 6th step is too much work instead of just drag&drop the scriptable object into the list of dialogues for example
SO might be overkill
yea for that project
a simple json with the lines, scroll through the array of strings
dude if you're copying a video then copy it ..
and, no, instance of Transform cannot be transfered to other GameObject instances
Visual Studio Warning:
"Screen.SetResolution(int, int, bool, int)" is outdated: "SetResolution(int, int, bool, int) is obsolete. Use SetResolution(int, int, FullScreenMode, RefreshRate) instead."
Why? I use Unity 2023.2.3f1 and why does even the Unity Documentation say, that it is still wroten "Screen.SetResolution..."?
good luck making other functions and mechanics mate
my dialoguemanager is even worse...
thanks for the motivation guys
i'd say start from scratch
im quite lost in this whole thing tbh
it is pain in the ass already to work with that dialogue system
not that diffcult, you're just working with a bunch of strings.
that's a good tutorial for a complete begginer
Let’s make a Dialogue System that you can easily tweak to suit your game!
● Listen to the Podcast: http://bit.ly/2un4o0m
● Download the Project: http://bit.ly/2t45YYc
● Download the Font: http://www.dafont.com/6809-chargen.font
● Singleton: http://wiki.unity3d.com/index.php/Singleton
♥ Support Brackeys on Patreon: http://patreon.com/brackeys/...
just look up how to do that in c#
actually i followed that tutorial
Hello, i have made a script that with it you can change the skins but when i click one it dosnt load the skin and let default skin the code is https://paste.ofcode.org/b2yjT5RfBESERxiNhAfxmS
because i want to make it such that step one instructions will be displayed, and users have to execute a certain action
Oh I think I get it. So if I said go.transform, transform would be a property that references the new instance of Transform that is created when go was created?
then step 2 will be displayed, and users have to execute a certain action
still, you can do this following the tutorial
exactly
if you ever find naming things somethingOne, somethingTwo you need a collection. Like array
guys it doesnt work
What was supposed to happen?
im making a start button for my game, and i wanted it to load the game
did you assign the function to button's on click event?
yeah just that i was confused as to how do i transit from displaying the dialogue to allowing the user to execute a certain action at a certain point of the dialogue
can someone help me with this
learn how to ask for help
No. Not without actual information
what is that
what information more you need
You could probably slice the sentence into different words, and when you hit that particular word you call a Method

Code of course
SetResolution has multiple overloads. The one you're trying to use, which takes two int, a bool, and an int, is obsolete. The other overloads in that screenshot are still valid. The warning/error suggests the correct overload to use
what information do we need in CODE channel?
how long does it take to learn c# coding or whatever its called
for you? years i'd say
Unanswerable
depends how fast you are at learning.. so far..you might take a few years
a real kneslapper pal
!code
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 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.
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 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.
Dude, there’s no need to be a jerk
double kill
sorry bossman
Read long code blocks
well you refuse to learn the proper way, thats not a good sign of wanting to learn
Hey, he was being optimistic
I dont get it? What is wrong by using it and what should be better used?
Currently, I use:
Screen.SetResolution(Display.main.systemWidth, Display.main.systemHeight, true, 60);
I am trying to make a object I brought from blender clickable
I put the "Button" Component on the object and changed the OnClick values
But nothing happens when I click it, it doesnt hit my visual studios breakpoint (when other methods do)
The purple parts are the objects imported that have the Button component
Any help appreciated!
Edit: SimonsSaysObject is a CanvasGroup
anyway, the code for dialoguemanager is this..
https://gdl.space/osajedovet.cs
so you're using a collection already with Queue
why did you make stepOne,stepTwo,etc..?
As versions move forward, some features are obsoleted. For now you're getting a warning, in a later version you'll be getting an error.
And again, the correct overload to use is the one mentioned in the warning message:
Use SetResolution(int, int, FullScreenMode, RefreshRate) instead.
So if I make a new script, that makes a new instance of Component. If I say gameObject within that script, that’s a property referencing the GameObject the script is attatchements to. Lastly, if I say gameObject.transform, that’s using a property to reference the instance of GameObject the script is attached to, and then transform is a property of that GameObject that references the instance of Transform that is attached to that GameObject?
because i didnt know how to transit from displaying step 1 to a user-executable action, without making everything in just one script
youve got it
Holy hell, that was a struggle. Thank you so much though, I’m glad I understand something that I’m never going to use XD
pseudo code:
if player presses certain key
proceed to another queue step
you will
the same way you scroll through sentences
unless you move to another engine
so for late response, like my 3D world i made for the enemy to path in
why would navmesh not work ?
i never refused, i just wanted to make a home menu quick
you did atleast several times
i've never used it before i just wondered if i'd have to find new options
"I just wanna do..." insert thing. Is common to someone who refuses to take a step back and revisit the basics before jumping head first.
Im serious search it in this discord, you will see
it will work
try it first, if it doesnt work then ask
ask chatgbt to make the script for you 🤩
so i should make all the instructions in one queue?
well if you have all the steps in a queue
you dont need variables such as stepOne stepTwo
you already have acces to the first, second step inside the queue
one more wrinkle in the story
if you do
Instantiate(obj)
and obj is a GameObject it will create a GameObject and a Transform
if obj is a prefab it wil create a copy of the prefab
if obj is a Component it will create a GameObject, a Transform and the Component
Hi everyone. I am making a game where a player can go on a hover board (2D top down) and when the player goes on the board I want the player to be able to look where they want but the boards rotation to be the same as the direction its travelling in. In simpler terms I want to be able to find the direction the board is travelling in only using the players current velocity. How would I go about this?
Oh, now it works, I was confused because of it doesen't show the "Screen."
Please help me with this
seprate them into two different gameobjects ?
Heres my suggestion. Do a c# crash course. Then, do a couple unity learn lessons. If that doesn’t work, do scratch, a c# crash course, then unity learn lessons. You can’t just dive head first into this.
wait
yeah so if from step 1, i wanna transit to a user-executable action, how do i trigger it? do i create a sentenceTracker lets say, for the 3rd sentence in the queue suggests the end of the step 1?
kinda smart
I look at your code and I see no effort to debug it, why is this?
in your dialogue manager
in update look for key pressed by the user
then execute NextDialogueSentence()
i alredy made a debug and it was working
where you handle all the things
thats horrible advice . Goodluck learning anything that isnt broken with that😆
Got it, that makes sense. It’s like a chain, and when you make something, it only has to make the stuff below it. Makes sense, Tysm.
proceed to next queue step, display it's dialogue
okay, i wont
any good videos to learn coding?
My advice is?
if(Input.GetKeyDown(Keycode.Space))
{
NextDialogueStep();
}
yes i have all these already, it's just that after 3 sentences, i need the users to perform some sort of action before continuing the dialogue
it's not kinda smart because i was being sarcastic
no talking about the other guy who suggested GPT
not smart
such as?
Oh didn’t see that
i was kididng lmao
Can anyone help me out please 🙂
If you need more info im happy to supply!
well you should prob say that cause ppl take that seriously and its just bad way to learn
it's a pizza making game, so, selecting a dough size
can you try disable the Orange,Grren,Blue objects
i aint readin all that
and then check if it works?
i thought the 🤩 emoji would make it clear but possibly not
then why are you here, because I see no evidence of debugging in that code
its videos your troll monkey @peak dock
i have a feeling that the orange, green blue ale blocking the raycast to Red @vast tangle
Debug was working but skin changes dosnt work
that statement makes no sense
if your not willing to learn then you should probably stop asking for suggestions
did you even bother clicking or are you actually inept ?
the first one is just text
I'm trying to make a sprite a random color from an array.
Like this? still doesnt work
Code Monkey is a good video-form resource for beginners/intermediates
it cannot catch the raycast
i dont know, gone?
right click -> ui -> make button, fit the size so it matches the graphics, then reduce the image alpha to 0 and see if it works @vast tangle
can someone mute this guy lol
im only speaking when other people are speaking to me
stop being a cuck
im just asking for help
https://www.youtube.com/watch?v=Z0Z7xc18CcA&list=PLX2vGYjWbI0S9-X2Q021GUtolTqbUBB9B
Its the same exact Playlist.
Watch this video in context on Unity Learn:
https://learn.unity.com/tutorial/scripts-as-behaviour-components
What are Scripts in Unity? Learn about the behaviour component that is a Unity script, and how to Create and Attach them to objects.
this is the code that changes the skin: https://paste.ofcode.org/3M5anup7uAybKVsf4DAEBi
it has the debug
you should read through w3schools c# after a bit it helped me a lot
thank you! ill look through it
It works as a button element, but I only want the purple button areas to be clickable and not just as a square button that also touch the background black circle
Do you really think that 1 Debug.Log statement is debugging code?
is there a way to make the purple object clickable?
it debug one skin change
well the button is a rectangle
can't make it circular
no you don't, you debug I PlayerPrefs call
Pretty sure this was answered last night
In order to make circular… Create a button from canvas Click button from hierarchy view, and choose rect transform from inspector window. Reduce the size to 51.69(width) and 30(height) In the Image script, choose the knob option from the source image. And check Preserve Aspect. Now circle shape you will get. And now if you want to resize the c...
i do not really know how debugs works
Is Using Cursor-Following Objects a Viable Alternative to TextMesh Pro (TMP) for Unity UI Elements?
Cause UI elements will only be clickable if they have a button/image, which i can't make invisible unlike sprites,a dn i was wodnering if its something that people do.
should've been first thing you learned
then google it
why cant you make the image invisible?
yes I understand 🙂
I was more asking if it was possible to make an entire object clickable instead of putting a button on it
Is adding a Button Component the wrong move here?
the button component need to have Image referenced
so it "catches" the raycast
no other way
disable the raycast target on TMP Text
button works only on UI elements, you cannot add a button to your 3d mesh for example @vast tangle
oh i see
you can simulate it
by making a raycast
so you don't need a button
but shoot a raycast from your mouse forward instead
Debugs work by putting them at the start and End of every single method you have and then to look at the console output to see what your code does.
Either that or learn to use the VS debugger and step through your code
and check if you hit your desired purple thing
In this video we will go over how to select an object using the mouse and on how to use the unity raycast to get a gameobject, how to use maskLayer to make sure we are not selecting other objects, drawing the raycast in and editor using Debug.Drawray and more!
All the code in the tutorial:
https://www.nerdhead.dev/post/selection-with-raycast-u...
watch this
thanks a lot ❤️
oh sorry i've explained myself wrong, im trying to make an inventory slot clickable/hoverable.
this is its components, sadly sprites and colliders don;t count for onclick actions prebuilt in unity.
So i was wondering if the best way to do this was using a collider.
(i've tried using immages but i can;t make them transparent even when i dodn't assign any object to them they appear as white)
you can use the physics 2d raycaster.. but is there a reason to use colliders?
can anyone recommend any tutorials that go show how to make an inventory system but also make it save?
that is a complex system
start with a basic list / dictionary of items and learn to serialize that into file
ok any channels that you would recommend?
You could make the Inventory Slot class implement the appropriate interfaces for IPointerXHandler (like IPointerEnterHandler) which doesn't need any colliders to use.
(only works for UI elements and upon second glance, it seems like you're using sprite renderers which are not UI, so maybe convert your system)
I would reccommend just learning all those part individually instead of blindly following someones way of doing it
https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnMouseOver.html
This might help, but UI Images and IPointer interfaces would be better (just change the color alpha to 0 to make them invisible)
i've never used raycasters, ill have to document myself about them.
ok through docs or specific website?
any idea?
its a a component, you put it on the camera
it gives you all the UI callbacks
still not sure why you're using colliders for UI like inventory though
uhm tbh neither documentation nor that really esplained it to me x.x sorry im very unexperienced, i'll just watch a video ^-^
because im a noob and i think practical rather than functional
huh? its a component, you throw it on the camera and does its thing
yeah maybe watch a video
Learn about canvases and rect transforms, it should take no longer than 1 hour and you will thank yourself later
what are component types? atleast in this content- Is it just the name of the component?
its just impractical to use physics objects (colliders) on UI lol
also they will not scale well with differen resolutions, Canvas handles that better
T is basically a wild card (generic) for any type
And the name of the component is the name of the class, which is the name of the type so you're correct on that
what button do i press to make
{
}
The { button
i dont have that
how did you type what you typed then?
If you're on EU like I am, use AltGR + 7 (for {) or 0 (for })
ah, okay, understood
so I can just say put something like "Health" instead of T to get the Component named that?
If you have a class named Health then yeah that should work
what is gr?
oh okay
Basically alt + ctrl
thanks!
The ui elements that can interact with events are images, buttons, text, and neither i fit what i need here :/ but ill try.
As i said images would be the best bet, but since its an inventory slot, and it can be empty, if i use immages, when empty, it would show a completely white image which isn't ideal/
nothing fit because the way you're doing it is wrong
what would be your best tip in my case?
You can just disable the icon when there's no item, or set it to a blank image (the former is a better option)
Use the UI and do it properly
They are asking for tips, I don't think that is the most appropriate tip in this case
the tip is to start over and learn the UI
Yeah, but maybe you could've gone a little in depth as to what they should learn first
anything else wil just confuse them, you want me to give a step by step on how they should display it?
this is out of the scope of a coding channel
But then again one could simply direct them to for example create a canvas and put an image into it, which would not be that out of scope imo
Or just a link to a resource if you don't want to use too much effort by making a 2 step intro into UI