#💻┃code-beginner

1 messages · Page 789 of 1

naive pawn
#

see the graphs in the wronglerp article i linked for examples

ancient nimbus
naive pawn
#

what's the error

#

note that that method is intended to be put somewhere in your codebase and then called instead of a wronglerp call, rather than being pasted in wherever the wronglerp is

ancient nimbus
# naive pawn what's the error

i have remade it and now it's on this line actually, sorry:

PlayerRigidBody.MoveRotation(Mathf.LerpAngle(PlayerRigidBody.rotation, FlapRotation, 1 - Mathf.Exp(-FlapRotationLerpSpeed * Time.deltaTime));

ivory bobcat
#

You should probably just use move towards as suggested at the end

naive pawn
#

also, is this in Update or FixedUpdate

nocturne kayak
verbal dome
#

Parenthesis mismatch

nocturne kayak
naive pawn
#

lerp is just a math function

#

you can use it wherever you need the math that lerp is

nocturne kayak
#

Yes

ivory bobcat
naive pawn
#

also, for future reference @nocturne kayak 👇

#

!code

radiant voidBOT
nocturne kayak
ivory bobcat
#

Imo, unless you care about the state of the t value (for reversal or to be specifically at any one point between the two points) smooth damp and move towards can probably do the same with less setup.

nocturne kayak
tulip gust
#

is there any way to make this blue gun sprite align perfectly?

ancient nimbus
#

Assets\Scripts\BirdScript.cs(34,26): error CS8112: Local function 'ExponentialDecay(float, float, float, float)' must declare a body because it is not marked 'static extern'.

wintry quarry
tulip gust
wintry quarry
#

doesn't sound like a code problem

tulip gust
#

true

#

which channel is better to ask this in

#

unity's UI is honestly my biggest opp so far

verbal dome
#

Or at least your previous code was

#

This looks like a different error, show code

ancient nimbus
#
            PlayerRigidBody.MoveRotation(Mathf.LerpAngle(PlayerRigidBody.rotation, FlapRotation, 1 - Mathf.Exp(-FlapRotationLerpSpeed * Time.deltaTime)));```
#

here yea go

verbal dome
#

You are clearly lacking C# basics

ancient nimbus
#

this is the code beginner channel

verbal dome
#

So you see this on the page:

ancient nimbus
#

of course there's gonna be beginners mate

verbal dome
#

I didn't mean to sound like an asshole

#

You'd basically copy that into your class

ancient nimbus
verbal dome
#

And then inside your method you'd call PlayerRigidBody.MoveRotation(ExponentialDecay(PlayerRigidBody.rotation, FlapRotation, FlapRotationLerpSpeed, Time.deltaTime));

#

Or something like that

verbal dome
#

So: cs static float ExponentialDecay(...) { ... } void Update() { PlayerRigidBody.MoveRotation(...) }

#

What's going on here is that you declare a helper method ExponentialDecay and then call that from your Update

#

You could just skip the helper method and do it inline (like in your previous code) but this is more readable

ancient nimbus
#

i see

naive pawn
#

ah you already got answers

verbal swift
#

Im looking at some code wtf does a ? mean in c# 😭

#

Ive never seen that b4

#

I have never in my life seen a ?

naive pawn
#

it's called a ternary, but just googling "question mark c#" should bring that up

verbal swift
#

Have you tried answering questions if ur gonna sit in this channel 25/8

naive pawn
#

second result, for me

naive pawn
#

i know what it is

#

but i'm trying to tell you that there's a more effective way to get the answer you want

#

have you heard about the "teach a man to fish" analogy

slender nymph
#

researching your issue/question with google is also something you need to do before asking here, per the server rules #🌱┃start-here

naive pawn
#

i could give you the answer here, and then do the same when you come back to ask about other relatively basic/straightforward things
or, i could tell you that google is more than capable of answering questions like that, and save both you and me a lot of time for future questions

edgy tangle
#

Knowing how to use search engines and documentation to find information about the solution to your problem is a very real part of doing professional coding. Can’t just always rely on people to help you.

shell sorrel
#

been programming most of my life, literally most of my time is not spent writing code, its reading docs and books and papers

exotic flicker
#

!learn

radiant voidBOT
half oar
#

I got at quick question.

naive pawn
#

!ask

radiant voidBOT
# naive pawn !ask

:thinking: Asking Questions

:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #🔎┃find-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.

-# For more posting guidelines, go to #🌱┃start-here

naive pawn
#

we can't answer if we don't know what it is 😉

half oar
#

sry had to go for a sec while writing. So anyways, i have ver. 6.3 of the editor rn, and i wanna do create with code, which uses 6.0. Now my question is, if i should download 6.0 extra for this, or if i should stick with 6.3. Does it even make that much of a diff?

naive pawn
#

for relatively simple tutorials like that, there shouldn't be enough of a difference to matter

half oar
#

okay, thanks Chris

fervent skiff
#

If I register callback on button during awake, how can I pass dynamic data that I will provide later? For example I want to change image and text on different element when I hover over a button

naive pawn
#

you could have a closure, in essence

#

presumably the thing registering the callback would know what it wants the callback to do, right?
you can use variables from the class inside the callback

wintry quarry
#

e.g.

Sprite mySprite;
string myText;

void MyCallback() {
  otherImage.sprite = mySprite;
  otherText.text = myText;
}```
fervent skiff
#

I really wanted to avoid doing it through variables 😄 But thanks

slender nymph
#

with UnityEvents on buttons you don't really have much choice

wintry quarry
#

There's not really any other way to store data in a C# program. Anything else (like a closure) is ultimately just a variable wearing a trenchcoat

shell sorrel
#

if you are registering via code i would just not use unity event

#

also you still can pass dynamic params though unity event

#

just make it a concrete class first then use that

fervent skiff
#

UI is really driving me mad

grand snow
shell sorrel
#

otherwise i would just sub with a function that already has ref to what you need, or make a closure to do it

naive pawn
#

yes, c# is a c-style language

#

it pulls a lot of syntax from c

visual junco
#

I'm currently following a tutorial for player movement and rotation, why does rb.velocity show up like this

#

is the tutorial outdated

viral warren
#

rb.velocity only works for the version below 6, in the latest version it is changed to rb.linearvelocity

solar hill
#

your editor should also tell you this im pretty sure

visual junco
solar hill
#

yes

viral warren
#

yes it's the same

wintry quarry
visual junco
#

Ok

#

thx

frosty yarrow
#

!ide

radiant voidBOT
gilded cypress
#

guys can someone fix a script for me im new to unity

naive pawn
#

you have 2 classes called NameScript

gilded cypress
#

yeah i know i tryed chatgpt to fix the scrip it just gave me 15 new errors

naive pawn
#

consider not doing that

solar hill
#

didnt you also have this same issue yesterday?

naive pawn
#

just name them properly

gilded cypress
#

yeah

solar hill
#

and it was clear you are missing some basic fundamentals of c# and unity

naive pawn
#

open the file, change the class name to what it should be, save

solar hill
#

and everyone recommended you watch some tutorials

#

rather than asking for help with very basic issues

gilded cypress
#

i didnt know what you ment

#

i did try to watch some

solar hill
gilded cypress
#

yeah i watched that

solar hill
#

you want people to fix your issues for you rather than actually learning, this isnt the channel or server for that

naive pawn
gilded cypress
#

i did try to fix it i couldnt do it i ask chatgpt and he gave me 15 new errors just like i siad

naive pawn
#

yeah, don't

#

chatgpt is not a replacement for thinking

#

chatgpt just won't really help you at this stage in learning

#

you gotta do things yourself

#

put some thought into it

#

yikes

#

aight

solar hill
#

then... dont be

gilded cypress
#

huh

naive pawn
#

good luck with.. existing on discord

solar hill
#

see you in a year ig lol

naive pawn
#

aaaand there goes your account

gilded cypress
#

what..

#

im cooked

solar hill
#

yeah rip to your acc, if you so much as say "im age" even out of context the discord auto detection will actually block your account

naive pawn
#

to be blunt, you clearly don't have the maturity to interact in online spaces safely and productively

solar hill
#

also this

#

perhaps consider discord 13+ rating is there for a reason

naive pawn
#

also google 13+ restriction, facebook 13+ restriction, etc...

solar hill
#

you are way too young to be given unsupervised internet access especially on a social platform like discord

gilded cypress
#

yeah

solar hill
#

there is a reason for this and you arent rebelious or cool because you choose to avoid them, you are only putting yourself in actual danger

naive pawn
#

though keep in mind that turning 13 does not automatically give you that maturity

solar hill
#

also this, in fact im of the belief all social medias including discord should not be acessible to children under the age of 16

#

from my own experience being a dumb 15 year old on discord almost a decade ago

naive pawn
#

i recommend to just stop relying on chatgpt to think for you. maybe consider stop using it altogether, and same with any other genAI/LLM stuff. start thinking and learning for yourself.

solar hill
#

also yeah youre 12 and already relying on chatgpt to solve these kinds of issues..... this next gen might actually be cooked

#

where is Meina gladstone when you need her

teal viper
#

Why you guys bullying a deleted account? 😬

solar hill
#

oh i guess they did actually get their account banned on discord bruh

naive pawn
#

no way

solar hill
#

they have an automatic filter if you so much as insinuate you are under 13 years old

#

not even in that context

#

you litterally cant say "im number" in any context because the filter can just delete the account

naive pawn
#

reminds me of that "i'm [int] and my gf is [int] \n\n are our levels too far apart?"

teal viper
#

Maybe they deleted it themselves when realized they're breaking the rules? Have some faith in humanity.

rustic moat
#

That would have been abnormally quick for a discord ban

raven perch
#

I'm starting to get into some procedural generation and was looking for some high level advice. I'm likely just going to start with BSP and work my way through some other popular algorithms. Does anyone have any experienced advice on data storage strategies to go with (such as lists, dictionaries, primitive arrays?)

#

For instance, ive seen some tips out there were people stored the generated maps in both arrays and in hashsets, one used for rendering and one used for pathfinding. I'm just getting caught in the nuance of learning what data structures I want to go with.

teal viper
raven perch
#

I still ahve to figure out how I want to preview generated maps too. I'd been just writing my own pixel data to a material but I thought perhaps unitys tilemap would be an interesting way to preview generated maps before i build a level out of the map data.

teal viper
wintry panther
#

i want to make a cube look like a 6 sided die

#

and i want to use pixel art for the texture

#

how would i do that? could i make one sprite with all sides of the die, then use that as a texture?

#

if so, how would i set that sprite up?

rich adder
wintry dew
#

How could i make an object be in two layers? I need it to be in Ground for player collisions, however i also need it in EditorObject for being detected by the editor camera, and making the box collider "include" the layer doesnt detect the raycast.

wintry dew
#

is there an analogous fix to that

rustic moat
# wintry panther i want to make a cube look like a 6 sided die

There's a few ways to do this. The simplest way is just model a die in blender and make it look like pixel art in the sides and just use that.

You can also make a texture for each side in any drawing tool and import each 2d texture in. Then make an object that is just a cube with texture renderers on each side with the texture you made set to them.
If you want more info you should go to the art chnnels

sour fulcrum
#

why does it need to be editorobject to be detected by the editorcamera

naive pawn
sour fulcrum
#

(if your trying to ignore stuff in a camera usually people have a dedicated hidden layer)

wintry dew
sour fulcrum
#

i don't understand

raven perch
#

could you use a tag for ground?

sour fulcrum
#

layer for ground is fairly common

wintry dew
#

im already using tags for other things and that wouldnt be consistent

rich adder
#

being detected by the editor camera

#

explain this better

wintry dew
#

the camera raycasts to the editorObject layer

#

so it can detect those

sour fulcrum
#

why

wintry dew
#

when im in for example play mode, do i manually switch the layers of the objects?

rich adder
#

why not just give it the ground layer

#

you could technically make a script for editor and switch it up

sour fulcrum
#

Generally (and ideally) nothing in your build scene/code should be composed for specific editor related code (one big exception is OnDrawGizmos though)

wintry dew
# rich adder why not just give it the ground layer

Well there would be some objects that in the editor should not collide with the player, so i wouldnt want them to be ground, but all should be detectable through the script i wrote that raycasts EditorObjects

wintry dew
sour fulcrum
#

That makes a lot more sense ok

wintry dew
#

yeah sorry for the confusion

sour fulcrum
#

When you say Editor people are going to assume Unity Editor

wintry dew
#

yeah i forgot about that one

#

well does this mean i have to manually change layers when switching to playtest mode?

sour fulcrum
#

I don't recall if you were the other person doing this kind of thing last month or not but generally making a editor in unity is a big design pain because of issues like this

#

as your trying to re-create editor behaviour but using editor behaviour will overlap

wintry dew
#

nah i havent discussed this here yet

wintry dew
#

i actualy have mine working pretty well so far but switching to playtest mode is whats currently tricky

#

so i give each object like an OnPlaytest method that runs when the event for switching to playtest mode is called?

rich adder
#

is this going to be a game or what? whats the purpose of this

sour fulcrum
#

Offtopic but just a heads up if you haven't ran into it, you can't make new Tags at runtime

wintry dew
#

well yeah i have the game just making an editor for it for the players, along with for me personally making additional levels

wintry dew
#

i might as well just give it some guid

rich adder
#

no, join a jam

naive pawn
#

!collab

radiant voidBOT
# naive pawn !collab

:loudspeaker: Collaborating and Job Posting

We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
• ** Collaboration & Jobs**

pure scaffold
#

Oh sorry

sour fulcrum
#

So just two cents for this editor thing, less a direct solution but just general vibe that might lead you to one

Try and avoid tag usage as much as possible since they are rigid at runtime, just use components and trygetcomponents instead
Generally honestly try and avoid layer usage as much as possible since you run into this double purpose issue, especially try and avoid editor related usage if you can

Swapping layers at runtime before and after you do specific things is probably a solid route but for other non raycast related things I'd also look into this as a solution tool:
https://docs.unity3d.com/6000.3/Documentation/ScriptReference/Physics.IgnoreCollision.html https://docs.unity3d.com/6000.3/Documentation/ScriptReference/Physics.IgnoreLayerCollision.html

You can specifically ignore collisions between two colliders and between two layers. Since your likely spawning everything via code you should have easy enough access to these kinda references

#

Good thing about making a runtime editor is generally you probably have way more room to do cursed shit performance wise

wintry dew
#

I guess id just store a variable that says if something should be ignored in collisions at runtime or something if i need to

gentle trellis
#

does anyone have a shader for 2d sprite that reacts with 3d environment? (3d lighting, cast shadows etc

verbal dome
#

With a basic lit shader

gentle trellis
#

is using meshrenderer extra work

verbal dome
#

Im not sure what would be the most straightforward way of animating it for example

gentle trellis
#

oh wait what

#

I thought I was in unity talk channel

#

okay thanks

sour cape
#

is there anywhere to discuss dots ? in real time

#

its blowing my tiny mind

sour cape
#

thanks! i couldnt find that somehow

ashen harness
#

!code

radiant voidBOT
ashen harness
#
using UnityEngine;

public class ProjectileDamage : MonoBehaviour
{
    // The damage that the projectile will deal on impact
    public int damage = 20;


    void Start()
    {
        // Destroy the projectile after 5 seconds if it doesn't hit anything
        Destroy(gameObject, 5f);
    }



    public void OnTriggerEnter(Collider other)
    {
        // Check if the object we collided with has a Health component
        Health health = other.GetComponent<Health>();
        if (health != null)
        {
            // Deal damage to the health component
            health.TakeDamage(damage);

            // Destroy the projectile after hitting the target
            Destroy(gameObject);
        }
    }
}
#
using UnityEngine;

public class Health : MonoBehaviour
{
    public int maxHealth = 100;
    public int currentHealth;
    public Component Player;
    //Player only reference
    public HealthBar healthBar;
    public GameObject uiPanel;
    private bool isUIVisible = false;

    void Start()
    {
        currentHealth = maxHealth;
        //Remove line below if it's not a player
        healthBar.SetMaxHealth(maxHealth);

        if (uiPanel != null)
        {
            uiPanel.SetActive(isUIVisible);
        }
    }

    void Update()
    {
        if (Input.GetKeyDown(KeyCode.V))
        {
            TakeDamage(20);
        }

    }

    public void TakeDamage(int damage)
    {

                if (currentHealth <= 0)
        {
            Destroy(Player);
            
            ToggleUI();
            
            
        }

        currentHealth -= damage;

        //Remove line below if it's not a player
        healthBar.SetHealth(currentHealth);
    }

    public void ToggleUI()
    {
        // If the UI panel reference is valid
        if (uiPanel != null)
        {
            // Reverse the current visibility state
            isUIVisible = !isUIVisible;
            
            // Set the active state of the GameObject
            uiPanel.SetActive(isUIVisible);
        }
    }
}
ashen harness
#

but my main question is why is it not dealing the damage to the health script of the player once the projectile hits the player?

frail hawk
#

make sure the OnTriggerEnter is being called, use a Debug.Log

verbal dome
#

Does it work when you press V?

ashen harness
#
    public void OnTriggerEnter(Collider other)
    {

        Debug.Log("Collided with: " + other.gameObject.name);
        // Check if the object we collided with has a Health component
        Health health = other.GetComponent<Health>();
        if (health != null)
        {
            // Deal damage to the health component
            health.TakeDamage(damage);

            // Destroy the projectile after hitting the target
            Destroy(gameObject);
        }
        else
        {
            Debug.Log("No Health component found on: " + other.gameObject.name);
        }
    }```
#

added the Debug.Log

frail hawk
#

so can you see the message now

ashen harness
#

and nothings being posted in the console when the projectile hits

frail hawk
#

ok then the OnTriggerEnter is not being called, make sure you fulfill all requirements for that

#

you need to mark the collider as "isTrigger" on the target objects the projectile hits

ashen harness
#

Ahhhh i see now

#

it works now

#

tysm

#

i just added the istrigger to the projectile itself so it can be multipurposed later on

frail hawk
#

ideally you would not have isTrigger on your objects, you would then check for OnCollisionEnter instead. isTrigger is for obbjects that would not collide with anything, for example coins that you collect but you dant want collisions to occur

ashen harness
#

I'll keep that in mind and now i get to try adding an hp bar to the enemy and letting the player shoot something back lmao

floral garden
#

Hi, anyone has a tip on how to manager a multi ending game? I thought using bool like:
has player talk to
Has player choose to…
Then when reaching a posible ending, i check if those bool are true but it seem like very barbarous 😅

hot locust
#

try to make special gameobject on scene

#

an emnpty gameobject for each case

#

and if a player did something you enable the curret gameobject

lucid shore
#

Yo yo yo

#

What is that game engine goodo or smth I low key forgot

#

Nvm it’s Godot

#

Can someone send me invite link pls

verbal dome
verbal dome
#

One for each bit, 32 bits by default

verbal dome
#

Jesus man just google it

lucid shore
#

Ok bucko 😂

#

Calm down Kevin g

frail hawk
#

it is like going to mc donalds and asking for the direction to burger king

#

i am not a fan of either btw

hot locust
frail hawk
#

but enabling and disabling gameObjects doesnt sound like a perfect soloution

#

in fact it sounds like a bad pattern

hot locust
#

i was coding hack before so i dont like all this unity things

#

i only know how to reverse it

echo ruin
#

What does it mean that a bool is not clean?

earnest wind
frail hawk
earnest wind
earnest wind
frail hawk
#

oh yeah that

echo ruin
frail hawk
#

bool or enum would be the first choice for this, how you handle it depends on you

#

or some kind of state machine would also solve it

hot locust
#

unreal

#

but it the same process

#

with the ram allocation and all

sour fulcrum
hot locust
#

there is just no UObject on unity

hot locust
#

just for my experience

earnest wind
hot locust
#

i thinks im not enough strong in unity

#

that why im learning it

earnest wind
sour fulcrum
#

if you don't know something though maybe don't give opinions and/or help then

lucid shore
#

Anyone free to Vc and help me make a pygame

#

Like tmr

hot locust
sour fulcrum
#

no vc's here and this is a unity discord

hot locust
#

aigh ill shut up next time

#

being kind is source of issue here

sour fulcrum
#

no one is saying that

hot locust
#

idk am giving up yall true ig

sour fulcrum
#

your allowed to not know things just don't misinform others because that's counter productive

#

would you like being told random stuff if you asked for help

hot locust
#

my method work so

#

idk

#

depend

earnest wind
#

This gotta be ragebait

hot locust
sour fulcrum
#

ok man

earnest wind
earnest wind
#

Alright bro just drop it its okay

hot locust
#

when he will know he is stupid he will change

frosty hound
hot locust
#

but aigh

#

mod got all the right on this virtual space

frosty hound
#

!mute 1074987335348932609 2d Insisting on getting the last word in doesn't make your point valid. When you return, have a better attitude.

radiant voidBOT
warm cargo
#

yikes

topaz ruin
#

Hi guys. Im creating the first game drag&drop and i have code here
https://pastebin.com/vDssWguv
and I want the cube not to go beyond the camera and for it to have a distance from the mouse to see where you want to put it but the ratio changes I don't understand why I want it to be the same so that the cube has a small distance from the mouse and as you can see the code doesn't really help so that the cube doesn't go beyond the camera How can I improve my code?

frail hawk
#

crossposting is not allowed

forest cosmos
#

Hello.
I am making a worms clone.

  1. I have an sprite and I put 2d polygon collider on it, it makes this collider. It doesn't fit the sprite. What to do?
    I got the destruction part working.

I move player but when its like this, its controls gets inverted ? right now moves it upward but slowly and left downward.

#

how to upload code?

frail hawk
#

!code

radiant voidBOT
forest cosmos
#
  1. On edge of a point, it just fights. snaps the the above one then below one.
    Please see in code I snap it so that the circle is stuck to the ground so it can climb steep edges.
verbal dome
#

same with transform.rotation -> rb.MoveRotation

boreal portal
#

How strongly is it advised to finish a Singleplayer game first before even attempting anything multiplayer, I'm not wanting to make anything super advanced, just to be able to simply connect peer-peer no dedicated server stuff etc. I'm aware that it's a bit of a nightmare to convert Singleplayer projects to multiplayer, just wondering how feasible it is to make something very simple that has rudimentary multiplayer

#

(if this is the wrong place to post this I apologise)

keen dew
#

Making something very simple and rudimentary is not terribly hard, making something polished that other people might want to play is

#

So it all depends on what the actual goal is

boreal portal
#

Would be happy enough to learn how to get a room in which two players can walk around/be directed to move in for the moment but wasn't sure quite how formidable netcode is

keen dew
#

There are plenty of tutorials for that, you could just browse through one and see how it looks like

boreal portal
#

Fair enough, il have a look then, just wanted to ask beforehand as have seen a lot of recommendations to entirely avoid multiplayer for any purpose before finishing a Singleplayer project

floral garden
verbal dome
#

For example cs public enum MyEnum : long for 64-bit

#

Note that unity only serializes the default 32 bit ints

floral garden
#

oh thanks you, it is so much easier and faster i think than just compar all posible bool one by one

ancient nimbus
#

i made and finished my first unity game, what should i work on now?

frosty hound
ancient nimbus
frosty hound
#

You came up with your first game, you can do the same for your second. 🤷‍♂️

#

Not sure why people need other people to tell them what to do. You're dedicating a lot of time and effort to make things, it shouldn't be random people on the Internet telling you how to spend it lol.

#

Anyway, make Flappy Bird.

ancient nimbus
frosty hound
#

Pong

ancient nimbus
#

ping pong, nice

#

i'll try that

#

thanks

frosty hound
#

Good luck

ancient nimbus
#

thanks man

#

i feel like its gonna be so fun to make

forest cosmos
earnest wind
sinful gazelle
#

what are these and how to remove them?

rocky canyon
sinful gazelle
rocky canyon
#

it just tells u info bout the code

#

noo.. its seperate from that

#

Intellisense is what shows broken code/syntax

potent hornet
#

My alpha is still 255 after setting it to 50. Is there a work around for changing it

sinful gazelle
#

I unticked this, it kinda worked

sinful gazelle
rocky canyon
#

IntelliSense

  • What it is: Your editor's smart assistant for code completion, parameter info, and basic syntax checks (like a red squiggle for a typo).
  • Focus: Real-time help with writing code correctly and quickly.
    CodeLens
  • What it is: A feature that displays information directly in your code editor, above methods, classes, etc..
  • Focus: Contextual history and usage: "This method was changed by John 3 days ago" or "This class is referenced by 15 other files".
cosmic quail
rocky canyon
#

go into file>pref settings or w/e and then searching for Code > Codelens

potent hornet
#

Thanks

winter hollow
#

Hello

rocky canyon
#

yea the pins in here have lots of sources

winter hollow
#

I am very new to unity, I only know how to dump a plane and assets, how I learn with you all

radiant voidBOT
rocky canyon
#

this server isn't really hand-holdy.. but we will help out when-ever

its best u venture off on ur own.. and try learning.. yourself and coming back to this server for specific help
say u dont understand a certain component.. or a script.. u can come and ask specifically to explain it.. or ask follow up questions 👍

stone narwhal
#

Hey guys I’ve got a question. How am I able to detect to my player is taller than a game object yk?

#

Any ideas of that

rocky canyon
#

basic math 😉

stone narwhal
#

I thought of maybe doing a sphere ray cast

#

Just seeing if there’s nothing, then I’m taller

stone narwhal
rocky canyon
#
  public Collider playerCol;
    public Collider targetCol;

    void Update()
    {
        if (!playerCol || !targetCol) return;

        float playerHeight = playerCol.bounds.size.y;
        float targetHeight = targetCol.bounds.size.y;

        if (playerHeight > targetHeight)
        {
            Debug.Log("PLAYER TALLER");
        }
    }```
#

if they are the same size (scale) u can use the bounds of the renderer or the collider

stone narwhal
#

Ah ok

#

Thanks !

rocky canyon
#

use a collider/trigger/raycast etc to get the transform of the other object

#

then the comparison should be relatively simple

ashen harness
#
using UnityEngine;
using UnityEngine.UI;

public class EnemyHealthBar : MonoBehaviour
{
    [SerializeField] private Slider slider;
    [SerializeField] private Camera Ecamera;
    [SerializeField] private Transform target;
    [SerializeField] private Vector3 offset;

    public void UpdateHealthBar(float currentValue, float maxValue)
    {
        slider.value = EnemyHealth.EcurrentHealth;
    }
    
    void Update()
    {
        transform.rotation = Ecamera.transform.rotation;
        target.position = target.position + offset;

    }
}```
#
using UnityEngine;

public class EnemyHealth : MonoBehaviour
{

    public GameObject Enemy;
    public EnemyHealthBar EnemyhealthBar;
 

    [SerializeField] float EcurrentHealth, EmaxHealth = 100;

    private void Awake()
    {

    }

    void Start()
    {
        EcurrentHealth = EmaxHealth;
        EnemyhealthBar.UpdateHealthBar(EcurrentHealth, EmaxHealth);

        

    }

    void Update()
    {
        if (Input.GetKeyDown(KeyCode.V))
        {
            TakeDamage(20);
        }

    }

    public void TakeDamage(int damage)
    {

                if (EcurrentHealth <= 0)
        {
            Destroy(Enemy);
        }

        EcurrentHealth -= damage;
        EnemyhealthBar.UpdateHealthBar(EcurrentHealth, EmaxHealth);
    }
}```
#

apparently EnemyHealth.EcurrentHealth is inaccessible due to its protection level and im honestly a bit lost lmao

#

been fighting this health bar for a while now

cosmic quail
#

might wanna make it public and get rid of the serializefield?

#

also you need to turn EnemyHealth into an actual reference

ashen harness
#

tbh didn't know serializefield was private , I'm new to this if you couldn't tell lmao

#
using UnityEngine;

public class EnemyHealth : MonoBehaviour
{

    public GameObject Enemy;
    public EnemyHealthBar EnemyhealthBar;
    public int EmaxHealth = 100;
    public int EcurrentHealth;

    private void Awake()
    {

    }

    void Start()
    {
        EcurrentHealth = EmaxHealth;
        EnemyhealthBar.UpdateHealthBar(EcurrentHealth, EmaxHealth);

        

    }

    void Update()
    {
        if (Input.GetKeyDown(KeyCode.V))
        {
            TakeDamage(20);
        }

    }

    public void TakeDamage(int damage)
    {

                if (EcurrentHealth <= 0)
        {
            Destroy(Enemy);
        }

        EcurrentHealth -= damage;
        EnemyhealthBar.UpdateHealthBar(EcurrentHealth, EmaxHealth);
    }
}```
#
using UnityEngine;
using UnityEngine.UI;

public class EnemyHealthBar : MonoBehaviour
{
    [SerializeField] private Slider slider;
    [SerializeField] private Camera Ecamera;
    [SerializeField] private Transform target;
    [SerializeField] private Vector3 offset;
    public EnemyHealth Health;

    public void UpdateHealthBar(float currentValue, float maxValue)
    {
        slider.value = Health.EcurrentHealth;
    }
    
    void Update()
    {
        transform.rotation = Ecamera.transform.rotation;
        target.position = target.position + offset;

    }
}
#

I did it :D

wintry quarry
rocky canyon
#

it just exposes it in the inspector and makes it editable.. (still private behind the scenes)

#

the default access modifier is private. That's why your field is private

#

☝️ this

ashen harness
wintry quarry
rocky canyon
cosmic quail
wintry quarry
#

They would still be private without serializeField:

float EcurrentHealth, EmaxHealth = 100;```
ashen harness
#

Ahh gotcha

#

makes sense

cosmic quail
# ashen harness makes sense

but once you made it public there was no point for serializefield being there anymore so thats why i told you to get rid of that as well

ashen harness
#

aye on the bright side I figured out like 9 other errors alone before this one 🤣 I'm learnin slowly but surely

nocturne kayak
#

Hello quick question. So I want to detect if something enters a collision with a box collider, so I should use OnTriggerEnter. But the thing is that I have the script attached to a different game object, so if I do OnTriggerEnter, it will try to find the box collider of the game object my script is attached to, but I can't do something like myboxcollider.OnTriggerEnter . So what should i do?

ashen harness
cosmic quail
ashen harness
#

idk if it helps but i did something like that with a projectile

nocturne kayak
#

Oh wait i might be dumb

edgy tangle
#

You can also just make a script which raises an event / UnityEvent when OnTriggerEnter fires. Then anything can subscribe to it can run a callback.

nocturne kayak
nocturne kayak
edgy tangle
#

Not as far as I’m aware.

nocturne kayak
edgy tangle
#

Yeah you can’t natively get a callback for OnTriggerEnter from another GameObject — only for this one.

#

AFAIK

nocturne kayak
#

I just want to create a hitbox that detects a player so that the NPC can pivot in front of the player. Maybe i should use a RayCast instead ?

edgy tangle
nocturne kayak
edgy tangle
#

That will tell you how “much” the enemy is facing the player

nocturne kayak
edgy tangle
sterile wraith
#

hello! Im applying a torque on the y axis using addTorque and the x and z axis are having no torque applied. in addition, the rigidbody has freeze rotation on x and z. even so, the other axis are rotating and im unsure why

#

same issue for relative torque

frosty hound
#

Please stop cross promoting this. If you have a tutorial to share, you can post in #1179447338188673034

Also read the guidelines for posting in that channel.

sterile wraith
#

is it due to the intermediate axis theorem

static violet
#

Hi I’m making a small 3D first-person game in Unity but I’m stuck on something I can’t manage to add fog that starts at around 5 meters like in the screen, I’ve looked for tutorials and stuff but I couldn’t find anything

#

if anyone can help me

#

ty

pearl hedge
#

it might help to se your set up and understand how you have built it and rekomend fixes and ways to improve :3 i am myself not a good coder

static violet
pearl hedge
#

so are you using the effekt sistem or a block half sethru

static violet
#

idk

#

with rendering > environment and fog but nothing

pearl hedge
static violet
pearl hedge
#

ok so i can garanty as i have almost 0 knolige using effekts so i may make a error \

#

o so around the player not spawn?

static violet
pearl hedge
#

if player some may shout but make a big sirkle no kollition and add t player in the middle and make the sirkle a child of the player and sorry for misspell missing some keys

grand snow
#

thats not fog its just controlled light

static violet
grand snow
#

Are you using a spotlight or point light?

static violet
pearl hedge
#

XD

static violet
grand snow
#

If lights dont work you have done something very wrong

#

please go learn the basics of unity

#

!learn

radiant voidBOT
verbal dome
#

Or are you doing something transform-related with the rigidbody (parent/child, rotating, moving)?

static violet
grand snow
finite sorrel
#

Howdy, I'm trying to setup a Node (in 3d space) for specific location where multiple units can go, and I would like it to work in a way that - as more units arrive at that node, they will get arranged in "esteticaly pleasing" way.. always forming n-gon .. sort of like on the very well made picture of mspaint..

As I don't know theroretical maximum of units at single node, instead of creating each scenario by hand placing empty game objects...My thoughts were to make a circular spline with expanding radius based on amount of units present (as a child for example) along which I would distribute those units in equaly distant matter. Therefore if there was only one unit present, radius would be barely noticable, but as more units would arrive it would grow. Does that make any sort of sense? Can someone point me atleast towards some way/name of what I'm trying to achieve?

sterile wraith
#

if i disable the torque in the y axis it wont roatet it

#

at all but then when i apply torque in just y it rotates in all directions

verbal dome
sterile wraith
verbal dome
#

Is it a child of another object and/or does it have children with any components?

sterile wraith
#

the boat is an empty gameobjec.t the body is the actual gameobjrct with teh bollider. then the rudder is an empty which si the pivot. the fin is the actual fin.

#

i apply the torque on the y axis to the boat becuase it has the rigidbody.

#

fin has box collider rudder nothing

west compass
#

how can I fix the vertical tiling for my material

#

now It is just stacked

slender nymph
#
  1. this is a code channel
  2. you need to fix the UVs for the model or edit the material to set the tiling you want
zenith cypress
#

Since that looks like it came from a prototype texture asset, they typically expect you to use their triplanar shader they provide, or your own triplanar shader.

west compass
#

ah I see thx

verbal dome
sterile wraith
#

but why

#

😭

verbal dome
#

I bet you are rotating the fin with transform

sterile wraith
verbal dome
#

What if you disable that code but enable the fin?

#

Rigidbodies dont work well with transform modifications, be it child or not

floral garden
#

hii , me again, does unity have a system of auto scrolling ? with the textmeshpro?

sterile wraith
#

thats very annoying tho

sterile wraith
#

use quaterniosn rotations?

verbal dome
#

Probably a Joint

sterile wraith
#

quaternions wouldn teven fix it?

verbal dome
#

No, the issue is that you are modifying the transform

sterile wraith
#

and thats not good with rigidbodies?

verbal dome
#

No

sterile wraith
#

do u know why?

#

that way i can alleviate future issues

#

and why disabling the box collider fixed it bc i didnt think that had to do w transforms

verbal dome
#

Because the physics engine has its own way of moving rigidbodies/their transforms

verbal dome
sterile wraith
verbal dome
#

When you disable it, the rigidbody just ignores it

#

Transform rotating a child with no collider is fine

sterile wraith
sterile wraith
# verbal dome Transform rotating a child with no collider is fine

im trying to read through the physics engine source code to understand why and it seems like the a child part changes the mass center. the file nprigidbody.cpp updates the balance point and the spin axes immediately. then if you move that child part the spin axes tilt away from the world axes. the integrator in dybodycoreintegrator.cpp takes the torque and applies it to the tilted axes. bc the axes are tilted the force makes the object spin on multiple sides at once. so like the engine sees a lopsided shape and acts accordingly.

#

thats what im able to parse from it

#

that was my first suspicion abt the shape being changed due to the collider, but when i debugged the center of mass, it didnt change in the console so 🤷‍♂️

frail slate
#

Sorry

#

I mean “scroll view”

floral garden
#

oh i think yes like if the text is too big in the case , it will scroll down and the user can scroll up down. if it is too long i will just cut the text I think

grand snow
#

TMP text can use content size fitter or layout groups to auto set its rect size

floral garden
#

you mean scroll Rect ?

grand snow
floral garden
#

i see

#

gonna try it then

mystic flume
#

how do i fix this fullscreen

#

im trying to be able to see the hirechy

ashen harness
#

Pretty sure there's a key bind but i forgot it 😂

mystic flume
wicked cairn
covert wave
#

this error

naive pawn
radiant voidBOT
# naive pawn !input
How to Set Input

To set Active Input Handling, go to:
Project Settings > Player > Active Input Handling

• Input Manager (Old): Use the original Input settings.
• Input System Package (New): Uses the new input system package.
• Both: Use both systems.

naive pawn
#

the error tells you what to do, too

covert wave
#

confused

#

what do I change

#

@naive pawn

naive pawn
#

open "other settings" and scroll down to active input handling

wintry panther
#

I made a cube that rotates randomly, and now i want it to slow down and land on the face that is closest to the ground plane. how could i do that and find out which face it's sitting on?

#

the cube is a d6 die and i want it to stop rotating after a while and land on the face closest to the ground

naive pawn
#

break that problem up into smaller tasks and figure them out one by one

wintry quarry
wintry panther
#

if you search up "roll d6" in google, it shows you a virtual dice roll. How is google doing the rotation for those dice?

wintry quarry
#

It's precisely how I did it when I solved this exact problem 6 years ago

wintry panther
#

right now, my die just rolls in a rnadom direction

wintry panther
#

but google's version rolls around, not just one direction

wintry quarry
#

it's just showing a random number in front of it at the end of the animation

#

there aren't even numbers on the faces as it rolls

wintry panther
#

right. im just wondering whats the best way to simulate a dice roll in my game. it needs to be fair

wintry quarry
#

You'll need to explain what your constraints are exactly

wintry panther
#

right now, i just pick a random direction and it rolls for a bit, then slows down

#

there is no ground in my game. its just a 2d game with a 3d die in it

#

the die needs to rotate randomly without moving its position

wintry quarry
#

one option is to do something similar to what google is doing - show some kind of animation and then just pick a random number to show.

wintry panther
#

then land on a side

wintry quarry
#

that's kinda how Baldur's Gate does it too

wintry panther
#

yeah baldurs gate does it, but that die moves around as well

#

i want a stationary die to roll in place

wintry quarry
#

you could record it manually, or you randomize the rolling direction over time and then have it stop

wintry panther
#

ah right true

#

i'll have to try randomizing the roll direction

#

im thinking based on what the current direction is

#

so say its rolling upwards, the randomness will make it roll slightly differently from upwards

naive pawn
#

you could also set random linear/angular velocities and have it play out physically (then detect the top face with what praetor mentioned)

#

like with nintendo's yahtzee

wintry panther
#

there is no ground. the die is floating essentially

naive pawn
#

but that might not work out with your intended UI/UX

wintry panther
#

and i dont want to move the position ever

naive pawn
#

(not a suggestion, just a train of thought) i wonder how jank it'd look if you simulated it physically and just had a camera following it to make it look like it's in the same position (without showing the geometry it's colliding with)

wintry panther
#

yeah, but with that, the camera would move when it shouldnt, at least for my game

naive pawn
#

nah, a separate camera just for the cube

wintry panther
#

ah right haha

crisp quest
#

How can i learn input system in unity ?
there are many videos and all of them teaches different methods

naive pawn
#

there's a lot of ways to use the new input system

#

options, in no particular order (because i don't have the brainpower to sort them right now)

  • InputActionReference as a serialized field, poll that
  • InputActionReference as a serialized field, subscribe to that
  • PlayerInput component with messages
  • PlayerInput component with UnityEvents
  • PlayerInput component with C# Events (not sure what that entails)
  • Generated class, poll that
  • Generated class, subscribe to that
#

this list is not exhaustive

crisp quest
#

script system is good or inbuilt one?

#

i mean i was using my script to move my player and i saw then there is another way to do it too, then im now asking which one is good and easy ?

wintry quarry
#

Are you asking about... another movement script? Or another scripting engine? Or something else?

cosmic dagger
crisp quest
#

i was just copying code monkey's tutorial and i still not working so im lost now

ivory bobcat
crisp quest
ivory bobcat
#

The new (not so new anymore) input system should be the same as always.

#

You'd simply setup the system for buttons actions etc then communicate with the input system through code

crisp quest
#

yea and yt videos making these things more complicated as everyone showing different ways , i tried to copy code monkey's code and the way he does things but even after setting up everything , its just not working

ivory bobcat
#

What Chris would be referring to would be whether you'd poll or not etc

ivory bobcat
crisp quest
#

this is what i was watching

#

here all he did is that when he presses spacebar and then console returned the "Jump" string 3 times

#

i copied and still not working

ivory bobcat
#

Have you setup the input system like he has? (it may have been done in some other video)

crisp quest
#

i literally have copied hime same to same as much i know

naive pawn
crisp quest
#

this is what he have done and i copied him

naive pawn
crisp quest
#

u mean to save asset right? i have clicked it and still not working

naive pawn
#

you've set the right function in that unityevent, correct?

crisp quest
naive pawn
#

check the input debugger to make sure your keyboard input is being received by the input system

crisp quest
#

how to check

naive pawn
#

open the input debugger, there's a button on the player input
open the keyboard menu
see if your input is being received

crisp quest
#

thanks its working now

lucid shore
#

Can anyone help me find some good tutorials for coding c# for game development

#

As most tutorials just tell you what to do but why

naive pawn
lucid shore
#

Ok thanks

wraith moon
#

this is my collider setup

#

and my rigidbody setup

frail hawk
wraith moon
#

its a bit hard to explain i might take a vid of it

#

the player should stop after coming up to the step (happens near the end of the vid)

frail hawk
#

you want to be able to go upstaris only when facing straight forward

#

if i understood correctly

#

you´d have to get the angle from your player to the stairs normals

wraith moon
frail hawk
#

could we see the code for moving the player

#

looks like you are transforming the player instead of using physics

wraith moon
#

im using addforce to move the player

frail hawk
#

you could place bigger colliders manually if you only have a few of these steps of course or are these this procedurally generated steps

wraith moon
#

theyre manual but i feel like that would be a bit jank in general honestly

#

i want something that would work universally

frail hawk
#

i see

#

it is straight forward, how to detect high steps. you could simply use a raycast from the heigth of the player knees forward, but how you prevent the player from going forward could be tricky

wraith moon
#

okay i figured out exactly what's happening

#

when i mfacing exactly straight, the player automatically stops (expected behavior)

#

but any sort of deviation messes up

lucid shore
#

Could I ask how people got started out in unity game development it just seems so complicated and hard to understand

wraith moon
# wraith moon

this was actually a problem with how my stairs were levelled lol

#

was a placeholder anyways

radiant voidBOT
naive pawn
#

start here

lucid shore
#

Thanks 🙏

coarse ibex
#

guys how do i add fog?

frosty hound
#

Use Unity's fog system google . Also not a coding question.

charred monolith
static violet
#

How can I do this in Unity? Like I can only see about 5 meters around me and after that everything is black thanks if someone can help me

naive pawn
grand snow
naive pawn
#

this is a code channel

fickle plume
naive pawn
#

please don't advertise your question
you're not gonna get anyone from here anyways. only code nerds here

#

if someone knows they'll be in that channel

golden notch
#

In the project assets window, how do I make a json file?

grand snow
golden notch
#

ok

fickle plume
balmy vortex
#

cuz I feel like this is a really unnecesarily drawn out way of going about it lol

frail hawk
#

you should use only one AudioSource

#

then use as many AudioClips as you want and then AudioSource.PlayOneShot(audioclip);

ancient nimbus
#

i just made this, is this a good way to make movement?


public class Player : MonoBehaviour
{

    public Rigidbody rb;
    public float PlayerSpeed = 5f;

    private void Update()
    {
        Vector2 InputVector = new Vector2(0f, 0f);
        if (Input.GetKey(KeyCode.W))
        {
            InputVector.y = +1;
        }
        if (Input.GetKey(KeyCode.S))
        {
            InputVector.y = -1;
        }
        if (Input.GetKey(KeyCode.A))
        {
            InputVector.x = -1;
        }
        if (Input.GetKey(KeyCode.D))
        {
            InputVector.x = +1;
        }

        InputVector = InputVector.normalized;
        Vector3 MoveDir = new Vector3(InputVector.x, 0f, InputVector.y);
        rb.linearVelocity = MoveDir * PlayerSpeed * Time.deltaTime;

    }
}
frail hawk
#

it is not good no make use of input axis instead

balmy vortex
#

wbt the actual methods themselves though

#

cuz I'm going to have to add a lot of different sound cues and I don't want it to get rly messy

frail hawk
#

methods would be called nearly at the same time, i dont see any cue here

#

also inside the Update you are calling the method every frame, i dont think that is what you want

#

if you want some kind of delay or cue you could use a Coroutine

edgy tangle
#

Why don’t you just play the AudioSource where you set the bool to true? Then you don’t need to be checking it with Update

balmy vortex
edgy tangle
#

Your bool playLeftDoorSoundCue in the if clause

naive pawn
#

you have significant spaghetti here

#

these methods basically just do 1 thing that can honestly be inlined

balmy vortex
#

oh sure

edgy tangle
#

You also have a method and bool with the same name

naive pawn
#

making systems more modular is nice, but at some point it becomes incoherent

balmy vortex
naive pawn
# balmy vortex this

i'm extrapolating a lot here, but do you really need separate AudioSources for something like this? you could have a single audiosource that's configured (spatial/volume stuff) and just play one shots with separate clips instead

edgy tangle
#

Yeah you have several steps for something that could be a single line

balmy vortex
#

or like how does this work

balmy vortex
#

oh oki

#

thanks king UnityChanThumbsUp

golden notch
#

Anyone got a tutorial on how to do something similar to source's bodygroups? To toggle a model part on and off?

cosmic quail
golden notch
#

So make a prefab where different pieces of the model are separate gameobjects?

#

how would I ensure the parts go where they need to relative of each other?

cosmic quail
golden notch
#

Oh so they will already be separated when importing?

golden notch
#

Is unity going to make a .meta file for all jsons or something?

slender nymph
#

every asset, including json files you import into the project will have an associated meta file

naive pawn
#

every folder has a meta file as well. these are features, not bugs

golden notch
#

ok

golden notch
#

ok so i can't figure out how to add more inputs to my setup. I remember having a list of different things and now it's not there

sour palm
#

Hay so I'm just having a general issue with something.
So I have on script called LedgeTriggerScript that just triggers if the player is in the ledge trigger space. Now I just need to set up a way for that script to tell the PlayerMovement script that the player is in a ledge trigger space, so I can it can do a clime movement.

#

This is in the PlayerMovement

#

and this is in the LedgeTriggerScript.

grand snow
golden notch
#

how? I know i seen it but i can't find out how to get back to it

grand snow
golden notch
#

i's not showing the new stuff

grand snow
#

!input

radiant voidBOT
# grand snow !input
How to Set Input

To set Active Input Handling, go to:
Project Settings > Player > Active Input Handling

• Input Manager (Old): Use the original Input settings.
• Input System Package (New): Uses the new input system package.
• Both: Use both systems.

golden notch
#

it's already set

golden notch
#

and it is selected

grand snow
#

What unity version is this?

#

the guide wants you to setup a global input action asset but that is not required

golden notch
#

2019.4.28f1 Personal

grand snow
#

try to update your packages and check for compile errors.

golden notch
#

it says up to date still

grand snow
#

Ah you need to upgrade to the last 2019 version so you can get v 1.12

#

Or upgrade from 2019

#

1.0.2 is ancient

grand snow
# sour palm how would I do that?

add a function to your class and call it. That is basic c# which you should already know

public void SetClimbState(bool enabled){...
//Elsewhere
pm.SetClimbState(true);
golden notch
grand snow
#

you install a different version...

#

thats just selecting from your currently installed ones

#

also why tf are you on ancient hub too

#

god damn

golden notch
#

haven't messed with it in a while

grand snow
golden notch
#

how much is going to break if i upgrade?

grand snow
#

Very little to nothing but you should use source control so there is no risk

#

otherwise make a full backup beforehand

torn glacier
#

guys in my unity project i have 999+ errors

#

and i have no idea what they mean

sour palm
polar acorn
#

Start at the top

grand snow
sour palm
#

Compiler Error CS0103

grand snow
#

It was just an example

#

You need to define the function and call it on the instance you get via GetComponent

sour palm
#

I tried that too but I got a Parameter and argument mismatch error.

rich adder
#

OnTriggerEnter is something unity calls via physics / trigger enter not something you call manually

#

a ledge grab system kinda over scoped for someone who doesn't know basics of C# / calling methods from other components

#

if you only have a bool that controls "IsLedgeGrabbing" you would use a method or set the field yourself

#

why OnTriggerEnter(true) was ever a thing? their example did not do that

sour palm
#

OnTriggerEnter is what my ledge detection method is called. It something i found from some tutorial a while ago.

floral garden
#

did you mean enable OnTrigger ?

rich adder
#

if they mean the bool then yes, but thats not a method

#

also for clarity most bools are prefixed with Is

floral garden
#

i have never see someone put a true on OnTriggerEnter.

floral garden
rich adder
floral garden
#

okk

rich adder
#

LedgeObject for a bool name is confusing cause it implies an object not a state/bool

floral garden
#

oh i think i will do it too

#

i don't think i am adding Is as prefix on my bool too

rich adder
#

its not a hard rule but it helps identify a bool, if you think about they are simple states

#

IsSleepy IsCrouching etc.

#

On prefix usually for Events

#

OnHit etc.

floral garden
#

let me note it in my doc

rich adder
#

😂

#

I sense some sarcasm ✍️

floral garden
#

hahaha

rich adder
#

anyway OP should probably scale down the scope until they get better at C# basics

floral garden
#

i am not joking if you think so, i am i think still a new and i need to make a doc so my project can be more clean

#

hmm , damn i forget what i was coming for :/

floral garden
#

thanks

rich adder
floral garden
#

damn

#

gonna need to refactor some code

rich adder
#

I mean just for the future, you don't have to refactor unless it really messes with your clarity, the important part is if YOU understand your own code today, tomorrow and months/years from now

floral garden
#

but if i am working in team

rich adder
#

certainly helps if everyone is on the same page, and if you follow "standard" naming practices then its easier than making your own, but you can certainly do the latter too

floral garden
#

well, if they need to know anythingj, they will ask me anyways event if the code is
in add(x,y)
return x+y;

sour palm
#

Alright I got it working thanks for the help.

rough granite
# rich adder

Curious now i know its not really proper but how much would a workplace be bothered if i named my variables starting with a capitol ie int MyInt instead of int myInt been doing it like this since the beggining since the first ever youtube video i watched on programming had it written as such.

teal viper
rough granite
#

Stuff is made from my nightmares, and 90% of the reason i hate godot

teal viper
#

Well, snake case is a standard in some languages. If you're gonna have to write python you might need to use it.

rough granite
#

Same with lua, though not many things use this as far as i know

teal viper
#

In Game dev, various tools are often written in python, so depending on what your company does, you might have to do it at some point.
And it's really not that bad. You can even delegate it to AI 99% of time and just confirm there are no issues.

rough granite
#

You can even delegate it to AI 99% of time
Bruh

#

Though i guess that makes sense it's like the language ai was made in right?

teal viper
#

Not really. It's just that most of the code shared online is python, so there's more training data for it.

#

But to be honest, this is kind of an overstatement.
More than that, simple tools usually don't have complex architecture and huge codebase, so it's harder for ai to mess up.

rough granite
#

Fair fair, i do recall seeing awhile ago about someone who was using ai and it wiped a whole database on them cause they hadn't restricted its access

teal viper
#

Honestly these "wiped the whole database" cases are probably 90% a human error. I bet they had things set up in a dangerous way or gave incorrect instructions and probably were not entirely aware how things work. I've been using agentic ai coding for more than an year now(both personally and at work), and I didn't have single case where a model would even get close to making such a critical mistake.

#

Usually it's more like messing up a powershell command syntax or forgetting to add a namespace using.

#

Which is extremely rare as of today as well.

golden notch
#

what is a good workflow, making a centralized script that handles inventory slots, or make a script on the slot itself that handles dragging, splitting, and drag'n'drop?

teal viper
versed light
#

LazyLoadReference<T0> can i serialise this for json so my saved data correctly references a prefab or asset? or is it unreliable ?

#

never used it before so not entirely sure of its purpose

covert wave
#

having a console error anyone able to understand this.

#

having trouble

#

If anyone knows ?

wintry quarry
# covert wave

looks like you're trying to load a scene that hasn't been added to the scene list or build profile

covert wave
#

I thought I did

#

@wintry quarry

wintry quarry
#

your error says you're trying to load the scene at index 2

covert wave
#

So how do i fix the error

wintry quarry
#

you can see the scene indices right here

wintry quarry
covert wave
#

This was the code

wintry quarry
#

Well it's pretty clear what the issue is from reading this code, no?

#

If you're in scene 1 and you run this code it will try to load scene 2

#

change the code to not do that

covert wave
#

I apologize im brand new to unity/coding Im sorry.

wintry quarry
#

You have nothing to apologize for

covert wave
#

Do I remove the + 1?

wintry quarry
#

No

#

Think about it

#

What should happen when you run Play and you're in scene 1 already?

#

you need to decide what should happen in that case

#

only when you come up with an answer to that question will you be able to write the code to do it

covert wave
#

fahhh

wintry quarry
#

It's not a trick question

covert wave
#

Lowkey my mind is broken it kind of is for me

wintry quarry
#

Do you want it to:

  • Do nothing?
  • Load scene 0 again?
  • Load scene 1 again?
  • something else?
covert wave
#

It a loading screen so, I want it to change from the scene including the loading screen to the actual game scene

wintry quarry
#

which scene is the loading scene and which is the actual game scene?

#

I only see "MainMenu" and "Game" in your scene list

covert wave
#

0 is the loading screen / main menu

#

1 is the actual game

wintry quarry
#

Well your error is indicating that you are actually running this code when you're already in the game scene

#

so you need to figure out why that's happening and stop it from happening

#

that's your issue

austere kraken
#

is there any voice channel to live dev

wintry quarry
#

no

austere kraken
#

ohk

#

can you suggest some thing for my game

#

anybody?

fickle plume
fickle plume
#

Don't cross-post, please.

lucid shore
#

When I do transform.Translate(Vector3.forward) why am I doing these dots like WhT is their purpose

frail hawk
#

in the sceneario you demonstrated

lucid shore
#

I’m sorry I’m new is it possible to explain further

frail hawk
north kiln
# lucid shore When I do transform.Translate(Vector3.forward) why am I doing these dots like Wh...
crisp patrol
#

guys i need help, for the OnTriggerEnter2D function, how do i specify which objects i want it to check for? For example: i have an enemy, when the player collides with the enemy the game ends, but right now if the enemy collides with something else (fx. another enemy) the game also ends. How do i specify so it's only on collision with the player?

frail hawk
#

it shows you the Transform class and all of the things that belong to it

lucid shore
#

Thanks

frail hawk
naive pawn
crisp patrol
naive pawn
#

CompareTag gives a boolean, you'd check if the incoming collider has the right tag

north kiln
#

Exactly what you're looking for.

naive pawn
#

but it's with magic strings, i'd recommend using layers for this. it fits very nicely with your usecase

#

you can configure some layers to not collide with certain other layers in project settings > physics/physics2d > layer collision matrix

crisp patrol
mint flicker
#

Yo i need help with something I can't find any tuts on it. I'm trying to make the animated 2d cloth like in hollow night or silk song when player triggers box it moves that way but its a bit buggy and just moves the wrong direction sometimes I'm. Using bools. how did silk song make theres

kindred temple
#

A user is getting a "Request timeout" error when a web request is being sent shortly after trying to send it, but my code is not setting the timeout field to any value.

Does anyone know what's going on here? According to the docs it doesn't seem like this should happen.

#

I'm not encountering this issue and neither is anyone else, it's just one person

grand snow
kindred temple
grand snow
kindred temple
#

Is there some kind of setting I can change to fix that?

The documentation seems to imply it won't timeout if none is set.

grand snow
#

share the actual error

#

and try to set a timeout yourself like 5 seconds

kindred temple
grand snow
#

mb i usually await unity web requests which can then throw.
Im going to presume its some internal mechanism to timeout so may not be something you can solve

desert leaf
#

How can I master on scripting? I have fundamental knowledge on c#(for unity ofc) but I struggle with scripting. How would you perceive if you were in my state. I'm looking forward for some advice.

frosty hound
#

Tutorials and practice. There's no magic solution if that's what you're hoping for.

#

And add discipline to keep your scope small when starting out so you can achieve actual results.

ivory bobcat
#

Is this related to code? If not, try moving the post to #💻┃unity-talk
Make sure to provide more or as much information as possible to get better help from the community

desert leaf
frosty hound
#

You just did?

#
  1. If you plan on making something with the intention of making money off it, it's too big for you

  2. If you plan on making something that the internet has convinced you is easy to make (ie, non-tutorial youtubers saying things like "I made GTA6 in 2 weeks"), it's too big for you.

  3. If the idea would require more than one person to complete it's too big for you

  4. If the idea includes any type of coop it's too big for you

  5. If the idea is your dream project, it's too big for you

#

If the idea is boring, simple, and nobody around you will care to play it or find it impressive, then it's the right scope.

ashen harness
#

What i did and am doing is i made a project and started adding random features and slamming my hand against the keyboard until it works 🤣 for learning purposes and experience

desert leaf
desert leaf
ivory bobcat
# desert leaf How can I master on scripting? I have fundamental knowledge on c#(for unity ofc)...

Just scripting or game development overall? This is a Unity game development server so we're more focused overall on the development of games. Relative to my own experiences, you'd be a good-enough of a scripter when you're able to implement your designs.
Assuming knowing c# and the Unity API isn't a concern anymore where you'd be able to quickly lookup what's needed when necessary and produce your wanted behavior.

ashen harness
#

and don't expect it to come together into a finished product just learn and learn and learn

ashen harness
#

and make a folder where you can store a bunch of your .cs files so you have your mechanics and etc ready for your next project as a baseline

desert leaf
ashen harness
#

and i would take notes of previous issues you had while making certain things and what your fix was for it

#

for anything significant that is

#

like oh hey this one mistake created 70 errors lmao

#

a lot of the beginning phase of learning from my current experience is literally just lack of knowledge and experience

#

that's why i'm just focusing on the current project of slapping a bunch of random features i want to learn together

#

without any end goal game for the project

#

it might turn into something but if it doesn't then its whatever because it was a project for learning

desert leaf
#

It feels depressing when you don't understand a chunk of code that puts the logic even after trying to understand it.

ashen harness
#

join that so we don't flood this chat lmao

ancient nimbus
#

Vector3 MoveDirection = new Vector3(HorizontalInput * CurrentSpeed * Time.deltaTime, PlayerRB.linearVelocity.y, VerticalInput * CurrentSpeed * Time.deltaTime).normalized;

guys i was wondering if it was useless to add: * Time.deltaTime

naive pawn
#

it makes it incorrect in this case

ancient nimbus
#

oh wow thanks

naive pawn
#

you're normalizing this vector making it a direction - the y value shows it's a direction of speed
the x and z values have CurrentSpeed * Time.deltaTime, meaning they're positions (or rather, delta positions)

so you basically compare 2 values that don't represent the same thing here

#

if you (for example) added * Time.deltaTime to the second parameter, making the entire thing a deltaPosition, then it wouldn't matter since it's normalized (magnitude doesn't matter) and it's shared between all 3 components - you could remove all 3 in that case and get the same result

ancient nimbus
#

i see

#

thanks

ancient nimbus
#

is there not a Debug.DrawSphere?

#

or is there a way to debug Physics.CheckSphere

naive pawn
#

gizmos work kinda differently to Debug though

#

you could also make a helper method to draw a bunch of lines approximating a sphere, just to give you a rough idea of where it is

ancient nimbus
#

thanks

#

i'm so happy man

#

i can't believe i made my first 3rd person controller script

#

no AI

#

no tutorial

#

only help from people

#

thanks alot guys

frail hawk
#

glad you did it, tutorials are fine, ai for beginners not

ancient nimbus
frail hawk
#

is that even possible

ancient nimbus
#

well

#

i won't use chatgpt or stuff like that

#

i'm not talking about pathfinding ai lol

frail hawk
#

hehe okay

ancient nimbus
#

i decided to add camera control which i think i should have done earlier, i used cinemachine but how can i make the movement depend on Head rotation too?

```  // GET WASD INPUT
  float VerticalInput = Input.GetAxisRaw("Vertical");
  float HorizontalInput = Input.GetAxisRaw("Horizontal");

  // USE  WASD INPUT TO MAKE A VECTOR3 THAT IS NORMALIZED AND MULTIPLIED BY THE CURRENT SPEED
  Vector3 MoveDirection = new Vector3(HorizontalInput, 0f, VerticalInput).normalized * CurrentSpeed;
  

  PlayerRB.linearVelocity = new Vector3 (MoveDirection.x, PlayerRB.linearVelocity.y, MoveDirection.z);```
ancient nimbus
wraith moon
#

is there a way to implement weapon sway with 2d sprite weapons and URP? i use a seperate overlay camera for the weapons

fierce smelt
#

Curious as too how difficult it is to code character movement in a 2d game?
I’ve never done coding before

slender nymph
#

the answer, as with anything that open ended is itdepends

rich adder
slender nymph
#

!learn 👇 get started with learning the engine, the pathways on the learn site are a good place to start with that. there's also beginner c# courses pinned in this channel

radiant voidBOT
cunning narwhal
#

I'm having to deal with multiple unity version compatibility changes and the way I'm handling it is by using preprocessor directives to switch on detected versions. Will this work the way I expect it to? I feel dumb asking but I need some assurance. See screenshot. Youll see if I'm on a specific version where the API changed implementation then hit that code, now if its 2022.2 or anything in between that and 6000 will it hit that code? Then finally if neither are true and we're on pre-2022.2 itll hit some legacy implementation?

grand snow
cunning narwhal
#

Sounds good, thanks. I've only had to deal with preprocessor directives with enterprise code stuff so unity is a bit heavy handed with their use but I appreciate that they have these

grand snow
#

yea they are just symbols that are defined for us to let us detect version easier

golden notch
#

For some reason it says it's null when it's not?

zenith cypress
#

amountMesh is null. Notice how the section for it in the log is empty

#

To see it better wrap it in quotations

golden notch
#

it should't be null

zenith cypress
#

It either can't find the object, or it doesn't have that component on it.

golden notch
#

the debug.log shows "object", not n"null"

#

ok so i guess it is null... why is it null? I set it in OnStart

zenith cypress
#

If you mean this, that's the function you are calling. Debug.Log with the object parameter. The log itself will show it being null easier if you wrap the object in quotations. Or Debug.Log($"'{amountMesh}' is null? {amountMesh==null} with amount {amount}");

zenith cypress
#

And in any case, if this is just a label or similar, you can also just expose it to the inspector and assign it there to not have this problem :)

golden notch
#

it's not null