#💻┃code-beginner

1 messages · Page 345 of 1

deft grail
#

before

cold orbit
#

i don't get anything in the console

deft grail
#

then thats why its not setting it

#

because it doesnt run

reef raven
#

Hi, I think I messed up a bit, was attemtping to make my character unavaiable to jump while mid air but it keeps doing so :( ,

deft grail
#

you didnt add the layermask into your Physics2D check

rose galleon
#

anyone knows how unity detects key press?

deft grail
cold orbit
deft grail
rose galleon
#

i was working on a double jump and I am using a float for that like a jump counter: on ground - 0, first jump - 1, second jump - 2

#

you can only double jump if jump counter is < 2

#

it was working perfectly

#

however, if I hold the key, apparently the code runs twice, because I cant double jump

cold orbit
#

can you tell me what should i write so that when i click the button the activeBuildingType change to the BuildingType that as been clicked (sorry if its not clear)

outer scarab
cold orbit
swift crag
#

this is for saving changes after you modify serialized data (which is an editor-only thing)

swift crag
#

I'd also log the Button you're accessing

#

so store the Button in a variable and then log that

swift crag
outer scarab
#

Oh true

swift crag
#

Actually, it's possible that you just have a messed up UI

#

If you don't have an EventSystem, you will not be able to interact with the UI

outer scarab
#

So reflection is the way to go

swift crag
#

what

swift crag
#

Search for this in the hierarchy

#

t:eventsystem

#

A single object should show up.

fresh wing
#

heyho guys, I wanna ask is it possible to add ui components for each element on a json array?

this is my array
[
{
"question": "What is .....",
"type": "multiple_choice",
"options": ["answer1", "answer2", "answer3", "answer4"],
"answer": "answer1"
},
{
"question": "tell me who is ....",
"type": "essay"
}
]

cold orbit
#

there's nothing when i type t:eventsystem in the hierarchy

swift crag
#

okay, you need to add one

#

go to GameObject > UI > EventSystem in the top menu bar

#

that'll create a new object with an EventSystem component on it

#

this is responsible for things like clicks

swift crag
#

Although, because you have multiple question types, it could be a bit difficult..

fresh wing
#

but Im planning to not use the essay type though

swift crag
#

well, sure, once you have a list of objects, you just instantiate a prefab for each object

fresh wing
#

only the multiple_choice

swift crag
#

parsing the json is the interesting part

#

For a single question type, it's simple: you'll create a class like this:

[System.Serializable]
public class Question
{
  public string question;
  public List<string> options;
  public string answer;
}
fresh wing
fresh wing
swift crag
#

right, and so you'll deserialize a List<Question>

#

It handles many more kinds of data -- like Dictionary<K,V>

#

JsonUtility can handle anything you can serialize in the inspector, basically

swift crag
cold orbit
#

@swift crag yessss i added one and now i get the debug.log that something got clicked

fresh wing
#

@swift crag is do you know where to find JSON.NET link?

swift crag
#

you'll want to install this through the package manager

#

...er, this page doesn't tell you how to do that lol

#

The name is com.unity.nuget.newtonsoft-json

tough trench
#

I just started learning unity and am trying to make something that when 5 copied prefabs collide with a cube they add 1 to the score does anyone know what I'm doing wrong?

swift crag
swift crag
#

my settings file looks like this 😁

tough trench
swift crag
#

have a look at this page

#

it'll walk you through the possible problems

tough trench
swift crag
#

i used to have a ton of trouble making physics messages work right

rose galleon
summer stump
# rose galleon that isnt the point-

It may be part of the issue since you are doing float comparisons.
Impossible to say without seeing code. Not sure if I missed where you shared it

fresh wing
rose galleon
#

mb

#

nvm

#

fixed it

#

it had nothing to do with key detection

#

but instead with me checking the y value for some reason

sick jay
#

im gonna bump this since i havent received a reply yet

fresh wing
#

@swift crag can I ask?,
is there any tutorial on how to clone prefab and add it into a list

#

so every prefab has a property of which is the selected option

#

and is it possible to make it scrollable?

swift crag
fresh wing
swift crag
fresh wing
summer stump
rose galleon
#

thats why it didnt work when falling

rose galleon
#

the main one is the most obvious one, Im using transform.position, so its gonna behave more like a teleport than a dash

#

so I wanted a tip for something to replace it with

#

and the second problem is that if I press right and left continuously, there is no distinction, so if I press a and soon after d ill dash to the right, even though the initial input was to the left

slender nymph
#

the most common suggestion for a dash would be to use a rigidbody and just assign the velocity. of course you'll also likely want to prevent other input from overriding that velocity for the duration of the dash, but that is fairly easy

rose galleon
#

or is that just elongating it unnecessarily?

rose galleon
#

nothing came out of it tho

#

huh

slender nymph
#

either you are overwriting your velocity somewhere, something is blocking it from moving, or there is some other issue with your setup. without having any other context it is impossible to know 🤷‍♂️

topaz mortar
#

Good morning 🍎

violet glacier
#

Should I be using textmeshpro or legacy text?

slender nymph
#

TMP

cosmic dagger
#

text mesh pro . . .

violet glacier
#

Thanks :)

rose galleon
rose galleon
slender nymph
rose galleon
#

isnt the whole concept of update being called every frame?

slender nymph
#

you don't "shut it off" you can use logic, like an if statement, to prevent it from doing certain things

rose galleon
slender nymph
#

yeah, that's one way to do it

rose galleon
slender nymph
rose galleon
#

and the result did not change

#

;-;

slender nymph
#

okay now take a look at your logic again and remember that there are no delays in your code at all

rose galleon
#

oh

#

dash duration?

slender nymph
#

you set isDashing to true on one line, then within the same method, with no delay whatsoever other than the two lines in between which also run immediately you then set it to false

rose galleon
#

IEnumerator it is then

slender nymph
#

you don't necessarily need a coroutine, if you just track when you start the dash and ensure you don't allow input when the current time is less than dash start time plus dash duration

rose galleon
slender nymph
ivory bobcat
#

This is the beginner coding channel. You should move (delete here and post at the correct location) your message to the appropriate channel.

opaque hinge
#

okay sorry

slender nymph
#

first of all, #archived-networking
second, you absolutely need to understand the basics before attempting multiplayer
third, you haven't done any networking of your object there

#

no

charred spoke
#

Well why do you think your bullets are only client side ?

#

Good guess. Your script is not telling anyone it is firing bullets

#

What behaviour are you looking for here? The server fires all bullets and syncs to all clients or something else?

#

Me personally I would not let the client fire bullets

#

Why do you need the server to see it ?

#

In that case?

swift vessel
#

Hello,I have a question, I am going to start making 2d pixel game in Unity, but I wonder what is the best Unity version for 2D ?

slender nymph
#

there is no "best" version. also this is a code channel

slender nymph
#

although i will say that 2022 introduced several QoL changes to the 2d physics api so go with that version or newer

charred spoke
#

The server seeing the bullet will not magically sync it to other clients. Multiplayer is a bit more complicated than you think. I suggest you start reading the docs for the MP framework you are using. Try to spawn a cube server side and have it synced to 2 clients first. Then move on to bullets

slender nymph
stuck crest
slender nymph
stuck crest
#

dang where did everyone go

slender nymph
#

well this is a code channel so it isn't really the right place for that question. but is your camera perhaps a perspective camera rather than an orthographic one?

#

hint: it is. so you also see depth

charred spoke
#

You lack all the fundamentals to do what you want. Start simpler like I suggested.

eternal needle
#

yea thats exactly why you should try building the next valorant. Have you finished your kernel level anticheat yet?
Dont waste your time, start simpler.

#

does it matter? if you dont understand the basics then ANYTHING multiplayer is going to be too complex. Even if its pong

#

you dont need to convince me, or anyone else that was advising you. Its not our project.

#

you also CLEARLY lack the fundamentals for unity give this is in your code
new Quaternion(0,0,0,0))

grim flare
#

hi guys im doing my 2d game but my enemy don't trigger animation event
it just disappear after die

slender nymph
#

show relevant code since this is a code channel

stuck crest
#

hello guys

#

how can i make something like this?

#

through code?

charred spoke
#

Have fun stumbling in the dark then

stuck crest
#

the roblox studio stage was crazy ngl

#

those were the days of peak developing

slender nymph
# stuck crest through code?

the layer variables are just LayerMask type. then you can either create a struct with the data you want to fold out like that, a custom editor that has a foldout, or a third party asset like NaughtyAttributes which has a Foldout attribute

grim flare
slender nymph
#

!code

eternal falconBOT
late jolt
grim flare
slender nymph
late jolt
slender nymph
#

oh of course, how could i not have known that since i definitely have intimate knowledge of your project!
anyway, what debugging have you actually done?

zinc shuttle
#

need help, i cant organise my scripts
i made so many code about everything but some code need other gameobject's code to work
any tutorial to lern how to manage all the classes and how to use classes for other class?

slender nymph
#

there isn't really an "organize my project" tutorial. how to organize everything really just comes from experience. don't be afraid to refactor things either, especially when things get messy, that's how you get the experience

late jolt
slender nymph
#

have you checked the console for errors? i saw at least one at the beginning of the video, not sure how relevant that one is. have you ensured that the variables you are using are the what you expect them to be?

late jolt
slender nymph
#

okay that doesn't really answer much of what i asked

coral crater
#

thanks for the info, do you (or anyone who has experience in this) have a recommendation transferring the values of the item script to one another instead of just moving the array? Ukikimp1qu

storm pine
#

Hello, I have a problem with my code. For a level y have to count the amount of steps of my player, because he dies when it reach a limit. but now, depending the size of the screen (if I play focused or maximized) for the same game distance it counts differents steps. This is my code:
The LvlManager that receive the steps:

private int stepCount = 0;

    private void OnEnable()
    {
        MovimientoTopDown.OnPlayerMove += IncrementStepCount;
    }

    private void OnDisable()
    {
        MovimientoTopDown.OnPlayerMove -= IncrementStepCount;
    }

    private void IncrementStepCount()
    {
        stepCount++;
        Debug.Log(stepCount);
        if (stepCount <= timeSlider.maxValue)
        {
            timeSlider.value = stepCount;
            // Actualiza el alfa de la imagen del panel
            darkPanelColor.a = timeSlider.value * fadeRate;
            fadeDarkPanel.color = darkPanelColor;
        }
        else
        {

            StartCoroutine(ShowFailSequence());
        }

    }

And this the PlayerMovement script that activates the event:

private Vector2 lastPosition;
    private float movementThreshold = 1.0f; // Umbral de movimiento para disparar el evento


    private void Start()
    {
        keepMoving = true;
        animator = GetComponent<Animator>();
        rb2D = GetComponent<Rigidbody2D>();
        lastPosition = rb2D.position;
}
private void FixedUpdate()
    {
        if (GameController.GetInstance().isGameStarted && keepMoving)
        {
            direccion = new Vector2(movX, movY).normalized;
            rb2D.MovePosition(rb2D.position + direccion * velocidadMovimiento * Time.fixedDeltaTime);
            if ((rb2D.position - lastPosition).magnitude > movementThreshold)
            {
                lastPosition = rb2D.position;
                OnPlayerMove?.Invoke();
            }
        }

    }
slender nymph
#

the same game distance
it doesn't actually sound like it is the same game distance. how are you measuring this distance

#

because it sounds like you may be using some UI elements and your player is moving in world space between those UI elements that are in screen space. and when your resolution changes, that affects how much the camera can see in world space due to the orthographic size

storm pine
#

The movX and movY values are obtain this way on Update()

movX = Input.GetAxisRaw("Horizontal");
            movY = Input.GetAxisRaw("Vertical");
slender nymph
#

that's not relevant to what i asked

storm pine
#

On my game the player moves on a tileMap that is inside a Grid. And then I just send this to the canvas using a renderTexture(). So I think it's not measuring anything with the canvas

slender nymph
storm pine
slender nymph
#

did you not even read what i had initially asked you? or do you just not want to actually answer that?

#

how are you measuring the distance travelled and how have you confirmed that it is actually moving a lower distance on higher resolutions

icy sluice
#

how do i hit a backface of an convex mesh?

storm pine
slender nymph
#

you said "depending the size of the screen (if I play focused or maximized) for the same game distance it counts differents steps"
how have you measured any of this to confirm that

storm pine
#

Because I have a slider with a maxStep as slider.maxValue set, and in maximized it advance slower than focused. In focused it advance so fast as I move

slender nymph
#

so you are making assumptions without actually confirming anything. in that case, show a video of what is happening so i can actually get some relevant details

#

use mp4 to embed in discord or upload to some remote host

storm pine
#

Yeah, sorry I don't know why it was recorder as mkv

#

Give me a moment

slate haven
#

if u cant open this website u can also use vpn

slender nymph
#

if you used obs with default settings to record it then just change the extension to mp4, it should be in a codec that is easily supported by both

storm pine
#

You can see here that in focused the slider is like 25% and in maximized it goes like to 50% of the slider

storm pine
storm pine
slender nymph
#

the X position is different there where it should be the same. so you are resizing something, there is a difference of 0.08 units, which isn't a lot but depending on the values you are using to determine a step it could be significant

storm pine
slender nymph
#

FixedUpdate runs at a fixed rate. if it is printing a different position when you are in the same position at different resolutions then you are resizing the game world based on the resolution rather than the camera's orthographic size

storm pine
# slender nymph FixedUpdate runs at a *fixed* rate. if it is printing a different position when ...

I found something interesting. My problem is not about how is resizing the game world. Because now I have count the steps on the player movement and it gives the same result if I go to the signal in both resolutions (32). So my real problem I've discover is how the lvlManager is receiving the event, but is supose to be the same, but I can't understand if this FixedUpdate updates the steps slowly, the levelManager that is suscribed to that event gives high values (1000 and thing like that for the same distance) since the OnPlayerMove is only Invoke when a step is incremented```cs
private void FixedUpdate()
{
if (GameController.GetInstance().isGameStarted && keepMoving)
{
direccion = new Vector2(movX, movY).normalized;
rb2D.MovePosition(rb2D.position + direccion * velocidadMovimiento * Time.fixedDeltaTime);
//Debug.Log(lastPosition);
if ((rb2D.position - lastPosition).magnitude > movementThreshold)
{
totalSteps+=1;
Debug.Log("Steps: "+ totalSteps);
lastPosition = rb2D.position;

            OnPlayerMove?.Invoke();
        }
    }

}
slender nymph
#

show the full code for both classes

storm pine
slender nymph
#

show the LevelManagerBase as well. and for future reference, it is always better to use two links than to post the files together like that.

fringe plover
#

Was fixing save loading bug for 10 mins, found bug: 😂

storm pine
slender nymph
#

yeah that'll do it. you'll have more frames when not viewing the editor since it doesn't need to draw the inspector and other editor elements every frame

storm pine
queen adder
#

How do developers attach clothing to a character that has multiple body types? Such as seen in the WWE character customization. Is there a name for that?

slender nymph
#

don't crosspost

queen adder
#

? It's a coding question

eternal needle
#

Ok show relevant code then and we can help

deft grail
queen adder
#

I did

#

Relax Karen's I'm just trying to find help

tough cave
#

bruh, why is my prefab not working when sending it to git, to a new branch... Its an empty object/prefab when i merge it to a other branch ughhh... :{

hasty tundra
#

Is there a way of converting multi-dimensional arrays to a string value? im trying to sort a save system for my games high scores, which (due to how many varients of mode there are) are best stored in a 3D array. However, when converting these values to a string to save in a Json all the data is lost. Any ideas on how i can solve this?

eternal needle
# queen adder ? It's a coding question

This is also definitely not a coding question. Probably more blender/asset related. Once you have the model which can actually swap out body types then it's just a matter of toggling the correct one which is 1 line of code

queen adder
eternal needle
hasty tundra
#

!code

eternal falconBOT
eternal needle
#

A 3d array for high scores also does really sound questionable (aka not needed). You could likely use a dictionary, since I suspect you are mapping game mode to index

queen adder
eternal needle
languid spire
queen adder
hasty tundra
#

https://gdl.space/ileloxocah.cpp Heres the link to the code, and i suspect there is probably a better way to save the highscores than with the 3D array. Essentially there are 3 different factors in play for each game (Map, mode and difficulty) and i want to store a seperate highscore for each combination of factors

slender nymph
eternal needle
languid spire
queen adder
#

Doing me a favor tbh

slender nymph
queen adder
#

I just asked a question

ivory bobcat
slender nymph
hasty tundra
eternal needle
languid spire
slender nymph
queen adder
#

My question is a coding question is it not?

slender nymph
#

if i start saying code words, it's a code question, right?

deft grail
#

no point arguing, your question in the beginning was right their response was wrong but so was yours after.

hasty tundra
#

ok, 1. when i tested with arrays it lost the data not only for the 3D array, but with 2D and even 1D arrays aswell. 2. Im not sure how i would swap over to Newtonsoft as i have never used it, is there a tutorial i can use to get it set up somewhere?

queen adder
eternal needle
deft grail
eternal needle
#

🤷‍♂️ the main point being that it's clearly a blender or other model creation tool issue

hasty tundra
# void thicket How are you testing it?

i was changing the arrays to be 2D or 1D respectively, changing values within them, and no matter what it always produced this when asked to load the data. It also gave the same response when i simply used .ToString() to convert to a string aswell

eternal needle
void thicket
slender nymph
languid spire
hasty tundra
#

i wasnt using ToString with the JSon convertor though and it still gave the same result?

void thicket
#

It’s not going to pretty print your elements

languid spire
void thicket
#

And it sounds like Json converter fall backed to ToString because it is unsupported type

hasty tundra
#

ah ok ok i understand now. Im assuming the Newtonsoft does support them then?

languid spire
#

yes

eternal needle
slender nymph
#

shouldn't be necessary if they are using the latest version available in the package manager

#

oh wait, actually it might still be definitely still is necessary for some types

hasty tundra
#

Thanks for the help guys, all setup and working now 👍

hollow venture
#

Hello guys.
A newbie question:
I have controller script to my player object who work perfectly. But in the moment hes connected to animator hes not able to move.
I checked all answers in google/gpt nothing fixed it :d

slender nymph
#

show relevant !code and any errors in the console

eternal falconBOT
mighty basalt
#

i have some spawnpoints that have a rigidbody2d and a boxcollider2d. these spawnpoints spawn enemies that also have a boxcollider2d and a rigidbody2d. however now the enemies push and run into the spawnpoints. is there an easy way to make these two objects ignore collissions?

slender nymph
#

why do spawn points need physics?

slender nymph
#

the objectively correct answer is to remove the rigidbody from the spawnpoints. there is no logical reason they should have one

mighty basalt
#

the spawnpoints move around

slender nymph
#

use a physics query, not a rigidbody

#

a simple checkbox or something like that only when you move it would be sufficient to check whether it is on top of something it shouldn't be active in

outer scarab
#

Hello friends, I'm struggling, someone help me pepehands

I have a Isometric Y as Z tilemap and want tiles to be highlighted on mouseover using a sprite which is already on the scene but will show and switch positions when hovering over tiles.

  • Cell size of my isometric cell layout is 1, 0.5, 1
  • The projects Transparency Sort Mode is set to Custom Axis with following values: 0, 1, -0.26

What I have tried:

  • Get mouse position by using Input.mousePosition
  • Convert the mouse position to world position using Camera.main.ScreenToWorld()
  • Convert the world position to cell position calling the grids WorldToCell() method
  • Change the position of the highlight sprite to the cell position

But the position is off like half of the tiles width in px.

#

(No screens right now, I'm on phone)

#

Appreciate every help.

hollow venture
#

this is my code and it works great but when connected to my animator i see my player replacing to walk animation but does not move anymore:

#

and there is no errors

coral citrus
#

The buttons I'm adding listeners to only sends the same wrong int to selected choice, it sends the int 4 which is 1 above the choices.Length through all buttons which shouldnt be possible.

        //Setup new buttons
        for (int i = 0; i < dialogue.choices.Length; i++)
        {
            choiceButtons[i].gameObject.SetActive(true);
            choiceButtons[i].GetComponentInChildren<TextMeshProUGUI>().text = dialogue.choiceText[i];

            // Add listener to the button
            choiceButtons[i].GetComponent<Button>().onClick.AddListener(() => SelectedChoice(i));
        }
rose galleon
#

If I were to make my boss decide one random attack and make it unable to repeat the last one, this is how I would make it right?
Also how do i tell it to reroll in the else{}?

https://hastebin.com/share/yelojupego.java

deft grail
deft grail
rose galleon
slender nymph
deft grail
rose galleon
slender nymph
#

you also don't really need to use a List for this as you don't actually need to remove anything from it since you aren't preventing it from repeating an attack permanently, just preventing the most recent one from being repeated. So you could use an array of Action and store the attack methods in the array, generate an index, and compare that to lastAttack. then when it is different, just invoke the action at that index of the array

rose galleon
mighty basalt
#

how do i make it so an object with a boxcollider2d doesnt get pushed out of another object with its own boxcollider2d?

slender nymph
#

the spawn point wouldn't need a collider or a rigidbody if you do what i suggested

mighty basalt
coral citrus
rose galleon
slender nymph
# mighty basalt what is a physics query?

well that just proves you did not try what i suggested.
a physics query is a query of the current physics scene to check for colliders in a specific area or path. Physics2D.CheckBox is an example of that and is literally all you need instead of relying on OnTriggerEnter2D/OnCollisionEnter2D

languid spire
slender nymph
coral citrus
#

Such a weird thing 😅
Thank you for the source.

languid spire
storm pine
slender nymph
#

not a built in one, no

mighty basalt
# slender nymph well that just proves you *did not* try what i suggested. a physics query is a ...

sorry but i really do not understand. physics2d.CheckBox is not a thing in unity, and i cant find anything like it when searching
https://pastebin.com/X8A9E4FN
this is my current code if that helps understand whats going on

slender nymph
#

ah right, only 3d physics has the CheckXXX methods. so you'd use an OverlapBox. or a raycast, or literally any other physics query that makes sense in context of checking the position

#

you should also really consider not naming your classes the same thing existing unity components unless you really know what you are doing (and can also easily articulate that you are using your own component type when trying to receive help with it)

slender nymph
#

well that's the 3d version not the 2d one

mighty basalt
# slender nymph well that's the 3d version not the 2d one

oh sry. ive found the 2d one, but still. so it checks if a collider is within a certain area. but should i do that in the tilemap script (should be renamed as you said)? and can i then do something like check if that collider belongs to something with tag spawnpoint and then ignore it?

slender nymph
#

do it from the spawnpoints themselves whenever they move. and you can check if they are on top of something they shouldn't be active over. and if they are you can just not spawn anything

frozen steeple
#

Im using a character controller for third person movement, and I also created separately an hoverboard that moves based on rigid body and forces. Basically I want to let the player hop on the hoverboard and "change comands". How should I implent this? like, do I disable the character controller and make the player model a child of the hoverboard? or is there a better way?

slender nymph
#

yeah that would typically be how you would swap to physics based movement from the CC

frozen steeple
#

i see, thanks!

static cedar
#

Yo peps, just asking if there's a linq method where you can get the current # of iteration?

wintry quarry
#

But like... what's wrong with for?

static cedar
#

Gonna convert it into a dictionary that stores an item and an index with a string name key from an array of items. Just need to get the index.

static cedar
wintry quarry
#

And that's... difficult?

static cedar
#

No. But i wanted to know if there's something that alr does it.

whole idol
#

Why is Object Variables not clickable?

tough cave
#

Why is the prefab not being noticed by the problemManager? I dont understand it. Someone can see the mistake?

    public class ProblemManager: MonoBehaviour
    {
        public ActionDialog IndividualDialog;
        public IActionDialog GlobalActionDialog;

        public List<Problem> ProblemList;
        

        public ActionDialog GetIndividualDialog()
        {
            if (IndividualDialog == null)
            {
                Debug.LogError("Failed to get a valid dialog from IndividualDialog! blaah");
            }
            return IndividualDialog;
        }
#

( it returns the LogError)

slender nymph
#

is there perhaps more code in this class that you aren't showing?

tough cave
#
    public class ProblemManager: MonoBehaviour
    {
        public ActionDialog IndividualDialog;
        public IActionDialog GlobalActionDialog;

        public List<Problem> ProblemList;
        

        public ActionDialog GetIndividualDialog()
        {
            if (IndividualDialog == null)
            {
                Debug.LogError("Failed to get a valid dialog from IndividualDialog! blaah");
            }
            return IndividualDialog;
        }

        public IActionDialog GetGlobalActionDialog()
        {
            return GlobalActionDialog;
        }
    }
public class ProblemPopup : IPopup, IPointerClickHandler
{
    //// Will have some relation back to the student.
    public Student originStudent;
    
    private ActionDialog dialog;

    //// Temp variable, will be replaced with a service locator to the ProblemManager.
    //// Later variables will ensure that only if the student has been touched, that the popup will be clickable.
    public ProblemManager problemManager;
    

    public void OnPointerClick(PointerEventData eventData)
    {
        if (originStudent == null)
        {
            Debug.LogError("originStudent is not initialized!");
            return;
        }

        if (!originStudent.isInRange)
        {
            Debug.Log("Student not in range");
            return;
        }

        if (problemManager == null)
        {
            Debug.LogError("ProblemManager is not initialized!");
            return;
        }


        dialog = problemManager.GetIndividualDialog();

        if (dialog == null)
        {
            Debug.LogError("Failed to get a valid dialog from ProblemManager!");
            return;
        }

        dialog.student = originStudent;
        dialog.ShowPopup();
        Debug.Log("Individual action: Open dialog.");
    }
#

it fails on dialog = problemmanaer.getindividual

whole idol
#

Why is Object Variables tab not clickable?

#

Im trynna access object variables

#

why cant i click it?

timid bridge
slender nymph
eternal falconBOT
slender nymph
#

this is a code channel

tough cave
#

Hmm I think i see it. Why or how come it says mistype match? I'm trying to import the problem manager inside this var. that literally the same type :{ zZzZz

slender nymph
#

prefabs cannot reference in-scene objects

spiral narwhal
#

I don't really think I understood how persistent path works haha

        public static void CreateAndWriteSaveGame(string gameState)
        {
            var currentDateAsString = DateTime.UtcNow.Date.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture);
            var currentDateFormatted = currentDateAsString.Replace(" ", "-");
            var currentTimeSuffix = "-" + Time.time;
            var saveGameFileName = currentDateFormatted + currentTimeSuffix;

            var pathStart = Application.persistentDataPath;
            const string gameSaveSubPath = "/Save Games/";

            var saveGamePath = Path.Combine(pathStart, gameSaveSubPath, saveGameFileName);
            File.WriteAllText(saveGamePath, gameState);
        }
#

So how do I make it point to some game related folder?

slender nymph
#

you're just using Path.Combine wrong, remove the slashes from the gameSaveSubPath

spiral narwhal
#

Whoops

#

Didn't realise haha

slender nymph
#

you'll probably also need to create the folder if it does not exist already

ancient holly
#
    private void ComboThree(System.Action finishAction)
    {
        bool firstDashAttackDir = Random.Range(0, 2) == 0;
        System.Action spinAttack = () => { TeleportToRandomCornerAndSpin(finishAction); }; // third
        System.Action secondSlash = () => { TeleportNearPlayerAndSlash(secondDashSlash); }; //second
        TeleportNearPlayerAndSlash(secondSlash); //first
    }

is this an ok way to use delegates? when a state ends it calls the finishaction and starts the next state

spiral narwhal
#

Just wondering: is there a Unity shortcut to move into the "persistent app path"?

#

Because in the editor I can't see the file

slender nymph
#

the location of it depends on the platform, but if you look at the documentation for the property it provides the path so you can navigate there on your file explorer

swift crag
#

I put a button in my game that opens the persistent data path in your file browser

#

it would be easy to add that as as menu item in the Editor

spiral narwhal
#

Would you mind sharing the button script? Sounds useful

slender nymph
#

yeah i was about to suggest that, i don't think there's any built in way to do it automatically, but making a button for it is pretty trivial

swift crag
spiral narwhal
#

Cheers

swift crag
#

There is no Application.logPath, so I had to construct that myself

#

I haven't checked if that works on Linux

#

using System.Diagnostics.Process.Start to open the folder feels scuffed

slender nymph
#

you can also slap a Menu Item attribute on that if you want to add a menu item like with the GameObject, Edit, etc menus at the top

swift crag
#

yeah

languid spire
#

there is

EditorUtility.OpenFilePanel("Persistent Data", Application.persistentDataPath, "*");
swift crag
#

[MenuItem("Foo/Bar")] adds an entry to the menubar up top that runs the static method the attribute was attached to

slender nymph
spiral narwhal
#

It does

languid spire
#

although it's a dialog

swift crag
#

you could finagle your way from that to an actual file explorer window

spiral narwhal
#

This worked like a charm on windows though

#

Yup serialisation works :)

#

Now I would like to plug in this service. Do you guys know easy to use libraries for encryption?

topaz mortar
#

Anyone know that feeling where you've been looking for a bug for hours and the longer you search the more you realize it's gonna be something insanely stupid and you're gonna hate yourself when you finally find it? I'm 4 hours in ...

real rock
swift crag
final totem
#

should i instantiate prefabs or components on the fly?

spiral narwhal
swift crag
#

but what are you trying to do with it?

swift crag
#

If so, there is no difference, other than what Instantiate returns to you. When you instantiate a Transform or a Collider or some mono behaviour type you created, Unity instantiates the game object it's attached to

final totem
#

scritpable objects can be changed or are read only tho?

swift crag
#

You can modify a scriptable object just fine. However, this can have some surprising behaviors if the scriptable object came from an asset.

#

The changes will stick around until the object is unloaded.

#

In the Editor, an object referenced in a scene you have open for editing will not unload when you quit play mode

#

So it will look like the changes are persistent.

#

If you load a new scene that does not reference the object, it will unload, and your changes will go away the next time the object is loaded.

outer scarab
swift crag
#

So if you quit and reopen the game, the changes you made will be gone

dark hatch
tender walrus
#

Hey I have a questions about the Bounds of a prefab. Currently I'm getting the bounds of a single prefab from its meshRenderer to perform calculations in a script, but I now want to create a prefab made of different prefabs by just dragging them in a parent prefab, and still have the Bounds to encompass the size of the prefabs together. Is there a simple way to achieve this? I tried wrapping the parent in a BoxCollider but it needs to be instantiated in order to get the bounds

wintry quarry
#

because there's no maxLinearVelocity on Rigidbody

#

in your version of Unity

#

Looks like it started in Unity 2022

final totem
#

should almost all textures have the read write disabled?

wintry quarry
#

yes

final totem
#
[BurstCompile]
public struct MyFirstJob : IJob
{
public NativeArray<float3> ToNormalize;
public void Execute()
{
for (int i = 0; i < ToNormalize.Length; i++)
{
ToNormalize[i] = math.normalize(ToNormalize[i]);
}
}
}

how can i call this?

desert plinth
#

Is there a way to apply the force of a rigidbody into the forward direction of an object and not just an axis?

#

Because when I use AddForce on a rotated object it still applies force towards the global z axis not local

wintry quarry
desert plinth
#

Ohhh thanks

wintry quarry
#

e.g.:

rb.AddForce(rb.rotation * force);
// OR
rb.AddRelativeForce(force);```
topaz mortar
# topaz mortar Anyone know that feeling where you've been looking for a bug for hours and the l...

So turns out everything was working correctly, I was just trying to load the wrong data ...
Trying to load the itemslot id instead of the actual item id, 6 hours well spent!

 HashSet<string> keys = new HashSet<string>();
 /*foreach (var key in character.ItemSlots.Keys)
 {
     if (character.ItemSlots[key] != 0)
     {
         keys.Add(key.ToString());
     }
 }*/

 foreach (KeyValuePair<int, int> pair in character.ItemSlots)
 {
     if (pair.Value != 0)
     {
         keys.Add(pair.Value.ToString());
     }
 }```
void thicket
topaz mortar
#

well it is a "list" of keys

fervent iron
#

very new, working on a Udemy course that is very helpful, but it is doing a poor job at explaining syntax and differentiating structures. For example, this structure below. Or when you need to use <> braces to identfy an object, etc. Is there a course, video, or something that anyone can recommend on the different structures and the required syntax? Im struggling when it comes to parsing through documentation and feel like there must be a lesson someone put together.

topaz mortar
#

itemIdsToLoad?

wintry quarry
fervent iron
wintry quarry
#

Basically you use it to mark that the ScriptableObject type it's adorning can be created from a menu within the editor

wintry quarry
fervent iron
#

that would give me enough to explore documentation to "know what i dont know"

#

thx

swift crag
whole narwhal
#

!code

eternal falconBOT
whole narwhal
#

Trying something srry

#

Hey I need some help. I'm trying to add a simple countdown timer into my game. Copied some code for it but the timer does not update ant stays at (0:00) : (1:00) when I press play. I can see the timeLeft variable go down in the inspector but again the text(legacy) object isn't changing. Any help is appreciated

#

Code is in that link above

rich adder
#

not sure where you got that from, but It should be
timerText.text = string.Format("({0:00}:{1:00})", minutes, seconds);
you can also do
timerText.text = $"({minutes:00}:{seconds:00})";

slate haven
#

I have a magnet pickup in my game. So I have defined a range of it to attract coins. Earlier it was attracting coins only in range as I was creating new coins every frame. Now I have been using Object Pooling, so whenever magnet is active, all the coins in the scene are attracted. Please do help.

    {
        if (pm.canAttract)
        {
            transform.position = Vector2.MoveTowards(transform.position, cs.playerTransform.position, cs.moveSpeed * Time.deltaTime);
        }
      


    }```

Ref: https://streamable.com/mnz8lu

Watch "2024-05-14 20-18-19" on Streamable.

▶ Play video
buoyant knot
#

do coins have physics?

#

like colliders and rigidbodies?

slate haven
#

yes

#

collider is a trigger here

#

and it has rigidbody

buoyant knot
#

then 1) do not move them in update, use fixedupdate
2) do not move them by transform. use their rigidbody

whole narwhal
#

Yeeesss

slate haven
buoyant knot
#

the transform and rigidbody will be fighting each other to overwrite the position

#

then you should fix that. not make it extra wrong by moving it to update

slate haven
buoyant knot
#

when you bring something out from the pool, you need to really reset it

slate haven
# buoyant knot when you bring something out from the pool, you need to really reset it

like how??

    {
        if (!poolDictionary.ContainsKey(tag))
        {
           return null;
        }

        
        GameObject objectToSpawn = poolDictionary[tag].Dequeue();
        objectToSpawn.transform.position = position;
        objectToSpawn.transform.rotation = Quaternion.identity;
        objectToSpawn.SetActive(true);

        poolDictionary[tag].Enqueue(objectToSpawn);
        
       return objectToSpawn;

    }

    public void DeactivateGameObject(string tag, GameObject collidedObj)
    {
        if (poolDictionary.ContainsKey(tag))
        {
            Debug.Log("Contains tag");
            foreach (GameObject obj in poolDictionary[tag])
            {
                if(obj == collidedObj)
                {
                    obj.SetActive(false);
                    Debug.Log("Item False now");
                    return;
                }
            }
            

        }```
buoyant knot
#
  1. i am not writing code for you. that is your job
  2. you need to reset all the internal variables
slate haven
#
  1. Im not asking u to write code
  2. How do i reset
buoyant knot
#

i recommend you use an interface, where every monobehaviour that needs to reset on the object gets a Reset() method called

#

then the spawn object looks for all the IResettable components and calls Reset()

slate haven
#

the code i have written, is that correct?

#

like does my code actually reset or not

buoyant knot
#

it resets nothing

slate haven
#

what if i dequeue

#

when it gets deactivated

slate haven
buoyant knot
#

if you have a script in the coin that gets a variable set at 0 at start, then it becomes 5 in its lifetime, explain to me how that coin comes back into play with the variable at 0

#

because the point of a pool is to save time by not reinstantiating

#

but that means you need an equivalent way to bring something back from scratch

#

as though it were brand new

#

otherwise code will depend on whatever happened during its old lifetime

slate haven
#

can you please elaborate more on how do i begin with?

buoyant knot
#

start by not object pooling until you have a better grasp on some more of the basic tools, such as interfaces

slate haven
#

but if i want to, how do i begin with interfacea

buoyant knot
#

watch a guide video

slate haven
#

because i really want to

slate haven
spiral narwhal
#
            Debug.Log(string.Join(",", myAes.Key.ToString()));
            Debug.Log(string.Join(",", myAes.IV.ToString()));

Why can't I see the array properly formatted?

wintry quarry
spiral narwhal
#

Yeah it is

#

But from a menu item

wintry quarry
#

Can you prove it? Add some more info to the log

keen dew
#

You're converting the arrays to strings before trying to join them

spiral narwhal
wintry quarry
#

Oh

#

Nitku has it right

#

You just want:

Debug.Log(string.Join(",", myAes.Key));```
spiral narwhal
#

Ah that would make sense

#

Cheers

wintry quarry
#

assuming myAes.Key is an array

spiral narwhal
#

Byte[] yes

slate haven
buoyant knot
#

because an interface lets many different classes implement Reset(), even if they have nothing to do with each other. and then let you call that method via the interface

wintry quarry
slate haven
wintry quarry
#

or imagine them in a list:

List<object> thingsToReset = ...
foreach (object o in thingsToReset) {
  if (o is Car c) c.Reset();
  if (o is Computer comp) comp.Reset();
  // etc... :sad:
}

You can do:

List<IResettable> thingsTOReset = ...
foreach (IResettable resettable in thingsToReset) {
  resettable.Reset();
}```
wintry quarry
blissful spindle
blissful spindle
wintry quarry
slate haven
wintry quarry
wintry quarry
#

What's the point of that?
And you realize it will only affect the most recent bullet right?

summer stump
blissful spindle
wintry quarry
#

seems pointless

wintry quarry
#

Think about what your code is doing and why

blissful spindle
summer stump
blissful spindle
slate haven
summer stump
wintry quarry
#
    void reset(gameobject obj)
     {
        reset(obj);
      }```
What? This code will just give you a StackOverflowException (assuming you fix the `GameObject` typo)
slate haven
wintry quarry
#

Which object?
How do you know which component it has to be reset?

summer stump
slate haven
flint python
wintry quarry
summer stump
wintry quarry
slate haven
#

will it be fine If I paste my main question here again?

wintry quarry
wintry quarry
#

This would be with the interface

#

without the interface, you would need to check for any number of different resettable components

wintry quarry
slate haven
wintry quarry
#

seems unrelated

wintry quarry
slate haven
#

Loup and soup told me

#

i mean

wintry quarry
#

IResettable is a hypothetical interface you would write and implement

slate haven
#

please do share ur opinion

#

as well

#

on my actual problem

wintry quarry
#

I don't know I don't have enough context

slate haven
#

may i explain

#

I have a magnet pickup in my game. So I have defined a range of it to attract coins. Earlier it was attracting coins only in range as I was creating new coins every frame. Now I have been using Object Pooling, so whenever magnet is active, all the coins in the scene are attracted. Please do help.

    {
        if (pm.canAttract)
        {
            transform.position = Vector2.MoveTowards(transform.position, cs.playerTransform.position, cs.moveSpeed * Time.deltaTime);
        }
      


    }```

Ref: https://streamable.com/mnz8lu

Object Pooling Code:

``` public GameObject SpawnFromPool(string tag, Vector2 position)
    {
        if (!poolDictionary.ContainsKey(tag))
        {
           return null;
        }

        
        GameObject objectToSpawn = poolDictionary[tag].Dequeue();
        objectToSpawn.transform.position = position;
        objectToSpawn.transform.rotation = Quaternion.identity;
        objectToSpawn.SetActive(true);

        poolDictionary[tag].Enqueue(objectToSpawn);
        
       return objectToSpawn;

    }

    public void DeactivateGameObject(string tag, GameObject collidedObj)
    {
        if (poolDictionary.ContainsKey(tag))
        {
            Debug.Log("Contains tag");
            foreach (GameObject obj in poolDictionary[tag])
            {
                if(obj == collidedObj)
                {
                    obj.SetActive(false);
                    Debug.Log("Item False now");
                    return;
                }
            }
            

        }```

Watch "2024-05-14 20-18-19" on Streamable.

▶ Play video
stuck crest
#

is it possible to disable this through script?

stuck crest
#

how can i do it

stuck crest
#

thanks

#

its not working

wintry quarry
#

Rigidbodies are not Behaviours

rich adder
wintry quarry
#

they have no enabled property

stuck crest
#

wait what

#

yo i didnt know that

wintry quarry
#

notice there is no corresponding checkbox for a Rigidbody2D

stuck crest
#

i thot all of them have it

rich adder
fringe plover
#

!code

eternal falconBOT
stuck crest
#

what would be the best way to like to pick up objects in unity in your opinion

rich adder
#

raycast, physics casts/overlap

slate haven
stuck crest
rich adder
stuck crest
#

is there a better way?

fringe plover
#

I made some code to load data from cloud, but i dont know how to make it wait first, any ideas? (DataStore is not my code, its part of API, and it doesnt have async methods)

    public void LoadData()
    {
        DataStore.Get("bombBuffCount", false, value => { SaveValues.instance.currentGameData.bombBuffCount = int.Parse(value); });
        DataStore.Get("shakeBuffCount", false, value => { SaveValues.instance.currentGameData.shakeBuffCount = int.Parse(value); });
        DataStore.Get("slowMoBuffCount", false, value => { SaveValues.instance.currentGameData.slowMoBuffCount = int.Parse(value); });
        DataStore.Get("coinCount", false, value => { SaveValues.instance.currentGameData.coinCount = int.Parse(value); });
        LoadingManager.instance.RestartAsync();
    }
stuck crest
rich adder
stuck crest
rich adder
#

you can also disable collisions between specific layers

stuck crest
#

but the raycasts wrent hitting

stuck crest
#

they were hitting before

fringe plover
rich adder
stuck crest
fringe plover
#

thats void

stuck crest
#

i forgot i updated my code

#

i did the test agin

rich adder
stuck crest
#

and it works

#

thank you @rich adder

rich adder
#

which API is this

fringe plover
#

i can change it... but never worked with networking and stuff, i use GameJolt to make cloud saving and achivement stuff

rich adder
#

also generally these type calls should be async

#

since they vary in speed, especially client internet speed

fringe plover
#

well... its fully on C# but... i dont wanna mess with it...

rich adder
#

you dont want your app to lockup while waiting for dl

rich adder
#

"its fully c#" what does that even mean.

fringe plover
rich adder
#

you using a library if you're not sure how it works?

fringe plover
#

dammit

#

its called API

#

i just use it

rich adder
#

do you know what an API is ?

fringe plover
#

no..?

rich adder
#

so why are you using the term so loosely

fringe plover
#

yes..?

rich adder
#

seems this is a waste of time, since you have no clear goal in what you're trying to achieve

fringe plover
bronze zenith
#

this code has absolutely no errors at all

#

i have no idea why i cant

rich adder
#

you still haven't explained why you are using this library, thats what I mean with no clear goal

#

you just said you're using a library, which you haven't even linked

rich adder
wintry quarry
fringe plover
bronze zenith
wintry quarry
#

to start with

rich adder
bronze zenith
#

yea but like where

fringe plover
wintry quarry
# bronze zenith yea but like where

Start with the place where you expect code to run that doesn't seem to be running.
Print the variables that are expected to be a certain value and make sure they're as you expect, etc..

Use logic and reason to deduce the problem

rich adder
fringe plover
#

ah wait

#

you mean why i use this lib and not trying any other?

rich adder
#

Which purpose did you add this library, what are you trying to accomplish with this ? what issue does this library solve ?

bronze zenith
rich adder
wintry quarry
fringe plover
fringe plover
bronze zenith
#

Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement.

#

i have no idea what that means

rich adder
#

these errors are too generic to tell what it is

bronze zenith
#

i wrote debug.log;

rich adder
#

well thats now how you call methods

swift crag
#

it sounds like you tried to do something like 1 + 2;

#

you can't just write an expression by itself like that

#

As the error mentioned, one valid expression is a call expression

#

like SomeMethod();

rich adder
#

"call" is basically ()

swift crag
#

Debug.Log("Hi"); would be valid

#

Debug.Log; is not.

wintry quarry
bronze zenith
#

oh so i put the code in the brackets

rich adder
swift crag
#

because it's not:

  • assignment: val = 1;
  • call: Debug.Log("Hi");
  • increment: val--;
  • decrement: val++;
  • await: await SomeAsyncMethod();
  • new object: new Something();

🌠 the more you know

swift crag
eternal falconBOT
#

:teacher: Unity Learn ↗

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

fringe plover
rich adder
#

but doesn't seem the library you sent has any async

#

maybe it does it for you

#

it does have a callback action at least

dusty shell
#

!paste

swift crag
#

you are probably looking for !code

eternal falconBOT
dusty shell
rich adder
swift crag
fringe plover
rich adder
#

so put the callback for RestartScene

swift crag
#

This library uses callbacks. When the operation finishes, it runs the method you gave it.

dusty shell
swift crag
#

This means that the game will continue running while the operation is taking place.

fringe plover
swift crag
rich adder
dusty shell
swift crag
rich adder
#

well maybe i'd use enum instead of bool for states

swift crag
#

you can't be both walking and running

#

so yes, an enum would be appropriate

#
public enum MovementType {
  Stopped,
  Walking,
  Running
}
tough cave
#

What could it mean when i try to instantiate a object. is says it found the correct prefab to instantiate, but it wont load into the scene at all?
Using a obstract class for this, where one type of popup does work, but the other doesnt... And I cant find the mistake...

swift crag
#

perhaps it is instantiating really far away

#

If you don't give a specific position, you'll get the prefab's position/rotation/scale

rich adder
reef raven
#
// test
tough cave
#

!code

eternal falconBOT
tough cave
#

sec

dusty shell
swift crag
#

enum lets you create a new type with a fixed set of values

swift crag
dusty shell
#

so it's like a boolean dictionary?

swift crag
#

I wouldn't say that, no

swift crag
dusty shell
#

checks which is currently True then works with that?

rich adder
#

jk

swift crag
dusty shell
#

yeah I get you

swift crag
#
switch (moveType) {
  case MovementType.Default:
    // stuff
    break;
  case MovementType.Walking:
    // stuff
    break;
  case MovementType.Running:
    // stuff
    break;
}
dusty shell
#

how do I set the movementType.variables tho?

#

the normal way?

#

just assign it to a boolean?

summer stump
#

As fen said, it is not a boolean, so not sure what you mean by "assign it to a boolean"

dusty shell
#

Oh i didn't see this

#

Thanks for this

rich adder
#

switch is just a fancy if else chain

dusty shell
#

Also, my unity remote 5 keeps randomly stop working 😦

dusty shell
rich adder
#

just making sure , you did call enum a boolean dictionary lol

dusty shell
tough cave
rich adder
dusty shell
rich adder
swift crag
dusty shell
swift crag
#

There are certainly unity-specific types (like MonoBehaviour) and unity-specific functionality (Unity runs the Update method on every enabled-and-active MonoBehaviour every frame)

rich adder
#

Coroutines are unity specific, but they use the C# type IEnumerator which is common for iterating

dusty shell
swift crag
rich adder
swift crag
#

a coroutine is just an iterator that unity will call MoveNext on regularly

dusty shell
#

As I work on projects

rich adder
#

ofc you can

#

I used to split it , 2 hours a day regular c# . 1 hour or 2 of Unity

dusty shell
#

Learning C# with what tho, projects?

rich adder
#

yeah just learning new things and messing with them repetitively. The Microsoft site has very nice lessons of random stuff

#

the modules are very well done, gotta respect m$ for that

bronze zenith
#

i tried to use a different method of debugging

#

in visual studio

buoyant knot
#

there are many ways to debug

bronze zenith
#

and it sitll didnt work

rich adder
dusty shell
bronze zenith
#

an if statement for wall jumping

buoyant knot
#

VS debugger is good to see the states of all the variables at a given point in time

rich adder
tough cave
#

no, it says in code it instantiated it (cuz i assume cuz it doesnt give any error on that line), but it does not show up in the scene hierarchy at all, niether the prefab. So I'm rlly confused.

rich adder
#

you're talking about this ?

tough cave
#

yeah

rich adder
#

because when you do not pass position it is spawned at World 0,0,0 iirc

swift crag
#

note that you're calling SetActive on the prefab, which does not make sense

tough cave
#

Yeah its supposed to spawn at 0,0,0. its the location of the canvas.

rich adder
#

so parent it to canvas, pass the transform in Instantiate

tough cave
#

it runs yes. it goes inside that method. and calling the correct prefab. Iknow the setactive dont make sense. was just trying for hope by now :p

swift crag
rich adder
#

also if its a UI element could also explain why you wouldn't be able to see it, even if you found it in world

tough cave
#

no, its a canvas that needs to spawn, that will create a popup dialog of some kind.

swift crag
#

okay, so popUp has a Canvas on it

tough cave
#

yes the canvas is the prefab

rich adder
tough cave
swift crag
hallow sun
#

Is there a variable type that can reference a json?
Im trying to avoid the Application.persistentDataPath thing as that makes it hard to share the project through github.

tough cave
#

What supposed to look like after its called.

#

ill try that sec

swift crag
#

You should log instantiatedPopup right after it is created. You can do it like this:

Debug.Log("Created: " + instantiatedPopup, instantiatedPopup);
#

Clicking once on the log message will select the object in the hierarchy, if it exists

rich adder
#

what does Application.persistentDataPath having anything to do with github

#

json in unity is just a TextAsset

hallow sun
#

contents stored in Appdata instead of the same folder

languid spire
tough cave
#
    public virtual void ShowPopup()
        {
            Debug.Log("Arrived in THE showpopup method in IPopup class");
            
            if (popUp == null)
            {
                 Debug.Log("Cant find popup object.");
            }
            
            Debug.Log(popUp.name + " going to be instantiated."); 
            
            // Check if the popup has already been instantiated
            if (instantiatedPopUp == null)
            {
                popUp.SetActive(true);
                // Instantiate the popup if it hasn't been instantiated
                instantiatedPopUp = Instantiate(popUp);
                Debug.Log("Created: " + instantiatedPopUp, instantiatedPopUp);
                Debug.Break();
                
              
                
            }
            else
            {
                Debug.Log("Popup already instantiated.");
            }
        }
#

You see it ? :c

rich adder
#

video needs to be mp4

tough cave
#

oh damnit.. is a whole file..

#

sec converting

snow girder
#

why can't i use this on a button

rich adder
rich adder
shell ice
#

what's the difference between these two please ( Missing and None )

snow girder
rich adder
# shell ice

Missing meaning at some point object was deleted

tough cave
rich adder
snow girder
languid spire
snow girder
rich adder
# tough cave

did it run? I dont understand. I dont see Break pausing the simulation

languid spire
#

event handler. what you define in the event on the button

tough cave
#

I removed the break yeah to show what was actually supposed to happen when clicking the popup that DID work, and not the other one when i walk at the other icon.

snow girder
languid spire
rich adder
tough cave
#

showing both dialogs come inside that method, with the correct gameobject(prefab. but 1 of them not spawning.

snow girder
tough cave
#

The first pop up/dialog that shows is a popup that works lol. that was a sample of what its supposed to do. but then i walked at the top of the classroom to click on a different icon, which is supposed to spawn a different dialog, which uses the same class. ( u can see that cuz both of the times i clicked on something, the same Logs came in the Debug window(on the right side)

warm cove
#

Hi! I am making a simple 2D platformer for school and wanted to add a lite feature, although I am not certain on how to do it. Right now in my game you can claim checkpoints, and I wanted to create sort of an inventory screen which shows you all claimed checkpoints and makes buttons for them (or at least unlocks their buttons depending on how many checkpoints you've unlocked). I thought of making a list where I add a checkpoint each time I claim one and using that to determine how many buttons, but I am really bad with UI elements. Any tips?

languid spire
snow girder
#

hype

rich adder
flint python
#

Could someone have a look at why the bullet movement behaves differently, when using GetComponentInParent, and having the script in the parent object or in both the parent and child object. Thanks

short hazel
#

Note that GetComponentInParent will search the current object before going up to the parent. If you have the script both on this object and the parent, it will return the script on this object.

flint python
rich adder
#

years later we still don't have a Skip self type of parameter..

gentle stratus
languid spire
gentle stratus
#

how do i install that

languid spire
#

via the package manager

gentle stratus
#

ok installed but got a bunch of compiler errors

#
Library\PackageCache\com.unity.ai.navigation@1.1.5\Editor\Updater\NavMeshUpdaterUtility.cs(47,61): error CS0246: The type or namespace name 'NavMeshSurface' could not be found (are you missing a using directive or an assembly reference?)
Library\PackageCache\com.unity.ai.navigation@1.1.5\Editor\Updater\NavMeshUpdaterUtility.cs(52,45): error CS0103: The name 'CollectObjects' does not exist in the current context
Library\PackageCache\com.unity.ai.navigation@1.1.5\Editor\Updater\NavMeshUpdaterUtility.cs(112,17): error CS0246: The type or namespace name 'NavMeshModifier' could not be found (are you missing a using directive or an assembly reference?)
Library\PackageCache\com.unity.ai.navigation@1.1.5\Editor\Updater\NavMeshUpdaterUtility.cs(112,60): error CS0246: The type or namespace name 'NavMeshModifier' could not be found (are you missing a using directive or an assembly reference?)
dusty shell
#

How do I add touch control for mobile?

gentle stratus
#

whats the new one

rich adder
#

in the package manager

rich adder
gentle stratus
#

is it this one

gentle stratus
rich adder
#

did you remove the old ones?

gentle stratus
#

fixed itself after i restarted the whole thing

dusty shell
gentle stratus
#

so i saw in the obselete navigation tab there are options for bake and object that arent present in the new navigation tab, where would i find them now

languid spire
rich adder
gentle stratus
#

maybe i missed the navigation static option but i dont see it here

rich adder
#

because the process is changed

#

you no longer need nav static

#

just bake, and choose if you want Collides or Meshes

tough cave
#

This unity is absolute buggin. what the flip.

    public void ShowPopup()
        {
            Debug.Log("Arrived in THE showpopup method in IPopup class");
            
            if (popUp == null)
            {
                 Debug.Log("Cant find popup object.");
            }
            
            Debug.Log(popUp.name + " going to be instantiated."); 
            
            // Check if the popup has already been instantiated
            if (instantiatedPopUp == null)
            {

                try
                {
                    instantiatedPopUp = Instantiate(gameObject); 
                    instantiatedPopUp = Instantiate(popUp); 
                    Debug.Log("Created: " + instantiatedPopUp, instantiatedPopUp);
                    

                }
                catch (Exception e)
                {
                    Debug.LogError(e);
                    throw;
                }

it works but only if i apply use BOTH of the instantiatedPopUp = Instantiate... If i commend 1 out, it wont work... doesnt matter which one. but it works if i let it run both omfg... I'm so confused... It also runs through the instantiatedPopUp == null with the new popup, so it can keep spawning the popup.. what a mess..

rich adder
gentle stratus
#

oops i didnt know that was a channel

dusty shell
#

I think I missed a few steps

rich adder
#

what

#

is that related to Google?

dusty shell
#

i found a yt video

rich adder
#

the whole point of parenting to something is to inherit its properties

rich adder
#

in code?

languid spire
#

transform.SetParent(null);

dusty shell
#

How do I limit the movement to just the left part of the screen

rich adder
#

clamping

dusty shell
#

in the drop down for the new input control it only specifies the number of fingers down

#

i think

rich adder
#

transform.position = parent.position

languid spire
#

then you need a position or parent constraint

rich adder
#

oh right ^^

open gull
rich adder
#

so it can have an occupied check

#

if its occupied return it or put it on closest slot

open gull
#

what does custom objects mean? sorry if it's a stupid question

#

the slot is a gameobject, which is stored in a list in the card script

rich adder
languid spire
#

use a constraint like I said

rich adder
open gull
#

thx 🙏🏼

rich adder
#

just an example , basically make a method or property

#

if(slot.CurrentCard == null)
//place hard
else
//return card / put on closest

open gull
#

got it thinksmart

rich adder
polar acorn
#

Then less likely your question will get buried

short hazel
#

It would be faster if you included all the relevant items in the original question. Seeing your three (3) messages in that channel, they have a pretty much insane lack of context, code blocks and debugging attempts. Check out #854851968446365696 for guidelines on how to ask a good question, and do it all at once, don't drop the info bit by bit as the conversation goes on

#

You miss 100% of the shots you don't take

#

Ask a full question there and wait for an anwser

hasty sleet
#

You can't just undermine the organization of the server and expect positive reactions

short hazel
#

That's just how it works here, nobody is entitled to get immediate help, but when someone is available and given that the question is nicely formatted they will help

rich adder
#

also generally when you're doing networking , you should already have years of experience

#

multiplayer is not trivial

languid spire
#

In that case, do what we did, read the documentation, experiment and figure it out for yourself

fluid glen
#

when I’m trying to download the lts 2022 2 errors comes up, the errors are android SDK & NDK Tools and OpenJDK how do I fix this?

snow girder
#

is there a way through code to lock the cursor in the center and keep it visible

hoary halo
#

How in the world do I check if an object is moving in unity 6? they have changed how rigidbody.velocity is and its confusing me

hollow dawn
#

im using this line of code to make my player move forward and backward so why doesn't it work? transform.Translate(Vector3.forward * Time.deltaTime * Input.GetAxis("Vertical") * speed);

prisma jolt
#

how do i make a cursor locked to the screen but not invisible

hoary halo
snow girder
hoary halo
#

Huh then I aint got no idea lmao

snow girder
sick jay
#

hi everyone, i wrote code that makes the player jump as long as its touching the ground. an issue is that when i walk from one gameobject onto another one directly beside it it must mess up the code because i can no longer jump

#

this is all the code that handles jumping, top part is in Update void

rich adder
#

bad way to do groundchecking

sick jay
#

thank you

#

how do i do it better

rich adder
#

ideally using a physics cast/check

#

like Physics.CheckSphere

sick jay
#

im new to this how does that work

snow girder
sick jay
#

the code i used was what i learned to use in unitys learn pages

sick jay
#

but what if youre at the peak of a jump

short hazel
#

As for why it doesn't work your way: it's a timing issue. OnCollisionExit is most likely executed after OnCollisionEnter, which leaves you in a permanent playerGrounded = false

rich adder
sick jay
#

you would jump over and over

sick jay
#

that doesnt work cause youd always be jumping

#

oh

snow girder
#

do you know how to lock a cursor and have it visible

hollow dawn
#

im using this line of code to make my player move forward and backward so why doesn't it work? transform.Translate(Vector3.forward * Time.deltaTime * Input.GetAxis("Vertical") * speed);

sick jay
snow girder
rich adder
sick jay
#

its something like CursorLockState.Locked

hollow dawn
sick jay
rich adder
#

its not working, then its not fine

hollow dawn
rich adder
#

you have a character controller ?
you should not be using translate

short hazel
# snow girder

Why would you want the cursor locked but visible in the first place? It's pretty frustrating for the user to see that they're not in control of the cursor like they usually are. That's why it's hidden

snow girder
#

but whatever is fine

sick jay
short hazel
#

Make a UI Canvas with an image in the middle?

hollow dawn
snow girder
rich adder
sick jay
#

i ended up with this

rich adder
#

raycast is good but too thin

sick jay
#

it seems to work

#

ah i see

#

i hung off the edge of something and it doesnt work

rich adder
#

I use a sphere usually if its a capsule

sick jay
#

its a cube hitbox

#

or rectangular prism

#

if you want the fancy name

rich adder
#

so you can use a box

sick jay
#

can you do a plane ray

prime cobalt
#

Is there a way to place a UI object into a specific position in a scroll rect list based on where your mouse is on that list? So like if I'm dragging an object it gets added to the list in the position I dropped it at.

sick jay
#

got it to work

#

thanks for the help

blissful spindle
#

Hi, here you can see my way of implementing player damage from enemies it has 1 flaw though and thats that when enemy enteres my collider he damages me once and then just stands there. how do I make it so the enemy will damage my player over time inside of the trigger? https://hatebin.com/tuukdqeltt

short hazel
# sick jay

Physics casts detect colliders, so when BoxCast() returns true you don't need to check whether the collider is not null. So the code can be simplified down to

return Physics.BoxCast(boxCenter, new Vector3(1, 0.1f, 1), Vector3.down, out _);
// Notice 'out _' which explicitly tells the engine to discard the value, as it's not used
sick jay
strong token
blissful spindle
sick jay
#

@short hazel if i could get your help one more time, this code still lets me jump even when i am in the air as long as there is an object below me, is there any way i can set a distance that object has to be below me for it to return true?

inland aurora
#

hi, im new to this scripting thing i was wondering if anyone can help me make a script for a school project

rich adder
rich adder
#

" help me make a script for a school project"

#

what does that even mean

rich adder
short hazel
sick jay
inland aurora
sick jay
#

i dont have it write scripts for me, i try on my own using the docs pages and then have it check it for errors, and it almost always finds them

inland aurora
#

what did you guys use to learn coding?

languid spire
inland aurora
#

no but like any websites'

sick jay
inland aurora
sick jay
#

Why are people here so rude and sassy to each other?

inland aurora
#

idk

blissful spindle
rich adder
languid spire
sick jay
#

This isnt the industry though its a place where people come for help