Kevin_
Kevin_
CC#
Created by Kevin_ on 4/24/2023 in #help
Unity Script Communication
Would you happen to know why a script would be referencing another version of the player stats event tho it's a SerializedField?
33 replies
CC#
Created by Kevin_ on 4/24/2023 in #help
Unity Script Communication
I found out that this code is referencing another version of the player stats for some reason rather than getting the updated one
33 replies
CC#
Created by Kevin_ on 4/24/2023 in #help
Unity Script Communication
How come?
33 replies
CC#
Created by Kevin_ on 4/24/2023 in #help
Unity Script Communication
What I'm currently doing is this, but for some reason in this script only bulletDamage does not update according to the stats the player picks up
[SerializeField] private PlayerStats _playerStats;

private EnemyStat _enemyStat;

private void OnCollisionEnter2D(Collision2D col)
{
if (col.gameObject.CompareTag("Enemy"))
{
_enemyStat = col.gameObject.GetComponent<EnemyStat>();

_enemyStat.health -= _playerStats.bulletDamage; // Subtracts enemys health by bulletDamage

Destroy(gameObject); // Removes bullet from world
}
[SerializeField] private PlayerStats _playerStats;

private EnemyStat _enemyStat;

private void OnCollisionEnter2D(Collision2D col)
{
if (col.gameObject.CompareTag("Enemy"))
{
_enemyStat = col.gameObject.GetComponent<EnemyStat>();

_enemyStat.health -= _playerStats.bulletDamage; // Subtracts enemys health by bulletDamage

Destroy(gameObject); // Removes bullet from world
}
33 replies
CC#
Created by Kevin_ on 4/24/2023 in #help
Unity Script Communication
Thanks I'll bookmark the link!
33 replies
CC#
Created by Kevin_ on 4/24/2023 in #help
Unity Script Communication
I've been working on stats system which I completed today, but I've been running into an issue where if I pick up a bulletDamage Buff its updates the stats but still only does the original damage. Thus I thought about using a singleton from what I understand its not good to use it. I don't understand if the reference is null or something else causing the issue.
33 replies
CC#
Created by Kevin_ on 4/24/2023 in #help
Unity Script Communication
Interesting. I am making a bullet-hell game so I'll keep that noted
33 replies
CC#
Created by Kevin_ on 4/24/2023 in #help
Unity Script Communication
Gotcha! Its better to have more flexibility rather than in this case take the easy way out.
33 replies
CC#
Created by Kevin_ on 4/24/2023 in #help
Unity Script Communication
Gotcha, so you would lose that flexibility room if you choose to implement it
33 replies
CC#
Created by Kevin_ on 4/24/2023 in #help
Unity Script Communication
I was mainly using it so I can easily access those variables rather than constantly getting the script associated with them
33 replies
CC#
Created by Kevin_ on 4/24/2023 in #help
Unity Script Communication
Okay, sounds good! Is there a specific reason on why I shouldn't so I can avoid it in the future?
33 replies
CC#
Created by Kevin_ on 4/24/2023 in #help
Unity Script Communication
I don't intend on making it multiplayer or have other players, just a single character.
33 replies
CC#
Created by Kevin_ on 4/24/2023 in #help
Unity Script Communication
33 replies
CC#
Created by Kevin_ on 4/24/2023 in #help
Unity Script Communication
More of like maxHealth, currentHealth, bulletDamage etc
33 replies
CC#
Created by Kevin_ on 4/24/2023 in #help
Unity Script Communication
Gotcha! Would making a singleton for my players stats be a optimal way of doing it or should I find another method of getting those stats?
33 replies
CC#
Created by Kevin_ on 4/23/2023 in #help
❔ Stats
Lol nothing changed from the code I don’t understand what caused the issue but 🤷
19 replies
CC#
Created by Kevin_ on 4/23/2023 in #help
❔ Stats
Before it would add the Damage buff to the players health for some reason but uhhh not anymore I guess....
19 replies
CC#
Created by Kevin_ on 4/23/2023 in #help
❔ Stats
Yes, I've done that. Umm.... really weird I restarted the editor and um... it seems to be working as intended
19 replies
CC#
Created by Kevin_ on 4/23/2023 in #help
❔ Stats
That doesn't work at the moment
19 replies
CC#
Created by Kevin_ on 4/23/2023 in #help
❔ Stats
Sorry I suck at explaining things
19 replies