#archived-code-general

1 messages · Page 384 of 1

knotty sun
#

not at all

fallow quartz
#

it will change in every object with that SO

knotty sun
#

so you make SO instances

#

but if I understand you correctly what's wrong with simple POCO's consumed by your monobehaviours

#

so you dont want to share variables you want to share variable declarations

knotty sun
#

well you say you want to share variables but you don't want one class changing the values used by another so what do you mean by sharing variables

fallow quartz
#

My problem is this:

#

How do I avoid duplicating variables without using inheritance

simple egret
#

You can use an interface

#

You won't be able to see your properties in the Inspector if you do so, though, on a field of the interface type

#

Inheritance works best here, especially when you don't know which of the 3 types you'll be getting at runtime

woeful spire
#

A mix of both is usually ideal.

stark sun
#

I made debug.break(); when it enters trigger and checked the fixed joint I create with script and anchor looked normal.
So I cant understand why joints break.

steady moat
fallow quartz
simple egret
#

Then your problem cannot be solved without duplicating code

#

What is the actual issue here?

steady moat
#

You can also us helper function. By example, if the issue is duplicate code in the damage taking, you could create a DamageCalculator

simple egret
#

Sounds like an XY problem

fallow quartz
#

so its a complete mess of same variables between different abilities

#

or with the stats i have the same

woeful spire
fallow quartz
steady moat
#

Fireball

  • int range

Fire Spear

  • int range
woeful spire
#

Then in the ability you could use a "projectile" component if it should spawn something projectile-like?

simple egret
#

Can you have different abilities with the same underlying C# type? Like a HealthPotion and a HarmPotion both have an amount to add/subtract from the health. Which means both could be two instances of the same class (one with a negative value, one with a positive one)

#

Scriptable objects can do that

fallow quartz
steady moat
woeful spire
simple egret
#

The variables could be kept private/serialized, and to apply the ability the player would be injected into that

class HealAbility : IAbility
{
    [SerializeField] private float _healAmount;

    // Interface forces implementation of this method
    public void Apply(Player player) => player.Health += _healAmount;
}
woeful spire
#

if objects are going to share a lot of logic - then using inheritence makes sense. Depending on how much the fireball and spear are going to share it can make sense to create a "Projectile" class for them - using generalized terms like direction and speed.

#

If they are wildly different and only share one or two variables it might be easier to use interfaces.

steady moat
#

And if you do not know whatever the player has a health:

class HealAbility : IAbility
{
    [SerializeField] private float _healAmount;

    // Interface forces implementation of this method
    public void Apply(Player player) { 
      if(player.Has("health")) 
        player.Set("health", player.Get("health") + _healAmount); 
    }
}
fallow quartz
#

that using inheritance is really complex

woeful spire
#

not really. Just sharing the variables wouldn't be very complex? Where does the complexity arise?

#

Inheritance would be used to decrease complexity.

#

sharing general ideas between projectiles would make it easier to create another projectile later on no?

#

having the fireball - for example - use an interface specifically for abilities could be good. Have a general callback from the ability back to the user with a separate class to add knockback or heal the player would make sense here too.

woeful spire
#

What part of inheritence do you want to avoid exactly?

fallow quartz
#

btw is the setter useful? Cause if i want to change a variable i dont see any difference between changing directly the variable or creating a setter

woeful spire
#

if it's one variable, I think you can safely ignore inheritance. If it's shared behaviour between this variable, then inheritance can be convenient.

steady moat
# fallow quartz making a big tree just for 1 variable shared on each pair of classes

Usually, in such case you want to use composition.
https://en.wikipedia.org/wiki/Composition_over_inheritance

Composition over inheritance (or composite reuse principle) in object-oriented programming (OOP) is the principle that classes should favor polymorphic behavior and code reuse by their composition (by containing instances of other classes that implement the desired functionality) over inheritance from a base or parent class. Ideally all reuse ca...

woeful spire
#

If you just want to change the value then you wouldn't really need it.

fallow quartz
#

and btw composition gets me into a problem, i cant change the values of the variables inside without putting them into public

#

cause its not inheritance

steady moat
fallow quartz
woeful spire
woeful spire
steady moat
#

Read on it before...

woeful spire
#

[SerializeReference] is for making something visible in the inspector.

fallow quartz
woeful spire
#

what you're doing here is assuming it's public.

#

well...

steady moat
fallow quartz
woeful spire
steady moat
woeful spire
#

oh my bad.

knotty sun
stark sun
sleek heath
steady moat
steady moat
#

There is situation where it changes nothing, but none as far as I know that they should.

woeful spire
#

when you want to control a value from another script...?

steady moat
#

Maybe except for structure handling

steady moat
steady moat
knotty sun
woeful spire
steady moat
woeful spire
#

You can use properties, but those properties would still be public right?

steady moat
knotty sun
#

that is a Unity attribute, not used by 3rd party serializers

steady moat
#

That being said, most serializier has their own properties.

woeful spire
#

I know ideally you want to isolate variables and use private - but wouldn't making them public be virtually the same as creating a property for them?

#

for this use case at least. Not in general of course.

steady moat
# woeful spire I know ideally you want to isolate variables and use private - but wouldn't maki...

In software systems, encapsulation refers to the bundling of data with the mechanisms or methods that operate on the data. It may also refer to the limiting of direct access to some of that data, such as an object's components. Essentially, encapsulation prevents external code from being concerned with the internal workings of an object.
Encaps...

#

It is a conceptual thing more than a pratical thing.

stark sun
#

why would I make something private? I can't think of any reason than not making inspector more crowded.

fallow quartz
woeful spire
#

making things public exposes them, sometimes without reason, which is a big no-no.

#

To be honest though... when you're making your own game you can hold that shit together using duct tape, as long as it works. So you don't really have to stress that kind of stuff until you run into situations where you realize the actual issues it creates.

#

I think what's happening is that @steady moat is technically correct with everything they're saying - but you don't need to hold yourself to this standard when making stuff for fun. When coding production code and more advanced stuff you should hold yourself to these standards.

steady moat
fallow quartz
steady moat
knotty sun
woeful spire
knotty sun
#

a property is a varaible

fallow quartz
fallow quartz
steady moat
simple egret
#

And if you ever need to do stuff when you get/set the value, you do it in one place (at the property), instead of at all the call sites

woeful spire
#

using properties would yield the same result in your case.

simple egret
#

C# conventions recommend you use properties to expose fields, but Unity pretty much doesn't care about properties lol

steady moat
knotty sun
woeful spire
steady moat
fallow quartz
#

Ok so in here, if i want to have the Add method inside Player instead of Stats, there is no way to change the values of my _stats in Player without declaring public every variable on Stats class?

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

[System.Serializable]
public class Stats
{
    [SerializeField] int _hp;
    [SerializeField] int _physicalDamage;
    [SerializeField] int _magicalDamage;
    [SerializeField] float _movementSpeed;
    [SerializeField] float _attackSpeed;
    [SerializeField] int _physicalDefense;
    [SerializeField] int _magicalDefense;
    [SerializeField] float _cooldownReduction;

    public int Hp => _hp;
    public int PhysicalDamage => _physicalDamage;
    public int MagicalDamage => _magicalDamage;
    public float MovementSpeed => _movementSpeed;
    public float AttackSpeed => _attackSpeed;
    public int PhysicalDefense => _physicalDefense;
    public int MagicalDefense => _magicalDefense;
    public float CooldownReduction => _cooldownReduction;

    //TODO [SerializeField] float _range;

    public Stats(int hp, int physicalDamage, int magicalDamage, float movementSpeed, float attackSpeed, int physicalDefense, int magicalDefense, float cooldownReduction)
    {
        _hp = hp;
        _physicalDamage = physicalDamage;
        _magicalDamage = magicalDamage;
        _movementSpeed = movementSpeed;
        _attackSpeed = attackSpeed;
        _physicalDefense = physicalDefense;
        _magicalDefense = magicalDefense;
        _cooldownReduction = cooldownReduction;
    }

    public void Add(Stats other)
    {
        _hp += other._hp;
        _physicalDamage += other._physicalDamage;
        _magicalDamage += other._magicalDamage;
        _movementSpeed += other._movementSpeed;
        _attackSpeed += other._attackSpeed;
        _physicalDefense += other._physicalDefense;
        _magicalDefense += other._magicalDefense;
        _cooldownReduction += other._cooldownReduction;
    }
}
simple egret
knotty sun
woeful spire
ivory smelt
sleek heath
woeful spire
#

we just want to access it.

knotty sun
steady moat
simple egret
woeful spire
#

having a public property and a private variable vs a public variable would yield the same results here right?

steady moat
simple egret
# knotty sun tell me about it

For example, tables that have a 1 to 1 relationship between each other have a third table in the middle which contains some data, as if it was a many-to-many relationship. So to join two tables you need more JOINs than usual, and conditions on the third table's join

woeful spire
steady moat
knotty sun
woeful spire
steady moat
simple egret
# ivory smelt You mean differently that using "Class.Attribute = 1"?

Like if one day you'd like to have an event raised or a method called when the value changes, you'd only modify the property's setter and nowhere else:

public int Sample
{
    get => _sample;
    set
    {
        _sample = value;
        SampleChanged(); // new!
    }
}

And you'd keep your c.Sample = 42; unmodified everywhere else.

If you didn't have the property, you'd need to add c.SampleChanged() everywhere you set a new value to c.Sample

fallow quartz
woeful spire
steady moat
ivory smelt
fallow quartz
sleek heath
steady moat
#

It is a crucial part to make compositon base code. Which could be a way to architecture what you want.

simple egret
sleek heath
#

so it's basically an anonymous function?

simple egret
#

Yep properties are methods under the hood

#

The compiler makes the heavy lifting work

sleek heath
#

so in the IL, it will say "set()" and "get()"

simple egret
#

Yup

ivory smelt
simple egret
#

Yeah I omitted it in my example, but you need a field to back the property up

#

Unless you use an auto-property ({ get; set; }) in which the compiler creates that field for you

#

Next C# version will allow you to refer to the field directly, eliminating the need for a field when you have code in the accessors:

public string Name
{
    get => field; // 'field' now a keyword referring to the compiler-generated field
    set => SetField(ref _field, value);
}

For my WPF MVVM lovers

sleek heath
#

C#14?

simple egret
#

I stopped counting but it should be in .NET 9 which releases next week-ish (?)

sleek heath
#

it already released

#

a month ago

simple egret
#

hmmm I'm late then

#

Stuck with Framework 4.7.2 at work 💀

knotty sun
sleek heath
simple egret
fallow quartz
knotty sun
fallow quartz
#

that force u to make variable public

sleek heath
ivory smelt
# simple egret Yeah I omitted it in my example, but you need a field to back the property up

So, correct me if im wrong or missing something, but would this be the correct cheatsheet?

    private GameObject _attributeA; //full private

    public GameObject _attributeB { get; private set; } //readonly

    [SerializeField] private GameObject _attributeC;    //inspector serializable readonly
    public GameObject AttributeC => _attributeC;

    [field: SerializeField] public GameObject _attributeD { get; private set; } //inspector serializable readonly BEST PRACTICE

    public GameObject AttributeE { get; set; }  //full public

    private int _attributeF;    //full public BEST PRACTICE
    public int AttributeF { get => _attributeF; set { _attributeF = value; Example(); } }
steady moat
simple egret
# ivory smelt So, correct me if im wrong or missing something, but would this be the correct c...

A: Field, private
B: Property, read-only (outside of declaring type)
C1: Field, private (+ Unity recognizes the attribute so it's displayed in the Inspector - not base C#)
C2: Property, read-only
D: Property, read-only (outside of declaring type + marks the compiler-generated field with the attribute so it's displayed in the Inspector)
E: Property, public, read-write
F1: Field, private (backing field of F2)
F2: Property, public, with custom accessor logic

thick terrace
#

and with a bit of extra code you can enable init properties in Unity for some extra fun 😀

steady moat
fallow quartz
ivory smelt
ivory smelt
thick terrace
steady moat
simple egret
ivory smelt
ivory smelt
steady moat
simple egret
thick terrace
ivory smelt
#

wdym? you cannot acces it from Class.AttributeE?

steady moat
thick terrace
steady moat
#

Hence, you will not be able to modify it directly, you will need to set it back after you are done.

fallow quartz
ivory smelt
#

So one returns itself and the other returns a copy of itself essentialy?

thick terrace
ivory smelt
#

Yeah a reference is a "path" to the data, while a property is a copy of the data itself

#

But what im not getting is in which cases a field is initialized as one or another

steady moat
fallow quartz
#

If a gameobject doesnt execute again Start when using dontdestroyonload, why my stats stay fine if I do it like in the image but reset if I declare it on the start? And whats the difference?

ivory smelt
#

like here im getting it but where does the difference begin? declaring the variables?

#

Dude i know how to program and suddenly I feel stupid asf its like i have forgot the basics lmao

steady moat
#

The difference is in the struct. If it is a class it is a reference type.

#

And the behavior differ

ivory smelt
steady moat
#

If you were to replace struct by class, you would not get the same result.

ivory smelt
#

while you were talking about class types

thick terrace
ivory smelt
#

damn XD

steady moat
ivory smelt
#

alr alr

ivory smelt
#

Thanks yall @steady moat@simple egret@thick terrace, I really appreciate your help! ^^

#

🫶

main shuttle
#

Why are you yelling?

knotty sun
#

and that is our problem why?

worn brook
#

Sorry

#

I just wanted to share my suffering with someone

rugged fulcrum
#

Does anyone know if its possible to resize a vertex buffer? I'm creating an empty max size vertex buffer to pass to a compute shader, but after i've generated these I'm almost always left with a lot of unused space at the end, any way to trim this out without copying a subset into another buffer?

vocal night
#

Are state machines common for animations in 3D games?

leaden solstice
cosmic rain
vocal night
#

he creates these statemachine scripts and every single motion has it's own state machine which makes no sense to me cause normally, I thought we controlled them with variables in the animator tab

rugged fulcrum
vocal night
#

I just want to know how to properly animate a 3d character tbh

#

and adding complex motions to those characters

leaden solstice
#

Read docs and try it out

leaden solstice
#

You didn’t even use a second to search?

#

Good luck

vocal night
#

I did but I understand nothing that's why I'm here

cosmic rain
vocal night
#

going simple from like walk and run to actions like swim, point and all

cosmic rain
tawny elkBOT
#

:teacher: Unity Learn ↗

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

ivory cove
#

Hi so after updating my unity version, when I make new scripts, for a short time my console gets spammed with this message. Doesn't seem to be affecting anything in the game and it stops shortly after the script is created, give or take 3 seconds. I was wondering what this means and how to fix it!

tired raptor
#

How do I fix this error?

ocean hollow
ocean hollow
tired raptor
tired raptor
ocean hollow
#

try asking there

wintry stone
#

I'm trying to make a healing beam similar to mercy from Overwatch does anyone know how to make the line renderer curve when the direction of the healing staff is facing a different direction than the target? Or if their is a better way to make this than a line renderer?

rigid island
#

probably some type of shader? maybe a spline mesh on it w shader ?

wintry stone
#

ok I didn't know if their was any way to do it with code with the line renderers points and just wanted to check

rigid island
#

I would honestly use a spline type deal with a shader, or the shader itself can just create that curve effect instead of bending the mesh

rigid island
wintry stone
#

yeah the bezier curve works thanks!

wheat elbow
#

Has anyone here integrated the SteamUtils API in their code?

Kind of confused -- I'm not sure how to A) check if the user has pressed the "submit" button and

B) How can we get the entered text?

#

this is my code if it helps =--

#
using UnityEngine;
using Steamworks;
using TMPro;
using System.Collections;

public class SteamDeckVirtualKeyboard : MonoBehaviour
{
    public TMP_InputField inputField;
    public string promptText = "Please enter text";
    public int maxCharLimit = 300; //max char limit for input

    private void Start()
    {
        if (SteamManager.Initialized)
        {
            inputField.onSelect.AddListener(ShowVirtualKeyboard);
        }
    }

    private void ShowVirtualKeyboard(string selected)
    {
        // Check if the game is running on a Steam Deck
        if (SteamManager.Initialized)
        {
            Debug.Log("IS RUNNING ON STEAM DECK");

            bool isShowing = SteamUtils.ShowGamepadTextInput(
                EGamepadTextInputMode.k_EGamepadTextInputModeNormal,
                EGamepadTextInputLineMode.k_EGamepadTextInputLineModeSingleLine, 
                promptText, 
                (uint)maxCharLimit, 
                inputField.text
            );

            if (isShowing)
            {
                // Start the coroutine to check for text submission
                StartCoroutine(CheckForSubmit());
            }
        }
        else
        {
            Debug.Log("NOT RUNNING ON STEAM DECK");
        }
    }

    private IEnumerator CheckForSubmit()
    {
        // Wait until the overlay (virtual keyboard) is closed
        while (SteamUtils.IsOverlayEnabled())
        {
            yield return null;
        }

        // After the overlay is closed, retrieve the text
        string enteredText;
        uint bufferSize = (uint)maxCharLimit;

        bool success = SteamUtils.GetEnteredGamepadTextInput(out enteredText, bufferSize);
        if (success)
        {
            Debug.Log("ENTERED TEXT: " + enteredText);
            inputField.text = enteredText; 
        }
        else
        {
            Debug.LogWarning("Failed to retrieve entered text from the virtual keyboard.");
        }
    }

}
#

It looks like the "enteredText" is empty

#

I basically just want to get whatever text is inside the box that pops up -- whether the user modified it or not through the virtual keyboard -- and make that the "enteredText"

leaden solstice
#

The struct also contains if user submitted or not

past raven
#

how does one un-unpack a prefab

soft shard
# past raven how does one un-unpack a prefab

If a prefab is unpacked in a scene, you cant re-pack it unless you Ctrl + Z and undo the operation, otherwise it would be easier to just drag another prefab into the scene again, unless your wanting to make a prefab variant

clever leaf
#

hey, a question: does unity support auto-tiling at runtime, or would I have to implement that system myself?

sudden lantern
#

Hi. I get an error that says "Layer index out of bounds" when I'm trying to log the layer name. What can cause this?

var context = ActorContext.Context;
Vector3 origin = context.transform.position;
Vector3 direction = -context.transform.up;

Ray ray = new Ray(origin, direction);
Document doc = SonicGameDocument.GetDocument("Sonic");
ParameterGroup group = doc.GetGroup(SonicGameDocument.CastGroup);
float castDistance = group.GetParameter<float>(Cast_Distance);
LayerMask mask = group.GetParameter<LayerMask>(Cast_RailMask);

Debug.Log(LayerMask.LayerToName(mask));
knotty sun
past raven
#

why do my sprites get fucked up when i unpack

#

i fucking hate unity

cosmic rain
past raven
#

it's too late i already invested 10 years into this bullshit

knotty sun
past raven
#

why is it doing this shit to my character

cosmic rain
past raven
#

just look at it

#

the body is all fucked up

cosmic rain
#

Well, why would it not be? What is there to make it look correctly?

past raven
#

ok you're trolling

cosmic rain
#

No, I'm trying to drag more details out of you. Otherwise it's impossible to help you.

past raven
#

the body is to the left of the rest of the character

#

body and arms

cosmic rain
#

Yes, that much I figured out. I'm asking why it shouldn't be? What are you using to make it look orderly as you expect?

past raven
#

it looks fine before i press play

#

scene view

#

then it gets all fucked up after i play

cosmic rain
#

Take a screenshot

past raven
cosmic rain
#

I really hate making assumptions, but I guess you're using bone animations or something. The fact that it breaks at runtime means that there is an issue with your rig setup or animations.

past raven
#

ah my animation

knotty sun
#

You also have a null ref exception in your console which may have something to do with it

fallow quartz
#

If I have this inheritance hierarchy and there is a same variable on those 2 classes, is there any way to avoid duplication?

cosmic rain
#

Make these 2 child classes inherit from an intermediate class that has the field.

fallow quartz
#

im going to make 1 full class just for 1 variable?

#

imagine this for each variable thats shared

#

would be crazy

cosmic rain
#

Not advisable. This might point that there is an issue with your design. Maybe you should be using composition more and inheritance less.

#

If you give an actual real life example of your issue, it might be easier to provide a suggestion.

fallow quartz
#

so how do I get a good design

cosmic rain
vestal arch
clever leaf
#

i wanted to make a destructible 2d environment

#

the idea is that you mine tiles for gold

#

and I was wondering if auto-tile at runtime is supported

vestal arch
#

yeah i don't think something like that would be implemented

#

too many specific details to make a general solution

clever leaf
#

ffs

vestal arch
#

not too hard to make though

clever leaf
#

so I won't escape having to make it

#

wonderful

#

thank you

vestal arch
#

yeah, specific systems are like that

clever leaf
#

is it so specific though?

#

you already can define rules for tiles

#

in editor, at least

#

if they were able to make it work in the editor it seems weird it doesn't at runtime

#

I have no real experience using tiles so I might just be outright wrong though

vestal arch
#
  • what range? (camera edge or distance from player)
  • what tileset? (maybe weighted, maybe depends on some different variable)
  • what is replaceable?
#

your answers to these create a specific system

clever leaf
#
  1. aren't tiles just placed based on a grid? distance/camera has nothing to do here
  2. don't exactly know what you mean here
  3. you can replace any tile at runtime, so I don't see how that matters
vestal arch
vestal arch
# clever leaf 1) aren't tiles just placed based on a grid? distance/camera has nothing to do h...
  1. conceptually, yes, but you can't generate infinitely. you have to decide when to start generating.
  2. what tile(s) should be used when generating new areas? how are they weighted? for example, if there's a concept of depth, then maybe that affects what tiles spawn, or the weight in which different kinds are chosen
  3. i mean, within the system. what tile should be replaced? you shouldn't generate stuff over existing tiles, or that would just close up anything you destroy
charred swift
#

Hi,
Is it possible to make a specific camera not render the environmental lighting?

clever leaf
#

nevermind

vestal arch
#

for that yeah pretty sure rule tiles work at runtime

clever leaf
#

great, that's what I wanted to know, thanks

ivory smelt
#

In Unity, is there a way to automate the declaration of properties by composition?
For example. If I put a tag [RequireComponent(typeof(DoorBehaviour))], a DoorBehaviour _doorBehaviour property is automatically created, and also _doorBehaviour= GetComponent<DoorBehaviour>(); is added to the existing Awake() or a new generatedAwake if not implemented yet?

warm cosmos
#

you can require components on gameobjects?

#

that's very cool actually

ivory smelt
#

it automatically puts the desired behaviour into the gameObject but u must do it from a script with class

fallow quartz
#

Can someone help me with the last question in that thread pls? Idk why when initializing the stats on start they are at 0 all the time but if I do It outside or on awake it works properly

knotty sun
fallow quartz
leaden ice
#

So... Is there another copy in the scene you're loading?

fallow quartz
knotty sun
#

then when the scene reloads a new version will be created and Start will run on that

leaden ice
fallow quartz
fallow quartz
leaden ice
fallow quartz
knotty sun
#

Start will not run on a DDOL object after it is first created, so no it will not run again

fallow quartz
knotty sun
#

almost certainly you are misinterpreting what you are seeing. Debug the Start method if you think it's running twice

fallow quartz
#

I made a debug log and the stats are at 0 even in the scene before, so i dont think the problem is DDOL

#

Debug.Log(playerInstance.GetComponent<Player>().Race.Stats.Hp);
Debug.Log(playerInstance.GetComponent<Player>().Race.Stats.PhysicalDamage);

I added this 2 lines just right under BuildPlayer has been executed

#

and they are on 0 but the object has the stats on the next scene

past raven
#

i have a sprite sheet for animation

#

but i cant drag it into the scene

#

i can only drag it under another object

#

and it doesnt show it

#

nvm

#

solved it

fallow quartz
#

@knotty sun @leaden ice

public void ConfirmSelection()
    {
        GameObject playerInstance = Instantiate(playerPrefab);

        CharacterRaceTemplate selectedRace = GetSelectedRace();
        CharacterClassTemplate selectedClass = GetSelectedClass();
        WeaponTemplate selectedWeapon = GetSelectedWeapon();
        ArmourTemplate selectedArmour = GetSelectedArmour();
        TrinketTemplate selectedTrinket = GetSelectedTrinket();

        Player playerScript = playerInstance.GetComponent<Player>();

        if (playerScript != null)
        {
            playerScript.BuildPlayer(selectedRace, selectedClass, selectedWeapon, selectedArmour, selectedTrinket, "YOU YOU");

            Debug.Log(selectedRace.Stats.Hp);
            Debug.Log(selectedRace.Stats.PhysicalDamage);

            Debug.Log(playerInstance.GetComponent<Player>().Stats.Hp);
            Debug.Log(playerInstance.GetComponent<Player>().Stats.PhysicalDamage);

        }

        DontDestroyOnLoad(playerInstance);

        //SceneManager.LoadScene("Test");

        //Debug.Log("Character with: " + selectedRace + selectedClass + selectedWeapon + selectedArmour + selectedTrinket);
    }```
#

the issue could be that when i instantiate the object start is not running right there?

knotty sun
#

Start will run if the Object and the script are active/enabled AFTER all of that code is finished

fallow quartz
knotty sun
fallow quartz
#

If I do it like this, when are stats initializing? Before Awake?

public abstract class Entity : MonoBehaviour
{
    [SerializeField] protected string _name;

    [SerializeField] protected Stats _stats = new Stats(0, 0, 0, 0f, 0f, 0, 0, 0f);

    protected virtual void Start()
    {

    }
    protected virtual void Update()
    {

    }
}```
upper pilot
knotty sun
fallow quartz
#

like when is that being initialized? cause in unity u can see the values

knotty sun
#

if you are talking about a class inheriting from that then the serialized values are set before Awake

fallow quartz
knotty sun
#

no, as I said, it's an abstract class so can never be instanced

fallow quartz
fallow quartz
#

its just to know the theory of how it works

knotty sun
#

then what I said above is true, deserialization takes place after instancing and before Awake

fallow quartz
# knotty sun then what I said above is true, deserialization takes place after instancing and...

Okay, and for this particular case where i want a gameobject to get the stats from templates (SO), is it better to move the initialization of stats from entity to Awake or where it is or leave them on the start and just create a gameobject right instant before the method executes? (which is really annoying, I thought instantiate would instantly activate start and trigger before the whole method finishes)

knotty sun
#

best, if you want instant access to the variables is to set them in Awake, that way you will know they will always be avaialble

fallow quartz
ivory smelt
#

Hello, does anybody know if there any way to avoid having to move every reference in the inspector after you change variable names? Its really annoying when you have a lot of references or even lists. I also find quite unpleasant doing it by code through FindByName.

rotund finch
#

Hello, having some issues with event triggers not triggering

fallow quartz
#

When you design a inheritance hierarchy is it more efficient to start building from the childs onto the fathers or from the base class into the childs?

hybrid ingot
#

Hey guys any ideas why this FPS displacement script works on editor but not on build?

{
    public TMP_Text fpsDisplay; // Reference to a UI Text component to display FPS

    private float deltaTime = 0.0f;

    void Update()
    {
        deltaTime += (Time.deltaTime - deltaTime) * 0.1f;
        float fps = 1.0f / deltaTime;

        // Update the Text component with the FPS value, rounded to whole number
        fpsDisplay.text = "Current FPS: " + Mathf.Ceil(fps).ToString() ;
    }
}```
ivory smelt
#

how does that work

thick terrace
# ivory smelt how does that work

when you rename a field put that attribute on it to tell the serializer the old name, it'll keep the old value and save it under the new name the next time the asset is saved

#

so you can remove the attribute later if you're sure all the assets have been resaved

ivory smelt
#

Ill check it out, thanks brother!

hybrid ingot
# rigid island in what way is not working?

well when I play the game in the editor I see it updating the text according to the fps, but when I build the game it gets a static number, meaning that its not updating the text tho for some reason, asked chatgpt and it said it might be due to textmeshpro, but also no alternatives were said to solve it.

rigid island
hybrid ingot
rotund finch
# rotund finch Hello, having some issues with event triggers not triggering

I have this prefab which I instantiate at a certain point in my game, and to which I attach through code an event trigger. Still through code I add a method as a listener.

This is the code that adds the method as a listener:


[HideInInspector] public UnityEvent onClick = new UnityEvent();

    private EventTrigger eventTrigger;

    private void Start(){
        eventTrigger = GetComponent<EventTrigger>();
        EventTrigger.Entry clickEvent = new EventTrigger.Entry()
        {
            eventID = EventTriggerType.PointerDown
        };

        clickEvent.callback.AddListener(OnClick);

        eventTrigger.triggers.Add(clickEvent);
    }

    private void OnClick(BaseEventData shit){
        Debug.Log("AAAAA");
        onClick?.Invoke(); 
    }
#

The event system is in the hierarchy, and the object presents nothing but an image component and the component itself

leaden ice
rotund finch
#

as I don't wanna go through the hassle of handling a collider in there

leaden ice
#

Collider?

#

What does that have to do with the question

rotund finch
#

ok, maybe I have explained my self poorly

leaden ice
#

If it's not a UI element it needs a collider for On click to work

#

As well as a physics raycaster on your camera

#

If it's UI it needs to be on a canvas and have a Graphic component and you need a graphic raycaster on the canvas

#

But this business with the extra UnityEvent is definitely not necessary in any case, it's a bit wasteful

#

You can also just implement IPointerClickHandler directly and avoid the event trigger entirely

rotund finch
#

How do I make it so that the press of a button, through a second camera, with its feed displayed on an object through a render texture, is registered?

#

when I say button I mean an UI element

#

in world space

leaden ice
rotund finch
#

I see

leaden ice
#

Assuming you're using RawImage

#

If it's a mesh displaying the RT you need a physics Raycast first

rotund finch
#

so i first translate the mouse movement from the main camera's space to the second one's and then what?

leaden ice
#

In a custom event system raycaster

#

Because then it will work with Event Trigger

fallow quartz
#

If i need to make a CD for an ability is better to use coroutines or just use a variable with time.deltatime?

#

whats more efficient

gray mural
leaden ice
rustic ember
#

Hi! I have a question regarding performance. Is there a difference in performance in these two lines, and if so, why? They both give the same result, but if one is faster I will use that.

int x = a+b*c-b;``` vs
```cs
int x = a+(c-1)*b```
leaden ice
thick terrace
leaden ice
#

Indeed

#

Assuming these are all ints at least

#

Also assuming none of them are properties

#

If b is a property it would be different

#

Or function call

steady moat
fallow quartz
#

i thought it was better

rustic ember
steady moat
rustic ember
#

Or is it always slower getting a property of a class than getting a variable within the method?

rigid island
#

fields are generally direct access to memory, method has to create a stack allocation

rustic ember
rigid island
#

property always have accessor public int MyProperty {get; set;} // <-accessor

rustic ember
#

Ah, okay! Thank you for explaining it 😊

rigid island
#

when you get value run this function
when you set run this function
and you can specify what to do on each one with a function

tawny lintel
#

Hi, is there any way to increase the NavMeshAgents priority level above 99? I need it for making an RTS with hundreds or thousands of units on screen. I want to use it to make units not overlap in various situations. 100 positions is also very bizarre, it's and Integer, so why only 100 values?

I have made various systems such as moving in formations or keeping group shapes, moving around corners with a random distance for big groups, etc...

But it's still not enough. For example a group of units attacking a single unit ends up having all units overlap pretty hard. If units that are closer to the target had a higher priority, it would reduce the overlap significantly. But I need to have 100.000 to 1.000.000 priority levels to achieve this.

Thanks for your time!

tawny lintel
leaden ice
wheat elbow
#
using UnityEngine;
using Steamworks;
using TMPro;
using System.Collections;

public class SteamDeckVirtualKeyboard : MonoBehaviour
{
    public TMP_InputField inputField;
    public string promptText = "Please enter text";
    public int maxCharLimit = 300;

    private Callback<GameOverlayActivated_t> overlayActivatedCallback;

    private void Start()
    {
        if (SteamManager.Initialized)
        {
            inputField.onSelect.AddListener(ShowVirtualKeyboard);
            overlayActivatedCallback = Callback<GameOverlayActivated_t>.Create(OnOverlayActivated);
        }
    }

    private void ShowVirtualKeyboard(string selected)
    {
        if (SteamUtils.IsSteamRunningOnSteamDeck())
        {
            Debug.Log("IS RUNNING ON STEAM DECK");

            bool isShowing = SteamUtils.ShowGamepadTextInput(
                EGamepadTextInputMode.k_EGamepadTextInputModeNormal,
                EGamepadTextInputLineMode.k_EGamepadTextInputLineModeSingleLine,
                promptText,
                (uint)maxCharLimit,
                inputField.text
            );

            if (isShowing)
            {
        StartCoroutine(CheckForSubmit());
            }
        }
        else
        {
            Debug.Log("NOT RUNNING ON STEAM DECK");
        }
    }

    private void OnOverlayActivated(GameOverlayActivated_t callbackData)
    {
        bool isGuideVisible = callbackData.m_bActive == 1;

        if (!isGuideVisible)
        {
           StartCoroutine(CheckForSubmit());
        }
    }

    private IEnumerator CheckForSubmit()
    {
        string enteredText;
        uint bufferSize = (uint)maxCharLimit;

        bool success = SteamUtils.GetEnteredGamepadTextInput(out enteredText, bufferSize);
        if (success)
        {
            Debug.Log("ENTERED TEXT: " + enteredText);
            inputField.text = enteredText;
        }
        else
        {
            //fail print
        }

        yield return null; 
    }
}
rapid glen
#

is there any reasonable way to search for text across all of the user-made scripts in my project? it would be in any .cs files in Assets/_Project. I want to search for the number "204" as i want to swap it out to a variable rather than hard-coded number

rustic ember
#

Hi! I am overwriting a texture with Texture2D.SetPixel(), and then calling Texture2D.Apply(). After running the script, it shows the old texture when I open the png file in another program. How do I make it show the new texture instead?

rapid glen
rustic ember
rapid glen
#

if you are getting the original image through code then maybe you could store that path?

rapid glen
rustic ember
#

Alright, thank you

rustic ember
spare dome
#

gpt only knows what the internet knows

#

so it most likely took that from stackoverflow or some other site

rustic ember
#

"path/to/your/texture.png"? What is the origin folder?

#

Do I have to right "C:/...", or is it already in the folder that the script is in? Or the asset folder?

rapid glen
#

like filePath = Application.persistentDataPath + Path.AltDirectorySeparatorChar + "data.json"

#

which will be in your Appdata LocalLow

rapid glen
knotty sun
rapid glen
knotty sun
#

nope

rapid glen
#

ah

#

nope to the first part or second? xP

knotty sun
#

nope you dont need the seperator

rapid glen
#

sick. that excerpt would be a proper replacement then?

knotty sun
#

yes

rapid glen
#

sweet. ill keep that in mind in the future

rapid glen
#

Does anyone know a way to see all forces applied to a specific rigidbody?

I am having troubles with a CarController where I let go of gas pedal and car continues to accelerate for an amount of time. time it accelerates for scales with the speed of the vehicle when i let go of gas pedal. i want to ensure there is not some random script somewhere affecting that rigidbody.

In my Update() i have throttleInput = Input.GetKey(KeyCode.W) ? 1 : 0;

and in FixedUpdate() i have

{
    rlWheelCollider.motorTorque = 2000;
    rrWheelCollider.motorTorque = 2000;
} else {
    rlWheelCollider.motorTorque = 0;
    rrWheelCollider.motorTorque = 0;
}```

I have made **certain** that `throttleInput` and `motorTorque`  work exactly as they should by using a Debug.Log. I have disabled everything else in this script, and know for a fact that the other two scripts on the vehicle do not deal with movement in any way. vehicle has a custom mesh collider and rigid body, children wheels have the wheel colliders.
naive swallow
rapid glen
spare dome
#

I believe its called Rigidbody.linearVelocity now

rapid glen
#

I'm moreso asking about finding sources of velocity, not seeing the actual velocity of the vehicle. I have an onscreen Km/h for that 🙂

spare dome
#

sources of velocity, elaborate.

rapid glen
#

I have looked at all references to the gameobject that has the rigidbody and none of the scripts on those objects add forces

spare dome
#

do you have any physics materials on your car, do you have friction on your car?

#

do you have raycast suspension?

rapid glen
# spare dome sources of velocity, elaborate.

Well you see the code snippet I offered above, so you would expect that when I let go of W and motor torque is set to 0 (i know for certain it goes to 0), that the vehicle would decelerate or at worse stay the same speed, however it continues to accelerate

#

i only had the keypress and the motor torque code enabled on the script. anything else would come from the wheel collider or rigidbody

#

oh whhops i didn't open the dropdowns

#

@spare dome do any of these values jump out as wrong?

spare dome
#

does it keep accelerating forever after input or accelerates longer after you stopped the input then stops after a while?

rapid glen
spare dome
#

does it stop accelerating after a second or two then starts to slow down?

rapid glen
#

yeah

lean sail
rapid glen
#

if im going like 15kph and let go it gets to like 25, but if im at 100kph it will go to like 200 or so

#

even though motor torque is def set to 0 on the wheels

rapid glen
#

and yes it slows down normally once it stops accelerating

spare dome
#

try making the rigidbody drag higher

#

just a wild guess

rapid glen
#

ok what you think?

#

like 5?

spare dome
#

try 1 - 5 to see what works if at all

rapid glen
#

setting drag to 1 using 5000 motor torque on back wheels lets me get to 19kph 😛 doesnt fix issue though :/ i let go at 5kph and still goes to 19

#

drag at .1 still same accel issue but i can go higher speed 😦

chrome trail
#

I'm trying to create a display for a sort of movement area for a character (That is the maximum distance a character can move in one turn) and I want to omit the vertices outlined in green from the final mesh. While I know how to find what vertices should be omitted, I don't know how I would go about drawing the triangles for these meshes let alone in a way that only omits the areas outlined in green. Any ideas?

cosmic rain
# rapid glen

One thing that seems suspicious is that the rb is kinematic? I don't think it's supposed to be kinematic for a setup with wheel colliders. Or are you changing that via code?

cosmic rain
rapid glen
chrome trail
pale shoal
#

is there a way to put 3d models in while the unity game is running i think we can use addressables no?

cosmic rain
# rapid glen yeah it's kinematic until the car is finished being set up

Okay.
I think wheel colliders have something like inertia, where even if the motor torque is set to 0, they would keep on applying forces depending on their rotation speed and other parameters. I think wheel damping is meant to control that. Can you try setting a higher value for wheel damping?

cosmic rain
chrome trail
cosmic rain
rapid glen
chrome trail
cosmic rain
arctic rune
#

ok so I'm trying to get an object to move from one side of an object to another this is what I got but once it gets to one side it stops and gets stuck, I realized it was because it would play both if statements at the same time. I can't figure out how to fix this and going on google hasn't been helpful. I tried using while loops so that the if would play until it gets to one side but learned that causes unity to freeze up so I don't know what to do.

leaden ice
#

it doesn't make sense

#

it's trying to determine which way the object should move solely based on its current position

#

Think about whether that's actually enough information to determine which way it should be moving.

#

(it isn't)

#

FOr eample, if the object is currently in the middle should it be moving left or right?

arctic rune
#

idk but its for a school assignment where I have to build off my professor's code. This is what I'm working with

leaden ice
#

THink about it

#

Use your brain

#

tell me if you think you can tell based on just the position

arctic rune
leaden ice
#

So you need to keep track of that

#

How do you keep track of things in a computer program?

#

Think about how you might do that

arctic rune
#

using variables

leaden ice
#

ding ding ding

#

so what kind of variable could you use to track which direction the object is currently moving?

arctic rune
#

int would likely be best

#

using 1 and 0

leaden ice
#

Well you could do that but isn't there a better type to keep track of something that can only have two possibilities?

arctic rune
#

oh

#

boolean

leaden ice
#

So then - use a bool variable and then think about what the code should look like given there are two possible modes for your object and values for that variable

#

think about it like:

  • If the object is moving right, then we are looking for a certain condition to turn around
  • otherwise, we're looking for some other condition to turn around
#

and also - the movement needs to change based on the bool as well

arctic rune
#

ok so I got this but now the object keeps going rather than stopping

#

hold up wait

leaden ice
#

you're doing = which is assigning the bool

#

but also you never need == true or == false

#

you should just do:

if (moveLeft) {
  // is moving left
}
else {
  // is moving right
}```
spare dome
#

and you are always assigning moveleft to true because it is in update

arctic rune
leaden ice
#

use Start for things that should happen only at the beginning

arctic rune
#

alr fixed it up and now its working thanks a lot for the help

spare dome
# arctic rune alr fixed it up and now its working thanks a lot for the help

also since you are basing it off of the position, it would only work if the object is at the world origin (0,0,0) so if you want it to move around to different places I do not think it would work, so you could do something like this if you want

offsetposition = new vector3(0,0,0);
currentpos = transform.position + offsetposition;

if(currentpos.x >= offsetposition.x + 4){
    // do something;
}

now I have no idea if this works but you get what its trying to convey

thin aurora
tawny elkBOT
rapid glen
#

@cosmic rain @spare dome My issue with accelerating seems to be more or less solved when I set the mass of each wheel to .1. I will have to look in to why this is the solution because there may be some other underlying issue

weak dove
#

I have an FBX file with several animations in it, and I'm importing those (Legacy) animations with the 3d model. In-game, I load in the the 3d model as an addressable. Does this also load in the animations that were imported with the model? Or do I need to load the animations as a separate addressable file?

leaden ice
#

A prefab?

#

A Mesh?

weak dove
#

A prefab, yes

leaden ice
#

A prefab with an Animator?

#

Whatever is directly referenced in the prefab will be loaded with it. If it has an Animator with the animations, it will load that.

weak dove
#

No, there was an Animator before, but I removed it. You were helping me with that problem yesterday. Essentially I have hundreds of animations in one fbx file. Loading all the animations in the Animator was taking up a ton of memory.

#

I managed to replace the Animator with an Animation component by importing the animations as Legacy animations.

#

The memory use went down significantly. But now I need a way to fetch the one specific animation I want (via script) and play it with the Animation component.

leaden ice
#

Make it addressable or use resources

weak dove
#

Make each animation clip an addressable?

#

When I run the profiler while loading in the prefab, the profiler is still showing hundreds of animation clips (even though the memory use for them is lower). So I thought maybe those clips were being loaded in with the 3d model in the prefab.

elder zenith
#

Hey, kind of a weird question, but has anyone made a Task<bool> that returns true if a specfic event has been called in a timeout period, else returns false?

swift falcon
#

Guys an asset throw Editor errors from Editor folder when i try to compile. what to do

#

i guess if theres at least one assembly then unity will try to compile Editor folders when building the client.

thick terrace
spare dome
rapid glen
leaden ice
fleet gorge
#

the only concern is that if you call the function by its name instead of invoking the listener then it won't trigger eventHasRun

leaden ice
#

well why would you do that

#

you mean the event?

fleet gorge
#

shrug only would happen if someone was using your code

leaden ice
#

There is no way to "invoke the event by its name" without triggering the listeners

#

if you mean some specific listgener function then sure but then we're not talking about an event anymore

#

unless I'm misunderstanding you

swift falcon
#

GUYS if framerate breaks/lags is there a way to log real life time somehow via code since game start that has passed

#

like i want to know if my app took 1min or 3min to finish loading (low framerate during loading, making it hard to count time)

formal nacelle
#

Hey there. I have a scene where I have a video capture from a we came going in and rendering on a rawimage under a canvas.

The user can then choose to put an overlay ontop of this via a selection keypress.

The overlays are png sequences as they are animated and have transparency. I'm currently going through the png sequence in the update, there is probably a much better way to animate the png sequence, but I havn't gone down other paths yet.

The user can then start a recording.
Currently I have a camera that is rendering to a rendertexture and then I saving each frame of the render texture, then stitching with ffmpeg to get an mp4.

The problem I'm having is thst the saving of each frame is causing the video on screen to lag.

Is there a good way to move like the saving of the images to another thread or to a buffer or something instead of direct to file,

leaden ice
formal nacelle
#

I'll check that out, thanks

fallow quartz
#

Instead of using inheritance for avoiding variable duplicate, is it a bad or good practice to for example in a class stats put all the stats of ur game and just make 1 constructor for each case? With this strat you can just build stats and the class will use only the ones needed

#

And is there any similar way to do this with methods?

weak dove
#

Why is it that having an Animator with 100s of states for different animation clips takes more memory that storing those same animation clips into a serialised list on a game object? Wouldn't the same information be held in memory in both cases?

placid summit
leaden ice
#

The answer is composition

steady moat
placid summit
#

I would not define attributes with string names and values - that is troublesome - the magic string situation. You can use both composition and inheritance but don't abandon inheritance

leaden ice
#

It's not a magic string situation

#

you can use an enum if you want, or define constants

swift falcon
#

guys so im in loading screen and i have no idea how quickly i can execute code. cause people are going to have slowe rmachines than me lol

leaden ice
#

this was a quick and dirty solution to explain composition

placid summit
#

ok I see - yes enum perhaps. I have not not gone that far with composition but it is an interesting plan. But you need a lot of code to check the attributes listed and do different work accordingly, which might be easier just using inheritance

leaden ice
#

not a lot of work really

#

each ability function handles its own

#

inheritance simply does not solve the problem

#

and as soon as you encounter a case where inheritance doesn't fit, you have to tear the whole system down

placid summit
#

I guess it is a bit like the component pattern - if they can all work individually its great - if they end up having to reference each other it gets complex

leaden ice
#

yes _comp_onent systems are a form of _comp_osition

fallow quartz
placid summit
#

I would have to look at a full example of composition - I have not struggled with inheritance before though

leaden ice
leaden ice
#

inheritance is not bad

#

it's a tool

#

that can be misused

#

like any tool

#

it has its place

placid summit
#

composition makes me think of a game where you can add components to a robot until it does what you want. It could make a good game somehow! It definitely has a good feel, but you gotta try all tools until you find what works for you

leaden ice
#

People tend to learn polymorphism/inheritance when learning OOP and then think it's a cure-all solution for every single class of problem and that is just not what it is.

placid summit
#

there are many ways to change a light bulb

#

actually not really - but something something ways to do something

thin aurora
#

No highlighting says enough here

arctic rune
#

Highlighting for what specifically

#

Cause it does do highlighting for all instances of a certain variable when one is selected

modern creek
#

It's probably fine - just reopen VS by closing it then opening it within unity by double clicking a script file in the project - might have to kick unity to regenerate the project/solution files

#

Debug.Log() for example

#

transform in transform.Translate should be highlighted, Translate() should too.. your ide isn't recognizing those members

arctic rune
#

Why would it be highlighted I only have Vector3 selected

vestal arch
#

by "highlighted" we mean "colored"

#

syntax highlighting is highlighting different syntax elements by coloring them
like namespaces and types should be green in your current theme, but only sphereMove is in your screenshot

arctic rune
fringe ridge
#

so what's the proper way to move rigidbodies? MoveRigidbody glitches on collisions, just setting velocity ignores all other forces. Maybe adding to velocity and then checking if magnitude is not over a certain threshold?

rigid island
#

MovePosition ignore collisions because its meant to kinematic

fringe ridge
# rigid island AddForce

Doesn't add force stack? The same issue as with velocity, I can't keep adding or setting it, because i want constant speed

#

constantly checking if the speed is above a certain threshold seems excessive

rigid island
#

oh yeah true, in that case something like a V3/Vel clamp above a threshold. afaik thats the only way

maiden fractal
#

You can do exactly same as with .velocity with AddForce alone if you just calculate the required force correctly. Calculating the force yourself may give you more freedom to do custom stuff though hence AddForce is often preferred

rigid island
#

//move input
var sqMag = rb.velocity.sqrMagnitude
if(sqrMag * sqrMag > maxSpeed)
rb.velocity = vector3.ClampMagnitude(rb.velocty, maxSpeed)
else
rb.AddForce

maiden fractal
#

Vector3.ClampMagnitude exists btw

rigid island
#

ahh wops

fallow quartz
#

if i declare in an abstract class a dictionary and then 2 classes inherit from it, the classes will have the dictionary empty so i can fill it as i want right?

#

so like this I have full control over what variables i want in a class, s that correct?

#

or is it a bad implementation

lean sail
fallow quartz
leaden ice
leaden ice
#

oh yeah

#

I misread it

fallow quartz
leaden ice
#

But it's not clear what you're gaining from the abstract class here.

fallow quartz
leaden ice
#

Right that's what the Dictionary gets you

fallow quartz
#

cause the dictionary is empty, i just put <Stat, float> (Stat is an enum with all the names) and then i can fill it on each class

#

ability class i mean

leaden ice
#

what does the abstract class get you

fallow quartz
#

so they all have the dictionary

#

otherwise i have to declare them in each class

leaden ice
#

but why do they need to be different classes at all

fallow quartz
#

how would u approach it then

leaden ice
#

ok you want virtual method behavior

#

you could use delegates

#

but it's similar

fallow quartz
leaden ice
#

well with a delegate you could put them... anywhere you want

#

its fine though

#

your approach is fine. It's very similar to the List<Attribute> approach I mentioned

pure ore
#

Can static values be set like any normal value or do they reset after the next call?

leaden ice
#

not sure why you have the impression they would reset at some point.

pure ore
#

Well I just thought, because they were static

leaden ice
#

Static means they are not attached to an instance of a type.

#

It has nothing to do with "resetting"

#

whatever that means

pure ore
#

like turning it back to false for example

fallow quartz
pure ore
#

But thanks

leaden ice
ivory smelt
#

does anybody know is possible to avoid the header cloning when declaring fields in a single line?

[Header("Config")]
[SerializeField] private float _lookSensitivity, _walkSpeed, _gravityMultiplier, _jumpForce, _dashForce, _dashDuration, _dashFovChange, _dashCooldown;
somber nacelle
#

don't declare the fields on a single line like that. what's happening is the attributes are applied to each field declaration on that line, which means the Header attribute is applied for each of them

leaden ice
steady moat
#

That being said, you could create your own property drawer and handle that case.

ivory smelt
#

how does that even work XDDD

leaden ice
#

why wouldn't it work

#

it's two lines

ivory smelt
#

ye ye i just tried it works but why does it now detect each field in the single line as a different one and it didnt b4

#

😵

leaden ice
#

it's doing exactly the same as what you just had

#

the only difference is Look Sensitivity was pulled out into its own group with the Header attribute

ivory smelt
#

I guess it just another Unity silly thing

#

Thanks!!!!

leaden ice
#

This is a C# thing

#

nothing to do with Unity

#

but alright

ivory smelt
#

Didnt know, anyways, I appreciate the help!

somber nacelle
# ivory smelt I guess it just another Unity silly thing

as i described before, when you attach an attribute to a line of field declarations, it applies to all of them. what praetor did was take one of the fields and declare it separately and attached the header attribute to that instead of the line that has a bunch of them. this is why you see two SerializeField attributes in his example

ivory smelt
#

my bad I missed ur message

#

so it kinda "breaks" the loop?

somber nacelle
#

there's no "loop". it doesn't break anything. the attribute is only applied to the one field because it is only attached to the one field declaration instead of to all of them.

fallow quartz
somber nacelle
#

the header attribute is only applied to the field it is explicitly attached to. if you want to separate a field from others to show it is not part of a group then you can use the Space attribute

#

but header does not create any sort of grouping, it just draws a header above the field it is attached to

ivory smelt
spare dome
#

it only applies to the one it is attached to

somber nacelle
ivory smelt
#

alright so this is just a visual thing

somber nacelle
#

yes

ivory smelt
#

no hiiden logic underneath

#

nice

fallow quartz
# leaden ice Even in my List<Attribute> case, at runtime often I would build a dictionary in ...
public class CommonBehaviors {
    public void Attack() {
        // Lógica del ataque
        Console.WriteLine("Atacando al enemigo...");
    }

    public void Defend() {
        // Lógica de la defensa
        Console.WriteLine("Defendiéndose...");
    }

    public void Heal() {
        // Lógica de curación
        Console.WriteLine("Curándose...");
    }
}

public class Character {
    public Stats CharacterStats { get; private set; } = new Stats();
    private CommonBehaviors commonBehaviors = new CommonBehaviors();

    public void Attack() {
        commonBehaviors.Attack();
    }

    public void Defend() {
        commonBehaviors.Defend();
    }

    public void Heal() {
        commonBehaviors.Heal();
    }
}

public class Enemy {
    public Stats EnemyStats { get; private set; } = new Stats();
    private CommonBehaviors commonBehaviors = new CommonBehaviors();

    public void Attack() {
        commonBehaviors.Attack();
    }

    public void Defend() {
        commonBehaviors.Defend();
    }

    public void Heal() {
        commonBehaviors.Heal();
    }
}

so something like this would be a good implementation?

swift falcon
#

do you guys write a prefab manager?

#

idk addressables seem like an overkill for now

lean sail
rigid island
swift falcon
#

well i already wrote it

#

Damn i learned after years of coding today that in c# u should do public fields in PascalCase

fallow quartz
sleek heath
halcyon steppe
#

Hi, I have the issue that my camera always looks 90 degrees to the left of the intended target.

The lookAt camPivot is supposed to deal with the vertical rotation of the camera, which works fine, and the playercam.forward part is supposed to correct the horizontal rotation to be the same as the player, which the camPivot is parented from. However with this code, the Camera always looks exactly 90 degrees left from the intended target. How do i fix this and are there better commands to copy the horizontal rotation of a transform?

lean sail
bronze crystal
#

my gamemanager is a singelton but when i restart game my ui elements gets lost.

#

here my restart function in my gamemanager scrip and to activate the ui to show restart.

#
public void RestartGame()
{
    // Reload the current active scene
    Scene currentScene = SceneManager.GetActiveScene();
    SceneManager.LoadScene(currentScene.name);

    // Optionally, reset game state variables here if needed
    gameState = false; // Example: Resetting the game state to its default value
}

// Function to activate the UI element
public void ActivateDeathUI(bool death)
{
    if (gameState == false && death == true)
    {
        if (deathUIElement != null)
        {
            deathUIElement.SetActive(true); // Activate the UI element
        }
        else
        {
            Debug.LogWarning("Death UI Element is not assigned in the GameManager.");
        }
    }
}```
quartz folio
bronze crystal
#

yes my ui elements still in scene, but the reference to it gets lost

quartz folio
#

Are the actual original instances you have referenced still in the scene

bronze crystal
#

yes

quartz folio
#

Or, did you reload the scene, which destroyed those instances and loaded wholly new and completely different UI elements

bronze crystal
#

this is how it looks like after restarting.

quartz folio
#

Yes, and the instances in the Sample scene are completely new instances. They are not the same objects you referenced, the original objects were destroyed and replaced when you reloaded the scene

bronze crystal
#

ah

#

so i need to store them in prefabs?

#

because i tried to store them in prefabs and it didn't really worked well.

quartz folio
#

You can have a UI singleton that doesn't use DontDestroyOnLoad and lives in the scene, so when the new scene spawns the new singleton takes over

bronze crystal
#

but this gamemanager is a singleton

quartz folio
#

And it uses DontDestroyOnLoad

bronze crystal
#

for every element that needs to survive you need to create a seperate script?

short quiver
#

Hello, I'm looking for a framework to help me abstract away series of inputs in a game for the behavior of opponents. I have an abstraction to specify control inputs to a character because I want to make sure that all bot behavior replicates what a player can technically do, so I can specify, tick-by-tick, movements, aim directions, etc.
I'd like to abstract things such that, when I say (for example), "press this input and aim at your opponent for 60 ticks", for example, without having to write out each frame of logic each time. How might I go about that?
And maybe for another example, "input move direction away from opponent for N ticks/until X happens", etc.
Obviously I'll have to write functionality to specify what it means to "aim", "at enemy", "away from enemy", etc.
And in terms of writing these instructions out, I'm fine with the code being written in C#, but it would be cool if I could use some more expressive DSL

bronze crystal
#

when one of my elemens survive, new one are put in the game, but then you get a overlap

last hemlock
#

so what's like, reasonable as far as waiting for a bugfix. like i was naively assuming they'd fix my super clear ez repro case in the next minor version, but it's been two months and 10 versions since i posted the bug

#

starting to worry Unity will drop 2022 LTS before even getting to it

bronze crystal
#

i dont get it what else do i need to implement to make ui survive

#

if someone can check my gamemanager

short quiver
#

my gamemanager is a singelton but when i

naive swallow
#

Also, what's with the System.Obsolete

bronze crystal
naive swallow
bronze crystal
#

not needed anymore basically

naive swallow
#

and don't use Find anyway

short quiver
quartz folio
bronze crystal
naive swallow
quartz folio
short quiver
bronze crystal
#

i dont understand why it directly is already in the unload section

quartz folio
#

Split it up so you have a global DontDestroyOnLoad singleton that persists state,
and a separate UI singleton that doesn't persist that references the UI

short quiver
#

can you please use a thread, you're burying this whole channel

naive swallow
bronze crystal
short quiver
#

see here what happens

naive swallow
bronze crystal
#

yes and then restart canvas doesnt appear again.

naive swallow
#

The canvas is disabled

#

You're probably disabling it somewhere and then not re-enabling it again

quartz folio
bronze crystal
cosmic rain
# short quiver

Break it down into composite parts:

  • an action to do(input)
  • when to do it(condition)
  • how much times to repeat it
    • repeat delay
    • exit condition

If you define a data structure with these data you can virtually queue any kind of actions sequence. You can also have utility nodes like Sequence and Parallel to make several of these run in the desired order or at the same time.

soft shard
#

Correct me if im wrong, but what you described sounds similar to how a Behaviour Tree works?

cosmic rain
soft shard
#

Interesting, I remember seeing a tutorial for a custom one built with UIToolkit a while ago, BTs seem very flexible once you can get them setup

short quiver
#

Break it down into composite parts:

cosmic rain
soft shard
inner shuttle
#

still struggling with this

latent latch
#

you need to minimize the problem before anyone can help. Create a dev build and continue printing to console

inner shuttle
#

okay

latent latch
#

It's probably something with your camera/raycasting method so figure out where

dusk apex
#

I'm going to focus on the actual problem and not assume:

he refuses to specifically see me ... ive checked the console ... but that isnt giving me any errors
So it's not throwing an error (reference exception and whatnot - the basics)
In DetectSlasher, log what the raycast hit and it's layer.
In SlasherSight log:

  • if it's blind, chasing, sees player, touching, and if it's in the mesh.
inner shuttle
#

no errors at all

dusk apex
#

Of course.

pure ore
#

Gamepad input, is that something I should worry about in development or just when I'm about to publish?

rigid island
#

new Unity Input system makes it stupid easy anyway

pure ore
#

Yes, but I bought InControl and don't really use it

#

But I guess it isn't about what you want to use, it's about what's easy to implement

rigid island
#

yeah , I just prefer the built-in solution because its Free 😄

#

as long as rebinding is easy, thats mainly why the new system shines as well

short quiver
#

Are there any standard naming conventions for Fluent interfaces? https://en.wikipedia.org/wiki/Fluent_interface I just want to make sure that my callers know that a given method will mutate and return itself

In software engineering, a fluent interface is an object-oriented API whose design relies extensively on method chaining. Its goal is to increase code legibility by creating a domain-specific language (DSL). The term was coined in 2005 by Eric Evans and Martin Fowler.

leaden solstice
viscid tree
#

If Evans and Fowler "created" it, it is likely some nonsensical, self-explanatory crap, disguised as something they can sell "talks" about. 😉

#

The way i see it is that it is just a bunch of chained predicates, no more no less

trim schooner
#

and do not cross post, delete from the other code channel too.

swift falcon
#

guys is this value maximum float in unity?
it wont increase no further

3.355443E+07

very confusing

#

for example i tried to multiply it by 2 didnt work

plain sphinx
#

I've got an issue where Gameobjects that I Instantiate stick around after stopping the game in the editor.

Everytime stop and start the game another appears

I've tried forcing them to destroy when the scene unloads but it doesn't get called.

I'm not sure what I'm doing wrong

#

Reloading scripts will make them disappear

plain sphinx
#

If your planning on using it with large values then be careful its still accurate enough at the values your using

swift falcon
#

okay i checked and it happens to float but not doubles

#

I just might reset my time each in-game day or something

crimson trellis
#

i had this problem for quite a while, i just need some sort of Awake method for non monobehavior (to store to a static collection) but it create duplicates anyone knows a good solution?

thin aurora
tawny elkBOT
thin aurora
#

As for your question, a non-monobehaviour is supposed to use the constructor.

#

As for the actual issue; your code is coupled very poorly. I suggest you don't have d add itself to a static list like this. I don't see the point of such complexity

crimson trellis
thin aurora
#

Currently your issue is very hard to debug since your code depends on eachother like this, which makes no sense

#

Why is it serializable?

#

I guess it's to show it in the inspector

#

Does the inspector show duplicates?

crimson trellis
#

i think it just a unity problem

thin aurora
#

Still, why are you doing this?

#

Why have a static variable that seemingly does the same thing?

#

Do you need to access the list from another class?

#

If so, use singletons and not this mess

crimson trellis
#

i just use this code to present my problem

thin aurora
#

If this is not the actual code then I suggest you just share your actual code

#

Nothing about this suggests that there would be duplicates

plain sphinx
#

@crimson trellis
You could do something like this to get it working.
But this is going to run everytime you make a new instance.

private static List<d> slist;

private void Start() {
    if (slist == null) {
        slist = new List<d>();

        // Do your run once code here
    }
}
thin aurora
#

Even better, it's worse because your list might not exist when you need it

crimson trellis
#

i just want to make custom class that could have callbacks so i need to store them in a static list

thin aurora
#

@crimson trellis Your assignment of list from slist might very well cause the issue as Unity might fill it in afterwards with the serialized values

#

So I still suggest you get rid of this weird system you have and not rely on a static list

thin aurora
#

You want something entirely different

#

What are callbacks here? Please explain in detail what you try to achieve

#

I'd rather give you a proper solution than fix the current one

crimson trellis
#

it mainly for language changes so it callback on everything that is related to language

thin aurora
crimson trellis
#

yea

thin aurora
#

Then I suggest you reverse the process. Instead of adding callbacks, use events

#

I assume you have some sort of manager for this localization?

#

In short, you should probably have some singleton that manages this localization. When you update the locale, you inform this manager.

crimson trellis
#

it only gonna be harder if i dont use static , also i think this is a unity serialize problem if i use event it likely will add the event multiple times

thin aurora
#

When that happends, it triggers an event and tells any depending monobehaviours of the update. These can then update their strings

thin aurora
#

Also, idk what num would be in this list?

#

I still don't understand what this list is supposed to contain

crimson trellis
#

it just for testing

thin aurora
#

But even then, what would this list have if your idea is to support callbacks?

#

You can't implement delegates into a list through an inspector. That's impossible

#

This is why there's events

crimson trellis
#

this isnt the actual code, the main problem is that unity create duplicates

thin aurora
#

Well, until you share the actual code that I requested there's not much I can do for you

#

So please either share that, or go with my suggestion

#

But I can ensure you your currently static approach will not work and looks horrible

crimson trellis
#

my actual code is kinda 'fixed' but im searching for a better solution

thin aurora
#

You mean the solution that I already gave?

#

Your question revolves around informing depending code on a change in your locale settings. This is what you explained.

#

The correct way would be to use events, and not callbacks. I don't see how this would even work to begin with

crimson trellis
#

my main problem is that unity create duplicates for things that is serializable ,i just want a safe way to init clas
ses and not rely on monobehaviour

thin aurora
#

I already told you that constructors exist for initialization when it comes to monobehaviours

#

So if you're not interested in actually fix your current system, then there you go

#

Not much else I can tell you at this point

plain sphinx
#

@crimson trellis
What is your code duplicating?
Is it duplicating gameobjects?
Is it duplicating prints to the console?

crimson trellis
thin aurora
plain sphinx
#

Sorry I must have missed it

thin aurora
#

It's okay. The issue is clearly the fact that they try to use a static list for some reason. Something I tried explaining to deaf ears unfortunately

#

So unless they improve the system, this is unlikely to be fixed

plain sphinx
#

@brah can you post the code that adds to the list?

crimson trellis
#

it in the constructor

plain sphinx
#

Have you tried the code I posted earlier?
I think that will likely fix your immediate problem.

crimson trellis
thin aurora
#

Considering you're still trying to fix this issue despite being told multiple times that your current approach is horrible:
You get duplicates because when Unity is serializing the class, your constructor gets called a second time which makes a second instance in the static list

#

So please start listening to advice that is given to you and get rid of this horrible system

thin aurora
tawny elkBOT
thin aurora
#

Because clearly your current code is simply pseudocode that misses all the context we need here

crimson trellis
#

my problem is very clear: find a way to add a class to a static collection when it created

thin aurora
#

Or in other words, you are currently trying to find a fix to your current solution even though the issue is that you need a proper solution to begin with

#

So I ask again, share your code

crimson trellis
#

well i 'fixed' that by whenever u use the class u check is the bool isAdded on, if false add to collection and set to true

#

so i dont have to rely on a constructor

thin aurora
#

Or in other words you added in another hack on top of the hack you already developed

#

Clearly you are not interested in actually being helped, or you are lazy

#

I suggest you seriously consider listening to advice that is given to you next time. I am no longer interested in doing so.

crimson trellis
#

emmm im not sure how your idea would solve the problem,it either also make duplicates or is tedious to set up

thin aurora
#

It doesn't matter because you're not even considering it to begin with

#

And considering you have not yet shared the actual code I'd assume this is still the case

plain sphinx
#

I'm having a weird issue where GameObjects I instantiate will stick around in the game scene after stopping and starting the in-editor preview
Has anyone come across this before?

I have a MainMenu Scene which loads to a World scene
I have a "SpaceVesselController" object that does the instantiating, it is also set to Don'tDestroyOnLoad

The gameobject is the players initial SpaceVessel
Stopping and starting the game preview creates duplicates of the initial space vessel in the World scene

Reloading code after changes resets the scene
I tried using SceneManager.sceneUnLoaded += DestroyMyselfFunction() but it doesn't seem to be called when stopping the game preview

#

I've checked the world scene file and none of these exist there.
So they only exist when playing

#

FusedQyou do you have any Ideas?
I've run out of things to try

crimson trellis
thin aurora
#

Share SpaceVesselController

plain sphinx
#

public class SpaceVesselController : MonoBehaviour
{

    // Singleton
    public static SpaceVesselController instance;

    [System.Serializable]
    public struct NamedSpaceVessel {
        public string name;
        public GameObject spaceVessel;
    }
    public NamedSpaceVessel[] NamedSpaceVessels;
    private Dictionary<string, GameObject> spaceVessels;


    public GameObject SpaceVesselContainer;



    public void Awake() {

        // Singleton
        if (instance == null) {
            instance = this;
        } else {
            Destroy(this.gameObject);
        }
        DontDestroyOnLoad(this.gameObject);


        // Initialize space vessel prefabs dictionary
        spaceVessels = new Dictionary<string, GameObject>();
        foreach (NamedSpaceVessel namedSpaceVessel in NamedSpaceVessels) {
            spaceVessels.Add(namedSpaceVessel.name, namedSpaceVessel.spaceVessel);
        }


       

    }
    

    public void CreateSpaceVesselContainer() {
        if (SpaceVesselContainer == null) {
            SpaceVesselContainer = new GameObject("SpaceVesselContainer");
            SceneManager.MoveGameObjectToScene(SpaceVesselContainer, SceneManager.GetActiveScene());

        }
    }



    public GameObject SpawnSpaceVessel(string spaceVesselName, Vector3 position, Quaternion rotation) {
        CreateSpaceVesselContainer();
        

        GameObject spaceVessel = Instantiate(spaceVessels[spaceVesselName], // Get the prefab by name
                                            position, 
                                            rotation); 

        // Parent to the space vessel container
        spaceVessel.transform.parent = SpaceVesselContainer.transform;

        return spaceVessel;

    }


    

}
plain sphinx
thin aurora
#

Please properly share your !code

tawny elkBOT
plain sphinx
#

edited

#

This is a recent addition, it has no effect

SceneManager.MoveGameObjectToScene(SpaceVesselContainer, SceneManager.GetActiveScene());
#

I just checked and SpaceVesselContainer starts in the world scene anyway

crimson trellis
#

can u explain your problem again?

plain sphinx
#

I move from the MainMenu scene to the World Scene
When the world scene starts, I instantiate a single game object from a prefab.
There is only one instance of this object here at the moment

I stop and start the game, navigate through the menu into the world scene.
A single instance is created again,
Now there are 2!

#

I can keep repeating and more gameobjects all get instantiated in the same spot!

#

Restarting the editor like you suggested resets it back to 1

#

But the same issue appears again

crimson trellis
#

are u talking about the darter being created?

plain sphinx
#

yes

#

Darter = SpaceVessel

#

This is what it looks like

crimson trellis
#

your SpaceVesselController seems right sorry couldn't help

plain sphinx
#

Thanks for trying

thin aurora
#

So the issue is that they persist when you stop debugging?

plain sphinx
#

correct

#

I found something interesting

I put this on my gameobject, and the space vessel gets destroyed as soon as its created when loading the world scene

public void OnSceneLoaded(Scene scene, LoadSceneMode mode) {
  Debug.Log("SpaceVessel: OnSceneLoaded");    
  Destroy(gameObject);
            
}

On the other hand this has no effect

public void OnSceneUnloaded(Scene scene) {
  Debug.Log("SpaceVessel: OnSceneUnloaded");    
  Destroy(gameObject);
}

its seems to be getting loaded inbetween scenes?
I didn't think this was possible

round violet
#

so i am getting a weird issue
i have a enemy prefab, inside there is a prefab containing the skeleton mesh + a animator
if i disable this skeleton prefab, my prefab gets instantly teleported to 0,0,0 when playing

it seems linked to the ragdoll physics of my skeleton, because if i removed all parts except 1 with a rigidbody it keeps teleporting
if i disable the rigidobdy it doesnt get teleported (makes no sense since the GO shouldbt be actif on a inactive rigibody

round violet
#

nevermind, seems like if a joint connection is null it goes to world center

normal isle
#

guys i want your help in creating shader graph on unity is it possible to create a shader graph that cut the mesh and on th cutting surface it show the inner port of the mesh let assume i have to cut th wooden block thn i also want to show cutting surface of wooden block

trim schooner
#

Yes

normal isle
#

can u guide me brothe i am able to cut the mesh but unable to applly fake inside texture

trim schooner
#

nope. dunno how to

#

there are lots of tutors on how to slice a mesh with a shader and fill in though

spare dome
shrewd tendon
#

Why do many people in unity state not apply MVC? What reasons do you have to not use it?

#

Is a separation into model and view still commonly applied, with different information flow paradigms?

mellow sigil
#

Didn't you already have a lengthy conversation about it last week

dusk apex
#

With Steve iirc

shrewd tendon
#

can I state that in game art the physical shape (and thus physics and behavior) is often connected to what an artist is trying to communicate to the user, and therefore behavior and presentation are intrinsically tied in assets, and therefore anything that builds on these assets cannot effectively separate model and view?

shrewd tendon
#

I thought about that conversation, and I made some guesses why one would not separate for instance model and view

#

the reason I needed to think about it is because it goes against everything in every other software engineering project I have taken on

#

I hope I didn't bother anyone with the question. I'll just see where my approaches fail then (:

mellow sigil
#

Maybe now would be a great time to learn something new. If you want a similar separation of concerns, look into ECS which uses entity-component-system instead of model-view-controller

shrewd tendon
eager tundra
shrewd tendon
#

interesting

#

when I was still a student I designed an architecture for an adventure game, that essentially generated the user interface from events

#

I really like the ecs pattern

eager tundra
#

yeah, it's great, but I feel that the current Unity implementation is a bit frustrating to work with

naive swallow
# shrewd tendon can I state that in game art the physical shape (and thus physics and behavior) ...

Often times, what you see and what makes sense in a game are different. Mega Man can stand almost completely over a pit because his hitbox is a rectangle, but his arms are wider than his feet so they are visually over nothing. This looks ridiculous, but allows for significantly better movement since you basically have built-in "Coyote time", and it allows you to jump on top of a ceiling directly above you, which can create new paths for those adventurous enough to try it.

#

In almost every 3D game, your character is actually a cylinder or capsule or some other simplified shape, the mesh doesn't actually do any of the physics calculations.

shrewd tendon
#

the way I understand the code and diagrams is that model and view changes often happen at the same time

#

and therefore, you just needlessly complicate things if you disentangle them...

#

if you think I don't understand correctly or if I do get it, please let me know!

eager tundra
#

that depends on your use case, project needs, personal preferences, etc
every architecture comes with its pros and cons
having the model and view decoupled makes it easier to create unit tests and swap different implementations

#

but then you need to deal with the added complexity of having them decoupled in the first place

steady moat
# shrewd tendon Is a separation into model and view still commonly applied, with different infor...

From I have seen, almost every sensible implementation of a game implements a "View" and a "Model". The "controller" aspect of the MVC is only implemented when needed and is not done systematically.

That being said, there is really a few situation when it is actually needed in video game. Such situation can be when dealing with non ui-view or with multiple view for 1 "system". By example, I implemented a MainMenu that combines UI Element and World Element. Where it is possible to put the whole logic in the "View" (UI Element), I found it was more natural to add an additional layer of abstraction to handle both. Most of what is done would be inline with what a controller is usually doing.

zealous lagoon
#

Hello, I have a bit of a problem. I'm trying out unity's job system by having a big NativeArray with structs and have each job modify a part of the array, like each job does 100 elements or so, with them all accessing unique indexes (like two jobs never read/write to the same place). But there's an issue, unity finds this to be an error and asks for dependency, which is unfavorable.

Using nativeslices causes the same error. Any ideas how to split the data without copying the entire array over and over?

I print the indexes to make sure, and no slices share any indexes.

#

I did some googling, unbelievable it seems like copying the entire array for each job is the only way to solve this. Maybe the forums I checked were wrong as it'd be pretty silly if its the only way

#

Theoretically, is it possible to bypass the memory checks? Unless there's an actual problem writing to different indexes of the array in parallel, it should be fine, right?

late lion
# zealous lagoon Hello, I have a bit of a problem. I'm trying out unity's job system by having a ...

The issue is that Unity's job safety system is unable to verify that each job is in fact accessing separate parts of the array and can be deemed to be safe. If the safety system's detection was more sophisticated, it might be able to handle your case, but it's not.

If these are completely separate jobs working on the same array, I think you have to use unsafe pointers instead of NativeArray to bypass the safety system.

#

There are unsafe versions of various NativeX collections, like UnsafeList, but there isn't an UnsafeArray, I think you just have to use pointers directly.

buoyant vault
bronze crystal
#

rider ide says i'm not using this function, but actually i'm within my player script: GameManager.Instance.ActivateDeathUI(death);

steady moat
bronze crystal
#

i said something wrong?

naive swallow
#

Or is it in a different assembly?

naive swallow
#

If that assembly references this one, you can call it just fine, but if this one doesn't have a reference to that one, then the IDE wouldn't know about it from here

bronze crystal
#

im actually call this function from within the player script

#

the function intself is in the gamemanager script

#

weird why the ide says i dont use it

zealous lagoon