#💻┃code-beginner

1 messages · Page 9 of 1

zealous oxide
#

yup, i believe so! i've got my platform effector2d collider mask set to "everything"

slender nymph
#

okay and is the enemy object's collider a trigger collider?

zealous oxide
#

the enemies have thier own layer called "enemy"

zealous oxide
slender nymph
#

and what layer is the groundCheck object on?

zealous oxide
#

groundCheck is also on "enemy"

#

platforms are on "platform"

slender nymph
#

and those layers can collide in the Physics2D settings?

zealous oxide
slender nymph
#

in the Physics2D settings

zealous oxide
#

everythings on by default

slender nymph
#

then there's some information that you aren't providing 🤷‍♂️
your mail slot screenshots where we only see very specific info aren't really providing all of the necessary context

zealous oxide
#

i'm happy to share more, just not sure what else I can share?

slender nymph
#

show the entire setup. full inspector/hierarchy

zealous oxide
#

ok i've figured it out, the Box Collider 2D, has the "is trigger" ticked. when i untick it, it doesnt fall through

#

but i'd like to use that box collider as a trigger for combat actions, eg when the player character melee attacks the enemy

slender nymph
#

well by the sound of it, your ground check collider isn't actually a child of the rigidbody2d

#

which is why i wanted to see more of the setup

zealous oxide
#

I can send you a full screenshot if thats what you're after?

swift crag
#

yes, that's what boxfriend is after.

zealous oxide
#

❤️

slender nymph
#

and the GroundCheck object

zealous oxide
swift crag
zealous oxide
slender nymph
# zealous oxide

it doesn't have a collider. so it's no wonder it isn't acting as a solid collider for collisions. the way you described it before you made it seem like it had a non-trigger collider

zealous oxide
#

so the ground check needs its own box collider?

slender nymph
#

if you intend for that to be how it collides with the ground, yes. otherwise you need to make the enemy's collider not a trigger

swift crag
#

currently, the GroundCheck game object does absolutely nothing

slender nymph
#

the rigidbody needs at least one non-trigger collider in order to be able to actually collide with stuff

zealous oxide
#

I see. on my player character the box collider has no "is trigger" and the respective players "groundcheck" is also empty, as it was for the enemy

slender nymph
#

right so that player's own collider is the non-trigger collider used for collisions

zealous oxide
#

ok brilliant, thank you, thats fixed the problem. I thought I was being dense

pine edge
#

the thing is, I'm not sure what to use here. if I do col.Lerp(x,y, currentHeat), it won't lerp in relation to the current float/heat value. i.e if the max value of heat can be 10, then at 5 it should be a colour between white and red.

slender nymph
#

currentHeat / maxHeat

#

and make sure at least one or both are floats

primal tree
#

I'm coming back to a Unity 2D Platformer project I had to stop working on in May. When I left it, I had some very annoying trouble dropping down through platforms with the character. I'm still having those problems, and I can't work out what's going on with it. Can anybody help? I'm happy to send you the entire project, if that would be best. https://forum.unity.com/threads/why-is-my-2d-character-getting-pushed-down-0-544207-in-y-when-uncrouching-below-a-passable-platform.1439920/

neat tulip
#

Could i have help with something to do with 2d movement

#

please

neat tulip
#

Huh

slender nymph
#

read it

slender nymph
neat tulip
#

I for some reason am able to double jump infinitly

#

and don't dont how to fix it

#

looked it up andf everything

primal tree
#

Yeah, that's somewhat aligned with what I was thinking, but I'm really not sure where to go from here. I spent forever trying to solve the issue in May, and I'm still confused now. =/ Rrrgh.

slender nymph
neat tulip
#

My bad wrong script

slender nymph
#

!code

eternal falconBOT
#
Posting code

📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

primal tree
#

Btw,

holy cow the formatting in that code is something else
Is that good or bad? =)

slender nymph
#

not good lol

neat tulip
#

my bad

#

sorry

primal tree
#

As I say, I'm happy to provide the project to anyone who can help. I'm reasonably experienced, I thought, but this has confuzzled me almost totally.

ashen ferry
primal tree
#

@ashen ferry Who are you referring to here?

#

Nice emoji! =D

ashen ferry
#

lmao accident kekW

primal tree
#

What's the nesting you have an issue with? The deepest if level I have is 4. I'll take a look at the video, but I'm unsure how else I'd handle this specific situation.

final trellis
#

getting a strange math issue, not sure of the right term but im making an equation to "cyclically clamp" a number between 0 and 2, where once it gets past 2, instead of clamping to 2, it 'cycles' back to 0, and when it goes to -1, it cycles back to 2, my equation ends up being num % 3, which does exactly as described on a calculator, however it seems to calculate -1 % 3 as -1 instead of 2

primal tree
#

Can anybody help me track down my issue with dropping down through the 'thin' floors?

primal tree
ashen ferry
#

ill refactor one method of urs into what I mean

primal tree
#

That's kind of you, I appreciate it.

sour wren
#

Ayoo guys!! I wanna make my own realistic arcade car system in Unity, but I have a question, do I need to rig the car to make the car?

#

Im beginner on Unity

primal tree
#

You'll need to rig it, but mostly within Unity. There's probably a good simple car tutorial in Unity - I'll have a look...

sour wren
eternal needle
primal tree
#

Yikes. One sec!

#

Crikey, why didn't that URL work first time? Anyhow. Yeah, you'll do most of your rigging in Blender, then trigger those animations in Unity. However, in getting the car moving, you'll want to setup wheel colliders etc. in Unity - and it may be easier to setup wheel turning etc. in Unity.

#

But load up the Unity Learn project and poke around with how the car is setup - that's a good starting point.

#

Again, if anybody can help fix the platforming in my project, I'd be very appreciative!

ashen ferry
hidden citrus
#

how do you go about adding a custom extension/button to a pre-existing tool like transform? I want to create a "reset position/rotation/scale" type button using custom code

short hazel
#

This option is already available from the menu top-right

wintry quarry
#

But yes, it is

primal tree
#

I think if you looked at my project, you'd approve of at least 90% of what I have there. Cheers, though!

hidden citrus
tender stag
#

its line 83 im pretty sure
else if(currentItem != itemsDictionary[selectedCell.item.itemData])

tender stag
#

the Switch method doesnt get called

#

this works

rancid tinsel
#

i have an array that goes from 0 to 19 and im using this to pull from it and got an out of index error, did i miss something cuz im feeling kinda sick and i might just be making basic mistakes

polar acorn
rancid tinsel
polar acorn
#

That is why int randoms are max exclusive, solely so you can plug the length directly into that second parameter

hidden citrus
#

Er, better yet, how can I get "this.transform" from the editor extension?

   if (GUILayout.Button("Reset All"))
        {
//// stuff here 
        }

unsure on how to access transform/rotation/scale

polar acorn
rancid tinsel
#

it does (its for a d20 dice)

#

so numbers from 1 to 20

proud nexus
#

can someone help me, i have a sprite for a wood plank (2d game), and i want to resize it to be the floor of my game, however i dont want to stretch it out, i want to repeat it until its the correct size, the first image is the one that i want to change to be repeated to make it look like the second image

polar acorn
#

How have you checked

rancid tinsel
#

oh whoops it pasted twice

polar acorn
#

Okay that shows that you have at least one list with 20 things in it, but nothing shows that this is the list you're getting the error on

rancid tinsel
#

its the only list, the error was for line 49 from the code i sent

polar acorn
#

Have you tried logging the length of the list before you access it

rancid tinsel
#

so this

rancid tinsel
polar acorn
rancid tinsel
rancid tinsel
rancid tinsel
#

there is a chance that the roll++; line might somehow be messing with it

rancid tinsel
polar acorn
rancid tinsel
ashen ferry
#

Debug.Log(arr.Length); shh dont tell I told

polar acorn
#

Put the length inside the log

rancid tinsel
#

it returned 20

polar acorn
primal tree
polar acorn
rancid tinsel
#

but there is a chance i missed something where it goes out of index after a few tries

polar acorn
#

before the error

#

roll is greater than the length of the list, which is your error

#

the list's length seems correct

#

so now check what roll is when it errors

rancid tinsel
#

guessing i change the random range to like 18, 20 so i can actually test for the error

#

since the error seems to happen when you roll above the index

#

otherwise id be here all day

#

also i got this and i forgot how to turn it off

#

whats the keybind again?

ashen ferry
#

insert

rancid tinsel
#

thank you

#

yeah idk the error doesn't seem to happen

#

even after rolling 2 20s in a row

ashen ferry
#

code got scared of debugging

rancid tinsel
#

ahh i recreated it

#

seems to happen when i spam click the dice

#

so its something to do with the coroutines prob

polar acorn
# rancid tinsel

So, is that logging the value of roll inside of the function throwing the error?

rancid tinsel
#

i dont deactivate the dice

polar acorn
#

If so, then a value of 20 is too high

rancid tinsel
#

so the roll++ keeps going off

#

before it can reset

#

i think

polar acorn
#

The list has 20 elements in it, meaning 19 is the highest value

rancid tinsel
#

yeah but Random.Range is maxExclusive no?

polar acorn
rancid tinsel
#

ohhh i get what youre saying now

#

i mean normally i use the result of the roll and then after it was used i add 1 to it

#

but i think i forgot to disable the dice after it starts rolling

#

therefore if you spam it, it keeps doing roll++

primal tree
#

Sorry to repeat this issue, but I really am bamboozled by it...

#

I'm coming back to a Unity 2D Platformer project I had to stop working on in May. When I left it, I had some very annoying trouble dropping down through platforms with the character. I'm still having those problems, and I can't work out what's going on with it. Can anybody help? I'm happy to send you the entire project, if that would be best. https://forum.unity.com/threads/why-is-my-2d-character-getting-pushed-down-0-544207-in-y-when-uncrouching-below-a-passable-platform.1439920/

tropic crown
#

!vs

eternal falconBOT
#
Visual Studio guide

If your IDE is not underlining errors in red or autocompleting code,
please configure it using the link below:

Visual Studio (Installed via Unity Hub)
Visual Studio (Installed manually)

lone mist
#

the docs should contain everything basic right? like movement and hitboxes?

frosty hound
#

The docs contain information for all aspects of Unity. It doesn't cover how to make a game.

lone mist
#

ah

swift crag
#

they do cover things you can use for movement (rigidbody, character controller) and hitboxes (rigidbody again, colliders)

primal tree
swift crag
#

indeed

round scaffold
#

guh

ashen ferry
#

maybe someone knows whats up with this I cant rename classes it goes right back to what it was

#

actually tested with 2 random other classes just in case im being oblivious about something again and got one to rename but changing it back is yet again impossible lol

alpine flare
#

I think thats because it connects to what you named the script in unity

#

maybe changing it in unity first

ashen ferry
#

yea that solved thanks now that I look at the class which renamed itself the way I tried its name changed in editor as well

#

no consistency?! huh

frosty hound
#

That's not how this server works

#

You can show your attempts and get assistance for issues.

cosmic dagger
#

we don't hand out code but can help with any issues or errors you have in yours. send your !code (attempts) when available . . .

eternal falconBOT
#
Posting code

📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

neat tulip
#

oh ok

#

my bad

unique violet
#

how can I get all the children of a gameobject as a list?

swift crag
#

You can iterate over a Transform's children

#
foreach (Transform child in someTransform)
#

it's a little awkward because it's not an IEnumerable<Transform> -- just IEnumerable -- so I don't think you could easily do

#
new List<Transform>(someTransform);
unique violet
#

ah okay thank you

swift crag
#

you'll just get objects

#

(which you could cast to Transform, sure, but it's annoying)

#

smells like very very old engine code :p

iron lava
#

So im trying to learn Unity for the first time (I know what a time to start) and I've started with a kind of flappy bird clone, but right now I have a trigger to increase my score when I go through the pipes but I gave my Player entity two Box Colliders so the trigger is going off twice, what would be the best way to fix this and avoid it in the future?

swift crag
ashen ferry
#

can I assume all awakes on prefab are already ran just below instantiate line or it happens sometime later

swift crag
#

That component would have a bool. It would be set to true when you hit the zone

swift crag
ashen ferry
#

nice ty

swift crag
#

where ScoreZone is a really tiny monobehaviour

#
public class ScoreZone : MonoBehaviour {
  public bool hit = false;
}
#

If the score code is on the pipes, not the player, it'd be even simpler

#

you'd just add that "hit" field to the component that gives you a point

#

and only give a point if it hasn't been set to true yet

iron lava
#

@swift crag I have the trigger in the prefab with the "pipe" colliders. My problem is it registers both of my players colliders but I only want it to register them as one

swift crag
#

Okay, so "Middle Script" is what gives you a point?

iron lava
#

yeah

swift crag
#

when you give the player a point, set it to true (and skip the points entirely if it's already been set)

swift crag
#

logic in your "Middle Script" component is a field

iron lava
#

like this?

swift crag
#

Yep.

#

So, right now, you unconditionally run Logic.addScore() in the trigger enter method

#

You want to make it so that you only do that if hit is false

solid timber
#

Hey, I have two 3d objects (flattened cubes) that are on the same Layer (SliceLayer), and I have changed the Physics so they cannot collide with each other in the Project settings.

So now I can lay these two 3d objects ontop of each other in the game, but there is a Z layer fighting going on. Is there a way to have 2 3d objects ontop/inside each other and then still show one instead of having Z fight?

swift crag
#

I think you could also write a custom shader that adds a bit of offset

#

...but that sounds like a pain in the ass

iron lava
#

sorry im very new to this how would you type that out? if hit = false Logic.addScore(); or something?

swift crag
#

Have you written any if statements yet?

#

oh, I missed the "if" in there

#

yeah, that's the idea

#
if (!hit) {
  // do stuff 
}
#

you can just use ! to negate it

#

instead of doing if (hit == false)

iron lava
#

so like that then?

swift crag
#

Close, but you're missing something to set hit to be true afterwards

#

otherwise, hit is going to stay false every time you enter the trigger collider

#

You could put that in the if statement, or just do it separately. same outcome.

#

(just don't do it before the if statement, of course, or it'll never succeed)

high garnet
#

Anyone know of any good ways to graph a animation curve in UI? I just need to copy it over into a UI form to act like a car dyno sheet

swift crag
#

hm, not sure how I'd draw a nice smooth curve

#

the first thing that came to mind was to just sample a bunch of points and draw dots on a texture

high garnet
swift crag
#

i think that's how a TI-84 does it

sly bolt
#

any help?

iron lava
swift crag
#

just set hit = true;

iron lava
#

right under the if statement?

swift crag
#

That will work.

#

This will:

  • If hit is false, call Logic.addScore();
  • Set hit to true
#

you could also do

#
if (!hit) {
  Logic.addScore();
  hit = true;
}
#

This will behave the same (it just avoids setting hit to true more than once)

#

Doesn't matter at all.

iron lava
#

okay thank you I think I understand how that works logically

hidden citrus
#

hey, what's a good way to set the collider to the raycasts hit distance?

I want the box collider to rescale itself from the rays root, out to the current hit point. though it seems like the debugger ray isnt stopping on contact with objects

   IEnumerator LaserStream()
    {
        while (isSpinning)
        {
            Ray rayLaser = new Ray(offset.position, transform.forward * rayDist);
            if (Physics.Raycast(rayLaser, out hit, rayDist, layerMask))
            {
            }

            colliderZ = rayDist;

            colliderVolume.size = new Vector3(colliderX, colliderY, colliderZ);
            colliderVolume.center = new Vector3(0, offset.position.y, rayDist / 2);

            Debug.DrawRay(offset.position, transform.forward * rayDist, Color.blue);

            yield return new WaitForSeconds(.15f);
        }
    }
swift crag
#

DrawRay just draws a line

hidden citrus
#

in my current example, itll draw it out based on the ray, but the ray itself isnt resizing on contact. does debug ray resize automaticaly?

swift crag
#

it doesn't do any physics

hidden citrus
#

is there a way to make the box resize on hit? Like say the laser hits a rock in front of the player, the collider should stop at that point, not pass through

iron lava
swift crag
#

Notice that you added an opening {, but have no corresponding closing }

#

This will cause an error as soon as the lexer (which chops your source code up into pieces the compiler can understand) finds something that doesn't make sense

hidden citrus
#

like have the ray stop here, then pass that info the collider and divide it by 2 for the center

swift crag
#

Where that actually is can vary.

#

this really confuses the compiler

#

notice how the error squiggles show up...earlier

#

in this case, it's because the missing } makes everything part of the What function

#

and then, at the very end, we get an error because we hit the end of the file without closing all of the curly braces

#

hence...

iron lava
#

oh okay I had to add one } for the void trigger and then another for the public bool. I see how that works

#

that works wonderflully thank you so much

swift crag
#

Right. Every opening { must be balanced by a closing }

#

The outer pair opens and closes the class definition. The inner pair opens and closes the method definiton.

#

And then the innermost pair is just a "block statement"

#
{
  statement1
  statement2
  statement3
}
hidden citrus
#

my math isn't too great but something to do with hit distance. trying to figure out "From origin, to hit distance". I imagine the offset -> hit distance = the length of the ray

      Ray rayLaser = new Ray(offset.position, transform.forward * rayDist);
            if (Physics.Raycast(rayLaser, out hit, rayDist, layerMask))
            {
            }

            var hitDist = hit.distance - offset.position.x;

            colliderVolume.size = new Vector3(colliderX, colliderY, hitDist);
            colliderVolume.center = new Vector3(0, offset.position.y, hitDist / 2);

            Debug.DrawRay(offset.position, transform.forward * rayDist, Color.blue);

            yield return new WaitForSeconds(.15f);
        }
solid timber
swift crag
#

note that messing with sorting priority won't help -- that just changes the order that materials are rendering in

#

one already renders before the other; it's the z-fighting that's the problem

#

One option IS to make both materials Transparent, rather than Opaque.

unique violet
#

how can I get the text data of a txt file hosted on github

swift crag
#

Whichever one gets drawn second will completely clobber the first one

swift crag
#

what are you trying to do

swift crag
unique violet
#

well im trying to make a ui list that has content based off the github text. if that makes sense

swift crag
#

for a message-of-the-day, or something similar?

#

something that you have to go on the internet to retrieve every time you use it

hidden citrus
#

aye figured it out i believe. unless ya'll got a better suggestion for "resize box collider to raycast length"

    IEnumerator LaserStream()
    {
        while (isSpinning)
        {
            Ray rayLaser = new Ray(offset.position, transform.forward * rayDist);
            Physics.Raycast(rayLaser, out hit, rayDist, layerMask);
            var hitDist = hit.distance;

            if (hit.distance <= 0)
                hitDist = rayDist;

            colliderVolume.size = new Vector3(colliderX, colliderY, hitDist);
            colliderVolume.center = new Vector3(0, offset.position.y, hitDist / 2);

            Debug.DrawRay(offset.position, transform.forward * rayDist, Color.blue);

            yield return null;
        }
    }

unique violet
#

the data will be like this

name
description
link
version
icon (base64)
name
description
link
version
icon (base64)
etc...
#

i also want to split them by each 5 lines so I can each piece of data per shortcut

#

@swift crag any updates?

swift crag
#

i would suggest just storing your data as JSON and then using something like Json.NET to deserialize it

unique violet
#

alright thanks

rancid tinsel
#

how would i carry over variables between scenes?

#

i have a game manager in one scene (where you choose your stats) and a game manager with the same script attached in the next scene where I would want to keep storing those stats so that I can use them within the actual game

eternal needle
#

the object that has the script

rancid tinsel
lone mist
#

why is this guy not showing up

summer stump
summer stump
rancid tinsel
summer stump
rancid tinsel
rancid tinsel
lone mist
#

why is my little guy not showing up 😭 can anyone help me?

glad comet
#

Sorry if this is a simple fix but my code for my character to jump up with the spacebar won't work. What is the problem?

civic coral
#

is coding the same for a vr project and a 3D project

summer stump
# lone mist

So it is supposed to exist in the scene before play starts?

lone mist
summer stump
lone mist
#

there it goes

#

thamk you

#

wait

#

isnt z a 3d thing

summer stump
sour wren
#

Guys, how can I rig a car? I intend to create my own car system, would it be possible for me to invent my own car rig?

civic coral
#

is there a system in unity for missions for your game

like kill [bad guy] and steal [key] to open [the big bad mafia room]

summer stump
summer stump
sour wren
civic coral
summer stump
#

And it looks real weak.

#

But generally, these assets are still just a framework, you will need to implement them and tie them in with the rest of your game. Gonna have to write some code somewhere, and it won't add the system for you

tropic crown
#

I've been following a yt video on a working survival system for a hunger system but I cant get the food eating function to work... Please help

summer stump
eternal falconBOT
#
💡 IDE Configuration

If your IDE is not autocompleting code
or underlining errors, please configure it:

Visual Studio (Installed via Unity Hub)
Visual Studio (Installed manually)

VS Code*
JetBrains Rider
Other/None

*VS Code's debugger plugin is unsupported.
We recommend using VS or Rider instead.

summer stump
vague sage
#

Hello I'm a super beginners

vague sage
#

and im wondering why my script isnt working when i folllowed the the tutorial to a tea.

#

Did i do something wrong in my unity

vague sage
#

Or did I do something wrong in my visual studio

tropic crown
summer stump
summer stump
tropic crown
#

just wanted to see if could clue me into why its not working

teal viper
vague sage
#

but i dont see the error

#

i thought it would show at the bottom

lone mist
#

help, the tutorial im following for sprites shows the lines of code colored but mine dont, what am i doing wrong?

vague sage
#

where can I detect the error>?

summer stump
eternal falconBOT
#
💡 IDE Configuration

If your IDE is not autocompleting code
or underlining errors, please configure it:

Visual Studio (Installed via Unity Hub)
Visual Studio (Installed manually)

VS Code*
JetBrains Rider
Other/None

*VS Code's debugger plugin is unsupported.
We recommend using VS or Rider instead.

vague sage
#

hold up.

teal viper
# vague sage

Open the console tab. That's where the errors should be.

lone mist
vague sage
#

this?

#

oh

#

wait one second

summer stump
# vague sage

Are you using vs code? Because that is for vs code. But yes that would be it

vague sage
#

also your thing didnt work

#

or i cant see Preferences when I open edit

summer stump
vague sage
#

should i get it?

summer stump
vague sage
#

okay im installing

#

what shuld I expect now?

#

to be able to run da code?

summer stump
summer stump
vague sage
#

okay sound good tysm

#

ill be back if thats fine

rancid tinsel
#

im struggling with figuring out how to grab values from a script thats DDOL'd but in a different scene as it isnt letting me assign it in inspector

#

could someone help me out please

vague sage
#

VehicleController

summer stump
summer stump
vague sage
#

@summer stump

tropic crown
summer stump
vague sage
#

@summer stump

#

can i start coding ?

tropic crown
#

Ok so It didn't show up when I moved it here

summer stump
# vague sage <@349017582105526273>

That dotnet error worries me. The unity extension should have installed any dependencies you needed..
But yeah you can code whenever. Do you have any compiler errors?

summer stump
vague sage
summer stump
vague sage
#

game runs

vague sage
#

time to put the cod ein and see if it will finally move

tropic crown
#

It could be that my refrence is my PlayerCam and no the PlayerObj

summer stump
tropic crown
#

yeah

#

and the second line

#

I feel like the player input should be the player object not the playercam

#

but it wont let me put any other item in the slot

summer stump
#

Ok... try doing this:

Replace the getcomponent line and null check with this line:

if (!other.gameObject.TryGetComponent(out SurvivalManager survivalManager)) return;

The reference thing shouldn't affect this at all

#

Dunno if you even need to go through gameObject actually

tropic crown
#

nothing seemed to happen

#

no debug log still

summer stump
summer stump
tropic crown
#

what?

#

the playerObj has a collider @summer stump

lone mist
#

ok so im following a tutorial but idk what im doing

#

im just copying and pasting

#

but i really want to know what im copying and pasting

#

do i look up that in unity docs??

young warren
lone mist
#

i have no idea what im doing

teal viper
#

Things you don't understand

cosmic dagger
lone mist
#

im just confused 😭

teal viper
#

If you don't understand any of it, it's time to go learn the C# basics.

cosmic dagger
summer stump
#

It HAS to be on the one with the script

tropic crown
#

I added a collider and I started flying lmaooo

queen adder
#

Hello, im new to unity and coding (Besides Lua) in general, May I ask what language unity uses?

summer stump
queen adder
tropic crown
#

unity confuses me

summer stump
tropic crown
#

when I press play I just start moving up

#

cannot walk or jump

summer stump
tropic crown
tropic crown
#

Ok im stupid asf I fixed the flying thing

lone mist
#

unity learn should be cool to like

#

learn coding and stuff?

queen adder
#

Is this to ambitious for a first game?

#

Horror game!
2D

Story:
A man wonders into a hotel and finds its been taken over by zombies, with the exit locked from the outside by a mysterious force/person, with the FBI on its way to land on its roof he needs to find a way up and out.

Main Character:
David Lemmings

Hotel:
Hotel Cliton

What i will learn:
Coding, bug fixes, level design, dialouge, basic music making, basic movement, basic teleport points.

lone mist
#

idk man, i struggle to create space invaders

queen adder
summer stump
cosmic dagger
tropic crown
#

@summer stump I added the collider and still nothing...

queen adder
summer stump
tropic crown
summer stump
#

It does't have the survival script on it

#

Not a rigidbody?

#

Wait what?

#

You added it to the camera?

tropic crown
#

my player has the script and the rigidbody

summer stump
#

The collider isn't on the right object

tropic crown
#

I have my collider on a child od the player

summer stump
#

The collider HAS to be on the same object as the script. Not a parent or child

tropic crown
#

ahhhh

summer stump
#

I mean, I guess you can get it from the parent of the transform... but why?

tropic crown
#

If I change it It might mess up the code of my fpc

#

wow it was really that easy

summer stump
#

Is this a brackey's tutorial? Why is the sensitivity so high on that camera? You aren't multiplying mouse input by deltaTime are you?

tropic crown
#

this ^

#

Its a bit odd how he did it all but its working so idkk

queen adder
rocky canyon
summer stump
tropic crown
chrome crypt
#

Since I can't reference a scene object in my prefab, I'm trying to reference it once the prefab clone enters the scene. So how can I set the object and function of this unity event from a script?

unreal imp
#

doesn't anyone know how to make the fire effect like in the gmod explosive barrels? Here is the code that does not work for me, everything related to the bool isInFire private void Start() { isInFire = false; random = Random.RandomRange(minimunHitsToDestroy, maximalHitsToDestroy); rb = GetComponent<Rigidbody>(); } void Update() { if (hitsReceived >= random) { Instantiate(explosionParticlesPrefab, gameObject.transform.position, Quaternion.identity); Destroy(gameObject); Vector3 position = gameObject.transform.position; Quaternion rotation = gameObject.transform.rotation; GameObject sherds = Instantiate(toiletSherds, position, rotation); } if (isInFire && particleInstance == null) { particleInstance = Instantiate(fireParticles, transform.position, Quaternion.identity, transform); var v = particleInstance.GetComponent<DestroyInRandomTime>(); if (!v.isActiveAndEnabled) { hitsReceived = maximalHitsToDestroy; } } }

cosmic dagger
eternal falconBOT
#
Posting code

📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

cosmic dagger
iron lava
#

can someone explain to me what this means? For some reference I had a trigger that increased my score when I went through it but now it doesn't and I get this, not sure what I did notlikethis

iron lava
#

well its refering to this but im really not sure what I did or how to fix it?

summer stump
#

Because that is the only thing that could be null on that line (and int cannot be, it just defaults to 0)

queen adder
#

Make sure the script isnt on another GO as well because if it is it could have a NRE

iron lava
queen adder
#

GO means GameObject

#

NRE means Null Reference Execption (The error message)

summer stump
iron lava
#

I think this (I know Script is a bad Script name but it was making issues to change it)

queen adder
#

You see how it says none on text

#

Ur not refering to anything so the Compiler says (Null: Meaning nothing ) Reference Exception

#

U just need to fill in the Text field

summer stump
iron lava
#

dang im not sure when or how I messed that up

#

its working now thanks

queen adder
#

Ofc brother 🙂

#

Also dont make everything public

iron lava
#

sorry if I wasted your time for something so silly

#

oh?

queen adder
#

Use [SerializeField] for something if no other code is referencing it

summer stump
queen adder
#

If u want something to just show in the Inspector use [SerializeField] theres no reason to make something public if you just want to modify the value from the inspector

iron lava
#

just SerializedField or SerializedField void?

queen adder
#

Like so

#
[SerializeField] Text scoreText;
iron lava
#

oh okay

#

is it bad to have them Public?

queen adder
#

To make all of them public yes

#

I know ur still new

#

So alot of this might go over ur head and thats fine (not trying to be rude)

unreal imp
queen adder
#

But unless another Script/ Class is reading or writing to the values of that script then dont make it public

unreal imp
#

srry for late response

queen adder
#

You could have another class accidently modify the fields of that script if its public

iron lava
#

I understand its a lot but I appreciate any help/advice

#

oh okay that makes sense

queen adder
#

Yeah ofc brother

#

Its better to have everything private by default

#

This is common practice btw 🙂

iron lava
#

I did see private void instead of public how is private and SerializedField different?

queen adder
#

private void ?

#

You mean the methods?

summer stump
#

Methods can return something, or nothing (void)

iron lava
summer stump
#

Yeah, that is a method

#

Which returns nothing

queen adder
#

Yeah That method should be private

#

But i think ur confused lol

#

Void is a return type

iron lava
#

so why SerializedField over private

queen adder
#

Private public are access modifiers

summer stump
#

It is WITH private, not instead of

queen adder
#

U dont do [SerializeField] on methods

ivory bobcat
summer stump
#

But variables DEFAULT to private, so if you don't specify, it is private

queen adder
#

You do that on fields / properties

iron lava
#

oh okay

queen adder
#

Ok so remember how private means nothing else can see it?

iron lava
#

so different tools for different tasks basicly (im sure those are bad words to use as an exaple)

queen adder
#

That means even Unity cant see it. (This isnt entirely true but...)
So u want a way for unity TO see it.

#

"[SerializeField]" Does that for u without having to make it to where anyone can modify the fields / properties

iron lava
#

I think I understand? Im sure it'll bite my butt one day and then ill understand fully

queen adder
#

Like i said ur still new

#

So most of it will go over ur head but as long ur doing research and actually trying like u are! You'll do great!

iron lava
#

Ive mostly been fallowing YouTube and step by step guides but If I wanna branch out a little wheres the best place to get general guides or a place to learn what the code means so I can kinda "kit bash" things together. I hope that makes sense sorry if it doesn't im pretty tired and just wanted to finish this project before I pass out

queen adder
#

Yeah best practices arent learned overnight. So give urself time to understand the concepts. Ur doing really good so far tho

iron lava
#

Thanks man. and thanks for the help, im sure ill darken your doorstep some other time but only time will tell.

cosmic dagger
tiny terrace
#

can I use lerp in order to change my rigidbody's velocity? i want it to de-accelerate until it reaches 0 within a timeframe

lean basin
#

I have a gameobject with script and collider. How do I get Collider component using the script? The collider could be anything. It could be sphere, it could be box, but there will always only one.

river roost
lean basin
supple wasp
#

How to make a joystick?

#

I want to make the R joystick move the character and the other L joystick move the camera

sullen rock
#

is FixedUpdate completely independant from FPS? like, even if I have 30 fps, fixedupdate will always be 50?

keen dew
#

yes

fossil drum
# sullen rock is FixedUpdate completely independant from FPS? like, even if I have 30 fps, fix...

Yeah it will do multiple FixedUpdate's in a frame then to catch up. Which can also cause the FPS to drop lower again.
https://docs.unity3d.com/ScriptReference/MonoBehaviour.FixedUpdate.html

If the application runs at 25 frames per second (fps), Unity calls it approximately twice per frame, Alternatively, 100 fps causes approximately two rendering frames with one FixedUpdate. Control the required frame rate and Fixed Timestep rate from Time settings. Use Application.targetFrameRate to set the frame rate.

sullen rock
fossil drum
sullen rock
#

seems to have done the job, yeah

subtle gull
#

new to unity, any good places to learn? or is youtube my 1 place to go ? XD

cosmic dagger
#

!learn

eternal falconBOT
#

🧑‍🏫 Unity Learn can offer you over 750 hours of free live and on-demand learning content for all levels of experience! Make sure to check it out at https://learn.unity.com/

subtle gull
#

ah ok thanks

tender flame
#

anyone knows a good way to play videos in unity?

the default Video Player is lagging freezing or skipping frames

tender flame
teal viper
#

That you are not using it correctly.

#

The default video player works properly for most people. If it doesn't work for you, there's something with your setup or code.🤷‍♂️

fossil drum
#

Or way too high resolution/bitrate.

gray basin
#

Hey im trying to implement accelerating and deccelerating in my movement code but i dont understand why this isn't working:

        rb.velocity = new Vector3(input_x * move_speed,0,0);```

"move_speed" just gets instantly set to "max_move_speed"... am i using MoveTowards incorrectly or what?
#

also input_x is just the "horizontal" built in axis

ivory bobcat
#

Log acceleration. If anything, you may need to have it be relative to delta time.
acc * Time.deltaTime

gray basin
#

acc is constant so the log always says 1

#

if i multiply by deltatime i just move very slowly instead which i dont understand. Shouldn't it move towards max_move_speed?

keen dew
#

It starts the movement from 0 every time

#

it should be move_speed = Mathf.MoveTowards(move_speed, max_move_speed, acc);

gray basin
#

yeah i just realized

static cedar
# iron lava I did see private void instead of public how is private and SerializedField diff...

Some quick rundown of different protection levels. UnityChanThink
Public - Anything can see it.
Internal - Only the current assembly the class belongs to can see it.
Private - Only the class/struct/interface it belongs to can see it.
Protected - Same as private but any classes that inherit from the class it belongs to can also see it.

Some more niche protection levels.
Protected Internal - Internal OR protected.
Private Protected - Internal AND protected.

ivory bobcat
dusky vigil
#

Hello, I have a problem with my pickup function (pick and drop weapon system) . When I pick a weapon from the ground the position of the weapon remains the same even if I change it in the script. The weapon container is to parent and unparent weapons to it, it's an empty obj. pls help 😦

fringe pollen
#

Is your weapon container under the camera?

dusky vigil
#

no, they both have the same parent which is an empty object used for camera recoil

rancid tinsel
#

why is VS telling me that i need to close a bracket when i have 14 brackets in total

#

im so confused

#

nvm it didnt like the public

slender nymph
#

yeah you cannot declare a public variable inside a method

rancid tinsel
#

makes sense

#

i was trying to figure out the syntax for the array

#

cuz i completely forgot

#

i got it now tho

jolly pendant
#

Any idea how to fix the following build error in IL2CPP?

Build completed with a result of 'Failed' in 365 seconds (364613 ms)
C:\Program Files\Unity\Hub\Editor\2022.3.5f1\Editor\Data\il2cpp\build\deploy\il2cpp.exe @Library\Bee\artifacts\rsp\10085445761055836420.rsp
Error: IL2CPP error (no further information about what managed code was being converted is available)
System.InvalidOperationException: Sequence contains no matching element
   at System.Linq.ThrowHelper.ThrowNoMatchException()
   at Unity.IL2CPP.TableWriters.WriteIl2CppTypeDefinitions.WriteDeclarationsFor(SourceWritingContext context, IGeneratedCodeStream writer, IEnumerable`1 groups, Func`2 skip)
   at Unity.IL2CPP.TableWriters.WriteIl2CppTypeDefinitions.WriteDeclarationsPart1(SourceWritingContext context, IGeneratedCodeStream writer, ReadOnlyCollection`1 allItems)
   at Unity.IL2CPP.TableWriters.ScheduledTableWriterBaseChunkedDualDeclarations`2.ChunkWorker(WorkItemData`3 data)
   at Unity.IL2CPP.Contexts.Scheduling.PhaseWorkScheduler`1.ContinueWithResultsWorkItem`4.InvokeWorker(Object context, Int32 uniqueId)
   at Unity.IL2CPP.Contexts.Scheduling.PhaseWorkScheduler`1.BaseContinueWorkItem`2.Invoke(Object context, Int32 uniqueId)
   at Unity.IL2CPP.Contexts.Scheduling.PhaseWorkScheduler`1.WorkerLoop(Object data)

UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
rancid tinsel
#

excuse the terribly messy code

wintry quarry
#

i.e. your array is empty

rancid tinsel
#

but I have 3 strings in that array no?

#

or did I mess something up

wintry quarry
rancid tinsel
wintry quarry
# rancid tinsel

string[] Scenario = {"You wake up in the middle of the street. You have no recollection of who you are apart from your name. The only people you see out are a group of people drinking. Do you talk to them? (A = Yes, B = No)", "", "" };?

#

This?

rancid tinsel
#

yes

wintry quarry
#

This is completely unrelated

#

you simply declared a local variable here also named Scenario

#

this will not affect the Scenario member variable

#

If you wanted to assign the member variable you need to omit the type

#

just do Scenario = {"whatever"};

ivory bobcat
#

Dirty solution: guard statements

wintry quarry
#

well a guard statement would stop the errors but won't fix the script (won't make it do the right thing)

rancid tinsel
rancid tinsel
wintry quarry
#

you're also possibly missing semicolons on those lines

rancid tinsel
#

deleting that gave more errors tho

wintry quarry
#

they are probably real errors.

ivory bobcat
#

Live 79 and 80, remove the type unless you're wanting to declare new types in that scope specifically

#

If you continue to get errors, you're probably using them before assigning them

rancid tinsel
#

what on earth is going on

#

how am i missing 3 ;'s in 1 line

wintry quarry
rancid tinsel
#

79 and 80 are the Scenario and ScenarioA arrays

wintry quarry
# rancid tinsel how am i missing 3 ;'s in 1 line
Scenario = new string[] {"You wake up in the middle of the street. You have no recollection of who you are apart from your name. The only people you see out are a group of people drinking. Do you talk to them? (A = Yes, B = No)", "", "" };
#

you can only use the syntax without the new part if you're declaring and assigning in the same line

rancid tinsel
#

is that for arrays specifically or?

wintry quarry
#

only arrays have the ability to do the special syntax without new afaik

rancid tinsel
#

would it go to the else on the first time this is run?

#

the way I understood it was that if the IF goes through, the ELSE doesn't and vice versa

swift crag
#

correct

#

in general, in a chain of if / else if / else, the first one that succeeds is run

#

everything else is skipped

#

else always succeeds

rancid tinsel
#

it seems to be doing both though

swift crag
#

doing both what?

rancid tinsel
#

as in doing the IF and then doing the ELSE in 1 run of the code

swift crag
#

and why do you think that's the case?

#

have you, for example, added some log statements to see which path is being taken?

#

perhaps the code is just running twice

rancid tinsel
#

because the ChoiceMadeA thing changes the text in the textbox, and it switches to it instantly

#

hmm maybe

#

only does one debug thats right below it tho

rare basin
#

how to move an UI object toward's mouse position if the mouse is on the edhge of the screen?

    private void Update()
    {
        Vector3 mousePosition = Input.mousePosition;

        bool mouseOnEdge = mousePosition.x <= edgeMargin ||
                   mousePosition.x >= Screen.width - edgeMargin ||
                   mousePosition.y <= edgeMargin ||
                   mousePosition.y >= Screen.height - edgeMargin;

        if (!mouseOnEdge) return;

        Vector3 worldMousePosition = Camera.main.ScreenToWorldPoint(mousePosition);
        Vector3 moveDirection = (worldMousePosition - map.position).normalized;

        map.Translate(moveDirection * mapSpeed * Time.deltaTime);
        clouds.Translate(Vector3.left * cloudsSpeed * Time.deltaTime);
    }

doesn't work, always moves to the same direction (left bottom cornet idk why)

rancid tinsel
swift crag
#

and is gamescreen.choicemade starting out false?

rancid tinsel
#

its starting out true 😭

#

let me check why

lunar grove
#

Anyone know a proper way to code VFX particle animations with trigger?

swift crag
#

are you trying to play a Visual Effect when a trigger collider is entered?

lunar grove
#

Actually I want to play a visual effect when I press a button, while the visual effect which is a slash is coded to damage enemies when it comes contact into them

#

via trigger collider

#

Do i use the particle trigger or do I use another way?

swift crag
#

i don't know what a "particle trigger" is

#

Oh, I see

#

This is a ParticleSystem

lunar grove
#

yeah yeah

swift crag
#

It looks like OnParticleTrigger is run when any particles from a ParticleSystem on the same game object enter or exit a collider

#

you have to ask the system for a list of particles that just entered or just exited

lunar grove
#

Is it worth using the particlesystem trigger though? Because I've seen some people say that they just prefer to use collider to do damage to enemies in games

#

like using collider around effects

swift crag
#

It would be more consistent.

#

the exact paths of the particles wouldn't matter

lunar grove
#

Sooo do I just attach a collider to the visual effect and code it that way?

eternal falconBOT
#
💡 IDE Configuration

If your IDE is not autocompleting code
or underlining errors, please configure it:

Visual Studio (Installed via Unity Hub)
Visual Studio (Installed manually)

VS Code*
JetBrains Rider
Other/None

*VS Code's debugger plugin is unsupported.
We recommend using VS or Rider instead.

rancid tinsel
#

the errors were in my IDE

#

it wasn't telling me what the issue was

#

since the issue wasn't semicolons, it was me messing up syntax for arrays

#

(IDE already configured)

swift crag
swift crag
thick goblet
#

When I SLOWLY left click to play my punching animation while both running and idle everything works. I'm able to move again. Except when I start spamming left click to punch while idle then suddenly my moveSpeed doesn't reset correctly back to 6f and I'm stuck frozen. Anyone know how to solve this? https://gdl.space/origofezut.cpp for the code

#

Could it be a bad Input.?

swift crag
polar acorn
#

@thick goblet When you start punching, it stores your current move speed in a temporary variable and then sets it to 0. After a delay, it returns it to the stores variable. If you press the button while the coroutine is already running, it will store 0 (the current speed) and set it to 0. The first coroutine finished and sets it to its stored value of 6, then the second one finishes and sets it's stored value of 0

swift crag
#

since you're just showing some particles, not drawing a mesh

thick goblet
#

I think I understand digiholic. I will try to solve it now

#

Thank you (Might not be able to though)

lunar grove
wintry quarry
swift crag
#

A box is a classic hitbox shape, yes

lone sable
#

Is there anyway I can hook into a "On Selected" aspect of a UI Component via code? I have a slider I want something to happen on selected/deselected with. I know I could do Animation Events, but, yeah.

It seems I can't hook into this event?

swift crag
#

along with spheres and capsules

lunar grove
#

Yeah i think a lot of games actually use box as a hitbox shape to be more efficient if i remember seeing one gamedev behind the scenes

thick goblet
lunar grove
#

Thanks a lot @swift crag , you're response was a real eye-opener!

swift crag
#

no prob (:

#

Oh yeah, one other thing to consider: you could use a mesh for the collision and as a source for the particles

#

you don't need an actual mesh renderer

#

(you could just turn it off after dragging the model into the scene)

lunar grove
#

Oh okay thanks for the extra tip!

swift crag
#

oh, wait, the particle system's "Mesh Renderer" emission shape...explicitly needs the renderer

#

Still works fine if the renderer is off

#

It does have a "mesh" mode as well, but you will need a Mesh Filter component on the object anyway so that the Mesh Collider works

#

so at that point it's probably just easier to turn off the renderer on a model you dragged in

#

two of the same object; the one on the left has its renderer off and a particle system with an Emission shape of "mesh renderer"

#

mmmm error shader

lunar grove
#

oh okay!

#

thanks again!

#

so that's via the particle system?

swift crag
#

Yep.

#

This will emit particles from each vertex

#

so, for example, you could make a half-torus mesh and use that as the hitbox

#

and also emit particles from it

lunar grove
#

Ah I see super helpful for more complex and detailed game projects

#

thanks for the heplful insights and information

vestal valve
#

What is the use of [System.Serializable] ?

slender nymph
#

the Serializable attribute lets certain serializers know that the type can be serialized

swift crag
#

By default, types won't be serialized, since you might not have intended for them to be saved and loaded

slender nymph
#

and if your next question is "what is serialization" it's basically converting an object into a format that can then be saved/written to disk

lunar grove
#

So I have this preset slash vfx that uses particle system, do I have to use the animator or a different way to make it so the slash vfx gets triggered upon mouse click?

swift crag
#

also, [System.NonSerialized] is used on fields to say "don't serialize this"

#

I like using this for classes that need to store some runtime information

#

for example...

#
[System.Serializable]
public class BlendshapeInfo {
  public string blendshape;
  [System.NonSerialized] public int index;
  public float value;
}
#

I ask the skinned mesh renderer's shared mesh for which index that blendshape name corresponds to at startup

#

so that I don't have to do that every time I update the blendshape

#

The index should not be serialized because there's just no point -- the value will only be known at runtime

lunar grove
#

Where are particle effects usually put into a scene?

#

or are they just called from the assets to play?

sly bolt
#

i have set the numeric values for both the spheres resembling their appearance and they are assigned properly while introduced into scene , but as soon as they collide numeric values of both the spheres turns to zero unexpectedly even though i have no modifications to the numeric values (except the image here).
please provide help this is like my 5th time asking.

swift crag
#

The new Visual Effect Graph package has you attach VisualEffect components to things to actually play the effects

#

but the definitions are stored in assets

lunar grove
#

because I have this game object with a the particle system that generates the attack VFX, and I attached it to my character, is that optimal or no?

#

because the cube collider

#

or box collider hits the enemies and damages them without the vfx playing

#

is there a way to synchronize the hitbox appearance with the particle system vfx?

thick goblet
#

I added a transform rotation to flip my player along with it's child objects so that the x faces the directions it's moving. I'm planning to implement fighting systems etc. Is this method a problem or is there a better way to do it?

swift crag
#

or just ignore the messages

lunar grove
#

is there a code to turn collider on and off?

rich adder
#

why not just 0 / 180

thick goblet
#

Lol uh because it looks cool

sly bolt
eternal falconBOT
#
Posting code

📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

calm coral
#

Your jpg quality is bad

sly bolt
#

.

#

here

#

debug logs are not present in that one but i can assure the numeric value sets to zero right after collision is executed

uncut dune
#

yo guys something is up with my line renderer

#

this is the code

#

and the ShootHitScan(); is being called in the animator

#

the wrong thing is

#

as u see

#

lr.SetPosition

#

is being set incorrectly

#

this is the debug

#

of the pos

#

this is the actual result

#

any idea?

#

from what I have tested there is a big delay

#

it saves an old pos

#

but I have no idea why

polar acorn
#

You're setting the line renderer positions of the prefab

#

Which means it gets applied to the next trail

#

Each one is showing the line of the previous shot

uncut dune
#

OHHHHHHH

#

IT WAS BECAUSE OF A

#

LETTER

#

THANK YOU SO MUCH

polar acorn
#

Also, why is SniperTrail of type GameObject when literally the first thing you do is get a component from it? Make the variable of type LineRenderer and save the getcomponent call

sly bolt
#

if you wish to see debug logs in runtime

calm coral
uncut dune
sly bolt
ashen ferry
#

you want for player sphere to collide with npc one and smaller number sphere should disappear and reduce bigger sphere number?

sly bolt
wary sable
#

Would running While(True) be the same as While(enabled)?

ashen ferry
#

Your current setup is messed up bro u gonna need to go bald im afraid kekW

#

not u dilly mb for not pinging

wary sable
#

Nah I know, that was just a wild comment

ashen ferry
sly bolt
#

here

rich adder
#

hastebin really is garbage

#

use hatebin

sly bolt
#

alright gimme a minute

rich adder
#

which one is the collision script

#

like this part

sly bolt
#

last one (numericsphere)

rich adder
sly bolt
wary sable
rich adder
#

i dont see it being set anywhere else

#

unless im blind

#

oh wait this setting a local one..

#

ur aware of that yes? just checking.

wintry quarry
rich adder
#

adding int in method makes it a local variable, so you're not changing the original SpawnerNumericValue
@sly bolt

sly bolt
rich adder
sly bolt
ashen ferry
#

u got 50 sprites to display numbers btw?

sly bolt
sly bolt
rich adder
sly bolt
#

actually it wont be 50

#

something like 48

rich adder
#

where is this happening

sly bolt
#

because numbers are starting from 2

ashen ferry
#

theres 3d text or something u could look into and just set its text to a number of sphere instead of that many prefabs

sly bolt
#

and if u mean where the randomising is happening then its in the bottom block of code in the same script

#

void shuffle

sly bolt
#

idk not sure

swift crag
#

there's nothing really "special" about 3D and 2D

#

you can slap a TextMeshPro component onto an object to have text appear on it

wary sable
# wintry quarry while(true) will run forever. while(enabled) will only run if and while `enabled...

I suppose I should have expanded my question more... I am writing a behavior designer node (rather converting an existing script I had into a node), and in that script is an IEnumorator with a while(enabled) loop (enabled is a part of monobehavior // not defined in my script). When making a node you have to change the parent class / interface for the class so I cant use monobehavior items like enabled. Would a While(true) loop be an acceptable replacement?

sly bolt
#

ive already made the necessary prefabs so it would be unnecessary at this point

#

unless they are creating a problem

#

i did read about textmeshpro but i thought it was only for 3d objects so went with this approach

ashen ferry
#

but u instantiate whole ass new sphere when u need to change the number

sly bolt
#

yes that is my mistake due to the misunderstanding

#

i will take a look into how it works and rework the project , but i dont understand why the collision is resetting the value

ashen ferry
rich adder
#

only seen NumericSphere script has such an assignement of numbers

#

but idk the value because thats set inside the inspector ?

wary sable
sly bolt
ashen ferry
#

wtf is node is that godot I smell pepeGun

rich adder
#

I don't see where else this is modified besides
Initialize

#

which is being passed in the same SpawnerNumericValue of whatever this script is on

wintry quarry
sly bolt
wary sable
rich adder
wintry quarry
sly bolt
#

changing to zero , even though it shouldn't

rich adder
#

you tried debugging both values before the operatioon and result ?

distant current
#

Can anyone help me with this? My buttons are not working even though there is an event system. It all started ever since I try to load scene additively

sly bolt
#

instantly after collision

#

watch this clip

wintry quarry
rich adder
#
if (SpawnerNumericValue % launcherNumericValue == 0)
                    {
Debug.Log($"SpawnerNumericValue is:  {SpawnerNumericValue} & launcherNumericValue is : {launcherNumericValue}");
                        SpawnerNumericValue /= launcherNumericValue;
          Debug.Log($"SpawnerNumericValue is:  {SpawnerNumericValue} ");
                        SetSpriteBasedOnNumericValue();
                    }```

@sly bolt
distant current
sly bolt
rich adder
sly bolt
#

1 sec

rich adder
#

launcherNumericValue is likely 0 like it says

distant current
sly bolt
distant current
#

I also tried to put my event system in hometown scene itself but still doesn't work

sly bolt
# rich adder yes lets see what the results are in the code

and yes as i anticipated the code changes didnt affect anything because the value getting to zero happens instantaneously after collision so other part of script wont execute because value is zero and i get the error "attempt to divide by zero"

rich adder
ashen ferry
#

that modulus operator is giga random afaik lol

rich adder
#

you cant do % 0

sly bolt
#

yep thats the exact problem

rich adder
#

well i assumed it wasnt because its public so thought it was set in inspector or somehting

sly bolt
#

the numeric values are completely fine until they collide and get set to zero for some reasons

#

no iirc i just set them public to get access in other scripts

rich adder
#

launcherNumericValue isn't being set anywhere

#

so if its 0 in the inspector by default, it wont be changed

sly bolt
rich adder
#

where do you set it according to inputs

sly bolt
#

first script, in the for loop

rich adder
sly bolt
#

yup

rich adder
#

I dont see launcherNumericValue being set

sly bolt
#

yes , its taking the value of 'value'

#

basically taking from input user entered

zealous oxide
#

https://hastebin.com/share/goqinafadu.csharp hey friends, in my 2d platformer, i've changed my player characters dashing ability (as per the screenshot) to be based on the direction the character is currently traveling (as per the code). if the character is going left or right, the dash goes the expected distance, left or right. if the character dashes up or diagonally up, it goes FLYING. now, i'm wondering if I would have had better success going back to my original dashing function but changing the code to allow for a direction based dash (as it is in the screenshot. the screenshot is from before my update, the haste bin is after my update).

rich adder
sly bolt
#

I cross checked if launched spheres have desired numeric values after launched and they do so i can assure their value is not zero initially

weary crystal
#

Getting started with the Unity game development, mainly 3D, any ideas where to start for free?

eternal falconBOT
#

🧑‍🏫 Unity Learn can offer you over 750 hours of free live and on-demand learning content for all levels of experience! Make sure to check it out at https://learn.unity.com/

sly bolt
#

its taking value of value

rich adder
sly bolt
#

no im not changing it im basically getting input from user and storing it in variable value in first script and then taking that variable in the function
void Launchsphere (int launcherNumericValue)

rich adder
#

ur instantiating it without a value or am i missing something
GameObject newBubble = Instantiate(bubblePrefabs[index], transform.position, Quaternion.identity);

#

value types default to 0 when not assigned

#

so probably is 0 when u spawn it

#

`public class NumericSphere : MonoBehaviour
{
private Rigidbody2D rb;
public float movementSpeed = 20f;

public int launcherNumericValue;
public int SpawnerNumericValue;

`

#

launcherNumericValue
isnt assigned but then its 0

sly bolt
#

it has the index value which is declared as launcherNumericValue - 2

rich adder
#

NumericSphere

rich adder
#
 public void Initialize(int value)
    {
        SpawnerNumericValue = value;
        Debug.Log("Numeric Value: " + SpawnerNumericValue);
    }
#

where is launcherNumericValue

#

cause if its not assigned anywhere else, explains the 0..

sly bolt
#

i am getting the value of it in the inspector (whatever i input from keyboard)

rich adder
#

now im hella conusfused tbh lol

#

ima take a quick tea break brodda

ashen ferry
#

I can write skeleton of what u exactly need to do with the spheres not much progress is being made here lmfao

rich adder
#

the code says the value is 0, i trust the compiler

#

this is one of those examples maybe splitting the code so early into different scripts can do more harm than good

sly bolt
# rich adder

what i meant here is the launcher_sphere and spawner_sphere both have their respective values set which is not zero but both values change to zero after both of them collide with each other

rich adder
#

you might just be looking at the defaulted / spawned one that might have 0 value 🤷

sly bolt
#

you can get idea of what im trying to say in this clip , read the debug logs

sly bolt
#

initially before collision

rich adder
#

values don't typically change themselves, so somewhere its being set to 0 and if its not you're looking at the wrong object

sly bolt
#

no i wasnt looking at object but the debug log

#
newBubble.tag = "LauncherSphere";

Debug.Log("launcher Numeric Value: " + launcherNumericValue);```
#

i set the log after launcher sphere is spawned and the value is indeed non zero

rich adder
sly bolt
#

u can watch the clip or i can record new one

sly bolt
rich adder
#

SphereSpawner

#

SphereSpawner may have the correct value but the new object probably does not

#

because i dont see it being passed anywhere

#

if you did newBubble.SpawnerNumericValue = SpawnerNumericValue

#

it would make sense because inside the NewBubble(NumericSphere)
is where you're doing division

sly bolt
#

hold on let me record and show the scene

crisp gate
#

how do i reset my main camera position if it exits a certain x/y position?
let's say if the camera's position is >= 1080, it transforms back to x = 0, y = 0

rich adder
#

assign it the position you want

#
if(camera.transform.x > myXLimit || camera.transform.y > myYLimit) camera.transform = Vector2.zero;
#

etc

crisp gate
#

ooo

swift crag
sly bolt
swift crag
#

you should be able to easily follow that number through your code

rich adder
# sly bolt

it would help if you did Debug.Log(name + valueOrWhatever) but I assume you're just debugging the values on spawner 🤷 like I said, the spawned object that does the division still spawns with a 0 value, why dont u click one of the balls and view the inspector for the current values

#

its really not a hard problem I think there is just misunderstanding

weary crystal
#

Why!??

rich adder
weary crystal
rich adder
#

not for that version

weary crystal
#

So should I downgrade? I'm a beginner.

rich adder
#

its not degrading but it probably is better to use a version that closely matches the tutorials/videos learning

swift crag
#

downgrade, not degrade :p

weary crystal
#

Okay, damn should've known before installing it, thanks.

weary crystal
swift crag
#

but yeah, the 2022 LTS is missing the project templates

#

i dunno what the deal is with that

#

the 2021 LTS will work just fine

rich adder
#

but use 2021 as its less buggy anyway

#

I literally already made 3 bug reports on 2022

#

idk why it was so shotty

swift crag
#

well, we are (relatively) close to the LTS's release

weary crystal
swift crag
#

an LTS is just a version that's going to get patches for longer than usual

weary crystal
#

So the problem is with the version, imma just install the 2021 now.

rich adder
swift crag
#

where's the "works on my machine" sticker

#

what version of macOS are you running?

#

i'm one update behind, I think

rich adder
#

im way old

swift crag
#

last time I updated on a whim I got slammed by that awful GC bug for months

rich adder