#💻┃code-beginner

1 messages · Page 296 of 1

open fog
#

this is the code that will select what turret to spawn, the randomization is just the sprite variations for the purchase button

summer stump
open fog
#

its set when you press the arrows on the shop

summer stump
sacred dagger
#

Hello. I have a database containing approximately 19,000 data (image, text, sound). 786 lesson objects in Unity as well. I want to pull 19,000 pieces of data into these lesson objects - using MYSQL - and divide them into parts, and print them as text, audio and image to my phone application. How can I do that?

rich adder
#

ask the general c# discord

sacred dagger
#

alright ^^

rich adder
#

!cs

eternal falconBOT
sacred dagger
#

Thank you so much

scarlet skiff
#

well uhm, anyone?

swift elbow
swift elbow
#

super broad; be more specific

rich adder
#

you only scale the collider size

onyx cove
#

Hello, i want to change the height of a box when i grab it, what do you think will be the best to do it, change the vertices coordinate of the box or the scale ?
and how can i make it smooth (seeing the box "growing")

#

not really grabbing it but only when i select it

swift elbow
#

it will, but you can always change the camera height so that its different when crouching thru code

rich adder
#

are you using character controller,
use this
https://youtu.be/-XNm7dPVVOQ

Welcome to part 4 of this on-going first person controller series, int this episode we're going to be covering how to crouch and stand effectively while also amending our movement speed WHILE we're crouching and also taking into consideration any obstacles above us before we stand back up!

Join me and learn your way through the Unity Game Engin...

▶ Play video
onyx cove
onyx cove
rich adder
#

and no scaling collider, wont be a problem, just follow the vid @queen adder

swift elbow
onyx cove
#

like only pulling the top of the box based on the height of the hand

swift elbow
#

how does that correlate with your original problem?

#

that sounds like something different entirely

onyx cove
#

oh yeah sorry i didn't explain it well

rich adder
#

ok the process is pretty much the same

#

capsule collider has the same properties as CC with sizing/center

onyx cove
#

what i want to do is to be able to "pull" the box and make it "grow" from the first screen to the second (sorry if i'm still explaining not very clearly)

wintry quarry
#

You're basically looking at procedural mesh processing or using the ProBuilder library or something.

onyx cove
#

yeah i created a procedural mesh

onyx cove
wintry quarry
#

Could change the vertices or add completely new geometry

#

Up to you

onyx cove
#

can i get the hand height from the interactor ?

summer stump
#

Chatgpt WAS working correctly (to mean it was creating spam that looks like code but doesn't function)

#

I'm confused, I see playerprefs stuff, but nothing with JSON

#

Ok, and so what is the question?

#

Oh. Ok.

polar acorn
#

Huh, did they just get banned in a different channel or something? All their messages just vanished at once

swift elbow
swift elbow
summer stump
polar acorn
#

Musta been quick, I looked away for like a second

#

I opened the code in a tab and came back and everything was gone

summer stump
#

I got pinged for one where they linked to a chatgpt link, then as I was about to respond they removed it all

open fog
#

uhhhh what does this mean
this is in a prefab

polar acorn
open fog
#

im trying to make set it as a script that it can exchange with

#

but yes, it is from the scene

polar acorn
rich adder
polar acorn
open fog
#

huh

polar acorn
#

Prefabs exist anywhere. What would those values be if you spawned it in a different scene?

#

Scene objects only exist when that specific scene is loaded

#

If you want to reference a scene object on an object you spawn at runtime, you'll need to spawn it first, then set the references

summer stump
eternal falconBOT
#

:teacher: Unity Learn ↗

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

open fog
#

omggg, ok
Ive spent an hour on this, now time to delete it all and go back to the drawing board

#

aka this bitch ass line of code

polar acorn
#

Then you could create instances of it as files

open fog
#

My main problem is that in the original version of the game, (which is text based and written in python)
theres an entire library of things you can buy

polar acorn
open fog
#

which, would be selected based on the number you inputted, it would just go to that place in the library and pull the stats from there

#

I have no clue how it works in c#

#

I have the number input sorted out, each page in the shop has its own number. The thing is, don't know how to make a library with each object that can have their own individual stats attached

polar acorn
#

if only there were a system someone had just linked a tutorial about

open fog
#

if only

ionic loom
#

!code

eternal falconBOT
ivory bobcat
# open fog I have no clue how it works in c#

Probably in the same manner but if you're wanting to use the Unity features like the inspector and whatnot, you'll need to work with some constraints like the one mentioned above about prefabs not being allowed to reference scene objects.

open fog
ionic loom
#

if anyone is free, I'm getting a null reference exception error and I know why, I just don't know how to fix it

open fog
#

welp cya

polar acorn
ionic loom
#

i know but I have no other solution

ivory bobcat
#

Use the thread

ionic loom
#

i am

magic galleon
#

Does anyone have a general rule of thumb on how you organise certain script aspects on an objects?

i.e. animation controller script has logic for all animation triggers etc?

#

I've got a stats script on an object, should I trigger animations on stats from the stats script or should I split it out?

dawn wharf
#

how to know that if an isometric game is in orthographic or perspective camera mode?

rich adder
dawn wharf
#

i understand but sometimes i feel it is difficult to observe it for me, cause hades game feels like orthographic but i somehow cant confirm it

summer stump
#

Or else it is at least faked perspective

#

You get smaller when you move further away from the camera

dawn wharf
#

i need to open hades again now to see this

#

brb

rich adder
#

I think hades is Ortho

swift elbow
#

i never realized

south sky
#

How do you add a delay in your code

rich adder
dawn wharf
#

invoke

dawn wharf
south sky
#

e.g

variable1 = VALUE;
[I want to add a delay here]
variable 2 = VALUE;
rich adder
#

don't ask things that can be easily googleable

south sky
#

No luck

rich adder
rich adder
south sky
tender stag
#

how can i also check the vertical angle?```cs
//Horizontal angle
if(Vector3.Angle(transform.forward, directionToTarget) < horizontalAngle / 2)
{

}```

polar acorn
tender stag
rich adder
#

imagine that

summer stump
rich adder
#

the items are all same size , its def ortho

dawn wharf
summer stump
#

Gotcha gotcha. Sorry for the misinfo!

dawn wharf
#

no worries we are all learning

south sky
#

I didnt understand it

#

And I couldnt reas properly

rich adder
#

how about the Link that literally says how to do it

dawn wharf
#

or watch a yt video of it

south sky
#

I am rn

rich adder
dawn wharf
ionic loom
#

lube? 🤨

dawn wharf
south sky
#

But its not what im looking for

rich adder
#

you said delay code

ionic loom
dawn wharf
rich adder
#

they're being laz

south sky
rich adder
ionic loom
#

there gotta be some turtorial

#

brackeys

#

i lub 🤨 that dude

south sky
dawn wharf
polar acorn
rich adder
ionic loom
#

@summer stump why do you not like brackeys

south sky
#

I apologise

summer stump
queen adder
#

it isn't working

polar acorn
# ionic loom <@349017582105526273> why do you not like brackeys

Brackeys is a great presenter. Not the best programmer. A lot of his code has problems that don't reveal themselves until you try to expand upon his tutorials, so around here a ton of our time has to be spent trying to de-program bad habits that cause problems further down the line

ionic loom
#

thats true

#

i followed his 3d player controller and couldnt do anything after

#

tried to make grapple hook and quit after 2 days

polar acorn
#

He's great at presenting topics, and is great for getting an overview of broad topics, like "how to use post processing" and whatnot. But the code itself is the least important part of the tutorials and people tend to just lift it wholesale

carmine sierra
#

any idea why the last velocity is wrong?

dawn wharf
summer stump
ionic loom
summer stump
#

Well, capitalization error

polar acorn
polar acorn
carmine sierra
summer stump
short hazel
ionic loom
summer stump
ionic loom
#

really? sounds like a real thing

swift elbow
polar acorn
# ionic loom 🤨

What? It's not a Unity component so if it's something in their project they'd need to show it

summer stump
short hazel
polar acorn
ionic loom
#

wait a rigidbody 2d is a component

polar acorn
summer stump
queen adder
#

but doesn't work on the other one

ionic loom
#

Oh i thought you meant the entire thing didnt exist not the spelling error

short hazel
short hazel
#

It's unreliable, that's it

#

Sometimes the plugins don't load, sometimes it doesn't detect the project, etc.

queen adder
#

Bruh i was using JEtBrains rider but i was getting the same error

short hazel
#

Switching from Rider to VSC
bruh

rich adder
#

sad

queen adder
#

so how do i fix rider instead?

short hazel
#

What "error" are you talking about?

rich adder
queen adder
rich adder
#

its not that diffcult

queen adder
#

and the script doesn't work

rich adder
short hazel
#

First things first, open a command prompt (outside of VSC) and input dotnet --info and see what it tells you

rich adder
#

which is needed for dotnet commands

queen adder
rich adder
#

ok so dotnet is not installed

#

just like the error told you earlier

queen adder
#

ok

short hazel
#

No wait

#

You typed incorrectly lol

rich adder
#

ah yea missing whitespace

short hazel
#

Add a space between dotnet and the --info argument

rich adder
#

you can also do dotnet --list-sdks

queen adder
ionic loom
#

omg ive been tryna do smt for the past 2 days it finally worked

queen adder
ionic loom
#

feels so good

short hazel
#

Yep confirmed, it's not installed

rich adder
#

yup dotnet is not installed

queen adder
rich adder
queen adder
#

ok

#

Am I on the right website?

#

the designs looks like cracked games websites

rich adder
#

Resart PC is required after

queen adder
#

ok

#

so i don't need to download this

#

sure?

rich adder
#

I mean, you can do both.

queen adder
#

i will use rider

#

somehow i got the professional for free

rich adder
#

"somehow"

#

lets just pretend you didn't mention cracked game website from earlier..

queen adder
#

ye

#

nope

#

i didn't

#

i promise

ionic loom
#

is it possible to put to oncollisionenter2ds on the same script? i already googled and couldnt really find a good answer

short hazel
#

No, you cannot have two functions named the same, with identical parameters

#

You can put all your code in the same one though. Or call two of your own functions from OnCollisionEnter

ionic loom
#

ohhhh that makes a lot more sense

ionic loom
#

female?

rich adder
ionic loom
#

nope my question was the x problem

swift elbow
#

its all one problem...

rich adder
devout flower
ionic loom
#

uh oh

rich adder
#

then you can send a "event" or "message" to the root script

summer stump
ionic loom
#

oh wait

rich adder
#

or platform type

ionic loom
#

i am

#

i have TWO tags

#

ik unbelievable

rich adder
#

You cannot have two tags on one object

ionic loom
#

i know im saying two in total

rich adder
#

oh ok , still confused why you needed two OnCollisionEnter

ionic loom
#
  private void OnCollisionEnter2D(Collision2D other)
    {
        if (other.gameObject.CompareTag("SpeedPlatform"))
        {
            maxSpeed = 14f;
        }
    }

    private void OnCollisionExit2D(Collision2D other)
    {
        if (other.gameObject.CompareTag("SpeedPlatform"))
        {
            maxSpeed = 9f;
        }
    }

i was just trying to replicate this but for jumping power

queen adder
#

@short hazel @rich adder it's working now ! Tysm 😄

ionic loom
#

youre welcome! 🙂

rich adder
swift elbow
polar acorn
#

The function runs when you collide with anything. That's why you check for tags

short hazel
#

One's Enter, the other is Exit. They're not the same so perfectly valid in this context

ionic loom
ionic loom
modest dust
#

Don't worry, you'll have more than enough opportunities to learn from experience once you get past the basics UnityChanOkay

swift elbow
#

that'll save so much more time for the future

#

unity learn has you do stuff and gives tangible results so try that !learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

modest dust
#

Or better than listening to someone yapping for a few hours straight, take a course and practice what you learn

polar acorn
ionic loom
frigid sequoia
#

Is this like... too much to have for an start method for each projectile? Cause I plan on adding more and I am kinda worried I should be doing something different

ionic loom
#

What is a proyectile

#

Sounds funny

modest dust
ionic loom
#

Is it just me or is proyectile a thing

frigid sequoia
#

Hardly, you are probably better faking it out yourself

wintry quarry
frigid sequoia
#

Like... a scriptable object or something like that?

wintry quarry
#

no just a class or struct

#

POCO

#

I mean you could you a ScriptableObject too

#

up to you

#

but it's not necessary

modest dust
#

plain class/struct, serializable if it's set in the inspector

ionic loom
#

Omg [SerializeField] I know what that is !!!!

#

You can drag the thingy and it works

rich adder
ionic loom
#

Aw 😦

rich adder
#

similiar thing though

frosty river
#

Hi, I'm on Mac and trying to now build my game for both Mac and Windows. In the Unity Hub, the only windows modules I see are under "WebGL". How to get windows build support?

rich adder
lofty sequoia
#

What does your unity hub modules look like?

frosty river
# rich adder

Should I select that even though it's under WebGL?

modest dust
frosty river
#

I thought it should appear under Platforms

frigid sequoia
#

Sry I never used that before, I don't quite understand it

modest dust
#

WebGL module is simply already installed, hence displayed differently

wintry quarry
#

you create a class or struct that holds the projectile data

lofty sequoia
summer stump
frosty river
#

oh its just a funky ui

#

its not "under" it

ionic loom
#

I just clicked smt random

#

Why would i even do that

summer stump
rich adder
#

"under" would probably be a collapsable arrow

#

as you see for "Dev Tools" or "Platforms"

frosty river
#

Is it safe to update modules in unity hub while you're doing stuff in the editor?

lofty sequoia
#

probably best to close the editor

rich adder
#

should be fine

frosty river
#

seems like it's still running

ionic loom
#

Oooo conflict

rich adder
#

just restart after

frosty river
#

why are so many games made just for windows if platforms like Unity can build for both?

wintry quarry
#

Laziness

#

And lack of testing resources

lofty sequoia
#

performance

modest dust
frosty river
# lofty sequoia

I was able to build for mac before adding the IL2CPP module, is there going to be a difference having this module or not?

#

I'm guessing I'm currently building for Mac mono

frigid sequoia
wintry quarry
#

It becomes one line

rich adder
whole idol
#

!code

eternal falconBOT
whole idol
#

Does anyone know why this code is so buggy?

wintry quarry
summer stump
whole idol
swift elbow
wintry quarry
swift elbow
summer stump
eternal falconBOT
ionic loom
#

Is there a reason for putting a public float into a. Serialize field

swift elbow
# whole idol

looks like a spelling mistake for the highlighted error

summer stump
# whole idol

Foe the unassigned ref error, do you destroy the target?

wintry quarry
frigid sequoia
# wintry quarry `myBulletData = payerStats.bulletData;`

So I set the struct on the playerController, give it all the relevant data and then pass that to the bullet itseflt and set every stat of it according to the struct data? Isn't that equally ineficient or I am just overthinking it?

wintry quarry
#

MathF < the Unity one is Mathf

frosty river
#

When you're messing with your code in the editor and clicking "Play", is it interpreting rather than compiling the C#? (this may be a very stupid question)

ionic loom
#

So why not make the private serialized float public?

queen adder
#

script: using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements;
public class UIHandler : MonoBehaviour
{
public float CurrentHealth = 0.5f;

private VisualElement m_healthbar;

public static UIHandler instance { get; private set; }


private void Awake()
{
    instance = this;
    
}

void Start()
{
    UIDocument uiDocument = GetComponent<UIDocument>();
        m_healthbar = uiDocument.rootVisualElement.Q<VisualElement>("HealthBar");
        SetHealthValue(1.0f);

}
public void SetHealthValue(float percentage)
{
    m_healthbar.style.width = Length.Percent(100 * percentage);
}

}

wintry quarry
eternal falconBOT
wintry quarry
#

It's one line

summer stump
summer stump
queen adder
#

i always forget to do that

#

tdah

ionic loom
queen adder
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements;
public class UIHandler : MonoBehaviour
{
    public float CurrentHealth = 0.5f;

    private VisualElement m_healthbar;

    public static UIHandler instance { get; private set; }


    private void Awake()
    {
        instance = this;
        
    }

    void Start()
    {
        UIDocument uiDocument = GetComponent<UIDocument>();
            m_healthbar = uiDocument.rootVisualElement.Q<VisualElement>("HealthBar");
            SetHealthValue(1.0f);

    }
    public void SetHealthValue(float percentage)
    {
        m_healthbar.style.width = Length.Percent(100 * percentage);
    }
    
}
frigid sequoia
#

Right?

carmine sierra
#

I have a function which is running later than expected, could this be to do with processing power and the way my function is being obtained? (from another script)

wintry quarry
#

there's no need to do that at all

#

when you need it you just do myProjectileData.range

#

there's no reason to duplicate all the variables

wintry quarry
#

code runs immediately when you call it
Nothing to do with processing power.

ionic loom
carmine sierra
carmine sierra
wintry quarry
frigid sequoia
summer stump
frigid sequoia
#

Ok... sure, I guess I will do that

wintry quarry
#

refactoring is a normal process. But yes you would simplify your code.

ionic loom
summer stump
frigid sequoia
#

So if I set the struct on the playerController I can use it no problem in any script or...?

modest dust
#

Anywhere you want

ionic loom
wintry quarry
ionic loom
#

Sounds sarcastic somehow

wintry quarry
#

Not really sure what you mean beyond that

summer stump
ionic loom
#

Wait stop doing what

summer stump
modest dust
ionic loom
#

Ok

frigid sequoia
wintry quarry
#

wdym by "direct reference to the struct itself"?

wintry quarry
#

Like anything else if you need the data you have to access it somehow through a reference or by copying it passing a parameter around, whatever.

carmine sierra
carmine sierra
frigid sequoia
#

Is that it?

queen adder
#

anyone can get it for free in unity store

modest dust
#

And you can't pass around private types anyways (outside of the declaring scope)

#

I feel like you're missing some C# basics

frigid sequoia
#

I never "needed" a struct

#

I would literally wouldn't know about it if I didn't ask you guys

modest dust
#

Well, it would be good to learn C# basics first or you'll be stuck on non-Unity related issues, like right now

#

Either learn one thing at a time or make a mess trying to learn both

frigid sequoia
#

Doing isolated stuff with code practice or stuff like that doesn't work for me whatsoever

#

I just forget it as soon as I finish it

modest dust
#

Well, at least learn the absolute basics

#

Such things as structs are one of them

carmine sierra
#

hi caesar, any chance you could help me?

modest dust
frigid sequoia
frigid sequoia
#

Precisely the reason why I am doing kinda of bigger thing here, just to force me to learn this stuff

carmine sierra
#

I am trying to run this function 0.5 seconds after the countdown starts

carmine sierra
#

I was wondering if you could pinpoint what could be preventing this (i couldnt myself)

modest dust
#

It's just a way to bundle related fields and copy the instance by value rather than by reference

#

Passing around a struct is just passing a new separate instance, changing the original fields doesn't change the copy

#

Passing around a class is just passing around a reference to that instance instead of making new copies, changing the fields of the original changes the passed "copies"

frigid sequoia
modest dust
#

Not only for performance

#

If I were to instantiate 10 bullets with a struct containing initial speed and rotation and maybe something more, and I'd want to modify these values differently for each bullet over time then passing via struct rather than class would make sense

#

And passing one by one is just.. wasteful. Why would you want to separately copy every single field. Rather than that if you ever want to change something, just add a new field to your struct and you're already done, no need to modify the method responsible for duplicating data

frigid sequoia
frigid sequoia
whole idol
frigid sequoia
#

I am kinda just using the PlayerController as struct now that I think about it....

modest dust
frigid sequoia
#

It basically holds most of all the data, which is kinda weird

whole idol
#

I'll list all the errors here in numerical order in case it's difficult to read📋

  1. Assets\Scripts\PlayerController.cs(91,18): error CS1061: 'Movement' does not contain a definition for 'isPrinting' and no accessible extension method 'isPrinting' accepting a first argument of type 'Movement' could be found (are you missing a using directive or an assembly reference?)

  2. Assets\Scripts\PlayerController.cs(69,39): error CS0117: 'MathF' does not contain a definition for 'MoveTowards'

  3. UnassignedReferenceException: The variable target of CameraManager has not been assigned.
    You probably need to assign the target variable of the CameraManager script in the inspector.
    UnityEngine.Transform.get_position () (at <17484a9af6b944dea5cd9be4dbb0da2c>:0)
    CameraManager.Awake () (at Assets/Scripts/CameraManager.cs:20)

https://gdl.space/ucudofaset.cs 👈 code

modest dust
summer stump
# whole idol ye

If it is configured, it should show the other errors directly in your code

I dunno what line the unassigned reference error is talking about, but it should tell you in your console

plucky ether
#

Hello everyone, literally just joined and was wondering if I could get a bit of help with a final project for school..

whole idol
summer stump
whole idol
#

compiler error* sorry

frigid sequoia
#

Like, my player needs to pick up stuff that modifies what it does, and most of the changes are attached to how the projectile works, so I would need to pass the reference of all the power ups picked by the player to be attached to the projectile

#

So my question here is... how would I make the proyectileData struct have a reference to all the power ups that effect the projectile the player has?

plucky ether
#

I'm not sure if I'm running into an issue with my code, or if I'm not implementing it properly into Unity, but I'm trying to get cakes that are falling from the sky to stick to a tray I've attached to the player by using a spring joint.

plucky ether
#

this is what my code looks like

slender nymph
#

your methods are inside of the Start method. they do not belong in there

ionic loom
plucky ether
#

Still really new, so it's something I didn't notice, I'll change that now thank you

whole idol
plucky ether
#

yes I did, I just didn't know if that was okay to post

teal viper
whole idol
slender nymph
plucky ether
frigid sequoia
#

Like so you undestand it better, powerUps shoud hold a list of all the the powerUps currently picked and should be taken in account. In this case, the "hasExplosiveShoots" IS a powerUp but I need to pass it to the projectile for it to do the stuff. "NinjaCloak" for example does other stuff that needs extra parameters that pretty sure should be better stored on a struct. So how the hell do I even organize this?

whole idol
#
Assets\Scripts\PlayerController.cs(91,18): error CS1061: 'Movement' does not contain a definition for 'isPrinting' and no accessible extension method 'isPrinting' accepting a first argument of type 'Movement' could be found (are you missing a using directive or an assembly reference?)

Assets\Scripts\PlayerController.cs(69,39): error CS0117: 'MathF' does not contain a definition for 'MoveTowards'

Anyway so here's the new console errors that seem to be only 2 trustable errors after restarting my unity

https://gdl.space/ucudofaset.cs Codezilla here.

summer stump
teal viper
wintry quarry
plucky ether
summer stump
teal viper
#

Didn't notice that the correct var is isSprinting lol

frigid sequoia
#

Is that right?

modest dust
#

If it's null, there's no powerup of that type

eternal needle
modest dust
#

Otherwise apply powerup

teal viper
# whole idol

So it's configured properly. How could you not see it suggesting you the correct variable name..?

summer stump
# whole idol

Ok, and when you hover over the underlined word (movetowards), does it say "quick fixes"

whole idol
#

it was showing me isprinting, it should had been issprinting instead

teal viper
# whole idol it's not

For the isPrinting I mean. When you were typing it should have showed you the correct option.

frigid sequoia
#

What I was doing until now was to create parameters in the PlayerController and keep them "unused" until the bool that indicates that the powerUp is picked is true; which happens when they pick the powerUp, it also sets all the relevant varibales

#

So you are telling me I should extend the struc on the powerUp itself?

modest dust
#

Add powerup class (or nullable struts) fields to the ProjectileData struct

whole idol
#

This is all I get

#

wrap, unwrap and the last one, introduce parameter for 'movement'

frigid sequoia
#

Is that what you are saying?

teal viper
whole idol
modest dust
wintry quarry
teal viper
# whole idol

That's what you should've looked at with movement.

frigid sequoia
wintry quarry
queen adder
wintry quarry
#

stop listening to it

whole idol
devout spire
#

I have a function that loads saved settings from PlayerPrefs which runs when the game launches (I know it's running because I can see the Debug.Log in the console) but the settings only apply when I open the settings menu for some reason. I've tried allowing the settings menu to be active for a moment when the game launches but that didn't work either. Does anyone have any idea why this is and how I could fix it?

teal viper
wintry quarry
frigid sequoia
eternal falconBOT
teal viper
#

If it's GitHub copilot, I'd disable it entirely while you're still learning.

whole idol
devout spire
# wintry quarry !code

Load Saved Settings Function:

    {
        Debug.Log("Loaded saved settings!");

        volumeSlider.value = PlayerPrefs.GetFloat("volume");
        musicSlider.value = PlayerPrefs.GetFloat("music");
        sfxSlider.value = PlayerPrefs.GetFloat("sfx");
    }```

Main Menu Class:
```using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class MainMenu : MonoBehaviour
{
    public GameObject settingsMenu;

    void Awake()
    {
        settingsMenu.GetComponent<SettingsMenu>().LoadSavedSettings();
    }

    public void PlayGame()
    {
        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
    }

    public void QuitGame()
    {
        Debug.Log("Quit!");
        Application.Quit();
    }
}```
frigid sequoia
summer stump
wintry quarry
devout spire
modest dust
devout spire
#

ty

whole idol
#

Ok so, my player has stopped moving and instead when I press the WASD keys he just rotates around himself... sadok

https://gdl.space/dayeqabaqo.cs < CharacterController script

https://gdl.space/gazomuwasa.cs < CameraManagement scirpt

You probably need to assign the target variable of the CameraManager script in the inspector.
UnityEngine.Transform.get_position () (at <17484a9af6b944dea5cd9be4dbb0da2c>:0)
CameraManager.Awake () (at Assets/Scripts/CameraManager.cs:22)```

^^^ Not true I did assign it
wintry quarry
#

You might have assigned it on ONE copy of the camera manager script

#

but there's another copy somewhere you didn't assign it

crisp knoll
#

Hello, need a bit of help.

I have this function in my BallBehavior script attached to a gameobject, and i want it to turn around as if it would bounce using it.

public void OnCollisionEnter2D(Collision2D collision)
    {
        Rigidbody2D rb = this.GetComponent<Rigidbody2D>();
        if (collision.gameObject.tag == "Vert Wall")
        {
            rb.velocity = new Vector2(rb.velocity.x, -rb.velocity.y);
        } else if (collision.gameObject.tag == "Hor Wall")
        {
            rb.velocity = new Vector2(-rb.velocity.x, rb.velocity.y);
        }
    }

However, the velocity is set to zero before i can flip it. is there any way to counteract this? or am i doing something wrong?

whole idol
whole idol
wintry quarry
crisp knoll
#

what is collision.relativeVelocity exactly?

crisp knoll
#

thanks

lost anvil
#

bump

whole idol
crisp knoll
#

Im not sure this will work. My object is colliding with a wall that wont be moving, and so wont the relative velocity be zero?

summer stump
#

The only way the relative velocity would be 0 is if neither object is moving or they are moving in the same velocity in the same direction (meaning no collision)

wintry quarry
summer stump
#

Relative velocity of one moving object and a static object is simply the velocity of the moving object

wintry quarry
#

the relative velocity will be whatever the pre-collision velocity of the moving object was

crisp knoll
#

okay, i think i get it now.

so replacing rb.velocity in the new vector2 with collision.relativeVelocity would solve my problem?

#

sorry if I seem stupid im very new to unity

wintry quarry
#

try it

crisp knoll
#

it still seems to have the problem

wintry quarry
#

have you tried Debug.Logging the relativeVelocity?

whole idol
#

it's no where except for where it should be

frigid sequoia
#

So I ended up doing something like this. Is this the intended way of using it?

crisp knoll
# wintry quarry have you tried Debug.Logging the relativeVelocity?

thats really wierd. the relativeVelocity is logging the correct velocity, but it seems that im having trouble changing the velocity to the right thing:

public void OnCollisionEnter2D(Collision2D collision)
    {

        Vector2 newVelocity = collision.relativeVelocity;
        Debug.Log(newVelocity);
        Rigidbody2D rb = this.GetComponent<Rigidbody2D>();
        if (collision.gameObject.tag == "Vert Wall")
        {
            rb.velocity = new Vector2(newVelocity.x, -newVelocity.y);
        } else if (collision.gameObject.tag == "Hor Wall")
        {
            rb.velocity = new Vector2(-newVelocity.x, newVelocity.y);
        }
    }
queen adder
#

i should die when the remaining distance is less than 1 but the death object activates before that

#

using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEditor;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Animations;

public class navmesh : MonoBehaviour
{

private NavMeshAgent agent;

public Transform Player;

public Animator anim;

public int Health;

public GameObject PlayerPrefab;

private void Update()
{

  agent=GetComponent<NavMeshAgent>();
  agent.destination=Player.position;
    Debug.Log(agent.remainingDistance);
    if (agent.remainingDistance>2)
    {
        
        anim.Play("run");
    }


    if (agent.remainingDistance<0.6){
       
        anim.Play("attack1");
      
        Health = 0;
        Debug.Log(Health);
        if (Health==0)
        {

            PlayerPrefab.gameObject.SetActive(true);
        }
       
    }
    



}

}

#

how do i type the code in the bars like you guys

crisp knoll
#

do triple backtick

#

and then the language

#

so like '''cs

#

but with backticks (left of the 1 on us keyboards)

queen adder
#

i can't send it for some reason

frigid sequoia
#

Also, I just noticed, struct cannot be modified from the the inspector right? Cause just pressing a bool to tick if some powerUp is active was VERY usefull for testing

whole idol
winter cedar
#

!code

eternal falconBOT
queen adder
#

can you guys help with my problem

#

up

summer stump
summer stump
#

That was not a yes or no question

queen adder
summer stump
whole idol
crisp knoll
#
private Rigidbody2D rb;
    void Start()
    {
        rb = GetComponent<Rigidbody2D>();
    }

    // Update is called once per frame
    void Update()
    {
        
    }

public void OnCollisionEnter2D(Collision2D collision)
    {

        Vector2 newVelocity = collision.relativeVelocity;
        Debug.Log(newVelocity);
        if (collision.gameObject.tag == "Vert Wall")
        {
            Debug.Log("Velocity to change to: " + new Vector2(newVelocity.x, -newVelocity.y));
            rb.velocity = new Vector2(newVelocity.x, -newVelocity.y);
        } else if (collision.gameObject.tag == "Hor Wall")
        {
            Debug.Log("Velocity to change to: " + new Vector2(-newVelocity.x, newVelocity.y));
            rb.velocity = new Vector2(-newVelocity.x, newVelocity.y);
        }
    }

I cant seem to find problems in this code except setting the rb.velocity. Im not sure what to do

summer stump
# queen adder 34

Ok, I kinda think the issue is in some other code.
You have PlayerPrefab.gameObject.SetActive(true) (which is kind of concerning, because prefabs do not exist in the scene, and don't have an active state), but it's a ui element that is set active?

queen adder
#

ahh man i think i messed up

summer stump
queen adder
#

i pasted the wrong code

summer stump
twin bolt
summer stump
queen adder
#

this code is better i think 😢 the Dead UI gameobject should be setactive true when the distance < 0.6 but it activates the moment i start the game

#

using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEditor;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Animations;

public class navmesh : MonoBehaviour{
private NavMeshAgent agent;
public Transform Target;
public Animator anim;
public GameObject UIObject;
private void Update() {
agent=GetComponent<NavMeshAgent>();
agent.destination=Target.position;
Debug.Log(agent.remainingDistance);
if (agent.remainingDistance > 2){

        anim.Play("run");
    }
    if (agent.remainingDistance < 0.6) {
        anim.Play("attack1");
       UIObject.gameObject.SetActive(true);          
    }
}

}

#

it looks like the code doesn't care about remaining distance and just activates

queen adder
teal viper
queen adder
#

its around 25

teal viper
#

Take a screenshot of the very first message

carmine sierra
#

what would you call an instance where there is only of them? (documentation reasons)

carmine sierra
#

thought singleton was right

queen adder
teal viper
#

Singleton is a programming pattern that makes sure that there is always only one instance.

carmine sierra
#

oohh okay

teal viper
# queen adder

Open the damn console tab, scroll up and take a screenshot...

queen adder
#

its 0 at start

#

wow

#

then it goes to 27

teal viper
#

Yep

queen adder
#

but why

teal viper
#

Navmesh agent takes time to calculate the path. Before it's ready, it doesn't know the remaining distance

#

Maybe check if it has a valid path before making the distance check

queen adder
#

how do i check ? and where

grave frost
#

This is a very noob question but I can't seem to remember. When setting transform.position, does the parent transform affect the output position? Because from the documentation it looks like it shouldn't, yet it seems to do this when set.

wintry quarry
#

Not sure what you mean exactly by "output position"

grave frost
#

the position that is resulted from setting the transform's position

#

so this line should set the object's transform position to the 'unit' position, reguardless of parent, correct?

gameObject.transform.position = new Vector3(unit.gameObject.transform.position.x, gameObject.transform.position.y, unit.gameObject.transform.position.z);
#

Will a normal transform having a parent that is a rect transform effect that at all?

summer stump
teal viper
grave frost
wintry quarry
#

regardless of parentage

grave frost
#

for some reason it's getting set to really large numbers of x, y, z instead of the unit's position. Its parent is a rect transform so that has to be it, right? But i thought parents shouldn't affect setting the position value.

wintry quarry
#

why do you have that situation?

wintry quarry
summer stump
grave frost
#

the object is displaying the unit's range which is all UI except for this object.

grave frost
wintry quarry
summer stump
grave frost
#

hmm why not? Even where I currently intern they do this. (this is not for intern, personal project)

wintry quarry
#

In Screen Space - Overlay, it results in what you're seeing.

#

If you use a Screen Space - Camera canvas it will work more or less

grave frost
#

okay, interesting. But it's generally fine to have the reverse?

wintry quarry
#

no

#

it's not ok in general to have UI objects that are parents of world space objects and vice versa

grave frost
#

what about when the canvas is in world space? Is that ok?

icy flume
#

I have a simple question. How do I set what UI element the mouse focus is on?

carmine sierra
#

what type of thing is time.deltatime

#

is it an enum?

#

I need to know for documentation

grave frost
#

deltatime is a float

carmine sierra
#

but time

#

and deltatime

summer stump
summer stump
carmine sierra
#

thought so

summer stump
carmine sierra
#

time i could call like an in built class?

#

or from unity's class library?

rancid tinsel
#

this doesnt do anything right?

frosty river
#

built my first game 🙂 followed a tutorial and its pretty basic, but still a good notch under the belt

frigid sequoia
#

What the heck is this error I am getting?

north kiln
summer stump
twin bolt
#

How do i change antialiasing in HDRP during runtime from script?

#

I've tried google, but none give good explanations.

carmine sierra
#

unity crashed what do i do?

rancid tinsel
#

I mean I know the code itself does something but I mean effectively, it does nothing?

#

Nothing changes by that being there I'm assuming

frigid sequoia
#

I am now getting this error out of nowhere. I have no compile errors showing anywhere

eternal needle
eternal needle
frigid sequoia
summer stump
frigid sequoia
#

Doesn't show any compile errors

inland monolith
#

Is there an easy way to take the text in a text object and project it to a text mesh on the canvas?

inland monolith
frigid sequoia
inland monolith
wintry quarry
#

isn't it just destination.text = source.text?

inland monolith
#

wait....

carmine sierra
#

any idea why these if statements aren't being entered? i have debugged everything

wintry quarry
carmine sierra
wintry quarry
#

then the name doesn't start with those

carmine sierra
#

this would be valid no?

summer stump
#

This would be a good use for enums

#

Instead of using a gameobject name

wintry quarry
#
Debug.Log($"My name is {name} and do I start with RED KING? { (name.StartsWith("RED KING") ? "yes" : "no") }");```
#

something like this

#

but yeah

#

using object names is crazy

#

as is having scripts named P1_NameInput and P2_NameInput

carmine sierra
#

i know its just barely getting by

wintry quarry
wintry quarry
#

then it's entering the if statements

inland monolith
wintry quarry
carmine sierra
wintry quarry
carmine sierra
#

no errors

inland monolith
#

The idea is I click on a seat lets say 1F for right now I then take that seat name and add it to the canvas where it says SEAT:. My issue is that I cant just directly connect the two because the code uses .txt which doesnt work with the textmesh
my question is there some way to have the textmesh read what is on the txt file at real time then display it?

teal viper
carmine sierra
#

this line is the issue

#

says object reference not set to an instance of the script

#

@teal viper idk if its fine to @ you

summer stump
#

It isn't automatic

#

You have to actually assign it. Usually to "this"

carmine sierra
#

ohh

summer stump
carmine sierra
#

as broken as it is

#

thank you @summer stump youve helped me alot finishing this project

summer stump
#

No prob

wintry quarry
carmine sierra
frigid sequoia
#

If I instantiate a collider just on top of a another one, does that trigger an OnTriggerEnter? It should right?

swift elbow
teal viper
frigid sequoia
#

I want to instantiate an explosion with a collider and it instantly detecting any enemies inside

wintry quarry
wintry quarry
frigid sequoia
#

I have to deactivate the collider for a frame and then activate it?

swift elbow
wintry quarry
#

anyway, it's not the right approach for this problem

frigid sequoia
swift elbow
wintry quarry
#

of course it's physics based

#

you're literally talking about colliders

teal viper
#

How is it not physics based if you're using colliders?notlikethis

frigid sequoia
#

Colliders, but not rb

wintry quarry
#

that's physics

#

anyway the fact you don't have a Rigidbody is why it's not working

#

but really

teal viper
#

Physics is not just an rb

wintry quarry
#

USE OVERLAPSPHERE

#

it's the right way.

wintry quarry
#

Using a collider for this is insane because you'd have to wait until the physics simulation step to react to the explosion

teal viper
frigid sequoia
teal viper
frigid sequoia
#

If you want to call detecting collisions by just colliders and not any physic simulation beyond that such as you would do with Raycast, sure, it is physiscs

teal viper
#

Or rather, in your understanding what would make it "physics based"?

frigid sequoia
#

But this is no different than taking two sprites and see if one is on top of each other

teal viper
#

It is different, because you're relying on the physics system to calculate the collision

languid saffron
#

Silly question, but how would I get the "Focus on Tilemap" option in Scene view?

teal viper
#

If anything an overlap query would be "less physics based", although that really doesn't make sense.

teal viper
frigid sequoia
#

As far as I know only rb use actual physic based collisions

wintry quarry
teal viper
frigid sequoia
swift elbow
#

Actually, it all goes through me first because I AM the physics system 😁

frigid sequoia
teal viper
languid saffron
#

Why doesn't it let me add a Scene when I click "Add Open Scene" button in build settings?

frigid sequoia
frigid sequoia
swift elbow
teal viper
#

Have explosions use overlap sphere. Other cases would implement logic that suits them.

languid saffron
frigid sequoia
#

The abstraction in this is: Is meant to be a zone where if either you or an enemy enter, you take damage

swift elbow
frigid sequoia
#

With some extra modularity and configurations

teal viper
timber tide
#

you can probably swap out different mesh colliders if you want different shapes that arent primitives

#

no clue how doable that sounds

green copper
#

Why can't I preassign the enemy manager in the prefab for a sentry turret?

#

if I try to set it to enemyManager, it says there's a type mistmatch, but the handmade turret I'm trying to prefab accepted it fine

wintry quarry
green copper
#

is there a way I can give the turret an Awake() to assign it, or should I do it in the blueprintManager that instantiates the turrets?

wintry quarry
#

do it in the thing that instantiates turrets

#

Or

#

use the singleton pattern

#

EnemyManager sounds like something that would be a singleton

timber tide
#

yeah. you can reference it directly from the class would be preferable

#

or via GameManager singleton such that you can dot access it via GameManager.EnemyManager

green copper
#

Having googled singletons, that sounds exactly correct, thank you

frigid sequoia
#

Oh, never mind, I am absolutelly drunk, it was not even usign a trigger Collider, how can I be so dumb?

#

It does work now, I just let a single frame where the colliders don't touch just to be sure

languid saffron
#

When I click the start button in my main menu, it takes me back to the same main menu, and I'm trying to get it to load the next scene. I've troubleshooted a bit like switching the Scene Load to 0 or 2 to see if the scene was labeled a different number. But it didn't work (Sorry if this sentence doesn't make a lot of sense, I'm very tired lmao)

young warren
hard lodge
#

ive tried for soo long but isk why it is not working, any help?

young warren
#

please look closer

eager spindle
young warren
eager spindle
#

depends if you want to put it in game manager or enemy manager

#

I used to do it in game manager but I realised it's a bit of a hassle if I want to delete something

#

And it's also not great for multiple people to change the game manager to add their singletons in a collaboration situation

young warren
hard lodge
#

No

young warren
eager spindle
#

when I started unity I made the mistake of immediately trying to link my code with my game, I feel that it's better to have a strong foundation in coding before starting unity

young warren
#

then compare where you declared your variable versus how they do it in the video

#

i would highly recommend you learn some basic terms for programming like variables and functions first

near wadi
#

!learn has a rather helpful Junior Programmer path.

eternal falconBOT
#

:teacher: Unity Learn ↗

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

young warren
#

otherwise you can't understand the help that is given

languid saffron
eager spindle
#

very interesting way to do it

young warren
#

did you mean to do + 1?

#

also show the scene index list in your build settings

languid saffron
eager spindle
#

you should add your scene to the scene index list

young warren
#

okay, so you want to load SampleScene right?

#

and this code is running in MainMenu?

languid saffron
eager spindle
languid saffron
young warren
#

ok, so then what do you think SceneManager.GetActiveScene().buildIndex will give you?

#

if this is running in the MainMenu scene, GetActiveScene will refer to the MainMenu scene, correct?

young warren
#

so what is 0 * 1?

#

0 multiplied by 1

languid saffron
#

Zero

young warren
#

okay, so you run SceneManager.LoadScene(0);

#

following so far?

languid saffron
#

LoadScene loads the scene yes

young warren
#

yeah, and what does SceneManager.LoadScene(0); mean?

languid saffron
#

Shouldn't we change it to 1 instead to load the next scene?

young warren
#

so do you need to pass to SceneManager.LoadScene instead?

#

in order to load the SampleScene

young warren
languid saffron
#

It works yippee

young warren
#

what does the 0 in SceneManager.LoadScene(0); refer to

languid saffron
#

Loads Scene 0 (Main Menu)

young warren
#

yep

languid saffron
#

But if we change it to 1 then it loads the actual game.

young warren
#

so to load SampleScene, as i'm sure you've figured out now, you use the scene index of SampleScene, which is 1

languid saffron
#

Can't this also be applied to a death screen? Like on collision with a certain object with a tag we can load the next scene?

young warren
#

sure

#

but i dont think you understand where the numbers are assigned to the scenes

#

please go to File > Build Settings

#

there should be a window that pops up

languid saffron
#

I'm there

young warren
#

can you pass me a screenshot of it please?

languid saffron
young warren
#

see the numbers on the right

#

0 for Menu, 1 for SampleScene

languid saffron
#

That's the numbers of the scene yea

young warren
#

yep

languid saffron
#

I understand that part

young warren
#

okay

#

so you understand what went wrong with your code?

#

as in why was it loading Menu instead of SampleScene earlier?

#

if not, it's okay. I can explain again if you'd like

languid saffron
#

not only does 0 * 1 = 0 (basic multiplication), but scene 0 is main menu and the actual game is scene 1

young warren
#

yep

#

now here's something else you can learn

#

documentation says SceneManager.LoadScene does this

devout linden
#

just wanna question if any programmer is Googling too much

young warren
#

you can pass in the scene name instead of the index

young warren
languid saffron
eager spindle
#

As a programmer it's important to be able to solve your own problem by searching

devout linden
#

I really use it even for player movement

languid saffron
eager spindle
#

And don't use chatgpt

young warren
languid saffron
young warren
#

of course this is prone to user error if you mistype the name or change the name of your scene in the future

charred spoke
#

Well use chatgpt responsibly.

languid saffron
young warren
young warren
eager spindle
# languid saffron Off topic, but why do you hate Java?

Java 😡
Overly verbose, lacks a lot of language features, expects users to know OOP before even stepping into the language, 2 build systems that split the open source community, users are expected to install the JRE just to run any java program,

charred spoke
young warren
#

you can reorder the scenes in the build settings as well, so using the scene index isn't foolproof either

languid saffron
eager spindle
#

I'll talk about it another day 😴

languid saffron
#

What we thinkin about my menu?

young warren
#

let's try to keep things on topic 🙂 this is a code channel

charred spoke
#

Very avant-garde

young warren
#

i'll head off now. happy developing

whole idol
#

Hi today I tried to play around with a new tutorial that teaches you how to use netcode, and the tutorial has me so far open 2 unities, why? because its how you play and test your game to see if the multiplayer actually works and stuff, so i tested it and it worked but now because I have too many windows open, is it okay if i close one? I can still access everything through the hierarchy of one of the unity's windows

#

not sure how it actually works really

#

I mean look

#

I can access the Network Object component through these game objects in the hierarchy

#

so why do I need to keep 2 Unity windows open at the same time?

young warren
#

because its how you play and test your game to see if the multiplayer actually works and stuff
isn't this why?

whole idol
#

yeah but

#

where is this like saved?

#

what will happen if I close one of them?

#

This is what im asking

young warren
#

you can always reopen it right?

whole idol
#

Im not asking things i already know

#

how?

young warren
#

how did you open the 2nd unity window the first time?

#

I'd assume if you close one, it's like the player disconnected

whole idol
#

I clicked the clone button or something

#

soon ill have to go to sleep and continue this project tomorrow

#

so this is why im asking

#

i dont want this to get lost or whatever

young warren
#

you dont need to save 2 copies of anything

#

this is just one unity project isn't it?

#

and you just opened 2 instances of it, that's all

#

so if your project is saved, that's fine

whole idol
#

ok ty

wicked cairn
tough lagoon
#

Me too, ❤️ it. I'm wondering if the tutorial led them on that path and confused them though

lost anvil
#

bump

severe robin
#

hello every one, I was following the tutorial to create the custom ui line renderer by game dev guide, every thing is working fine but while adding the material the texture of the material is not being applied to it, why? here is a code snippet:
https://paste.ofcode.org/AgP6AvqCDVepQSMy7Zg3SF

fickle plume
#

your material name is m not material

severe robin
#

@fickle plume no there is no error, and here is the attached material

severe robin
fickle plume
#

what are you assigning then?

severe robin
#

I have assined a materail to "m" in the inspector

fickle plume
#

And then you set it in the code to something else

#

recheck the tutorial code

severe robin
#

No, i am just overriding the material of canvasRenderer to m..thats the problem in the tutorial no material with texture is being used

fickle plume
#

@severe robin If you are using your own material don't switch it on line 18 to something else called "material" in inherited graphic class

severe robin
#

I removed the material switching part, but still only the color tint is being applied and no texture is being shown

fickle plume
#

You are using a custom shader there, there's no guarantee it actually uses the texture.

severe robin
#

It is not a custom shader it is built in ui shader, it is being applied correctly to an image but not to custom graphics:

fickle plume
#

Try changing color on the image component. I'm seeing in 2023.1 it doesn't update texture taken from material unless color changed at least once

#

might have to trigger refresh for UI to update

lost anvil
#

bump with update, the item is moving to the player hands last position when the item is interacted with

magic pagoda
#

is there a way to have a drop-down menu for your strings on the editor under the script variables? or does it have to be a seperate window

#

Im trying to make a drop-down menu for myself to pick from a list of enemy types when making a new enemy

severe robin
teal viper
#

In terms of position and hierarchy

lost anvil
#

its all parented fine and whatever im experimenting with localmove etc right now and im getting somewhere so ill get back to you if this doesnt solve anything

magic pagoda
#

thank youu!

timber tide
#

however, enums inherently have a drop down if you just want to use those

severe robin
teal viper
#

Also try playing with tiling scale

magic pagoda
#

this may be a dumb question but... shouldnt this script make the enemyType variable a drop down menu in the inspector?

teal viper
#

Though, I don't see the whole context, so hard to say.

magic pagoda
#

what other info do you need?

teal viper
teal viper
#

As well as a screenshot of your console tab

magic pagoda
timber tide
#

ya got any errors in your console window

#

need to clear them before editor updates

magic pagoda
#

oh shit I do actually- I hadnt noticed that

#

these two

#

..and the first one is still there

#

...I have a feeling that Im being a dumbass atm

timber tide
#

second probably just unity being silly so just deal with the top

teal viper
magic pagoda
#

yeah second was gone after the clear but the first one is still there

#

ohhHHH-

#

okay I see

#

the enemyType used to be a string value and apparently another script is still trying to access it that way

#

my random enemy spawning script