#💻┃code-beginner

1 messages · Page 693 of 1

polar acorn
#

But I guess it's the only non-forum programming channel any more

sharp solar
#

yeah i really hate forums

earnest wind
#

oh thats gpu shader

sharp solar
#

if u need forum answers you go to a forum website lol

wintry quarry
#

Nope. Awake and OnEnable do

naive pawn
#

gotcha

sharp solar
#

is vscode better than studio for unity stuff

naive pawn
#

no, nothing is really objectively better than anything else in this space

sharp solar
#

is it subjectively better

naive pawn
#

...you do know what subjective means, right

sharp solar
#

yeah it means im asking you lol

sour fulcrum
#

(most people use studio)

sharp solar
#

i heard vscode has that one good HLSL plugin that makes it tolerable

naive pawn
#

i can't even use vs lmao

#

i only barely have an opinion between vs and vsc

teal viper
#

Vs also has an hlsl extension

sharp mirage
#

or do i have to assign a material to the rb and give it no friction

rich ice
#

-# think you replied to the wrong message btw

sharp mirage
#

i did but its just to ping him

naive pawn
#

i have no idea what you're talking about

sharp mirage
naive pawn
#

not particularly

sharp mirage
#

yo am i tweaking wtf

polar acorn
#

For you, the day Bison graced your village was the most important day of your life. But for me, it was Tuesday.

foggy yoke
#

I'm trying to change my sprite's color, but the function is not being called. I have the Player Input component attached, and everything is set to the right setting(i've checked a 100 times, im pretty sure everything is correct but i could be wrong)
This is my function:

public void ChangeColor(InputAction.CallbackContext context)
    {
        if (context.performed)
        {
            if (renderer == null)
                renderer = GetComponent<SpriteRenderer>();

            Debug.Log("Changing color");

            currentColorIndex = (currentColorIndex + 1) % colors.Length;
            renderer.color = colors[currentColorIndex];
        }
    }```
foggy yoke
#

It works now, thank you.. 😅

rich adder
foggy yoke
#

but why does it work without the context.performed?

rich adder
foggy yoke
#

i know, the action had a "Hold" interaction thingy.

rich adder
#

Debug.Log(context.phase) see whats happening

foggy yoke
#

it says "Performed"

rich adder
#

interesting..wonder why its not in the if statement

#

is it normal that intellisense stops working inside #ifconditional compilation ?
Is there any way to keep working on the code with color/intellisense without having to always comment out the conditional ? a bit annoying to work with like this

polar acorn
#

I usually write the code first, then wrap it in the conditional compilation

rich adder
#

yeah I fear thats what I have to keep doing, google doesn't seem to have any answers on this..
just annoying going back to the file to add stuff having to comment it out then put it back

#

first world issues 🥲

sour fulcrum
#

Half a question for my own behalf and half a suggestion, at that point would an assemblydefinition be preferable?

rich adder
#

I would assume if you have a LOT of libraries / scripts and don't want to always having them Reload every tiny change you make to unrelated assemblies

#

its also puts you in to compartmentalization mode

sour fulcrum
#

No i meant for your thing

#

you could scope that monoscript to only android builds right?

naive pawn
rich adder
naive pawn
#

oh yeah, you're vsc on mac right?

rich adder
naive pawn
#

yeah this doesn't happen for me, for both defines that exist and don't

sour fulcrum
#

eg. for my little package my editor scripts are in a editor assembly definition so their all in the context of being in editor

naive pawn
#

oh wait hold on, i was testing with smaller regions

rich adder
naive pawn
#

i tried doing the entire file and intellisense did break

rich adder
sour fulcrum
naive pawn
#

ah i think i found it?

#

if the define doesn't exist, then that code basically doesn't exist, so intellisense isn't provided

rich adder
rich adder
naive pawn
#

something like that, yeah

#

since that is indeed kinda what #if/#endif does

rich adder
#

bummer.. Luckly these files wont be touched much just curious if it was normal that it does this to intellisense in case i use others like if Unity_Editor

naive pawn
#

i imagine it'd break to have something like this if unincluded(?) regions were processed

class C {
  #if A
  public K<T> k;
  #else
  public K k;
  #endif
}
rich adder
#

hmm makes sense that only works if its UNITY_EDITOR, otherwise its as if it wasnt there

sour fulcrum
#

can you just combine them then?

#

like if android || editor

naive pawn
#

i mean, it looks like it should be && if anything, which would similarly not work

#

not sure though

#

i didn't find any matching settings for "symbol" or "region" unfortunately

rich adder
#

yea..idk..good ol // will do for now lol

hallow acorn
#

does someone know what can cause moving a 2d sprite feel stuttery? im using rb.velocity to move it if that helps

frail hawk
#

any code to provide?

#

also make sure it is not the camera

hallow acorn
#
private void Move()
{
    if(Mathf.Abs(playerControls.Land.Move.ReadValue<Vector2>().x) > 0.1f)
    {
    rb.linearVelocityX = Mathf.Lerp(rb.linearVelocityX, playerControls.Land.Move.ReadValue<Vector2>().x * maxSpeed, acceleration * 100 * Time.deltaTime * Time.deltaTime);
    }
    else
    rb.linearVelocityX = Mathf.Lerp(rb.linearVelocityX, 0, deceleration * 100 * Time.deltaTime * Time.deltaTime);
}```
camera is not connected in any way, this is my move function which is the only part of my code that should be relevant. could it be because of Mathf.Lerp?
frail hawk
#

test it out without the lerp

slender nymph
hallow acorn
hallow acorn
slender nymph
frail hawk
#

do you have small gaps on the ground? might want to use smoother collider on the player

hallow acorn
#

but atleast i know i do thinks wrong that arent really related to my main problem as it always is haha

hallow acorn
slender nymph
#

but you do seem worried about stuttering which is a result of that "differences across frame rates"

sand marten
#

guys i need a little help making a APK of my game

hallow acorn
sand marten
#

oh okay

slender nymph
#

anyway, we need more context for the current issue

hallow acorn
hallow acorn
slender nymph
#

i'm done attempting to help here. so good luck.

frail hawk
#

can you please explain what you are doing on the first if statement and why you have it there

hallow acorn
rich adder
slender nymph
#

it's being used in the incorrect lerp, not on the velocity itself

hallow acorn
rich adder
#

oh true thought they said they removed lerp

slender nymph
hallow acorn
rich adder
rich adder
#

stutterring can be many things, might help to see whats actually going on

hallow acorn
#

i think im going insane it magically fixed it self

#

i cant do this anymore

rich adder
#

there are so many things that can make it stutter

#

also you should always show your code in context, we didnt even know how Move was called

#

ideally rigidbody move calls should be done in FixedUpdate (unless its an Impulse mode)

hallow acorn
#

called it with Update and FixedUpdate, at the moment its in fixed update but it seemed like it worked the same

#

yea thanks for helping i think im heading to sleep. cant wait until i open unity tomorrow and 100 errors appear out of nowhere

rich adder
#

it seem so but once the framerate start switching up you will notice it will move different

rich adder
#

one moves by framerate and another moves with set time

crisp bolt
#

hello, I'm writing a basic character controller script and look script using the new action input, I move the player based on the camera's X axis movement and for some reason whenever I move the character itself the camera will start drifting on the x-axis. is there an obvious reason for this? I can provide my code if needed.

obtuse knoll
#

👀 👉 👈 I'm trying coding but everything I look at looks like a random mix of words...

obtuse knoll
#

where are people pulling all these random words from

#

👀 Can i get a finger in the direction where someone can teach basic coding that will help me in unity projects?

polar acorn
eternal falconBOT
#

:teacher: Unity Learn ↗

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

rough granite
polar acorn
#

The bot message still stays if you delete your message after the fact

rough granite
polar acorn
#

I don't know if cleaning up a message purely intended just to summon a bot message is a "stinker"

limber flower
#

working on an old project and i have no idea what the + 0.2f could be for, any ideas?

limber flower
#

obviously, i mean what purpose could it serve

polar acorn
#

Well, which parameter of raycast is that?

limber flower
#

i do not know

#

like i said old project i have a very loose idea as to what anything is for

polar acorn
#

So, how about checking the documentation and seeing what parameter that is?

hexed nymph
#

Yoooo Im making a button that when you click on it changes its function but for some reason it doesn't work

slender nymph
#

be more specific than "doesn't work" and show what you tried

hexed nymph
#

    void Start()
    {
        but = GetComponent<Button>(); //this works
        but.onClick.AddListener(JoinPlayer); //this doesn't
    }```
polar acorn
hexed nymph
#

When I click to test the game, the script gets the button component (that has no listeners) and then I try to add some but the game ignores that

polar acorn
#

How are you determining it isn't

hexed nymph
#
    {
        if (PlayersHelper.playerCountHELP >= 2) //this is when you click on the button
        {
            but.onClick.RemoveListener(JoinPlayer); //but still the game doesn't recognize this command
            but.onClick.AddListener(DeletePlayer); // this too
        }
        else
        {
            but.onClick.AddListener(JoinPlayer); // this too
            but.onClick.RemoveListener(DeletePlayer); // this too
        }```
polar acorn
#

Add listeners in Update is not a good idea by the way

hexed nymph
#

this is when I start the game but it ignores the 2nd line on the Start function

hexed nymph
polar acorn
hexed nymph
polar acorn
hexed nymph
ivory bobcat
#

Just for clarity, a runtime error can cause all sorts of things to go wrong.
If it's a compiler error, you won't be running the latest up-to-date of the application.

ivory bobcat
polar acorn
hexed nymph
polar acorn
ivory bobcat
#

I'm pretty sure the code isn't ignored. Instead you've likely got an error or the behavior simply isn't what you're expecting.

hexed nymph
polar acorn
#

How about using some debug logs to see what code is running and when

hexed nymph
#

I did

#
    {
        if (whoAreYou == "P2")
        {
            Debug.Log(whoAreYou + " has joined!");
            playHelp.playerCount = 2;
            PlayersHelper.playerCountHELP = 2;
            p2text.text = whoAreYou;
            but.onClick.RemoveListener(JoinPlayer);
            but.onClick.AddListener(DeletePlayer);
        }```
#

the debug works

ivory bobcat
#

Show the logs?

hexed nymph
polar acorn
hexed nymph
#

this code is what the button does when you click on it

polar acorn
#

How about instead of these tiny piecemeal windows into what's happening, you just post the full !code

eternal falconBOT
hexed nymph
#

instead shows "joinplayer"

polar acorn
hexed nymph
polar acorn
hexed nymph
polar acorn
#

And try putting a log outside the if statements

#

see if the functions are called

hexed nymph
#

okok

polar acorn
#

If the idea is simply to make the function toggle every time you hit it, why not just have one function and read a boolean in it, then toggle the boolean when you want to swap?

hexed nymph
polar acorn
hexed nymph
#

bruh it worked now

#

thanksss

polar acorn
#

Still, consider not doing this callback swapping and just use a boolean instead

hexed nymph
#

I think the problem was that I thought that the inspector will show the changes lol

hexed nymph
#

thanks anyways!

polar acorn
woeful scaffold
#

its been like almost a week and now im able to code an interaction system by mself finally 🙏

sour fulcrum
#

thats a big step! congrats

woeful scaffold
#

thxx, ill def need help with scriptableobjects tho as i want to have a pickup system

limber flower
#

im having an issue where my character has the "in air" tag no matter what, and when i fiddle with the values to try and correct that, it has the grounded effect when its way above the ground, any ideas?

https://paste.mod.gg/lnuuuybfykwh/0

wintry quarry
limber flower
twin pivot
#

but personally i just try to avoid using floats as much as possible

wintry quarry
#

A good way to debug this is to use Debug.DrawRay/Line to visualize your Raycast

#

Then you can actually see in the scene where it is and why it's not giving you the expected results.

limber flower
#

That will be very helpful yes

#

Can't test that right now but I'll do that when I get back

woeful scaffold
#

im trying to figure out how to create a hotbar with working slots + scriptableobject holder

#

this is SO HARD

#

my brain just shuts off

#

does any1 have any good place to go to, to better understand the structure of it?

twin pivot
#

how about getting a so with an array of objectsand have the hotbar as some sort of holder

woeful scaffold
#

What i did so far is making an Item[] array to hold item type

#
 {
     public Transform hand;
     public Item[] slots;
     public int currentSelectedIndex = -1;
     private GameObject currentEquippedItem;

     void Start()
     {

     }

     void Update()
     {
         for (int i = 0; i < slots.Length; i++)
         {
             if (Input.GetKeyDown(KeyCode.Alpha1 + i))
             {
                 EquipItemAtIndex(i);
             }
         }
     }

     public void EquipItemAtIndex(int index)
     {
         if (index < 0 || index >= slots.Length) return;

         if (slots[index] != null)
         {
             Destroy(currentEquippedItem);

         }
     }
 }```
#

this is how far ive come in 20-30 minutes without chatgpt and its breaking my brain

ivory bobcat
true knoll
#

I'm making a 2d shader to change a noise texture to water, but after I add the material with a shader to the image with the noise, masking no longer works... I have very limited knowledge with shaders and am slowly going insane. Any fixes anybody knows of?

teal viper
frigid sequoia
#

I would usually just make this a subclase wihtout asking but considering it seems I may be overusing it... should I create a subclase for specific the gear slot for weapon and off-hand that use a slighty different logic or do I just work it out on the same class?

frigid sequoia
#

Are u sure u are using the right layers???

true knoll
#

It works when I dont have the shader/material on

limber flower
frigid sequoia
#

This is mine working with no issues. I dunno

wintry quarry
#

You can also turn on the physics query visualizations

#

That's a thing that exists too

faint osprey
#

need a lil help im adding an edge collider at runtime how would i make it ignore all layers other than the 'enemy' layer

wintry quarry
faint osprey
#

u can set up layers to ignore others?

wintry quarry
#

Of course

#

Physics 2d project settings

faint osprey
#

so like that

pallid heron
#

if I have a static variable, is there any way at all to set that using the inspector? I want to have a static ScriptableObject but I'd rather not load it in during Awake if possible

teal viper
# true knoll How do I do that?

Sample the mask texture in your shader and discard the pixel depending on the value.

Though, I'm not 100% sure. If unity uses stencil buffer for masks, you might need to specify stencil test value.

limber flower
#

i truned on the options that im pretty sure are supposed to make me see ray casts, but i dont see the ray in scene or game view, how do i fix that?

sour fulcrum
# pallid heron if I have a static variable, is there any way at all to set that using the inspe...

I've commonly had scriptableobjects be stored on a major singleton that i can always count on existing then use a static property to access it statically, eg.

public class ContentManifestCollection : ScriptableObject
{
    [SerializeField] private PlayerManifest playerManifest;
    [SerializeField] private CardManifest cardManifest;
    [SerializeField] private BiomeManifest biomeManifest;
    [SerializeField] private ScriptableColorPresetManifest colorManifest;
    [SerializeField] private SpriteManifest spriteManifest;

    public static ContentManifestCollection Contents => ContentManager.Instance.ContentCollection;

    public static PlayerManifest Players => Contents.playerManifest;
    public static CardManifest Cards => Contents.cardManifest;
    public static BiomeManifest Biomes => Contents.biomeManifest;
    public static ScriptableColorPresetManifest Colors => Contents.colorManifest;
    public static SpriteManifest Sprites => Contents.spriteManifest;
}
frigid sequoia
#

If I have something like this, is there not a way to assign to that slot, each its own gameObject? Do I have to go one for one?

#

Cause that's something that wastes me a lot of time considering how often I do it lol

marsh canyon
#

Is there a special type of raycast or reference to use for the camera?

I want to make a script that tries to see if there are any objects between the player and camera.... and if there is... then turn the mesh renderer off of that object until it no longer touches the raycast

sour fulcrum
frigid sequoia
#

But there is also a specific method depending of what you are doing

frigid sequoia
#

First I make sure the UI actually shows as I want to before making it work

marsh canyon
#

cause I don't think simply just one raycast would work for this.... could be wrong but I haven't really used raycasts for many things before

frigid sequoia
#

As the origin of the raycast

marsh canyon
#

so what, just do a simple normal raycast with that position as point A to point B being the player to determine the distance?

limber flower
#
private void Update()
{
    grounded = Physics.Raycast(transform.position, Vector3.down, playerHeight * 0.5f + 0.2f, whatIsGround);

    MyInput();

    if (grounded)
        rb.linearDamping = groundDrag;
    else
        rb.linearDamping = airDrag;
}
sour fulcrum
#

@frigid sequoia you might want to re-read their question

#

or actually not sure how its phrased

rough granite
limber flower
sour fulcrum
#

oh i misread it, apologies

rough granite
sour fulcrum
#

@marsh canyon you probably want a boxcastall

frigid sequoia
limber flower
frigid sequoia
#

You probably want to get all the targets in the way tho, not only the first one

rough granite
limber flower
frigid sequoia
limber flower
#

idk someone reccomended it

rough granite
limber flower
#

i see

rough granite
#

though it depends on what's happening cant' do much without such info

limber flower
#

ok so the boolean "readyToJump" becomes true very inconsistently

#

which is supposed to be activated when a raycast that points directly down crosses a "whaIsGround" layer

rough granite
#

eg
[SerializeField] float GroundCheckDistance = 0.1f;

limber flower
#

well if i could see the ray i would know whats happening

#

but i cant figure out how to enable physics debug

rough granite
#

just use OnDrawGizmos()

#

eg
private void OnDrawGizmos()
{
Gizmos.DrawRay(transform.position, -transform.up * GroundCheckDistance);
}

#

though i don't think these have a range limit

#

might be wrong

limber flower
#

is that to fix the problem overall, or make the ray visible

rough granite
#

that'd just make a visable ray when in scene view

limber flower
rough granite
#

which i why i recommended changing the 0.2f to a public float with a name instead of a magic variable

limber flower
#

it doesnt reach the ground on flat ground consistently

rough granite
#

right so increase it

limber flower
#

ive increased it to twice the player height and it didnt work, and decreased it to really short and it worked, i just want the visualization so i know whats happening when i change things

rough granite
rough granite
limber flower
rough granite
limber flower
#

whys that?

#

i just did it that way because i know thats what they use in tf2

rough granite
wary sonnet
#

what was the cmd to trigger the docs bot here ?

north kiln
#

!docs

eternal falconBOT
north kiln
#

The commands are listed in id:guide > Start Here

wary sonnet
#

nice thanks

rough granite
#

same with readyToJump

#

hard to tell for which one isn't working when neither show in the inspector

limber flower
#

so readyToJump is working fine, but grounded turns on and off constantly if i make any movement, even camera movement

rough granite
#

on the rigidbody, i've never used continuous since it's never really worked for me

frigid sequoia
#

Mmmm, I don't find anything missing, does it not point it out?

rough granite
#

always stuck to discrete

limber flower
#

when i switched to capsule colider just now it makes the character shake violently when it bumps into anything

#

freeze rotation for x and z is on

rough granite
frigid sequoia
#

I love when scripts just dissapear when I rename them lol

rough granite
limber flower
#

increasing player height (adjusts how far the ray should be) it still is on and off but its off more often, which should be the opposite of what it does

#

and decreasing playerHeight makes it almost always off but occasionally on for seemingly no reason

rough granite
#

instead of Vector3.down

limber flower
#

functions identically

#

grounded seems to be tied to camera movement for some reason

rough granite
#

why though :/

limber flower
#

thats the question

rough granite
#

what if you turn off interpolation on the rigidbody?

limber flower
#

all that did was make the grounded bool true less often

rough granite
#

and the continuous what if you try discrete?

limber flower
#

i changed that back when you said to and didnt notice anything different

limber flower
#

actually thats not true

#

it doesnt wobble anymore

rough granite
#

ok so what i though Continuous is meant for fast moving things

limber flower
#

but collisions still affect the camera which isnt good

rough granite
#

which the player i doubt is meant to be

rough granite
limber flower
#

it does not

#

but its tied to the player which does

#

camera holder contains the camera, and gets teleported to camera pos

limber flower
#

its position gets set to the object camera pos when the game is running

#

camera holder controls up and down motion and camera holder is just attached to the player which is turns left and right

rough granite
#

right, could the camera being in the same object thats getting moved/teleported be the issue?

limber flower
#

well the player character shouldnt get rotated when it runs into a colider anyways

rough granite
frigid sequoia
#

Ok, so here is a extremely weird question, like, if I am filtering gear... ah what do I do with the stuff that is being filtered? I like just.... hide it?

limber flower
frigid sequoia
#

So let say I have this and I want to JUST show weapons, do I still keep all the rest on scene but just like dissabled?

rough granite
limber flower
#

oh ok

rough granite
limber flower
#

as i learn more about unity i realize that i definitely picked the wrong tutorial to learn movement and camera controls

rough granite
frigid sequoia
#

Shouldn't I keep it cleaner?

rough granite
limber flower
#

100% of my learning of unity has been fixing all the things that are bad that i got from that tutorial

frigid sequoia
#

An auto filter basically

rough granite
#

i see is there a lot of items to where it'd be more worth it to delete and spawn the new items versus just showing and hiding them? cause it's actually recommended to keep objects hidden in a "pool"| and just show them over spawning them in cause spawning a lot of Objects will have frame spikes

frigid sequoia
#

I have no freaking clue what would be more efficient honestly

#

I have to keep track to all that is in the inventory forever anyways

limber flower
#

what i would do is have an invisible inventory , and when you open the ui inventory it just shows you what things from your invisible inventory that fit the filter

frigid sequoia
#

So keep making and unmaking it seems kinda dumb

sour fulcrum
#

Just do it however you want tbh. The best way is gonna be stuff your not interested in rn anyway

rough granite
limber flower
#

ok i genuinely dont know how this code works, because even when the player height is set to zero, which should make the ray that checks if the character is grounded very short, i can still occasionally jump

frigid sequoia
#

Maybe you should check the code for jumping instead of the check of the one that check if you are grounded

#

Anyways you should send a debug that tells you when you are grounded

rough granite
limber flower
#

i did

#

i can see when grounded is true

#

and nothing i do to the values that grounded supposedly uses to calculate if the character is grounded changes how grounded works

rough granite
#

alright well besides the raycast this is your jump code, where the readyToJump restricts your jumping to once every 0.25 seconds at minimum

limber flower
#

yes

#

and that works exactly as intended

frigid sequoia
#

You are probably too focused on the values when probably the error is not on the numbers but in the logic

#

Are you 100% of the time grounded while not jumping?

limber flower
#

no

#

wait do you mean grounded as in touching ground, or grounded as in the boolean

rough granite
limber flower
#

sure

frigid sequoia
#

I mean the boolean obviously

limber flower
frigid sequoia
#

I didn't ask that.....

#

I ask if you are always grounded when you are not jumping

limber flower
#

sorry tired

rough granite
limber flower
#

it is not always true when im not jumping, but it is always not true when i am way above the ground

#

if im only a meter or so off the ground it is sometimes true and sometimes not

#

im trying to send that video

frigid sequoia
#

Yeah, then the bool is doing weird stuff, and it has nothing to do with the numbers

#

Would be way easier to see with the Debug.DrawLine but....

#

If you are totally still it's always true?

teal viper
#

And log whenever a value is assigned to it

#

It could be a faulty ground detection logic

limber flower
frigid sequoia
#

I mean TOTALLY still

limber flower
#

ohok

frigid sequoia
#

Sometimes walking can change the result

limber flower
#

so if im perfectly still the value doesnt change, if i walk around or look around the value rapidly switches

#

again trying to send that video

frigid sequoia
#

Depeding it the ground is not even, something gets in between the raycast or you just have the raycast on the wrong object and it's shooting to infinity cause of animation

teal viper
# limber flower

Absolutely nothing is clear from that video.
Anywas, you should debug properly.

frigid sequoia
rough granite
# limber flower

could you send an updated paste bin of the code cause it looks like the raycast/grounded bool only returned true after the camera was facing nearly horizontal, though it was hard to tell cause 60% of the video was loading

frigid sequoia
#

Note how the rotation in Y is changing while u move?

#

Yeah, you are sending the raycast to random places

#

Not the ground

#

The rotation and scale of your root player should NEVER change

limber flower
#

!code

eternal falconBOT
limber flower
rough granite
frigid sequoia
#

It should always rotate inside a parent item that does not

limber flower
frigid sequoia
#

Cause then it does weird stuff

rough granite
limber flower
#

i will find it

#

Very fast tutorial to make an FPS character in Unity in less than a minute!

PasteBin link for code: https://pastebin.com/RXZ1dXgw
GitHub link: https://github.com/dustinmorman/FPSControllerTutorial

Link to my Upcoming Game - Survive the Uprising: https://store.steampowered.com/app/1984690/Survive_the_Uprising/

Link to the Discord - https://dis...

▶ Play video
rough granite
limber flower
#

the version in the pastebin is significantly modified from the one in the youtube video

limber flower
rough granite
#

idk thats what the tutorial told you to use

limber flower
#

i havent watched it since march

rough granite
#

never used one so i have no input on it

limber flower
#

what makes it a character controller instead of not that

rough granite
#

character controller is a script built in unity that does some extra things

acoustic belfry
#

Hi, i was analizing my melee attacks for, the player AND the enemy, (method is similar) for the animation events/update, yet i stumbled with the issue that, if is locked in one frame is too....odd, and if i put it for a lot of frames, it damages per frame wich is not the idea, so, how i can make my method of melee only trigger, when has already been triggered?

    {
        Vector2 MacheteRange = new Vector2(attackRange, attackRange);
        Collider2D hitEnemy = Physics2D.OverlapBox(meleePos.transform.position, MacheteRange, 0f, victim);
        if (hitEnemy != null)
        {
            if (hitEnemy.TryGetComponent(out ValeriaController enemy))
            {
                enemy.TakeDamage(meleeDamage);
            }
        }
    }```
limber flower
#

what is the alternative

limber flower
#

maybe it is

rough granite
# limber flower what is the alternative

well the problem with it is it sucks for slopes and doesn't use physics but it does have a built in ground detection that i think just uses collisions and not raycasts

limber flower
#

im just going to go to sleep and see if i can figure this out in the morning

rough granite
#

ay i get sleep yippee

eternal needle
acoustic belfry
#

just

#

what if i did this

    {
        if (ValeriaHasBeenhit) return;
        Vector2 MacheteRange = new Vector2(attackRange, attackRange);
        Collider2D hitEnemy = Physics2D.OverlapBox(meleePos.transform.position, MacheteRange, 0f, victim);
        if (hitEnemy != null)
        {
            if (hitEnemy.TryGetComponent(out ValeriaController enemy))
            {
                enemy.TakeDamage(meleeDamage);
                valeriaHasBeenHit = true;
            }
        }
    }```
#

what if i did this

#

and then

#
{
    ValeriaHasBeenHit = false;
}```

another event with this
#

it is a bad idea?

eternal needle
acoustic belfry
#

but i mean, the way i hit all my enemies is similar

#

cuz all my enemies share the same base

#

with the same health value

#

i just hit that script

#

and substract that value, until they die

#

atleast have worked till now

but now im wondering if is a good idea

eternal needle
#

it doesnt matter what it hits, ideally you wouldnt have different logic between the player and enemy in terms of how a melee hit works. The logic is the exact same, the only difference could be like checking what layer its on, or searching for a specific component, or reading a component value to know what "team" its on

acoustic belfry
#

it would just be

    {
        if (DemonHaveBeenHit) return;
        Vector2 MacheteRange = new Vector2(attackRange, attackRange);
        Collider2D hitEnemy = Physics2D.OverlapBox(meleePos.transform.position, MacheteRange, 0f, victim);
        if (hitEnemy != null)
        {
            if (hitEnemy.TryGetComponent(out EnemyBase enemy))
            {
                enemy.TakeDamage(meleeDamage);
                DemonHaveBeenHit = true;
            }
        }
    }```
acoustic belfry
#

...just slighty more complex

#

but my issue is

#

this, bool, return, thing. It is good?

eternal needle
#

so then if your player has the same logic, you suddenly can hit only one enemy

acoustic belfry
#

but i mean, my enemies use the same base

#

to wich it gets hurt

#

the hurt area is on the base

#

and the player detects the base

acoustic belfry
eternal needle
acoustic belfry
#

oh, holup, one?

#

i mean

acoustic belfry
#

but now, you may be refering to another thing

#

wich...i can't see

#

i mean, you mean, i use this method, and i touch 3 guys, three inherite from the same fella

#

what would happen?

eternal needle
# acoustic belfry i mean, you mean, i use this method, and i touch 3 guys, three inherite from the...

follow the logic line by line, follow it 3 times if you need. lets say some event calls your code to start performing melee attacks for X frames. first it resets so ValeriaHasBeenHit = false happens.
next meleeAttack is called. Lets just assume Physics2D.OverlapBox finds a Collider2D (this method also only returns one collider). You damage the target, valeriaHasBeenHit is set to true.
For all the next frames meleeAttack is called, ValeriaHasBeenhit is true, so you return.

acoustic belfry
#

ooooooooooooooooooooooooooooooooooooooooooooh, so the thing is, i should make the bool thing, work, on the Target, not on the attacker

#

makes sense

eternal needle
acoustic belfry
#

i want it to be hit once

#

until the method reset damage is set

#

mmm, it should better use a timer

#

yeah, a timer

eternal needle
#

Or just do it properly like i initially suggested and have a list of enemies that were already damaged

acoustic belfry
#

is...is actually..very simple, just check if the attack is melee, do the bool thing, and put a timer, if the timer goes zero, the bool returns to false and can keep get it ass kicked

#

oh right

#

the issue is...i dont know how

eternal needle
#

google how to make a list in c#. then how to add to a list. then how to check if something is in a list

acoustic belfry
#

ok

#

well, thanks

acoustic belfry
frigid sequoia
#

Can I like.... add a item to an ordered list on a specific possition instead of recalculating the whole sorting?

#

Like let's say inventory is ordered by descending item rarity. And I want to add an item I know the rarity of, can I not just tell the List to place it within the items of the same rarity as it comes in?

#

Like, sort this only item in particular and forget the rest of the list?

frigid sequoia
#

But that, like... has to be sorted still right?

#

Like, I can sort it by a bunch of values but I have to call it right?

eternal needle
#

if you want the items sorted then its gonna have to be sorted. Doing it yourself will likely just be worse compared to using built ins

#

there are data structures specifically for keeping objects sorted as they are inserted. you dont want to manually sort the list everytime

frigid sequoia
#

So if I do this, if I add an item with the same gearRarity it automatically gets sorted between the rest of the same rarity?

#

Like I would still have to call the list to sort it by gearRarity anyways right???

#

I mean, I can always do a list of lists and have a list of each rarity

eternal needle
# frigid sequoia So if I do this, if I add an item with the same gearRarity it automatically gets...

it would yes but you would need to implement a custom comparer on InventoryItem. Also you wouldnt be able to add the same item, if the comparer returns 0 then it'd probably error as well.
Maybe you could get away with just using List.Insert(index, item) to insert items at a specific position. You would just need to search through and compare the rarities.
Or realistically if the list is small enough you could sort it every time a value is inserted. Just implement a custom comparer on InventoryItem

acoustic belfry
eternal needle
#

the main thing you'd want to know is that it cant have duplicate elements, like a dictionary. you'd really have to be using a large list, a lot per frame, to ever notice a difference in performance between the two also

acoustic belfry
#

btw, this is how it should be?

{
    Vector2 MacheteRange = new Vector2(attackRange, attackRange);
    Collider2D[] hitEnemy = Physics2D.OverlapBoxAll(meleePos.position, MacheteRange, 0f, victim);

    foreach (Collider2D hit in hitEnemy)
    {
        if (hit != null && !alreadyHit.Contains(hit))
        {
            if (hit.TryGetComponent(out EnemyBase enemy))
            {
                enemy.TakeDamage(meleeDamage);
                alreadyHit.Add(hit);
            }
        }
    }
}```
acoustic belfry
#

i mean, for what i saw, in theory this analizes the list, then analizes each fella on it, and checks if has the hit

#

or atleast thats what i think i did

eternal needle
#

oops I pasted the 3rd declaration, didnt realize the physics 2d has one that takes a list and one that takes an array. The 3D physics overlap functions only take arrays 🤔

frigid sequoia
#

Hashset better for searching specific items very fast. List better for iterating over all the items

frigid sequoia
#

Searching for a specific index to insert it manually seems like even more costly in resources tbh.

#

I think Imma go for a list of lists, seems reasonable

acoustic belfry
#

makes sense

eternal needle
frigid sequoia
#

Mmmm, not really much different than to just get the rairty straight from the gear.gearRarity

#

Any advantage to using a dictinoray there?

eternal needle
frigid sequoia
#

I guess, but can also just add them in order so I know which is which without the need of an fixed index lol

eternal needle
frigid sequoia
#

My AddItem method would pass the whole item, then the rarity would be checked, being an enum that basically can be used as index for the list of lists, then I just add the incomming item to the relevant list which is the one with matching Index on the list of lists

sacred lake
frigid sequoia
#

So the thing you are likely to want to equip (aka, the better items show first)

eternal needle
frigid sequoia
frigid sequoia
# sacred lake Can you elaborate?

Ah... the ideal would be that inventory holds all the items that you can equip, once you click a slot, it shows everything that can go in that slot, ordered by rarity, you can them click to swap it with whatever you have equiped right now

#

There is not much to it, really

eternal needle
iron wing
#

how do i shorten a variable name?
at the moment, I have this:

var FOV = CinemachineCamera.Lens.FieldOfView;

but wont initializing it as "var" and then modifying FOV modify the variable indirectly? so i'd just be changing a copy?

eternal needle
#

yes right now you'd just be changing FOV, a float, which wont affect the lens field of view

drowsy flare
#

Can I change the size of a sprite in pixels?
(Something like transform.localScale.inpixels = )

#

Realized it doesn't need to be in pixels, I just want to change the width and height to a fixed one, like 1F, 1F

ivory bobcat
#

I'm still not sure what you're asking.

mystic hatch
#

Can somebody help me with this? I am new to coding and this code was working normal and now it keeps giving me this error. I didn't change anything. I have no idea whats going on.

silk night
silk night
ivory bobcat
mystic hatch
#

It's for detecting objects to pickup. I just don't know why it suddenly stopped working.

drowsy flare
ivory bobcat
iron wing
mystic hatch
ivory bobcat
# mystic hatch I have a video of it working.

Show where you've defined PickupDetector. Working or not working doesn't really matter. It's saying that you're trying to use the type PickupDetector but it doesn't know what that is.

eternal needle
wooden hill
#

note: it wont work on properties

rough sluice
#

Do someone know that why nothing is happening when I click any button?:

using UnityEngine;
using UnityEngine.SceneManagement;

public class MainMenuController : MonoBehaviour
{
    public void OnStartClicked()
    {
        Debug.Log("Start button clicked!");
        SceneManager.LoadScene("GameScene");
    }

    public void OnNothingClicked()
    {
        Debug.Log("Nothing button clicked!");
    }

    public void OnExitClicked()
    {
        Debug.Log("Exit button clicked!");
        Application.Quit();
    }
}
wooden hill
#

and i think you don't have an eventsystem

#

rightclick in hierarchy and add an event system

rough sluice
rough sluice
wooden hill
#

what do you not understand?

#

"oh what" isn't descriptive

rough sluice
wooden hill
#

the left of your scene window

#

look at it's tab what is it called

#

Hierarchy

#

where you modify your scene

#

just like how you make a new cube or a new button. rightclick inside there and create an eventsystem

eternal needle
past yarrow
#

Why do we normalize inputDirection 2 times please ?

faint sentinel
frail hawk
naive pawn
#

normalization is idempotent

eternal falconBOT
past yarrow
naive pawn
past yarrow
naive pawn
#

yeah, because it should be normalized...?

#

it's the first assignment that's unnecessary (and arguably a mistake - if the input is near zero you get a magnitude of 1)

past yarrow
errant zenith
#

hey

#

would anyone mind giving me a help over vc? I am getting a bug with the camera

slender nymph
eternal falconBOT
soft creek
silk night
verbal dome
#

It kinda does seem to avoid walls but the agent radius is smaller than the graphics of the character so part of it clips through the walls

red igloo
#

I had a break for 2 months and I've started again. I'm going to use the new input system using input action references (What I got so far https://paste.ofcode.org/JYGMuMHR5sxnBZTDw84ums) . In the image shown I would like to know how I could convert that into the new input system cause right now that's using the old input system. Help would be appreciated.

median hatch
#

is there any way of not having hiccupts when doing loadscene async

median hatch
naive pawn
sour fulcrum
naive pawn
median hatch
#

i divided my city into chunks

#

and whenever i enter a new area i want to unload the previous one

#

each area has entities and collectables and stuff

#

but yea the spikes are a bit crazy right now

red igloo
#

Would this be fine? well it works

naive pawn
#

sure

red igloo
#

Since im going to be adding controller support how can I make it so when your on controller and you slightly move the stick to move I want the player to move slowly

median hatch
#

next what you can do is add a blend tree

naive pawn
red igloo
polar acorn
#

Yeah, the difference is, ClampMagnitude prevents it from going over 1 magnitude, while normalize will set it to 1 magnitude

naive pawn
#

there's also a Vector2 version

polar acorn
#

If it's less than 1, ClampMagnitude won't affect it

naive pawn
sharp solar
silk night
sharp solar
#

if you were to move right and forward you would walk faster than just moving forward if you werent to normalise it

naive pawn
silk night
naive pawn
#

both in the original inputmanager code and the current inputsystem code, the horizontal/x axis is used to go forwards and backwards

rocky canyon
#

whats "back and forth" in this context?

naive pawn
rocky canyon
#
  • and - ?
round bobcat
#

How do I start with creating a video game?

naive pawn
#

!learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

silk night
eternal falconBOT
#

:teacher: Unity Learn ↗

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

rocky canyon
#

check the pins

sharp solar
silk night
sharp solar
#

most important thing is to not try and aimlessly learn stuff because you wont get anywhere

rocky canyon
#

^ if u have questions or get confused just ask

#

goals r guud

rocky canyon
red igloo
#

I got it working! Vector2 input = Vector2.ClampMagnitude(currentInput, 1f);

sharp solar
#

whats the difference between vector2 and float2 fellas

silk night
#

More utility functions on vector2

naive pawn
#

Vector2 is from UnityEngine, float2 is from Unity.Mathematics

frail hawk
#

very well explained

naive pawn
#

they're from different systems

sharp solar
#

is a buffer just a line of bits

naive pawn
#

no, "buffer" is a really broad term

sharp solar
#

shader buffer then

#

in unity

#

sorry

#

computebuffer i mean

naive pawn
#

a buffer at its core is just a chunk of data you can read and write into
more specific buffers will have more specific data and perhaps more specific constraints

prime tartan
#

how can i rotate my plane which has forward x velocity in 2d to 45 and -45 angle based on if my mouse if at top or at down

frail hawk
#

you asked 5 questions at the same time mate

sharp solar
#

i recommend asking the question 1 part at a time

#

yea like what murado said

prime tartan
#

wdym

naive pawn
#

what does "if at top or at down" even mean

naive pawn
sharp solar
#

and linear fading

prime tartan
#

i want to rotate my plane 45 to -45 degrees on x based on mouse y at top or bottom of the screen

naive pawn
#

does this have anything to do with velocity?

prime tartan
#

if at top -45 bottom 45

#

like i want a rotation of that type so that the degree of rotation is where my plane would move forward

#

not directly related

naive pawn
#

break the task down into sections

  • get the mouse position in viewport space
  • map that to angles
  • apply the angles to the plane
prime tartan
#

ok

#

now what functions do i use

#

to co-relate them

frail hawk
#

the heck

naive pawn
#

don't spoonfeed please

sharp solar
#

im just saying this is a fairly simple task and chat gpt could probably explain the entire thing to you

silk night
frail hawk
#

the code had a few mistakes, it wasnt even rotating on x

silk night
naive pawn
#

also do clamping if you want to ignore the mouse being outside the viewport

silk night
sharp solar
naive pawn
#

then why did you do it?

frail hawk
#

haha

silk night
#

Treat chatgpt as if you have a 50% chance it flat out lies to you and if you dont think you could identify the lies, dont use it yet to help you out

naive pawn
#

50% is generous lol

silk night
#

copilot is actually doing a fair job at completing thoughts though, chatgpt is mostly hallucinating when it comes to unity 😄

errant zenith
#

forsome reason

naive pawn
#

share !code

eternal falconBOT
prime tartan
#

i can get the x position using Input.Horizontal in a var and change the rotation using quaternion euler but am just asking what math function could get me to co-relate them if am asking too much sry but i have tried for like an hour cant find the fuction and chatgpt script isnt working

naive pawn
#

Input.Horizontal isn't a thing
if you mean the axis, well, that'd be delta, not the absolute position

silk night
naive pawn
#

also you'd want the y position

prime tartan
#

input.getaxis bro

sharp solar
# naive pawn then why did you do it?

programmers dont like AI
what a surprise
the idea behind asking chat gpt stuff is it gives you terminology and concepts to further ask about instead of getting someone to tediously walk you through how to make a plane fly for your game (like you are doing now)
it's a great tool as long as youre able to use your brain

naive pawn
prime tartan
prime tartan
#

i thought input.getaxis could do

polar acorn
#

Input.GetAxis gets you the value of that input axis at that frame

prime tartan
#

oo

polar acorn
#

Input.GetAxis("Horizontal") will give you whatever value along the input's X-axis it's at right now, from -1 to 1

naive pawn
#

i don't care if you use AI

prime tartan
#

ops bro

#

i forgot that i wrote horizontal

naive pawn
#

just don't push it on beginners and don't come crying when it doesn't work

prime tartan
#

ik thats wrong but wasnt there a MouseY input too?

silk night
#

Vertical

naive pawn
#

yeah, that's delta position, isn't it

naive pawn
prime tartan
#

now whats a delta bro 💀 what have i been doing the whole time

sharp solar
#

delta is the difference between 2 numbers

polar acorn
sharp solar
#

math concept

prime tartan
#

then input.mouseposition.y?

#

gemini told

sharp solar
#

delta can quite literally be interpreted as "difference"

naive pawn
#

start using google and docs instead of that

prime tartan
#

i searched on google

#

thats the first result showed

#

rn

#

so i asked

naive pawn
#

yeah because google is pushing their ai

#

click the linked source or scroll down to actual docs where there are primary sources

sharp solar
#

@naive pawn i see your point bro but i promise you its cause this guy is funny

naive pawn
#

what are you talking about

prime tartan
#

me?

naive pawn
#

no

prime tartan
#

bro i am not experienced even to a bit

silk night
prime tartan
#

thats like my 2nd project in unity

#

ok

frail hawk
eternal falconBOT
#

:teacher: Unity Learn ↗

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

frail hawk
#

ai won´t take you anywhere rn

sharp solar
#

is it more common to set public variables in scene editor or get script to find stuff in scene at runtime

naive pawn
#

"variables" is an insanely broad ask

sharp solar
#

cant lie i kinda hate dragging objects into public variables

#

it annoys me

sharp solar
silk night
hexed terrace
# sharp solar variables

Those are called 'fields'.

Fields should pretty much never be public. SerliazeField private fields to display them in the inspector.

naive pawn
# sharp solar variables

those are serialized variables
there are several other uses of variables where your question doesn't even make sense

#

just do what works for you

#

the recommendation is to use SerializeField'd fields but at a beginner level it doesn't really matter imo

frail hawk
#

and don´t call your script Random

polar acorn
#

If you can set a field in the inspector, you probably should set it in the inspector. Every other method of assigning a variable has an overhead cost, but assigning it in the editor is free, it just gets created with those values already set

hexed terrace
#

no reason not to learn good practices early

sharp solar
naive pawn
naive pawn
sharp solar
#

actually though where the hell do i rename the component

#

its been bothering me

sharp solar
#

ignore the folder they are in for a sec, the script is not called random, that was the original name

#

ive reloaded this project like 5 times now and the component name doesnt update

naive pawn
#

the file isn't called random, but the component is

#

you have a class Random : MonoBehaviour in there

sharp solar
#

ahhhh

#

cheers

#

i didnt realise the class was called that lol, 100% see the issue now

naive pawn
#

kind of an unfortunate naming thing

#

the class and file are separate entities, but "script" can refer to either depending on context

#

(only in unity/this kind of context though afaik, normally we don't call classes as scripts)

near junco
#

Hello
I've been struggling a bit with Enums, I tried to search for answer but never got one that worked for me so I'm trying here hope this is the right channel

I have a scriptable object, that old an enum where the value can be selected in the inspector
in another scripts I'm trying to get this "selected value" to, then, start a switch statement depending on said "selected value" (integer)

I can't find a way to solve this, am I missing some basic understanding of enum ?

sharp solar
#

we dont have native class support in luau so this is all new to me

sour fulcrum
frail hawk
# sharp solar ahhhh

just trying to help you so you don´t get confused later that is why i said that you should be careful with the naming. quick tip: if you rename your class inside your IDE unity will also rename the file inside unity (at least with vs2022)

naive pawn
sharp solar
naive pawn
sour fulcrum
#

trueing

sharp solar
#

does monobehaviour tell unity that this is the class we want this component script to be

hexed terrace
silk night
polar acorn
near junco
sharp solar
#

oh so class : class is an inheritance thing?

frail hawk
#

yep

grand snow
sharp solar
#

epic

polar acorn
sour fulcrum
hexed terrace
#

do you still not need public there to expose the property to other classes?

#

[field: SerializeField] public MyType MyName { get; private set; }

naive pawn
#

but like, you don't always do that

hexed terrace
#

well yeah, only if you want it exposed

polar acorn
#

A private property with no implemented getter or setter seems like it should just be a field, honestly

sour fulcrum
#

could be protected 😄

naive pawn
#

or internal 😏

polar acorn
sharp solar
#

what is an assembly when it comes to this internal keyword stuff

#

is that sort of like the stack of classes

naive pawn
#

it's basically just a group of files that form a self-contained unit

#

don't worry about it at this stage

polar acorn
near junco
# grand snow Same as any field, you read it from the instance

What I don't understand is that Enums seem to be Types
which doesn't allow me to get value from the enum when I'm trying to pass it to a variable in another scripts
Then how do I get the value of my enum If I can't pass it into another variable ?

grand snow
polar acorn
naive pawn
#

an enum type is just a set of names for a set of ints

polar acorn
#

Yeah, you make a variable of type int with a value of 0. You don't make a variable of type 0

red igloo
#

Is this how you do a boxcast? just wanted to know if I did it right and it does work.

naive pawn
#

no errors, so yeah?

#

might not do what you want it to do if you pass args in the wrong order

#

this kind of question is what docs are for

polar acorn
naive pawn
#

probably shouldn't hardcode boxSize though

rough granite
polar acorn
rough granite
polar acorn
naive pawn
rough granite
polar acorn
naive pawn
#

the field: means to apply the attribute to the automatic backing field

polar acorn
#

Change the value to a thing

#

By setting I mean setting

rough granite
polar acorn
#

You cannot set a propery in the inspector without [field: SerializeField], even if it's public

rough granite
#

Huh

burnt flare
#

for this kind of terrain how should I proceed to reduce lag ?

naive pawn
# rough granite Huh
+                  public Type field;              // works
+        [SerializeField] Type field;              // works
-                  public Type prop { get; set; }  // doesn't work
-        [SerializeField] Type prop { get; set; }  // doesn't work
+ [field: SerializeField] Type prop { get; set; }  // works
#

(please don't format your code like this, i'm just doing it to compare)

rough granite
naive pawn
#

it's called a property

rough granite
naive pawn
#

a getter is a specific component of a property

wooden hill
#

wait what's the difference between the last two even? what does adding field: do the other one doesn't?

naive pawn
#

it makes it work

#

SerializeField works on fields

#

field: before the annotation means to apply the annotation to the backing field
without it, the annotation is applied to the property

polar acorn
naive pawn
#

without automatic backing fields, it'd look something like this

[SerializeField] Type m_Field;
Type prop { get => m_Field; set => m_Field = value; }
#

but with an automatic backing field, you can't see the supposed m_Field, so that's what the field keyword does

#

the field keyword also works in the accessors, but not in unity's version of c#, iirc?

wooden hill
#

i see.. yeah

#

is the serializedfield of the autoprop then named (in inspector for example) the same as the prop?

naive pawn
#

probably?

grand snow
naive pawn
#

props are just methods that act like fields, if you cause an error in them the stacktrace shows a get_name/set_name method, so i guess the field would be something along those lines

wooden hill
night raptor
burnt flare
#

I wanna achieve this

grand snow
#

You probably need to use chunks like minecraft to better manage collision and the mesh drawing

burnt flare
#

didnt know there was another layer of optimisation

polar acorn
#

Instancing helps, but it's not a silver bullet

grand snow
#

yea its not good enough for this many meshes

night raptor
#

Should look up how minecraft does it

burnt flare
#

so the idea would be to make cut the terrain by chunks and merge them as one mesh

polar acorn
#

Despite what Minecraft's aesthetic might make you think, a fully voxelized terrain made of cubes is stupidly difficult and incredibly performance intensive

grand snow
#

yea its one method, it helps with collision and culling but how the chunk itself needs to avoid a gameobject + mesh renderer per block.

burnt flare
#

ill look into minecraft but I think its harder to achieve

grand snow
plucky tinsel
#

why does this set all line renderer positions to the exact same position ?

grand snow
plucky tinsel
#

damn it, not again

#

thank you

grand snow
#

haha yea its a common issue that trips me up still

sharp mirage
#

anyone know why im getting this? the issue has to do with the wall touch part

polar acorn
sharp mirage
#

its the wall touch part

#

which is a raycast hit 2d

polar acorn
#

If this is the line the error is on, either playerAttributes, WallTouched, or WallTouched.WallTouch is null

sharp mirage
#

its defo either wall touched or walltouched.walltouch

polar acorn
#

So use some debug logs and find out which

sharp mirage
#

when i do find out which is null what do i do from there

polar acorn
#

Make it not be null

sharp mirage
#

how

#

sry if that sounds dumb

polar acorn
#

or check for it being null before you try to use a property of it

polar acorn
# sharp mirage how

If it is supposed to sometimes be null: Check that it's not null before you try to use it.
If it is not supposed to sometimes be null: Give it a value

sharp mirage
#

ok

near junco
# polar acorn They _are_ types. You make a variable of the enum's type and you can set that va...

Yeah no I already knew that I just explained my problem like an idiot sorry
I know enum is the type, what I wanted to say is that I can't find a way to access the data of my enum variable cause VS Code keep telling me that my enum variable is a type, which is not valid in the current context

I'm just trying to get the selected value of my scriptable object instance , like I have a toolClass scriptable Object, which contain a ToolType enum, and in an other script I want to get the enum result of the Scriptable Object instance Sword (_itemReference) which inherit from toolClass

but I don't know how to do it
the solution that gave rob5300 don't seem to do the job since I want the value of the enum to be set by the scriptable object instance when user select the setting in the inspector,

maybe what I'm trying to do is not for what enum is and I'm just lacking basic understanding on how to achive my goal

polar acorn
#

not the ToolType enum itself

naive pawn
#

right you're still conflating the type and a value of said type

#

right now you're basically doing switch (int), that doesn't make any sense

#

wait hold on

#

the enum is ToolClass.ToolType...?

#

or what

#

what's the variable you're trying to read here

polar acorn
#

Looks like _itemReference is a variable of type ToolClass, and ToolClass contains an enum named ToolType

#

You wouldn't switch on the type, you'd want your ToolClass to have a variable of type ToolType

naive pawn
polar acorn
#

The enum can be defined anywhere

polar acorn
naive pawn
#

oh, ofc. i assumed the error was just about it being a type

polar acorn
#

It's probably got multiple errors. I don't know which one would take "priority" over the other

naive pawn
polar acorn
#

and I don't know if the compiler can show multiple errors on the same token

near junco
naive pawn
#

that doesn't answer my question

polar acorn
slender nymph
#

what variable in the ToolClass class is of type ToolType that you are trying to read for the switch

naive pawn
#

ToolClass seems to have a serialized field of type ToolType. what's that field called

#

something like toolType?

near junco
#

I keep trying to access the wrong stuff

naive pawn
#

no, you're inexperienced

#

we can't fix dumb, but we can definitely help fix inexperienced

near junco
#

I already declared my enum and I forgot about it

polar acorn
naive pawn
#

(btw, convention is to name enum members as PascalCase as well)

near junco
#

I'm sorry I wasted your time this was such a small problem from me

near junco
#

but VS Code keep telling me to do Uppercase, it takes time to kill old habit

wooden hill
#

you'll get used to it eventually don't have to excuse yourself here

naive pawn
naive pawn
wooden hill
#

it's a convention, you are not required to do it (at least in your own hobby projects) BUT since everyone tries to adhere to these it makes it easier for everyone to read and just feel smooth ya know?

naive pawn
#

the most important thing in style is to stay self-consistent

grand snow
#

the worst naming convention is m_ 🤮

wooden hill
#

can't check rn but when you set enums in inspector are they saved as int?

naive pawn
#

yeah

#

serialized according to the backing value

wooden hill
#

oh so you cant insert any infront

naive pawn
#

just gotta move everything else over

wooden hill
grand snow
#

we have modern ide's so we dont need to name things like this anymore

#

Unreal still do it with their class names like AActor 😐

wooden hill
#

oh

polar acorn
wooden hill
#

i think android/google had mVariableName

#

probably thought of that

wooden hill
#

it should be AnActor

#

🙂

naive pawn
#

probably not a great idea, but doable

polar acorn
wooden hill
wooden hill
subtle wyvern
#

there are in this server channel for helping like i publish a post and then you triyng to help me
sorry about the english

frail hawk
#

yes you can create a thread

subtle wyvern
naive pawn
#

if you need help, first step is to !ask

eternal falconBOT
proper cloud
#

Hello people,

I am trying to drag a UI image:

    public void OnPointerDown(PointerEventData pointerEventData)
    {
        dragStart = getMousePosition();
    }
    public void OnPointerMove(PointerEventData pointerEventData)
    {
        if(dragStart != Vector3.zero)
        {
            Vector3 mousePos = getMousePosition();
            if (isDragging)
            {
                transform.position = mousePos;
            }
            else if (dragStartDistance <= Vector3.Distance(dragStart, mousePos))
            {
                isDragging = true;
            }
        }
    }

Dragging too fast unfortunately causes the mouse to loose the ui-image, which stops the "OnPointerMove" from getting called.
any solutions to this, or am I forced to move the drag-logic into an Update method?

Setting the position directly should be as fast as it gets, and unfortunately trying to snap the transform back in the "OnPointerExit" didnt fix the issue.

Thanks for any help!

grand snow
proper cloud
grand snow
#

yay

past yarrow
hybrid wagon
#

I cant get proper highlighting to work in .compute and .hlsl files

#

it works fine in .cs files

#

i checked the settings, error highlighting and squiggles are on for both

#

it just looks like this

#

better than plaintext but not that much better

slow idol
#

when i instantiate a clone of an object, it no longer collides with anything

hybrid wagon
slow idol
#

it looks the exact same as the original object

hybrid wagon
#

including the rigidbody and collider components?

slow idol
#

yes

hybrid wagon
#

send a picture

slow idol
#

wait no hang on

eager elm
#

If I have three events, OnMovedLeft, OnMovedRight and OnMoved and I want to invoke OnMoved every time one of the others got called, is there a fancy way to "link" them?

hybrid wagon
#

var OnMovedLeft(...) {
OnMoved();
}

eternal needle
eager elm
#

ah damn didn't know that works

#

I thought I can do OnMovedLeft += OnMoved;
but that doesn't seem to work, although it gives no errors

#

I guess it just adds any subscribers from one event to the other

eternal needle
#

right now yea you are adding the events, and i suspect OnMoved has nothing subscribed to it at that point

slow idol
#

it seems like it's not transferring a variable

#

the clone doesn't have the same layermask

sour fulcrum
#

🤔

#

Not saying your wrong but doesn’t sound like the kind of thing that can happen afaik

slow idol
#

well

#

i have an exact clone

#

and this ((layers & (1 << otherCollider.gameObject.layer)) != 0)

#

works for the original

#

but not for the clone

sour fulcrum
#

Not to nitpick your troubleshooting but your assuming the layermasks are different when so far what you've seemingly confirmed is that they inconsistently pass that condition

#

You should directly log both's layermask values in order to confirm said assumption

slow idol
#

yeah, the last debug log returns false

sour fulcrum
#

no as in

#

Debug.Log("Original LayerMask Is: " + gameObject.GetComponent<Projectile>().GetLayerMask())
Debug.Log("Clone LayerMask Is: " + clone.GetComponent<Projectile>().GetLayerMask())

polar acorn
#

It'll give you the layer mask as an int, but you can at least see if they're equal

slow idol
#

im actually gonna fucking lose it, i broke it in a different way

sour fulcrum
#

😄

sour fulcrum
# slow idol yeah, the last debug log returns false

Just in general make sure to directly test/log the thing your troubleshooting so you don't invest in a false assumption

this debug log here is unideal because who knows what layers is, your assuming the clone is wrong because this failed rather than directly checking

slow idol
#

they're different

#

why tf

#

bruh are we fr

polar acorn
#

What does GetLayerMask() do?

#

Where is it getting that data from?

slow idol
#

simplest function possible

polar acorn
# slow idol

Okay, so what sets layers? It's private, where does it get set to anything?

slow idol
#

big function called Set()

polar acorn
slow idol