#💻┃code-beginner

1 messages · Page 475 of 1

atomic holly
#

How can I use an inspector reference assignment in this case ?

#

I can't assign a function in the inspector in Unity ?

atomic holly
rich adder
#

haha yeah we overcomplicate stuff right?

atomic holly
#

Nice, it works 👍

#

Thanks men

#

It take a long time for a little thing like that 😭

#

Thanks for ur time men

rich adder
#

no worries, with time you shrink the amount of time spent on these little problems

pastel pawn
#

Hello! I was working on some submarine movement code but i've been having a bit of trouble adding realistic collisions- when i hit something i just stop dead in my tracks and get stuck for a second, and i've had some trouble writing anything that would help since i want it to just push back a bit, any ideas on how i could fix this?

rocky canyon
#

using rigidbody? @pastel pawn

#

add a physics material w/ just a little bit of bounce

chrome fern
#

hey guys if i make a game where i can publish it

rocky canyon
terse spindle
chrome fern
terse spindle
#

hello I have a walking script
it works fine on normal character but on a ragdoll character legs dont even move right, I locked the hips rot on x and z still dont work

chrome fern
#

btw i am a 16 yrs beginner any suggestion for me

terse spindle
#

I was wondering what I could do

cerulean dove
#

Okay, does anybody know why this operation isn't just drawing the main screen? I assumed that blitting back and forth would be identical to perform no blit at all, but for some reason it draws an empty scene as opposed to when nothing is performed and it draws the objects in the scene properly.

rocky canyon
cerulean dove
#

Alrighty then

rocky canyon
#

good luck 🍀

chrome fern
#

help guyss

rocky canyon
#

!learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

chrome fern
#

plzz suggest something

chrome fern
rocky canyon
#

check out this section @chrome fern

languid spire
rocky canyon
#

what do u mean and?

#

if ur 16 hopefully.. u can put two and two together.. and realize u just need to start researching and learning

rocky canyon
#

check the pins at teh top of the channel too ^

#

theres literally more resources than you'd ever have now-a-days

cosmic dagger
chrome fern
rocky canyon
#

ill give u the most important tip.. 📖 read..
you're going to get referred to the documentation a lot round these parts

languid spire
#

best tip of all, don't do gamedev

cosmic dagger
chrome fern
rocky canyon
#

this place is more for specific problems.. you try something and fail.. cant figure it out urself.. and then u come and ask

#

b/c it sucksss 😈

languid spire
# chrome fern why

because it is a shed load of learning and hard work for absolutely zero return except the fun of doing it

chrome fern
#

that helpfull

#

ok guys thanks for u advice

#

know i have a brief idea of what i should do

rocky canyon
#

start simple as possible

#

make a clone of a mobile game or summin

pastel pawn
pastel pawn
rocky canyon
#

give it a shot first

sullen zealot
#

hello!
does modifying a MonoBehaviour class also modiufies it outside of th function.
example:
Holder script

using UnityEngine;

public class Holder : MonoBehaviour
{
  public string text = "";
}

script that references it

using UnityEngine;

public class Action : MonoBehaviour
{
  [SerializeField] Holder holder;

  private void Start()
  {
    Func(holder);
  }

  private void Func(Holder holder)
  {
    holder.text = "hello";
  }
}

will the holder text modify after the call or will it make a copy and only modify that?
i tried using ```cs
void Func(ref Holder holder)

but i get this error: Cannot use ref, out, or in parameter 'Holder' inside an anonymous method, lambda expression, query expression, or local function
cosmic dagger
rocky canyon
sullen zealot
languid spire
cosmic dagger
# sullen zealot i didnt

wouldn't it make sense to try it first and see if it modifies the class? that's the question you're asking, and you already have a way to get the answer . . .

sullen zealot
#

i also saw this

languid spire
sullen zealot
#

oh ok thanks

languid spire
pastel pawn
#

it might be because my object isn't exactly falling into anything

#

it's ramming into smtn and it's floating as well

rocky canyon
#

its probably ur movement code

#

thers a constant force component that helps when testing physics and stuff

rocky canyon
#

i just use it so i dont have to write movement code..

#

(once i get my collisions and physics lookin correct just by using test forces (slamming it into the ground. or a wall or something) then i remove them and focus on my code (knowing that it isnt my code thats messing it up

#

not exactly sure is happenign w/ ur scene/movement that this doesnt happen..

#

can u share ur !code

eternal falconBOT
rocky canyon
#

my first thought is that when u collide u can stop ur inputs for a brief second

#

this would give it time to bounce back from the wall b/4 ur inputs override and move back to it

errant kayak
#

im trying to get line 14 to show up in the editor for a scriptable object but its just not appearing in the editor, anyone know why?

languid spire
#

because Unity will not serialize that kind of array

rocky canyon
#

can't expose 2D arrays like that i dont think

errant kayak
#

it does so for another array i have set to this tho

rocky canyon
#

probably not a 2 dimensional array no

#

Sprite[] would work fine.. Sprite[,] no

errant kayak
#

i see

willow scroll
#

I don't like how little types Unity supports

#

It's just array and list

rocky canyon
#

public List<Sprite[]> SpriteSheet;

#

lol

languid spire
#

easy solution

[Serializable]
public class MyClass
   public Sprite[] sprites
...
public MyClass[] SpriteSheet;
rocky canyon
#

big brain this

pastel pawn
# rocky canyon can u share ur !code

i'm not gonna pretend like i wrote this because the majority i didn't as i've been using chatgpt to help me learn how to use the code and with specfic issues so sorry if this looks janky

using UnityEngine;

public class SubmarineMovement : MonoBehaviour
{
    public float moveSpeed = 5f; // Maximum speed of the submarine
    public float acceleration = 2f; // How quickly the submarine accelerates
    public float deceleration = 2f; // How quickly the submarine decelerates
    public float rotationSpeed = 2f; // Speed of rotation response to input


    public Rigidbody rb; // The Rigidbody component for physics

    private Vector3 movementInput; // How much we want to move the submarine
    private Vector3 currentVelocity; // Current velocity of the submarine
    private Quaternion originalRotation; // The initial rotation of the submarine

    private void Start()
    {
        // Store the original rotation of the submarine
        originalRotation = transform.rotation;
    }

    private void Update()
    {
        // Get input for movement
        movementInput.x = Input.GetAxisRaw("Horizontal");
        movementInput.y = Input.GetAxisRaw("Vertical");

        // Ensure the movement is locked on the Z-axis
        movementInput.z = 0f;
    }

    private void FixedUpdate()
    {
        // Calculate the target velocity based on input
        Vector3 targetVelocity = movementInput.normalized * moveSpeed;

        // Apply acceleration and deceleration
        currentVelocity = Vector3.MoveTowards(currentVelocity, targetVelocity,
                        (movementInput.magnitude > 0 ? acceleration : deceleration) * Time.fixedDeltaTime);

        // Move the submarine based on the calculated velocity
        rb.MovePosition(rb.position + currentVelocity * Time.fixedDeltaTime);

        // Apply rotation based on movement direction and input
        if (movementInput != Vector3.zero)
        {
            // Determine the amount of rotation based on the direction of movement
            float targetRotationZ = -movementInput.x * rotationSpeed;
            Quaternion targetRotation = Quaternion.Euler(0, 0, targetRotationZ);
            rb.MoveRotation(Quaternion.Slerp(rb.rotation, targetRotation, Time.fixedDeltaTime * rotationSpeed));
        }
        else
        {
            // Return to the original rotation when not moving
            rb.MoveRotation(Quaternion.Slerp(rb.rotation, originalRotation, Time.fixedDeltaTime * rotationSpeed));
        }
    }

    private void OnCollisionEnter(Collision collision)
    {
        // Log collision detection
        Debug.Log("Collision detected with: " + collision.gameObject.name);

    }
}```
willow scroll
#

I wonder why multidimensional arrays are also not supported

languid spire
#

God I do so hate it when people flood the chat. With AI generated code no less

willow scroll
pastel pawn
languid spire
#

!code

eternal falconBOT
pastel pawn
#

is there a way to just hide the code?

rocky canyon
#

ur basically overwritting any knockback or anything that would even occur

pastel pawn
#

ooooooh alright that makes sense

rocky canyon
#

probably need to ask chatgpt how to use AddForce instead

pastel pawn
#

any tutorials where i can try learn it myself?

rocky canyon
#

dozens

pastel pawn
#

don't wanna be stuck relying on it since it's really

#

coding lmao

rocky canyon
#

Movement using AddForce

pastel pawn
#

alright thanks it helps a lot ThumbsUpCat

rocky canyon
pastel pawn
#

and thanks for not publically executing me for using ai

rocky canyon
#

its fine to get help.. but try to do most of it urself..

#

when u have problems u atleast know why ur code does what it does in the first place

#

instead of just guessing

pastel pawn
#

mhm i hope i can gradually start writing the code myself more and more the more i do code

rocky canyon
#

and then move on

cosmic dagger
#

even if they didn't say it was AI you can tell . . .

rocky canyon
pastel pawn
#

i don't wanna lie that i did

rocky canyon
#

yea point being is that most of us can tell

#

😉 even if u try to hide it

#

lol

cosmic dagger
#

just make sure to understand every line of code before you move on. don't use code that you can't understand. how are you able to fix it, or use the help someone provides . . .

pastel pawn
#

yeah i'd expect it- similar to stuff like generated art then?

rocky canyon
#

its just b/c chatgpt likes to comment EVERYTHING

pastel pawn
#

wait just that?

cosmic dagger
pastel pawn
#

i thought it was specific with how the code was laid out

rocky canyon
#
// this calls a method called Foo
void Foo(){

}```
#

well nooo sh!t

#

lol

rocky canyon
#

it tends to look the same..


// logic
movement = stuff;```
#

much better 🤣

#

its dumb af tho.. it wont last 3 messages before starting to add them back

pastel pawn
#

yeah that checks out lmaoooo

rocky canyon
#

anyway.. try adapting ur script to AddForce

rocky canyon
#

(may need to calculate more numbers for that) but its more realistic than just snapping the Rigidbody position

pastel pawn
#

can't really make a devlog either when all the coding is asking a robot lol

rocky canyon
#

ya, not really much to learn from u if ur copying from ai 😉

languid spire
# pastel pawn i've started to notice-

Difference between AI Art and AI Code
with AI art, if a bunch of pixels are not 100% correct you probably wont even notice
with AI code if a single character is out of place the code is complete crap

signal narwhal
signal narwhal
#

Thats how i learned c#

pastel pawn
#

yeah

rocky canyon
pastel pawn
#

i'll still try use it less tho lol

rocky canyon
#

most ppl dont tho.. they copy and paste and go on their way

signal narwhal
rocky canyon
#

always fact check too..

signal narwhal
rocky canyon
#

dont assume ai knows everything.. b/c it absolutely doesn't.. it actually has no concept of what its saying..
its just gathering all these words and arranging them in a way that statistically is closets to what it expects u to want to see

#

🫣

signal narwhal
#

Eh sometimes it works

rocky canyon
#

yea, not saying it wont... but i tend to think of it as a tool

signal narwhal
#

Yeah it is

rocky canyon
#

add it to ur toolkit for <insert reason>

signal narwhal
#

Wont help you with complex stuff but for the easy stuff it works

eternal needle
#

You might as well flip a coin, heads you learn wrong or tails you learn in an inefficient manner with details lacking from a spam generator

rocky canyon
#

(template style stuff)

signal narwhal
rocky canyon
#

just to keep u from typing repeativiness all the time

signal narwhal
#

I use it to write basic movement ive done a hudnred times already

rocky canyon
#

ehh, you can give it as many custom stuff as possible and it still gets all stupid sometimes

languid spire
#

Classic Catch 22 situation
You have to know what you are doing in order for it to be useful
If you know what you are doing you don't need to use it

eternal needle
rocky canyon
#

if u dont know how to use ur tooling than its useless

signal narwhal
rocky canyon
#

screws nail into water w/ a hatchet

#

ur not gonna win an AI is good argument here.. lol

willow scroll
rocky canyon
#

this is the pro-tip out of em all ^

#

start making packages

signal narwhal
#

Haha yeah ive already made a few packages

rocky canyon
#

ALL templates

#

if u want it i probably already made it

signal narwhal
#

Smart

rocky canyon
#

organization is my key enemy now

#

no good in having it if i cant find it

#

😅

signal narwhal
#

I got some templates for procedural gen and just basic backgrouds n shi

#

But i REFUSE to make an movement template

willow scroll
#

Also I wonder. If you have already done it a hundred times, and writing it with ChatGPT meets your needs, have you just been writing with ChatGPT from the start?

rocky canyon
#

ya, i got a few of those.. 3D Controller, 2D Controller, and Vehicle Controller

#

those are my most used assets

signal narwhal
#

Then i edited it to my liking

rocky canyon
#

if i make an angry bird clone.. the exact same time someone across the world's angry bird project becomes corrupted...

#

did i just steal his project? 🤔

eternal needle
signal narwhal
#

Ive watched hundreds of videos, coded miltiple games

#

Ai was just one of the tools i used when i couldnt find the information in videos

willow scroll
rocky canyon
#

I love using ChatGPT to start refactoring for me...

signal narwhal
rocky canyon
#

thast about it tho ¯_(ツ)_/¯

willow scroll
signal narwhal
#

Not exactly

#

More like a google search

#

But instead of going thru all the links it gives the info straight

rocky canyon
#

yoo @willow scroll apparently thers a new variant of it.. i cant remember the name..
but apparently it only crawls educational + scientific papers

#

that one may be good.. but its also a subscription

signal narwhal
#

The same way you can call someone in a youtube video a teacher

eternal needle
rocky canyon
#

i cant teach.. i only demonstrate..

signal narwhal
#

Something false if it works?

rocky canyon
#

monkey-see-monkey-do type-a stuff

signal narwhal
#

It might not be the most efficient way

#

But it works,

#

If i learn the thing that works

#

I can make it efficient along the way

rocky canyon
#

told ya u cant win this argument 😅 we can't change ur opinions.. but ur probably not gonna change any of ours either...

eternal needle
#

It works until it doesnt and suddenly "I changed nothing and my code stopped working!!!"

ember tangle
#

How does a NavMesh agent actually move? Through the rigid bodies velocity?

rocky canyon
#

soo that makes this conversation.. pointless?

eternal needle
signal narwhal
glass dust
#

I just started using unity and confused what this is?

rocky canyon
#

dont use anime letters in ur file projects

signal narwhal
#

Once again a TOOL, not something that fixes everything for you

#

Imagine writing code in japanese

rocky canyon
polar acorn
ember tangle
# rocky canyon no, it uses translation

Hmm, I've implemented a janky flowfield and I don't know if I should go through the NavMesh Agent to actually move the gameObjects or directly use the translation.

signal narwhal
#

Have a lovely day yalls imma continue living

rocky canyon
#

ThisIsAGoodProjectName
This-Is_ a bad projectName!

#

but b/c the spaces and the !.. to the best of my knowledge _ and - are fine

polar acorn
glass dust
rocky canyon
eternal needle
glass dust
#

thank yall btw

rocky canyon
#

np.. 👍 good luck

polar acorn
tawdry trench
#

hey does anyone know how to get a random point a certain distance out of cameraview?

signal narwhal
rocky canyon
willow scroll
rocky canyon
#

but if ur on ur own now (without traning wheels) u'll discover how its been lying to u

#

or if..

willow scroll
# signal narwhal Something false if it works?
private void Update()
{
    foreach (GameObject go in FindObjectsOfType<GameObject>())
    {
        if (go.name == "Player" || go.name == "player" || go.name == "PLAYER")
        {
            Transform transform = go.GetComponent<Transform>();
    
            FieldInfo positionInfo = transform.GetType().GetField("position", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
    
            positionInfo.SetValue(transform, (Vector3)positionInfo.GetValue(transform) + moveSpeed * Time.deltaTime * Vector3.forward);
        }
    }
}
eternal needle
signal narwhal
signal narwhal
willow scroll
signal narwhal
#

Haha indeed it does

#

And admittedly it would help a beginner

signal narwhal
#

Guess its a winnerless race

hazy crypt
#

yeah...

#

any idea how that happened?

#

it doesnt actually stop me from opening the project or playing it tho

rocky canyon
polar marsh
#

How do I stop the player from holding down a button in the new input system? I have a fire event and i want to make sure the player has to press the key each time they want to
Interactions don't seem to do anything for me

languid spire
polar marsh
#

Ah okay

#

Just curious, how come the interactions don't work?

#

Or am i using them incorrectly

languid spire
#

no idea, I dont use them

polar marsh
#

Hmm, ill have a look into it. Thanks

polar marsh
#

Oops sorry, will do next time

hazy crypt
signal narwhal
eternal needle
hazy crypt
#

twice

#

but its just an error

#

its consistently on when i start unity

#

and appears twice when trying to play unity

#

my editor still works fine though

eternal needle
#

Did you read the first part of my question?

#

I dont know what switching pcs have to do with if you're intending to use unity version control

hazy crypt
#

i never even used version control

polar marsh
#

Does it do it on all projects

hazy crypt
#

but the project is older

polar marsh
#

Or just the one you tried to open there

hazy crypt
#

it was like 20 ".xx" versions older

eternal needle
hazy crypt
eternal needle
#

But also, use version control. Git/github is the best

#

Version control does a lot, let's you backup your project, keep track of changes, share with others

polar marsh
hazy crypt
#

kool

hazy crypt
#

OH YEAH

#

THATS HOW I GOT MY PROJECT

#

this time it did it for me

polar marsh
# hazy crypt oooo

Idk if its better than an actual git client i've never used it but worth a try

hazy crypt
#

instead of me bringing it in with my SSD

eternal needle
#

Git is really just the best way. You really dont need VC integrated with your IDE

hazy crypt
#

didnt even know i had it

jovial turtle
#

is pressing play supposed to take this long?? Unity 6000.0.17
(this is the first time im running it after importing about 10 scripts)

rocky canyon
#

no.. restart ur project / delete ur Library folder

jovial turtle
eternal needle
#

10gb sounds like a lot though

rocky canyon
#

and then it should be fast as it was when u started..

jovial turtle
#

alright

rocky canyon
#

a good restart is ur second best bet

#

but deleting the library will speed it up even mor

queen adder
#

Hello I am a pretty new dev Im not the best at anything but I have basic knowledge of programming and unity and I was wondering if anybody would give me some good beginer tips. Could be really specific or really gerneric just anything that could be helpful while making a game. Programming tips, orginaization, unity and how it works, art anything at all but programming would be most benifical for a specific question. How should I be refrencing things scripts the most optimal way? Anyways I would appriciate anyhelp its all great thank you!

wintry quarry
#

It's kind of like asking "What's the best tool"? The answer changes depending on what you're trying to accomplish. A hammer is great for driving nails, but not very good at driving screws or figuring out if a plane is level.

queen adder
#

Another question... How would I learn of these methods? Whats a good resource?

wintry quarry
#

Learning by doing is the best way

#

Otherwise your breain will just blank out the information

#

just make some simple games, and when you run into some situation you don't fully understand or need help with, ask around for help or google

queen adder
#

100% agree I've experienced that first hand. What would be the best way to find this info is what im asking. Is there a spesific website, YouTube tutoritals, just google the problem and use what ever shows up, this discord, all of these things even I need to find the info so that I can learn it

wintry quarry
#

I guess it really depends on the situation

#

all of the above can be helpful

rocky canyon
#

use version control asap..

#

thats bout all i got

queen adder
#

Got it and I know im being extreamly vauge let me give an example, In my first project my enemy script looked like this

anyways it was all a mess and I felt as if I was doing things completely wrong it worked but it was awful to work on it super annoying. I have no idea anyother ways to be doing what im doing. I dont know what I dont know if that makes sense. How do I learn these things?

rocky canyon
#

and,
Tip #3 - and don't build walls of code in here.. use one of the external paste-bins for !code like that ^

eternal falconBOT
queen adder
queen adder
rocky canyon
#

tip #4..
stop using public just to be able to assign things via the inspector
[SerializeField] private GameObject aSimpleGameObject

queen adder
rocky canyon
#

!vc

eternal falconBOT
#
Using version control in Unity

Unity Version Control

git Git

Get the latest .gitignore file from here. It should be placed at the root of your Unity project directory.

wintry quarry
rocky canyon
#

if its only being accessed via the script its declared/created in.. use private

#

only that class should be allowed to read/write to it

queen adder
rocky canyon
#

but by [SerializeField]ing it.. you gain access to be able to assign it via the inspector

#

(even tho its still private)

queen adder
rocky canyon
#

its a best practice kinda thing

#

no need for me to know what color boxer's my neighbors wearing

wintry quarry
#

it's a good coding practice thing, and encourages good architecture.

queen adder
wintry quarry
#

judiciously

#

when you need something to be accessible from elsewhere

rocky canyon
#

when that variable needs accessed from somewhere else

wintry quarry
#

usually on a property or a method

#

I would recommend never on a field as a rule of thumb

queen adder
rocky canyon
#

like if my Enemy script is deducting points from my players health..

#

then I could use a public float Health;

queen adder
#

So only when other scripts would need to change the value

wintry quarry
rocky canyon
#

oor more better:
private float Health;
and then a public method to change it

Health -= damage;
}```
#

playerHealth.ChangeHealth(10f);

#

^ better structure.. and more readible..

queen adder
rocky canyon
#

than playerHealth.Health -= damage;

rocky canyon
#

but no.. in general it doesn't need to be

wintry quarry
rocky canyon
#

the Pins up top are a good starting location to find good resources @queen adder

queen adder
queen adder
rocky canyon
#

📌 Where / How to learn?

There's always more than one way to learn, but here are a few of our favorites:

📌 Official Unity Resources:

queen adder
rocky canyon
#

Single Responsibility

#

the PlayerHealth should be the only thing changing it's Health variable..

#

that way its more organized and better off in the end..

#

add methods to that script to modify it within itself.. and call that from external sources

#

also another good tip is
void Awake <-- use this method to initialize itself
void Start <-- use this method to initialize and grab things from other scripts

#

that way when u go to do that in Start you know that the other script's Awakes have ran.. and they are all set up

queen adder
rocky canyon
#

thats keeps u from getting errors like this this this.. and that.. has not be assigned or is null etc

#

ya, check out SOLID if u never heard of it..

#

you wont get the full gist of it right off the bat.. but its something to keep in mind

wintry quarry
#

imagine if some other script modified the health directly and forgot to update the healthbar or check if the player died

#

😵‍💫

queen adder
wintry quarry
#

So this is why it's good to use a private variable for Health, as an example

rocky canyon
queen adder
rocky canyon
#

you can manually add ur own order here

#

but thats a last resort for me..

#

best to just keep things set up correctly

queen adder
queen adder
rocky canyon
#

yea don't...

#

just letting u know it exists

queen adder
queen adder
rocky canyon
#

the LightSettings set itself up in its Awake() soo by doing it in the Start() we already know it's awake has ran.. and the lights are set up and ready to be grabbed

#

if we did both in Awake() its a dice roll whether they'll be ready or not..

queen adder
#

Awake to spawn things Start to grab things from said script got it

rocky canyon
#

like my GameManager ^ all that stuff is set up in Awake()

#

we need to wait for Start() to try to access any of em

#

if we don't theres a chance they're not ready

hollow slate
rocky canyon
#
    private void Awake()
    {
        x = this;

        GameObject STARTGAME = GAME.gameObject;
        GameObject STARTLOAD = LOAD.gameObject;
        GameObject STARTREFS = GAMEREFS.gameObject;

        // GAME WARMUP - TURN ON RELEVANT SYSTEMS
        STARTGAME.SetActive(true);
        STARTLOAD.SetActive(true);
        STARTREFS.SetActive(true);

        SceneManager.sceneLoaded += OnSceneLoad;
    }```
rocky canyon
haughty flower
#

Hi all! I am a brand new game dev literally started a day ago. I am making the basic obstacle course game from Brackey's tutorials if anyone is familiar with it.
I finished it and decided to expand upon the game by adding a Checkpoint system. This is where everything fell apart. I made the GameManager a prefab, created an IsTrigger Cube to act as a checkpoint that passes on a Vector3 of its current position to the GameManager and the GameManager updates the player position based on the Vector3 that got passed. The problem is that I needed to make the GameManager not destroy on restarts since the Restart function reloads the entire scene and that would reset all the position data by destroying the GameManager.

Now that I made the GameManager not destroy on load, it breaks the whole game. After I restart twice, the GameManager loses reference to my Score system and calls a NullReferenceException.
It goes from this, on a fresh load: https://i.imgur.com/tTMRLtB.png
To this after one restart: https://i.imgur.com/hOGTfMa.png
To this after two restarts: https://i.imgur.com/MJ7iiQI.png

After which it produces the error. Are there any tutorials on how to navigate this kind of thing?

rocky canyon
#

like if my other scripts tried to grab this gameobject b4 its even SetActive then we got problems

queen adder
rocky canyon
#

yeap.. its easy just to do it that way all the time..

#

so ur not backtracking trying to figure out why ur references arent read yet

#

b/c technically a script w/o anything relying on it.. u could do things in Awake() or Start()..

queen adder
#

Good practie to do it all the time it cant hurt it

rocky canyon
#

and to the viewer.. there wont be a difference

#

soo alot of ppl just slap it in awake or start.. or w/e their IDE autocorrects first 🤣

#

then when they have an issue u gotta go back and refactor all of em

#

or u take that little hacky shortcut i showed u.. and they add the script in there to make sure it runs all of its functions first

#

ohh ohh ohh,
and dont divide by zero 🤪

rocky canyon
cosmic dagger
rocky canyon
#

u either need to DDOL those references as well.. and keep them with the gamemanager..

#

or everytime u load a new scene.. have a funciton that looks and finds all the references it needs in that scene

queen adder
#

Alright thank you very much for the help very helpful will take all this into consideration when coidng. Thank you so much!!!

rocky canyon
#

heres my GameManager...

#

everytime i load a new scene i run BootSystem

#

it goes thru and finds all my new references in that scene

haughty flower
#

Ahhh gotcha, thank you. I will try to do this 🙂

#

So basically I have to go and individually set each of these references in the GameManager script

rocky canyon
#

as u can see here.. my first scene is MainMenu and then my second scene is Level1 but i never unload my BootLoader scene..

#

all its references are tucked in the scene w/ it

#

soo i never get them lost

rocky canyon
#

but that might cause different issues.. if those have references to the game-world

#

if its a small game its probably easy enough to just run a function that reassigns everything fresh

haughty flower
#

That's really cool, I didn't know you could do that.

rocky canyon
#

each new scene..

#

but its up to you

rocky canyon
#

if u wanna research it some more

haughty flower
#

Thank you 🙂

rocky canyon
#

nvm i figured it out im an idiot

#

can't update my health when my player is disabled 😅

#

altho tbh i still dont know why it does that

#

ohh sure i do... b/c if playerhealth = null.. then maxHealth is just zero

#

nvm

coarse zodiac
#

im a pretty new beginner does anyone know how i can make an animation start? i have a character and he has a sword i made a sprite sheet for said sword but i have no idea how to make it trigger any ideas?

rocky canyon
#

Open Animator window.. for the object..

wintry quarry
rocky canyon
#

it should include the animation u made..

wintry quarry
#

such as a trigger

coarse zodiac
#

i have no clue how to open the animator im brand new to unity its confusing to me i can open it but my gameobject doesnt show up in it

rocky canyon
#
  • add a paramter (float, int, trigger or w/e)
  • add a transition from idle -> ur animation (use the parameter as the condition)
    and then
  • using a reference to that animator you just set the parameter
coarse zodiac
coarse zodiac
#

will do appreciate you!

wintry quarry
#

but the animator works the same either way

rocky canyon
#

the important part being the Transitions.. altho theres many ways to do this.. including calling the clips manually..

#

altho i do like the statemachine

#

also remember the parameters names are important... if ur parameter is isTriggered it'll only work w/ "isTriggered" as thats not the same as "IsTriggered" minor gripe.. but you'd be suprised how many people ignore their spelling right when it matters the most

livid path
#

What is workaround to bind data source as struct without copy in UI Toolkit?

rocky canyon
#

wrappah class

eternal needle
rocky canyon
#

lmao! i know right!

rocky canyon
steep rose
#

hey notepad instructions get right to the point

queen adder
#

quick question how would I get an object in unity to move in way its facing

wintry quarry
#

the way it's facing is transform.forward

#

so - use that direction for whatever movement code you want

#

(unless it's in 2D in which case it's transform.right or up)

queen adder
#

it is in 2D

#

its being silly how would i write ie

#

I would I write the transform right

wintry quarry
#

what do you mean

#

transform.right

#

what does "it's being silly" mean?

queen adder
#

Sorry its late im tired. I dont know how it do it i do cs transform.position = transform.right is that right

wintry quarry
#

no that doesn't make any sense

#

position is a position

#

you wouldn't assign a direction vector to it

#

use that direction for whatever movement code you want
Remember when I wrote this?

#

you could for example do this:

transform.position += transform.right * speed * Time.deltaTime;```
#

(in Update)

#

(note += not = )

queen adder
#

Thats what it was i just forgot the +

#

whoops

hazy crypt
#

how do i download assets

#

in my asset folder

#

there are some assets i no longer have (i made them myself dw), and i wanna redownload em to recolor it (i have a new use for it)

wintry quarry
#

Otherwise - just copy the files into your asset folder, if you have them from some other source.

hazy crypt
#

is getting a file from my project

#

into my computer

wintry quarry
#

copy it from the asset folder to another folder in your computer

hazy crypt
#

the file is on my old pc which i dont have rn

#

kk

wintry quarry
#

If you don't have the PC, I don't see how you could get it

hazy crypt
wintry quarry
#

you mean from the build?

hazy crypt
#

from the editor

#

i think it got saved from the cloud

#

or smth, i havent used unity in a while

#

(months)

wintry quarry
#

If you have the project open, then you have the project on your computer

#

just copy it from the assets folder

hazy crypt
#

kk

hollow zenith
#

Hey, how can I convert hex value to rgba?

vestal grove
#

For a 2d game (non pixel art with target resolution for 1920x1080), is there any pro/con for setting PPU of all sprites to 1?

teal viper
#

Think of it as a better way to scale your sprite.

vestal grove
#

is using ppu as 1 a common practice?

teal viper
vestal grove
#

Ok, thanks for the info

hollow zenith
#

I expected something like ColorUtility.ConvertStringToHex(String string)

eternal needle
normal thicket
#

what is the problem?

timber tide
#

problem is you need to configure your IDE if you can't catch the syntax errors yourself

normal thicket
#

how?

eternal needle
#

that sure is a lot of problems

#

!ide

eternal falconBOT
eternal needle
#

i also highly recommend doing some c# basics first outside of unity if you have no clue what these errors are.

normal thicket
#

i configured IDE but its still not got any changes

ivory bobcat
# normal thicket i configured IDE but its still not got any changes

Does intellisense properly highlight and underline the issues within the ide? The conflicting statements should be highlighted and normally prohibited from being typed - you'd get errors as soon as you start attempting to type em instead of randomly writing stuff and later having to fix the whole mess.

normal thicket
#

yeah I got it

sharp abyss
#

I have a game that you can swing. anybody know how can I make passive spider legs that I can show player The law of inertia while swinging?

teal viper
#

Wat? "Passive spider legs"??

sharp abyss
#

I meant I dont want to walk it like https://youtu.be/9-7owO16syA?si=ySphmlU9qdjTQFSE this video just legs that stand there but go opposite way while my character is swinging

After messing around with a 3D-ik driven spider, I decided to make a 2D one and invite you to come with me on the process.

How to make an atmospheric 2D game: https://www.youtube.com/watch?v=S10eaYrNnYM

Leg mover script: https://pastebin.com/r0rmu3nr

Spider Brain (Movement): https://pastebin.com/yh59eAXQ

Want to talk to me, or other like min...

▶ Play video
teal viper
sharp abyss
#

okay thanks 👍

pastel pawn
steep rose
#

and from what im seeing, try changing your acceleration rate to 0.5f or 0.3f to make the acceleration slower

pastel pawn
#

i did, it doesn't change anything

languid spire
# pastel pawn

So you didn't bother reading the addforce documentation before writing this?

steep rose
#

that doesnt make sense

pastel pawn
steep rose
#

just use 1

pastel pawn
#

😭

#

i've been using unity for like 5 days gimme a break lmao

pastel pawn
steep rose
queen adder
#

sorry I don't know where to ask this appologies if this isnt the correct place if not tell me where I should put it. but I am working on a assignment and am having massive confusions between the example project and my project. why does my canvas not have a drop down menu like this one here?

steep rose
queen adder
#

my canvas, no drop down menu

pastel pawn
languid spire
steep rose
#

but yes get rid of all those inputs in replace of this one

queen adder
#

not sure how to do that

#

sorry im total beginner this is just for a class, i am super lost

pastel pawn
languid spire
steep rose
# pastel pawn i don't think i'm doing it right-

you would need to assign movedirection as a vector3 and use GetAxisRaw for x and y inputs, then use your player transform instead of orientation, I just use an orientation object so nothing can change the forces on my player

#

i suggest you !learn how to do so

eternal falconBOT
#

:teacher: Unity Learn ↗

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

pastel pawn
mild plank
#

Hi, anyone knows how do I make fog for my game, but only on the outside of the house? I tried SSMS tool, but that also works all the time, I just want the fog on the outside. And also, so that the fog is everywhere, not only on objects and the sky just shines in blue. Any suggestions?

ripe shard
# mild plank Hi, anyone knows how do I make fog for my game, but only on the outside of the h...

one approach is to make a custom fog shader and render a large sphere around the camera with it, overdrawing everything in the scene and thereby applying a fog effect, sort of like a skybox but instead of behind everything you draw it in front of everything. That shader can then sample the depth texture and world Y and any custom masks you would like to have for masking out building interiors. You may have to be clever about coming up with these interior masks however.

#

Another (more expensive) approach would be to use path-traced volumetric fog (you'll probably buy an asset for that and use its tooling).

mild plank
#

Yeah not beginner friendly 😅

ripe shard
#

if you have advanced feature plans, you will need advanced features 😉

mild plank
ripe shard
#

actually its only not-a-baseline-feature because its so expensive to implement generically

ripe shard
#

and match the skybox to the fog color

#

if you just want to bleed the fog into the skybox, you can use the overdraw-shader-thing i mentioned earlier with a simple fog (fog is just and overlay of the DepthTexture with some color grading)

mild plank
#

is the basic unity lightning setting fog smoothly interactable via scripts? Like the intensity

ripe shard
#

yes

#

but its a static/global API, so you need to be careful how you manage changing it

mild plank
#

Time.deltaTime adding to some Light.fog.value?

#

Sorry I am trying hard

#

and not getting too far

ripe shard
mild plank
#

ohh fogDensity alright alright

#

Thx, when I get home I will experiment a bit with it

cosmic quail
cosmic quail
steep rose
#

i dont think so

#

a cube trigger, not a mesh trigger

cosmic quail
steep rose
cosmic quail
#

yea i guess not sure about the performance hit with that though

languid spire
#

Unless the player is allowed to walk through walls/floors/roofs then you only need a trigger on the doors

steep rose
#

huh? that doesnt make sense

#

just use a trigger for the whole room

#

then when you enter set a boolean to true

#

else, set it to false

languid spire
#

How else is the player going to move from inside to outside if not through a door?

steep rose
#

im not sure but adding a trigger for every door seems a bit rough, not to mention it may not work correctly due to the fact how triggers work.
if you add a trigger for every door you would do Ontriggerenter to set something to true but you could never do Ontriggerexit to set it back to false

#

since you wouldnt be in the trigger anymore

ripe shard
cosmic quail
steep rose
languid spire
ripe shard
cosmic quail
steep rose
languid spire
cosmic quail
ripe shard
#

anyway, the more robust way to set it up is to define a volume that is considered "inside", an event based system made by evaluating door-triggers is way more fragile

languid spire
#

think about it
You are outside- isInside is false
You walk through the door - isInsiide is true
you walk through the door again, therefore you must be outside - isInside is false

steep rose
cosmic quail
ripe shard
languid spire
ripe shard
languid spire
#

And why would it not be robust?

ripe shard
# languid spire And why would it not be robust?

because we don't know anything about the level structure, if it has multiple doors and a team of undisciplined level designers, this can break very easily when configured incorrectly, breaking all future state aswell. we're probably not talking about a door that guarantees the room can only be exited through that same door or even through any door.

#

if you just define a volume you do not break future state because you counted the enter/exit events wrong

languid spire
ripe shard
#

given your years of exp, i find it surprising that you can't see the issues with that

languid spire
steep rose
#

guys stop fighting, it will get you nowhere. both ways a good for what this guy is probably doing, if he doesnt know how to place triggers properly then thats on him.

gloomy bison
#

how would one be able to create a system where you walk through one door and another room appears where the door left off, like a random room generation?

#

so far chatgpt keeps taking me to the same route of errors

languid spire
#

I've actually got one of those, believe me it ain't easy to do

gloomy bison
#

imma just go to reddit and youtube and see where i can find a tutorial

#

bearing in mind i have 15 minutes left before i have to leave

steep rose
gloomy bison
#

yeah, i usually dont use it but i find it really funny

#

i'll try figure this out when i get back

quick pollen
#

Quick question, how can I make it so a quaternion's X rotation is 0 without messing things up?

quick pollen
brave compass
quick pollen
# ripe shard use its eulerAngles API

I feel as though doing something like this is extremely dangerous

Vector3 cameraEuler = cameraTransform.rotation.eulerAngles;
        cameraEuler.x = 0f;```
lethal holly
quick pollen
#

oh wait I think I get it

lethal holly
#

However, if its for camera rotations (mouselook) you could try just storing a vector3 representing the rotation locally (literally store the euler angles as a member var) and make changes to those and set them

quick pollen
#

i got it, thank you!

#

I just did

        movementVector3 = cameraTransform.rotation * new Vector3(inputVector.x, 0f, inputVector.y) * moveSpeed;
        movementVector3.y = 0;```
brave compass
lethal holly
#

That way you avoid drift or other issues with the calculation

quick pollen
#

then multiplied the vector with deltatime in the end

#

I'm trying to get a kind of soulslike type of vibe with the movement

lethal holly
#

But maybe I misunderstood what they meant and answered the wrong thing

quick pollen
ripe shard
# quick pollen heres the result I was looking for

if you search for FreeCamera.cs in your project you will find a nice camera implementation as part of shadergraph examples (may also be in the SRP package) that illustrates how to make a simple camera via euler angles

brave compass
#

There was never any issue with the camera, just the movement vector.

lethal holly
#

Im pretty sure alfy is talking about a problem relating to his mouse look 🤔

brave compass
#

It's related, yes, because the movement vector is rotated by the camera. When the camera was tilted down, the character could move into and above the ground, which they didn't want. They still want the camera to be able to tilt down, just not the movement vector with it.

ripe shard
#

regardless, the question was about controlling Quaternions and that free camera is an example that does it through a Vector3 representing euler angles that get modified and converted into a Quaternion each frame

brave compass
#

It was the wrong approach to try to modify the Quaternion in the first place, since its much easier to project the movement vector afterwards. Classic XY problem.

quick pollen
#

I'm using cinemachine for the rest

lethal holly
#

Ah I see that part now, I missed the movement message

quick pollen
#

my main issue was the way I processed the information mainly

rich adder
steady crown
#

im trying to make it so the animation only plays when i walk and stop when i dont. right now the animation continues after i stop walking, what can i do?

pliant sleet
#

Can somebody help me with this...? I am trying to make a 2D platformer and my player seems to jump inconsistently, like sometimes it jumps higher and the opposite (here are the script for the movement and the player's RB)

lethal holly
steady crown
#

i tried with an else if but didnt work

lethal holly
#

You just need to use an else here

steady crown
#

or should it be before

rich adder
lethal holly
#

Let me show you 😄

rich adder
#

dont send screenshots of code @pliant sleet

pliant sleet
steady crown
rich adder
steady crown
#

this doesnt work for some reason

lethal holly
wintry quarry
#

also why are you manually adding gravity

rich adder
#

btw you should not be doing * time.deltaTime on veloicty

wintry quarry
#

why not just use the built in gravity

lethal holly
wintry quarry
#

well the deltaTime makes sense there, but it's not going to be consistent

lethal holly
#

Go inside the animator and have it open on a second window and watch that value change while the game runs. Make sure it updates correctly

steady crown
#

hmm is it because i made the method a void and that doesnt work with booleans?

lethal holly
#

if it does then its an issue with how you configured the animator

rich adder
#

ohh thought we need it only with functions like MovePosition

lethal holly
pliant sleet
steady crown
#

oh okay

wintry quarry
#

it's also not clear what your Jump() function is doing

#

since you didn't show it

#

please share code via !code not screenshots

eternal falconBOT
steady crown
pliant sleet
wintry quarry
#

showing the code would be better

pliant sleet
#

I ll just use screenshots for now, sorry

wintry quarry
rich adder
wintry quarry
#

otherwise you'll have to set the jumpPower variable absurdly high

rich adder
#

wait why is the x velocity the force for jump 🤔

pliant sleet
wintry quarry
#

To set the velocity you would do rb.velocity = newVelocity;

#

if you want to NOT modify the x axis, you should be adding 0 force on the x axis

#

because any number + 0 gives you the original number

#

Again AddForce is additive

pliant sleet
#

that's right, thanks.

#

and the AddForce() function is well used ?

wintry quarry
#

wdym by "well used"?

pliant sleet
#

like if I should use a better version of it

#

that does the same thing but better

wintry quarry
#

As mentioned, you should be adding an impulse force here

pliant sleet
#

Got it

#

Seems to work perfectly now. Thanks!

main karma
#

what's "others" in the profiler cause it's eating 15ms of my game

#

idk how to identify bottlenecks using the profiler well and this is driving me nuts

rich adder
rich adder
#

well then check the hierarchy and sort by most ms

main karma
#

the garbage collector takes almost 0.00ms

#

how do you do that

rich adder
# main karma how do you do that

I would recommend this vid first https://www.youtube.com/watch?v=xjsqv8nj0cw

In this video, we look at an overview of the Unity Profiler in Unity 2022 LTS.

You’ll learn more about profiling your game to identify bottlenecks, the Profiler’s interface, and how to identify issues that need fixing.

The Unity Profiler is a tool for creators who want to understand performance issues and how to address them.

Helpful resour...

▶ Play video
main karma
#

okay, also another question is... if I have like let's say over 600 unity objects that are a duplicate of the same object, if I batch them all would it still impact fps?

#

like greatly?

#

got a particle on all of them

#

my fps drops by like 40 in the editor with these many vs without

#

I want to optimize my game to handle around a thousand and idk where to begin, I got no lights, and no shadows in my game, everything is baked

#

almost everything is static as well

#

and batched

#

scripts only take around 3ms

rich adder
#

if you plan on using so many partciles you should probably use the VFX graph

#

they will boost the particles greatly as its not straining the CPU (particle system limitation)

#

its all based on GPU

main karma
main karma
rich adder
main karma
#

alr

#

and it's faster?

rich adder
#

once you learn the tools it has you can easily port it

#

well yes its many times faster because its entirely on the gpu and not going back n forth to CPU like particle system

#

for small amounts is okay but if you have many its will chugg

main karma
#

ohh, that would certainly help as I'm getting CPU bottlenecked

rich adder
#

are those generated cubes ?

#

otherwise you should batch them

main karma
#

I already batched them

#

I followed the simple optimization tips you can find in every tutorial and did some of my own

#

like removing shadows as all my levels are dark

#

and baking every light in the game (no real time lighting)

#

so my gpu doesn't do much

#

if I can move the vfx to the gpu that would help greatly I think

#

as I got thousands of VFX going on

rich adder
#

yea it should help greatly

final pelican
#

I have a player on a board that should move depending on a die roll. Afterwards, the turn count would go up as the player has to reach a goal in a certain amount of rolls.

How would I connect the die to the player so that it can only move the amount the die shows and after doing so, the turn count raises?

lethal verge
#

Hey! I have a small problem. I am controlling a circle according to my mouse movement. So if I drag my mouse up, the circle accelerates up until I drag my mouse down. This works for any direction. The problem is when I reach the end of the screen with my mouse I have no space to keep moving my mouse in that direction, for instance, if my circle stands completely still and my cursor is in the right side of the screen, I have no space to drag my mouse to the right side to make my circle go right. I thought of locking my mouse in the middle of the screen and hide it but then comes another problem. When I lock the mouse the movement stops working so I don't really know how I should fix this? Any suggestions?

rocky canyon
#

use mouse Delta's and lock the cursor like ur original instinct

languid spire
#

Rotate or Move your camera to track the mouse

willow scroll
#

This is a way if you want your mouse to be visible and not limited by the screen bounds

#

This is achievable with the InputSystem's WarpCursorPosition method

#
Mouse.current.WarpCursorPosition(calculatedPosition);
lethal verge
willow scroll
wintry quarry
lethal verge
#

I mean if you drag your mouse to the right and it goes over to your second screen

wintry quarry
#

As for "why it doesn't work" when locked, presumably your code is the problem

lethal verge
willow scroll
wintry quarry
rocky canyon
willow scroll
lethal verge
#

I have hidden the cursor and locked it in the middle

#

When I unlock it I can move the ball

#

I will show the scripts 2 sec

#

using UnityEngine;

public class PlayerController : MonoBehaviour
{
public float forceMultiplier = 5.0f;
private Rigidbody2D rb;
private Vector2 lastMousePosition;
private Vector2 movementDirection;

void Start()
{
    rb = GetComponent<Rigidbody2D>();
    rb.gravityScale = 0;  

    
    lastMousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
    
    
    Cursor.lockState = CursorLockMode.Locked;
    Cursor.visible = false;
}

void Update()
{
    
    Vector2 currentMousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);

    
    Vector2 mouseMovement = currentMousePosition - lastMousePosition;

    
    if (mouseMovement.magnitude > 0.01f)  
    {
        
        movementDirection = mouseMovement.normalized;

        
        rb.AddForce(mouseMovement * forceMultiplier, ForceMode2D.Force);
    }

    
    lastMousePosition = currentMousePosition;
}

void OnApplicationFocus(bool hasFocus)
{
    if (hasFocus)
    {
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible = false;
    }
    else
    {
        Cursor.lockState = CursorLockMode.None;
        Cursor.visible = true;
    }
}

void OnApplicationPause(bool pauseStatus)
{
    if (pauseStatus)
    {
        Cursor.lockState = CursorLockMode.None;
        Cursor.visible = true;
    }
    else
    {
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible = false;
    }
}

}

eternal falconBOT
rocky canyon
#

dont use mouse position

lethal verge
#

!code

eternal falconBOT
rocky canyon
#

use mouse axis / deltas

rich adder
rocky canyon
#

mouse position will never exceed the bounds of the camera

wintry quarry
# lethal verge I have hidden the cursor and locked it in the middle
        Vector2 currentMousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);


        Vector2 mouseMovement = currentMousePosition - lastMousePosition;


        if (mouseMovement.magnitude > 0.01f)
        {

            movementDirection = mouseMovement.normalized;


            rb.AddForce(mouseMovement * forceMultiplier, ForceMode2D.Force);
        }```

This is all so overcomplicated. Why not just use `Input.GetAxis("Mouse X")` and `GetAxis("Mouse Y")`?

Of course it doesn't work as is - since you're basing it on mouse _position_ instead of the mouse delta input
rocky canyon
#

delta's can (b/c its the change)

lethal verge
#

I want it to go in all directions but won't it just go left/right, up/down if I use mouseX and mouseY

rocky canyon
#

do u have to press a diagonal key when ur playing a first person shooter?

#

or do u just press up and left at the same time 😉

lethal verge
#

Damn true

rocky canyon
#
        float moveX = Input.GetAxis("Mouse X");
        float moveY = Input.GetAxis("Mouse Y");

        velocity += new Vector2(moveX, moveY) * speed * Time.deltaTime;``` its simple
lethal verge
#

Yes I should simplify everything I see now that it's over complicated

#

and do you recommend locking the cursor or doing like you said to make the mouse go outside the screen?

rocky canyon
#

wont matter.. even if its locked.. the object will still go off the screen edges

#

b/c its tracking the delta (differnece in mouse movement).. locking the cursor doesnt affect it any

#

the delta's still change even when its locked or hidden

#

mouseposition is what gets locked to 0,0 when u do that

lethal verge
#

Okay so it will still be able to move if I use the code you sent even when I lock the mouse

rocky canyon
#

yes.. b/c ur moving the object

#

not the cursor

#
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible = false;
    }``` in my example i sent.. i locked and hid
#

test it out and see what happens when u do different things

lethal verge
#

Okay I will try it out thank you @rocky canyon

eternal needle
final pelican
rocky canyon
#

Start Move
Roll Dice
Calculate Spot
Move until hit that spot
Subtract or Add count or w/e

#

might want to look into coroutines and while loops

midnight meteor
#

Hello ,why it doesnt appear in the inspector?

#

@wintry quarry its nothing thats why i hid it

rocky canyon
#

probably compile errors.. but why u using [SerializeField] on a public variable?

wintry quarry
#

check your console window

midnight meteor
#

nothing in my console window too

wintry quarry
#

show us

eternal needle
midnight meteor
rocky canyon
#

have u clicked INTO the editor?

#

so it triggers a recompile

wintry quarry
# midnight meteor

make sure:

  • Your code changes are saved
  • That you refresh your unity assets if you have auto-refresh off
rocky canyon
#

it wont just show up while u have that VS window in the way

wintry quarry
#

Also what Spawn said

midnight meteor
#

how to check the refresh thing ?

wintry quarry
#

Preferences -> Asset Pipeline Settings -> Auto Refresh

rocky canyon
#

just click the unity window.. lol

midnight meteor
#

oh that's weird

final pelican
rich adder
#

oof

wintry quarry
midnight meteor
#

maybe an asset changed it

#

thanks both !

rocky canyon
#

👻

midnight meteor
#

is this fine ?

rocky canyon
#

🔍 ass

wintry quarry
#

yep

midnight meteor
#

cool cool

#

appreciate the help

rocky canyon
#

just making a joke. not sayin ur ass or anything 🤣

midnight meteor
#

is there a "reset settings" button ?

rocky canyon
#

also.. if u use public theres really no need for [SerializeField]

#

now if its private u could do that.. to expose it in the editor

rocky canyon
midnight meteor
midnight meteor
#

i mightve downloaded a unity asset that changed a lot of my settings

#

( the fast script reload )

rocky canyon
#

theres not a straight forward way no

steep rose
rocky canyon
#

his AutoRefresh got toggled off for some reason

midnight meteor
rocky canyon
#

he wanting to know if he can reset all the settings in the editor

midnight meteor
#

usually it wont let me

rocky canyon
steep rose
#

for many reasons

midnight meteor
#

but yeah i'd rather take my time than redownload unity because of some error

rocky canyon
#

just regular ole game-dev stuff

eternal needle
midnight meteor
rare hawk
#

I'm working on a 2D RPG (think Final Fantasy 1-6), and I'm contemplating whether it would be better to make some components DDOL or to have them in (almost) every scene. I see pro's and cons for both ways (one gives me easier data management, but makes it harder to find object for cutscenes and stuff. The other takes more resources, but makes scene management easier).
Any advice?

rocky canyon
#

i can just give u my personal preference... i like to use additive scenes / and keeping my GameManager scene and all its references loaded at all times

#

no DDOL needed

rich adder
#

isnt DDOL basically just an additive scene 😛

short hazel
#

Yes it is lol

eternal needle
rare hawk
rocky canyon
#

idk bout that one.. all my stuff exists from the beginning.. the only thing i have to do is search for couple of new things w/ each scene reload

wintry quarry
rocky canyon
#

and then find the new one

wintry quarry
#

especially because the battle system for a JRPG is best done with an additive scene.

hazy crypt
#

i went to the VCS tab last night

#

and logged in

#

boom it was fixed

wintry quarry
#

the data model would be stored on a DDOL object/script

rare hawk
steep rose
rare hawk
rocky canyon
#

u could probably store all ur party members in there as well.. and already have hte reference/data to them like said

wintry quarry
eternal needle
rare hawk
rocky canyon
#

electronics too

#

if u think about it for a while it makes total sense tho

rare hawk
# rocky canyon i store my player in the boot scene

So your player is always loaded, and you move it to the correct place in a new scene load based on what that scene has pre-defined?
I have to say that for a JRPG that doesn't seem very useful, as most party members would join the game way later on, but I might be mistaken. Will definitely watch a more in-depth video on it during breakfast tomorrow (it's 9 PM here)

rocky canyon
#

when i pick up something it stores it on the inventory in the bootstrap scene

#

and so on and so on

wintry quarry
#

the individual scenes read that data and decide to do things like spawn a controllable player character based on it, for example

rocky canyon
#

also true ^

rare hawk
rocky canyon
#

my player is the oldest part of my project and holds alot of its own things. unfortunately

#

so thats why mines loading into the boot

#

but i have a function called LoadChapter() which basically is a new scene.. that new scene has the starting position in it.. i just move my player too it

midnight meteor
#

Hello , why cant i drag the gameobject from hierarchy to there ? it keeps saying "typemismatch" although it is a gameobject

rocky canyon
#

after i initialize and grab that position on scene load ofc

#

it is a mismatch

wintry quarry
rare hawk
rocky canyon
#

using that script

midnight meteor
#

oh i see i will make it a prefab then

#

thanks

rocky canyon
#

u can make it basic for now and build it up as u go

#

eventually it'll be a payoff to have everything structured in that way

rare hawk
rocky canyon
#

ofc u can always use a DDOL object.

#

and shove everything within it..

#

but i favor the bootloader/strapper (same thing i know nav)

rocky canyon
#

if u can manage everything its fine.. scaleability is when you'll hve regretslol

rare hawk
rocky canyon
#

💯

rare hawk
#

Thanks a lot both of you! I'll put it on my planning

rocky canyon
#

if u want fast and easy.. just use DontDestroyOnLoad(this.gameObject); on ur important stuff

humble summit
languid spire
#

what is wrong about it?

humble summit
#

The description and example

wintry quarry
#

How so? Works for me.

languid spire
#

no it is not

#

be specific

wintry quarry
#

Maybe share some details about what you're trying to do and what's going wrong.

humble summit
#

The type or namespace "Load" does not exist in the namespace "Assets.Resources"

wintry quarry
languid spire
humble summit
#

I copied the stuff directly from the doc

languid spire
#

show it

humble summit
#

var textFile = Resources.Load<TextAsset>("Text/textFile01");

slender nymph
#

it sounds like you have your own namespace called Assets.Resources. that is what is causing the issue

wintry quarry
#
var textFile = UnityEngine.Resources.Load<TextAsset>("Text/textFile01");``` will work
wintry quarry
#

so it's conflicting

#

the docs are 100% fine

humble summit
#

the string "namespace Resources" does not appear in my solution

wintry quarry
#

namespace Assets does

#

and public class Resources does

#

that's your problem

#

you named your class Resources

languid spire
#

why would it when it's complaining about Assets.Resources

wintry quarry
#

Solution is to either:

  • Not name your class Resources
  • Use the fully qualified name as in my earlier example var textFile = UnityEngine.Resources.Load<TextAsset>("Text/textFile01");
humble summit
#

the string "class Resources" does not appear in my solution

slender nymph
#

it's not a class named Resources that is the issue. it is a namespace called Assets.Resources

rocky canyon
#

using Resources = UnityEngine.Resources;

slender nymph
#

if it were a conflicting class, the error would be about the type Resources not containing that member, but the error specifically states that the type Load is not in the namespace Assets.Resources

humble summit
#

I found the offending namespace in some generated code.

slender nymph
#

and what is generating that code? 🤔

languid spire