#💻┃code-beginner

1 messages · Page 638 of 1

polar dust
#

you can select multiple materials at once, as far as im aware, there is no way to convert all materials in the project

analog drift
#

Ok got it, thanks for the help

polar dust
#

its funny, every time I have to convert a set of materials, I ask the same question "why cant this be automatic"

wintry quarry
#

the wizard finds them all at once for you

polar dust
#

it does!?

rocky canyon
#

yea.. in the Window> menu

#

under rendering

polar dust
#

oh cool!

#

now i feel silly for manually converting over and over again

analog drift
#

Haha, it's good that I asked

rocky canyon
#

its kinda confusing how they have two different variants of it in two different Menus

shadow rain
#

NOOO WAAY

#

I FIXED IT

#

I JUST PUT IN CONTROLLER.VELOCITY.MAGNITUDE

#

SO HAPPY

tender gazelle
#

Hi Guys. So i have a problem, it shows that i didn't assign a groundCheck to my Character even tho i did. What should i do?

wintry quarry
#

on that other copy, you didn't assign the variable

#

to fix it - find and remove the extra copy

polar acorn
rich adder
mystic anvil
#

@rich adder I debugged scene.buildIndex and it's always at 0

rich adder
#

show code

mystic anvil
green copper
#

Can I reverse the process of checking a dictionary for a value? I have a dictionary of morse code character with ascii char as the key and a string of dits and dahs for the value, and I can search a string to see if it contains the key, can I do the reverse for translating back?

verbal dome
#

You can have a second dictionary that does it the other way around

bold swallow
#

I have a question about IronSource, where should I ask it?

green copper
#

Yeah, I figured that'd work, it'd just be a pain to redo and reverse everything

verbal dome
#

You can automatically populate the second dictionary from the first dictionary if you want to

rich adder
verbal dome
#
foreach(var kvp in dict1) dict2.Add(kvp.Value, kvp.Key);```
polar dust
bold swallow
# polar dust what is the question?

I have completed the implementation, released my game but I still get test ads on my game. I want to know how to switch them to live ads intead of test ads.

tender gazelle
mystic anvil
#

@rich adder Fixed it, it's working now

hollow dawn
#

I'm so confused on how to do this in the player movement script should I first add the mouse Input.GetAxis("Mouse X") & Input.GetAxis("Mouse Y")? or is that not needed? theres hardly any good sources online can't find a damn thing

polar acorn
hollow dawn
# polar acorn Do you want to get the `Mouse X` or `Mouse Y` input values?

I have no clue what's needed and what's not? I'm using cinemachine I can already move the camera without a camera look script. Its just that I don't know how to rotate the players rigidbody when looking around and making the movement camera relative so where ever direction I am looking at I can go in that direction.

polar acorn
mystic anvil
#

I found a better solution Nav

rich adder
rocky canyon
analog drift
#

Hey I am making a driving motorcycle, imported an asset of the bike. I saw someone on youtube making a controller by having a sphere in the middle and programming it. Is that the easiest/optimal way or is there another better way to do that? If anyone did it before or knows anything about that?

rocky canyon
#

the sphere method is a solid "arcade" type setup

#

How the arcade-like car controller was made; big sphere rolling around, car model just copies position. Raycast down to find ground normal for car. Sphere gets force based on car model direction. Tilt/wheel turning/etc. all lerps. #gamedev #unitytips

#

but its up to you ultimately.. depends on how arcade <- -> realistic ur going for

analog drift
verbal dome
rocky canyon
verbal dome
#

@hollow dawn It's really better if you just look up a tutorial, otherwise we'd probably need to just type out everything for you.

hollow dawn
rocky canyon
#

the sphere is rolling and being pushed in the forward direction of the model... when u turn u rotate the car model.. and the whole time the car model is just tracking the rigidbodies position..

#

so everythings working together..

verbal dome
hollow dawn
verbal dome
#

Does it work like you need it to?

analog drift
verbal dome
#

I don't know how you are rotating orientation

hollow dawn
verbal dome
#

We weren't talking about rotating the rigidbody. You wanted to move relative to the camera

rocky canyon
#

to see how they all work

#

everything u mentioned theres an asset on the store already

#

car u gotta deal with friction, plane u gotta deal with gravity, boat u gotta deal with bouyancy

verbal dome
#

@hollow dawn Oh you mentioned rotation too, but yeah anyway my answer is about the relative movement only

hollow dawn
verbal dome
#

I mean you already have this line:cs moveDirection = orientation.forward * verticalInput + orientation.right * horizontalInput;
Which will work if you rotate the orientation transform correctly, only on the y axis

#

But I have no idea if you are actually doing that

hollow dawn
hollow dawn
median heath
#

can anyone help me i cant add image to sprite rendere

#

i jsut started unity

wintry quarry
#

in the import settings on the image

analog drift
median heath
median heath
rocky canyon
#

can u show the inspector/import settings of said sprite

median heath
#

im seeing people drag images directly to sprite

rocky canyon
#

ya, b/c thats possible

median heath
rocky canyon
wintry quarry
median heath
#

thx

#

:( for some reason its still not working

#

im dragging but nothing happens

#

i saved

hollow dawn
verbal dome
#

Yeah, expand the asset from the arrow and drag its child sprite in

median heath
#

wait ill send a vid

green copper
#

can anyone reccomend a module or package for handling fancy text?

Thing kind of thing that handles each letter differently, so I can do things like change the colors of letters to fill them in, or make letters shake like in Slay the Spire

median heath
hollow dawn
verbal dome
median heath
verbal dome
#

Sprite Mode should probably be Single

median heath
#

oh

#

finally

#

thz

#

it was the sprite mode that fixed it ig

rocky canyon
#

i swear, the same colors, same grid, same monolith in the middle

#

anyway.. i think the answer is:

  • move ur camera in lateupdate
  • or use cinemachine
hollow dawn
rocky canyon
#

whats "weird" about it?

rocky canyon
#

you can try changing the camera's update setting.. usually its already set on "Smart"

#

thats usually fine in my projects 🤔

hollow dawn
# rocky canyon whats "weird" about it?

I don't it just feels too smooth and when I am moving my mouse left to right it swings up and down idk just werid is there something wrong with my script?

rocky canyon
#

mayb? do u have any smoothing in ur code?

#

it def shouldnt go up and down for lateral movement

hollow dawn
#

maybe im just tripping

rocky canyon
green copper
#

What is it called when a texture is split up like this so you can make squares with a center texture that tiles and the borders can extend so you can get a texture for any size

I'm aware of the concept but I can't for the life of me remember what it's called to look up how to implement it

rocky canyon
#

9splice

green copper
#

thank you

polar acorn
#

9 slice*, but I think most search engines will know what you mean

rocky canyon
#

yea that ^ lol

#

my electrician days are coming back

hollow dawn
# rocky canyon

when I try to look right or left really quickly it doesn't do it

#

its like too slow/smooth idk

#

how do I fix it?

rocky canyon
#

can u share ur camera script?

hollow dawn
#

just using cinemachine

rocky canyon
#

then just tweek the settings

#

mainly the Damping stuff

hollow dawn
rocky canyon
#

not sure.. im using the newer Cinemachine

#

these seem important too

odd sapphire
#

what doess null mean cus in my language it means zero

rocky canyon
#

it means gone, not here.. poof.. non-existent

wintry quarry
bold swallow
#

Hi, I have a question about LevelPlay and IronSource, where should I ask it?

slender nymph
green copper
#

how can I make it maintain integrity as pixel art instead of squashing wierdly? I made a 9-sliced object in the create gameobject menu

slender nymph
#

this is a code channel

green copper
#

crap sorry meant to swap

quiet crown
#

Does anyone have any tutorials for animations? I have it set so the sprites change when you press a key down to go a direction but not sure how to do the actual animations

zinc charm
cosmic dagger
eternal needle
# zinc charm I implemented an organic growth algorithm (l-system), but it is so slow it hogs ...

use the profiler and see which part specifically is taking the most time. you can set a custom sample too so it shows as a different label
https://docs.unity3d.com/6000.0/Documentation/ScriptReference/Profiling.Profiler.BeginSample.html
That whole _dna part using strings too definitely isnt optimal. You should pool if instantiating is a major problem but also you dont need to use GameObject as your type for instantiating. you should use the component you directly want to reference as the type, unity will pass back the reference of the component and still spawn the whole prefab

cosmic dagger
#

That is definitely costly since DrawTree is called every frame . . .

acoustic belfry
#

Hi, how i can make that an object an enemy spawn to get yeeted into the oppositive side of a proyectile and meele damage?
the thing is, my enemies explode into shards and sometimes items, and i want them to fly to the side of the damage, so how i can do that?

For now i did that the proyectiles explode upon contact, and a material that has complete friction, but its very buggy and sometimes it moves the shards i dont want to, and also the meele "push" doesn't work using this method

verbal dome
#

How are you moving it?

slender nymph
#
  1. it is going to vary a bit due to fluctuations in deltaTime
  2. depending on how you actually move the object there's probably a better way to get the velocity
#

so you're randomizing the velocity each frame

#

moveSpeed2 = Random.Range

moveDir * moveSpeed2
moveSpeed2 is the velocity here

slender nymph
wintry quarry
#

Also you have the move speed variable right here there's no need to calculate anything

hidden fossil
#

does anyone know why my laser beam isnt appearing for my laser tower?

#

!code

eternal falconBOT
hidden fossil
dense cargo
#
if (laserBeam == null) {
  laserBeam = GetComponent<LineRenderer>();
}

You're saying if it is null then get the comp for it.. but that will just return null. If it's null you need to initialize it instead.

#

Otherwise, if it's not null, get the comp

hidden fossil
#

i have the component assigned

dense cargo
#

So then yeah, change if (laserBeam == null) to if (laserBeam != null) or if (laserBeam is not null)

hidden fossil
#

still not appearing

dense cargo
#

What's the material like for the line renderer? Is the line renderer thick enough and is it's color something other than totally transparent?

hidden fossil
dense cargo
#

Hmm, well here's a few things I noticed though I'm not sure if any of them are the culprit(s)...
If the LineRenderer width is 0 or just not wide enough relative to the rest of your scene scale, it won’t be visible.
If firingPoint is null, laserBeam.SetPosition(0, firingPoint.position) will cause an error.
It also looks like you only update the LineRenderer positions when shooting begins, but the beam won’t move if the target moves. So you'll need to ensure SetPosition() updates every frame inside the while loop.
The laser could be rendering behind other objects as well, effectively being culled.

hidden fossil
#

nah the beam isnt even appearing for the linerendere positions

eternal needle
dense cargo
#

Well, damn near 0, by the looks of it

eternal needle
#

oh i see this time the top value was 1.0, last time you had it at 0.1 which made the width a lot smaller

#

I would honestly just start with a new line renderer and recreate the one you have. when you create a new one via the right click menu, it should be visible

dense cargo
#

Setup as much as you possibly can in the inspector as well, easier to keep track of it all. That or do everything in code. lol

sour fulcrum
dense cargo
#

You may be right, I can't remember exactly how that works here

cosmic dagger
dense cargo
#

Nice neonblobfingerguns

mystic anvil
#

Wanted to ask how can I make object movement be responsive to the camera, so where I am looking is where the object goes.

teal viper
#

Also, I'd recommend not moving an object via it's transform, if it also has a dynamic rigidbody(and you want physics to work correctly).

teal viper
#

Rb.MovePosition might also work

mystic anvil
teal viper
#

Also, I'd just recommend going over the beginner pathways on unity !learn:

eternal falconBOT
#

:teacher: Unity Learn ↗

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

mystic anvil
#

I will have a look

#

I made it work with translate but the object looked laggy

teal viper
#

Yes, there might be several reasons why it's like that. Many of which could be caused by mixing up transform movement and physics.

wintry quarry
#

!collab

eternal falconBOT
#

:loudspeaker: Collaborating and Job Posting

We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
Collaboration & Jobs

warm mason
#

Why can I not put these in those fields?
Im 100% sure they're specified correctly as Text mesh Pro, and the auratypetext and auracount ARE TMP, and the button is just a button.

#

it works now

eternal needle
#

oh nvm, thought that was an object in scene

warm mason
#

yeah not sure why it didn't work

#

but the good old closing and redoing worked lol

eager spindle
slim salmon
#

Can a script with errors still be fully compiled? Because Unity stops compilation if errors found.

stuck field
#

You need to fix the errors

#

It can't compile with errors

#

Not because of unity stopping it for no reason, its like what happens when you get an error in a function, the function stops if not handled

polar acorn
#

It can't compile anything if there's compile errors anywhere. Even in completely unrelated scripts.

queen adder
#

Does anyone know why Impluse mode is not working as intended ?

frosty hound
#

Because you're using MovePosition as well

queen adder
#

Can you explain ? I dont understand , I am a dummy.

#

What actually happening in there ? I dont find any clue on documentation ...

frosty hound
#

MovePosition is you saying "from here, try to go to this new position"

#

Prior to that, you're using AddForce which is you saying "I'm going to push you this hard in this direction"

#

You're overriding the physics engine trying to achieve that by immediately telling it to be somewhere right after

#

Which you can see in your FixedUpdate how you are calling ProcessMovement right after ProcessSprintMovement

#

If you're attempting to add sprinting, you need to increase the distance you're traveling in ProcessMovement's MovePosition by increasing your moveSpeed while sprinting or using a separate higher value sprintSpeed while sprinting.

queen adder
#

I still dont get it . You are telling me addforce is pushing me in one direction. What is the point adjusting the moveSpeed to a higher value as well as sprintSpeed ? Since it is pushing into the same direction ...

frosty hound
#

I'm eluding to the fact you don't need your ProcessSprintMovement function at all

#

If you want to spring, just increase how fast you move in your ProcessMovement function.

queen adder
#

Wait , it works. I just adjusted the moveSpeed to a higher value as well as sprintSpeed...

#

No, because the code above I have simplified , the main thing that I want is whenever the player press SHIFT button , it will dash a certain distance , so ... there will be something OnSprint() function and check whether it is pressed down ...

frosty hound
#

In that case, you need to use a state machine so you're tracking what "state" your character is in.

#

And then, in your update loop, depending on the current state of the player, handle it appropriately

#

So that you're running your dash logic without the movement, jumping, wall climbing, swimming, etc. not overlapping unnecessarily.

queen adder
#

I will take it as advise and try , thanks for helping me out. Can I add you as friend ? Hehe , because there are still too many things I want to ask ... Can we ?

frosty hound
#

I don't do DMs, sorry

#

-# Which included a dash

queen adder
#

OMG, this is so cool , I wonder one day I can be like you...

#

the controller is splendid ...

rigid pike
#

Can anyone help with this code? Im fresh in Unity and C# and just finished my first tutorial and now im about to do my first clicker game but this is not working for some reason and it says that the value is quote "assigned but it's value is never used" and even basic calculation like Money =+ 1; doesn't work. (Yes i know this could have been done better with FOR loop but i haven't learned that in C# yet so im doin the longer way)

eternal needle
eternal falconBOT
polar acorn
#

If you want to use the variables you declared outside the function, don't create new ones

eternal needle
#

you'll gain a lot if you go through c# basics first, there is a intro to c# link pinned in the channel

rigid pike
#

i was used to it working normally as far as i remember from c++

eternal needle
#

thats not how c++ works either

rigid pike
#

i could have sworn it works normally that way- i guess my memory is just bad

#

but when i remove the double, the variable is not colored anymore, is that normal?

#

even if i fix the "double variableName" it still doesnt add up the number

#

oh wait

eternal needle
rigid pike
#

i think i found the problem

#

nevermind lol

eternal needle
#

your code doesnt add to Money, it simply reassigns it to the equation. if you wanna add to the current variable then its +=

#

=+ just means you're assigning it to a value and theres a positive sign

rigid pike
#

okay now it works, thanks, i will do the basics after this "game" im trying to make

#

but won't be general c# different from unity one? i mean in normal c# you don't have "objects" like buttons and all that

eternal needle
#

unity uses c#, its not a different language but it is on an old version. you probably wont be using the newer features in any beginner level guide

#

the idea of learning c# first is that you arent learning both unity and c# at the same time. it wont be fun when you have to learn new objects like a button in unity, yet also have no clue how to write the code that the documentation is telling you

rigid pike
#

how far should i go into basic c# so i don't overlearn c# code that i won't "need that much" in unity in general?

#

also, last question, where could i find some open source unity projects to look into to learn?

naive pawn
rigid pike
eternal needle
rigid pike
#

I have another problem this time unity specific one (Atleast i think so). I put a gif as image source to a button, but the gif doesn't play it instead just stays as an image.

frosty hound
#

Unity doesn't play gifs

rigid pike
frosty hound
#

You either have to animate frames, or use a video player.

zinc charm
tender stag
#

how come the "Found command!" is still called when i type in giberish

#

i'll type in "ffsggfdsjjhhfdg" as the command, and it somehow still finds it

eternal needle
tender stag
#

anyone know how to fix it

#

its honestly pissing me off now

#

how is it finding a command which doesnt exist

#

its the if(foundCommand.HasValue) that always has a value

verbal dome
#

Instead of just "Found command!", print some info about the found command and also print commandName

#

That's the first debug step i'd take here

#

(Also no need to use ToLower if your string comparison is ignoring the case anyway)

polar acorn
#

How about printing some identifying properties of the command instead of just whether it exists and what type it is

#

Whatever Command is it probably has a name or something

verbal dome
#

Yeah they seem to have a name and some name aliases too

#

I haven't worked enough with nullable structs to know if there's any quirks I'm missing, but I don't see anything wrong with the code right now

tender stag
#

Debug.Log($"Found command! Name: {foundCommand.Value.Name}");

#

it doesnt even say the name

verbal dome
#

It's either null or empty

polar acorn
#

Okay, so the Command isn't null, it's probably just got null values

#

What is Command? Maybe it has some sort of "isValid" property or something

tender stag
polar acorn
# tender stag command is the struct

Ah, it's a struct. FirstOrDefault will return the thing it finds, or the literal default. Since Structs aren't nullable, it gives you a struct with its initial values

verbal dome
#

What happens in CheckDuplicateAliases?

polar acorn
#

Your linq query cannot return null

#

So has value is always true

tender stag
verbal dome
tender stag
tender stag
#

just loop through them?

verbal dome
#

Ohh right it's not a List of Command?, it's a list of Command

polar acorn
verbal dome
#

Makes sense now

polar acorn
# tender stag so whats my best option

Instead of doing FirstOrDefault, store the result of the query in a list. If the list is empty, set foundCommand to null. Otherwise, set it to the first thing in the list

#

So, foundCommand = resultList.Count > 0 ? resultList[0] : null

tender stag
verbal dome
polar acorn
#

And the default value of a struct is non-null

tender stag
#

ended up with this

#

thanks

livid arch
#

can someone help me rewrite my character movement code? theres alot to it so i dont really wanna start from scratch

rich adder
livid arch
rich adder
eternal falconBOT
rigid pike
#

how do i make it so that a number doesnt get shortened to exponents?

polar acorn
rigid pike
#

well then how do i make it not have exponent? i understood it the way that i have "something" in my code that is telling the number to get shortened but i don't. it automatically gets shortened

naive pawn
#

do you just mean the stringification of floats?

rigid pike
#

this: From lets say 123456836839696 to 123.45E+24 for example

polar acorn
#

If you're printing the float, don't format it

zinc charm
#

@eternal needle I got the pooling but don't understand the instantiating by component thing you mentioned. how would I do that?

verbal dome
#

It does get automatically formatted

rigid pike
#
MoneyDisplayText.text = Money.ToString();
#

just this

eternal needle
naive pawn
#

if the output isn't what's desired, then specify a different format, that's all

polar acorn
#

Isn't the default format just going to give what you put in? I'll go fire up Unity and double check, I probably should have confirmed that first

naive pawn
#

100f .ToString() and 1e2f .ToString() are gonna yield the same result

zinc charm
verbal dome
#

Did you recently change the type of lineRenderer field?

polar acorn
zinc charm
#

I assigned prefab

polar acorn
verbal dome
#

It wouldn't compile if it wasn't the right type

zinc charm
#

idk might be a runtime issue, the game acutally started and then throw this error

verbal dome
#

Assign none to the variable and assign it again

zinc charm
verbal dome
#

It might be serialized as a reference to the old type

verbal dome
zinc charm
#

ok ty, assignin again solved the problem

bold falcon
#

hello, i have a question, im pretty new to the "new" input system. my question is about whether i have to reference a InputAction in each script in which i need it, or can i make a one reference in scripts with static instance of it, and use that reference in all scripts where i need it?

#

for example i have a InputManager script where i calculate all the angle for rotating to face the mouse and stuff like that, which works cuz i can read the value and save it to a public vec2. but with a button value, where i either need to subscribe a function to it or use "triggered" value within it, im not sure, or rather it doesnt work, so is it possible or do i need to make a new reference to the Actions asset and all the input actions in it anew?

rich adder
bold falcon
#

oops, sorry my bad, didnt notice

primal ridge
#

can anyone help? the raytracing wont detect the ground layer so my character doesn't get drag. the ground plate is set to the ground layer.

verbal dome
#

Show your !code and the inspectors of relevant objects

eternal falconBOT
verbal dome
#

(Raycasting, not raytracing)

strange sapphire
#

when I try to add my project to github, gitattributes come up empty, anyone else have this problem...?

magic pagoda
#

can someone link me some sort of tutorial on grid systems..? Ive been looking for one but I havent been able to properly understand the ones that I watched I fear q.q

#

the best I could find was this one but Im... not exactly sure whats going on here...
https://www.youtube.com/watch?v=G7iPGJl37Xc

Utilizing this component dramatically simplifies the task of designing a grid. By defining the parameters such as tile size, gap, and type within the Grid Component, it automatically computes world positions based on the specified grid indices.
This reduces the complexity of placement, ensuring an efficient and streamlined grid creation process...

▶ Play video
queen adder
#
void DrawNormal()
{
    Vector3 normalVector = -(planet.position - player.position) / (planet.position - player.position).magnitude;
    Handles.DrawLine(player.position, player.position + normalVector * 10f);
    SceneView.RepaintAll();
}

Why does this not show up in the editor?
It gets called by an editor button

rich adder
wintry quarry
#

or do you mean the Handles line doesn't show

#

if the latter, make sure you have gizmos enabled

#

Also:

Vector3 normalVector = -(planet.position - player.position) / (planet.position - player.position).magnitude;```
Is a super confusing way to write this:
```cs
Vector3 normalVector = (player.position - planet.position).normalized;```
rich adder
wintry quarry
#

definitely just use the built in component as mentioned

magic pagoda
#

Well not just tilemaps, but Im working on a tile-based tower defense... Ive tried but I wasnt able to code stuff onto those tiles, they were just sprites

rich adder
#

You can certainly use the Grid system for 3D as well (if thats what you meant)

#

I've done it myself, you can also place tiles with a Prefab brush that can use 3D objects

#

but yeah Tilemap would be only 2D.

magic pagoda
#

nono I meant 2D ^^;

I wanna attach components to the grids Im using, and I guess use them kind of like prefabs? Does that make sense?

rich adder
#

basically if you ever tried to make your own grids with like multidimensional array , this cuts the work in half lol

magic pagoda
#

Ill give this a read, thanks!! ^^

robust harness
#

Stupid question but Is there a way i can pass csharp Item = ItemManager.instance.itemSO[selectedIndex]; into ```csharp
public Dictionary<ItemsScriptableObject, int> itemSO = new Dictionary<ItemsScriptableObject, int>();

#

Item is of type ItemsScriptableObject if that matters

wintry quarry
#

sorry I see itemSO is a Dictionary<ItemsScriptableObject, int>()

#

what do you mean by "passing it in"

#

passing what into what

#

with the goal of what

#

This is actually most confusing because we don't knwo what selectedIndex is

#

is selectedIndex an int?

robust harness
#

yes

wintry quarry
#

your dictionary is backwards

#

your dictionary is set up to look up an int by an ItemsScriptableObject key

#

If you want to do lookups in the other direction you need a Dictionary<int, ItemsScriptableObject>

#

or even just an array or list of ItemsScriptableObject

#

(if the indices are contiguous)

robust harness
#

the thing is i have itemSO setup like this in ItemManager.cs so i dont think i can do lookups in another direction ```csharp
public void ListItems()
{
foreach (Transform child in ItemContent)
{
Destroy(child.gameObject);
}

    foreach (var kvp in itemSO)
    {
        GameObject obj = Instantiate(InventoryItem, ItemContent);
        var itemName = obj.transform.Find("ItemName").GetComponent<TextMeshProUGUI>();
        var itemDescription = obj.transform.Find("itemDescription").GetComponent<TextMeshProUGUI>();
        var TypeOfItem = obj.transform.Find("TypeOfItem").GetComponent<TextMeshProUGUI>();
        var itemIcon = obj.transform.Find("itemIcon").GetComponent<Image>();
        var stackSize = obj.transform.Find("stackSize").GetComponent<TextMeshProUGUI>();

        itemName.text = kvp.Key.itemName;
        itemDescription.text = kvp.Key.itemDescription;
        TypeOfItem.text = kvp.Key.itemType.ToString();
        itemIcon.sprite = kvp.Key.itemIcon;
        stackSize.text = kvp.Value.ToString(); // Shows the correct count
    }```
wintry quarry
#

you can do this code with an array or a list just as easily

#

or with a dictionary in the other direction, just as easily

#

for a dict in the other direction the Key and the Value in the KeyValuePair would just be reveresed

#

It's also possible to have two dicts, one in each direction, if you need to do lookups in both directions

#

You just need to make sure they're always in sync

robust harness
wintry quarry
#

As I mentioned the key and value would just be reversed

#

it would be kvp.Value.itemName

#

what's assuming you had a Dictionary<int, ItemScriptableObject>

#

if you had a list you would just be doing:

for (int i = 0; i < myList.Count; i++) {
  String name = myList[i].itemName;
}```
zinc charm
eternal needle
#

what your video had initially didnt seem like it was doing all that much truthfully, so i assume this can still be pushed pretty far without advanced topics

gilded canyon
#

if i have a dont destroy onload that stores settings of my game in the menu how do i make it so that the object doesnt duplicate every time i enter the menu scene

eternal needle
#

if applicable you really could even just precompute a ton of results and use that.

eternal needle
gilded canyon
#

like a intro scene

eternal needle
#

either that or a proper singleton implementation will destroy duplicates on awake

#

it just means a scene before your main menu. it exists for the purpose that itll only be loaded once, because nothing ever sends u back to the bootloader scene

gilded canyon
#

i get what you mean

robust harness
queen adder
#

anyone can help me for some reason my visual studio doesnt have autocorrection for unity i tried some stuff i saw on yt didnt help

eternal falconBOT
queen adder
#

ill try this

magic pagoda
#

IT WAS A GIF-

#

"That link is not allowed" IT WAS A GIF 😭

queen adder
#

lol

polar acorn
magic pagoda
#

unity really said:

magic pagoda
polar acorn
#

This isn't a comedy channel, this is for getting things done

eternal needle
magic pagoda
#

fair enough. anyways... grid layout groups will probs solve my problem? Ill give it a try tomorrow, since its getting late.

queen adder
white lagoon
#
    void Update()
    {
        for (int i = 0; i < hearts.Length; i++)
        {
            if (i < HP)
            {
                hearts[i].enabled = true;
            }
            else
            {
                hearts[i].enabled = false;
            }
        }
    }

i have this code, and I want to make it so if hearts are 6-10, the 5 hearts change from red to blue depending on the amount, do I have to make another for loop here which starts at i-5 if i is bigger than 5, or is there a more efficient way

polar acorn
eternal needle
#

the more efficient way here also would not be doing this in update at all. do this logic anytime the HP changes, which should only be through a public method or property

white lagoon
#

umm, the heart system is in a different script than all my player related stuff

#

okay nevermind, the 2 scripts are still on the same object

polar acorn
bold swallow
#

I have this script that theoretically creates 52 playing cards and puts them into an array. The problem is that in the for loops when I check with a Debug.Log, everything seems to be working fine, but when I got and check after the for loops, I only get the last card that was added

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

public class ShooterScript : MonoBehaviour
{
    public Card[] deck = new Card[52];
    public Card[] hand = new Card[5];
    Card tempcard = new Card();
    int k = 0;

    void Start()
    {
        //first we loop for all the suits (4)
        for (int i = 0; i < 4; i++)
        {
            //then we loop for all the values (13)
            for (int j = 1; j < 14; j++)
            {
                tempcard.value = j;
                tempcard.suit = (Card.Suit)i;
                deck[k] = tempcard;
                Debug.Log(k.ToString() + ". The " + deck[k].value.ToString() + " of " + deck[k].suit.ToString());
                k++;
            }
        }

        for (int l = 0; l < 52; l++)
        {
            Debug.Log(l.ToString() + ". The " + deck[l].value.ToString() + " of " + deck[l].suit.ToString());
        }
    }
}

public class Card{
    public int value;
    public Suit suit;
    public enum Suit {Clubs,Diamonds,Hearts,Spades};
}
#

The console looks something like this:

1. The 2 of Clubs
.
.
.
50. The 12 of Spades
51. The 13 of Spades
0. The 13 of Spades
1. The 13 of Spades
.
.
.
50. The 13 of Spades
51. The 13 of Spades
grand snow
queen adder
white lagoon
#

should i be making variables readonly if i don't plan on changing their value?

bold swallow
grand snow
#

yes

#

if you want 52 cards with their own properties then yes you need 52 instances

#

btw you can do your i to suit cast in the upper loop to convert only 4 times

bold swallow
grand snow
#

make a new card instance in your j loop

#

make new card instance, assign data (or define a constructor on Card), add to array, done.

#
int k = 0;
for (int i = 0; i < 4; i++)
{
    var suit = (Card.Suit)i;
    for (int j = 1; j < 14; j++)
    {
        Card card = new();
        card.value = j;
        card.suit = suit;
        deck[k] = card;
        k++;
    }
}
bold swallow
#
//first we loop for all the suits (4)
        for (int i = 0; i < 4; i++)
        {
            Card.Suit s = (Card.Suit)i;
            //then we loop for all the values (13)
            for (int j = 1; j < 14; j++)
            {
                Card tempcard = new Card();
                tempcard.value = j;
                tempcard.suit = s;
                deck[k] = tempcard;
                Debug.Log(k.ToString() + ". The " + deck[k].value.ToString() + " of " + deck[k].suit.ToString());
                k++;
            }
        }
grand snow
#

change K to not be a member var too

bold swallow
#

Done

grand snow
#

should be good now I think

bold swallow
#

Ok it works as expected now, thanks a lot!

north kiln
#

You can also do it like this:
for (var suit = Suit.Heart; suit <= Suit.Spade; suit++)

#

and directly iterate over the enum

grand snow
#

np np. Very important to understand how references work and how it differes between a class and a struct (reference type vs value type)

north kiln
verbal hedge
#

Could anyone help me? Im really struggling to find a solution to my problem

eternal falconBOT
sick trout
#

void Update()
{
if (Input.GetMouseButtonDown(0));
{
Debug.Log("True");
}
}

#

why

#

this is still printint "True"

#

event if I'm not clicking

#

or holing

polar acorn
#

Because you have nothing in your if statement

#

semicolon means end of statement

sick trout
#

oooooooooooohhhhhhhhhhh

#

silly me

#

thanks

#

and also

#

how to Debug.log something, but in a new line even if it is repeating

polar acorn
#

Disable collapse

verbal hedge
#

Im getting this error but i've checked and all the objects are there. Any ideas to help?
NullReferenceException: Object reference not set to an instance of an object
DeckManager.DiscardHand () (at Assets/Scripts/Managers/DeckManager.cs:59)
TurnManager.StartPlayerTurn () (at Assets/Scripts/Managers/TurnManager.cs:31)
TurnManager.Start () (at Assets/Scripts/Managers/TurnManager.cs:17)

sick trout
polar acorn
polar acorn
verbal hedge
verbal hedge
#

59: discardPile.AddRange(handManager.cardsInHand.ConvertAll(cardObject => cardObject.GetComponent<Card>()));
31: deckManager.DiscardHand();
17: StartPlayerTurn(); // Begin with the player's turn

polar acorn
#

Start loggin'

verbal hedge
#

on 59?

polar acorn
#

Yes that's the line the error is on

verbal hedge
#

thank you! 🙏 I'll try and see if i can find out what it is

polar acorn
#

discardPile, handManager, handManager.cardsInHand, cardObject, and cardObject.GetComponent<Card>() could all be null and break that line.

verbal hedge
#

didnt get anything back from this:
if (handManager == null)
{
Debug.LogError("HandManager not found");
return;
}
turnManager = FindFirstObjectByType<TurnManager>();
if (turnManager == null)
{
Debug.LogError("TurnManager not found");
return;
}

#

time to test the rest

verbal hedge
#

and then I can just redo it

ivory bobcat
# verbal hedge didnt get anything back from this: if (handManager == null) { ...
    Debug.Log($"Discard pile: {discardPile}", this);
    Debug.Log($"Hand Manager: {handManager}", this);
    Debug.Log($"Card in hand: {handManager.cardsInHand}", this);
    discardPile.AddRange(handManager.cardsInHand.ConvertAll(cardObject => cardObject.GetComponent<Card>()));
```Any of the references that print out *blank* would be null.
If you're still getting an nre when none of the above are null then likely a card object is null.
verbal hedge
verbal hedge
#

Does anyone know why my enemy sprite appears behind my canvas image despite being a higher layer?

slender nymph
#

that doesn't seem like a code question. but also i believe it depends on the canvas render mode whether it will sort sprites above UI (this could be incorrect as it has been a while since i've done much with sprites)

slender nymph
verbal hedge
slender nymph
#

i'm not 100% certain, but i think screen space camera can also sort world sprites above UI

dense forge
#

@slender nymph can i dm you for help, if not i understant

slender nymph
#

!ask 👇

eternal falconBOT
dense forge
#

okay

wet pivot
#

I am setting the rotation of an object like this:
characterModel.transform.rotation = Quaternion.Euler(0, 0, 0);
and for some reason it keeps setting the y value to -180. I don't understand what's happening here.

keen dew
#

How did you check the y value?

wet pivot
#

In the inspector

keen dew
#

The inspector shows the local rotation, the code sets the global rotation

wet pivot
#

oh snap i get you. I am setting the rotation on a child object so that may be why this is happening

#

I changed it to transform.localRotation and it's working as expected

#

Thank you!

warm mason
#

this was working fine all day, why am i getting this error now?

#

not sure what im missing D:

#

i know 😄 the highlight in the picture is unintended

#

switching it to just TextMesh fixed it, maybe the name is different?

#

doesn't work, but either way im not using a canvas anyways, im using it with 3d world space so that wouldn't apply anyways

#

it seems like tmp might just not be installed lmfao somehow

#

or something

#

idek

#

oh sheesh, my whole project is blowing up

#

everything isn't working now when its suppose too

#

seems like its not recongnizing any of the libraries 0,o

#

no idea wy

keen dew
#

Close VS, go to Edit -> Preferences -> External Tools -> Regenerate Project Files in Unity and reopen VS

warm mason
#

yeah it worked

burnt vapor
#
  1. They are not libraries, they are namespace definitions
  2. The whole point is to be able to reference code from other namespaces. Randomly adding System.Collections.Generic is not going to help them with TextMeshPro
  3. They already had UnityEngine.UI included, it just isn't being recognised. That's the whole problem
true siren
#

Can someone help me fix the gradlew.bat --no-daemon -b

i can temporarily fix it by downloading gradle.bat and pasting it into the temp file of the unity project but this dose not fix it forever.

teal viper
#

You're saying it as if it's an error that everyone knows about and reads about it in the morning newspaper while seeping some coffee.

frozen star
#

can you run a unity build in windowed mode? (non fullscreen) If so, can you detect OS level drag and drop into the unity program?

strong wren
pure seal
#

After installing the .net sdk, vscode still shows it as missing. I have looked up solutions on reddit and tried it but it does not work.

#

I have the extension to install it as well

teal viper
pure seal
#

yes

teal viper
#

Did you install the .net sdk or .net runtime?

pure seal
#

the .net sdk

teal viper
#

Then check the environment variables

#

Also try pinging it for info in the command line.

woeful schooner
#

am i crazy or is this just
wrong
like that condition is objectively true but no matter what it will never read true in the log (and i have an if statement a little later using the same condition that also never activates)

rare basin
#

it's a floating point issue

#

use can use Mathf.Approx(-3.5)

woeful schooner
#

in the condition? alright, thank you
i'll go try that

rare basin
#

that -3.5 you see in inspector in reality could be like -3.50000000000001

#

or so

woeful schooner
#

well the thing is i've just frozen the movement and manually moved it to -3.5 by typing into the inspector because i've been struggling with this for a minute
so i don't think it would be, but yeah i'll try approximating it

rare basin
#

it doesnt matter

woeful schooner
#

alright

rare basin
#

also can you show the hierarchy

#

of the object you want to read transform for

#

it also might be that you are reading transform.position.y (world position)

#

and comparing it to local position in the inspector

woeful schooner
#

it was local position, yeah
i just changed the check to be transform.localPosition.y instead and that's fixed it
thank you so much!

rare basin
#

np

#

i'd still use Mathf.Approxmiately just to be sure

burnt vapor
#

No excuse not to use Mathf.Approxmiately, even if you are sure the value is the exact same

woeful schooner
#

yeah, i'm using it now- i've just never seen it before since i started with c# and apparently never ran into enough of an issue with floating point values to find out about it

keen cargo
#

You might've been super lucky to not get it elsewhere

#

It's just how floating point values work, they're both accurate and inaccurate in a sense

woeful schooner
#

i dunno what to say
i've just never come across mathf.approximately and i've made a solid few movement systems and whatnot

keen cargo
#

It's a good practice to keep in mind

woeful schooner
#

yeah, i will from now on

keen cargo
#

There's a couple other handy best practices in the pins, take a look at those too

#

Especially the vector calculation

earnest wind
#

will this be the best way to make a "region" rendering?
so that it turns on the objects in the region when you go inside the trigger?

#

or would there be a better way than iterating trough each object?

frosty hound
#

That works, yep.

#

If these objects are always together, you could child them to a shared group container parent and just toggle that parent instead.

#

Or you can associate a container object with this trigger, and whenever a new object that has to be hidden/shown with it is added, child it to the container.

wintry quarry
#

!ide

eternal falconBOT
pure seal
teal viper
pure seal
#

ohh, sorry, I didn't specify, my bad

#

I'm using a mac

#

it is always a bit weird with apps not specifically designed for it

red wigeon
wintry quarry
#

if you already have Unity installed you can skip it

queen adder
#

anyone know how do i add so i could see my box collider outline box

#

like i want to see how to box collider looks

verbal dome
#

Do you have gizmos enabled?

#

This is a code channel by the way

tender stag
#

anyone got a better way of storing nested commands?

#

similar to what im doing

verbal dome
#

I'm not sure if it matters in this case 🤔 other than the potentially annoying warning

#

Assuming you aren't going to actually reach the depth limit of 10

tender stag
#

what command could possibly have 10 arguments

verbal dome
#

It would definitely be an issue if you had cs public struct A { public A nested; }
Because each struct would need to have a value for its nested struct, which would have a value for its nested struct and so on

#

But you have a list so I don't think it really matters?

tender stag
verbal dome
#

I'd almost want someone from Unity to confirm if it's an issue or not

#

Logically, I don't think it is because the first empty list stops the recursion

willow shoal
#

hi! how to fix this script? my player after touch on left he keep move slowly. i just need just normal move. i trying find script for me. can some one help? ```CS
public float speed;
public VariableJoystick variableJoystick;
public Rigidbody rb;

public void FixedUpdate()
{
Vector3 direction = Vector3.forward * variableJoystick.Vertical + Vector3.right * variableJoystick.Horizontal;
rb.AddForce(direction * speed * Time.fixedDeltaTime, ForceMode.VelocityChange);
}

#

i know i need one line of code delete or change so

verbal dome
#

You mean it doesn't stop after you stop turning the stick?

willow shoal
#

but I don't know which one

#

yes

verbal dome
#

The simplest fix is to add some linearDamping on your rigidbody component

#

Rigidbodies don't slow down automatically unless there is linear damping ("air resistance") or they collider with something and have friction

willow shoal
verbal dome
#

Do you need help finding linear damping here?

willow shoal
#

rb.linearDamping = 20;

#

i found

#

from unity help

verbal dome
#

Sure you can do it in code, or just change it in the inspector

willow shoal
#

this is it?

verbal dome
#

It's right there

willow shoal
#

ok!

#

where add this for my script?

public Rigidbody rb;

   void Start()
   {
       rb = GetComponent<Rigidbody>();
   }

   void OpenParachute()
   {
       rb.linearDamping = 20;
   }

   void Update()
   {
       if (Input.GetButton("Space"))
           OpenParachute();
   }
#

OpenParachute(); is answer but where

verbal dome
#

Do you really have a parachute in the game or did you just copy this from somewhere?

willow shoal
#

i just found in official unity help web

verbal dome
#

You don't need code if you don't need it to change during gameplay

willow shoal
#

i just copy past and learn how i twok

verbal dome
#

Just change it in the inspector

willow shoal
#

oh im stupid

#

YES! thats it

#

thank you

verbal dome
eternal falconBOT
#

:teacher: Unity Learn ↗

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

coral pilot
#

Hi all, I am new to unity and am really confused by some of the things that are happening when using the behavior scripts. Firstly, when I edit the X it's actually editing the Y, is this due to some rotation that I have set on the object I am trying to move? Also, if I don't start the object at exactly (0,0,0) then the object seems to grow a mind of its own and move all over the place. Finally, when I am editing this position (X), why are other coordinates (Y,Z) being affected when I never told them to move in the script?.. Some of this is very confusing to me could anyone help out?

{
    void GetValue(string value)
    {
        if (float.TryParse(value, out float newPosition))
        {
            Vector3 beforePosition = transform.position;
            
            transform.position = new Vector3(
                newPosition,
                transform.position.y, 
                transform.position.z);
        
            // Debug.Log($"Y {beforePosition.y} -> {transform.position.y}");
        }
    }
}```
tender stag
#

ended up doing this

#

i know its definitely not the best way

#

but im not getting the error

zenith summit
#

Are there record structs in unity?

brave compass
# zenith summit Are there record structs in unity?

Unity officially supports most of C# 9. Record structs were added in C# 10. So, no. There are some methods to force Unity to use a newer C# version. As long as the features you use don't require runtime support and are just a language feature, it's doable. I don't know if record structs require runtime support.

cosmic quail
minor robin
#

I'm searching for a good inventory guide on youtube is there any recommendation from someone that has followed a guide?

white lagoon
#

how do i get the magnitude of the horizontal velocity from the rigidbody

verbal dome
#

I think you just want the absolute value of it

#

Mathf.Abs

verbal dome
#

Just ignoring Y?

white lagoon
#

so i just have to do Mathf.Abs(rb.velocity.x), there is no way to use .magnitude here?

white lagoon
verbal dome
#

A single axis does not have a "magnitude"

polar dust
#

Magnitude is the length of a vector

white lagoon
verbal dome
#

That's what Abs does

#

Makes it always a positive value

naive pawn
#

unsigned value of a scalar, |x|
magnitude of a vector, |v|
distance from the origin of a complex number, |z|
cardinality of a set, |A|

kinda fun to think about

rocky canyon
#

whats the best way to rotate an object on a local pivot to a min and max range..

#

many ways to do it.. and to work out the bugs i believe my code got convoluted.. just curious what other people do (use) in this situation

rich adder
#

Clamp?

rocky canyon
#

nah i mean i have a clamp

#

im talkin about the actual rotation..

#

u could movetowards a euler prop..
or u could slerp..
etc

rich adder
#

ohhh yea.. I always used Slerp for rotations not sure if its fine

verbal dome
#

Slerp is fine if you don't care about which axes it rotates around to reach the target rotation

#

Since it takes the fastest route

rich adder
rocky canyon
# rich adder ohhh yea.. I always used Slerp for rotations not sure if its fine

i have a particular model thats all whacked out in blender -> unity import.. when its oriented the correct direction (while having a container object [the collection obj in blender].. Z and Y both rotate it on the same global axis it appears.. lol.. it completely ignores the gizmo/pivot/local settings... after thorough searching i figured out that the collection is 1,1,1 as it should be w/ 0,0,0 rotation.. yet all the objects facing north and south come in with also local coords of 0 on the X but the ones facing west and east come in with a -90..

soo i can offset that in blender by also changing that 1 object to have a -90 rotation and not applying it.. but then the mesh faces the wrong way.. and i can fix that but its weird b/c the mesh is rotated weirdly in blender.. but the import to unity flips it the right way up..

this is a different issue but the reason i ask about rotation..

rocky canyon
rich adder
rocky canyon
#

sorry for the book

rocky canyon
#

not sure wtf blender is doing to me

verbal dome
#

I don't follow what the actual issue is

#

All of these objects look like you'd want to rotate them on one axis only

rocky canyon
#

yes locally.. but in the video i show.. ^ the first one
fine when its oriented with the axis directly..
but as soon as i rotate it downwards.. that same axis with the local transform rotates globally

#

sooo the scripts dont respect the local transform method im using

#

isnt the inspector transform a local transform?

rocky canyon
#

i think the object is broken.. if its not aligned w/ the axis perfectly the transform rotation rotates it globally.. all the other axis' work.. so my script does work b/c it falls on the Z axis.. if it were the Y it wouldn't

#

should rotate like this..
but instead it rotates like this..

#

i mean i could leave it.. but it bugs me knowing that if i were to want to change the rotation of another different object that also imports w/ the -90 rotation (the ones facing west and east) the script isn't gonna work

#

i'll continue to get that weird issue where only 2 of the 3 axis's are actually axising in local space

rugged beacon
#

how should i find and delete everything in dontdestroyonload

grand snow
hollow dawn
grand snow
#

@rugged beacon you may be able to get the Dontdestroyonload scene via scene manager and then get the scene root and destroy them that way? (not sure if this is possible though)

eternal needle
wet pivot
#

When I'm using a Cinemachine camera, is it possible to keep the rotation the same when switching between cameras? I've noticed that if I face one way and then switch to another camera, it switches my view back to the way I was facing before.

wintry quarry
#

and hoiw those cameras rotate

wet pivot
#

oh didnt notice that

#

I'll ask in there

ocean loom
#

How do i use the "TAB" button in unity, ive tried to use

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ScoreBoard : MonoBehaviour
{
   public GameObject scoreboardUI; // Assign in Inspector

   void Start()
   {
       scoreboardUI.SetActive(false); // Start hidden
   }

   void Update()
   {
       if (Input.GetKeyDown(KeyCode.Tab))
       {
           Debug.Log("Tabbed");
           scoreboardUI.SetActive(true);
       }

       if (Input.GetKeyUp(KeyCode.Tab))
       {
           Debug.Log("UnTabbed");
           scoreboardUI.SetActive(false);
       }
   }   
}
#

but im having issue It wont show up

#

debug.log isnt logging either

#

oh and ive also tried a break-point in the code and that wont work either?

wintry quarry
#

Put a log OUTSIDE the if statements

#

if the logs aren't printing the code isn't running, a breakpoint isn't going to tell you any different.

ocean loom
wintry quarry
#

also make sure you're not ignoring any errors in console.

wintry quarry
#

does scoreboardUI happen to be this very same GameObject the script is on?

#

If so, you're about to facepalm so hard.

ocean loom
#

how do i get it running 😭

wintry quarry
wintry quarry
ocean loom
meager cypress
#

If you want to make something hidden while running logic, hide the component not the gameobject

wintry quarry
wintry quarry
#

you could put everything inside in child objects, you could use a tottally separate object

#

whatever you want

ocean loom
#

Thank You so much, it works now. I was being very stupid 😭

wet pivot
cloud walrus
#

Guys i know this isn't the correct channel for this but this is the most active channel and the one i get most of the help from,

I've posted about this problem since yesterday without receiving any real help, and i need help with it to keep up with my course

#

I've checked all types of unity tutorials of Unity Timeline and i've followed to the letter (ig) but none of them has worked out with me, like have this bug in my unity editor that i don't know how to fix

specifically in the first second, it's not even behaving as intended (like it isn't recording the first second at all)

teal viper
# cloud walrus I've checked all types of unity tutorials of Unity Timeline and i've followed to...

At the very least ask in #💻┃unity-talk
Code is totally unrelated here...

To answer your question, the initial state is considered default, so there's nothing to record. You should research how the timeline works and what it records in the key frames. Is it delta positions or actual positions? If it's the latter, you can probably hit some button to record the key manually. If not, you'll need to make sure your object is at the starting point every time.
Read the manual for the timeline.

And don't ignore community rules or you're risking to get banned.

cloud walrus
teal viper
cloud walrus
#

i really really did all of that i swear, i made my question as clear as possible and what problems i'm having and i did a research the entire day without a clear understanding of what i did wrong, but next time i'll ask in a more polite way i promise

worthy tundra
#

ik this is a stupid question but how do i get the input field to start accepting input without the mouse? like normally you have to press on the input field with the mouse to get it to start accepting text, but i want a script that makes it start accepting input when you press enter

rich adder
worthy tundra
rich adder
worthy tundra
#

its a tmp input field of that changes anything

worthy tundra
#

never played with ragdolls but id assume the gravity on the rigidbodies is on

rich adder
#

also dont crop the entire window for console

worthy tundra
worthy tundra
rich adder
#

since you put log Before not After as it was said

worthy tundra
rich adder
#

Null Reference

worthy tundra
#

there arent any

rich adder
#

Okay but many times someone else was hidden so thats why its wise not to crop such things

#

where is messageInput assigned ? that UI method normally works fine

#

there is also another method mentioned in the thread

worthy tundra
rich adder
worthy tundra
worthy tundra
rich adder
#

are you pressing the correct key?

#

no idea if log its printing is fine ig

worthy tundra
rich adder
#

I bet Event System is missing

worthy tundra
worthy tundra
rich adder
worthy tundra
# rich adder probably similiar function to Select
    private void Update()
    {
        if (Input.GetKeyDown(messageKey))
        {
            if (inputSelected)
            {
                messageInput.DeactivateInputField();

                inputSelected = false;

                return;
            }

            messageInput.ActivateInputField();
            messageInput.Select();

            inputSelected = true;
        }
    }

its a little 🥴 but i can optimize from here, thanks 🫀

meager cypress
#

The documentation frustrates me so much I find myself vibe coding just to see examples of what some of their functions do

rich adder
#

"vibe coding" ?

#

😬

teal viper
meager cypress
#

It's not the understanding issue, it's why does this even exist issue. Such as contactfilter2D

teal viper
#

Contact filter is probably corresponding to its name: a data structure that provides some filter parameters.

meager cypress
#

Yeah and that's the thing. There's no information on what it actually does specifically

#

that's why it's frustrating

#

We already have layermask why bloat it?

rich adder
#

its filtering for the physics2d class

eternal needle
teal viper
meager cypress
eternal needle
#

What kind of conversation are you expecting here? What kind of results was it not faster in? There is a lot more here to consider than just saying "results shows in some cases it is NOT faster and I want to know why". Which is something you've seemingly taken at face value because you dont know why!

teal viper
eternal needle
#

I wouldnt be surprised if the "not faster" comparison was a case where the filter did nothing.

rich adder
#

my source is..that I made it the fuck up

eternal needle
#

even if it wasnt visibly faster in some cases, which is borderline obvious as to why that might be, the whole discussion is just incredibly silly. saying the documentation is telling you lies feels like tinfoil hat conspiracy.

meager cypress
#

If you cannot help someone, don't.

eternal needle
# meager cypress If you cannot help someone, don't.

Thanks, I'll continue to help others as I have been 👍. I get you have frustrations with reading in general, which you pointed out in your first message. maybe try re-reading the conversation slowly and asking for more clarifying details in parts you're confused about

teal viper
#

All we heard is that you're being suspicious of the docs.

eternal needle
#

the message above the one they replied to was my answer on a case where it wouldnt be faster even. its clear they just didn't understand the conversation

teal viper
#

And while it's true that the docs can be misleading sometimes, it's generally correct and the only thing we can rely on, as the source code is not available. And the documentation is the next credible thing.

#

If there's a specific performance issue you're having, it would be so much more productive to use the profiler to analyze the problem and share the details here, instead of making ambiguous tests of the unity API.

eternal needle
#

Plus, when something says its faster, that doesn't mean it's a noticeable difference.
Talking about cases where it'd be the same speed (or negligibly worse) would imply the ContactFilter2D didn't find anything to filter out. It's going to be nothing in terms of performance for this to run.
For cases where it did filter something out, you have less results to filter through. Going through 4 results instead of 5 is faster. That might be an insignificant boost, yet its still faster and just less logic for you write manually

meager cypress
#

I just said I have issues with the documentation not providing enough information to the point where asking AI is literally better than searching dead documents. That is ALL.

#

You, linking me to the docs, when my issue was the documentation is the most unhelpful response anyone could ask for.

#

Just say you don't know!

eternal needle
#

Well this just turned into a block, you clearly cant fucking read lol
they didnt even link you the docs!

teal viper
meager cypress
#

Okay you saying it's not better is just stupid and false. I have gotten the result I needed. That's what matters.

teal viper
meager cypress
#

Okay, so what answer did you provide?

#

I obviously didn't ask a question.

eternal needle
meager cypress
#

Okay since you're having so much trouble I'll answer for you.

#

"We already have layermask why bloat it?"

meager cypress
#

If you don't know, do not answer. You don't have to provide a response thinking it may help when you're uncertain.

teal viper
#

I provided a response based on my experience reading docs and working with different game engines and other programs. If that's not good enough for you, I'm sorry.

sour fulcrum
#

If you ask chatgpt for example “why might x not be faster” because it’s a storytelling engine and not a programmer it’s going to do its best in an attempt to give you the best answer to that question, even if it’s not necessarily true

meager cypress
#

I'm pretty much done with this topic.

slender nymph
meager cypress
#

I just said I'm done discussing it so take your snarky replies elsewhere

sour fulcrum
#

(It wasn’t snarky whatsoever)

timber tide
#

contactfilter exists because 2D and 3D rigidbodies use two different physic APIs

woeful schooner
#

both my conditionals here seem to be firing at the exact same time, is that correct?
i paused playback in the editor & manually moved my player over a platform (which is always going to be on a river, i'm essentially just making regular frogger), stepped forward one frame, and onPlatform became true while simultaneously the player got a game over

#

ah actually i've just managed to make things work, but i didn't address the simultaneous firing at all so if anyone knows whats going on there i'd still be happy to know

keen dew
#

Not simultaneously but both run after each other every time a trigger is entered

#

What probably happened is that first the river trigger ran which set onPlatform to false so the next check caused the game over, and then the platform trigger ran which set onPlatform to true

#

If the goal is to not get a game over when the player is on a platform then this logic doesn't do that

woeful schooner
#

ahh yeah i see
thank you!
like i said the code itself works now because i swapped some things around with ontriggerstay & enter but i really appreciate the explanation behind the logic

timber tide
#

I'd suggest just ditching tags all together and check a proximity around the player which will give you a list of colliders

#

this way you can filter out a list and iterate through them in one go

worthy tundra
#

how do i make scoll view automatically scroll to the newest item

ruby zephyr
#

I really don't understand why I can't access Scenes, I don't see any fix for my problem in youtube or google.

using UnityEngine.SceneManagement;

public class PlayLoadScene : MonoBehaviour
{
    
    void LoadGameScene()
    {
        SceneManager.LoadScene("SampleScene", LoadSceneMode.Additive);
    }

}
#

like, the function "LoadGameScene" should show in this list right

stuck field
ruby zephyr
#

ill try making it public because I think on the tutorial that I watched they didn't put public or private at all

stuck field
#

👍

#

No modifer defaults to private

worthy tundra
#

how do i make scroll view auto scroll to the bottom

ruby zephyr
#

yo, if i put
using UnityEngine.SceneManagement;

SceneManager should show up on my IDE when I am going to type it right?

If it does not, even when I have the suggestions on my IDE turned on, would that mean I do not access the SceneManagement?

#

because I already made the function of the button and the script but it is not working

rich adder
ruby zephyr
#

oh, it is working now when I tried it on void start,

But on button click it won't

ruby zephyr
#

what is that?

#

I'm currently doing the main menu

ruby zephyr
#

I do, should I put the object with the script on the event system?

rich adder
#

no

#

inspect event system in playmode and see what you pressing

ruby zephyr
#

it is pressed

#

it showed up

rich adder
ruby zephyr
#

to be sure, i will put a debug on the script of loadscene

ruby zephyr
#

event system in the hierarchy, in its inspector at playmode

rich adder
#

what about it

ruby zephyr
#

I mean, i thought you were asking me to test

rich adder
#

did you put a log in that function to see if it prints too

ruby zephyr
#

I am about to do it

#

is there a chance that unity would crash when I don't have the scene on my builds and I pressed the button with the script to load that scene?

rich adder
#

not likely unless you have it paused because of some error

#

show current code

ruby zephyr
#

I seem to be having a lot of problem in my Unity itself, this is kinda overwhelming

#

different crashes are showing like

It looks like another Unity instance is running with this project open.

Multiple Unity instances cannot open the same project.

rich adder
ruby zephyr
#

and now it crashed again and a window showed up to Debug unity.exe

rich adder
ruby zephyr
#

eveytime I test the button

rich adder
#

show the function you wrote

ruby zephyr
#

I will try one more, and I might do a screen record

#
using UnityEngine.SceneManagement;

public class PlayLoadScene : MonoBehaviour
{
    public void LoadScene()
    {
        
        Debug.Log("Button clicked!");
    }
}

heres for the debug

teal viper
#

Share the logs, share the code.
There's no much point in a video at this point.

#

Check the !logs after the crash.

eternal falconBOT
#
📝 Logs

Documentation

Editor logs

Windows: %LOCALAPPDATA%\Unity\Editor\Editor.log
MacOS: ~/Library/Logs/Unity/Editor.log
Linux: ~/.config/unity3d/Editor.log

Unity Hub

Windows: %UserProfile%\AppData\Roaming\UnityHub\logs
Mac: ~/Library/Application support/UnityHub/logs
Linux: ~/.config/UnityHub/logs

ruby zephyr
#

there isn't even an error showing up to my console, along with the Debug.Log

#

ohhh, I found the problem,

it is the Debug.Log code.. Idk why but when it is present my Unity crashes

#

everytime I play

#

that is just weird...

#

nvm fixed it

teal viper
ruby zephyr
#

well, I just removed the Debug.Log since it seems to be a problem to my Unity

#

now I am worried how I am gonna Debug.Log in the future

frail hawk
#

doesn´t sound like a solid soloution tbh

#

never heard of removing debug logs would solve problems

ruby zephyr
#

i know right, I feel like its my laptop that is having problems with Unity, like just how would my Unity crash like this when I only tried to stretch a UI in a canva using (Alt + Mouse Click).

naive pawn
ruby zephyr
#

latest version?

#

well I'm currently working on 6000.0.26f1
but I'm updated at 6000.0.44f1

teal viper
#

Avoiding using debug logs is not a solution

ruby zephyr
teal viper
hot anvil
#

I follow the code monkey tutorial and I'm facing this problem. Why the red blue and red landmark are not on the floor? Since floor position is (0,0,0) and player position is (0,0,0)
NB: Capsule position is at (x:0, y:1,z:0)

short hazel
hot anvil
#

Thanks guys, it worked

hollow dawn
keen owl
#

Start with a smaller number

teal viper
#

If you reduce the linear damping value, you could probably reduce the force amount as well.

hollow dawn
#

@keen owl @teal viper Thanks I just fixed it

teal viper
wintry quarry
#

Why add a magic number

teal viper
#

If you really need to change the value range, make the multiplier a serialized field as well

wintry quarry
#

One issue here is that "speed" is a misnomer for what that field actually does

teal viper
#

Or a named constant in code.

keen owl
#

Yes definitely create a field for speed multiplier especially if you are using the speed variable elsewhere in your code. Avoid magic numbers 👆

keen owl
teal viper
#

It's force

hollow dawn
#

would it be a problem later on?

teal viper
#

It would make your code confusing to read. It might even confuse you in the future

hollow dawn
#

oh how would I be able to correct this?

teal viper
hollow dawn
teal viper
#

And the speedMultiplier would be force multiplier as well

white lagoon
#

i've read somewhere that using GameObject.Destroy() can be a bad idea sometimes, if I destroy the enemies using this and I have a prefab made for the enemies, will they come back when i load the scene again?

#

okay i tested it and it works, resolved

wintry quarry
wintry quarry
grand snow
#

You can "destroy" an asset but only with an argument given to allow it. And this only works in editor ofc.

wintry quarry
#

GameObject is a subclass of UnityEngine.Object

#

that's why GameObject.Destroy works

#

but the function actually lives in UnityEngine.Object

white lagoon
#

it says to change it to just "Destroy(gameObject)"

wintry quarry
#

You could have written Component.Destroy or MonoBehaviour.Destroy too

white lagoon
wintry quarry
#

no

vestal tusk
#

Hey guys, can anyone help me, ive been doing the unity tutorial 2d adventure game and just made a healthbar but now when i go into the game panel the whole thing is just blue?

cosmic dagger
gentle bone
#

repeat the tutorial...

wintry quarry
#

Doesn't sound like a code question though

gentle bone
#

probably just missed 1 step or some config whatever... just go back and repeat the tutorial probably the mistake shows up..

exotic tree
#

I also have a problem since I use planets in my game I wanted to do a first person camera and the problem is with cameras horizontal movement because of it my player is just flying off the planet

#

public Transform player;
public float mouseSensitivity = 2f;
float cameraVerticalRotation = 0f;
// Start is called before the first frame update
void Start()
{

}

// Update is called once per frame
void Update()
{
    float inputX = Input.GetAxis("Mouse X") * mouseSensitivity;
    float inputY = Input.GetAxis("Mouse Y") * mouseSensitivity;

    cameraVerticalRotation -= inputY;
    cameraVerticalRotation = Mathf.Clamp(cameraVerticalRotation,-90f,90f);
    transform.localEulerAngles = Vector3.right * cameraVerticalRotation;

    player.Rotate(Vector3.up * inputX);
}

}
heres the code for the camera movement

cosmic dagger
eternal falconBOT
exotic tree
#

whats the problem though

keen cargo
#

First solve posting your code

acoustic belfry
#

Hi, in a 2Dgame, how i can make that an enemy detects from where it attacks were? i mean the angle

#

my idea is that when it dies it technically shoots the shards and items to the oppositive side of the damage, so it can give the illusion the enemy exploded and the hit of the weapon sent the shards fly

the issue is, how i can make it detect the angle of the damage?

rocky canyon
#

what are u using to hit

#

w'e it is u can probably get the normal

#

then u just reverse it -normal

acoustic belfry
# rocky canyon what are u using to *hit*

two things
one are proyectiles that have a ontriggercollision that checks if the enemy has a damage method, and use it
the other is the player who has a (thinking on making it temporal and replace it) overlap that when if the enemy is inside her overlap, and the player clicks right-click, it triggers it damage method

acoustic belfry
#

better this

worthy olive
#

idk, idk. the second if statement is just not working? I think glideForce gets overwritten somewhere? where, i do not know..

polar acorn
#

Make sure to put it in curly braces if you add another line to the condition body though

acoustic belfry
rocky canyon
#

how are u detecting the hit in the first place?

#

how u know a collision tkes place.. depending on what type of function ur using theres ways to get the info from the contact/hit poin t

acoustic belfry
acoustic belfry
#

i think something went wrong with my message, holup

#

player

 private void MeleeAttack()
 {
     // Cast a ray to detect if an enemy is in range

     Vector2 MacheteRange = new Vector2(attackRange, attackRange);
     Collider2D hitEnemy = Physics2D.OverlapBox(machetepos.transform.position, MacheteRange, 0f, demons);
     Collider2D hitProyectile = Physics2D.OverlapBox(machetepos.transform.position, MacheteRange, 0f, proyectile);



     // If an enemy is detected, deal damage
     if (hitEnemy != null)
     {
         if (hitEnemy.TryGetComponent(out EnemyBase enemy))
         {
             enemy.TakeDamage(meleeDamage, 0);
         }
     }
     if (hitProyectile != null)
     {
         if (hitProyectile.TryGetComponent(out MortemRifleProyectile enemy))
         {
             enemy.Parry();
         }
     }

 }```
#

bullet

private void OnTriggerEnter2D(Collider2D collision)
{
    if (collision.transform.TryGetComponent(out EnemyBase enemy))
    {
        enemy.TakeDamage(riflebulletdamage, 1);
        push();

    }
}```
wintry quarry
#

so you can try to approximate it with e.g. subtracting the hit object's position from the attacker's position

#

or you can switch to some kind of cast

#

e.g. boxcast or raycast

#

and that will give you a hit normal

green copper
#

I've played games where you can turn a wheel or crank by clicking a point on the edge or handle and spinning your mouse in a circular motion to emulate spinning it

How would I go about implementing something like that?

For my system I'd need to be able to spin the wheel multiple times, i.e. where the handle not teleporting back to the start position is important, but keeping track of how many times it's turned, and in which direction, is also important

rocky canyon
#

ud have to use a boxcast or do some math stuff

#

u could use this

wintry quarry
acoustic belfry
rocky canyon
#

what erro

acoustic belfry
rich adder
#

keep refreshing or clear cache