#πŸ’»β”ƒcode-beginner

1 messages Β· Page 439 of 1

quick fractal
#

And I'm not interested in serializing the static bool

#

That's for when you're actually in game

#

But changing it to light worked! thanks

tidal trellis
#

Awesome that got rid of that error. thanks! Now i have this last error com.unity.modules.accessibility: Package [com.unity.modules.accessibility@1.0.0] cannot be found
I cannot find this in the package manager in the unity registry though. Does it maybe have a different name?

#

going to just try removing it

mint remnant
#

was hte transform reset position on the prefad of weapon?

tidal trellis
#

Ok seems like i can remove that accessibility thing since nothing was actually using it

alpine dew
#

Think you could walk me through how to properly do this? 'GameObject' does not contain a definition for 'StartCoroutine'

wintry quarry
polar acorn
#

Huh, guess it doesn't

#

Does fadeOut have any sort of unique script on it

alpine dew
#

No but maybe I could make a class just for it and have it only include the delay?

#

actually idk about that

cedar bone
#
...
void PickUp()
    {
        print("test");
        Debug.DrawRay(cam.transform.position, cam.transform.forward*200, Color.red);
        heldWeapon = hit.transform.gameObject;
        heldWeapon.transform.parent = weaponHolder.transform;
        heldWeapon.transform.gameObject.layer = LayerMask.NameToLayer("Weapon");
        heldWeapon.GetComponent<Rigidbody>().useGravity = false;
        heldWeapon.GetComponent<Rigidbody>().isKinematic = true;
        heldWeapon.transform.localPosition = Vector3.zero;
        heldWeapon.transform.localEulerAngles = new Vector3(0, 0, 0);
        heldWeapon.GetComponent<Collider>().enabled = false;
    }        

}
#

well the prefab is attached to an empty

#

and im changing the transform of the empty

#

the empty is heldWeapon

#

its called "pistol" in the editor

raw token
#

I meant their inspectors - where all the components are displayed...

But in any case, the Pistol game object's local position and rotation are changing, and they just won't do that on their own - they'll stay consistent relative to their parent unless something else is affecting them.

Maybe see if something unexpected is referencing the Pistol - enter play mode and drop and pick up the pistol and dance around a bit. Then try right clicking the Pistol game object in the scene hierarchy and selecting "Find References In Scene" to see everything which references it. Failing that, right click on it's Transform component in the inspector and do the same

cedar bone
#

when I did "Find references in scene"

#

the weaponHolder components Pos isnt changing

#

but the actual pistol is

raw token
# cedar bone when I did "Find references in scene"

It will filter the scene hierarchy to show objects which reference it. So go through whatever's present in the filtered hierarchy, and make sure that the scripts which reference the Pistol are really meant to

cedar bone
#

this is the heirchy when picked up

#

Pistol is the thing thats changing position

#

this is when i did "find references in scene" isnt Player meant to be here?

serene dirge
#

Does anyone have any idea how to get a collider to jump along with the character animation?

steep walrus
#

im following a tutorial and I want to add on a little bit by deleting some of the game objects. I have the object in as a prefab it seems as I imported it as an .fbx from blender but when I try to use the "Destroy(Easy);" the Easy party gets underlined red and says it doesnt exist in that context

raw token
mint remnant
steep walrus
#

yes FINALLY

raw token
steep walrus
#

i went to a c# discord and someone sent me over a script that i looked over and ran

cedar bone
#

this is very very wierd

#

idkw ahts moving it

steep walrus
#

i think it maybe fixed my path in environment system variables to the correct thing? not exactly sure what the issue was still but its fixed now thats all that matters

mint remnant
raw token
steep walrus
#

Easy object does exist in my scene, what do you mean by reference it in my script?

cedar bone
#

im doping it on "Pistol"

#

which is an empty

cedar bone
#

weaponholder is in the correct position

#

and Weapon_01 is in the correct position

mint remnant
steep walrus
mint remnant
teal viper
eternal falconBOT
#

:teacher: Unity Learn β†—

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

raw token
# cedar bone im doing it on the transform

I think it'd make sense that Player doesn't show up when performing FRIS on the transform, since the PlayerMovement script only holds a reference the game object and not the transform. But Player should show up if you FRIS the Pistol game object... scratch that - they perform the same search. It's super weird that Player doesn't show up at all πŸ€”

Does your console just log "test" once when you pick up the gun, or is it spamming it?

steep walrus
polar acorn
steep walrus
#

and I want to destroy easy

polar acorn
polar acorn
steep walrus
#

how do i make a variable hold a game object

#

ohhhh

polar acorn
#

Do you know how to make a variable

steep walrus
#

wait i think i get what youre sayin

#

yeah i was just confused what you meant by drag it in ill try again right now

steep walrus
mint remnant
#

consider making a new empty object that holds your script and acts like a manager of objects, then reference the object you want destroyed in there and do it from that object/script

raw token
#

@cedar bone in your earlier code/video, your raycast for the pickup is looking for objects on the "Item" layer, but Pistol is on the Weapon layer...

Did you change that in the code after recording the video? πŸ˜•

steep walrus
cedar bone
#

but weird thing is its not lighting up when I do that

#

so its probably too fast for me to see

raw token
# cedar bone nah it makes sense cause it should only be moving it once, when i run PickUp()

Yeah... I just wanted to definitively make sure, because that was the only code which you've shared that deliberately alters it's position/rotation...

It's super confounding. The only thing I can think of is that some script is referencing it by accident... but then, nothing shows up in the FRIS search...

I guess I might try deleting the object while in play mode and adding a cube as a child of WeaponPos, ensuring that behaves properly. Then manually assigning it to heldWeapon and seeing if it's behavior changes... at least that might narrow down the potential sources of the problem...

Does WeaponPos have any scripts on it?

gaunt escarp
#

my character automatically moves when i press play without any inputs

rich adder
copper orbit
#

hasStarEffect here should turn true if it passes placedPosition == grenadeStarLocation, right?

#

its always giving me false. I am not sure why

rich adder
quick fractal
#

Am I doing something wrong here? My unity script doesn't have public void Start() referenced when the DLL does but I don't imagine that would stop it from working entirely right?

mint remnant
#

not sure what you're attempting to do here, but hte default Start() method is private

quick fractal
#

public void Update works fine

north oar
#

why do variables like if i have a float walkSpeed = 5f; and i want to change it to 10 so i put it as = 10f; it doesnt change it and stays at 5?

quick fractal
#

I see no reason why start being public would break

quick fractal
#

And where

north oar
#

its above the start void and itsa public

mint remnant
cosmic dagger
north oar
#

in the code in visual studio

cosmic dagger
quick fractal
cosmic dagger
quick fractal
#

I'm gonna try it in update where I instantly flip the bool to false

cosmic dagger
quick fractal
#

Either that or the entire block inside of it, yeah

cosmic dagger
quick fractal
#

I'm worrying that it's cause the Unity script linked to the dll via an asmdef doesn't have Start in it

cosmic dagger
quick fractal
#

It says it added it once

#

Which is exactly what I wanted to happen

#

Buuuut, it doesn't work in the slightest

#

The mixer linker automatically defaults to being linked to the master slider which mutes everything so I know it's not adding the component

cosmic dagger
quick fractal
#

There's only one audio source in the scene

#

Pretty sure it can't be different, right?

bold plover
#

I'm a bit confused as I thought I already declared what I needed to?

#

Relevant code lines.

quick fractal
#

Say, if the audio source is above my component that does the searching, that wouldn't be a problem would it?

#

The audio source is on Wave

cosmic dagger
rich adder
quick fractal
#

But it's not

cosmic dagger
#

can't you just look at the GameObject and check if the component is added?

quick fractal
#

No, actually

#

Else I would just add the component manually and be done with it

#

It's not even uh.. Visable in editor

#

All the meshes and scene are gone because I desperately need storage space

cosmic dagger
#

how is the GameObject not visible in the editor?

quick fractal
#

Well that gameobject is

#

It's not usable though

cosmic dagger
#

no idea what that means . . .

quick fractal
#

Cause I need to build the file via a bundle builder and if I just update it in unity, none of the meshes are gonna be there

#

I need to add it after the scene loads so that it links up without doing it in the editor, which is messy but I don't have the storage space for 10GB worth of rocks and castle pieces

teal viper
#

Surely they're gonna be there early runtime

quick fractal
#

They should always be there, looks like it is adding the component though

#

Maybe the last line is just messed up

#

Nope that's.. The only field the component has

north oar
#

i got a script that has public GameObject gun; but its not letting me attach my game object gun to it, the gun has no script or anything its just a cylinder

quick fractal
#

That'd probably be less jank than adding stuff at runtimee I don't know that works

north oar
#

is that too vague

cosmic dagger
north oar
acoustic arch
#

im attemtping to make my enemy ai pathing with NavMeshPlus for 2D

north oar
acoustic arch
#

im recieving the error Failed to create agent because it is not close enough to the NavMesh

north oar
#

well i feel like a goober i just took it out of the folder and it worked lol

#

interesting i put it back in the folder and it loses the game object nvm

cosmic dagger
rich adder
quick fractal
#

Just

{
if (audio.name == "Wave")
{
mixer = audio;
}
}``` looks like it'd work
cosmic dagger
quick fractal
#

Atp I do not care, I just want to get this audio source 😭

#

Plus it'll only run once in start

cosmic dagger
quick fractal
#

That's fixed with a single s

cosmic dagger
#

then yeah, that will work . . .

quick fractal
#

And removing .gameObject

cosmic dagger
#

did you even check the GameObject name after calling FindObjectOfType. is it the correct one?

quick fractal
#

No

#

I did debug it and it was the complete wrong thing

#

Sick, the slider works

#

I can probably add that other component now

#

All fixed, I should use foreach loops more

cosmic dagger
quick fractal
#

There is only one in the scene, I forgot the player is added to that scene, which contains like 50 to look through

cedar bone
#

its the rigidbody

#

but i set it to kinematic tho

#

so idk y

cosmic dagger
quick fractal
#

Not at runtime, nup

#

Like a doofus, I forgot to take the player into account

cosmic dagger
#

have you no shame?

north oar
acoustic arch
#

what exactly does it mean when it says not close enough, what is it checking for

teal viper
slate badge
#

does anyone know the "enabled" equivalent for component?

signal mango
#

There isn't one, because a component has no concept of being enabled

#

That is something Behaviour adds on top

timber comet
signal mango
#

Some non-behaviour components have an enabled state, but it's not something standard so you have to handle those ones explicitly

slate badge
#

Damn because I want to momentarily pause my character's rigidbody and I thought i could use the same logic as making a sprite renderer pause momentarily

tranquil barn
#

guys i was following the unity tutorial course but their code had autocomplete but when i type my code isnt showing suggestions how can i enable them i tried reinstalling both unity and visual code and also tried to install some extra extensions/plugins...
how do i enable it i cant find anything on google

eternal falconBOT
signal mango
#

You can of course also just disable the game object

slate badge
#

is there a way to freeze the location of my character momentarily then?

signal mango
#

constraints lets you do that

timber comet
signal mango
#

rb.constraints = RigidbodyConstraints.FreezePosition;

slate badge
slate badge
#

Okay got a problem

slate badge
signal mango
#

rb.constraints = RigidbodyConstraints2D.FreezePosition;

slate badge
#

Lol i put Rigidbody2DConstraintsatwhatcost

#

Hey is it normal to be stuck on "completing domain"?

signal mango
#

If you're actually stuck on it, that would be a bug

slate badge
#

Damn it

#

Is there any way for me to save the project before force closing?

signal mango
#

Nope

livid path
#

Guys, how to animate padding property in layout group components in Animator? Animator don't see this properties

wheat sapphire
#

i need help asap, i have a problem with my code. my GroundCheck Trigger isnt working, thus making jumping impossible. I do not know what to do at this point

#

πŸ˜”

slate badge
signal mango
#

Set it to RigidbodyConstraints2D.None

modest dust
#

rb.constraints &= ~RigidbodyConstraints2D.FreezePosition;

signal mango
#

That works too, but since it's the beginner channel I wasn't sure if I should start throwing bitwise operations in

eternal needle
eternal falconBOT
signal mango
#

If you're going to do that, you will probably also prefer rb.constraints |= RigidbodyConstraints2D.FreezePosition;

#

Which will merely add the position constraint on top, rather than make it the only constraint (so if you had rotation constrained previously, it will remain constrained)

stark perch
#

why is this happening

worthy tundra
#

i want a float in a script to have a 50% chance of becoming negative, how do i do that?

eternal needle
eternal needle
worthy tundra
# eternal needle Which part do you struggle with? You can get a random value from 0 to 1 and then...

nvm i have another problem.

i have a weapon script that calculates weapon spread, however when i use a shotgun, sometimes the spread is entirely vertical, sometimes entirely horizontal, sometimes a small circle, sometimes a large circle, and these results are always the exact same BASED ON THE DIRECTION IM LOOKING AT.

so, one direction will always give me result x, another direction will always give me result y and so and so.

https://pastebin.com/EYv3KtQe

eternal needle
tender pelican
stark perch
#

what makes it happen

eternal needle
stark perch
#

the character goes into the ground when he lands

#

it kindof glitches when you land

eternal needle
stark perch
#

i decreased the jum force and it fixes it

#

it still happens if you jump frfom a heigh place

#

@eternal needle it happens too when i walk into walls

eternal needle
stark perch
#

somehow it fixed it but only after i made the collider a capsule

cedar bone
#

how do you disable a rigidbody?

#

because I did all of this, and it still moves

eternal needle
# cedar bone

Most of that isnt needed. You simply set it to kinematic and that's all. If its moving still, thats because you're either moving it via the transform or you have it parented under a moving object

#

Also dear lord cache that GetComponent

cedar bone
#

this is how it moves btw

#

its weird, when I delete the rigidbody it stops doing that

eternal needle
eternal falconBOT
eternal needle
#

Also I'd assume you're moving it via MovePosition then

cedar bone
#

i have no other references to that Game Object

cedar bone
cedar bone
eternal needle
#

I have absolutely no idea what you're showing with the video

cedar bone
#

the pistol should stya in one position

#

but because of the rigidbody it isnt

#

its moving around the whole thing

#

and it gets fixed when I remove rb

eternal needle
#

Honestly it's a pain to even try looking around in the video on mobile. But I can see it looks like the object is parented under your player, in which case it will move with the player

#

Kinematic rbs do not move on their own

cedar bone
#

I also sent some msges later that go more into depth

#

for example tehres no scripts referencing it

cedar bone
#

im gonna go to sleep, can u pls @ me if you find an answer

eternal needle
#

πŸ€·β€β™‚οΈ the pistol is very clearly parented under a few objects so im not really sure what else you're looking for.

#

Kinematic rbs simply wont move around by themselves, they are ignored by the physics system

pallid nymph
eternal needle
#

Well from what I see its parented under something called the CameraPos

#

Which sounds wrong

#

For stuff like this, I'd recommend just recreating the object with as minimal setup as possible then adding parts back until it recreates the same issue

inner quartz
#

Hello guys, I'm back, please tell me how I can do the following:
I have my own method by which I improve a certain upgrade. but I have several upgrades. I also have several variables (double): CashUpgradePrice, CashUpgradeProgress, LevelExUpgradePrice, LevelExUpgradeProgess. So, I need to pass some value through the method and this value determines which upgrade I need to improve. Please tell me I don't know how to do this

#

I already have a value passed through the method:

    {

    }```
frosty hound
#

Use an If statement that checks what UpgradeName is and handle the results

inner quartz
frosty hound
#

Then your current attempt at passing the upgrade name isn't going to be useful

#

How are you storing the data for these upgrades, currently?

languid spire
#

A simple option is to replace the individual variables with an array of doubles and the string with an enum. then its just a case of

array[(int)UpgradeName] = //something
inner quartz
frosty hound
#

Oh boy ...

#

Well, in that case, just save everything as floats, and just do PlayerPrefs.SetFloat (UpgradeName, UpgradeValue); and be done with it

inner quartz
#

Maybe anyone know how do I can learn coding on C# more good?

languid spire
worthy tundra
hushed hinge
#

what does this mean?

languid spire
#

what about 'could not be saved' do you not understand

upper ginkgo
#

hello guys, i wanna be a game developer and i am starting my journey. which coding language should i learn? and have any good tutorials?

eternal falconBOT
#

:teacher: Unity Learn β†—

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

upper ginkgo
#

C#*

languid spire
upper ginkgo
#

oh Thank you πŸ™‚

rich adder
cold canyon
#

!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)

cold canyon
#

!vscode

eternal falconBOT
#
Visual Studio Code guide

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

https://on.unity.com/vscode

dry igloo
#

I have a question about Physics material 2D :
I saw I could add a physic material both to the rigidbody and the the collider of an object. Can I just put it on any of these or is there a difference/good practice for that ?

wintry quarry
#

It's pretty straightforward

dry igloo
#

Aaaah ok I see! So RB for the whole object, single collider just for a part of it

#

thanks πŸ‘

dry igloo
#

I have an other question :
I'm making a simple ball breaker game, so with a paddle and a ball. Is it normal if the paddle doesn't have the same speed when I have its inspector open than when I don't ?

I apply a vector2 right/left every frame when the player press right/left, multiplied by speed and by deltatime, to give some context

wintry quarry
#

I apply a vector2 right/left every frame when the player press right/left, multiplied by speed and by deltatime
What does "apply" mean?

#

Providing your actual code would be more useful

#

If you're setting a Rigidbody's velocity, then you should not be using deltaTime

dry igloo
# wintry quarry > I apply a vector2 right/left every frame when the player press right/left, mul...

Yup, here is the whole controller :


Rigidbody2D rb;
public float moveSpeed;

private void Awake()
{
    rb = GetComponent<Rigidbody2D>();
}

void Start(){}

void Update()
{
    TouchMove();
}


void TouchMove()
{
    if (Input.GetMouseButton(0))
    {
        Vector2 touchPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        if (touchPos.x < 0)
        {
            //move left
            rb.velocity = Vector2.left * moveSpeed * Time.deltaTime;
        }
        else
        {
            //move right
            rb.velocity = Vector2.right * moveSpeed * Time.deltaTime;
        }
    }
    else
    {
        rb.velocity = Vector2.zero;
    }
}
wintry quarry
#

right exactly as I said

dry igloo
acoustic arch
mint remnant
#

I put this in my player controller's Start() and it seems to have had no effect on my mouse position. Cursor.lockState = CursorLockMode.Locked;

wintry quarry
mint remnant
#

yup, just dropped a debug right before it

wintry quarry
#

Also did you give your game window focus?

mint remnant
#

it seems to lock and hide when I click though

wintry quarry
#

click on the game window when the game starts.

#

yeah

summer stump
#

Very common issue where the game window is not actually focused

wintry quarry
#

then it's working fine

summer stump
#

This will not occur in the build in the same way. Just an editor thing

wintry quarry
#

Note that the Unity Editor has special handling for this because it's important you be able to still interact with the editor window itself while the cursor is locked

mint remnant
#

ok I guess I just didn't have focus, yea editor I can understand needing to prevent that

#

is it normal when it locks it to also hide it?

wintry quarry
#

yes

mint remnant
#

added Cursor.visible = true; but that didn't turn it back on, guess I'll have to create a little crosshair at center

wintry quarry
terse plume
#

I am trying to wait/get an event when an AudioSource finishes playing... so I am checking isPlaying but paused clips now trigger as completed πŸ€¦β€β™€οΈ
Is there a simpler way I am missing? πŸ™ƒ

#

yep, for what I see people compare the time to 0 or to the full lenght and do some fuzzy stuff to know if something is paused or not πŸ˜›

rocky canyon
#

why not check if its paused first?

#

if its paused ignore it.. check the rest

eternal needle
#

Checking the time would be my first thought to do tbh

rocky canyon
#

ya, seems easy enough

terse plume
#

isPaused ain't a thing πŸ₯²

#

and !isPlaying happens both on Stop and Pause πŸ˜›

wintry quarry
terse plume
#

yep, I was scared of the audio listener doing wacky stuff but I found this.audioSource.ignoreListenerPause = true; so I can do it 🦾

rocky canyon
errant pilot
#

Guys is there a way to have a parabolic trajectory without physics?

rocky canyon
#

i mean yes, u can do custom math

#

thers a formula for it.. just convert it to c# and tada

errant pilot
#

so what translate using the formula?

rocky canyon
#

Need to show the path of a projectile? Not paying attention in Physics catching up to you? No problem! Learn how to draw the trajectory of a projectile would take using a LineRenderer and one of those pesky physics formulas you said you'd never use again! Show a visualization of where those objects will go!

We're using a grenade in this case, b...

β–Ά Play video
errant pilot
#

thank you!

terse plume
#

Verlet intetgration
Y = Y0 + VY0 * time + 1/2 * A * time^2
(keep in mind, I use y0 and vy0 because I use the big boy time and not dt)

Yi+1= Yi + VYi * dt + 1/2 * A * time^2
VYi+1 = VYi + A * time

if you want to use dt

primal trench
#

is there a way to make a script that runs when the game is run no matter what scene your in? like the equivelant of a godot autoload?

polar acorn
#

Put this on your starting scene

tender hamlet
#

I am working with a team of people to create with CAD software specifically for a robotics program (specified parts, not like other CAD softwares) and we want to make it possible to automatically generate chains that connect two gears. I attached an image of what i am trying to do. Ive experimented with unity splines but i couldnt find any way to automate it, it is good for generating a predefined path for chains to generate on though. So what is the best way that i can generate these chains around two selected gears of any predefined size.

cosmic dagger
# tender hamlet I am working with a team of people to create with CAD software specifically for ...

My first attempt would be to place empty transforms at each cardinal direction (NSEW) of a gear (as children). I haven't used splines but you should be able to use the position vector of each transform β€” for both gears β€” to create a spline around them (remember, the front gear will not use its West transform point and the back gear will not use its East transform point)

You need to figure out how to add the bezier curve to round out the spline along the gear, but that shouldn't be too hard . . .

sage mirage
rocky canyon
#

hes wanting to check

#

not set

mint remnant
willow whale
#

does anyone fancy looking at some code and figuring out what on earth ive done

#

because it dont work right

mint remnant
willow whale
#

its a massive block of code i dont know if i should send it all

mint remnant
#

use pastebin for large chunk of !code

eternal falconBOT
willow whale
#

will do, im gonna send a picture of what my current unity looks like idk if itll be helpful to look at the hierarchy

polar acorn
#

What is the actual question though

willow whale
#

the question is

#

there is a slider going left to right and there needs to be green areas which highlight where the player should cut but the green areas are all wrong ever since i realised nothing was coded to fit any screen size other than the one i was working on

#

so the green areas just need to be randomly placed within the range of the slider

#

which may be off aswell

mint remnant
#

AdjustSliderSize() references Screen sizes, but is only called at Start(), never in a Update() call, so changing the screen would not re-call the Adjust

dawn oracle
#

anyone know how i can stop it from adding multiple score? ```js

private void OnTriggerEnter(Collider other)
{
    if (other.tag == "ball")
    {
        if (tagchecker.tag == "ingame")
        {
            if (teamchecker.tag == "blue")
            {
                redscorenum = redscorenum + 1;
                string redscoretext = redscorenum.ToString();
                redscore.text = redscoretext;
            }
            if (teamchecker.tag == "red")
            {
                bluescorenum = bluescorenum + 1;
                string bluescoretext = bluescorenum.ToString();
                bluescore.text = bluescoretext;
            }
            //StartCoroutine(die());
        }
    }
}``` when the ball enters the trigger zone it goes thru multiple times
wintry quarry
#

Does one of your objects have multiple colliders?

dawn oracle
#

uh no i goes thru a random amount

#

sometimes its 3 and somtimes its 7

#

ect

polar acorn
#

How about you log this and other to see what's colliding with what?

dawn oracle
#

im gonna try and disable all collider

#

when it happends

#

go it

#

got it*

mint remnant
#

Confused why this is happening:
I have this calc Mathf.Floor(hit2.point.y / chunk.cubeSize)
where chunk.cubeSize is fixed at 1f
and I print out the hit2.point and the resultant calculation immediately after it
1 time it gives 64 for a hit point of 64, then sometimes it gives 63 for a hit point of 64. Same input in both cases, but the calculation deviates

brave compass
polar acorn
#

Sometimes that division comes up as 64.000001 and sometimes it comes up as 63.9999998

#

Those floor to different values

#

Since printing a vector in Unity rounds to two decimal places, both would print the same value for hit2.point

mint remnant
#

Hrmm, how to solve that? I expected a number divided by 1 to pretty much always equal the same thing

wintry quarry
#

The default is to only show 2 digits

mint remnant
#

print(" Hit Point: " + hit2.point + " Cube Point: " + cube + " Hit Nornal: " + hit2.normal);

wintry quarry
brave compass
mint remnant
#

Hrmm F8 showed it to be 64.00000000

#

Hit Point: (0.68492380, 64.00000000, 0.95993330) Cube Point: (0.00, 63.00, 0.00) Hit Nornal: (0.00, 1.00, 0.00)

wintry quarry
mint remnant
#

yes, in the print I print out cube vector as well, shows 63

#

for completeness here's the entire cube calc Vector3 cube = new Vector3(Mathf.Floor(hit2.point.x / chunk.cubeSize), Mathf.Floor(hit2.point.y / chunk.cubeSize), Mathf.Floor(hit2.point.z / chunk.cubeSize));

wintry quarry
charred spoke
#

Is cube size also a float ?

mint remnant
#

yes cubeSize is a float, fixed at 1f

wintry quarry
#

well let's go ahead and print it just to make sure

charred spoke
#

I don’t think that actually guarantees that it is stores in memory as exactly 1.0

rocky canyon
charred spoke
#

What happens if you just do not do the devision ?

mint remnant
#

Hit Point: (0.45427690, 64.00000000, 0.55240290) Cube Point: (0.00000000, 63.00000000, 0.00000000) Hit Nornal: (0.00, 1.00, 0.00) cubeSize = 1.00000000

wintry quarry
#

What does the division result print?

crystal chasm
rocky canyon
rocky canyon
crystal chasm
#

Sorry I was too slow

rocky canyon
#

no worries

#

i figgured out by changing the padding around.. and then when it wrapped it centered it once.. and all the edges were cutt off

#

so thats when i realized it was wrapping... easy enough to disable it

crystal chasm
#

Cool

mint remnant
#

Hit Point: (0.66471980, 64.00000000, 0.98727500) Cube Point: (0.00000000, 63.00000000, 0.00000000) Hit Nornal: (0.00, 1.00, 0.00) cubeSize = 1.00000000 div = 64.00000000
Divisopn added, now suggest Mathf.Floor is at fault

rocky canyon
#
Cube Point: (0.00000000, 63.00000000, 0.00000000)
Hit Nornal: (0.00, 1.00, 0.00)
cubeSize = 1.00000000
div = 64.00000000```
crystal chasm
#

if (div == 63){ div = 64;}

#

What about Mathf.roundtoint?

rocky canyon
crystal chasm
#

Or if it's a floating point precision error, add 0.0001f to the equation..

rocky canyon
#

whats his issue, now?

#

or shall i go on a scrolling quest

copper belfry
#

Hi

crystal chasm
#

He's using Mathf.floor. and it's doing what it does

rocky canyon
#

ahh soo non-issue lol

crystal chasm
#

It rounds down

mint remnant
#

Mathf.Floor(hit2.point.y / chunk.cubeSize) is returning 63 sometiems 65 other times

rocky canyon
#

lol.. it skips 64?

crystal chasm
#

Use roundtoint

mint remnant
#

opps sorry, 63 sometime and 64 others

crystal chasm
#

I didn't notice what server I was in. My bad. I don't work here.

mint remnant
#

I want it to floor it though, RoundToInt could Ceil it in cases

crystal chasm
#

But it will ceil it to 64

fallen apex
#

i need an UI element in unity that works like a radio button, basically i have for example 3 of them and i can select 1 of them

modest kraken
#

how can I make this more efficient? I basically want to spawn the object randomly within the box collider but in a grid layout, and I also don't want it to spawn on top of itself. ` float minX = Mathf.Ceil(col.bounds.min.x);
float maxX = Mathf.Ceil(col.bounds.max.x);
float minY = Mathf.Ceil(col.bounds.min.y);
float maxY = Mathf.Ceil(col.bounds.max.y);

    Vector3 randomPosition = transform.position;
    while (randomPosition == transform.position)
    {
        float randomX = Mathf.Floor(Random.Range(minX, maxX));
        float randomY = Mathf.Floor(Random.Range(minY, maxY));
        randomPosition = new Vector3(randomX, randomY, transform.position.z);
    };
    transform.position = randomPosition;`
versed light
#

is there a method in unity to use for creating assets automatically ? i tried OnValidate to make sure assets exist for my given data and if not create the asset/save to asset datbase but apparently you cannot do such ops in OnValidate. so is there some built in function that i can run ? i dont want to have to keep manually remembering to press some ui button to verify / regenerate assets every time i change some data

versed light
wintry quarry
versed light
wintry quarry
#

or is this using Unity.Splines or something

zenith cypress
#

You can do asset stuff in validate if you delay it by a frame, like with EditorApplication.delayCall heheheh Not that it's the proper way to do this, but that is a thing that exists lol

versed light
wintry quarry
#

Sure but how? Through a custom editor tool?

#

or just in a ScriptableObject inspector?

versed light
#

currently i use a ui button to call a regenerate method

#

but some times i forget to press it and so the mesh assets no longer match the spline

wintry quarry
#

SO you edit by typing in numbers etc to the inspector?

versed light
#

oh yeah

#

it is a scriptable object

wintry quarry
#

Couldn't you do this through a custom editor?

#

basically at the end of OnInspectorGUI you update/save the assets if there were changes?

versed light
#

oh umm

rare socket
#

I've encountered an issue with Prefab Overrides. I've applied a script to one of my gameObjects within a prefab. The script requires the assignment of a seperate gameObject so it can reference it within the objects script. However, after apply the script and its corresponding gameObject, I am unable to apply the override. Could someone explain what my problem is? (Image for reference)

versed light
#

i think you might be right

#

ill try that then!

wintry quarry
versed light
#

yeh you can only reference prefabs in your asset directory not instanced versions of it

rare socket
#

Hmm... Is there a well known work-around?

versed light
#

no because once you save and exit that reference is gone

wintry quarry
#

Workaround? no.

#

If you want a prefab to know about an object in the scene you need to assign that reference in your code

#

after instantiating the prefab

rare socket
#

Alright then. Will do! :D

uncut crypt
#

I created a shader and am trying to set it as a materials shader but it is not showing up as an option. What could be wrong?

fallen apex
#

i need to select just 1

wintry quarry
#

A Toggle Group is not a visible UI control but rather a way to modify the behavior of a set of Toggles. Toggles that belong to the same group are constrained so that only one of them can switched on at a time - pressing one of them to switch it on automatically switches the others off.

fallen apex
#

i did a gameobject with toggle group component then i put some gameobjects as child with tiggle component

wintry quarry
#

Read the Description part, it says how to set it up

lethal bolt
#

Does Anyone Know how to do Target Rotations The left one should do the same as the right one?

fallen apex
versed light
shell gorge
#

What do I put here? I’m not sure what scopes mean

versed light
#

@shell gorge

shell gorge
#

Oh I need to but a .com link?

slender nymph
shell gorge
#

Oh

#

Where do I ask this then?

slender nymph
#

if your actual intention is to upload your game to itch.io then you need to actually build the game, and upload the build files to it.

slender nymph
shell matrix
#

my state doesn t change, and this appears in animation. If i press manual on the bool variable work but automatic don t. I don t un
derstand why.

shell gorge
slender nymph
#

yeah no, that's not what that is for. like at all. if you want to host your android game on itch.io then you need to build it and upload the built game to itch.io. you do not need to be trying to add a package repository here for any of that

rocky canyon
#

^ go on itch and start the process..

shell gorge
#

Oh. Someone said to do that. Sorry.

slender nymph
#

whoever said that was entirely incorrect

rocky canyon
#

it'll ask u for a build.. (for webGL it'll include an html file) just zip it up and upload it to itch

rocky canyon
#

you just build a game page..

slender nymph
rocky canyon
#

itch's got u

#

they probably recommended itch so u can get play testers

#

w/o needing to have an app and them download it

slender nymph
#

the screenshot you've shown is for adding a package repository to add packages to your project via the package manager

shell gorge
#

Can someone just message me privately about this please? I can’t keep looking At one and another’s comment. Is making my head weirdπŸ˜“

polar acorn
#

So everything you know about this screen you can just ignore it

#

It's utterly unrelated

shell gorge
#

I’m confused.

polar acorn
#

Yes we can tell

shell gorge
#

I want to make it for android, that’s all

shell gorge
#

So I don’t do anything with package manager?

polar acorn
#

No

#

That's where you install packages

shell gorge
#

Okay.

#

Uh what do I do here??

polar acorn
shell gorge
#

Okay

#

Can’t find unity, so I just go to preferences?

polar acorn
#

The slash means "Or"

shell gorge
#

Oh

queen adder
#

BaseHeathbar.slider.value -= 1;
that will subtract one right

polar acorn
queen adder
#

so its just setting it to -1

polar acorn
#

It's setting it to BaseHeathbar.slider.value - 1

queen adder
#

got it thank you im trying to subtract 1 from that value

shell gorge
polar acorn
shell gorge
eternal needle
#

That would indeed be the warning you showed. Unless digi snuck into your room and saw something we didnt

shell gorge
#

Okay

#

It just tells me to go to external tools

polar acorn
#

And it brought you to another one

#

that tells you what to do

#

you need to read the error messages

shell gorge
#

Okay

#

I’m confused. Can you tell me that plz?

polar acorn
#

If you can't read it on the window you're looking at why would you be able to read it if I type it out

shell gorge
#

Idk where it tells me what to do, it just says β€œexternal tools”

polar acorn
#

Did you just forget your own screenshot that you sent when you were there

shell gorge
#

I’m so confused rn

#

I’m at external tools, now, what do I do there?

polar acorn
shell gorge
#

Okay.

#

Okay. Where in unity hub do I get a Recommended Jdk?

polar acorn
shell gorge
#

Ok

#

Where do I add modules at?

polar acorn
shell gorge
#

Install what?

polar acorn
#

Unity

summer stump
#

You're going to have to find the installer you used to install the editor

Or delete the editor and reinstall via the hub

shell gorge
shell gorge
polar acorn
shell gorge
#

Downloading a editor now

polar acorn
#

It would be quite difficult to use Unity without Unity

shell gorge
summer stump
polar acorn
shell gorge
shell gorge
polar acorn
shell gorge
#

Okay

#

The installer is downloading. It’s on 0 of 2

summer stump
shell gorge
#

1 of 2.

shell gorge
#

The editor is now done. What do I do now?

summer stump
#

Did you install a NEW editor, or the same one again?
Or did you do it via the hub?

shell gorge
#

Do I show in explorer and add modules in the folder?

mint remnant
#

The strange solution I came up with to my Mathf.Floor problem is to do this prior to the Floor call

            if(hit2.normal == Vector3.up || hit2.normal == Vector3.right || hit2.normal == Vector3.forward)
                hit2.point += hit2.normal * 0.02f;
            else
                hit2.point += -hit2.normal * 0.02f;
frigid schooner
#

hi helpful people

#

uk how i can do onTriggerEnter then do something right, can I disable a trigger after it is triggered? I only want the trigger to trigger once

slender nymph
#

can I disable a trigger after it is triggered
sure, why not

wintry quarry
cedar bone
#

How would I make a t variable (for Quaternion.Slerp) where the t function is different for every function?

#

kind of like a private variable for a class but for functions

wintry quarry
#

kind of like a private variable for a class
If you want a private variable in your class, make one?

#

t is a float parameter btw, not a function in Slerp

summer stump
#

private float myValue

Done

cedar bone
raw token
#

The code in methods which return IEnumerators is also instanced when you call the method - so you could do that sort of encapsulation in a coroutine, if individual class instances don't fit your use-case Ah I misread

cedar bone
frigid schooner
summer stump
cedar bone
#

can I make it so they have 2 different values

wintry quarry
summer stump
cedar bone
wintry quarry
cedar bone
wintry quarry
#

that wouldn't make any sense

cedar bone
#

Thank you!

wintry quarry
#

in general variables are only accessible in the scope they are declared

#

with public (and other nonprivate) members being the exception, and then only through the . accessor

copper orbit
#

i have a method with a default parameter called defaultDamage. This defaultDamage should be modified in Setup by the attached switch. The numbers printed in Debug are correct but the values are not getting set in the method. What am I doing wrong?

wintry quarry
#

and what do you mean by "the values are not getting set in the method"?

copper orbit
#

totalDamage should overwrite defaultDamage. I can see in the debug.log that the setup is receiving the correct number but it wont take over for the default value for method "buster"

wintry quarry
#

Also I'm a little confused because it seems like Buster calls Setup and Setup calls Buster?

wintry quarry
copper orbit
#

no that setup is for a different script called bullet. its not calling itself

wintry quarry
#

So I'm a little confused if the left screenshot is calling the function on the right, or vice versa

copper orbit
#

defaultDamage is 15. If it receives totalDamage, defaultDamage in "buster" method should be set to that

copper orbit
wintry quarry
#

So this part is not related?

#

so the one on the right is calling the one on the left

copper orbit
#

no thats a different setup for a class called bullet. the one on the right is calling the one on the left, correct

#

the one on the left is not calling, right

raw token
wintry quarry
#

Why don't you do Debug.Log("Buster called with defaultDamage: {defaultDamage}"); @copper orbit

#

on the first line of Buster

#

I'm worried you're expecting that calling the function like this:
Buster(defaultDamage: totalDamage) means that all future invocations of Buster() without a parameter will have that new default value

#

Is that what you're expecting? Because that's not how that works at all

copper orbit
#

that is what i am expecting

wintry quarry
#

yeah you're misunderstanding the default value

copper orbit
#

how can i fix for it to be permanent once received?

raw token
#

A method parameter does not have any persistent state - when the method executes, it's just whatever value is passed in as an argument at that time.

In your code you've specified a default value for the defaultDamage parameter as 15. The only time that that default value matters is if you call method without specifying an argument for that parameter, e.g. Buster() instead of Buster(someValue).

The only way to change the value of a parameter is to pass in a different argument when calling the method.

wintry quarry
#

The only thing having the default parameter value (i.e. doing void Buster(int totalDamage = 15) does is that calling Buster() is equivalent to Buster(15)

#

Buster(defaultDamage: totalDamage) is just using named parameters - it's also equivalent to Buster(totalDamage)

#

also the name defaultDamage for your parameter is confusing - it should probably just be called damage to avoid confusion

#

you could do this:

public void Buster() {
  Buster(this.totalDamage);
}

private void Buster(int damage) {
  //  normal buster code
}
#

since you seem to be already saving the value in this totalDamage variable

copper orbit
copper orbit
wintry quarry
#

note that you would probably not call Buster inside the Setup method

#

just set the variable

#

unless I'm misunderstanding

trail harbor
#

What is the right way to detect a projectile hitting this shield?
I have a mesh collider on it (picture 2)
But nothing happens (picture 3) which is a script attached to the shield

#

It just hits the player, never my shield

wintry quarry
#

triggers are not physical

trail harbor
#

What direction should I go then? If you have a tip

wintry quarry
#

Also a MeshCollider is probably too complex here - should probably just use a BoxCollider

#

or a couple of them

wintry quarry
trail harbor
#

Thing is, a box collider pushes my character

#

I will try something

wintry quarry
#

if the collider part of the player's Rigidbody in the hierarchy it will not push the character, as it will be part of the character

#

unless you did something like give the shield its own Rigidbody

#

basically - you have to pay attention to how you set up the objects.

raw token
copper orbit
#

thats good to know. Appreciate it

spring coral
#

how do i get the DDOL scene?

copper orbit
#

DontDestroyOnLoad(gameObject);

spring coral
#

thats just to put it into that scene

#

im talking about accessing that scene

wintry quarry
cosmic dagger
spring coral
#

i assumed it was something like that, and id need to have to ref to a DDOL gameobj

#

could just throw something in that scene too i guess

wintry quarry
#

you can probably do SceneManager.GetSceneByName("DontDestroyOnLoad")

spring coral
#

let me try that

wintry quarry
#

it won't exist unless there's at least one DDOL object of course

spring coral
#

yeah i know theres multiple in there by the time i get to this part of the code

cosmic dagger
#

do you have any singletons? they're usually DDOL . . .

spring coral
#

no luck

#

and i guess i could do that too?

summer stump
#

What is the actual issue. What are you trying to access the scene for? That could help with suggestions

spring coral
#

i need to collect all root canvases in all scenes

#

including DDOL

#

lol this works

frigid schooner
#

hi i ran into some problems

#

I want to turn off the collider after the firwst collision

#

[SerializeField] private GameObject thecolliderthing;
Collider mycollider;
void OnTriggerEnter(Collider other)
{
if (other.tag == "Player")
{
//update variable
mycollider = thecolliderthing.GetComponent<Collider>();
mycollider.enabled = false;
Debug.Log("Collider.enabled = " + mycollider.enabled);
}
}

slender nymph
#

serialize mycollider and get rid of that GameObject variable. then you won't need to use GetComponent at all since it will already have a reference to the correct collider

#

but also, what exactly is the issue

frigid schooner
slender nymph
#

do what i said and make sure to actually drag the object into the slot in the inspector

dusk glen
#

can somone help me

slender nymph
dusk glen
#

huh am new

summer stump
#

It says you should never ask if someone can help you

#

Just ask your question straighy away, and if someone CAN help, they will

dusk glen
#

oh its just i dont know my sharing game thing dosent work

#

and most tuts are outdated me and my friend spent 3 hours watching tuts none of them worked

slender nymph
#

none of them worked
doubt
it's more likely you've not followed the tutorial(s) correctly

dusk glen
#

no there all outdated

summer stump
dusk glen
#

like the unity thing to share your unity project to others

#

i forgot what its call scm somthing i think

summer stump
slender nymph
dusk glen
#

well they look different

summer stump
dusk glen
#

wheres the channel to ask for it

summer stump
dusk glen
#

sorry am not really good at english is that to join the project or invite

frigid schooner
#

can you check over

#

[SerializeField] Collider mycollider;

void OnTriggerEnter(Collider other)
{
    if (other.tag == "Player")
    {
        //update var 
        mycollider.enabled = false;
        Debug.Log("Collider.enabled = " + mycollider.enabled);

    }
}

}

slender nymph
#

!code

eternal falconBOT
eternal falconBOT
frigid schooner
#

and I drag the collider component in the object to the script serialize field

slender nymph
#

and there is nothing wrong with the code. if you are receiving a NullReferenceException then you didn't bother assigning the variable

frigid schooner
#

what does that mean

wintry quarry
slender nymph
#

that means if you are still getting a NullReferenceException you did not drag the collider into the slot in the inspector on one or more of the objects with this component attached

frigid schooner
#

wait what i dont get it

polar acorn
frigid schooner
#

a line that is commented

slender nymph
#

have you made sure to clear the console, save your code, and try it again? because obviously comments cannot throw an exception

frigid schooner
#

wait im stupid

#

sorry

#

it was line 16 on another script

slender nymph
#

then you didn't drag the TMP_Text object into the slot on that component

#

also get your !IDE configured

eternal falconBOT
frigid schooner
#

I did

slender nymph
#

apparently not considering that is the only thing that could possibly be null in this code

#

and exceptions do not lie

summer stump
frigid schooner
#

line 16
deathstext.SetText("Deaths so far: " + deaths);

slender nymph
#

again, that is because you did not drag the object into the slot in the inspector on at least one of the objects with this component

mint remnant
#

Maybe you dragged it to hte inspector in playmode?

frigid schooner
#

nope

mint remnant
#

so screenshot the inspector of that object showing it and hte script attached

summer stump
frigid schooner
slender nymph
#

add this line to the Update method before the line that throws the error: Debug.Assert(deathstext != null, $"deathstext is null on {name}", this);

summer stump
frigid schooner
#

wait I dont get it

#

why

summer stump
#

Might be a different object πŸ€·β€β™‚οΈ
But it is

Type t:displaydeathtimes in the hierarchy

summer stump
mint remnant
#

I see (1), that suggest there is more than one of these , is the script on another object too?

slender nymph
slender nymph
#

notice how the name of that is different than the object you screenshot before

#

and there are two different object names being printed

frigid schooner
#

the trigger(1)?

slender nymph
#

so you've got this component on at least three objects. where two of them do not have it assigned

frigid schooner
#

this my respawn code under the triggers

wintry quarry
#

you have an object called trigger (1) and one called trigger (2). These have the script on them without the reference being assigned

summer stump
slender nymph
#

fun fact, you can click the error message with the name in it to see what object it is πŸ˜‰

frigid schooner
slender nymph
slender nymph
#

that's not the name of the component though. you need the actual full name of it

summer stump
wintry quarry
frigid schooner
#

sorry guys

summer stump
frigid schooner
#

what do these mean

wintry quarry
#

they mean you have a broken script on some object

#

you can safely remove it

#

for example

frigid schooner
polar acorn
#

Ah, scroll locked. It's been resolved

summer stump
ember tangle
#

I have an fbx file as a child of a GameObject, is it now considered a GameObject in terms of accessing it through a script? I can't find any documentation on it and it doesn't seem like a GameObject as although it has components attached it has a prefab field in the inspector.

polar acorn
frigid schooner
polar acorn
#

Discord didn't scroll down all the way

slender nymph
#

a scene is a hierarchy of different gameobjects, and gameobjects are just containers for components. so in order for something to actually be in the scene, it must be a gameobject with one or more components (even an "empty" gameobject still has a transform component)

ember tangle
slender nymph
#

why would you need to? also, that's just linking it to the prefab in your assets folder

ember tangle
#

The "battle map" scene will eventually be created with a JSON file made by the "campaign map" scene, and unless this is a very wrong way to go about it I intended to create all of the 'units' in script from a generic prefab that would have the models and stats attached as it built the battle map.

#

so the unit has a model that in this case is an imp, but would be swapped for an acher when needed etc etc

slender nymph
#

okay well that Prefab field there does not exist at runtime. that is something that is editor only to allow overrides to/from the prefab

#

you get get references to the prefabs you have in your assets folder and instantiate them based on the data in the json file, but that wouldn't be relevant to that Prefab slot you see

ember tangle
#

now I think I need to instantiate this object with the animator attached in script from a prefab instead of what I am doing now.

#

thanks for your help

sour fulcrum
#

Is C# Dictionary's TryGetValue safe to use if the value is null?
Troubleshooting an error I have and just wanted a vibe check

sour fulcrum
#

thank you

slender nymph
#

yes, but if you are potentially storing null as a value you'll probably want to null check them

sour fulcrum
#

yeee

wintry quarry
#

of course it wouldn't be safe to dereference that null afterwards...

polar acorn
sour fulcrum
#

id elaborate but its weird niche modding stuff that i would be shot to death for speaking on πŸ˜„

steep walrus
#

how can i wait a set amount of time to run the next line of code, i have looked it up and found solutions but none of them are working for me

slender nymph
#

use a coroutine. note that the code that is being delayed needs to be called from in the coroutine, but after the delay

slender nymph
steep walrus
#

yeah i just looked that up sorry i shoulda looked it up before asking

slender nymph
#

lmao wtf i just noticed the documentation examples use an infinite for loop in one of the examples instead of a while loop. like i know it's technically valid but that's just so cursed as example code for beginners

mild onyx
#

why is it trying to say that speed is a double when i made it a float at the start?

wintry quarry
#

it's saying 1.5 is a double

#

you can't put a double into your float variable

cosmic dagger
mild onyx
#

ah, 20 minutes of google wasted

cosmic dagger
#

Look at how you assigned it when you declared speed at the top. What looks different?

static cedar
teal viper
#

or rather, you don't want it to be converting double to float implicitely

mild onyx
#

changed an if statement to a while to test a theory and it broke my unity

teal viper
#

Broke..?

mild onyx
#

cant interact with it at all, i think ill have to close it with task manager

#

happened the exact moment i pressed shift (its in the while statement) and i can still hear the music

teal viper
#

You could try breaking it with the debugger(assuming it has a simple breaking condition)

mild onyx
#

seems strange that i couldn't minimize the window or anything though, i just used task manager but im gonna test it again to be sure it was the code

teal viper
#

It's weird that you can still hear the music though. That would imply that it's not a real freeze.

teal viper
mild onyx
#

yep the while is definitely the cause, ill just use an if and an else instead

cosmic dagger
mild onyx
cosmic dagger
# mild onyx why?

As dlich mentioned, you'd lose precision going from double to float. Assigning back to a `double!+ will yield different results depending on the accuracy needed for the value . . .

mild onyx
#

good point

teal viper
mild onyx
#

well google said that getkeydown() was a boolean, so i figured adding a while infront would make it a "while this key is down type thing". instead im going to do it so that if getkeydown () multiplies the speed and else sets it back to its original value

#

if you get what i mean

north kiln
north kiln
static cedar
wintry quarry
ember tangle
#

Can someone explain to me what the private set means? ```public abstract class Foo
{
public string Name { get; private set; }

 protected Foo( string name )
 {
     this.Name = name;
 }

}```

wintry quarry
ember tangle
#

but why would the set be private in the context of an abstract class

wintry quarry
#

To prevent any other classes from setting that property

#

In this case it's making sure only the constructor can ever set the property

ember tangle
#

wouldn't the inherited class would be setting it?

wintry quarry
#

it's preventing that on purpose

#

it can only be set through that constructor the way it is written

ember tangle
#

what I am reading has it used this way, im just trying to understand it: public class Bar : Foo { public Bar() : base("bar") { ... } }

wintry quarry
#

since the constructor is protected, inherited classes can call that constructor

ember tangle
#

when inherited

wintry quarry
#

this is a constructor on a child class which is calling the constructor on the parent class

#

this is the only way that the child class can set that property the way it's set up

ember tangle
#

but the string is still unique to the inheriting class?

wintry quarry
#

I have no idea what that means

ember tangle
#

"bar"

wintry quarry
#

what about it

#

The value of the Name property will be set to "bar" here.

#

that's all

ember tangle
#

buts its bar.name, right?

wintry quarry
#

No, Name is the property

#

not name

#

and I'm not sure what you're getting at with that question exactly

#

You can do:

Foo example = new Bar();
print(example.Name);```
#

this will print "bar"

ember tangle
#

okay perfect thankyou

#

I get it

wintry quarry
#

You can also do

Bar example = new Bar();
print(example.Name);
#

it will print the same thing

teal viper
cosmic dagger
summer stump
void thicket
earnest beacon
#

ik this isnt really code but uhhh

rich adder
#

if its not code why did you post it here

earnest beacon
#

well where am i supposed to put it

rich adder
earnest beacon
#

ok

#

hold on

#

aha

#

couldnt find a good place

#

thanks

queen adder
#

How would I make something turn to a random range of rotatinons

ivory bobcat
queen adder
#

Oh that helps a lot makes me think and i think i got it thank you!

daring mortar
#

i was wondering if anyone give me any pointers on how i could get it to only instantiate one object but keep it moving all in one script

mint remnant
#

If I have a prefab that has a script with a constructor on it, how would I go about calling that or can you even?

willow scroll
#

Constructors are used to create an instance of the type, but it's not required when this type is attached directly to the object

#

Also, you cannot call it, because, in this case, you're going to create another instance of this class

#

Which does not make sense

raw token
#

Use Start()/Awake() for initialization instead... Constructors on MBs aren't really supported and will act weird πŸ‘€

mint remnant
#

So the alternative would be to get a reference to each object instantiated and from there pass along pertinant info like that object's ID or some such?

willow scroll
raw token
mint remnant
#

a minecraft replica, World class will spawn chunks at locations, but then each chunk will need to know if it's the one being touched, instead of all of them at once

rich adder
#

or make a bool for it

daring mortar
daring mortar
#

ill see what i can do

rich adder
#

or store it in a field, only spawn if null

willow scroll
#

You seem to instantiate the object, somehow move it, and destroy, all in one frame?

#

Oh, I now see, it's about timing

#

Haven't mentioned that float DestroyAfter

#

You have to create a variable for a Coroutine, which, if null, is assigned to a new Coroutine, which does all this using a WaitForSeconds class

#
private Coroutine _attackCoroutine;

private void Update()
{
    if (_attackCoroutine == null)
        _attackCoroutine = StartCoroutine(Attack(10f));
}

private IEnumerator Attack(float lifetime)
{
    // spawn & move
    yield return new WaitForSeconds(lifetime);
    // destroy
}
daring mortar
#

thank you so much im still learning so this helps alot

cold ruin
#

I'm learning drag and drop script UI but when I dragged the UI object , it starting to teleport somewhere far away. what am I missing here? (vid and script in file)

mint remnant
#

No idea what a .mkv file is, but I assume it's some kinda video

cold ruin
#

idk what other video file beside this... but ya, it's a video showing my problem

mint remnant
cold ruin
#

here

mint remnant
#

ok so video shows what's going on, but you're going to need to post the code outside of a video, see !code for the best ways to do that

eternal falconBOT
modest dust
#

Your canvas is in world-space render mode and you're giving your dragable item a world-space position of your mouse position which is pixel coordinates of where it is on your game window screen

cold ruin
#

then how can I fix it ?

modest dust
#

Either change the canvas to screen-space, keep the dragable item in the canvas and adjust the anchored position, or transform the mouse screen position into world position

cold ruin
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using UnityEngine.UIElements;
using Image = UnityEngine.UI.Image;

public class DraggableItem : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
{
    [Header("UI")]
    public Image image;

    [HideInInspector] public Transform parentAfterDrag;
    public void OnBeginDrag(PointerEventData eventData)
    {
        image.raycastTarget = false;
        parentAfterDrag = transform.parent;
        transform.SetParent(transform.root);
    }

    public void OnDrag(PointerEventData eventData)
    {
        transform.position = Input.mousePosition;
    }

    public void OnEndDrag(PointerEventData eventData)
    {
        image.raycastTarget = true;
        transform.SetParent(parentAfterDrag);
    }
}
#

where should I fix it again ?

#

i'm dumb sorry

modest dust
#

Fix it where you change it's position obviously

#

OnDrag

#

Reference your Camera and transform the mouse screen position into world position, docs linked above

cold ruin
#

after almost an hour, my idiot brain still can't proceed how it can be done right while reading the docs

copper python
# willow scroll ```cs private Coroutine _attackCoroutine; private void Update() { if (_atta...

By the way if you really want to improve your code to the maximum, you could change

if (_attackCoroutine == null) 
     _attackCoroutine = StartCoroutine(Attack(10f));

Into

_attackCoroutine ??= StartCoroutine(Attack(10f));
```.

`??=` is called the null-coalescing assignment operator and can be used to remove a lot of if statements which check whether a variable is null. It's pretty nice if you know how to use it
#

Yes I'm a nerd πŸ€“

static bay
#

Input.mousePosition gives the mouse's position in screen space in terms of actual pixels, with the bottom left being 0, 0.

#

Your image is being sent to the correct position based on that.

#

But your canvas is in world space.

willow scroll
cold ruin
#

but when i changed it into screen space, it either ridiculously big or ridiculously small, and it won't let me resize it, if the problem is my script, I still don't know how to fix it

static bay
#

Because yes, in the scene view ScreenSpace/Overlay UI can look very large.

queen adder
#

Guys I tried everything, i cant enable intellisense, dont send me docs and websites, i already tried everything

willow scroll
queen adder
#

i have neccery packages and VS code unity ext and c# ext downloaded

static bay
#

Have you tried using Visual Studio instead?

cold ruin
willow scroll
static bay
#

Is there any reason it's not just using Screen Space - Overlay?

cold ruin
static bay
#

Just double click the canvas to have the scene view camera focus on it, and click the 2D button, and you should have an easy time messing with it.

#

As for appearing small in the game view that must be due to your own scalings.

#

I wouldn't be surprised if you started with Overlay, swapped to World, and then scaled it way down until you saw the elements.

cold ruin
static bay
#

All good.

static bay
#

Like these 3 specifically

shell herald
#

i have a system where if the player manages to accidentally deselect the ui and is on controller, it auto selects a pre set button again.

currently i have this if statement:

if (EventSystem.current.currentSelectedGameObject == null)

But Rider is telling me that comparison to null is inefficient. is there a way to do the same thing but in a more efficient way?

static bay
#

if(!EventSystem.current.currentSelectedGameObject)

#

Objects have a implicit conversion into a bool.

#

So you can just slap them into if statements where true is when the object exists and false when its null.

shell herald
#

ah, aight

#

thx

static bay
#

I BELIEVE that's what Rider is guiding you towards.

pallid nymph
willow scroll
cold ruin
arctic ibex
#

Is there any reason my reference isn't turning up in the inspector???

pallid nymph
#

compile errors

arctic ibex
#

no

pallid nymph
#

you haven't saved? πŸ˜„

arctic ibex
#

already saved, zero erros

pallid nymph
#

ah..

arctic ibex
#

It's just not there πŸ€·β€β™€οΈ

pallid nymph
#

make a change (like add an empy line), save again, go to Unity?

arctic ibex
#

good idea

pallid nymph
#

maybe it hasn't properly recompiled, it does that sometimes

arctic ibex
#

nope

pallid nymph
#

alternatively, make sure Slider is what you think it is

arctic ibex
#

nothing there...

pallid nymph
#

make sure it's the one in UnityEngine.Whatever, and not a local class created by mistake or something

arctic ibex
arctic ibex
#

okay, it randomly appeared now

pallid nymph
#

well, it wouldn't show if it's not something that extends from UnityEngine.Object or is [Serializable]

arctic ibex
#

even though i didn't change anything....

#

weird, but I'll take it

pallid nymph
#

it's Saturday, Unity is a bit lazy

arctic ibex
neat bay
#

why is the normal between circles 1-3 unchanging - and hwy does it only change when it grabs the normals of the floor? Am I misunderstanding what hit.normal returns?

#

Heres the code for the instantiation:

Instantiate(magicCircle, transform.position - (Vector3.up * 0.5f), Quaternion.Euler(hit.normal * 90));
pallid nymph
#

show all the code (in some code pasting site, you know, like hatebin or gdl.space)

neat bay
#
[SerializeField] GroundedCheck grounded;
[SerializeField] GameObject magicCircle;

RaycastHit hit;

void Update()
{
    if (grounded.grounded)
    {
        Physics.Raycast(transform.position + (Vector3.up * 0.01f), Vector3.down, out hit);
        Instantiate(magicCircle, transform.position - (Vector3.up * 0.5f), Quaternion.Euler(hit.normal * 90));
        Debug.Log("Normal: " + hit.normal + "Altered: " + hit.normal * 90);
        Destroy(gameObject);
    }

}

this is literally it

#

oh wait

#

i think im an idiot

#
Physics.Raycast(transform.position + (Vector3.up * 0.01f), Vector3.down, out hit);

this is wrong right?

teal viper
#

I'm more worried about that silly rotation calculation

neat bay
#

Vector3.down is casting a ray only onto flat surfaces right?

neat bay