#💻┃code-beginner

1 messages · Page 120 of 1

ivory bobcat
#

Maybe use the Color type instead?

polar acorn
#

The thing whose color you want to change

ivory bobcat
#

Oh, unless you're just asking for code.. maybe show us what you've tried.

ivory bobcat
#

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]; }

amber spruce
#

why cant i assign my gameobject to my variable

#
    public GameObject EnemySpawnerHideout1;
rich adder
#

is that a prefab?

amber spruce
#

no does it have to be

rich adder
#

no

amber spruce
#

it seems to only let me add a prefab to it

gaunt ice
#

is the code in the prefab script?

rich adder
amber spruce
#

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?

amber spruce
#

im still super confused

#

i assume i want the target component

rich adder
amber spruce
#

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

rich adder
frosty hound
#

Show what you're trying to drag to what you're dragging to, full view.

rich adder
# amber spruce how?

the link i've sent has an example, make method in the enemy script where you want to pass the spawner

north kiln
#

if you have trouble, be specific about what you're having issues with

amber spruce
#

the link has multiple options

frosty hound
#

For starters, if you have a prefab selected, you won't be able to drag scene objects into it as a reference.

north kiln
polar acorn
amber spruce
#

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

rich adder
gaunt ice
#
MoveToTargetExample instance = Instantiate(_prefab);
#

read the article/code

amber spruce
#

i am but its really confusing like what is MoveToTargetExample

rich adder
north kiln
#

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

amber spruce
north kiln
#

The component you care about on the prefab

amber spruce
#

and what is instance

rich adder
#

the object you just spawned

#

instance is a common name

north kiln
amber spruce
#

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;
north kiln
#

If EnemyHealth is the name of the type, use it to declare variables of that type:
EnemyHealth instance = Instantiate(...

split dragon
#

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"

amber spruce
#

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

frosty hound
#

Just because you did it wrong, doesn't make it "worse" lol

north kiln
polar acorn
#

not GameObject

split dragon
north kiln
#

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

amber spruce
#

but wont that mess with stuff

polar acorn
#

then yes

polar acorn
north kiln
amber spruce
#

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

north kiln
#

I feel like you've completely ignored the instructions, the resources, and are just stumbling your way through instead

amber spruce
rich adder
polar acorn
north kiln
#

because your prefab should be declared as a type on the prefab object, not the thing you're trying to reference

amber spruce
polar acorn
split dragon
north kiln
#

then go to bed, and read the resource when you're properly awake

amber spruce
#

all i want to do is keep track of the remaining enemies

#

why is this so dang difficult

rich adder
polar acorn
#

you can't just program by successive approximation

amber spruce
#

alright im gonna go to bed and figure it out in the morning thanks

polar acorn
#

learn what you are doing and then you'll see that it's actually simple

#

code means things

#

it's not magic

north kiln
rich adder
polar acorn
rich adder
#

ahh yeah but i thought mix that with events and their brain melts

polar acorn
#

Fair

split dragon
#

I have a question: I have 2 options how to make graphics settings:

  1. Create public sliders fields for each section of the graph and write everything in Void Update.
  2. 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)
buoyant prawn
#

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)

rich adder
split dragon
buoyant prawn
buoyant prawn
static cedar
#

Imo, the latter is better.

grand gust
#

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

split dragon
#

Which subtype should be written after the dot in order for the toggle system to work? If the slider needs "value", then for toggle?

dire smelt
#

the

 [Header("Crouching")]

Not separate

north kiln
dire smelt
lavish magnet
#

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

languid spire
dire smelt
#

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

queen adder
#

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.

languid spire
#

so that is what I have written. x will be A if PickA is true or B if PickA is false

gaunt ice
#

dont cross post

#

you have to search the script that calls destroy and having reference to the gameobject

queen adder
#

There is not any API for that? I searched for it but couldn't find it, I use a networking lib too

dire smelt
gaunt ice
#

i know nothing on network behaviour....

languid spire
dire smelt
gaunt ice
#

step by step

bool A=currentXXX+totaXXX>=maxcliXXX;
if(A){
  return maxXXX;input to A
}else{
  return currentXXX+totaXXX;input to B
}
languid spire
dire smelt
north kiln
#

yes

gaunt ice
#

i just assume the top link to the left hand side of >= and bottom link appears in the right hand side.....

languid spire
#
float x = (CurrentAmmo + Total Ammo >= MaxClipsize) ? MaxClipsize : CurrentAmmo + Total Ammo;
fierce shuttle
north kiln
#

Or just directly find reference to Object.Destroy

fierce shuttle
#

Thats also an option, though you may have to already know where at least one "Destroy" call is in your code

north kiln
#

Or put one in temporarily, or if your IDE is good enough go to Object.Destroy via search

fringe plover
#

Im genius

languid spire
#

yeah, like false does not exist

fringe plover
#

false is just !true

fierce shuttle
# lavish magnet Hello, like everyone else, im making an fps shooter, and I’m wondering how I sho...

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

hybrid jetty
#

hey can i get some good resource to get started with unity addressable for dynamically loading Scenes

steep shoal
pallid verge
#

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

gaunt ice
#
  1. reference it in your script
  2. transform provides bunch of methods but none of them find child by tag
pallid verge
#

this is what i have currently but i think it gets every Flag gameobject

pallid verge
gaunt ice
#

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

pallid verge
gaunt ice
pallid verge
#

which is kinda impractical imo

rare basin
#

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

gaunt ice
#

open the prefab, drag and drop the reference, ctrl+s

nimble apex
#

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

queen adder
#

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:

warm raptor
#

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 ?

teal viper
#

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.

eternal falconBOT
nimble apex
#

ty

teal viper
queen adder
teal viper
#

Share your code properly if you want people to have a look at it.

queen adder
#
//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

queen adder
languid spire
#

does it debug?

queen adder
#

no

languid spire
#

are there errors in the console?

queen adder
#

no, there's no message on console

lavish magnet
queen adder
languid spire
queen adder
#

no

languid spire
#

add one, the IPointer interfaces need this to work

queen adder
#

other buttons work, but this one doesn't don't know why

#

still doesn't work

#

I have physics2draycaster

fluid kiln
#

how do i make an ui element clickable (left and right click) and hoverable?

languid spire
#

wait a second, this is a different script, this is not ChooseLeaderButton

queen adder
languid spire
queen adder
#

the code is the same

queen adder
north kiln
#

yeah, well that was like 1 of the 5 things to check

#

and each one of those things have about 5 things each

neon ivy
#

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

queen adder
#

don't know what I'm missing

north kiln
#

no troubleshooting overlaps
What does this mean

queen adder
#

looking at the webpage you shared, there's no raycasttarget enabled that overlap when hovering the mouse button over the character selection button

north kiln
#

so what does it show in the event system when you hover your element?

queen adder
#

ok, the problem was that the foreground image had the raycasttarget enabled, but now when hovering over the button I get a console error:

north kiln
#

read the stack trace, re-read the error, look at the code it's talking about, and think about it

unborn gale
#

What is this?

hasty basalt
#

help in c# please?

unborn gale
#

I never put this object in?

north kiln
# unborn gale

Not a code question; and it's the render pipeline debug object. Ignore it

gaunt ice
#

not code question really, DDOL scene is for storing the dontdestroyonload objects

unborn gale
#

Ok

fringe plover
#

why it giving me error

north kiln
#

because that's not how you initialize a struct

fringe plover
#

i fixed, thx

queen adder
north kiln
#

being of value 0

queen adder
#

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

north kiln
#

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

queen adder
#

that was code somebody gave to me so didn't know

#

do I just delete the line and leave everything the same then?

north kiln
#

no, understand your logic and rewrite it so it makes sense

queen adder
# north kiln 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:

north kiln
#

if you're struggling so much just use string.Replace

#

and replace it with ""

bleak prism
#

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

wintry quarry
#

Depends on whether you like reinventing the wheel or not

bleak prism
#

instead of using drag and drop

queen adder
#

thanks

bleak prism
#

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

wild cargo
# bleak prism

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

bleak prism
#

That would make more sense if i understand what a pooling system is that is

#

Basically predefine the objects

wild cargo
#

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

bleak prism
#

Oh yea

short hazel
#

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

bleak prism
#

I could do such a system for switching between weapons

#

technically

short hazel
#

No, it's overkill

bleak prism
#

Oh

short hazel
#

Switching between 3 objects once every 15 seconds does not need a pooling system

wild cargo
#

Pooling is great for stuff like bullets which can be recycled easily

bleak prism
#

📝 noted

wild cargo
# bleak prism 📝 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

shrewd swift
#

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

wild cargo
shrewd swift
#

i tested alt, ctrl, shift

shrewd swift
#

curious

wild cargo
fierce shuttle
# lavish magnet Ok i get it, but im still confused on how my hiearchy works, and wdym seperate f...

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

wild cargo
shrewd swift
wild cargo
#

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

shrewd swift
# wild cargo

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

ashen helm
#

@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

wild cargo
#

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

ashen helm
#

i'll check rn

wild cargo
#

Alr

#

It shows the logs of the most recent instance you played in

ashen helm
#

there aren't any exceptions, assuming the word "exception" is supposed to exist somewhere in the file

wild cargo
#

Because if the lists were empty it would return an IndexOutOfBounds exception

#

Maybe you're assigning a null sprite into the variable

wild cargo
#

With the Start()

languid spire
#

exactlly, script execution order problem

ashen helm
wild cargo
keen dew
#

That's not true though

languid spire
spring skiff
#

How can I make, that VS2022 does open every script in the same window?

ashen helm
wild cargo
ashen helm
languid spire
keen dew
wild cargo
keen dew
#

no

wild cargo
#

Wow ok

languid spire
ashen helm
#

🤷‍♀️ 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 ?

languid spire
#

so what happens when you change Start to Awake in that script?

ashen helm
#

the objects don't get instantiated

spring skiff
#

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.

languid spire
ashen helm
#

the objects that have that customer script on them don't get instantiated anymore

languid spire
#

which will have nothing to do with the change you just made

ashen helm
eternal falconBOT
ashen helm
spring skiff
ashen helm
languid spire
ashen helm
#

that was all i changed, in the script i sent earlier, changed Start to Awake

spring skiff
#

I already have VS 2022 installed and also with the Unity conponment

#

And also selected in unity

languid spire
ashen helm
languid spire
ashen helm
ashen helm
steep shoal
spring skiff
steep shoal
#

there is a bunch of different one

spring skiff
#

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?

steep shoal
#

you should be able to see each individual component installed by clicking the tab

teal viper
spring skiff
# steep shoal

What Tab?
by clicking with tabulator, it will select, but dont show the insides.

teal viper
#

What insides are you looking for?

spring skiff
# teal viper 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.

teal viper
#

It is enough

spring skiff
#

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.

teal viper
#

You only need the unity workload

spring skiff
#

But is there a way to see what plugins are installed in what package, without deselecting everything by clicking on them in VS Installer?

hollow gale
#

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?

teal viper
teal viper
spring skiff
teal viper
#

But anyways, I don't understand what you're trying to achieve by messing with the workloads.

hollow gale
teal viper
rare basin
#

there are multiple other ways of referencing your components

hollow gale
#

for example?

rare basin
cosmic grove
#

guys i dont understand whats happening(yes im new to this)

rare basin
#

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

cosmic grove
#

oh right

#

thanks!

rare basin
#

you literally had it explained in the error

cosmic grove
#

and thats why i showed you the error

#

i didnt clearly know what it meant

#

so i asked

rare basin
#

but it literally says "object reference not set to an instance of an object"

#

i said the same

cosmic grove
#

forgive my simple mind. i wouldnt understand a sentence even if it was said in clear comprehensive english

hollow gale
steep shoal
#

in the inspector

cosmic grove
stray wraith
#

is there any way to fix a broken unity scroll rect? i accidentally tweaked the viewport and it completely broke, not undoable

stray wraith
woven crater
#

how to make it so that i loop everything and trigger shoot in the same frame with different seed?

gaunt ice
#

0.00001f doesnt make any sense unless your fps is > 1/0.00001=100000frame pre one second
and why you need different seed?

woven crater
#

in one frame

gaunt ice
#

you can do this even the seed doesnt changed

#

the state changed after each call to it

woven crater
#

kekwait oh right i've using the wrong value type then forgot about it

unkempt goblet
#

why does the game over screen not show? The player deletes but the ui never shows

gaunt ice
#

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

unkempt goblet
gaunt ice
#

in where you compare the tag (calling .tag)

eternal falconBOT
unkempt goblet
gaunt ice
#

then you are calling CompareTag on the gameObject itself, not the collision

unkempt goblet
#

ok ok

#

ty

steep shoal
#

to the ui

#

also did you mean objectwithtag vs object(s)with tag

broken tendon
#

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

verbal dome
#

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

broken tendon
#

would i just be applying multiple materials, 1 for each modifier

verbal dome
#

Each modifier could have its own shader pass, I guess yeah.
Or you can have a monolith shader that does it all

waxen oracle
#

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

languid spire
#

when you child the player to the platform the player will take on the scale of the platform

waxen oracle
#

Is there a way to stop it doing that

languid spire
#

yes, have the following construction
Empty GameObject
--- Platform as child
--- Player as child

waxen oracle
#

Then the player won’t follow the platform though

#

since the platform moving shouldnt move the empty game object

languid spire
#

yes it will if you move the Empty GameObject rather than the platform

wild cargo
languid spire
wild cargo
#

Idk knowledge..?

languid spire
#

the second parameter is for position not scale

wild cargo
#

No, you're talking about Instantiate

gaunt ice
wild cargo
#

Anyways they could just write SetParent and the IDE would tell them the bool's pos regardless so

gaunt ice
#

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.

languid spire
waxen oracle
#

Unfortunately that did something really weird that didn’t really help

wild cargo
#

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

waxen oracle
#

the platforms all dissapeared

#

the cube player became a big cuboid

#

then fell

wild cargo
#

And you used true in the SetParent()?

waxen oracle
#

Ill put my code in a sec

waxen oracle
wild cargo
#

it should look like this:
player.SetParent(platform, true)

waxen oracle
#

!code

eternal falconBOT
waxen oracle
#
    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

wild cargo
#

Or maybe it's already true by default idk

rich adder
#

main "root" gameobjects should not be scaled at all

waxen oracle
#

if i make the scale 1 on the parent it returns to being a cube

rich adder
#

if they have a mesh, mesh should be child and be scaled like that

waxen oracle
#

but id like it to be a cuboid

rich adder
#

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

thorn holly
#

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?

thorn holly
#

So nothing in the try will run if anything produces an error?

languid spire
#

exactly

thorn holly
#

Great, thanks!

small mantle
#

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.

rare basin
small mantle
woven crater
#

why i cant overide the range and speed ? -w-

woeful epoch
#

can someone teach me coding?

woven crater
woeful epoch
#

nah

rich adder
woeful epoch
#

nah

rich adder
#

then no

woven crater
#

lol

rare basin
eternal falconBOT
woven crater
#

hmmm okay.

rare basin
rich adder
woven crater
#

its having the same value as the weapon scriptable object

#

i overwrite the speed and range to randomspeed and range

woeful epoch
rare basin
#

then no

rich adder
woven crater
waxen oracle
#

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

languid spire
# woeful epoch nah

All you need to know

if (cantBeArsedToLearn) answer = "nah";
Console.WriteLine(answer);
rich adder
#

world pos

waxen oracle
#

k thanks

polar acorn
woven crater
languid spire
#

yes it was, class variable

rich adder
#

at start

#
void Start()
    {
        Range = Weapon.RangeModifed;
        speed = Weapon.shootSpeedModified;```
#

so you instantiate with random speed, and then your start method runs

woven crater
#

i need it so it will work with normal weapon which not set random range and speed

rich adder
#

then fix the flaw in your current logic..

woven crater
#

oh i see so all of this run before start?

rich adder
#

well yeah thats on object creation @woven crater

woven crater
#

ah right make sense ...

rich adder
#

for Init the values

#

then you can pass maybe a bool or weapon type to determine if you're getting random or set values

woven crater
#

thank

waxen oracle
#

Is there a function i can use that finds the parent of an object?

rich adder
waxen oracle
#

so i could run like

#

Obj = gameObject.transform.parent

rich adder
#

yea

waxen oracle
#

Nice

#

thanks

peak dock
rich adder
languid spire
#

ok so yuo have code errors

rich adder
#

also make sure to configure your IDE

peak dock
#

this is the first game im making

rich adder
eternal falconBOT
rich adder
#

pick which editor you're using

#

takes a few minutes but save you hours of troubles

peak dock
#

i use visual studio

rich adder
rich adder
#

thats not visual studio

#

thats visual studio code

peak dock
rich adder
#

pretty big

gaunt ice
#

huge difference

languid spire
#

and you are obviously missing both an { and a }

rich adder
peak dock
#

ive never coded before

rich adder
#

make sure you did all the steps

peak dock
rich adder
#

might need to install .NET SDK at the end

languid spire
eternal falconBOT
#

:teacher: Unity Learn ↗

Over 750 hours of free live and on-demand learning content for all levels of experience!

thorn holly
#

Code wise, are components fields within a gameObject?

languid spire
#

no

rich adder
#

they are Components

peak dock
#

you guys are so helpful btw, thanks

thorn holly
rich adder
thorn holly
#

Like I can say gameobject.transform, so isn’t the transform component a field of gameobject?

rich adder
languid spire
peak dock
#

how long does it take to get decent at unity?

neon ivy
#

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

summer stump
thorn holly
rich adder
languid spire
peak dock
#

ive heard unity charges you per download, it it true?

summer stump
rich adder
thorn holly
languid spire
peak dock
rich adder
summer stump
peak dock
#

i might rewrite the code

languid spire
rich adder
#

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

rich adder
peak dock
#

i installed visual studio

rich adder
#

smart

#

but you still need configure it

rich adder
peak dock
rich adder
thorn holly
#

@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?

rich adder
#

GameObject is part of it

thorn holly
languid spire
#

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

thorn holly
#

So when you make an instance of Object, does it also make an instance of GameObject and Component?

peak dock
#

@rich adder

languid spire
#

depends how you make that instance

peak dock
languid spire
rich adder
#

its showing you everything wrong

peak dock
rich adder
#

you just need to write proper syntax

peak dock
#

how to i fix

#

what is syntax

rich adder
peak dock
rare basin
#

fix the errors

#

you have all of them underlined

#

hover over it and read the error

rich adder
peak dock
#

this is what i want:

rich adder
rare basin
#

do what you've been told to

peak dock
rich adder
#

start in order

#

over the red

#

it says whats wrong

thorn holly
languid spire
rare basin
rich adder
#

xD

#

prob

peak dock
#

guys!

#

be serious

#

im in desperate need of help

rare basin
#

hover

#

over

#

the

#

red line

languid spire
#

I am dead serious

rich adder
rich adder
#

if you don't get your glasses asap

rich adder
rare basin
peak dock
#

the color

summer stump
rare basin
#

in video:
public
in your code
Public

#

for example

languid spire
#

man, programming is definitely not for you

thorn holly
peak dock
#

i just installed visual stufio

#

i have no experience

rare basin
#

then learn the basics of c# first

rich adder
#

well then do a proper crash course then on c#

#

gamedev aint a cake

rare basin
#

you can't get help if you dont understand the help

rare basin
#

what else

#

video

#

your code

#

what is the difference

desert elm
#

how I add all the results into a list?

peak dock
#

its getting better

rare basin
rich adder
rare basin
#

how you can't see ANY difference between the tutorial code and your code

#

you must be blind then im sorry

languid spire
rich adder
#

so why didn't you see that in the code with ;

#

; these symbols actually mean stuff in coding..

rare basin
short hazel
rich adder
thorn holly
#

@peak dock srsly just go do a c# course

desert elm
#

what does arr mean?

short hazel
#

Variable name

#

Can be changed

#

Short for "array" to type less

thorn holly
#

Also @languid spire if I make a new object in the editor, does that make an instance of Object, GameObject, and Component?

peak dock
#

and i will learn

desert elm
rich adder
peak dock
rare basin
peak dock
#

instead of making me guess

rare basin
rich adder
languid spire
rare basin
#

but you dont understand it

#

as i said, you cant get help

#

if you dont understand what we are saying

thorn holly
acoustic arch
#

can you use a nav mesh with most 3D environments

thorn holly
rare basin
#

wdym make object through the editor?

rich adder
thorn holly
#

Sorry the inspector ig

rare basin
#

you cannot make objects throught the inspector (not mentioning custom inspecotr buttons to instantiate things)

thorn holly
languid spire
rich adder
rare basin
peak dock
#

almost done

rich adder
#

no

rare basin
#

jezus fucking christ xd

rich adder
#

its worse

peak dock
#

fixing this masterpiece of a code

rare basin
#

wear your glasses, zoom 200% on the video and on your visual studio

#

look on the differences

#

and make it 1:1

rich adder
languid spire
peak dock
thorn holly
peak dock
#

you guys are just jelous that im learining so fast

rare basin
#

yup

#

i wish to be that good

sharp tapir
#

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?

languid spire
rare basin
#

well do you have any code?

sharp tapir
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[System.Serializable]
public class Dialogue
{
    //public string name;

    [TextArea(3, 10)]
    public string[] sentences;
}
rare basin
#

you might want to watch some dialogue tutorials on youtube, as your questions is so general to help you with all of it

sharp tapir
#
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;
        }
   }
}
rare basin
#

i'd make dialogues as scriptable objects, some kind of dialogue manager

thorn holly
rare basin
#

and integrate it with input system

sharp tapir
rare basin
#

what if you have 30 steps?

rich adder
#

holy shit ever hear of an array ?

sharp tapir
rich adder
#

you're in CS and u dont know an array

#

sad

rare basin
#

Dictionary<int, Dialogue>

#

<step, dialogue>

rare basin
gaunt ice
#

maybe year 1 student

rich adder
#

even a CS crashcourse tells you about collections and O notation xD

rare basin
#

and all the variables stepOne stepTwo

sharp tapir
#

yeahh i just started year 1

rare basin
#

this entire architecture is just bad

#

you won't be happy workign with that code later

peak dock
#

😮‍💨

languid spire
sharp tapir
rare basin
#

adding 6th step is too much work instead of just drag&drop the scriptable object into the list of dialogues for example

rich adder
#

SO might be overkill

rare basin
#

yea for that project

rich adder
#

a simple json with the lines, scroll through the array of strings

peak dock
#

Guys, help me with that last part

#

and we good

#

ill forgive u

rare basin
#

200% zoom video

#

and find it

rich adder
#

dude if you're copying a video then copy it ..

languid spire
spring skiff
#

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..."?

peak dock
#

im dont guys

rare basin
#

good luck making other functions and mechanics mate

sharp tapir
peak dock
#

thanks for the motivation guys

rare basin
sharp tapir
#

im quite lost in this whole thing tbh

rare basin
#

it is pain in the ass already to work with that dialogue system

rich adder
rare basin
#

that's a good tutorial for a complete begginer

rich adder
#

just look up how to do that in c#

sharp tapir
#

actually i followed that tutorial

rich adder
rare basin
#

then why do you have big switch statements

#

and weird variables like stepOne

violet falcon
sharp tapir
#

because i want to make it such that step one instructions will be displayed, and users have to execute a certain action

thorn holly
sharp tapir
#

then step 2 will be displayed, and users have to execute a certain action

rare basin
rich adder
rare basin
#

its just a chain of dialogues

#

im assuming it's linear

#

without any branches/choices

peak dock
#

guys it doesnt work

thorn holly
peak dock
rare basin
#

did you assign the function to button's on click event?

sharp tapir
#

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

violet falcon
rare basin
rare basin
#

do you have event system?

summer stump
peak dock
violet falcon
rich adder
rare basin
summer stump
short hazel
rare basin
peak dock
#

how long does it take to learn c# coding or whatever its called

rare basin
#

for you? years i'd say

rich adder
violet falcon
languid spire
summer stump
eternal falconBOT
thorn holly
rich adder
#

double kill

rare basin
violet falcon
#

i tried

summer stump
rare basin
rich adder
languid spire
spring skiff
vast tangle
#

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

sharp tapir
rich adder
short hazel
thorn holly
# languid spire exactly

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?

sharp tapir
thorn holly
# languid spire 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

rare basin
rich adder
rare basin
#

unless you move to another engine

acoustic arch
rich adder
peak dock
rare basin
acoustic arch
rich adder
rare basin
#

it will work

rare basin
acoustic arch
sharp tapir
rare basin
#

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

languid spire
terse raven
#

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?

spring skiff
rich adder
thorn holly
sharp tapir
#

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?

peak dock
#

kinda smart

languid spire
rare basin
#

in update look for key pressed by the user

#

then execute NextDialogueSentence()

violet falcon
rare basin
#

where you handle all the things

rich adder
thorn holly
rare basin
#

proceed to next queue step, display it's dialogue

peak dock
#

any good videos to learn coding?

rich adder
rare basin
#
if(Input.GetKeyDown(Keycode.Space))
{
   NextDialogueStep();
}
sharp tapir
acoustic arch
rich adder
acoustic arch
#

not smart

thorn holly
acoustic arch
rare basin
#

gathering certain item?

#

killing certain monster?

vast tangle
rich adder
sharp tapir
rare basin
peak dock
rare basin
#

and then check if it works?

acoustic arch
languid spire
rich adder
#

its videos your troll monkey @peak dock

rare basin
#

i have a feeling that the orange, green blue ale blocking the raycast to Red @vast tangle

violet falcon
languid spire
acoustic arch
rich adder
peak dock
tender breach
#

I'm trying to make a sprite a random color from an array.

vast tangle
#

Like this? still doesnt work

rich adder
#

you have some vision problems

rare basin
#

your button is missing target graphic

wild cargo
rare basin
#

it cannot catch the raycast

peak dock
rare basin
#

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

rare basin
peak dock
#

stop being a cuck

#

im just asking for help

rich adder
violet falcon
#

it has the debug

acoustic arch
peak dock
vast tangle
languid spire
vast tangle
#

is there a way to make the purple object clickable?

violet falcon
rare basin
#

can't make it circular

languid spire
polar acorn
rare basin
violet falcon
fluid kiln
#

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.

rich adder
rare basin
rare basin
vast tangle
# rare basin well the button is a rectangle

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?

rare basin
#

so it "catches" the raycast
no other way

rich adder
rare basin
#

button works only on UI elements, you cannot add a button to your 3d mesh for example @vast tangle

vast tangle
#

oh i see

rare basin
#

you can simulate it

#

by making a raycast

#

so you don't need a button

#

but shoot a raycast from your mouse forward instead

languid spire
# violet falcon i do not really know how debugs works

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

rare basin
#

and check if you hit your desired purple thing

#

watch this

vast tangle
#

Great I was just about to ask what I should google 🙂

#

thank you!

fluid kiln
fluid kiln
# rich adder disable the raycast target on TMP Text

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)

peak dock
#

I FIXED IT GUYS

#

it works

#

im a master coder

rich adder
unkempt goblet
#

can anyone recommend any tutorials that go show how to make an inventory system but also make it save?

rich adder
#

start with a basic list / dictionary of items and learn to serialize that into file

unkempt goblet
#

ok any channels that you would recommend?

wild cargo
rich adder
modest dust
fluid kiln
unkempt goblet
hidden sun
#

any idea?

rich adder
#

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

fluid kiln
#

uhm tbh neither documentation nor that really esplained it to me x.x sorry im very unexperienced, i'll just watch a video ^-^

fluid kiln
rich adder
#

huh? its a component, you throw it on the camera and does its thing

#

yeah maybe watch a video

wild cargo
desert elm
#

what are component types? atleast in this content- Is it just the name of the component?

rich adder
wild cargo
#

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

peak dock
#

what button do i press to make

{

}

wintry quarry
#

The { button

peak dock
wintry quarry
#

how did you type what you typed then?

wild cargo
desert elm
wild cargo
wild cargo
#

Like the one next to it

peak dock
#

oh okay

wild cargo
#

Basically alt + ctrl

fluid kiln
rich adder
fluid kiln
wild cargo
rich adder
wild cargo
rich adder
wild cargo
#

Yeah, but maybe you could've gone a little in depth as to what they should learn first

rich adder
#

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

wild cargo
#

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