#šŸ’»ā”ƒcode-beginner

1 messages Ā· Page 799 of 1

solar hill
#

its like building a house but you cant actually see anything youre doing the entire time

#

thats what that ai just did for you

ivory dove
#

this is for example 1-3 blocks, the game is 6-7 blocks in total

solar hill
#

i mean all that did was just outline how your project files are going to look lol

swift crag
#

I just finished wasting over an hour arguing with someone over AI hallucinations

solar hill
#

but once again thats purely useless to you lol

#

that is nothing

#

that block is nothing lol

ivory dove
#

i dont wanna look dumb infront of everyone, can i dm you something?

solar hill
#

just ask here

#

dont worry theres no stupid questions

#

people of all skill levels come here

swift crag
#

(i have to wonder what a ScriptableObject "balancer" would do šŸ˜‰ )

ivory dove
solar hill
#

i mean its not going to mean much but sure

#

lets see it

ivory dove
#
  1. Core Simulation & Engine

    Three-Stage Battle Engine: Built a deterministic simulation that resolves every snap via Trench Battles, Skill Duels, and Play Results.

    Tactical Loadout System: Developed a "coaching instruction" layer allowing users to set situational weights (e.g., pass/run bias, 3rd-down aggression).

    The Brain: Created the math-heavy SimulationEngine that calculates yards and success probabilities using player skills, morale, and scheme modifiers.

  2. General Management (GM) Systems

    Roster Architecture: Implemented a 53-man roster system with Practice Squad, Injured Reserve, and salary cap logic.

    Scouting Fog of War: Developed a tiered discovery system where player attributes are revealed from vague letter grades to exact values.

    Draft & Trade Machine: Built an AI-driven trade evaluator and a 7-round draft state machine that prevents logic loops.

  3. Narrative & The "Human Element"

    Locker Room Conflict Engine: Modeled player personalities (Diva, Maverick, Team-First) and how they react to triggers like benching or losing streaks.

    Morale & Performance: Linked psychological states to on-field output, where low morale significantly debuffs player success rates.

  4. Technical Architecture & Data

    SQLite Persistence: Established a robust data layer for saving 15-season careers, player stats, and league history.

    Modding Support: Created a safe import workflow via JSON manifests, allowing users to re-skin teams and logos without breaking the simulation.

    Unity Project Structure: Organized the MVP using UPM (Package Manager) standards and Assembly Definitions for optimized compilation.

  5. Release Readiness & Quality Assurance

    1,000-Season Audit: Ran a headless stress-test harness to verify that league-wide statistics (passing yards, interceptions, etc.) mirror real-world NFL benchmarks.

    Edge-Case Guards: Built "Nuclear" safety protocols to handle bankruptcy, empty rosters, and infinite loops.

    Legal & Launch Prep: Drafted the App Store/Google Play metadata, Privacy Policy, Terms of Service, and Day 1 Patch Notes.

Final Project Status

MVP Ready: YES

Single-Player Career: 100% Feature-Complete.

Multiplayer: Intentionally deferred to the post-launch roadmap for stability.
solar hill
#

right

rich adder
solar hill
#

to this is just

#

what a description

#

what is your plan here though

swift crag
#

unfortunately, this is nothing

solar hill
#

i doubt it wrote any scripts for you

solar hill
#

a few hours ago

swift crag
#

it is just a very enthusiastic list

ivory dove
solar hill
#

right

#

but where are the scripts

rich adder
#

its just gobbledygook

ivory dove
solar hill
ivory dove
rich adder
#

something these generators excel at, spewing words with no real coherent plan

swift crag
#

you should understand that the LLM is just emitting words that you want to hear

#

i saw this exact situation in a GitHub repository a few months ago

swift crag
#

it was allegedly a system for doing full-body tracking by measuring wireless interference

solar hill
swift crag
#

it was a very impressive looking repository

solar hill
#

you cant shortcut around this

#

no amount of ai can help you, youre going to have to learn on your own

swift crag
#

unfortunately, it didn't actually...do anything

#

it was a mile-high pile of framework ideas and no actual software

#

amusingly, this included an AI-generated review of the source code

#

it reported that the code looked great, but that it didn't actually do anything

ivory dove
solar hill
#

probably a real long time

ivory dove
ivory dove
solar hill
#

i dont see it being in your cards any time soon

#

if you are interested in developing

#

im happy to show you where to start

#

but youre going to have to start small

#

you might not even complete a full but very basic game in a year

ivory dove
#

i dont mind starting somewhere, as long as i can get to where i can to achieve what im trying to, im sure itll take time as i have one year left in uni and work as well, so def more than a year i guess

solar hill
#

you probably wont recreate nfl head coach 09 for some long time

#

even longer than a year

swift crag
#

that's the spirit (:

solar hill
#

but im sure if you start learning

#

you will release something

swift crag
#

I started doing game development after quite a few years of programming

solar hill
#

heres the thing, and you dont have to promise anything

#

but you should not use ai

#

while working, while learning especially

swift crag
#

it's fun to bounce ideas off of, I suppose

#

but it gets really messy once you start asking LLMs to make something for you

#

for example, this is a good idea

ivory dove
#

yeah i understand, but i mean is it really wrong 100%?

swift crag
#

Locker Room Conflict Engine: Modeled player personalities (Diva, Maverick, Team-First) and how they react to triggers like benching or losing streaks.

...although "Locker Room Conflict Engine" is one hell of a name for this, haha

solar hill
ivory dove
rich adder
edgy sinew
#

I’ve found AI can be useful for summarizing stuff, or digging up obscure info on something. That kinda stuff.
Like a less reliable Google but can find rare / hard to find info quick.

solar hill
#

also this

rich adder
#

and if you know better, you don't see a point in it

solar hill
#

ai is a yes man

#

we just had a guy here a few hours ago in this server

#

who was convinced he discovered some new revolutionary technology

solar hill
#

turns out ai was just edging him on

#

praising him

solar hill
#

and it lead to what can only be described as delusions of grandeur

#

those are one of the many dangers of relying on ai

ivory dove
#

thats funny ngl

solar hill
#

too much or at all

rich adder
#

I give GPT some basic clerkwork type of shit

solar hill
#

if you must use ai, use it sparingly and with caution, never use anything it gives you if you dont understand it

rich adder
#

"give me a nice json list of first and last names" or some shit

ivory dove
#

i wouldnt rely on it fully, but with coding i know f all, so id usually just ask it to do the code and if any errors come up i send it the error log to fix it

solar hill
#

if youre learning coding

#

all the more reason not to use it

#

you dont have to

rich adder
#

problem solving is 80% of the job

edgy sinew
#

I’ve described Unity related problems to AI with very precise wording and specificity,
It often dug up the exact line of code / solution I needed to solve the issue.

teal viper
solar hill
#

this is a thing that happens as well

#

you have a problem a, ai figures solution b, solution b causes problem c, problem c is now fixed by solution a which is also problem a

rich adder
edgy sinew
rich adder
#

you know by learning, you keep using it and its the calculator effect

#

sure they are quick, but then you kinda lose your own ability to quickly do something in your head

#

if GPT is offline, what now you can't solve something?

solar hill
#

yeah skill atrophy comes quickly if you use ai, even if you use it every now and then iirc

#

a lot of people who use ai to "diagnose issues" and "debug" are just using it to quickly parse a shit ton of google searches that they could have done manually

edgy sinew
#

Definitely not. It was more of a ā€œthis deprecated function in Unity has this behavior and it’s not described in the docs, so you have to do _ to counteract that.ā€

rich adder
#

if gpt found it , technically the info is there if look hard enough

edgy sinew
#

Maybe I could’ve found it searching on Google — yes exactly

rich adder
#

where do you think LLMs are grabbing this data (mostly reddit 🄲 )

solar hill
#

like hmmm what a good use of resources

#

i think its a sign of bad things to come

#

laziness and dependency on instant gratification and results

rich adder
#

I set my search to bypass the AI crap

solar hill
#

theres going to be a generation in a few years that will never venture to the second page of google search results

rich adder
#

there probably wont even be, they are slowly phasing out that structured internet and will soon just be spoon fed answers from an LLM

teal viper
solar hill
#

we just offtopiced a real question

edgy sinew
#

Mb, go ahead Whiterun Guard. Dam even deleted the post

waxen adder
#

Let's say we have a GameObject that has a script attached to it. I make a static class that holds a reference to the script on that game object. What happens to the reference when GameObject gets destroyed?

waxen adder
pastel cave
#

you can have scripts on a gameobject directly...?

edgy sinew
pastel cave
#

Oh. Okay.

rich adder
pastel cave
#

I thought they meant in the ScriptableObject sense

solar hill
#

an SO is just a data container

#

it would have no use even if you could add it directly to an object

pastel cave
edgy sinew
#

I dont think that can be attached to a GameObject. But a Component can have a space to contain a ScriptableObject instance.

rich adder
#

ScriptableObject are pretty wacky , they are very similiar to static classes in certain aspects mixed with some POCO

waxen adder
edgy sinew
rich adder
#

they certainly can be very useful also for sharing data across gameobjects without them referencing each other

pastel cave
#

Never did it again either

#

Perhaps it was a coincidence? I have no clue.

rich adder
#

could be anything

edgy sinew
#

Haven’t heard of that one yet. Yeah ^ could be anything literally

rich adder
#

if you're interested, best check the crash log with the stack trace usually you can get some kinda of idea

pastel cave
#

One downside of learning a new engine: learning all the ways you can make it unstable I guess

rich adder
#

but also the version of unity you use matters too

edgy sinew
rich adder
#

been using the same unity version and have yet to encounter a crash, I think it only happened once cause of Probuilder

pastel cave
rich adder
#

I didnt even touch 6.3 yet

#

most of my projects are still on 6.0.33f1

#

I use patcher for binary and have old Unity Hub so it doesn't bug me about "security fix" bs

pastel cave
#

My unity hub keeps pestering me to install 6.3 so I can go through its tutorial stuff

rich adder
#

ima let 6.3 mature a bit before switching over

pastel cave
#

Very valid

rich adder
#

CoreCLR is the main thing me and most been waiting on

pastel cave
pastel cave
rich adder
#

basically the new .NET thats multi-platform

#

compatibility for one, newer packages, having the latest c# features etc.

pastel cave
rich adder
#

2027 will be in Experimental Preview with 6.7LTS

pastel cave
#

Is this like

#

Some weird unity specific versioning system I don't know about

rich adder
#

Half the time I think even Unity doesn't know what Unity says

pastel cave
#

Something something pricing fiasco

sinful zinc
#

is there a way to adjust the speed a cinemachine camera will re adjust at when i change the Follow

rich adder
#

maybe you can have two of them, one with diff target use the blend mode if you need to control speed from one cam to another

prime goblet
#

of unity

#

forever

#

would it not be better for the lts to get more features? or are they scared that if they screw something up they'll have to actually maintain it

slender nymph
#

that just happens to coincide with the 6.4 release

prime goblet
#

6.4 is definitely the proof of concept for the version of unity that's been out for a long while now

slender nymph
prime goblet
#

ah

#

that makes sense

swift crag
#

i have no clue how to order these things

rancid obsidian
#

Hello. I've been trying to get the material swap animation to work with an object in Unity, but everytime I enter play mode, all the skinned mesh renderer keyframes disappear for that animation, and only those. Is there any fix to this?

hybrid gust
#

So, I'm trying to wrap my head around adressables. But at this point I'm not sure I even have the right use case for using them.

My thought process was to have some easy data structure that lets me easily add prefabs and scriptableobject data in a way where I can reference subsets of them all at once.

That SOUNDS like something I should be able to do with the Adressables right? Even resource I've come across has started to make me question if its really just intended for remote stuff.

sour palm
#

hay I'm having an issue with my wall grabbing. its working mostly fine now but when jumping and then try to grab a wall the player will often times just launched up into the air.

teal viper
hybrid gust
#

I only figured I'd give them a try so I didn't have to use streaming assets or resources tbh

#

But there isn't any cavet to using it that way is what you're saying?

teal viper
#

I don't entirely understand whta you're trying to do. But addressables is just a way to load assets. That's basically it.

teal viper
hybrid gust
lilac coral
#

hi ive had something thats been putting me of starting unitty its that when i was following a tutorial my coding stuff wast like linked ppl told me to activate it in unity but idk how

slender nymph
#

!ide

radiant voidBOT
lilac coral
slender nymph
#

what do you even mean by that

lilac coral
#

i have

slender nymph
#

do you know the difference between the unity editor and the unity hub?

lilac coral
austere kraken
#

How Optimize my Game?

wintry quarry
slender nymph
#

start by using the profiler to determine where your actual performance issues are coming from

slender nymph
austere kraken
lilac coral
austere kraken
lilac coral
#

i dont think ik what it is either

lilac coral
slender nymph
lilac coral
#

oooh ok holon

slender nymph
#

presumably you are referring to the editor as the "unity engine"

austere kraken
#

Why unity don't have work room like blender bro whyyy

#

VC

#

channels

wintry quarry
#

Because they can't moderate them

austere kraken
#

But blender Have?

naive pawn
#

their problem to deal with then

wintry quarry
lilac coral
naive pawn
wintry quarry
lilac coral
wintry quarry
#

you likely won't get IDE configured properly until the compile errors are fixed

naive pawn
#

!ide

radiant voidBOT
wintry quarry
young sapphire
#

HOW DIFFICULT IS UNITY FOR AN ABSOLUTE BEGINEER AT CODING I ONLY HAVE EXP IN CODING C# FOR 2 APPS I MADE

wintry quarry
# naive pawn !ide

If there are compile errors doesn't it sommetimes block/stop the IDE packages from compiling?

#

sort of a chicken and egg problem

austere kraken
wintry quarry
lilac coral
wintry quarry
#

read it

young sapphire
wintry quarry
#

no

naive pawn
# radiant void

@lilac coral configure your ide, and there'll be a highlight telling you where

naive pawn
austere kraken
#

Show You script Screenshot bro

lilac coral
naive pawn
#

trying to configure your ide for an hour?

austere kraken
young sapphire
#

how much money can i make as a solo dev using unity

wintry quarry
#

$12

#

at least

naive pawn
#

12Ā¢

young sapphire
#

every day?

naive pawn
#

there's no solid answer for that

young sapphire
#

oh wow thats allot

naive pawn
#

it could be 0, it could be -$100, it could be +$4k

#

don't fall into survivorship bias

young sapphire
naive pawn
#

all the solo devs you know of are successful, because you don't hear about the unsuccessful ones

#

Survivorship bias or survival bias is the logical error of concentrating on entities that passed a selection process while overlooking those that did not. This can lead to incorrect conclusions because of incomplete data.
Survivorship bias is a form of sampling bias that can lead to overly optimistic beliefs because multiple failures are overloo...

austere kraken
#

and play store take 25$ to Publish games

young sapphire
#

whats harder making game on pc or mobile?

austere kraken
naive pawn
#

do you mean developing on mobile or developing for mobile

#

those are very different questions

young sapphire
#

developing for mobile

#

ill make the game on my pc

naive pawn
#

oh, then it's impossible to answer then

austere kraken
#

Mobile one harder like godot

naive pawn
#

all the questions you're asking here are subjective and specific to you, your experience, your preferences, your expectations, your goals.

young sapphire
#

so its easier to make a game on pc for mobile

naive pawn
#

no

young sapphire
#

ok

naive pawn
#

and neither is the inverse

young sapphire
#

is C# used in Unity

naive pawn
#

yes, have you done any research

young sapphire
#

no thats why im askin

naive pawn
#

you should do research

austere kraken
#

can anyone tell me what to know from frame debug i m new in it

young sapphire
#

ok but thats boring

naive pawn
#

it's boring to answer these very googlable questions for a beginner who doesn't want to utilize any other resource too

#

the internet is a vast expanse of knowledge, use it

#

knowing how to research for information is a crucial skill, you won't get very far if you refuse to practice that

sage hedge
#

hey i need a friction system in my game some one can help me

lilac coral
#

hi

#

this is apparentl not working

wintry quarry
lilac coral
#

idek

wintry quarry
# lilac coral

looks like you have a compile error, and your IDE is still not configured 😬

wintry quarry
#

did you save the code?

lilac coral
#

i give up with ts atp

#

yes

livid anchor
#

Hey a question if you will. When using the "AddComponent" method, can I pass a script I instantiate ?
Like I make a script = new MyScript(); then AddComponet(script) ?

sour fulcrum
#

You can’t make a new Instance of a UnityEngine class because of Unity specific reasons but AddComponent does return the component it’s going to make, as stated in the docs

#

So you can just do

MyClassType newInstance = go.AddComponent<MyClassType>();

livid anchor
#

Ok well too bad. Adding the script to a gameobject and getting the returned script instance was what I was doing but i was hoping to refactor that code

sour fulcrum
#

Why would you want to refactor that?

teal viper
#

"The code is not good enough! Let's make it worse!"

livid anchor
#

I have three class deriving from an interface, I randomely assign one of the scripts to a gameobject and use it through the interface

So I would have like to : create a Iscript variable, attribute a random derived script then add the Iscript variable to the gameobject

teal viper
#

You can freely cast an instance of a class to an interface that it implements.

#

Not entirely sure if you know that and whether that's related to what you're trying to do or not though. The explanation is all over the place.

#
Iscript maybeClassField = Instantiate<IscriptImplClass>();
livid anchor
#

Right now i have that :

private IPickUp ChoosePickUp(GameObject pickUp)
{
    IPickUp script;

    if (GetSpawnOccurence(_tailKillerPUSpawnChance))
    {
        script = pickUp.AddComponent<TailKillerPickUp>();
    }
    else if (GetSpawnOccurence(_enemyKillerPUSpawnChance))
    {
        script = pickUp.AddComponent<EnemyKillerPickUp>();
    }
    else
    {
        script = pickUp.AddComponent<NormalPickUp>();
    }

    return script;
} ```

I would have preferred to add the component right at the end in an agnostic way
teal viper
#

What component though? There seem to be several.

livid anchor
#

Only one component can be added in that method, depending on a random chance of spawning.

teal viper
#

Yes, but you still need to decide which one is added. Thus I don't get what you're trying to do.

#

Oh, you want to avoid writing Add Component several times?

livid anchor
#

I just wanted to assign an existing instance of a script

teal viper
#

Is that it? Just reducing code to type?

teal viper
#

Well, you can't really do that. The problem is that MonoBehaviours can't live outside of a gameobject, so you can't create it separately and add later.

#

What you could do is either make it not a MonoBehaviour, or use generics maybe.

livid anchor
#

Can't we somehow get a variable for the type of script we want to assign ?

#

Something like that ?

#

System.Type type = typeof(NormalPickUp);
pickUp.AddComponent<type>();

ivory bobcat
#

It looks like a unnecessary helper method.

livid anchor
#

I have to test but apparently I can write that :
script = pickUp.AddComponent(scriptType) as IPickUp;

short gust
#

is using ScriptableObjects as sort of "builder/template" object for creating runtime objects from them - bad idea in general? they would just populate configured data into object on creation and give it to someone else and not store the reference itself.

ivory bobcat
livid anchor
#

Why ?

#

The pickUp gameobject exists, and I'm just adding a component.
previously I was doing that : script = pickUp.AddComponent<NormalPickUp>();

And it worked

ivory bobcat
#

Nevermind, it's late night here

livid anchor
#

Is it sleepy time ?

sour fulcrum
halcyon moon
#

what happened to my project??? i tried to build it normaly but it gave me this. and now nothing is working

midnight plover
#

Maybe you have some platform dependent code or you have some editor code that cant run on build.

hexed terrace
#

The error tells you when there's editor only code

minor pier
#

hey all, i had a small curiosity, i have a dream of making a metroidvania and idk if i will ever get to it but i do like to gather some knowledge if i would start on it.
Im making a movement system rn and i had a curiosity on what the best way is to make a grounded check, most of my friends/classmates just use the rigidbody of the player with on colission enter colliding with the ground tag and i found another way to do it recently by putting a small trigger under the player's body so it doesnt give you your jumping capability back when colliding with the roof or walls, but it has some flaws here and there and i had the curiosity, how do u all do it usually and whats the most practical way to do it?
im doing 2d btw, and im trying to figure out what works best as i seem not to be able to bunny hop like for example in hollow knight or silksong, it sometimes bugs a little and stops me from jumping for a sec.

midnight plover
minor pier
#

hmm sounds interesting! i havent rlly worked with raycasts yet so i may needa do some research on that to make it work, but ty for the help btw :)

#

does anyone know how silksong and hk do it btw?

polar acorn
halcyon moon
#

ok

halcyon moon
#

it was justa faulty compiler error

polar acorn
#

To be honest I just plugged in the error into google and scrolled past all the AI and found it pretty quick on stack overflow. But it makes sense, some sort of file failed to load, and since build profiles are cached a restart wouldn't fix it, so you gotta swap em out

sour palm
#

hay is it possible I could talk to someone in a voice chat to get some help

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
#

voice chat eliminates the benefits of a community server.

sour palm
#

ok then here. I having an issue with my ledge grab. can you help?

midnight plover
radiant voidBOT
naive pawn
#

not with that limited context, no

rough granite
naive pawn
#

didn't you have a thread for this

sour palm
#

I did at 1 am.

naive pawn
#

doesn't seem like you've added any further info about what issues you're having

sour palm
#

ok here the issue I'm having is that my ledge grab keeps launching my player upwards.

naive pawn
#

use your thread, and this is not an appropriate method to show code

#

you were given instructions above

glass summit
#

Why is TMPro grayed out?

polar acorn
#

You probably already have the namespace imported

glass summit
swift crag
#

presumably, you don't have a using TMPro; directive at the top of those scripts

glass summit
swift crag
#

There is no problem in any of your scripts. The IDE is just pointing out that the TMPro namespace is not necessary in this instance, because you already have a using TMPro; directive at the top

glass summit
polar acorn
swift crag
#

In the script you linked here, there is no using TMPro; directive

glass summit
polar acorn
swift crag
polar acorn
#

If you don't have the namespace imported, you need to fully qualify the type, including all namespaces

#

If you import the namespace at the top, you don't have to do that

glass summit
#

OHHH

#

Ok

#

thanks

oak spoke
#

has anyone any idea how to make my cam to be 3d person but will be semi top down

slender nymph
#

this is a code channel.
also obligatory: use cinemachine

pastel cave
#

So is dynamic rigidbody supposed to be the catchall for practically everything that isn't static?
Kinematic seems very... unuseful

polar acorn
#

A kinematic rigidbody is one that can exert forces, but doesn't respond to them. It's meant for things directly controlled by code, so it's great for player characters

broken nest
#

Hey, can I make a coroutine run faster than update?

grand snow
#

yea, do two loops each update šŸ˜†

broken nest
#

No way ahaha

grand snow
broken nest
#

I was thinking like 0.001ms

grand snow
#

!code

radiant voidBOT
broken nest
#

Cna I do yield return new WaitForSeconds(0.001f

slender nymph
#

that would be pointless as you are bound by the speed of Update

broken nest
#

okok

grand snow
#

Yes but there is no guarantee it has waited that amount of time (its framerate dependant)

#

60 fps is 0.016ms per frame

broken nest
#

okok thanks

grand snow
#

Usually we use delta time to adjust things to be framerate independent and for us to count up accurately

rough granite
grand snow
west quail
#

guys what is a dot product šŸ’” all the answers i saw on google i dont understand. if someone could explain it a bit that would be nicenotlikethis

polar acorn
#

It's basically "sameness percentage"

west quail
#

or in between too

swift crag
#

no, those are the extreme values

west quail
#

alr yeah makes sense since its a float

polar acorn
#

Take a vector and check its dot product with, say, due north. If it's got a dot product of 0.7, it's about 70% north

swift crag
#

also, this only holds for unit-length vectors

#

i.e. normalized vectors

polar acorn
#

So, not quite due north but still pretty north

swift crag
#

so dotting (10, 0, 0) with (1, 0, 0) gives you a result of 10

polar acorn
#

Example use: "When someone is looking somewhat in the direction of Slender Man, play a static effect" becomes something like:

if (Vector3.Dot(player.transform.forward, directionToSlenderman) > 0.8f){
  playStatic();
}
swift crag
#

You can also use Vector3.Angle if you want an angle

#

(the dot product gives you the cosine of the angle, hence why it's 1 when the vectors align and -1 when they're opposing)

west quail
#

alright this makes much more sense than any other explanation

polar acorn
#

It has some major importance in math, but we don't care about how to compute it or any of those other properties, we just care about the results. Game developers get to cheat on a lot of this vector math stuff by not needing to know the why of things

grand snow
#

Quaternions 😭
Euler Angles šŸ™‚

broken nest
swift crag
west quail
swift crag
#

not "run something really fast"

#

explain what you are trying to make your game do

grand snow
broken nest
#

I want to get data

swift crag
grand snow
#

share some code

broken nest
#

I want to simulate something higher than the framerate to get the data

swift crag
#

Vector3.Dot(foo.normalized, bar.normalized) is sufficient

swift crag
west quail
#

thx

swift crag
#
void Update() {
  timer += Time.deltaTime;
  while (timer > 0) {
    RunStep();
    timer -= 0.001f;
  }
}
#

this executes RunStep once per millisecond

#

note that it's not running the method, waiting one millisecond, running it again, waiting again, etc.

#

it's running the method many times in a row per frame

broken nest
eternal needle
west quail
#

i would guess so

swift crag
swift crag
eternal needle
#

Like what data is this and why does it have to be every ms. You cant render anything with this within that time step regardless

grand snow
#

Till you share something we cant show you how to actually do this properly šŸ˜†

broken nest
swift crag
#

explain what you want your game to do

polar acorn
swift crag
#

do not tell us any technical details

grand snow
broken nest
#

I want to create an array with the position of an object every 0.001s while it's moving

polar acorn
#

If you want something to run faster than the frame rate, run it multiple times a frame.

void Update(){
  doThing();
}

Does 60 things a second.

void Update(){
  doThing();
  doThing();
}

Does 120 things a second.

swift crag
#

do not express this in terms of code

eternal needle
#

The position is never gonna update between milliseconds if update hasn't run..

swift crag
#

only tell us what the resulting gameplay will be

polar acorn
#

Not what are you trying to do

swift crag
#

I think you're experiencing the XY Problem right now, where you--

#

dammit

broken nest
#

I want to make an array like this
t= 0s x=0 y=0 z=0
t= 0.001s x=1 y=0 z=0

polar acorn
#

then why are you doing this

#

The solution? Don't do it.

grand snow
#

Is this rage bait or what

polar acorn
#

If that doesn't work to solve your problem you'll need to explain why

#

Because until you give a reason otherwise, the solution is "Don't"

#

Not doing something is always easier than doing something

swift crag
broken nest
swift crag
#

because you are continuing to not tell us what your actual gameplay goal is

polar acorn
#

it seems like you don't even know

swift crag
#

we know you're trying to make an array with the positions of an object at sub-frame intervals

#

i wonder if you're trying to draw a trail behind a fast-moving object

broken nest
#

There's a cube that moves along axis X in game at 1 unit per second.
The cube is shown to the screen every frame.
I want to move the cube along the X axis in game, AND get its position with better precision than the frame rate

grand snow
#

but why

polar acorn
#

Why do you need the position more precise than the frame rate

#

What is the purpose of doing that

grand snow
#

If you move by x amount a frame there is no better precision

broken nest
#

To get the data

polar acorn
#

For what purpose

broken nest
#

Say put it in a notepad whatever

grand snow
#

If its a linear move then you can just fill in the gaps yourself

pastel cave
#

What data? It's a position

eternal needle
#

If it moves 1 unit per second just do the math lol, you dont need to read the position then

polar acorn
grand snow
broken nest
#

Holy shit I understand sorry I'm dumb ><

polar acorn
#

You see how asking the attempted solution got you nowhere, but stating the actual problem found a better way?

pastel cave
#

Honestly I dunno if this was an X/Y problem it was just confusing

#

We didn't get any information on what Y really is

eternal needle
#

It most definitely is. With the current info, id see no reason to even use unity for this. Just write a for loop interval of 0.001, printing t and x as the same value

pastel cave
#

Okay yeah that's true I guess it's an unsolved X/Y problem

eternal needle
#

Unity is gonna be less accurate than the data they want. I'm sure floating point precision alone would cause some of those values to not line up 100% mathematically

pearl spruce
#

hey guys im trying to make a vr game in unity and i managed to link my vr to my pc but when i try to run the project it says i cant because its an unknown source or smth does anyone know how to fix this?

rich adder
pearl spruce
#

i didnt find the channel

rich adder
pure pine
#

anyone can help me make this code rotate based on the players direction of looking? cus rn the 3rd person pov just stays in place while following the player regardless of their rotation

rich adder
pure pine
#

Nvm i found a yt video

#

Thanks for the tip tho

pure pine
#

Cus im trynna learn not use a tool

#

Ty @timber tide

slender nymph
#

well if you want to learn and you don't want to use any tools, then why are using a game engine?

pure pine
slender nymph
#

but it's literally the same concept

pure pine
slender nymph
#

you're using a game engine so you don't have to learn the fine details about rendering, asset management, etc.
cinemachine is a unity package that is meant to help you set up a good camera easily without needing to manually set it up just like all that other stuff you are skipping learning

#

and if you're against packages then you can't use the built in UI stuff because that is a package, so does that mean you're going to learn how to manually create and render UI? or is that a package you're willing to use?

pure pine
#

Thanks for the info tho UnityChanThumbsUp

slender nymph
#

here's a hint: you'll be using the components from the UI package. especially if you follow literally any tutorial for it

ripe spear
#

following along with the make a rogue like game, and having trouble with the make a character step, specifically a NullReferenceException, stopping my character going into the tilemap, is this a hierarchy issue or code or something else?

slender nymph
ripe spear
#

I had a look through here while researching my problem, but haven't been able to find a solution, also it's not mentioned in the docs so I guess I've misunderstood an instruction:

https://learn.unity.com/course/2d-roguelike-tutorial/tutorial/add-a-player-character?version=6.3

Unity Learn

In the previous tutorial, you created the game board for your game; the next piece of functionality to add is a player character that can traverse the board.

By the end of this tutorial, you’ll have done the following:

Created a

PlayerCharacter

GameObject using one of the provided assets.

Ensured that the

PlayerCharacter

GameObject ...

slender nymph
#

did you read through all of the information that is provided by the steps in the page i linked?

ripe spear
#

As far as I am aware, yes

slender nymph
#

then you should know that the stack trace is necessary to even begin to troubleshoot this

ripe spear
#

oh i misread ur question, my bad, 5 mins

#
BoardManager.CellToWorld (UnityEngine.Vector2Int cellIndex) (at Assets/scripts/BoardManager.cs:20)```

this is saying the stack trace issue is occurring here:

public Vector3 CellToWorld(Vector2Int cellIndex) {
return m_Grid.GetCellCenterWorld((Vector3Int) cellIndex);
}


but I init m_Grid several lines beforehand, using ` private Grid m_Grid; `
slender nymph
#

that's where you declare it, but where do you actually assign it

ripe spear
hybrid gust
#

If I used a scriptableobject to hold data (sprites, textures, etc) for a single object, then made everything addressable. I should be able to reference just the parts of the object I need by instantiating them via the handle for the scriptable object data?

#

Does that sound right?

#

So long as the handle's for the scriptable objects stay alive, the referenced textures, sprites, ect should also be loaded?

harsh tartan
#

Why does it say Mismatch at my prehabs but in my hierarchy its correct?

using System.Collections;
public class NpcMoveManagement : MonoBehaviour
{
    public float moveSpeed = 3.0f;
    public float arriveDistance = 0.1f;
    public float turnSpeed = 720f;


    public Transform targetPoint; // NPC_DoorEntrance
    public float waitAtTargetSeconds = 2f;

    bool isWaiting;
    bool hasArrived;

    void Update()
    {
        if (isWaiting || hasArrived)
            return;

        if (targetPoint == null)
            return;

        Vector3 toTarget = targetPoint.position - transform.position;
        float distance = toTarget.magnitude;

        if (distance <= arriveDistance)
        {
            OnArrived();
            return;
        }

        Vector3 direction = toTarget.normalized;

        if (direction.sqrMagnitude > 0f)
        {
            Quaternion targetRotation = Quaternion.LookRotation(direction);
            transform.rotation = Quaternion.RotateTowards(transform.rotation, targetRotation, turnSpeed * Time.deltaTime);
        }

        transform.position += transform.forward * moveSpeed * Time.deltaTime;
    }

    void OnArrived()
    {
        hasArrived = true;
        Debug.Log($"{name} reached {targetPoint.name}.");
        StartCoroutine(WaitAtTarget());
    }

    IEnumerator WaitAtTarget()
    {
        isWaiting = true;
        yield return new WaitForSeconds(waitAtTargetSeconds);
        isWaiting = false;
    }
}
ivory bobcat
ivory bobcat
mild mulch
#

I was following the Roll-A-Ball course and I can't playtest it becasue I "need to fix errors", can someone help me pls?

ivory bobcat
hexed terrace
#

Your visual studio isn't setup correctly. Follow the guide below to do it.

#

!vs

radiant voidBOT
# hexed terrace !vs
Visual Studio guide

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

• Visual Studio (Installed via Unity Hub)
• Visual Studio (Installed manually)

mild mulch
hexed terrace
#

that's why your visual studio isn't highlighting errors

#

it's also a requirement to get help in here

#

there is another problem with line 19 that VS hasn't highlighted because you haven't got it setup correctly

ivory bobcat
#

And yeah, it's required to have a configured ide to get support on the official unity discord server

harsh tartan
ivory bobcat
harsh tartan
ivory bobcat
mild mulch
harsh tartan
#

how do I make it so when they get cloned they get that target? as now they just choose a random target?

#

I need to set the target in my script or?

ivory bobcat
#

The manager or whoever spawns it should somehow have a reference to it.

harsh tartan
#

Thanks

mild mulch
#

and how can I add that?

ivory bobcat
#

Compare your line with their line. You should've missed the assignment operator.

mild mulch
#

šŸ‘

harsh tartan
# ivory bobcat ```cs var instant = Instantiate(...); instant.field = ...;```

Thanks I did:

    void SpawnNPC()
    {
        if (GameObject.FindGameObjectsWithTag("NPC").Length >= maxNPCs)
        {
            return; 
        } else {
        int randomIndex = UnityEngine.Random.Range(0, npcPrefabs.Length);
        GameObject npc = Instantiate(npcPrefabs[randomIndex], transform.position, Quaternion.identity);
        npc.GetComponent<NpcMoveManagement>().targetPoint = GameObject.Find("Npc_Entrance").transform;
        Debug.Log("Spawned NPC: " + npc.name + " at " + DateTime.Now);
        }
    }```

And now it works
marsh void
#

hi does anyone have good yt video that introduce to doing ai in unity?

chrome tide
hexed terrace
marsh void
chrome tide
# marsh void enemy behaviours. ML angents are too advance for me

you should understand basic concepts such as navmesh (so that your enemies avoid obstacles), raycasts (so that your enemies see) etc. you could start with a simple enemy that chases the player when they see/it gets too close, a quick youtube search should give you one of those tutorials. it will help you to understand patterns such as a State Machine if you want to create more advanced enemy behaviours. you could also take a look at how other games do these kind of enemies, such as Lethal Company

marsh void
#

thanks

rose gorge
#

how should i go about making a keyboard based movement system on an isometric map/game with direction based animations? (2d)

rocky whale
#

!code

radiant voidBOT
rocky whale
#

this is my code for making the gameobject move along with the cursor
the value for Mouse.current.position.ReadValue() is in the 100s when its pointing at 0,0 in game view?

using UnityEngine;
using UnityEngine.InputSystem;

public class SetBlock : MonoBehaviour
{

    // Update is called once per frame
    void Update()
    {
        transform.position=Mouse.current.position.ReadValue();
    }
}
thick root
naive pawn
#

please consider sending your question along with or even before sending the code

chrome tide
keen dew
naive pawn
# rocky whale this is my code for making the gameobject move along with the cursor the value f...

mouse position is often provided in screenspace, not worldspace.
though seems like the inputsystem one is provided in window space, according to docs: Pointer.position

i haven't actually seen this space before tbh, not sure if it'd be interchangeable with screenspace.
for screenspace, you'd use Camera.ScreenToWorldPoint to convert to worldspace.

i guess try that? i couldn't find a specific conversion function from windowspace to.. anything else, really. the Display class seems pretty barebones

#

is this windowspace/display thing just to disambiguate between the entire physical screen vs the rendered screen thonk

rocky whale
#

the movement works after converting but for some reason the sprite doesnt render in game view (my cursor isnt there cuz of taking the ss)

ivory bobcat
#

Normally you'd have to set the z value of position to some value away from the camera position (which the screen point would be relative to)

rocky whale
#

Ahhh forgot abt the z axis, thanks!

dim frigate
#

I'm new to unity and I made this code for player movement with an input for every idle position sprite. BUT when I put .png sprites or .gif sprites in the input they don't show while I'm playing the game the player is invisible... why?
code: https://paste.mod.gg/byaxpjxqifem/0

opal zodiac
#

YOO anyone able to help me understand constructors and why i have to compose new objects on awake ?

teal viper
naive pawn
#

anyone able to help me understand constructors
is there a specific question you have in mind, or a specific aspect you don't understand?
if not, go look at existing resources.
why i have to compose new objects on awake
you don't in general. maybe you do for the specific task you're doing, but that's unrelated to constructors in general

hot talon
#

hi when buttons clicked my panels not working please help me

naive pawn
hot talon
hot talon
naive pawn
#

start debugging through the chain of events that should happen. check your listener - is it being triggered?
if so, the issue is in the activation or whatever after that
if not, the issue is with the button or the event

swift crag
#

you can tell if a function is being called by using Debug.Log

hot talon
#

I checked with Debug.Log, and the listener is being triggered. The message shows up in the console

naive pawn
#

ok, then something after that isn't working. if you have conditionals, check if they're being passed

swift crag
#

okay, that's a good start

naive pawn
#

if you're not sure what to check next, start with sharing the relevant code so we can give more specific advice i guess

#

!code

radiant voidBOT
hexed terrace
hot talon
tribal fulcrum
dim frigate
hexed terrace
hexed terrace
#

When sharing screenshots, pls make sure that the inspector is actually visible, you've got it squished over hiding a lot of information

dim frigate
hexed terrace
naive pawn
naive pawn
hexed terrace
#

ah, overridden - didn't read that line

dim frigate
hexed terrace
#

you're gonna need to record a video of what's happening.. show the issue, and then pause the game -> select the player, the scene view and find where the player is

#

Make sure the inspector is visible and actuallly useful (not hiding like in the screenshots)

warm crater
#

Should I use Player Input

nocturne pond
#

Hey everyone so im learning C# and in the lessons about variables and declaring them it says to declare them right before you use them so essentially in the same line of code. Although for game developpement is it better to declare all the variables before at the top or while using them since in gamedev we reuse variables quite often?

solar hill
#

it really depends for which reason youre declaring them

wintry quarry
#

in the minimal scope required

#

if it's something you need to store state over the lifetime of the object, then it should be a field at the top.

If it's a local variable, declare it as late as possible.

#

the smaller the scope of a variable, the easier it is to read the code, because you need to remember less context.

nocturne pond
wintry quarry
#

"at the top" are typically fields, yess

#

beginners tend to overuse fields in places where local variables will do fine

nocturne pond
wintry quarry
hexed terrace
#

field is the name for the variables declared (usually) at the top of a class, outside of a method

nocturne pond
#

okay

wintry quarry
#

They're essentially bits of data that are part of the object that the class defines. Like properties of the object. For example a balloon might have a color field, or an Animal might have a legCount field

nocturne pond
#

okay

wintry quarry
#

this is opposed to a local variable which is ephemeral and only exists for as long as the scope it's defined in.
For example you might declare a local variable to hold osme intermediate calculation value that is created and consumed immediately.

// Calculating the area of a triangle:
float baseByHeight = b * h;
float area = baseByHeight  / 2f;```
dim frigate
nocturne pond
wintry quarry
#

both of those are local variables, because they are declared inside a method

nocturne pond
wintry quarry
#

a field would be declared inside the class, but outside of any method

nocturne pond
#

okay

wintry quarry
#
class Example {
  string myField;

  void SomeMethod() {
    string someLocalVariable;
  }
}```
nocturne pond
nocturne pond
#

so i still dont understand how i would choose which to put in field and which to put as normal is field for variabled repeated many times throughout the whole code and normal variables just used a few times or otherwise?

frail hawk
#

then you lack of c# basics

solar hill
#

i wouldnt say this is necessarily c# basics

#

mostly just basics of programming in general

#

fundamentals* should say

naive pawn
nocturne pond
solar hill
#

i dont think he was implying its wrong

#

he was just pointing out why you lack that understanding to begin with

nocturne pond
solar hill
#

i think you might need to take that chip of your shoulder

nocturne pond
solar hill
#

we are here to help

solar hill
#

its not abnormal nor was it hostile lol

naive pawn
#

there are some prerequisites in programming that you need to know before going on to learn other things. that's just a fact, it's not bad to not know them - nobody starts off knowing everything of course

frail hawk
#

i am trying to tell you that you need to learn the basics of programming nothing more nothign less

nocturne pond
#

okay well im not trying to be rude i just don't feel there is a need to say you lack of something in programming to a beginner whos young so might have a harder time understanding different notions?

nocturne pond
frail hawk
#

fine, keep up the hard work

nocturne pond
naive pawn
nocturne pond
solar hill
#

theres more to programming than jut understanding a certain syntax as well

naive pawn
#

i'd also like to note that there's kind of a separation between knowledge and experience - this is kind of a concept that relies on both
knowledge about how scoping works, and the experience to understand what should be scoped where

naive pawn
#

docs/guides can only get you so far, specifically in the knowledge aspect
you gotta try stuff yourself for the experience aspect

nocturne pond
naive pawn
#

ides also have great tools for that process, namely moving lines (alt+up/down in vscode, not sure for other ides)

nocturne pond
#

alright

edgy tangle
#

I’m of the opinion that starting out it’s fine to overuse fields. With experience you will learn why it’s bad to overuse them, but to start out you shouldn’t be too concerned with scope. Just take the approach that helps you best understand what you’re trying to implement

#

I think every programmer years down the line (or even weeks or months) can look back at their old code and cringe at how poorly it’s written. That’s normal. It’ll happen to you. So don’t worry about doing things in ideal ways yet.

naive pawn
#

cringeing at your old [anything] just means you've improved

solar hill
#

documentation is very essential

naive pawn
#

[insert sheldon "Why? WHY?! Oh, that's why." gif here]

edgy tangle
#

I wanted to send the gif of grandpa Simpson saying ā€œIt’ll happen to you!ā€ with my comments but sadly cannot… 🄲

cosmic dagger
#

It inevitably happens. You'll start with a small class that grows into some big, yet efficient production-ready asset (code) . . .

sullen arrow
#

Hey guys, Im trying to have scoring system that will update after player pick up object, then the object dissapear. The disappearing part is work but the score is not.

cosmic dagger
rancid tinsel
#

I thought this tells the compiler to ignore it, but it is treating it as a duplicate variable name - could someone explain this to me?

sullen arrow
cosmic dagger
naive pawn
#

otherwise if it were treated as a discard it'd be ambiguous

cosmic dagger
# rancid tinsel

You have two names that are the same because it's the same character. Just put separate names for each parameter . . .

wooden cradle
#

hello i need help with this

cosmic dagger
rancid tinsel
sullen arrow
cosmic dagger
# wooden cradle yes

From the error message that popped up, does the class derives from MonoBehaviour?

ivory bobcat
# wooden cradle yes

It's not a component if it doesn't inherit from Mono Behaviour. What exactly are you trying to do?

wooden cradle
ivory bobcat
wooden cradle
solar hill
#

this isnt the script giving you the error message.

ivory bobcat
wooden cradle
#

im new so i dont really know

solar hill
#

"PlayerMovement"

#

do you have a script called that

wooden cradle
#

no this was in a old project this one is another but still giving the error

solar hill
#

so youre getting the error for "PlayerMovement" when you try to add FPSMovement to the object?

cosmic dagger
#

but you sent us a script called FPSMovement. Did you rename it?

wooden cradle
ivory bobcat
wooden cradle
#

forget the playermovement this was a another project

wintry quarry
# wooden cradle

Step one make sure there are no errors in your console window on Unity

cosmic dagger
solar hill
wooden cradle
sullen arrow
cosmic dagger
wintry quarry
#

It should be open at all times, it's vitally important

wooden cradle
cosmic dagger
solar hill
radiant voidBOT
wooden cradle
#

oh can someone teach me to do basic 1 person movement ?

sullen arrow
wooden cradle
solar hill
#

what

#

just send it here

wooden cradle
#

oh

solar hill
#

please also read the bot messages...

radiant voidBOT
cosmic dagger
#

No, copy-paste it into a code website, then send us the link to view it . . .

wooden cradle
#

ohhhhh

#

okay

#

and its a chatgpt script sooo

ivory bobcat
cosmic dagger
solar hill
#

because why should we

wooden cradle
solar hill
#

you didnt bother making it why should we waste our time fixing it

wooden cradle
#

its just that i dont understand the monobehavior error i just want to know how to fix it

wintry quarry
#

Because look at your script

#

it clearly doesn't derive from MonoBehaviour

#

you probably have more than one script with the same name or something

#

but the one you're trying to drag is not a MonoBehaviour

cosmic dagger
ivory bobcat
# wooden cradle <:503error:1068124152424300544>

The volunteers here might be willing to help you fix something you've thought of and written up yourself (or with the help of a tutorial). But most aren't willing to fix code written by AI because the AI will likely not write coherent/good code - sometimes making absolutely no sense.

wintry quarry
#

so either it's a different file, or you need to refresh your assets, or restart Unity

cosmic dagger
#

or save it . . .

wooden cradle
#

i think its better if i restart a project

solar hill
#

i think you should ditch the ai and learn unity the normal way

radiant voidBOT
#

:teacher: Unity Learn ↗

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

wooden cradle
radiant voidBOT
#

:teacher: Unity Learn ↗

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

solar hill
#

youre mising some important fundamentals of the unity editor

#

see that you learn that first

sullen arrow
#

I was able to fix up the counter not updating, now I just have to fix the UI text not updating with it.

cosmic dagger
#

@sullen arrow Instead of directly accessing (and changing) the counter variable, you should call a method on the CoinManager. This method should add to the counter variable, and update the UI text. Doing this will avoid constantly assigning the UI text every frame in Update . . .

sullen arrow
frail hawk
#

show new code and explain what is not working

sullen arrow
#

I havent change anything so far, I incorrectly linked? the coinManager script with my player, os that was why the counter wasnt updating. @frail hawk

ivory bobcat
#

Are you certain what you've "linked" (reference) is the correct object in the scene?

frail hawk
#

maybe you are using Tmp instead Text

sullen arrow
#

I dont have text option, only TextMeshPro.

frail hawk
#

and you are able to assign your TMP componeent into that field

#

i really doubt

cosmic quail
sullen arrow
frail hawk
#

because your component is not of type Text that is why

cosmic quail
cosmic dagger
wintry quarry
#

or TMP_Text

sullen arrow
#

Thank you so much guys! YOu are literal life savers, its finally working

#

Also Im really sorry if I was confusing, using text in unity is completely new to me :3

cosmic dagger
#

Agreed, TMP_Text is much better to use . . .

frail hawk
#

you did not explain well enough before that is why i asked again

rancid tinsel
#

how would you guys go about making a ticking system that ticks every second irrespective of lag (if that's even possible)

naive pawn
#

respect deltaTime

#

or compute it yourself if you also need to consider the max timestep thing

wintry quarry
# rancid tinsel how would you guys go about making a ticking system that ticks every second irre...

It depends what you mean by this. If you actually need a consistent real-world timer that runs exactly on the second every second, it can't be done.

But if you want something like FixedUpdate that just guarantees the correct number of runs over time, it's pretty simple:

  public float interval = 1;
  private float timer = 0;

  void Update() {
    timer += Time.deltaTime;
    if (timer >= interval) {
      timer -= interval;
      DoSomething();
    }
  }```
naive pawn
#

i mean, if you have lag >1s, then it'd be impossible to make it update every second. you can still make it count more than 1 second after the lagspike though

naive pawn
#

ah, you ninja edited that out lmao

wintry quarry
#

I really borked my edit

rancid tinsel
wintry quarry
naive pawn
wintry quarry
#

for some reason when I write this example I always use if, because I'm oddly worried about someone mis-copying it and freezing their editor and being mad at me UnityChanLOL

dense salmon
#

hello

edgy tangle
#

That way it accounts for variable frame rates

rancid tinsel
#

that could work

edgy tangle
#

If deltaTime is larger, you’ll take more damage the next frame

wintry quarry
#

Depending on the game, that might not be a great idea. For example what if you step into a pit of fire very briefly but then there's a lag spike on that particular frame. You end up taking more damage than expected

rancid tinsel
#

since I'm doing it per second though, should I maybe do it as float damageMult = lastTickTime - currentTime?

wintry quarry
#

these are the cases where a FixedUpdate style thing is better

wintry quarry
#

this used to a be a problem with the jetpacks in the game Satisfactory. You would start flying then there's a lag spike and by the time the game recovers your character is flying super high in the sky and you're out of fuel so you fall and take fall damage

rancid tinsel
#

oh lol yeah that doesn't sound great

wintry quarry
#

Because the game treated it like you were holding down the jetpack button for the whole lag spike

edgy tangle
#

It might get messy but you could have some predefined threshold of deltaTime to account for a lag spike

#

Or yeah using FixedUpdate might just work instead

#

But that does mean you are locked to the physics tick

#

Which in the case of the fire example is probably preferable

eternal needle
rancid tinsel
#

are usings not inherited? I'm so confused

slender nymph
#

why would they be? they aren't actually logic or properties, they just allow you to remove the namespace for types in that file

rancid tinsel
#

I just kind of assumed anything the base class has, the children would too

slender nymph
#

it's not part of the class though

#

they are even declared outside of the class

rancid tinsel
#

but if the base class uses a Debug.Log for example?

grand snow
#

Dont think using statements work like #include

#

if that makes no sense to you then dw about it

slender nymph
#

they aren't imports. they just allow you to omit the namespace for types you use in that same file

naive pawn
# rancid tinsel but if the base class uses a Debug.Log for example?

and that's in the base class. this Debug.Log is a new one, outside the base class

usings aren't related to classes, they're related to files - files don't get inherited
(they can also be in namespace scopes, but they still apply to just that specific declaration, and not the namespace as a whole.)

rancid tinsel
#

that makes sense, I'm just experiencing some sort of Mandella effect lol

grand snow
#

If a class is in a namespace then it doesnt require a using statement for its contents

edgy tangle
steep field
#
{
    public int x;
    public int y;

    public Coord(int X, int Y)
    {
        x = X;
        y = Y;
    }

    public static bool operator ==(Coord c1, Coord c2)
    {
        return c1.x == c2.x && c1.y == c2.y;
    }

    public static bool operator !=(Coord c1, Coord c2)
    {
        return !(c1 == c2);
    }

    public bool Equals(Coord other)
    {
        return this == other;
    }

    public override bool Equals(object obj)
    {
        return obj is Coord other && Equals(other);
    }

    public override int GetHashCode()
    {
        return x.GetHashCode() ^ y.GetHashCode();
    }
}```

Hey everyone.  I recenlty found out that csharp allows us to override opperators like == or !=. But after that, I was told that it was better not to do that. Then I started searching and found that it is acceptable in gamedev for simple things like coordinates. But is it true? Or it is better to use methods always?
grand snow
#

Perfectly acceptable to override operators if your type needs that

#

best used with classes as by default thats reference equals

misty sand
night raptor
# steep field ```cspublic struct Coord : IEquatable<Coord> { public int x; public int ...

Afaik the only reason not to override operators is the readability which can get poor when used wrong. Especially the equality/comparison operators should be fine to override where such comparisons make sense for the class. Lets say you had a color class, overriding the more than operator for it I would really try to avoid since what makes a color larger than other color? If you wanted to compare the intensity of the color for example, it would be much more explicit to do it via method for example. For mathematical classes/structs (vectors, matrices etc.) it does make sense to override the arithmetic operations too since those are very clear to the reader what those would do. Overriding an operator which meaning is not automatically clear in the context of the class/struct is the only case in which I think overriding is a bad practice.

civic palm
#

This is my script for a SFX manager for my game, i am new to sfx manager scripts (followed a guide to get myself going) and it doesnt cover how to make a looping sound function? could anyone help me on making a function for playing and stopping looping sounds?

The script spawns in an object with an audio source, and destoys it once sound is over.

#

my functions for the looping sound stuff is where i left off, only the PlaySFX one is actually complete

ivory bobcat
civic palm
#

Ok ok I see

#

So: I assume my function that loops audio (PlayLoopingSFX) is meant to be given the name of the audio (string audio name) and then, StopLoopingSFX is meant to also receive that same name and then it stops he audio and deletes the audio source object.

So my question is: How can I define the audio name (string audio name) in PlayLoopingSFX and then also check for it in StopLoopingSFX?

ivory bobcat
#

Maybe have a field referencing the instantiated looped audio source instance.

civic palm
#

I will keep that mindset in mind when asking questions, at first I was annoyed but I now see the valid issue with the way I came to ask for help xD

ivory bobcat
#

It could be a reference to a single instance, a collection of instances, etc

civic palm
#

I’m pretty new to code stuff so I’m not rly sure what it means exactly, do you have any resources on how to do that?

night raptor
# misty sand

Highly recommend stating clearly what is the problem you are having when asking. Of course we can see the error in the console but many here may not even open the screenshots. One tip for your code outside the issue in hand, think how you could simplify the two if statements so you would not have to write the same check twice (tip: else statement).

Regarding the actual issue, you are calling GetComponent on the gameObject your script is on, the renderer within the child object won't be found by that. There are ways you can access the child object (transform.GetChild for instance) but maybe easier and more robust way would be to expose the renderer you need to the inspector via [SerializeField], drag and drop the right object to that field and use the value directly without even having to do any GetComponent stuff.

misty sand
night raptor
# misty sand i havent learnt how to use serialisedfields yet, im guessing i definetly shouldļæ½...

You already have public float aiSpeed which is exposed to the inspector. The idea with [SerializeField] is that you can keep the field private (so it can't be modified from other scripts) while still having access in inspector. [SerializeField] private float aiSpeed would be shown in the inspector exactly the same, just now it being private which everything should be unless it really needs to be public. Whether you use public or SerializeField do exactly the same thing in the sense that the value can be modified in inspector, from code quality standpoint, the latter is more recommended. What you want to do to reference the right Renderer is to make a serialized field (either public or using SerializeField) of type Renderer

grand snow
#

Yea thats a core feature of unity but you may be using it already

#

public fields are serialized by default

misty sand
night raptor
misty sand
night raptor
misty sand
#

is there any drawbacks from using public then like performance?

night raptor
# misty sand is there any drawbacks from using public then like performance?

No, it's just bad practice when it's not needed. Lets say you worked together with somebody else to make the project and the other guy saw that you have a public field called playerCam, they may want to set it to some other camera in their other script to switch cameras during play. Since you only wanted to make it public to modify in inspector, you probably didn't take into account in your code that the value can change from a frame to another. Maybe it wouldn't happen in this case but in general there can be cases where changing a field can break the code when it isn't being anticipated. Things being public usually indicate that it can be freely modified outside the class, if that is not what you want, you should avoid making things public. The SerializeField attribute is there just for that reason, to allow making things visible in inspector without exposing the field to other code. If a field is public already, SerializeField doesn't do anything since public fields are already being showed.

swift crag
#

public fields show up in the inspector by default; other fields need [SerializeField] to do so

slender nymph
#

technically it doesn't work for properties, but you can target their backing fields

swift crag
#

Properties with automatically-generated backing fields require special treatment, yeah

#

I've found that to be more of a nuisance than it's worth

night raptor
#

There's also [HideInInspector] in case one wants to make something publicly available for other classes but doesn't show in inspector

eternal needle
swift crag
#

having an explicit field means I can rename the property without needing to deal with that change in serialized name

slender nymph
night raptor
#

Sure, you can even use both SerializeField and HideInInspector for a same field to serialize but not show. Serialization is definitely beyond what the original question was about though

slender nymph
#

i'm not saying that using both is what will do it, i'm saying that using HideInInspector on a public field will still serialize that field. it just won't be shown in the inspector. that is something that can be important to remember, especially if you add the attribute later on or you change what the value is assigned in the field initializer since the initial value will still be serialized for that field

night raptor
#

@misty sand Anyways, this public vs [SerializeField] conversation is something good to be aware of but beyond the point. To recap the asnwer to the original error you had: if you want to get the renderer component from the child object, my suggestion was to make a serialized field of type Renderer and drag and drop the right reference in inspector similarly to what you have done with other fields like the playerCam. I suppose you could use GetComponentInChildren to find the renderer too but if you have multiple renderers under the parent object, you may face some trouble, dragging the references in inspector is often the easiest approach

grand snow
young sapphire
#

noob question i just finished the beginner tutorial for unity and im trying to add a second AI enemy but its going through the walls i have baked

#

im doing the roll a ball tutorial

#

just starting out guys notlikethis

slender nymph
#

<@&502884371011731486>

gloomy bison
#

hi. i want my mouse to control the flashlight and the camera slowly lerps towards it almost like this. however, the player body doesn't follow. how do i fix this?

if (canMove)
{
    rotation.y += Input.GetAxis("Mouse X") * lookSpeed;
    rotation.x += -Input.GetAxis("Mouse Y") * lookSpeed;
    rotation.x = Mathf.Clamp(rotation.x, -lookXLimit, lookXLimit);

    transform.rotation = Quaternion.Euler(0, rotation.y, 0);


    if (flashlight != null)
    {
        flashlight.localRotation = Quaternion.Euler(rotation.x, rotation.y, 0);
    }

    
    playerCamera.transform.localRotation = Quaternion.Slerp(
        playerCamera.transform.localRotation,
        Quaternion.Euler(rotation.x, rotation.y, 0),
        smoothTime * Time.deltaTime
    );
}```

edit: this is happening in the update function with time.deltatime on movement stuff
vapid aurora
#

šŸ¤

gloomy bison
#

sorry its almost 2am my brain is cooked

distant escarp
#

hey, i got the shader graph to work with the simple noise node (creating waves) but now im having trouble recreating the noise node in C# like was suggested; does anybody have any ideas?

vapid aurora
# gloomy bison so in stupid people terms (me), what fixes to the code would i need in order for...

Relax, you're not stupid, you're just thinking in 2D in a 3D world. We've all been there. šŸ¤
Look, it's simple: in your script, instead of rotating the camera on the Y-axis, find the 'Player' object (the parent) and rotate it. That way, when the body rotates the flashlight and camera will rotate automatically because they're attached to it Only use camera rotation to look up and down (X)

Try that and let me know. Don't overcomplicate things; logic is always simpler than it seems. Short and simple

gloomy bison
# vapid aurora Relax, you're not stupid, you're just thinking in 2D in a 3D world. We've all be...

so now i have this with the following code:

 if (canMove)
 {
     rotation.y += Input.GetAxis("Mouse X") * lookSpeed;
     rotation.x += -Input.GetAxis("Mouse Y") * lookSpeed;
     rotation.x = Mathf.Clamp(rotation.x, -lookXLimit, lookXLimit);

     transform.rotation = Quaternion.Euler(0, rotation.y, 0);

     Quaternion targetCameraRotation = Quaternion.Euler(rotation.x, 0, 0);
     if (flashlight != null)
     {
         flashlight.localRotation = targetCameraRotation;
     }


     playerCamera.transform.localRotation = Quaternion.Slerp(
     playerCamera.transform.localRotation,
     targetCameraRotation,
     smoothTime * Time.deltaTime
     );
 }

what have i done wrong and what knowledge do i n eed for it to happen horizontally too?

#

(i split them up and change a bit of it but im still not sure i've done it right)

vapid aurora
#

With that, the body (the Parent) handles the horizontal rotation, and your camera (the Daughter) only needs to look up and down It's the cleanest way to do it and prevents the code from becoming a tangled mess of quaternions

Try it, compile it, and go get some rest—you've earned it. Short and simple

gloomy bison
#

the smoothness

vapid aurora
# gloomy bison everything i do stiffens up the horizontal axis. i want what i have vertically, ...

I understand, you want the body's rotation to have that same smooth feel as the camera.
Look, to avoid a stiff feel, don't use Rotate directly. Create a targetRotation variable for the parent and use Quaternion.Slerp or Lerp in the Update, just like you did with the camera, but applied to the Player transform.

Basically

You calculate the desired body rotation along the Y axis.

You smooth the transition between the current rotation and that target rotation

This way, both axes will flow harmoniously Don't overthink it for today; your logic is already sólida you just need to smooth out the code. Time to rest, because tomorrow's code will be much easier to read!

#

šŸ¤

slender nymph
#

are you using AI to answer their questions? because that is against the server rules

gloomy bison
#

man imma just continue this tomorrow. i cant deal with 2am coding atm

#

gn gng

vapid aurora
vapid aurora
slender nymph
vapid aurora
slender nymph
#

get to studying, because it's obvious you need to
seems like someone is a little insecure and is lashing out despite not having seen any indication of my skill level.

vapid aurora
#

@sour fulcrum @twin pivot @rich adder āœ¦ĶŸĶŸĶž_

rich adder
slender rapids
#

can i talk now

#

hey can anyone hlep me

#

Im new to unity and trying to make a forest with trees that span at random locations

#

how can i do this while ensuring the treess dont spawn too close together

#

@here

chrome tide
#

Take a look at an algorithm called Poisson Disk Sampling, it might help you with this problem.

slender rapids
#

thanks šŸ™‚

slender nymph
slender rapids
#

sorry

hybrid gust
#
if (heldObjectrigidBody != null)
{
Vector3 targetPosition = playerCamera.transform.position + (playerCamera.transform.forward.normalized * heldObjectDistance);

Vector3 targetDirectionForce = ( targetPosition - heldObjectrigidBody.transform.position ).normalized * strength;

heldObjectrigidBody.AddForce(targetDirectionForce, ForceMode.Force);
}

So this code works to keep a rigidbody in the general vicinity at the "targetPosition". But I'm having issues with the rigid body overshooting the target and bouncing back.
I know there is a way to fix this with some math, but I can't for the life of me remember what that math is.

naive pawn
mild mulch
#

which one do I use?

keen dew
#

Which one do you have?

mild mulch
#

I currently have the lower one selected, but I do not know if that is the correct one to use, or if theyre both correct

keen dew
#

If you have them both installed it doesn't matter which one you use

mild mulch
#

I do have them both installed, does it really make no difference?

keen dew
#

why would it

mild mulch
#

because to me they look like different versions

keen dew
#

They are

mild mulch
#

but I can use both?

keen dew
mild mulch
#

thanks!

narrow yacht
#

Does anyone know how much more time (if any) will Visual Studio 2022 Professional be supported as an IDE for Unity 6 and the next Unity versions?

ivory bobcat
narrow yacht
ivory bobcat
inland crystal
#

Depends what you mean. An IDE for Unity is just a text editor with tools. The text editor part will always be supported - you can write Unity code in notepad if you're masochistic enough. But you're probably more concerned about Unity projects being able to use IntelliSense, do code highlighting etc. I don't see a good reason why they'd remove that capability that is already there, unless there is a major change to how things work.

gloomy vale
#

hello
here is my story xD
i thinked about a colony game like as Stranded alien dawn
since last september im prompting on Chatgpt assets
im new in this game desing world xD im looking for tips maybe somebodi/es who can jump with me for this journey ^^
have a good one šŸ˜„ im french btw ^^

sour fulcrum
#

most people here do not like chat gpt

#

this channel is for questions about programming, we don't have a channel for stories

gloomy vale
#

not he good channel ok thank you

fickle cave
#

Hey does anyone know any good tutorials for Vr.

#

Wanna make a physics sandbox shooter. Any tips?

hidden marten
#
        if (foh.FollowObjects != null)
        {
            Debug.Log(foh.FollowObjects.Count);
            npc.targets.AddRange(foh.FollowObjects);
            Debug.Log("Targets added");    
        }    

im using this script to add one list to another. but its just not adding. the log gives proper count yet the list doesnt add at all. someone please help me out

sour fulcrum
#

you have the brackets now so that snippet is fine but just letting you know unlike languages such as python, c# does not functionally care about identing whatsoever, it's just a visual thing

#

perhaps debug.log foh.FollowObjects count?

#

if its empty it would be correctly adding nothing for example

naive pawn
naive pawn
hidden marten
naive pawn
#

are you looking at the right instance then?

hidden marten
hidden marten
naive pawn
#

try Debug.Log("Added to npc list", npc); to make sure you're targeting the right object, and not for example a prefab

sour fulcrum
naive pawn
#

and again, do try logging npc.targets.Count

hidden marten
#

from the logs the list is added to the list of the prefab and not of the instance

#

i didnt even know that could happen

grand snow
#

time to name those variables better

bronze fossil
#

both the pink bird and player are being translated

    playerPositionerScript.TranslatePlayer(0.25f, 1f);
    StartCoroutine(PlayerPositioner.MoveObjectX(transform, followPoint, 1f));



public void TranslatePlayer(float viewportX, float duration)
{

    Vector3 viewportPoint = new Vector3(viewportX, 0.5f, GameManager.zDistance);
    Vector3 worldPoint = mainCamera.ViewportToWorldPoint(viewportPoint);

    StartCoroutine(MoveObjectX(gameObject.transform, worldPoint, duration));
}


// ? This function is only supposed to move object smoothly in x direction
// ! This function is supposed to let user control their y as they wish but is not functioning to do that
public static IEnumerator MoveObjectX(Transform obj, Vector3 targetPos, float duration)
{
    Vector3 startPos = obj.position;
    float elapsed = 0f;


    while (elapsed < duration)
    {
        float t = elapsed / duration;
        t = Mathf.SmoothStep(0f, 1f, t);
        float newX = Mathf.Lerp(startPos.x, targetPos.x, t);

        obj.position = new Vector3(
            newX,
            obj.position.y,   // preserve current Y
            obj.position.z    // preserve current Z
        );

        elapsed += Time.deltaTime;
        yield return null;
    }
}
#

when the pink bird and player are being translated back the player is jittering

naive pawn
radiant voidBOT
bronze fossil
# naive pawn !code

sory

        playerPositionerScript.TranslatePlayer(0.25f, 1f);
        StartCoroutine(PlayerPositioner.MoveObjectX(transform, followPoint, 1f));



    public void TranslatePlayer(float viewportX, float duration)
    {

        Vector3 viewportPoint = new Vector3(viewportX, 0.5f, GameManager.zDistance);
        Vector3 worldPoint = mainCamera.ViewportToWorldPoint(viewportPoint);

        StartCoroutine(MoveObjectX(gameObject.transform, worldPoint, duration));
    }


    // ? This function is only supposed to move object smoothly in x direction
    // ! This function is supposed to let user control their y as they wish but is not functioning to do that
    public static IEnumerator MoveObjectX(Transform obj, Vector3 targetPos, float duration)
    {
        Vector3 startPos = obj.position;
        float elapsed = 0f;


        while (elapsed < duration)
        {
            float t = elapsed / duration;
            t = Mathf.SmoothStep(0f, 1f, t);
            float newX = Mathf.Lerp(startPos.x, targetPos.x, t);

            obj.position = new Vector3(
                newX,
                obj.position.y,   // preserve current Y
                obj.position.z    // preserve current Z
            );

            elapsed += Time.deltaTime;
            yield return null;
        }
    }

naive pawn
hidden marten
naive pawn
bronze fossil
hidden marten
naive pawn
naive pawn
bronze fossil
#

oh

#

hmm ok

#

thanks

bronze fossil
hidden marten
#

why is it saying it doesnt exist anymore when it is literally there

naive pawn
#

i see that you haven't logged a context in any of those logs

naive pawn
hidden marten
naive pawn
#

you should log a context and see if the object points to the object you think it does

hidden marten
naive pawn
hidden marten
bronze fossil
naive pawn
naive pawn
naive pawn
bronze fossil
#

ok thanks

hidden marten
hidden marten
naive pawn
#

it's a seperate argument

#

Debug.Log(message, context)

#

and once you have that, you can click the log message to see what actual object in unity the context is pointing to

hidden marten
#

lemme try that

naive pawn