#💻┃code-beginner

1 messages · Page 289 of 1

cosmic dagger
#

i assume multiple coroutines were running every frame . . .

deft quarry
rancid tinsel
hushed hinge
#

yet all I have is different Cinemachine names

#

like what cinemachine am i supposed to use?

rich adder
#

i only see 1 here

#

are we not looking at the same image

#

and its already installed it seems, so just learn how it works and components avail

hushed hinge
summer stump
#

I think they mean components

#

Oh yep.

rich adder
#

ohh

rich adder
cosmic dagger
#

i am unsure what you mean by different cinemachine names. can you clarify?

summer stump
#

@hushed hinge have you looked up a guide?
There are many out there

hushed hinge
cosmic dagger
rich adder
#

Cinemachine Virutal Camera is general purpose

hushed hinge
#

like this

rich adder
summer stump
rich adder
#

are you talking about removing the black line viewport ?

hushed hinge
summer stump
#

It has pinned resources too

summer stump
hushed hinge
summer stump
hushed hinge
rich adder
#

oh ok, so you dont need the target group on i linked earlier.
Just use regular Virtual Camera

#

but yeah this isn't coding related

hushed hinge
rich adder
#

you dont need any scripts for cinemachine follow target

rocky canyon
#

cinemachine is a pretty advanced system.. u can do almost everythign from the inspector

hushed hinge
#

since i have a camera script for the 2 players

rocky canyon
#

cinemachine can follow 2 objects ez

summer stump
rich adder
#

ofc you don't want body to be 3rd person follow, but you can see Follow can just be linked directly

rocky canyon
#

put ur players ina target group and follow it

rich adder
#

I sent that too thinking they needed both players but apparently only 1 😛

rocky canyon
#

ez

hushed hinge
# rich adder

it just won't work, also what type of camera i meant is that the camera doesn't just so instant focus on the player like the player can move around in the camera a bit around

frosty river
#

How can I see/fix whatever is cutting off weapons from the player's camera view?

#

I turned off mesh renderer for the player capsule it doesnt stop the cutoff

#

is it just how the camera works that it starts considering objects at a certain plane?

rocky canyon
#

near clipping plane of the camera

frosty river
#

yeah, got it

#

lowering near clipping plane fixed

rich adder
acoustic sun
#

When I try to publish a game, it loads to 90%

timber tide
rancid tinsel
#

what on earth is this

#

it just added that stuff

timber tide
#

auto complete will also add the libraries needed if you mistakenly allow it

rancid tinsel
#

how do i check if the path is completed with navmesh?

#

as in, check if the agent reached the destination

rich adder
rancid tinsel
#

like hasPath etc

rich adder
#

Not sure has path would work well

#

There is no built in event sadly which is kinda weird but oh well

acoustic sun
whole idol
#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MouseMovement : MonoBehaviour
{
    public float mouseSensitivity = 100f;
    float xRotation = 0f;
    float yRotation = 0f;
    void Start()
    {

        Cursor.lockState = CursorLockMode.Locked;
    }

    // Update is called once per frame
    void Update()
    {

        float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;
        float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime;
        xRotation -= mouseY;
        yRotation -= mouseX;

        //clamp the rotation
        xRotation = Mathf.Clamp(xRotation, 90f, 90f);
    }
}


summer stump
whole idol
#

Why is this necessary here ?

        xRotation -= mouseY;
        yRotation -= mouseX;

I think it should be
yRotation -= mouseY;
xRotation -= mouseX;

summer stump
whole idol
polar acorn
summer stump
polar acorn
whole idol
rancid tinsel
polar acorn
#

There's very little reason for a 3D object to rotate about the Z axis

native seal
#

do you guys recommend [SerializeReference] along with [SubclassSelector] from mackysoft or just use scriptable objects

#

theres not much of a difference correct? besides the fact that two thingns cannot hold the same reference

polar acorn
native seal
#

haha

north kiln
polar acorn
#

Man

north kiln
#

There's probably a few of them out there

polar acorn
#

I've been doing things the hard way

#

making my own like a chump

native seal
#

this can effectively replace scriptable objects right?

#

besides the fact that I noted

north kiln
#

It's more fragile, but it can be a replacement at times

native seal
#

yeah thats what I was worried about, everything losingn references

#

is that an issue?

north kiln
#

personally I try to avoid it unless it's solving a larger usability problem

native seal
#

noted

#

because Im making a ton of abilities made out of up to 10 scriptable objects and was thinking it would be much easier to do this with subclass selector

#

but if something happens and I have to reassign all my abilities that would suck

#

stick with SOs i assume?

north kiln
#

I can't really give much recommendations, I would just exercise caution in regards to liberally applying the attribute. If you're in a state of doing regular refactorings it can complicate things. If you apply SerializeReference to arrays it can also easily break things because adding to the array creates an annoying duplicate that references the same item as the last instead of a copy.

#

I haven't touched it for a while because I'm doing ECS stuff and it's mostly unnecessary for me

native seal
#

so in general, if I want to avoid weird stuff happening just stick to SOs

north kiln
#

Certainly is the most robust way of going about things, though can be annoying having to create extra objects

native seal
#

👍

timber tide
#

macky has some other neat utility too

#

the weighted selector is fun

#

but beyond serialized references and SOs, mostly a mix between SOs with plain c#

#

serialize references are nice for interfaces, but I've kinda abandoned that idea

native seal
#

less SO's than me lol

#

looks really good

#

one ability that isnt even finished lol

#

cant think of a better way to do it tho

timber tide
#

haha seems like just how it is cause ive a directory per ability too

native seal
#

yep lol

timber tide
#

adding triggers just adds more to the mix

native seal
#

what is meant by "trigger", i remember you guys talking about them and how it was difficult to implement

timber tide
#

it's just adding conditions to your ability for when you want to do some recursive ability actions

#

I think they call the pattern meta magic or something

#

instead of making the whole ability as one, just chop it into components -> fireball -> fireball explodes

native seal
#

i kinda just hard code that

#

since i have different stages of the ability, it works out

#

pre activate, activate, post activation etc

timber tide
#

yeah, that's probably fine. I was thinking maybe ill reuse stuff

native seal
#

yeah it is more modular

timber tide
#

sword casts level 5 fireball explosion

native seal
#

you could allow the player to make custom abilites

#

that do wacky things

#

thing is, I was wondering how to allow that. for example, if a player has say "poison chance", i want the basic bow attack to then have the poison effect which seems like it would require assigning things to the SO from somewhere else

hushed hinge
native seal
#

or should I just already have all those effects on it and only if the stat is above a certain amount say posion chance > 0, then it would apply

native seal
timber tide
#

if it's just a numbers thing then I'd feel like it would be another iterate over a list of applications when you hit the target kind of thing

hushed hinge
timber tide
#

no, but make sure your colliders are set correctly

#

if you're using ontrigger methods then you need at least 1 rigidbody and 1 trigger collider (both must have colliders though)

hushed hinge
native seal
#

when the player gets access to that modifier

#

atleast in the way im doing things right now

timber tide
#

some passive system right

native seal
#

yeah

#

and im trying to avoid hard coding every ability to have knowledge of all the possible "states" it could have

timber tide
#

I'd tackle that by scrolling over a list of passives that apply at the target direction when the target is hit

native seal
#

make it so the caster or target has the list and all abilites would just read from that list whatever it may be

#

like imagine gloom shrine in POE

timber tide
#

When target is hit -> Ability.Cast(IEnity Target)

#

two things to think about is the direction the ability comes from (Does it come from the target or does it appear at the target)

hushed hinge
timber tide
native seal
hushed hinge
native seal
#

for example, i have a list of status effects on my bow attack, which are just an Effect similar to the Damage Effect, Cooldown Effect etc, if I could just add Poison Effect when the player has poison, that would solve the issue

#

these Effects are all scriptable objects also

timber tide
#

yeah that's just numbers stuff, but assume you do want another projectile to spawn from you like say if you hit an enemy you have a 20% chance to cast a fireball from you

#

that itself is basically another ability you have, but you don't manually cast it but you treat it as any other ability with some automated targeted conditions you give it

hushed hinge
timber tide
#

I think the problem might be with your Find method

native seal
native seal
#

try to do a clean build of ur game

hushed hinge
native seal
#

click the arrow

hushed hinge
native seal
#

hm maybe your version doesnt have it?

#

try to rebuild in general

timber tide
hushed hinge
native seal
#

just build it again

hushed hinge
timber tide
#

well, as you work on stuff, sometimes stuff you previously worked on breaks so it's worth to debug.log to make sure where the error may be

hushed hinge
#

there's no error

native seal
hushed hinge
#

I need to get this fixed, I don't get why it doesn't work in game

native seal
#

ah maybe just make all of those thingns innate to any projectile

native seal
#

not you, im sorry

timber tide
#

PoE has both local and global stuff, but usually it comes down to what and how much you want to iterate when you hit some character

native seal
timber tide
#

like, make as many conditional containers you want, when you hit an enemy if you have a passive container with behaviour that targets the enemy, then just check if it's empty or not

hushed hinge
timber tide
#

my effect system / ability system has both. When I equip an ability I look through all modifiers and add it to the ability like a normal component if the tags are compatible

#

maybe that's what you're thinking of

native seal
#

perhaps I could include it as part of my AbilityInstance

hushed hinge
native seal
#

since i have my ability definiton SO

timber tide
#

when I equip an ability, I look at all previous modifiers (including stuff like effects) and then do some bitwise operations, then I populate the ability's containers with all the modifiers you can use

#

ability hits -> iterate over the containers

native seal
#

do you populate the SO or some instance of the ability?

timber tide
#

when I new the ability I have some subscribe to a observer system on the actual instance (it can already have some effect original to it, and I would keep track of what is a modifier and what is original to it)

hushed hinge
#

I DON'T GET WHAT I'M SUPPOSED TO DO

trail vigil
#

Hi, I'm looking for a forum to find a paid Unity tutor, does anyone have any recs?

hushed hinge
native seal
timber tide
native seal
#

then u can use debug logs there

timber tide
#

targeting abilities is a pain though

#

probably the biggest problem with making these controllers

hushed hinge
# hushed hinge I DON'T GET WHAT I'M SUPPOSED TO DO

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;

public class Counter : MonoBehaviour
{
private TextMeshProUGUI _text;
private int _amountPickedUp = 0;
private int _allPickups = 0;
public int levelNumber = 1;

private void Start()
{
    _text = GetComponent<TextMeshProUGUI>();
    FindAllPickups();
    _text.text = _amountPickedUp.ToString(); //+ "/" + _allPickups.ToString();
}

private void FindAllPickups()
{
    GameObject[] gameObjects = GameObject.FindGameObjectsWithTag("Pickup");
    _allPickups = gameObjects.Length;
}

public void PickedUp(int value)
{
    _amountPickedUp += value;

    if(_amountPickedUp >= 100)
    {
        RemovePickups();
        GameObject.FindGameObjectWithTag("Player Manager").GetComponent<PlayerManager>().AddLife();
    }

    _text.text = _amountPickedUp.ToString();// + "/" + _allPickups.ToString();

    if (_amountPickedUp >= _allPickups)
    {
        PlayerPrefs.SetString("Gems" + levelNumber.ToString(), "Clear");
    }

    //for (int i = 1; i < 8; i++)
    {
        //print("Gems" + i.ToString() + ": " + PlayerPrefs.GetString("Gems" + i.ToString()));
    }
}

private void RemovePickups()
{
    _amountPickedUp -= 100;
}

}

hushed hinge
native seal
eternal falconBOT
native seal
hushed hinge
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;

public class Counter : MonoBehaviour
{
    private TextMeshProUGUI _text;
    private int _amountPickedUp = 0;
    private int _allPickups = 0;
    public int levelNumber = 1;

    private void Start()
    {
        _text = GetComponent<TextMeshProUGUI>();
        FindAllPickups();
        _text.text = _amountPickedUp.ToString(); //+ "/" + _allPickups.ToString();
    }

    private void FindAllPickups()
    {
        GameObject[] gameObjects = GameObject.FindGameObjectsWithTag("Pickup");
        _allPickups = gameObjects.Length;
    }

    public void PickedUp(int value)
    {
        _amountPickedUp += value;

        if(_amountPickedUp >= 100)
        {
            RemovePickups();
            GameObject.FindGameObjectWithTag("Player Manager").GetComponent<PlayerManager>().AddLife();
        }

        _text.text = _amountPickedUp.ToString();// + "/" + _allPickups.ToString();

        if (_amountPickedUp >= _allPickups)
        {
            PlayerPrefs.SetString("Gems" + levelNumber.ToString(), "Clear");
        }

        //for (int i = 1; i < 8; i++)
        {
            //print("Gems" + i.ToString() + ": " + PlayerPrefs.GetString("Gems" + i.ToString()));
        }
    }

    private void RemovePickups()
    {
        _amountPickedUp -= 100;
    }
}
timber tide
# native seal like giving it a target to move toward?

more that when you have these automated targeting conditions through triggers it changes the behaviour of your abilities usually. In PoE you have abilities that you personally would target, but when they are trigger then you sometimes need some automated logic

native seal
hushed hinge
native seal
#

turn off the collider on the textmeshpro

hushed hinge
native seal
#

maybe thats the issue

timber tide
swift elbow
hushed hinge
hushed hinge
native seal
#

sorry, was thinking of raycast target, nvm that

hushed hinge
#

oh

native seal
#

make a development build and try debug log statements

hushed hinge
native seal
hushed hinge
swift elbow
#

You're not doing it in the inspector

native seal
#

_text = GetComponent<TextMeshProUGUI>();

swift elbow
swift elbow
native seal
#

check your collider matrix

#

in project settings

timber tide
# native seal ah, and have it modular as well, i see how that could be hard

if you want to start out with something very flexible, instead of just casting from the point of the player, give the ability two points in space. The start location and target location. Two points makes a direction, but this allows you to say offset the position by 10 units y, but 5 unity y on the target. This would make the ability spawn above with a direction downwards towards the player. Then say you add 5 z local to the target, now you have it spawn 10 units above with a 45 degree angle downwards basically

native seal
hushed hinge
timber tide
hushed hinge
swift elbow
#

Private TextMeshProGUI _text;

native seal
#

yeah then i could just use any point in space such as the enemy location to fire it from despite it being cast from the player

#

and do the cool things like you said

hushed hinge
swift elbow
#

TMPro_Text _text

hushed hinge
swift elbow
#

Maybe the t has to be lowercase in TMPro_Text

#

I'm not sure if I remember properly

tame mist
#

hello, all my scripts say Assembly Infromation Filename Assembly-CSharp.dll
I imported a new asset that has scripts with a different Filename and references a Definition File Destructible2D.
I'm trying to edit some of their scripts to reference my own scripts and it doesn't work. How should I change the imported scripts Assembly Definition to be able to reference my other scripts?

hushed hinge
swift elbow
#

Wait maybe that's for classes

#

Nvm it's for both

native seal
#

quaternium im sorry but you're not really helping him

#

the issue is with the build

swift elbow
#

Quaternium 😭

native seal
#

there is no errors

#

typo lol

swift elbow
#

Oh

hushed hinge
native seal
#

her

hushed hinge
native seal
#

did you make a dev build like i said

hushed hinge
rich adder
#

and both can use it
UI version and mesh version

swift elbow
timber tide
#

doesnt TextMeshProGUI work just the same though

rich adder
#

TPM_Text is preferable because its shorter to type as well

native seal
#

why would that make the collider not work in build

rich adder
#

worth checking though ig

swift elbow
native seal
#

no the gems arent being picked up

#

in build specifically

swift elbow
#

Oh

#

@hushed hinge you've had me on this mouse chase for nothing 🤦‍♂️

#

Listen to your superiors

native seal
#

and therefore because they arent being picked up, the countner isnt updating

#

its not an issue with the counter itself

summer stump
errant wedge
#

Do I need to learn C# before starting the unity learning?

timber tide
#

it could be related to the counter if it is erroring in the build

swift elbow
summer stump
eternal falconBOT
#

:teacher: Unity Learn ↗

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

native seal
timber tide
#

but I'd like to see some debugging to actually figure out what's not being triggered

summer stump
#

but Unity uses c#, so you will obviously need to know it

errant wedge
#

Any recommendations for a program?

summer stump
errant wedge
#

To learn C#

rich adder
summer stump
#

W3Schools

#

TutorialsPoint

#

Microsofts own guide

#

don't pay for anything

#

Skip youtube until later

errant wedge
#

So unity Essentials then Junior Programmer?

timber tide
#

c# then unity

summer stump
#

or do one of the sites I mentioned above to learn JUST C# first

swift elbow
summer stump
errant wedge
#

I think learning C# first would be more beneficial

rich adder
hushed hinge
swift elbow
timber tide
#

issue is not debugging and senseless chattering on an issue you could probably solve quickly

uncut shoal
#
[System.Serializable]
public class Biome
{
    public NoiseSettings noiseSettings;
    [Range(0.0f, 1.0f)]
    public float minTemperature;
    [Range(0.0f, 1.0f)]
    public float maxTemperature;
    [Range(0.0f, 1.0f)]
    public float minPrecipitation;
    [Range(0.0f, 1.0f)]
    public float maxPrecipitation;
}```
How do I make it draw the min and max like a single value. Like, a range with two sliders. I remember seeing an editor window with that before but I forgot where.
errant wedge
#

on UnityLearn do I just search for the C# guides?

#

or is there a specific area

hushed hinge
summer stump
rich adder
uncut shoal
#

yes

timber tide
#

but this is for vectors

uncut shoal
#

how would that work

summer stump
#

@hushed hinge

uncut shoal
#

o I see

#

Thanks!

swift elbow
timber tide
uncut shoal
#

I know.

hushed hinge
summer stump
hushed hinge
summer stump
hushed hinge
#

when you shorten the name development build to dev build

#

also, I just asked "and then build and run?"

summer stump
swift elbow
hushed hinge
#

yeah

#

Should I then click on build and run?

summer stump
hushed hinge
#

I don't know what to pick

summer stump
#

looking up the difference would tell you which one to pick

#

one builds the game and runs it, one just builds it

#

as the names suggest

#

do you want to run it?

hushed hinge
#

I meant the last 4 choices below Development build

rich adder
#

those aren't connected

summer stump
hushed hinge
#

Oh

rich adder
#

build and run is especially handy for tesiting WebGL as it creates the server for you when you build in run, otherwise you'd need a server to run JS in local browser for security issue from browser

whole idol
#

So unity removed their 2d vector composite from Input Actions, what can I use instead?

whole idol
#

this one

rich adder
#

Did you select the correct Action Type?

#

oh looks u you didn't

summer stump
whole idol
hushed hinge
summer stump
summer stump
rich adder
hushed hinge
whole idol
#

I havent seleted any one yet

summer stump
rich adder
whole idol
#

its on button by default

summer stump
hushed hinge
summer stump
#

I didn't say show an error

hushed hinge
#

what console?

whole idol
#

whats a composite?

summer stump
eternal needle
rich adder
#

gpt code lol

hushed hinge
summer stump
gentle stratus
#

i have these two scripts but on my editor it gives me a warning Assets\Scripts\Stats\SlimeStats.cs(24,18): warning CS0108: 'SlimeStats.sightRadius' hides inherited member 'EnemyStats.sightRadius'. Use the new keyword if hiding was intended.
and also i cant find the "Slime" option to add to my assets

rich adder
eternal falconBOT
summer stump
gentle stratus
#

i mean its abstract i thought id have to define what the variables are

summer stump
summer stump
gentle stratus
#

oh so i just have to remove the stuff before the variable name

hushed hinge
summer stump
eternal needle
whole idol
#

I think the last one?

hushed hinge
timber tide
#

there is errors though what are you looking at

summer stump
rich adder
#

its still there

whole idol
eternal needle
# hushed hinge I thought i should show this?

u should really take a step back and go learn the absolute basics of coding (outside unity) or just whatever beginner unity learn tutorials there are. surely some unity learn page will talk about the console

rich adder
summer stump
#

Saying "there are no errors" instead of just showing the console is fighting imo

gentle stratus
hushed hinge
summer stump
eternal needle
gentle stratus
#

its downloading rn

eternal needle
# gentle stratus its downloading rn

after you do the IDE thing, it is just created in the assets folder. Thats what the CreateAssetMenu attribute is used for, you can create an instance of it that lives in your project.

gentle stratus
#

oh got it

rich adder
#

cause you already got VS

eternal needle
#

probably the unity module on vs

gentle stratus
#

downloading update

rich adder
#

ah workload

gentle stratus
#

i already have unity module installed

rich adder
#

then you probably just need to regen project files

gentle stratus
#

how would i do that

summer stump
gentle stratus
#

alright

whole idol
#

cool 👍

rich adder
summer stump
#

But, as suggested, I'm gonna "calm down". Best of luck. Seeya

hushed hinge
timber tide
#

your build does show errors so I suggest going to the line they are at and throwing some logging down

#

the logging should show in the build log

timber tide
#

by learning how to debug your code by printing to console

whole idol
#

Im trying to save my progress that I made so far to ensure that this project will be there tomorrow. So my question is why is it that when i hit save or ctrl+s file exporer opens up in this asset folder directory instead of just automatically saving my project that it already exists as a collection of files? Also when I look for the project's name on my file exporter, it says open and then you have to save this file as a game's ASSET. Does it make any sense that you would save this entire project file inside of it's own assets as a game asset ?

#

the button says open up when i go dir over this entire unity folder

#

so you have to open it, and then it says save

#

so i can literally save it as an asset or something

native seal
#

debugging is one of the most essential things to programming

#

look up how to debug in unity

eternal needle
native seal
#

I saw debug logs in your video from before, is your whole game made from copy pasting code?

whole idol
#

got it, anyways, thanks

eternal needle
rich adder
#

both

hushed hinge
summer stump
native seal
#

Debug.Log is used similarly to print in your generic language of choice

eternal needle
native seal
#

u can put them around to see what's happening

#

if variables are as you expect. etc

summer stump
#

I remember seeing the notes she got from teachers like months ago, and yeah.... not great at all

hushed hinge
native seal
#

I've said dev build like 10 times

#

was one of the first things I suggested

hushed hinge
hushed hinge
#

I just have a low mind with ADHD and Autism that it's hard for me to understand hard

young fossil
#

Hi. I'm making a wave system with shop breaks. Would it be best to use an FSM here?

Thinking the states would act like;
Shop-> Wave 1 -> Shop -> Wave 2...

native seal
#

they are shown in the profiler

eternal needle
young fossil
native seal
#

u can do them with the animator but probably not the best idea

summer stump
young fossil
#

Yea was about to say don't suggest the animator, ahahah, been down that road before

hushed hinge
native seal
#

lol yeah don't recommend it

hushed hinge
#

Also I and more used to designing

young fossil
#

Alright well thanks guys

hushed hinge
#

All I asked that why my texhmeshpro wouldn't work

rich adder
eternal needle
eternal needle
hushed hinge
#

I know how to debug

young fossil
hushed hinge
young fossil
#

I would use enums with it too

#

Trying to find the most effective solution

#

A lot of things rely on it, it's the main gameloop, so it needs to be robust

rich adder
#

the numbers of waves can just be a int

summer stump
rich adder
#

pretty much

gentle stratus
#

visual studio finally updated and i clicked regen project files, does this mean its regenning project files

hushed hinge
young fossil
summer stump
young fossil
#

Even with the current scope, there's at least four states. Shop, wave, death and entry

timber tide
# hushed hinge Yes I was, I'm just so forgetful

You've got a null exception in your dev build. You need to go that line and start debug.log and printing everything that's being access on that line. If it's a multiple dot operation then you debug left to right of the line.

native seal
#

fsm

gentle stratus
eternal needle
# young fossil So you vote against FSM? Any reason why?

if its just wave, shop, wave, shop then its simple enough that you can just use an enum or a bool even (which of course wouldnt be too adaptable). But if you want to add something more complicated in the future then maybe a state machine would be better.
Although I cant really imagine that this would be that complicated, or that anything would really need to read this data. I assume you're just going to load scenes based on this data

summer stump
hushed hinge
rich adder
#

making sure the solution shows all your unity files

gentle stratus
#

okay

native seal
gentle stratus
#

in the meantime though im getting this error and not sure what it means

hushed hinge
native seal
#

not sure

summer stump
# hushed hinge I don't think it's much of a help for me when I debug on something even though e...

everything seems to be working

But.... you are here for an issue. These argumentative responses are tough to deal with. My 5yo daughter is going through a stage just like this, which is why my patience was so low before haha. Please just understand that we are actually trying to help you. Refusing to look things up, and saying debugging is not worth it is just an absolutely wild way to respond

#

Just run your game in the editor one time, and show the WHOLE uncropped console

native seal
hushed hinge
native seal
#

scripts/stats and just in scripts

summer stump
#

Well.... I tried I guess.

gentle stratus
#

oh thanks

native seal
#

linedol u have to be willing to recieve help

#

not just ask how how how

#

"okay I googled it but I don't understand this part, care to explain that specifically"

gentle stratus
#

if i create an instance of enemystats called slime do i call it enemystats or slime in a script

native seal
#

wdym

#

like a script able object instance?

gentle stratus
#

yeah

native seal
#

u can name it whatever you want

gentle stratus
#

i meant the type

native seal
#

send a picture of what you mean though

gentle stratus
#

like this class uses PlayerStats which is the name of both the scriptableobject itself and the instance of it

eternal needle
gentle stratus
#

looks like this rn

eternal needle
#

Your stats ideally shouldnt be different between player or enemy, otherwise your abilities are just gonna have to do the same thing twice.
Your ide still doesnt look configured tho

#

You probably missed a step

native seal
#

just extent playerstats and enemystats from a base class Stats

native seal
#

what u name the SO doesn't matter

native seal
#

then add anything enemy or player specific to the enemy or player class

gentle stratus
#

is the latest version of visual studio editor 2.0.22

rich adder
#

did you close vs before and do the Regen Project files?

#

screenshot the Solution Explorer window in VS

gentle stratus
#

i was updating vs so it closed before i clicked regen project files

#

but yeah still not working

rich adder
#

right click on Assembly on the right

#

do Reload with Dependencies

#

i think

gentle stratus
#

oh that worked

#

so should i make an abstract stats class for playerstats and enemystats to inherit from

eternal needle
native seal
#

about maybe avoiding inheritance

gentle stratus
#

i dont really follow from your message why i should avoid inheritance

#

are you saying i should keep any shared stats in the abstract stats class

native seal
#

you should have a stats field in your overall player class as well as your enemy class

#

avoids all the inheritance

#

so like public class Enemy { Stats stats = new Stats() ...}

gentle stratus
#

i see

native seal
#

and then you can define your stats however you like in the constructor

#

stats could be a dictionary between enum and float for example, thats what I do

gentle stratus
#

should stats also have shared methods

native seal
#

what do you mean?

#

post pictures

#

or code snippets

gentle stratus
#

like add this to stats.cs

public bool damage (float amount) {
    if (amount > health) health = 0;
    health -= amount;
    return true;
}```
native seal
#

well depends the route you go

#

but if your stats are super simple like health damage, etc

#

sure

gentle stratus
#

hm ok

native seal
#

if you went the dictionary route, it would be more complicated overall but more robust if you wanted more complicated stats

gentle stratus
#

should i build the enum class into the stats class

native seal
#

no just make it outside of it

#

no reason to do it specifcally inside the stats class

gentle stratus
#

alright

native seal
#

wouldnt make a difference though

#

just more annoying to access since you would have to do Stats.Stat.Health or whatever

gentle stratus
#

yeah makes sense

woven crater
#

when getting a tile from a tilemap inorder to work on it
do you get the type Tile or Type TileBase?

native seal
#

all tiles inherit from tilebase

#

just use the GetTile function also, it returns a tilebase

woven crater
native seal
#

yeah use the GetTile function from your tilemap

woven crater
#

yeah thank. i think i meant to have a list of tile but idk i should use tile clas or tilebase class

native seal
#

all tiles inherit from tilebase

woven crater
#

i read it and still alil confuse of how the two are different to eachother

native seal
#

basically if you want to make your own kinds of tiles, you would inherit from tilebase

#

Tiles are unities tiles and what you place with the tile pallete etc

woven crater
#

oh i see, i think i kinda get it now

gentle stratus
#
public class Stats : ScriptableObject {
    Dictionary<StatNames, float> stats = new() {
        { StatNames.Health, 100 },
        { StatNames.MaxHealth, 100 },
        { StatNames.Attack, 10 },
        { StatNames.Defense, 0 },

        { StatNames.Mana, 100 },
        { StatNames.MaxMana, 100 },
        { StatNames.Magic, 10 },
        { StatNames.Resilience, 0 },

        { StatNames.Speed, 3 },
        { StatNames.SprintMultiplier, 1.5f },
        { StatNames.JumpHeight, 3 },
        { StatNames.Stamina, 100 },
        { StatNames.StaminaRegen, 0.25f },
    };

    Dictionary<StatNames, bool> conditions = new() {
        { StatNames.Healing, false },
        { StatNames.Recharging, false },
    };
}```
i have this right now but if i wanted a player to have say healthregen id just set it in the player itself?
and if i wanted to edit speed id do like stats.speed = 12?
native seal
#

just inherit from Dictionary<StatNames, float>

#

and then u can make whatever functions u want

rich adder
#

good for base stats template but not for mutable data

gentle stratus
#

ic

native seal
#

you can then fill the dictionary in the constructor

#

and then change the values for the stats within the start function of your player/enemy

rich adder
#

use SerializableDictionary 😛

native seal
#

GenericDictionary ❤️

#

yeah if you want to be able to change the dictionary within the inspector, use one of those from the asset store

#

since unity can't serialize dictionaries

rich adder
#

Unity has also one you can use that basically just uses a struct lol

gentle stratus
#
public bool damage (float amount) {
    if (amount > stats[StatNames.Health]) stats[StatNames.Health] = 0;
    stats[StatNames.Health] -= amount;
    return true;
}```
is this the right way of doing it
native seal
#

either works id assume

native seal
gentle stratus
#

alright

native seal
#

you should fill the dictionary with all the enum values in the constructor

#

you can do it like this public Stats() { foreach (Stat stat in Enum.GetValues(typeof(Stat))) { Add(stat, new StatValue(0)); } }

#

whatever your names are

gentle stratus
#

oh ok

ruby python
#

Mornin' all,

I may just be tired but I'm having an issue and I can't see what's wrong.

I'm using pretty much the exact same code on in Two seperate scripts to create a public list (on each).

https://pastebin.com/VNGnqAaz
This one acts as expected and appears in the Inspector (First Image)

However, this one.....
https://pastebin.com/RcgBpZ9T

Doesn't show the public fields in the inspector (Second Image), and I really can't see why.

Am I just being a moron? lol.

native seal
#

is [Serializable] above your Wave class?

north kiln
#

EnemyInWave is not [Serializable]

ruby python
#

Typical. As soon as I posted I saw what was wrong. lol.

I missed the system serializable

#

<------- 6am moron. lol.

native seal
#

lol

gentle stratus
#

something went wrong

#

oh wait im bad

#

i forgot to instantiate stats

#

nvm still same problem

rich adder
#

dictionary is null

#

you cannot add elements to something null

#

initialize it =new()

native seal
#

you shouldnt have a stats field in your stats class

#

your stats class already is a dictionary itself

#

it inherits from it

gentle stratus
#

oh

rich adder
#

oh didnt even see that lol

native seal
#

and personally i wouldnt have conditions within your stats class

gentle stratus
#

yeah that makes sense

native seal
#

thats more of a state machine typoe of thing

#

this is a huge rabbithole tho, be cautious

#

i just recently went down it and finally got my stats/ability system in a working state weeks after i started

gentle stratus
#

damn

native seal
#

keep if simple if your game is simple

gentle stratus
#

well ive done all but whats an easy way of setting all of those values when i make a new instance of stats

native seal
#

manually within whatever class has a Stats field

gentle stratus
#

thats kinda annoying i quite liked this interface

native seal
#

you can do that, but only for "max stats"

#

it gets a bit messy when you start changing those midgame

gentle stratus
#

oh

native seal
#

a lot of people are stringint about not changing SO's during runtime but it can work

#

with stats though I dont really recommend it

gentle stratus
#

okay

native seal
#

though you can do that still

#

have a seperate Stats field in your Player/Enemy class that holds the base stats

#

then at start, it would add all those values to your real stats

rich adder
native seal
#

well only if you think SO's are a way of saving data

native seal
#

from the unity store or github

gentle stratus
#

oh so the thing you mentioned

native seal
#

yea

gentle stratus
#

ok ill get that

native seal
#

so you could have a scriptable object called like EnemyData that has Stats on it

#

where would make all your base stats

#

then plug that into your enemy class and copy all those base stats on start

gentle stratus
#

does it run stuff if i put an onstart function in it

#

thinking about how to instantiate the base stats

native seal
#

what do you mean?

gentle stratus
#

like rn the stats are all 0

native seal
#

what is "it"

gentle stratus
#

the playerstats and enemystats classes

native seal
#

when you do Stats stats = new Stats()

#

that calls your constructor

#

that adds all the stats

gentle stratus
#

yeah but rn theyre 0 and i want to make them not 0 when i start

native seal
#

on your scriptable object?

gentle stratus
#

yeah

native seal
#

so either hardcode it or use genericdictionary

gentle stratus
#

what does genericdictionary change

native seal
#

your dictionary appears in the inspector

#

and you can change each stat

gentle stratus
#

oh

#

though you said it might cause problems when updating in runtime

native seal
#

no that is only if you are changing a scriptable object during runtime

#

inspector is not runtime

gentle stratus
#

ic

native seal
#

the whole purpose of scriptable objects is to define everything in the inspector

#

and use it as a data blob

#

basically

gentle stratus
#

okay got it

native seal
#

like this is of my SO's

#

for reference

#

all of those stats are copied into the enemies empty stats when the enemy is spawned

gentle stratus
#

oh ok

mortal pewter
#

Hi, is this where I can ask for Unity-related help?

native seal
#

code

gentle stratus
#

so to install this i just need to drag and drop both cs files into the assets folder?

native seal
#

use package manager

#

and import from git link

mortal pewter
#

UmbraGlobe, would you be able to help me as well?

native seal
#

with code sure

native seal
#

read what it says mainly

gentle stratus
#

i was adding by git link and like it loaded for a split second but i didnt see any change so i might just copy the files

native seal
#

yea go for it

gentle stratus
#

oh i didnt read console

mortal pewter
#

My enemy class is a prefab and I'm trying to hook a slider onto this enemy. I've instantiated the healthBar object but calling this function yielded that error. Do you think it has to do with the fact that the enemy class is a prefab, therefore is not instantiated?

native seal
#

post the full code

#

!code

eternal falconBOT
gentle stratus
#

do i have to put the files in the same folder as my stats stuff or can i keep it in the main assets folder

native seal
#

u can put it whever

gentle stratus
#

oh ok

native seal
#

though one of them needs to be in Editor

gentle stratus
#

right

#

in the editor couroutines?

native seal
#

no

#

just make a folder called Editor within scripts

#

or outside of it

mortal pewter
gentle stratus
#

oh

native seal
#

Qang post ur full code

mortal pewter
native seal
#

are you assinging healthbar in the inspector?

mortal pewter
#

Please let me know if you'd like the Health class too, it's really short

#

no, it's one of the class variables in Enemy class

native seal
#

look at your enemy class on the gameobject

#

is Health not assigned

#

public HealthBar healthbar; does not instantiate anything

rich adder
native seal
#

it creates a null variable

#

that needs to be assigned

mortal pewter
native seal
#

see "None"

rich adder
#

None

mortal pewter
#

ah ic

native seal
#

put your healthbar on your enemy too

#

then drag it in

#

assuming Health is a monobehaviour

sick dust
#

Hello unity people!

I am doing a research project, and I have a level with a script that reads/writes to a json. These functions works great when first loads, but restarting the scene causes an error "NullReferenceException: Object reference not set to an instance of an object
updateText.DisplayMessageWithoutLearningMoments (updateText+DialogueEntry entry) (at Assets/updateText.cs:348)"

This is really confusing because the object that is erroring is instantiated according the unity runtime. Is there something simple I'm missing?

I'd be happy to give more context/code just don't want to ramble on lol

mortal pewter
#

line 11 is a slider, which it seems to have...

native seal
#

same thing with Slider

#

when you write public Slider slider, it is not creating an instance of it

#

rather creating a null field that you can assign it to

#

in this case, in the inspector

mortal pewter
#

ic, it's declaring it

native seal
#

if you have a background in c++ its a bit confusing

#

i was confused at first too

mortal pewter
#

Yeah, this is my first time using c# and doing game dev

native seal
#

so to make an instance of something you would do public Thing thing = new Thing()

mortal pewter
native seal
#

with monobehaviors, you typically dont do this

#

yes you need to assign it

#

so either in the inspector or by calling GetComponent in start

mortal pewter
#

It was already in the inspector when the error popped up

native seal
#

send a full picture of your enemy gameobject

#

with all the components

mortal pewter
#

It doesn't have anything under the hierarchy

rich adder
#

healthbar needs to be on the same prefab, then apply changes

native seal
#

your sprite renderer and E are null

#

that will be an issue as well most likely

#

but whever your class called Mana is

#

doesnt have Slider assigned

mortal pewter
# native seal but whever your class called Mana is

Uh sorry, I dragged the wrong thing in. But now I can't seem to drag the Health object into this slot. Ignore e, I was testing some stuff out. And both Health and Mana have sliders assign to them. I moved the health and mana bar to the same prefab as well.

native seal
#

try unpacking your prefab

#

unless you are in the prefab view

#

i can't tell

mortal pewter
native seal
#

ah yeah ignore what i said

#

does Health have a healthbar component

mortal pewter
native seal
#

your field is of type HealthBar

rich adder
native seal
#

your healthbar doesnt have the healthbar component

mortal pewter
mortal pewter
native seal
#

you should have the Health script

mortal pewter
#

oh yeah that's on my mana script, brb 1 sec

rich adder
mortal pewter
rich adder
#

Healthbar also isnt applied to prefab and slider field

mortal pewter
#

ah mb

rich adder
#

you're good 🙂

native seal
#

make sure all of your fields dont say none

mortal pewter
native seal
#

yes that is fine

vale karma
#

im diving into state machines again bc im getting rusty in 3d now and need one for movement. what are all the types of state machines? finite, hierarchical, somethin and somethin

native seal
#

make sure YOUR classes dont have any nones

#

so health, enemy, etc

mortal pewter
#

And for some reason, I still can't drag the Health object into the slot

rich adder
#

get into more complex ones if the project requires

native seal
#

does Health have the Health script on it

vale karma
#

I found that one good series of state machine tutorials, but he fucks up each tutorial and then the next one he just fixes his current one. I want to just use the end result, but he literally throws a script out each tutorial

#

I went thru it before, and have one built already, but its not modular, i cant use it without ripping hair out

native seal
mortal pewter
native seal
#

this tutorial was pretty interesting though I dont fully understand it lol https://www.youtube.com/watch?v=NnH6ZK5jt7o

In this video, we're going to build a flexible and efficient object-oriented state machine in Unity using C#. The days of using an enum state machine are OVER! This tutorial covers everything from defining states, implementing transitions and predicates and moving between animations using code, all with SOLID principles and the State and Strate...

▶ Play video
vale karma
#

I havent learned too much about enums, just that they arent very scalable

native seal
#

it is pretty advanced

#

depends on your use case

#

it more depends on your state change logic

native seal
#

if you have alot they can become combersome

vale karma
#

Okay ill give it a go. I just need air, ground, idle walk and run in that order super super sub sub sub

rich adder
#

i like the KISS principle the best

vale karma
#

yea, i did try it that way. But once i needed more functionality and more states, it became kinda meh

native seal
rich adder
vale karma
#

i went from all in one script, to 3, to finite, a halvesie, and now i forgot it all haha

#

ill do some research and watch the vid thanku

rich adder
#

you're trying to over-optimize / over engineer too early I think

native seal
#

beware that video is advanced and for robust systems

#

i dont recommend it if you are just doing idle walk etc

#

seems like the animator would work lol

mortal pewter
rich adder
#

even adding an extra enum entry wont be a big deal wit ur usecase

vale karma
#

I was also going to have like a UI store system, a working station, storage, customer interaction, and economy... i figured itd be useful haha

native seal
#

just have a state "busy"

#

if you are in any of those screens

vale karma
#

thats a good idea 😮

native seal
#

dont need to overcomplicate it

rich adder
#

abstract when possible too

#

dont cram every state in the player itself

mortal pewter
# native seal so does it work now?

Oh my days, it finally works! THANK YOU SO MUCH, YOU'RE A SAVIOUR. I've been trying to figure this out for hours now haha, this prefab and object stuff is kind of confusing

#

tysm to u and navarone, u guys are the best

native seal
vale karma
#

its not so much about overoptimization.. but i just want to learn better methods than what im using. Atm i cant really build games with what i know. And its not alot if you dont include if statements

mortal pewter
rich adder
native seal
#

by instantiating the prefab

#

if you set up everything correctly it will all be seperate

mortal pewter
#

Ah okay, I'll test it out tomorrow. Thanks

native seal
#

np

rich adder
#

@vale karma Its like you're trying to buy a chainsaw to slice some bread lol

#

just cause its powerful its not always the right tool for the job

vale karma
rich adder
vale karma
#

f it ill do it without one, and go until it hurts

native seal
#

fsms are rarely needed unless u are doing some sort of AI or movement atleast in my experience

#

atleast super robust ones

#

just use enums for the most part

rich adder
#

yeah and if youre getting complex with substates mind as well use Behavior trees

#

loooking at GTA3 source code the other day , the enemy AI is only a statemachine switch statement with like 10 enums lol

summer stump
rich adder
#

hey if it works it works right?

ruby python
#

!code

eternal falconBOT
ruby python
#

Oooookay, so I'm beginning to dislike lists. lol.

I'm generating a new list 'per wave' of enemies using the following.

https://pastebin.com/KVjNdafZ

I am now struggling on adding my enemy items to said list (the public 'AddEnemyToWaveList' method).

The thing I'm struggling with is what to pass in for the EnemyInWave waveList from the script trying to access this method.

This is the line that covers that. I think I'm right in saying that I need to take 'currentWave' which is an int (as I'm using it earlier on with .ToString() to name the generated list.

GameManager.Instance.enemyManager.AddEnemyToWaveList(GameManager.Instance.currentWave, enemyID);

Would anyone be able to give me a clue please? 😕

vale karma
#

does anyone have an issue with reverse engineering a mechanic? It seems like I can say "click on card, flip it over, pick another card, flip it, check if they match, if so , win, if not lose" but then i go to code it, and instantiating prefabs of cards with front and backs on a grid layout with mechanisms to change images and know if another one matches it and when to check that, how many times you can do all of this before game over... bro its a simple card game why am i crying XD

#

i tend to get locked up in doing loops that recreate code i already made in a different way

rich adder
#

takes time and repetition to hone your own workflow

vale karma
#

i stopped trying when i jumped from delegates, actions, func, to scriptable objects.. my heart hurts

#

yea, im just complaining. im coding too hard or too boring

native seal
#

if not it will not be called

#

also your functions that make a list should just return a list

gilded elm
#

hi, I wanted to know, I have two objects which have collisions and I would like to put them together and make it so that if we move one, the other follows, do you have any ideas?

ruby python
native seal
#

you have a Start function in EnemyInWave

#

this does not get called unless u explicitly call it

teal viper
gentle stratus
native seal
#

oh wait

#

send your whole file please, i think im getting it confused since its cut off?

ruby python
native seal
#

yes, my bad

#

so you have the EnemyInWave class defined within another class?

#

that is not in that code snippet?

ruby python
rich adder
gilded elm
# rich adder parenting or maybe joint ?

I would like it to be the RAM of a computer which is on the motherboard slot and jsp how is that possible, I would like to take it and resume (the RAM) at any time

ruby python
rich adder
#

whos the genius that made this css

native seal
native seal
#

do you need it to be passed by reference?

ruby python
#

!code

eternal falconBOT
ruby python
rich adder
native seal
#

yeah i am confused as well

#

is this just for the number of enemies in the wave?

#

or does enemyID correspond to something

#

if so shouldn't your list just hold some Enemy class?

ruby python
native seal
gentle stratus
#

where

native seal
#

put [Serializable] above the class header

gentle stratus
#

oh ok

ruby python
#

So, basically I'm trying to keep a track of how many enemies exist in a wave. The waves overlap in their spawning so just keeping track of how many enemies exist wasn't working. The idea being that if the player destroys all enemies in a wave, a power up is 'dropped', but if some enemies survive, no drop.

native seal
#

you could have a static int on the enemy class which increments in the constructor

#

num of enemies

#

or do you mean all the enemies of an individual wave

#

so even if there are enemies in a "different" wave, if you kill all of the enemies in the previous wave the powerup drops

ruby python
#

Tried that, but as the Waves overlap (wave 2 starts before wave 1 has 'finished' the numbers don't work.

#

Gimme a sec

native seal
#

you could have an ID on each enemy that when the next wave starts, gets incremented

#

then on every enemy death, will check if your list of ALL enemies has no enemies with that associated ID

astral falcon
#

Why dont you have a list of a wave class and that wave class holds a list of the current enemies? Each enemy could call that wave reference to tell that it got destroyed for example

#

and then teh wave class calls the gamemanager or what not to tell, all enemies dead, drop that power up

native seal
#

yes that would work, just have a callback when an enemy dies for the Wave class to check if its list.count = 0

astral falcon
#

As every enemy is already an instance inside that list, you can just easily remove it with the reference and update the whole game state

ruby python
native seal
#

link doesnt work

ruby python
#

Copied the wrong thing. lol.

astral falcon
#

I just flew over that script, but already seeing, you call the gamemanager instance to just update manually the count with -1. Thats what I meant. You have to have a reference to your wave to sort things correctly. Just having a major ALL ENEMIES int will fail in so many ways

ruby python
astral falcon
# ruby python Oh yeah I know. That's the thing I'm trying to replace with this whole list thi...

Ah got it. So I sadly dont have the time to go through all the code and write some pseudo code here, sorry. But try to figure out how to get away from manually set integers for waves and counts. Make a list of wave which its .Count property will already give you what you want. If you need a function for all active wave enemies, write a script, that collects all waves and gets a property from them which you can sum up. Get more in the object oriented direction for this case.

native seal
#

at the beginning of a level, you should perhaps set up a list for with every single wave that will be in that level

ruby python
native seal
#

the list of enemies will be contained by a Wave

#

and when the enemy dies, it will remove itself from the list, then check the Count of the List<Enemy> within the wave

astral falcon
native seal
#

it seems like your levels are determined by the song so could you randomly generate all the waves at level start?

#

or do you need to have them adjusted on the fly

ruby python
native seal
#

okay so it doesn't need to change during the level itself

astral falcon
ruby python
native seal
#

so there are a few ways you could it do it. you could generate a List<Wave> which each Wave contains a List<Enemy> and every time an enemy dies, it has a callback to the wave that it in to remove itself from the wave and check the count

#

and then when each wave appears, will add a new Wave to the list

ruby python
astral falcon
native seal
#

and if the wave ends, it will also be removed from the list, and generate no power up since all the enemies will just be deleted with it

ruby python
#

method.

native seal
#

dont do it with a bunch of ints

#

just hold A list of waves which holds a list of enemies

#

have a Wave field in your enemy class that gets assigned when the wave is spawned

#

and on death will call back to the wave to remove itself from the list

astral falcon
#
GameManager.Instance.numberOfEnemies = 0;

This line already kills the option to determine individual waves and enemies. Just make your currentWave a function AddEnemy() or something and use that inside the wave class.

native seal
#

personally i would try to avoid relying on GameManager so much

#

have the GameManager call SpawnWaves, then your wave system handles itself

#

its bad when both classes are dependent on eachother

#

typically your game manager should be responding to events sent by your systems and responding accordingly to reduce dependencies

astral falcon
#

Yep, cleaning things up might help in the overview. Make your wave a single file and detach it from the gamemanager. Its more important than to be a little child in your gamemanager 😉

ruby python
#

My head hurts. LMAO

astral falcon
#

I can imagine 😄

ruby python
#

Seriously appreciate the time and input though guys, thank you 🙂

astral falcon
#

So, first, take everything that is related to a Wave and put that in your extra file class Wave.cs

native seal
#

its better to think backwards when designing systems like this imo, dont design it top down from your gamemanager if that makes sense

#

make it its own little system and then only the things it REALLY needs it gets from the gamemanager

#

although you could design it in a way that a gamemanager is not needed

#

it is ultimately up to you

ruby python
#

tbh, most of this is from the Galaga in 3D tutorial course, I've modified it quite a bit to make it work for me though. But never used Lists like this, so yeah, giving me a headache. lol.

native seal
#

lists are nothing but an array with special functions

#

that reduce boilerplate

#

insert, contains, etc

ruby python
#

And I'll be brutally honest, I like the singleton route simply because I absolute despise referencing multiple classes/scripts etc. I find it very difficult to bug hunt. lol.

astral falcon
#

One step after the other. Take your time now and refactor your code a bit to clean up dependencies.

native seal
#

singletons are the ultimate bug machine

#

your game manager should inject all the dependencies into the EnemySpawner/WaveMananger whatever it is and it can function alone from there

#

then have your wave manager send events that the game manager subscribes to

#

so imagine like StartWaves(songLength... etc)

astral falcon
#

Id say, take your time now and use what you read and got on your side. Then come back and see, where youve gotten

ruby python
#

But yeah, I've got some things to think about. 🙂

astral falcon
#

Just dont want this discussion to end in a "you could do this or that or here or there" thing 😄 I think we repeated ourselves too much already and kept confusing. So I guess, you know what the suggestions mean and now, happy coding 🙂

ruby python
#

Hehehe, the refactoring based on the suggestions is kinda daunting if completely honest. lol.

astral falcon
#

Just start, dont get afraid of ALL tasks from the start. You will get used to it and looking at it more object oriented, like what can those things do, will make it easier over time 🙂

native seal
#

just refactor completely separately from ur stuff now

#

so if you mess up or go down the wrong path you still have the code that works

#

just try some of the things we suggested in some separate class and build from there

astral falcon
#

Or make a branch if you use github/lab/devops what not

ruby python
#

Just spitballing ideas. But, I have this 'sub class' that governs the waves (number of enemies, the path they take and the grid formation to use)

    public class Wave
    {
        public int smallEnemyAmount;
        public Path path;
        public Formations enemySmallFormation;
    }

Could I not use the smallEnemyAmount in some way to keep track?

native seal
#

it would be better to have the wave contain a list of enemies imo

ruby python
#

Okay.

native seal
#

since that list gives you the count as well

ruby python
#

Okay, I gotcha.

native seal
#

then have a function on your wave that takes in an enemy and removes it from the list

#

and every time that's called. you could check if enemies.count() == 0

#

the enemies, having a reference to the wave it's in, could call Wave.RemoveEnemt(this) passing in itself

ruby python
#

Okay, yeah makes sense, I understand the theory behind it, now just need to figure out how. lol. Keep looking at the code and have no clue where to start lol. I'm sure I'll figure it out though. 🙂

native seal
#

dependency injection is your best friend when you have multiple layers like this

reef patio
#

Hello.

#

Can someone direct me to a cutscene script? TO make a video before the game starts and one at the end.

blazing flicker
#

!code

eternal falconBOT
blazing flicker
#
public bool _isFacingRight = true;

    public bool IsFacingRight { get { return _isFacingRight; } private set{
            if (_isFacingRight != value)
            {
                transform.localScale *= new Vector2(-1,1);
            }
            
            _isFacingRight = value;


        }}
#
private void SetFacingDirection(Vector2 moveInput)
    {
        if (moveInput.x > 0 && !IsFacingRight)
        {
            IsFacingRight= true;

        }
        else if (moveInput.x < 0 && IsFacingRight)
        { 
            IsFacingRight= false;
        
        }
    
    }