#๐Ÿ’ปโ”ƒcode-beginner

1 messages ยท Page 624 of 1

restive lantern
#

Meant to reply to the message above

#

From native code I somehow have to supply the correct MethodInfo when calling a generic and I have never understood how to generate that ๐Ÿ˜…

polar acorn
#

Native code

grandpa_simpson_hat_rack.gif

wintry quarry
#

They say the exponent in decimal is a "decimal number". I don't understand how they store that or how they do math with it on a binary computer

restive lantern
#

Anyways guess I'm doing a type lookup then.

wintry quarry
#

Huh

slender nymph
#

they're using it from native code for whatever reason

polar acorn
naive pawn
wintry quarry
restive lantern
# slender nymph they're using it from native code for whatever reason

I'm programming a mod that is supposed to work for all Unity games to use Steam Audio with reflection using collision data by overriding AudioSource ๐Ÿ™ƒ
I could use C# for this, but then it wouldn't work with games compiled for il2cpp.
Maybe there is a better way to do this, but my current way is to just do everything on the native side of things.

slender nymph
#

congrats, your questions are off topic! modding discussions are not permitted here

restive lantern
#

Just wanted to explain. No further discussion.

polar acorn
#

At least it's not fuckin gorilla tag

restive lantern
#

Lol...

wintry quarry
# naive pawn manually

So if they're doing the math in software doesn't that make decimal like thousands of times slower than regular floating point math?

slender nymph
naive pawn
#

they still are simple operations

restive lantern
slender nymph
#

i don't see what that second point has anything to do with anything i have said. that is a separate discussion which i have not participated in.

slender nymph
naive pawn
polar acorn
restive lantern
restive lantern
naive pawn
polar acorn
#

At this point it's mostly in the case of "You aren't going to find much help for calling these functions from native code since it's not something most people have to do so we don't really have experience with it".

restive lantern
#

Oh yeah I know, but I used to send lots of separate messages in DMs that generate pings regardless, and people got annoyed so I developed the habit to combine multiple messages in one ๐Ÿ˜…

polar acorn
#

You might have to do some documentation binging on your own

restive lantern
#

Thank you, anyways

grim marsh
#

Hello, I have a problem with a raycast and maybe somehere could help me fix it?

Basically I have a script that shots the ray and returns hit game object, but the moment there is no object (player looks into sky and shots ray) it returns null and I get a bug report that no object is set to variable. Any ideas how I can fix it/bypass it

naive pawn
grim marsh
polar acorn
#

Usually by wrapping it in an if

grim marsh
#

It is in if

polar acorn
eternal falconBOT
restive lantern
naive pawn
#

no clue tbh

#

probably googlable

verbal dome
#

I see some charts pop up every now and then

restive lantern
#

I have implemented fixed point maths (because I have no idea about floating point) in hardware before, it did work in a single cycle but ate sooooo damn much space ๐Ÿ˜… no wonder CPUs nowadays have so many transistors.

restive lantern
restive lantern
#

Please tell me, how? ๐Ÿ˜ฎ

rich adder
restive lantern
#

I remember attempting to research something and all Google gave me was the same AI generated article in like 20 languages lol

restive lantern
verbal dome
#

Funny how "web" isn't the default for a search engine anymore

polar acorn
#

Easier way: include swearing in your search.

"Picture of an owl" -> AI crap
"Picture of a FUCKING owl" -> Only human made

rich adder
naive pawn
#

or filter for stuff before 2020 or smth

restive lantern
#

That worked for a while but then articles claiming to be from before 2020 popped up that were definitely AI generated lol

rich adder
#

all that stuff is still all in the LLMs no ?

slender nymph
rich adder
#

shiit.. someone needs to make a google search that omits that crap..

ripe shard
#

we need AI to remove AI

restive lantern
#

There are models that detect AI generated text, but that's probably way to slow to run for each search result

ripe shard
#

its somewhat fascinating how 'everyone' invests in AI that nobody actually wants.

polar acorn
restive lantern
#

Yeah..

polar acorn
eternal needle
restive lantern
#

Oh well

ripe shard
#

i feel like the world is more and more made for those 0.5% of people who are suckers for that kind of exploitative marketing BS and the rest of the world has to run along.

polar acorn
restive lantern
#

We need something like an adblocker, but for AI. A list of websites that contain AI shit and that are then automatically blocked.

ripe shard
restive lantern
#

True ๐Ÿคฆโ€โ™‚๏ธ

ripe shard
#

also not all AI is bad, i like my intellisense

eternal needle
naive pawn
#

gentle reminder, this is kinda way off topic

rich adder
#

to call it "Intelligence" is being generous

restive lantern
#

We somehow drifted from floating point to AI

ripe shard
restive lantern
#

What off-topic channels are here?

rich adder
#

none

polar acorn
ripe shard
restive lantern
#

Oh well lol

ripe shard
#

imagine replacing discord mods with some AI

rich adder
#

Image unity documentation one day just says Unity Muse as default search

ripe shard
#

offtopic police bot AI

restive lantern
polar acorn
restive lantern
#

... nvm for some reason Discord suggested a channel from another server

grim marsh
eternal falconBOT
grim marsh
#

Edited

polar acorn
#

Yep, just saw right as I sent

grim marsh
#

Wrong key

polar acorn
#

So, what's the error you're getting?

grim marsh
#

It returns null when I use it and ray doesn't hit anything

#

"Object reference not set to an instance of an object"

grim marsh
#

second if

polar acorn
#

Ah, because you don't actually have anything in your if statement

#

Take a look at the first if statement. Compare it to your second.

#

Notably, the ends of the lines

rich adder
#

when we open a if statement block, you probably don't want to end it before doing anything inside of it lol

#

; means "end this statement"

grim marsh
#

Isn't the second one nested in the first if?

rich adder
polar acorn
#

An if statement runs until it finds either a { or a ;, whichever comes first

grim marsh
#

Doesn't it run everyithing in { }?

#

I'm confused now

rich adder
grim marsh
#

Oh I see it now

polar acorn
#

But yours does not

grim marsh
#

There is this one ; after if๐Ÿ’€

#

๐Ÿ˜ญ

#

Thank you guys

naive pawn
grim marsh
#

traitor

naive pawn
#

so if you have if (...) doThing();, it runs only doThing()
if you have if (...) { ... }, it runs the entire block statement
if you have if (...);, it runs the empty statement which does nothing

if you have if (...); {} like here, the if runs the empty statement, then the block statement runs detached from the if

#

are you trying to search through code? if not, you're in the wrong place

rich adder
#

probably want to use the included Search

#

Window -> Search -> New Window

naive pawn
grim marsh
celest sapphire
#

Unity talk got you ! thanks

grim marsh
#

Thank you

queen adder
#

how long does it take to get good enough to do this? : https://www.youtube.com/watch?v=4O0_-1NaWnY

jdh

See the code on GitHub: https://github.com/jdah/minecraft-weekend

NOTES:

  • The water and lava textures are from the now defunct (?) Painterly Pack, my animation skills weren't up to the challenge.
  • The depth sorting algorithm depicted is mergesort but it's mislabled as quicksort (oops!). I was initially using mergesort but ended up using quick...
โ–ถ Play video
naive pawn
#

very

#

also not really a relevant question to learning

#

you shouldn't set "make thing fast" as a goal

#

just "make thing" is already a significant goal

restive lantern
#

Specially without a game engine, though most game engines don't handle voxel graphics very well.

naive pawn
#

imposing a time limit on yourself when you're still a beginner will only stress you out and make you dislike the experience

restive lantern
#

Time limits are great if you know you can do something but want a bit of an extra challenge, as Chris pointed out it's bad if you just want to learn.

queen adder
#

i want to get good at coding

rich adder
#

If you commit yourself you will get good

queen adder
restive lantern
#

Coding has many facettes, you can't be just "good at coding", there are so many subcategories.

naive pawn
restive lantern
#

You'll never feel like you're really good at coding because coding is just such a huge space there's always more to explore.

proper hawk
#

!code

public void PlayRussianRoulette()
    {
        int chamber = Random.Range(1, 7);
        Debug.Log("Spinning the chamber...");

        if (chamber == 1)
        {
            Debug.LogError("๐Ÿ’€ Bang! Quitting Unity Editor...");
            /////////EditorApplication.Exit(0); // so we dont get banned :))
        }
        else
        {
            Debug.Log("๐Ÿ˜… Click! You survived this time.");
        }
    }
eternal falconBOT
rich adder
#

kinda clickbait title

naive pawn
queen adder
proper hawk
#

wanted to test if it can run functions

restive lantern
#

The !code command is just to show that help page lol

eternal falconBOT
naive pawn
#

if it could... do you think dyno would be running a whole instance of unity editor

queen adder
#

I am learning react native. I wont work for coding but will enjoy making things for myself and community

polar acorn
proper hawk
#

ohh notlikethis

#

makes sense

#

saw bots that can run basic stuff

restive lantern
#

Imagine you could just make that bot execute arbitrary code lol

naive pawn
#

there are bots that can

slender nymph
#

there are repl bots, but dyno is not one of them

naive pawn
#

but you wouldn't be able to run unity library code in them

restive lantern
#

There'd be way too many bitcoin miners in that bot by now if you could just run code without restrictions

naive pawn
#

("i run code" that uses piston)

naive pawn
restive lantern
#

You'd hope so

naive pawn
#

the contained ones anyways. something like replit obviously does

restive lantern
#

Heck people have abused GitHubs actions system to run miners before

#

I've seen bots made by inexperienced people that had a "calc" command that literally just pushed everything into eval() ๐Ÿ’€

rich adder
restive lantern
inland latch
#

hi not sure if this'd go here ot not since it's about the editor not coding, but for some reason my unity editor keeps making a really subtle static noise, and i know it's unity as when i close unity it stops, and when i mute the unity application in sound mixer it also stops. the sound is coming through my speakers so it's not a hardware thing, if it was i don't think muting the unity app would fix it. this happens in editor and play mode, regardless.

  • also, it seems to randomly stop and start so it's not consistent
rich adder
#

I looked into once to implement unity as a 3D viewer

restive lantern
restive lantern
#

Debug information

#

They contain stuff like what function is at what address etc.

grand snow
#

*for windows. Linux elf binaries do not require an external debug symbol file

restive lantern
#

It's the closest you get to Unity source code without paying extra.
And with Unity source code you could do literally anything you want anyways. But that expeeeeeensive. I think you even have to pay another extra to be allowed to distribute modified versions.

clever gorge
#

right i just started unity and its telling me that i cant enter play mode because there are compiler errors

#

how do i fix this because ive litterally just installed it

slender nymph
#

fix your compile errors

cosmic dagger
#

check the console to see the compile errors, ten fix to to enter play mde . . .

polar acorn
#

It is entirely possible your template contains compile errors. Possibly due to out of date packages. Check the console and update the ones that are having issues

bright zodiac
restive lantern
#

I have no idea about the way native things are supposed to be done tbh from a game developer perspective.

#

But I would assume it's well documented.

steep whale
#

can anyone find the bad logic here? Im generating rooms for a tiny dungeon crawler and the grass variances works great but the edge generation does not. what did I mess up? see screenshot for problem, it only ever generates grass grass then 5 edge then remainder grass for what should be the entire lowest x position as edges

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

eternal falconBOT
steep whale
rich adder
steep whale
verbal dome
steep whale
verbal dome
#

Yep

#

So the code works

steep whale
# verbal dome Yep

beautiful, thank you for the assistance. new, stranger problem. why do you think this lower left corner is always generating without edge, even with the inspector fixed?

#

ignore the random grass tile off to the right, that will eventually be exit hall logic

verbal dome
#

What is safeRoomPosition.x set to

steep whale
verbal dome
#

What if you set x to zero?

#

Or one

steep whale
#

any advice on how to offset a second noise generation so the flower patterns dont match so closely with the grass?

verbal dome
#

I'm guessing you didn't write this code?

steep whale
verbal dome
#

If you use chatgpt, at least try to understand the code that it feeds you

#

Not to sound harsh

#

But if you read the variable names they are pretty self explanatory

steep whale
#

its a learning process

queen adder
#

i'll try to explain this the best way possible, but i'm bad at explaining so sorry in advance. I have two scripts, one that instantiates a new object and one that stores a bank of values. when instantiating, the code takes one of the values from the bank script. what i need is to be able to have the instantiating script choose a random number out of say 20, then pull that specific string and use it in the instantiation. that way, it would be a random value each time it is instantiated.
here is the current code:

public void CopyTask(string newTaskData, string taskText)
{
    //do not fix or TOUCH AT ALL if this is touched everything breaks!!!
    //do not optomise in fear of project collapse
    GameObject newButton = Instantiate(buttonPrefab, buttonParent.transform);//creates new button
    newButton.gameObject.GetComponent<buttonStringKeeper>().buttonString = newTaskData;
    buttonStringKeeper data = newButton.GetComponent<buttonStringKeeper>(); //this and ^^^ could be combined but that could break so redundancy = better

    newButton.transform.GetComponentInChildren<TextMeshProUGUI>().text = taskText;//gets text component and edits it

    Button buttonComponent = newButton.GetComponent<Button>();//gets the component


    if (data != null)
    {
        // Use lambda to capture the message dynamically
        buttonComponent.onClick.AddListener(() => OpenOverlay1FromInspector(data.buttonString, newButton.gameObject)); //adds onClick with the string
    }
    else
    {
        Debug.LogError("ButtonData component not found on the button!");
    }
    //need to add listener with the button script buttonStringKeeper
    //need to pull button string keeper string and use it when opening
}

this is the instantiating script^^^

#
public class TaskStringBank : MonoBehaviour
{
    //STORE VARIABLES
    //call copy script with value from here
    public GameObject ModalController;
    public void callCopyScript()
    {
        string taskText = "Walk to somewhere you would have driven - 1000";
        string taskData = "Walking a short distance such as 3 miles instead of driving can help reduce emissions by between 500-1000kg of CO2 per year!|1000|google.com";
        ModalController.gameObject.GetComponent<ModalWindowController>().CopyTask(taskData, taskText);
    }


}

and this^^^ is the bank script. it is currently set up with one value. it is also the script with the function to call the instantiation. I cannot figure out the best way to do this, so any help would be great

polar acorn
queen adder
polar acorn
# queen adder yes, it needs to pick the cooresponsing two taskText's and TaskData's with each ...

Step 1: Create a class that contains both the text and data together, so that you can keep them together.
Step 2: Change your CopyTask function to take that one object instead of two strings
Step 3: Create a list of that class that holds all available options
Step 4: Random.Range from 0 to the length of the list, then get that index from the list to grab a random selection
Step 5: Pass that value to CopyTask

queen adder
polar acorn
#

You would make a class with two string fields

#

and use that instead of passing the two strings directly

frigid sequoia
#

I have a script that holds a reference to all the entities in play. GameManager is gonna need a reference to it to check if the game is finished or not (check for remaining non-dead entities). I want to call this method whenever one entity dies from the entity script, and I am doubting what would be the proper way to do it, to send a reference of the list from the entity that dies as an argument (they all have a reference to list already) or to make a new reference to the list on the GameManager itself.

#

I don't think it would make much of a difference in this case, but I am kinda curious what would be preferred

polar acorn
# frigid sequoia I have a script that holds a reference to all the entities in play. GameManager ...

Whenever something dies, invoke an event that other things can subscribe to. Have whatever object has the list of enemies subscribe to that event, remove that enemy from the list, and do whatever it must when the list is empty.
https://gamedevbeginner.com/events-and-delegates-in-unity/

Learn how to connect scripts & objects using delegates, actions & Unity Events in my in-depth beginner's guide.

queen adder
frigid sequoia
polar acorn
#

Well, now you have the perfect time to use them

frigid sequoia
#

Like most of times I can do with a simple standalone reference

frigid sequoia
sour fulcrum
# frigid sequoia I have a script that holds a reference to all the entities in play. GameManager ...

There's kind of a few ways you could put that together but like if you went way further into this than you are currently you would probably have it in the gamemanager or some comparable manager because you'd want to handle stuff like this for more than just enemies. in the past i've done something like this but it depends on a couple things

GameManager

    List<Enemy> allActiveEnemies
    UnityEvent OnEnemyRegistered
    UnityEvent OnEnemyUnregistered

    private void Awake()
        OnEnemyRegistered.AddListener(CheckLevelStatus)
        OnEnemyUnregistered.AddListener(CheckLevelStatus)

    public void RegisterEnemy(Enemy newEnemy)
        allActiveEnemies.Add(enemy)
        OnEnemyRegistered()

    public void UnregisterEnemy(Enemy enemy)
        allActiveEnemies.Remove(enemy)
        OnEnemyUnregistered()

    private void CheckLevelStatus()
Enemy

    Awake()
        GameManager.RegisterEnemy(this)

    Death()
        GameManager.UnregisterEnemy(this)

(this aligns mostly with what digiholic suggested)

polar acorn
frigid sequoia
sour fulcrum
#

nah

polar acorn
sour fulcrum
#

just do it tbh

#

this is using something i made so looks a little different but for example a tower defense game i made back in december had these kinda events in my gamemanager

    public static ExtendedEvent OnGameManagerEnable = new ExtendedEvent();
    public static ExtendedEvent OnGameManagerAwake = new ExtendedEvent();
    public static ExtendedEvent OnGameManagerStart = new ExtendedEvent();
    public static ExtendedEvent OnGameStart = new ExtendedEvent();
    public static ExtendedEvent<bool> OnGameEnd = new ExtendedEvent<bool>();
    public static ExtendedEvent<EnemyBehaviour> OnEnemySpawned = new ExtendedEvent<EnemyBehaviour>();
    public static ExtendedEvent OnNewWave = new ExtendedEvent<EnemyBehaviour>();
    public static ExtendedEvent OnWaveFinished = new ExtendedEvent();
    public static ExtendedEvent OnIntermissionStart = new ExtendedEvent();
    public static ExtendedEvent<EnemyBehaviour> OnEnemyKilled = new ExtendedEvent<EnemyBehaviour>();
    public static ExtendedEvent<IHighlightable> OnHighlightChanged = new ExtendedEvent<IHighlightable>();
frigid sequoia
#

I don't think it would make me good to add events now tbh....

#

Like it should be something I do from the start

sour fulcrum
#

at the end of the day it's your call. this is an accurate answer to the question you asked tho

ancient stirrup
#

ondestroy?

timber tide
#

You can add events whenever you want and I think an event bus is the idea here

frigid sequoia
#

I could, and I have no doubt it would be the right way to do it from the start

#

But everything that happens when something dies is already like well nested on all others scripts

#

I think it would cause more issues than anything handle that with an event now

timber tide
#

Well this would be the most proper way. Otherwise just call the singleton reference directly

final kestrel
#

When I want to initialize my singletons. It is enought to start the game at the initialization scene and I can then unload it because I'll have my dols already with me on the next scenes right?

#

I'm looking back at some stuff I made couple months ago but I cannot see any reason why I wanted to keep init scene loaded with the DOLs in it.

timber tide
#

What's the question? You can make a loading scene and do the manager/singleton instantiation there then load onto a main scene that will keep those managers loaded

#

meaning you don't need those managers in the main scene (but for development purposes I do it anyway)

final kestrel
#

Ah okay. So I understand correct. I somehow thought I needed the scripts that are dont destroy on load should stay on the initialization scene at the beginning of the game and never unload that scene to keep them active.

timber tide
#

dont destroy on load just prevents the gameobject from ever being cleaned up (from deloading) until you unflag it as is

#

so if you aren't using additive scenes and just load/deloading scenes then you probably want to use it for your managers

final kestrel
#

Yeah I failed to understand that it seems. Thanks for the answer!

#

Also another quick question. Is marking PlayerController that is responsible for your player movement/interaction etc dont destroy on load making sense? If so how can I set all the serialized references in the next scene? Because probably the next scene will have different references to hold on my player.

cosmic dagger
timber tide
#

Well, if you have stuff being serialized on each scene that's a little tricky. Initialize the manager in the scene where there are those dependent, but say the next scene have new dependencies that you want to serialize on the editor then you can just destroy the manager and recreate it on the next scene (still a singleton) but this means you lose those previous references. Otherwise you need to dynamically bind them as you enter the scene if you want to keep the persisting DDOL manager.

frigid sequoia
#

I get it, it's THE intended way

#

I am just not using that now

cosmic dagger
hardy ibex
#

im making a rocket launcher weapon and for an explosion, would it work if i increase the hit detector colliders size, played the particles, and destroyed the bullet all at once when it hits? and if it would, is that a good way to do it?

frigid sequoia
sour fulcrum
# frigid sequoia I am just not using that now

its totally valid to want to know how best to do something and decide not to do it currently ๐Ÿ‘. I personally disagree on your take that it needs to be a all or nothing kinda implementation but you know how best to program for yourself so whatever floats your boat

cosmic dagger
#

@frigid sequoia Also, as another option, you can use an SO with a list field for your enemies and directly reference it in any script that needs the list . . .

sour fulcrum
#

@final kestrel not sure if this helps but in a lot of stuff i've made i tend to have a singleton manager that exists in DDOL (i tend to call it a GlobalManager). and a singleton that exists in the level scene/s (i tend to call this a GameManager, RoundManager etc. depending on the kinda game). Then either ither handles stuff depending on the scope of the thing they are managing

frigid sequoia
#

Handles just a tiny bit of other functions, but it's mostly for that

final kestrel
cosmic dagger
cosmic dagger
sour fulcrum
#

we love so's

cosmic dagger
#

Your enemy manager script controls adding and removing the enemies while the scripts that need it will have their own field for it. It saves memory since each script will reference the same SO . . .

sour fulcrum
frigid sequoia
#

Yeah, the list of entities is a singleton basically

#

Is a single script on an object that hover over everything else, as well as the GameManager

cosmic dagger
sour fulcrum
#

I thought ideally we wanted to avoid storing runtime data on SO's

#

not that i don't do it just thought it wasn't the vibe suggestion wise

frigid sequoia
weary basin
#

hello, I'm new to unity and I'm trying to use the unity version control but it won't let me enable it for some reason... would anyone know why?

frigid sequoia
#

This is basically the list of entities that I am handling, does a bit more than just hold the data, that's why I didn't make it a SO

cosmic dagger
sour fulcrum
#

Heard ty chef

#

I forget and the unity docs are a little vague, are Awake or OnEnable suitable for resetting and/or initialization runtime data on SO's or does it need to be handled by a monobehaviour etc.

cosmic dagger
sour fulcrum
#

right yeah that sounds right

#

i wanna maybe say if you use both to call a function that handles all the usecases?

#

the docs really need to be more explicit on how they work

cosmic dagger
#

You can use preprocessor directives to prevent errors in the editor for SOs . . .

cosmic dagger
rocky canyon
#

good read

#

Prior to this a ScriptableObject instance ONLY ever called OnEnable once per booted application session (build or editor), so it was effectively useless for initialization. Now it can be used almost as a MonoBehaviour.

Unfortunately the documentation is not clear:

grand snow
#

this caught me recently too

#

I rarely use scriptable objects more than just data storage so "loaded" confused me too

acoustic belfry
#

Hi just for be sure. If i have a base code with a method, and in another code wich uses that base had the sane method but with other things inside, it will override it?

rich adder
#

you add new and that hides the parent one

polar acorn
teal viper
sour fulcrum
# acoustic belfry Hi just for be sure. If i have a base code with a method, and in another code wi...
//This class or any derivatives can be created and used.
    public class MyBaseClass
    {
        //This ALLOWS derived classes to override this function.
        public virtual void MyVirtualFunction()
        {

        }
    }

    public class MyDerivedClass : MyBaseClass
    {
        public override void MyVirtualFunction()
        {
            base.MyVirtualFunction(); //This runs the code in the virtual function. You don't have to run this if you don't want the code in the original function to run.
            //My additional code.
        }
    }
    //This class cannot be created or used, Only things deriving from it can be.
    public abstract class MyAbstractBaseClass
    {
        //This REQUIRES derived classes to override this function.
        public abstract void MyAbstractFunction();
    }

    public class MyAbstractDerivedClass : MyAbstractBaseClass
    {
        public override void MyAbstractFunction()
        {
            //There is no base implementation for this function so there's nothing to call beforehand.
            //My code that runs.
        }
    }
rotund forum
#

Hopefully someone can point me in the right direction for this;

I'm trying to create a base ENEMY CONTEXT class that I can change for each enemy type prefab I give it to (HP, ATTACK, etc.).

The issue I am encountering is I also want to be able to create an array of attacks the enemy can use... but I'm not sure how to reference the data from those attacks. I want it to be plug-and-play and tried creating an attack class array but it doesn't show on the enemy GameObject.

It seems like Scriptable Objects might be the way to go from my research, but... well I got the array to show up, but I can't add anything that derives from the scriptable object. I'm sure I'm missing something obvious here and would appreciate the help if anyone can let me know what I'm doing wrong.

sour fulcrum
polar acorn
rotund forum
polar acorn
rotund forum
polar acorn
polar acorn
sour fulcrum
#

are you trying to add via drag n drop or by the little circle search menu

rotund forum
sour fulcrum
#

you need to create a ScriptableObject

#

they are asset instances but not gameobjects

#

like a Material

polar acorn
#

ScriptableObjects essentially let you define data in a file in your project, instead of in an instance that gets generated by code during runtime

rotund forum
#

Hmm. Probably where I am seeing trouble. I have a version of Unity where there is no option to just create a ScriptableObject. I thought it was enough to add the inheritance to the class.

sour fulcrum
#

click the link above

polar acorn
teal viper
polar acorn
#

Chance are, you don't even need the child classes. If you define your Attack SO well enough, you just need multiple instances of it

trim solar
#

my friend needs help with a unreal engine 5.5 problem, is there a unreal engine equivlent to this discord ?

sour fulcrum
polar acorn
#

Like, one of them would have the name Punch and the damage value of 10 and speed 3 while Kick would have 20 damage and speed 1 or something

rotund forum
# polar acorn No version of unity lets you just create a scriptable object. You have to do tha...

So this isn't that then?

https://youtu.be/PVOVIxNxxeQ?t=96

In this video, we are going to show you how to use Scriptable Objects to manage your data in Unity.

Download the Unity Royale Project here!
https://on.unity.com/33FplpG

Learn more about Scriptable Objects here!
https://on.unity.com/33PzcJR

Get Inspiration on what else to do with Scriptable Objects here!
https://on.unity.com/2RKXXkK

Chapters:...

โ–ถ Play video
sour fulcrum
#

why is that part just cut off like that wtf

polar acorn
#

It's that thing I said you had to do

#

Unity doesn't just do that. You have to tell it to do that

polar acorn
rotund forum
#

My brain is expanding.

#

Thank you.

#

@sour fulcrum @polar acorn Thanks again guys; I started making INSTANCES of the SOs and now everything has come full circle. This is exactly what I needed.

#

๐Ÿ™‚

teal viper
acoustic belfry
# polar acorn Depends on a lot of factors. You should probably show the code that you're askin...

ok, holup

using UnityEditor.Purchasing;
using UnityEngine;


public class mortem_rifle_script : EnemyBase
{
 void chase()
 {
     Debug.Log("deberia estar persiguiendote");
     chasing = true;
     if (debeDisparar == true && reload == false)
     {
         if (distanciaAbsoluta > rangoDisparo)
         {

             animator.Play("Base Layer.MRifle_Walk");
             transform.position = Vector2.MoveTowards(transform.position, objetivo.position, runSpeed * Time.deltaTime);
             bullettimer -= Time.deltaTime;
             if (bullettimer <= 0)
             {
                 bullettimer = firingspeed;
                 disparar();
             }
         }
         else
         {
             bullettimer -= Time.deltaTime;
             if (bullettimer <= 0)
             {
                 bullettimer = firingspeed;
                 disparar();
             }
         }

     }

 }
}```
#
public class EnemyBase : MonoBehaviour
{
    public int health;
    public Vector2 boxSize;
    public float distanceRay;
    public LayerMask groundlayer;

     void update{
chase()
]

  void chase()
{
debug.log("u need an chasing code in ur enemy")
}

}```
sour fulcrum
polar acorn
acoustic belfry
teal viper
acoustic belfry
#

so i just put the sufix virtual on all the methods in my base, and then put override in the methods of my enemy?

teal viper
#

So if it's a mortem_rifle_script reference, the chase method defined in it would be called. If it's the base class reference(even if the instance is actually the extending class), then the base class method would be called.

teal viper
acoustic belfry
stuck palm
#

if I have an editor script added to a gameobject, will it strip it from the gameobject in the build?

teal viper
twin pivot
#

im getting a null reference at line 20 and 24

#

the script component i attached to it gets deleted when i start the game for some reason

slender nymph
#

or rather more specifically, the object with this component on it does not also have an Upgrade1 component on it

twin pivot
slender nymph
#

then show its code

twin pivot
slender nymph
#

that is a single method that isn't even what would cause it to delete itself

frigid sequoia
#

What's.... the difference between these 2?

twin pivot
slender nymph
#

the second is deprecated

#

literally how the fuck should i know if you won't show relevant code for that

twin pivot
slender nymph
#

okay now show the code i actually asked for

twin pivot
#

the code in upgrade1?

slender nymph
#

yes

twin pivot
slender nymph
#

well there's nothing there that would cause it to be destroyed, so you're gonna need to investigate what could possibly be destroying that component

twin pivot
#

yes i am aware

#

i was asking if instantiating a copy of all of these could be what was causing this

frigid sequoia
#

Okay, I will use the other one then

slender nymph
slender nymph
frigid sequoia
#

Any particular reason why that method is no longer in use? Seems pretty alright

twin pivot
frigid sequoia
#

I guess they touched the whole gameObject scripts

slender nymph
slender nymph
# frigid sequoia Any particular reason why that method is no longer in use? Seems pretty alright

the FindObjectXXX methods were deprecated in favor of a group of methods that can optionally perform the sorting that the previous versions of the methods were already doing. FindFirstObjectByType does exactly what FindObjectOfType did, it gets all of the objects of that type, sorts them by instance ID then returns the first. There is an alternative FindAnyObjectByType that does not do that sorting though

strong wren
#

The deprecation message should show you this information. Make sure your IDE is configured.

frigid sequoia
#

There is just a single one, so i guess I should do the FindAny

slender nymph
#

or use a better way to get a reference, even the unity docs suggest using the singleton pattern over the Find methods if you only have a single object of that type

slender nymph
strong wren
#

Ah, makes sense for a backport.

sour fulcrum
#

wasn't it introduced earlier than 6 tho

slender nymph
#

in 2022.2, which is also when 2023 was in alpha. so new addition for 2023, but backported to 2022.2

frigid sequoia
#

Oh, yeah, I should totally be using that as singleton, I don't know why I wasn't

#

In fact all these should, huh

#

Is there a way to make the whole Main Components and its children don't destroy on load from the inspector or do I have to make a script just for that?

slender nymph
#

gotta do that in code

cosmic dagger
twin pivot
frigid sequoia
#

I have a question, it's not gonna happen, but I am like curious to know how this goes. How does it work when you have stored data and release a new build? In like.... Let's say you just realized a particular weapon is way too strong and decide to tune it down but the player already has that as saved data on their character? I am guessing you would need to save all that kinda stuff as SO and the player just saves references to those that get updated as soon as used?

#

Else the player would find that... his wooden sword in particular is like damage 10 but all others wooden swords for now on are like 8?

teal viper
#

Some games might have stat randomization or modification features. Depending on how they are implemented, the player might indeed retain stats from before the update.

#

Basically, it's all up to you

sour fulcrum
frigid sequoia
#

The thing is... the player is intended to ultimately assembly a whole roster of players of different clases, with different stats, skills and equipment. I would need to store the whole roster as saved data, and be able to modify it later if needed

#

So for example if the player saves a warlock on the roster and that warlock has a summon imp skill; if I want to later modify the skill and affect all players it would need to be stored as an static SO and just give the player the reference to that right?

sour fulcrum
#

when you mean save do you mean in a single play session or multiple play sessions

teal viper
frigid sequoia
sour fulcrum
#

if you launch a game, modify a scriptableobject and close the game the scriptableobject won't save that change

#

you need to compose a way to save stuff yourself (usually using Json)

frigid sequoia
#

Ok... and can I just add whole scripts to a SO no issue right?

sour fulcrum
#

i have no clue what that means with and without the context of this conversation

frigid sequoia
#

I mean, in the previous example. I would need to have a reference to what a warlock is through a SO (cause I intend to save the player having one of those). This implies several scripts attached, one for each skill for example. If I want to modify the whole logic of an skill I would have SO that has a reference to that script of the skill.

sour fulcrum
#

the word script does not make sense in this sentance

#

do you mean another scriptableobject? a monobehaviour? a base class?

#

because you don't put scripts anywhere

teal viper
frigid sequoia
#

I do not intend to modify SO at runtime whatsoever

#

And I would need to save a player having X character on the roster. These all are the scripts that make a character for now. All these are mostly common to all entities. But a rogue in particular has X stats, a particular behavior script for him alone a skill script that is particular to them

#

I could save the rogue as a prefab and make the save date "Player has a rogue", but I would need to save like different instances of that rogue not being any rogue, but THAT particular rogue. It having stuff like equipment or a given name. That could not be saved as part of a prefab. So I would need to store all that as SO?

teal viper
#

You'd need to create serializable data for each of the scripts and save it as json or something.

sour fulcrum
#

You cannot save gameobjects or scriptableobjects at runtime

frigid sequoia
sour fulcrum
#

based on the messages in this conversation i don't know if that is true?

teal viper
frigid sequoia
#

I mean, it would be fucking great if could just plug the whole gameobject and save it, but I know that's not a thing sadly

teal viper
#

Yeah, I also had the feeling we're talking about save game system

obtuse ether
#

coding in something to send you to the next level while also saving what level you're on

sour fulcrum
obtuse ether
#

and for some reason its skipping from level 2 to level 4

#

and its triggering ontriggerenter twice i think?

#

anyone know why

eternal needle
teal viper
obtuse ether
#

shouldve checked tag of the thing colliding w it

#

bc if anything enters its trigger then poof next level

obtuse ether
twin pivot
teal viper
#

How do you know that?
Is it assigned in the first place?

ruby zephyr
#

May I already try making extremely simple games to practice? As I am only able to learn programming in c# and Don't have any idea how to program on Unity since I never had the idea of trying.

Here's a summary of what I know in c#

Basics of C#: Variables, data types, input/output, type conversion

Conditional Statements: if, else if, else, nested conditionals

Operators: Relational (>, <, ==, !=), Logical (&&, ||)

Basic User Input Handling: Reading and validating input (Convert.ToInt32, ReadLine)

Basic Debugging Skills: Identifying syntax errors and logical mistakes

Simple Programs: Grade average calculator, username-password validation```
#

I wanna apply these to Unity to at least experience programming in Unity while Learning c#

ivory bobcat
#

You would not be able to apply i/o operations from console applications

eternal needle
eternal falconBOT
#

:teacher: Unity Learn โ†—

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

ruby zephyr
nimble apex
#

๐Ÿค”

eternal needle
#

Yea maybe dont do that. And also don't use AI generated anything here

#

no one wants to read AI written text and definitely dont want to be responded with it either

ruby zephyr
#

I learn with chatgpt, ask questions for deep explanations but I dont work with them since I know I would not learn

ruby zephyr
ivory bobcat
#

Main issue with learning from ai would be not being able to validate what it suggests

eternal needle
#

Learn with an actual resource instead of a spam generator. Theres TONS of guides online for everything

eternal needle
ruby zephyr
#

Yes I'm watching a course on YouTube and so far I think I'm learning any way, but in Unity, I wanna start learning since the lessons that I am learning is only about programming

eternal needle
ruby zephyr
sour fulcrum
#

sure

#

it's called writing

#

if your gonna be programming you'll be doing a lot of it

nimble apex
#

the biggest problem so far is AI will lie with confidence, they will confidently answer u with wrong answer like its 100% right

#

and they dont even know theyre actually lying

eternal needle
nimble apex
#

lets say u learnt to chapter 6 , and u ask chatgpt, it may confidently answer

yes, now you have learnt to chapter 3 so far

ivory bobcat
ruby zephyr
#

Good point, then language translations, grammar corrections by ai are discouraged?

nimble apex
#

do not let chatgpt represent ur learning curve, question, answer

i had failed damn hard with that

nimble apex
#

but normally google translator should do....

eternal needle
#

moving on from the whole AI part, truthfully you've learned the absolute basics of c#. I suggest looking more into functions, classes/instances, and then you'd have an ok foundation to at least understand how things work in unity.

ruby zephyr
#

Alrightt, should I learn some in Unity since classes are in Unity right? I dont even know what to call them

eternal needle
#

you can say you learned if statements and variables, but at the same time you've had so little experience it's doubtful you'd be able to write these programs easily

ruby zephyr
#

Oh, how about rigid body things

nimble apex
eternal needle
#

Unity has components, which are classes yes, but you're going to be very confused if you don't understand how to access information on a class

nimble apex
#

the main container is class

ivory bobcat
nimble apex
#
public class abcde{
     //content
}```
eternal needle
ruby zephyr
#

Because they say we can freely join game jams, and I kinda wanna join one for experience, but since I don't even know how to apply my knowledge in Unity, how would I do.

eternal needle
#

the best thing is really not to try and teach such concepts and let them go use actual guides imo.

nimble apex
#

u should have the link already

#

or additional info for C#

ruby zephyr
#

New to Unity?

Learn With Pathways

Check out new courses

nimble apex
ivory bobcat
shrewd gazelle
#

hey guys if a script has name space in it do you guys know how I. an access variables from another script becuase it is not letting me

ruby zephyr
#

Is this the right place?

polar acorn
shrewd gazelle
polar acorn
shrewd gazelle
#

So I want to use variable from another script inside the script that has namespace in it. but if theres no way to do that I think I can figure it out based on what you said.

polar acorn
#

Once you add the using statement the namespace no longer has any effect

teal viper
#

At least not in regards to code outside the namespace.

teal viper
shrewd gazelle
#

ok Ill share it but fyi Im aware that my script is not clean Ill clean it later lol. what was that website that you guys use to share

teal viper
#

!code

eternal falconBOT
shrewd gazelle
#

so I just want to be able to access varibale from sonartaken script and use it inside the sonnar script

teal viper
shrewd gazelle
#

ok

teal viper
#

Still doesn't link to your code.

#

Look at the url before sharing it. It should contain extra characters, not just the base url.

shrewd gazelle
#

I put both scripts on top of each other

teal viper
shrewd gazelle
#

this is what I get in my console

frigid sequoia
# frigid sequoia In fact all these should, huh

Ok, I am extremely confused, cause I turned all those scripts into singletons and make them don't destroy on load and now it's returning me this error. But... it doesn't make sense, cause it's working, and that could not work without a reference at all so....

#

Wtf?

teal viper
teal viper
teal viper
frigid sequoia
#

Yeah, that's the only thing that could be happening, but... the script is working, at the same time that is telling me it does not have a reference to the players... how?

#

I am extremely confused

shrewd gazelle
#

like this @teal viper

teal viper
teal viper
# shrewd gazelle

Mmm... Vs code is not gonna help much. Especially since it not configured correctly for unity.

keen owl
shrewd gazelle
#

this is visual studio code the blue one

teal viper
frigid sequoia
#

Oh, I think it's calling the OnEnable twice

teal viper
frigid sequoia
#

Does that trigger by default at the start if the component starts enabled?

shrewd gazelle
teal viper
shrewd gazelle
teal viper
#

No. In C#, code can belong to different assemblies. These would normally compile to separate dlls. Basically, separate modules of a program. Code in one assembly can't see code in another, unless the other assembly is referenced correctly.

#

If you have a project manager, maybe ask them for help. They should know enough about the project to tell you why the other script is not recognized in your code.

shrewd gazelle
teal viper
shrewd gazelle
twin pivot
# teal viper Unassigned when? Where?

When i start the game, a script thats a component of tmp text, before i start it it says it was assigned but if i check after i start it its no longer there

#

oh my god i just figured it out

teal viper
twin pivot
near wadi
molten monolith
#

Hello, unity noob over here, I experimented a bit with RPC calls and was wondering if fusion + photon voice would be a good solution for a solo project by a beginner ( I have C# xp, just 0 experience game developing )

The project I'm making is based on proximity chat

hot harbor
#

What's a good way to expose the tag property of a gameObject, similar to how one would do layermasks for rigidbodies?

#

As in I could expose it as a public field and modify the values

#

I searched and came across editorGui.Tagfield but that's not exactly what I needed

#

For context I wanted to have a way to distinguish between ally and enemy projectiles, and they happen to be on the same layer so tags were the choice that came to mind

#

However I wanted to use a scriptableObject for the configuration and seting the tag instead of manually configuring each prefab

fleet onyx
#

hello, does anyone knows what this error is? :

TransientArtifactProvider::IsTransientArtifact call is not allowed when transient artifacts are getting updated

burnt vapor
gleaming bridge
#

silly question but how do i round of the edges for a square image

frosty hound
obtuse sluice
#
        animator.SetBool("Walk", horizontalMovement != 0);
        animator.SetBool("Jump", !isGrounded && rb.linearVelocity.y > 0);
        animator.SetBool("Fall", !isGrounded && rb.linearVelocity.y < 0 && !isWallJumping);

Can someone help me where my logic is maybe wrong?
so every animation works well, just the fall wont trigger

#

I set
Jump => Fall to true
and
Fall => Idle to false

burnt vapor
obtuse sluice
#

Okay got it nearly right now. now the jump is sometimes triggered after fall instead of idle. I try to fix it

#

thanks

stray wigeon
#

!vscode

eternal falconBOT
#
Visual Studio Code guide

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

https://on.unity.com/vscode

stray wigeon
#

Hey, I'm new to unity, trying to make a small game prototype with some funky movement. I am kind of confused as to why I do not have code autofill (tab) or hints about what certain functions or lines of code do for VScode like most guides show? I have Unity Code Snippets installed and the Unity extension for vscode. Any ideas?

frosty hound
eternal falconBOT
frosty hound
#

VSCode is finniky at best though. If you want something reliable, use Visual Studio or Rider.

stray wigeon
#

to this in a couple seconds:

#

And intellisense still doesn't work. Guess it's time to just switch to VS

frosty hound
#

Yeah, I don't use VSCode at all for Unity

slender nymph
stray wigeon
stray wigeon
polar dust
#

VSC isnt a "real" IDE, its basically a text editor with extensions to let you do IDE things

verbal dome
#

In practice it does pretty much everything that VS does

#

In unity context at least

hot harbor
#

I was wondering if anyone could give me some suggestions on configuring 2d movement?

I've implemented the entire thing based on modular movements where every move is a scriptableObject to be executed by a state machine that has an array of said movements

My question is if there was an easier way/better way(s) of setting this up, since I've found that every small change in say, speed or direction values calls for a new scriptableObject

Code is in pastebin
https://pastebin.com/HJCcbc88

#

Also i'm aware that if I want collisions it'd be best to use rigidbody.Move; I've just yet to refactor things

verbal dome
#

Do you really need the moves to be this configurable/modular, instead of just making concrete classes/functions for different moves? Do the moves always share a lot of common variables?

verbal dome
hot harbor
verbal dome
#

If you are referencing a scriptableobject, you aren't creating a new one (hopefully) every time you read its variables

hot harbor
hot harbor
verbal dome
hot harbor
#

what did you have in mind instead of this?

#

I also think it's quite cumbersome...

verbal dome
#

Idk, the caller passing in the direction as a parameter

#

But i don't know enough about your game to judge it

#

One idea is to make the MoveConfig abstract and split it into child classes that implement only the stuff they need

hot harbor
#

I even wrote a custom editor just to separate linear from circular and etc etc๐Ÿ˜‚ proves to be completely unnecessary if I had split them into child classes

#

Thanks

slow knot
#

does making a completely physics based camera as a gimmic work well, not just like its affected by physics but like almost like it moves back and fourth based on how fast you go and stop almost like a cartoon at sudden movements

verbal dome
slow knot
#

is this the wrong channel for that question?

slow knot
verbal dome
#

Or do you need collisions and physucal interactions with the camera?

slow knot
#

maybe its not fully decided but one of my ideas was to have the camera move with the head which uh i now realize i should probably just write a normal camera script and acnhor it to the head and make the ehad do the calculations...

slow knot
#

maybe the head anchoring method would work better, either way im almost done with the rigidbody camera script and ill have to test it out... afterrr i fix my bad ahh player movement

stray wigeon
#

Not sure where to ask, but I can't get grid snapping to work with rotation. Only XYZ movement. Or does unity not support that?

verbal dome
#

Hold ctrl (or shift?) While rotating to snap

stray wigeon
#

Ctrl works. Thanks. Couldn't find it for the life of me. (Or I am just bad at google)

stray wigeon
vague charm
#

Hello, I am trying to make the water tiles in my game add speed to the user when they interact with the water but every time I try to add a tile with a script to the tile palette it won't appear to place. I thought I was supposed to make a prefab and then I would be able to make them but I'm not quite sure what I am doing wrong

rich adder
#

Tiles arent meant to be GameObject / SpriteRenderer

#

drag the sprite tile from the project folder and put them in the Tile Palette

#

On that note if you want to use GameObject as tile (for interactions and whatnot) Then you use gameobject brush instead. These can't be put in tile palette but also they are nested in tilemap object but they are not part of the tilemap technically

vague charm
#

I see, I was trying to add them straight to the palette(after the script was attached) but it kept saying invalid. So am I sup--ooooooh

#

Ok i will give that a try

#

It worked ๐Ÿ˜ญ thank you very much

slow knot
#

is it linearVelocity or just velocity when working with cameras, im getting told velocity but VS code doesnt aggree

pure drift
#

!code

eternal falconBOT
polar acorn
#

There is no such thing as .velocity any more, anywhere

rich adder
polar acorn
#

It was renamed to avoid ambiguity with angularVelocity, which has always existed

#

But technically the field velocity would imply it controlled both

#

Which it never has

pure drift
#

https://paste.myst.rs/gtnn6dq2 with this code how can i make my asteroids spawn smaller versions of themselves 2 times right now it splits apart once but i cant do it after that

polar acorn
#

So, a script with a field for "SmallerAsteroidPrefab" or something, and as long as that's not null, spawn two of that when it dies

pure drift
polar acorn
#

You could use whatever script you want

rare elm
#

hi. i bought a game kit that uses a Timeline to define when creatures should be added

mostly it's a good metaphor, but there are times at which having it as code or data would be better (mostly during bulk editing)

is the timeline a UI only thing, or is there some way to get it as code/data?

polar acorn
#

But the easiest way is one on the asteroid itself

maiden totem
#

just to make sure, Player.Look is already affected by framerate and will be smaller the higher the framerate is? So I don't need to multiply the lookVector.x * mouseSensitivity by Time.deltaTime? Or do I still need to? Assuming this is in Update()

slender nymph
#

if it is mouse input then yes, it is already framerate independent. if it is joystick input then no, it is not

maiden totem
#

So I don't need to multiply by deltaTime I suppose?

slender nymph
#

you do when it is being used for joystick input

maiden totem
pure drift
cloud walrus
#

For anyone that took Unity programming pathway, how sufficient did you find the course?

slow knot
#

right now its just seizure simulator since its like 80 lines which isnt enough for this really. and at the same time im bad at these kinds of maths so i might be cooked

#

also how do i call this function

rich adder
# slow knot

Unity calls this function when there is a collision exited between a rigidbody +collider and another rigidbody/collider

slow knot
#

ah so i dont need to add it to my update loop? great

rich adder
#

na. Just like Update these are called by unity

pure drift
polar acorn
pure drift
#

ohh ok thank you so youre saying i shouldnt do it like how i am doing it right now i should create two prefab varients

edgy spruce
#

Does this always take so long to download?

pure drift
mystic ferry
edgy spruce
mystic ferry
silent valley
rare basin
#

anyone might be able to help me? i am trying to make drag&drop inventory system, but cannout figure out, why the OnBeginDrag doesn't work.

public void OnBeginDrag(PointerEventData eventData)
{
    print("begin drag");
    if(CurrentItem == null) return;

    _dragHandler.StartDrag(this);
}

I have implemented the IBeginDragHandler interface

#

and I do have a Image component

#

on that MonoBehaviour

#

and nothing overlapping that image

#

and event system present

slender nymph
#

view the event system at runtime to see what it detects when you try to drag that object

rare basin
#

the Selected: at the very bottom?

slender nymph
#

it has a preview window at the bottom of its inspector that will show you useful info like that

rare basin
#

yea it's always nothing

#

even when i hover the mouse over my inventory slots

#

just wondering what's wrong, as I have nothing above the inventory slots, just started the project

#

that's the only UI I have

slender nymph
#

and if you actually set a sprite on the image does it work?

rare basin
#

no, doesnt work aswell

#

but if i add a Button component under the inventory slot

#

it's interactable

#

changes color on hover etc

#

i thought it's possible to make IBeginDragHandler with just a Image, right?

slender nymph
#

it is. which component actually implements the interface?

rare basin
#

InventorySlot

slender nymph
#

and your canvas has a GraphicRaycaster, yes?

rare basin
#

the InventorySlot object doesn't have Image comopnent, the background and item icon has

#

but I have also tried adding one

#

same result

slender nymph
#

the object that actually has the component that implements the relevant event system interface has to be the one with a graphic that can be raycasted against. so if InventorySlot has the InventorySlot component then it must be the object with the image on it and there cannot be another image overlapping it (like Background and/or Item Icon) unless those are not raycast targets

rare basin
#

okay got it, but it still doesnt work as i mentioned

#

this is inventory slot, with image as a raycast target

#

background and item icon has raycast target DISABLED on their images

#

it still doesnt print for whatever reason

#

there is absolutely nothing else covering/overlapping the inventory slot image

#

funny thing is, that when i add EventTrigger comopnent

#

to InventorySlot

#

and assign something random to just test if its working

#

then its working

#

yes my VS is saved ๐Ÿ˜„

slender nymph
#

are you sure about that

rare basin
#

yes

slender nymph
#

did you make sure it actually compiled too?

rare basin
#

yes

#

i have even restarted unity and PC

#

there is even a thing like that in inspector

#

why would EventTrigger work but not IBeginDragHandler

#

on same setup

rare basin
slender nymph
#

if you also implement IDragHandler does it start working?

rare basin
#

umm yea lol

#

it works now

slender nymph
#

okay so i guess IBegin/EndDragHandler require IDragHandler to work. which kind of makes sense considering you can't begin dragging without also dragging

#

plus you probably wanted full drag functionality and not just detecting when dragging has only started

rare basin
#

so my idea was that i will handle

#

all dragging and dropping in

#

InventoryDragHandler instead

#

should I keep everything inside InventorySlot then? I wanted to kinda separate it to keep single-resposnbility

slender nymph
#

how would that separate object detect when you have stopped dragging

rare basin
#

i did OnEndDrag in InventoryDragHandler

#

and OnDrag

slender nymph
#

okay, so how would that detect when you've stopped dragging a completely different object

rare basin
#

so basically i did only start drag in InventorySlot then activated drag handler and the ondrag started to work there

slender nymph
#

again, neither OnDrag nor OnEndDrag would be called on a separate object

rare basin
#

hm, i see ๐Ÿ˜„

#

then i will do it all in InventorySlot

#

thanks

slender nymph
#

you can still separate that functionality out to a different component, but that component just has to be attached to the object being dragged

rare basin
#

i just had a issue, where when I was dragging a Image's rect transform

#

from a slot1

#

it was "under" slots10

#

so i wanted to set it as last sibling temporarily

#

when dragging it, and setting it back as a child to original slot

#

is that a good idea?

#

it works, tyvm

#

oh and btw @slender nymph, you don't even need Image on the InventorySlot component, just having the Image as a child works aswell

#

just wanted to lyk

pure drift
#

!code

eternal falconBOT
pure drift
#

how can i make my instantiated gameobjects faster for example i want the small and medium asteroids to be faster

polar acorn
#

Nothing in this code seems to be moving them in the first place

#

Well, it wraps if it's off screen

#

So what actually moves the objects

pure drift
polar acorn
pure drift
#

oh ok thank you i guess i can just use a serializefield and adjust it for each of the prefabs

polar acorn
#

Yeah that's probably the best way

pure drift
#

thank you

proud bloom
#

hi, im having an issue where my bullet prefab that holds the bullet script wont let me assign the enemy gameobject or the empty EnemySpawn onto it. i try and it says type mismatch. here is how i have it set up, any help would be appreciated. this is the code, im trying to enable the Enemy after disabling it when its hit by a bullet.
https://paste.myst.rs/6dazt4rj

polar acorn
#

you need to set the reference on the instance of the bullet after you spawn it

proud bloom
#

Hmm ok thats what i figured, how would i go about doing that? this is where i instantiate my bullet in my player script. i have a empty gameobj for the bullets to go into on spawn would i do anything with that?

proud bloom
#

GameObject

polar acorn
#

You should use the type you actually want instead, most likely Bullet.

#

Then, instantiate will return a reference to that Bullet and you can set its Enemy field

proud bloom
#

this is all im using besides my bullet script and my prefab

grand snow
proud bloom
#

thank you ill try that

onyx narwhal
#

does anyone know how to rotate a capsule collider in Unity 2D? ๐Ÿ˜ญ

timber tide
#

Usually you can flip stuff by setting the x scale negative but not sure how that works with physics

#

otherwise flip the collider values in a script

onyx narwhal
#

damm i thought there was just a "rotate collider" button or something ๐Ÿ˜ญ

teal viper
#

I'm general, you should keep visuals separate(separate gameObjects) from physics and game logic

neon forum
#

why, when naming my script "game Manager" it became a funny gear?

wintry quarry
neon forum
#

ah, okay, ty

wintry quarry
#

Kind of a Unity Easter egg tbh

neon forum
#

neat

#

did old unity scripts always look like gears?

wintry quarry
#

No just GameManager

neon forum
#

fair enough

sand mesa
#

my public variables aren't showing up in the inspector

#

any ideas?

timber tide
#

Ya got a canvas on the GO

#

rect transform even

#

Ah, you're just serializing other images onto this manager

wintry quarry
timber tide
#

Yeah wrong namespace probably

wintry quarry
#

Make sure you have using UnityEngine.UI instead of using UnityEngine.UIElements;

sand mesa
#

oh

timber tide
#

Don't need that SerializeField either if you set it as public

wintry quarry
#

i'm sure that was an attempt to debug/fix but yes

sand mesa
#

chears

sand mesa
#

... hm

#

why is it saying opened dialogue has content, but closed doesnt?

sour fulcrum
#

the field declarations there only apply when the class is initialized

wintry quarry
#

reset your component

sour fulcrum
#

so if you added that component before adding that "locked. damnit" it won't appear after the fact

sand mesa
#

oh i see

polar acorn
#

The values you put in code for a serialized field are just the default values

#

The inspector takes precedence

noble forum
#

Hey, i feel dumb asking this as i have been programming in unity for a while, but im left confused. It seems i get the null from that but at the same time it is assigned?

glacial forge
#

what is the correct way to get a tilemap collision? I see there are multiple collider functions you can use OnCollisionEnter2D and OnTriggerEnter are 2 that i have tried, but none are working

here is my current code

private void OnCollisionEnter2D(Collision2D other)
{
 Debug.Log(other.gameObject.tag.ToString());
}

This is attached to my player which has a rigid body 2d and a circle collider. My tile map has a tilemap collider and its tag is set to "World", yet when i play the game nothing happens. i turned trigger on (for both player and tilemap) when using the on triggerenter method

wintry quarry
#

once it works properly

#

the other time it throws an error

#

You might have multiple copies of the script in the scene

noble forum
#

Oh, that would explain things

#

Only that im almost sure its a single copy, let me see

wintry quarry
glacial forge
#

dynamic

#

not sure what the difference is there

#

so i left it default

rich adder
glacial forge
#
void ApplyMovement()
{
    float speed = moveSpeed;
    if (inputHandler.SprintValue > 0)
    {
        animator.speed = sprintMultiplier;
        speed *= sprintMultiplier;
    }
    rb.linearVelocity = new Vector2 (velocity.x * speed, velocity.y * speed);
    //animator.SetFloat("Horizontal", velocity.x);
    //animator.SetFloat("Vertical", velocity.y);
    //animator.SetFloat("Speed", velocity.sqrMagnitude);
    
}
#

that function is called in fixedupdate

noble forum
#

It's quite a big script, so there is no way i missed another copy

#

Also i don't see it anywhere

glacial forge
# glacial forge ```cs void ApplyMovement() { float speed = moveSpeed; if (inputHandler.S...

velocity comes from my input handler

private void Awake()
{
    if (Instance == null)
    {
        Instance = this;
        DontDestroyOnLoad(gameObject);
    }
    else
    {
        Destroy(gameObject);
    }

    moveAction = playerControls.FindActionMap(actionMapName).FindAction(move);
    jumpAction = playerControls.FindActionMap(actionMapName).FindAction(jump);
    sprintAction = playerControls.FindActionMap(actionMapName).FindAction(sprint);
    RegisterInputActions();
}

void RegisterInputActions()
{
    moveAction.performed += context => MoveInput = context.ReadValue<Vector2>();
    moveAction.canceled += context => MoveInput = Vector2.zero;

    jumpAction.performed += context => JumpTriggered = true;
    jumpAction.canceled += context => JumpTriggered = false;

    sprintAction.performed += context => SprintValue = context.ReadValue<float>();
    sprintAction.canceled += context => SprintValue = 0f;

}

This is just getting the inputs from the input system and assigning a vector based on that for the player controller to access

rich adder
glacial forge
#

Player:

#

Tilemap:

austere crypt
glacial forge
glacial forge
rich adder
glacial forge
#

yup just comment on that its already back

rich adder
glacial forge
glacial forge
rich adder
#

ahh your player is trigger

glacial forge
#

ah didnt realize trigger stops it from detecting

#

thought they both needed to be trigger

rich adder
#

OnCollisionEnter needs both solid , OnTriggerEnter 1 can be trigger and other solid as long its dynamic

rich adder
glacial forge
#

ah ok makes sense

one more thing, what is the correct way to get the object form the collider? I thought i could just do an as but I cant so I'm not sure what is best practice

private void OnCollisionEnter2D(Collision2D other)
{
    Debug.Log(other.gameObject.tag.ToString());
    Vector3Int pos = new((int)other.gameObject.transform.position.x, (int)other.gameObject.transform.position.y, (int)other.gameObject.transform.position.z);
    (other.gameObject as Tilemap).SetTile(pos, null);
}
wintry quarry
#

GameObjects are never Tilemaps

#

Use GetComponent

#

Tilemap is a component on the GameObject

#

it is not the GameObject itself

glacial forge
#

ah i see

wintry quarry
#

also note that Collision2D is not the same as Collider2D

#

Collision2D is a struct that contains information about the collision.

noble forum
glacial forge
wintry quarry
glacial forge
#

is there any reason not to turn on trigger for the tilemap?

wintry quarry
#

Do you want it to be a trigger or a physical collider

#

If you want it to be a trigger, make it so

glacial forge
#

i cant say i know the difference other than it will trigger or not

wintry quarry
#

Triggers are not solid objects

#

they exist merely to facilitate OnTriggerEnter etc

#

objects will not physically collide with them

glacial forge
#

ah ok, well in this case it doesn't matter since its instantly destroyed when the player touches it so there are no physics to be done with it.

is a trigger collider easier on the computer then since its taken out of physics?

wintry quarry
#

it will bump into it

rich adder
wintry quarry
#

no triggers are not "easier on the computer"

glacial forge
#

better/worse performance was the wording i was looking for, but fair enough. essentially though its just a digging game where the player is falling down. Its gonna be fixed velocity down with a/d controls and blocks break as the player runs into them. so i dont care about physics since the rate of movement wont be changed by the world other than maybe changing the velocity by calculating what kind of tile is going through

#

if it doesn't make a difference on performance I will switch it to a trigger collider and just use on trigger enter

glacial forge
#

Perfect, got it all working. Thanks!

ruby zephyr
#

Guys, do you think it would be worth it to go through an online course that is paid to learn game development specifically in unity? Ignore the expenses.

naive pawn
#

paid
no

#

!learn

eternal falconBOT
#

:teacher: Unity Learn โ†—

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

naive pawn
#

the internet is full of free resources

#

you absolutely do not need paid courses

ruby zephyr
glacial forge
#

What is the correct way to implement global data in a game? This isnt just the settings menu where you change sound, im talking data alot of objects will look at and use for calculations/ some setting on how certain objects behave.

In my research i have seen 2 main methods and that is just make a static class which is what im familiar with outside of unity, or make a singleton script. Im not sure how to make a singleton script persist through scenes though so I dont know if that is relevant.

Just trying to learn best practice for future reference

onyx cove
#

Hi, I'm currently using the Meta Voice SDK and having issues, but I'm not sure why. Does anyone know why I'm getting these errors?

grand snow
glacial forge
naive pawn
#

the only difference in paid courses is that they're paid
there's not really a difference in quality

grand snow
#
public static MyClass instance { get; private set;}

private void Awake()
{
  if(instance == null) instance = this;
  else Destroy(this);
}
glacial forge
#

it would contain data other objects would use in their start function. also my game transitions between scenes alot. so I was just thinking I didnt want to drag it into every scene/make an object for every scene because that seems bad. is there a reason to do it this way over a static class or is it just so you can use inspector on it?

ruby zephyr
grand snow
naive pawn
#

if you have the persistence and willpower to put in effort, you can learn without a dedicated helper just fine
just gotta utilize the resources you have, and free resources are plentiful
if you ever have a specific question that you can't find answers online for, you can always ask here for free

glacial forge
#

its literally just holding values for other objects

#

thanks!

naive pawn
# ruby zephyr How about a mentor? Would make a big difference?

another point; having a mentor falls into a similar hole as trying to get direct/dm support; it's only one person. they won't always be free, and 2 eyes on a problem can easily miss subtle details. community support, like this server, gets around this by utilizing a whole community to see your issue and potentially point out causes (or even unrelated issues)

(and that's assuming a mentor is fully competant, sometimes inexperience in a specific topic can lead to misdiagnosing problems)

ruby zephyr
glacial forge
#

@ruby zephyr my 2 cents may not matter much here, but as someone who has tried making a game multiple times and failed I can assure you it has never been becasue i couldnt figure out how to do something. What killed most of my games was just passion/time. if you have infinite time and you actually want to make a game then there is plenty of free resources everywhere. There is tutorials for almost everything and unity manual/ this discord has gotten me the rest of the way. in my opinion the only thing paying for tutorials would have done for me is burned money

naive pawn
# ruby zephyr I don't really consider myself slow enough to not follow tutorials, maybe I'm ju...

oh, everyone needs time.
gamedev is not a single skill, it's composed of many different aspects
graphics, programming, design, audio, and then weaving it all together.

programming itself isn't a single skill either; it's decomposing a problem, designing a solution, debugging, understanding errors, being able to research effectively

so it will take time and patience. maybe you might be underestimating how much it takes.
but if you have the will to practice those skills, you will get as far as you want. (there's not really an end to a journey of developing skills)

#

also, if you aren't confident you'll be able to develop those skills enough to be a game, don't worry about that
if you want to learn now, start learning! whatever you learn will be transferable to other situations or projects or whatever, and maybe you'll find the confidence as you build your knowledge and experience

ruby zephyr
#

That's enough to encourage me, thanks! I guess I'll just finish all tutorials in Unity Learn, try, and Improve.

brave compass
#

I would say paid courses or mentors can have an element that free resources do not, which is accountability. If you've given money to a person and there's an expectation that you will be somewhere at a time (physically or virtually), it's a push to keep going.

#

You don't need that push if you're super passionate and self driven to learn. But not everyone has that, and some elements of game dev can be boring to learn.

naive pawn
#

i mean, you can do that yourself with project planning

#

deviate from learning the actual gamedev for a sec to plan out your learning/development journey, set appropriate milestones

brave compass
#

The extreme end of that is university. It's pretty easy to give up on your own plans, but dropping out of school is a bigger deal.

glacial forge
# ruby zephyr That's enough to encourage me, thanks! I guess I'll just finish all tutorials in...

the thing that i find is the most helpful is just getting excited about an idea. just make sure your first project is simple that you can do it quickly but still interesting enough that you want to pursue it. you can definitely just watch tutorials to watch tutorials, but having an idea first i find to be helpful so you can learn different examples and methods from tutorials. Of course I come from a strong programming background so if you dont have that foundation I would definitely work on that. just getting your first win always feels nice!

as to accountability im making a game with a friend this time so we are keeping each other accountable but like listed above there are a few ways to do that.

naive pawn
ruby zephyr
#

So what should I really stick to learning?

#

I was told to learn programming of c#, learn Unity hub's environmental, (tools, stuffs inside), and try to apply in game development

#

Currently I'm only learning basic c# and could not apply it to unity

naive pawn
#

learn about stuff relevant to your goal

#

if you don't know how to code, then yeah some basic c# before going to unity c# would be nice
there are also some resources pinned in this channel

ruby zephyr
#

Really?, like what, if I want a shooter game should I not learn how to make a horror game as well?

#

Lets say, I want to make a variety of Indie games

naive pawn
#

well, if you want a shooter game, you wouldn't need to learn about, say, dynamic audio cues

#

it's not like learning is a one-time thing

#

focus on your current goal

#

if you want to make a horror game, learn about that
if you want to make a shooter game, learn about that

brazen crescent
ruby zephyr
naive pawn
#

i mean you wouldn't be learning about how to make a shooter game
you would be learning, say, first-person controls, basic inventory systems, HUDs, physics, modelling, sound effects
a lot of that would be applicable to a horror game too
but some wouldn't, like reloading mechanics. unless you can shoot the monster, idk.
and some skills would be more specific to horror games, like playing with dim lighting, or elaborate animations or cutscenes, or writing a story

if you're currently making a shooter game that doesn't have those elements, then no need to learn them yet

naive pawn
#

you don't need to make a game for each step

#

as you learn more, you'll be able to make more complex mechanics/games

ruby zephyr
#

Here's what I wanna do:

When you told me to learn the things that I just want, but then I wanna develop different genres as well which would mean I have to learn different mechanics,

I had a plan of learning the easiest components of games like,

  • I'lll make a button to play,
  • simple wasd movement
  • and other more
#

So for every game I'd have to learn how to make something that they all have in common?

Then I'll learn how to make a character, make it move, and interact. Because this applies to many games.

#

_
_
I have actually never thought of that idea.

trail heart
#

@ruby zephyr Even if there's nothing in paid learning resources that isn't out there in free tutorials, they're generally better in my opinion
Unlike scattered free tutorials they can be connected and cohesive learning paths that ramp up the complexity gradually over many projects
They also serve as examples and pre-compiled notes for you later
But since anyone can just start making and selling courses their quality also varies a lot, so it's best to research their offering and reviews before committing

zenith mantle
#

it keeps increasing if im not looking at an interactable

frosty hound
#

Line 27 of your PlayerInteract script is trying to reference something that doesn't exist.

#

A good guess is that you're trying to do something with the object the player is looking at, which doesn't exist if they aren't looking at something.

wintry quarry
#

Yep, gotta make sure when you Raycast your code is actually checking for a valid hit or not

zenith mantle
#

also gotta say im just following a tutorial so uh ye

#

thanks in advance if yall reply ๐Ÿ™

wintry quarry
#

There's a reason it's underlined in a green squiggle

zenith mantle
wintry quarry
#

It's trying to warn you

zenith mantle
#

ohhh

wintry quarry
#

Yes

zenith mantle
#

hm how about this ?

#

or is it always like that even when im not jumping

wintry quarry
#

Don't you see the line that explicitly sets it to -2 ?

naive pawn
#

courses may be better depending on your learning style, sure, but there's still no difference between a paid course and a free one aside from spending money (and the commitment that comes with that)

zenith mantle
#

actually

#

nvm i just remembered this exists

trail heart
# naive pawn there are *several* free, high-quality courses that aren't just single feature g...

There's so many resources out there it's hard to generalize
There's high quality free stuff and low quality paid stuff, but on average the balance goes the other way
Ideally when paying you get access to support or teaching assistants as well
I don't recommend everyone to buy courses outright, and hunting for bundles and sales is much better than ever paying full price, but if the premise is that money is no issue then there's not really a drawback to taking that shortcut

zenith mantle
#

is anything wrong

#

its not weaponswaying for me

slender nymph
#

double check the axes you are getting input from

slender nymph
#

read your code and find out!

zenith mantle
#

aa

#

ok

#

time to fuck around and find out

slender nymph
#

do you just not know what an axis is? or that axes is the plural of axis?

zenith mantle
#

ok but i know its a plural

frail hawk
#

how about reading some unity docs?

polar acorn
frail hawk
#

and this

zenith mantle
slender nymph
#

crazy how actually paying attention to error messages can help you fix issues

zenith mantle
#

another stupido question what am i supposed to change

#

also my excuse is

#

i just got unity

#

today

verbal dome
#

It literally tells you

polar acorn
slender nymph
# zenith mantle i just got unity

finish a thought before sending a message. and consider going through the pathways on the unity !learn site to actually learn how to use the engine instead of trying to skip ahead to a finished product

eternal falconBOT
#

:teacher: Unity Learn โ†—

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

polar acorn
#

And use the ones that actually exist

rancid tinsel
#

is the component pattern just... adding components? it seems so simple, so much so that it doesnt sound right

polar acorn
#

Yes. It's more complicated when you're not using Unity

#

It's a general programming practice that Unity was built around

wintry quarry
rancid tinsel
polar acorn
#

Yeah, it seems easy because Unity was designed to make it easy

rancid tinsel
#

wait so whats the difference between that and decorator

#

is decorator at runtime?

polar acorn
#

It seems like it's mostly just a difference in mindset - whether you're adding functionality to a neutral container, or putting neutral data into a functional container?

rancid tinsel
#

ah so its about intent i guess?

#

adding a rigidbody to a player would be component, but adding a playercontroller script would be decorator?

polar acorn
#

Seems like it? I dunno, I'd need to see some more concrete examples of a decorator pattern to really grok it

queen adder
#

This Code should work but is there a more elegant way? My intuition thinks this should be possible without creating a int count variable

#
                        //Check is all Quest cleared
                        
                        //Count how many are finished 
                        int questCleard = 0;
                        for (int j = 0; j < _quest.Length; j++)
                        {
                            if (_quest[i]._questCout == 0)
                            {
                                questCleard++;
                            }
                        }
                        //All Clear?
                        if (questCleard >= _quest.Length)
                        {
                            TransformMotherCell();
                        }
                        
slender nymph
#

you can use a linq method for that, like .All

polar acorn
slender nymph
#

or that

polar acorn
#

If the code reaches the end of the loop, they're all cleared

grand snow
#

I often do that, where if you require everything to meet some criteria you return early if any are false.
then after the loop you know the condition was met.

eternal falconBOT
queen adder
#

i've hit a brick wall

hexed terrace
#

sounds painful

queen adder
#

very

#

are there any cloud code experts here

#

cloud code + cloud save

#

js

#

I can write data but not read

#

๐Ÿ˜ข

#

nvm got it working

polar acorn
rich adder
# queen adder js

just fyi you no longer need to use the js module since they added c#