#archived-code-general

1 messages · Page 76 of 1

swift falcon
#

not exactly sure if it belongs in this channel, but it probably does

i'm working on a crosshair system where the crosshair only appears when you're hovering over an object that can be interacted with. everything was fine until i remembered to add a check to make sure you were close enough to the object in order to use it.

now, for some reason, when i hover over an object, it doesn't detect i've done so. only when i stand still, hover off the object, and hover back on, does it detect properly, and if i move around, it fails again

code is right here (still new to using c# but i think this belongs here over the beginner channel)

`void OnMouseEnter()
{
float dist = Vector3.Distance(this.gameObject.transform.position, camera.transform.position);
if (dist < minDist)
{
//these two following lines work fine on their own without the distance check
isHover = true;
chAnim.Play("Base Layer.CrosshairIn", 0, 0f);
}
}

void OnMouseExit()
{
    float dist = Vector3.Distance(this.gameObject.transform.position, camera.transform.position);
    if (dist < minDist)
    {
        //as well as these two
        isHover = false;
        chAnim.Play("Base Layer.CrosshairOut", 0, 0f);
    }
    else
    {
        //so that it doesnt play the fade out animation whenever you hover off anything
        isHover = false;
    }
}`
timid crater
#

Good evening! Can I use an action to assign a value to a variable? for example I have a function that returns a GameObject, and I have an action that is subscribed to this function, what should I do to assign the value returned from the function to another variable? code goes like..

public static Action a;
public GameObject object;

void Start()
{
  a += myFunction;
}
// Somewhere in the code.
a?.Invoke();

// In another script.
public static GameObject myFunction(GameObject obj) {}

I don't know where to go from here to do what I was wondering in the question I listed above.

tepid charm
#

try logging when you hover and exit, and the distance

#

see if anything seems off

swift falcon
tepid charm
#

oh sorry

#

I missed that

swift falcon
#

nothing different from what was already happening

#

i forgot to add that it does detect when you hover off just fine

#

its only hovering on that doesn't work right

#

ok, so nothing is wrong with the code, some of my colliders are the issue

#

breaking up a few of them into smaller fragments appears to have fixed the problem

glossy basin
#

Hello there, when working on Jobs system and using burst compiler, what is the difference between native list and native array?

#

do they have very specific use cases?

heady iris
#

NativeList is resizable. NativeArray is fixed in size.

#

Use NativeList where you would want a List, and use NativeArray where you would want an array

lament bloom
#

I'm trying to figure out how to go about implementing combat, my simple vision for now is just that when a sword swing animation plays and the sword's mesh collider comes into contact with the collider of a combat-capable entity, damage should be dealt to that entity according to

  1. the sword's stats
  2. the player's stats
  3. the stats of the thing being attacked

I'm thinking of having the receiver of the attack be listening/responding to the collision from the sword, but I also need to wait for an animation event from the attacker to fire before registering a hit. How would I go about waiting for an animation event to fire, but respond to it only if a collision is occurring? In my head it would look something like

public void OnCollisionStay(Collision collision)
{
    // wait a finite amount of time for animation event to fire
    if (eventFired)
    {
        // look up the stats of the weapon and the player who attacked us and take damage accordingly
    }
}

maybe i can use a coroutine here?

heady iris
#

oh hey, I already implemented something like this

#

here's my setup:

#

a Weapon has a Moveset. The Moveset tells you what animations to play and how powerful each move is.

#

a Weapon also has Hitboxes. The Weapon turns the Hitboxes on and off at the appropriate times through animation events.

#

Entities have Hurtboxes

#

if a Hitbox touches a Hurtbox, the Weapon is told about the collision

lament bloom
#

i see

#

you activate the colliders only when the animation is happening

heady iris
#

the Weapon removes duplicate collisions

#

if it sees a fresh contact, it notifies the Hurtbox that it got hit

#

the Hurtbox tells its Entity that it took a hit

#

Hitboxes and Hurtboxes also have "quality" fields, so that glancing hits don't hurt as much

#

so if the glancing hurtbox is touched first, you might get an 0.3 quality hit

#

and then if that hitbox goes on to strike the good hurtbox, you get an 0.7 quality hit

#

(not 1.0 quality, or you'd be double-dipping on damage)

lament bloom
#

this makes sense yea

#

hmm

heady iris
#

also, I use triggers for everything

lament bloom
#

unfortunately my anim set comes with only a single animation event on every attack animation indicating when the attack fully "connects" but this isn't ideal for my situation

#

not rly looking forward to going in and adding 2 extra anim events to every attack 😹

#

but it's probably the best way to go about this sort of thing

heady iris
#

yeah

#

I also have separate events for each limb

#

my "kick" weapon puts a hitbox on your foot and then activates it at the appropriate time

tepid charm
#

yeah that's what I usually do

#

gives you very precise control over the animation

shut ivy
#

can anyone help explain to me how object rotation works in world vs local space? I have a bullet hole decal i'm spawning into my game and aligning to the normal of the terrain, which works perfectly fine, but if i try to modify the local Y axis of the decal it completely overwrites all the axis. Is there a way to preserve all object rotation in world space and only modify one axis in local space?

GameObject bulletHole = Instantiate(_decal);
bulletHole.transform.rotation = Quaternion.FromToRotation(Vector3.up, hit.normal);
bulletHole.transform.localRotation = Quaternion.Euler(0, Random.Range(0, 180), 0);
bulletHole.transform.position = hit.point + hit.normal * .001f;
#

I've tried with bulletHole.transform.localRotation = Quaternion.Euler(bulletHole.transform.localRotation.x, Random.Range(0, 180), bulletHole.transform.localRotation.z); and
bulletHole.transform.localRotation = Quaternion.Euler(bulletHole.transform.rotation.x, Random.Range(0, 180), bulletHole.transform.rotation.z); as well

heady iris
#

I would suggest using AngleAxis

#

you give it an angle and an axis (surprise!) and it produces a rotation

#

so, if the axis is the world-space vector pointing into the bullet hole, then the angle will spin the decal around

#

I guess I'd just get it lined up, then use transform.forward (or whatever direction is "in")

#

you can figure that out by looking at the arrow gizmos with the decal selected

#

if this was the decal stuck in the ground, then I'd say "in" is the -Y axis

#

because the green arrow (Y) is pointing out of the ground

#

so I'd use -transform.up

heady iris
#

if I give that capsule a random rotation (so that all three axes are non-zero), grabbing the red or green rings changes all three axes at once

shut ivy
#

thanks a bunch, this is definitely helping me get in the right direction, i've got it spinning on the correct axis now

heady iris
#

this makes it hard to reliably change a rotation by just mucking with one number

shut ivy
#

i can get the decal to reliably rotate around it's local y axis now, which is amazing, but it's still resetting x and z to zero no matter what I do, this is all amazing information but at this point i think i'm just fine with having the decal look the same every time it's spawned lol

heady iris
#

I don't understand -- if it's correctly rotating around the Y-axis, how could the world X and Z Euler angles be getting reset to 0?

#

wouldn't that mess up its orientation?

shut ivy
#

i should have been more clear, after i align the decal to the normal if I try to rotate around just a single axis it resets the other two to zero and throws off the alignment completely, the angle axis works for another application in the same project tho so thanks a million for that information

#

turns out i was doing the declaration backwards -_- my final code:

bulletHole.transform.localRotation = bulletHole.transform.localRotation * Quaternion.AngleAxis(Random.Range(0,180), transform.up);

what i was doing

bulletHole.transform.localRotation = Quaternion.AngleAxis(Random.Range(0,180), transform.up) * bulletHole.transform.localRotation;
#

instead of multiplying the existing rotation against the new rotated axis, i was creating a new rotation around an axis and multiplying that against the rotation, so 0x * localx

lament bloom
#

Is there a reasonable way to differentiate between colliders on the same object for various intents and purposes?

heady iris
#

You're spinning the object around an axis

#

the result is the world-space rotation

#

since transform.up is the world-space up vector

shut ivy
#

i thought transform.up was local and vector3.up was world?

heady iris
#

transform.up is the world-space direction that "up" is for you

#

I guess Vector3.up is the local-space "up" direction

#

which is a constant, because it's your local space!

shut ivy
#

oohhh

leaden ice
swift falcon
#

Hi I want my focus to move smoothly if I look to the sides, my focus moves smoothly vertically but horizontally it does not.:


        // Rotation Y
        float yAngle = Mathf.LerpAngle(transform.eulerAngles.y, playerInput.horizontalMouseInput, smoothness);
        transform.eulerAngles = new Vector3(transform.eulerAngles.x, yAngle, transform.eulerAngles.z);

        // Rotation X
        float xAngle = Mathf.LerpAngle(transform.eulerAngles.x, playerInput.verticalMouseInput, smoothness);
        transform.eulerAngles = new Vector3(xAngle, transform.eulerAngles.y, transform.eulerAngles.z);``` help
heady iris
#

that seems fine

#

what if you remove the code that controls the X rotation?

#

just to rule out some kind of influence

harsh osprey
#

i'm trying to make it so that if a gameobject with a specific tag collides with a trigger, something happens, but it isn't working for some reason even though the code seems fine to me? the debug log that outputs 'working' is the only thing that runs, but it seems to ignore everything else

    void OnTriggerEnter2D(Collider2D collider)
    {

        Debug.Log("working");

        if (collider.gameObject.CompareTag("solid"))
        {
            Debug.Log("solid gameobject trigger working");
        }
        else if (collider.gameObject.CompareTag("striped"))
        {
            Debug.Log("striped gameobject trigger working");
        }
    }
quaint rock
#

debug.log the collider or its tag and see what you are actually getting

heady iris
#

yes

harsh osprey
#

ohh it's giving me the trigger instead of the gameobject i want it to do something with

#

that should've been obvious to me 🤦‍♂️i think i can figure it out from here, thank you

lament bloom
#

im finding that occasionally due to animation oddities, the character "drawing back" their sword after a strike counts as a second collision

#

how can i avoid counting these accidental collisions as actual attacks?

#

i also find that the weapon (obviously) collides with the person holding it 😹 i don't really know a smart way to differentiate valid collisions between assailant weapon and body from accidental collisions

heady iris
#

in my system, the hitbox checks that

#
    void OnTriggerEnter(Collider other)
    {
        if (other.TryGetComponent<Blockbox>(out var blockbox))
        {
            weapon.entity.StateMachine.TrySetState(weapon.entity.states.flinchState);
            weapon.Contact(this, blockbox);
        }
        if (other.TryGetComponent<Hurtbox>(out var hurtbox))
        {
            if (weapon.entity != hurtbox.entity)
                weapon.Contact(this, hurtbox);
        }
    }
lament bloom
#

hmm

quaint rock
lament bloom
#

what is .Contact

heady iris
#

that's part of my code

quaint rock
#

also just enable the collider only when you need it

lament bloom
#

hmm

heady iris
#

sounds like it's enabled at the wrong moment, then

lament bloom
#

yeah it might be

heady iris
#

you'd need to put each unit on its own layer

#

so that it can't hit itself

quaint rock
heady iris
#

well, the enemies shouldn't hit themselves, either!

#

but maybe they should be able to infight

#

my game has basically 0 distinction between the player and non-players (it just swaps in a different brain)

#

it's a nice philosophy

#

it also makes it really easy to enable Silly Mode where the player is given control of some garbage low-level enemy

#

:p

lament bloom
#

hmm

heady iris
#

the tl;dr to achieve that:

#

make your "entity" class get all of its instructions from a "brain" class

#

actually let me just find the article..

#

this is specifically in the context of Animancer and its Finite State Machine system

lament bloom
#

i checked back with my animation events and they seem right, it seems like pretty much ever attack hits the training dummy twice somehow, not really sure why? i'm using OnCollisionExit too so it should technically only trigger once the sword has left the training dummy, not while it's making contact

heady iris
#

it could wobble back and forth tho

#

also, maybe the dummy has two colliders

lament bloom
#

oh shit yeah

#

thanks 😭

heady iris
#

:p

#

I store all of the hit data like this

#
private readonly Dictionary<Entity, List<Tuple<Hitbox, Hurtbox>>> hits = new();
olive shore
#

Christian server pls dont swear, thank you, go with god

heady iris
#

for every entity, it records every hitbox-hurtbox pair

#

most of that is irrelevant

#

i could just store a set of entities

#

actually

#

why don't I just do that

#

I do need to remember the quality of the hits, but that's just a float

#

I'll think of something!

lament bloom
#

what kind of project are you working on

heady iris
#

it's a soulslike

lament bloom
#

lovely

#

good luck 🫡

plucky karma
serene lake
#

I am using netcode for gameobjects and keep getting this error:
```ArgumentException: Type System.Int32[] is not supported by NetworkVariable1. If this is a type you can change, then either implement INetworkSerializable or mark it as serializable by memcpy by adding INetworkSerializeByMemcpy to its interface list. If not, assign serialization code to UserNetworkVariableSerialization.WriteValue and UserNetworkVariableSerialization.ReadValue, or if it's serializable by memcpy (contains no pointers), wrap it in ForceNetworkSerializeByMemcpy1.

#

Does anyone know why this is the case

night harness
#
[System.Serializable]
public class UnityEventCollider : UnityEvent<Collider>
{
}

public class TriggerForwarder : MonoBehaviour
{
    public UnityEventCollider onTriggerEnter;
    public UnityEventCollider onTriggerStay;
    public UnityEventCollider onTriggerExit;

    void OnTriggerEnter(Collider other)
    {
        onTriggerEnter.Invoke(other);
    }

    private void OnTriggerStay(Collider other)
    {
        onTriggerStay.Invoke(other);
    }

    void OnTriggerExit(Collider other)
    {
        onTriggerExit.Invoke(other);
    }
}

Unity isn't liking this UnityEvent I'm trying to set up and I'm not sure why

#

the functions added in the collider events are

    public void ForwardTriggerEnter(Collider other)
    {
        if (other.CompareTag("Player"))
            InteractUIUpdate(true);
    }

    public void ForwardTriggerExit(Collider other)
    {
        if (other.CompareTag("Player"))
            InteractUIUpdate(false);
    }
leaden ice
lofty storm
#

Umm.. So I want to make a controls editor for my game. The input system I used for my game is the old fashioned way ( If (input.Getkeydown(keycode.w)) ) one. So how will I be able to do this?

potent sleet
night harness
leaden ice
leaden ice
night harness
#

oh im dumb, ignore the first error i sent

lofty storm
#

switching is easy right?

leaden ice
lofty storm
#

or is it a lot of work?

potent sleet
leaden ice
potent sleet
#

once you learn it you wont go back to old inputs, trust @lofty storm

night harness
leaden ice
lofty storm
#

Thanks!

leaden ice
#

Show the inspector

#

For the event

night harness
leaden ice
#

Yeah

#

You've assigned the function incorrectly

#

You assigned them from the static parameter list

#

Reassign and use the top entry for the function where it says dynamic

#

When done properly the bottom right part will disappear (where it says None)

night harness
#

wow that is very easy to miss

#

thank you

plucky karma
#

Why do you need a trigger forwarder script...?

#

All monobehaviour objects have OnTrigger event implemented...?

night harness
#

and afaik the stock OnTrigger calls have protection on them to stop that

#

if I missed a way i'd love to know

serene lake
potent sleet
lament bloom
#

is there a straightforward way to check if a component exists on any parent of a given game object?

plucky karma
#

This sounds like a bad practice use.

lament bloom
glossy basin
#

Hello there, does anybody know or have an article for merging multiple noises together? I am currently making a game like minecraft and I would like to have some more variation on my noise, essentially I would like to add some flat areas, and some others with mountains and so on (biomes pretty much). I tried multiplying two noises together but results get extremely random; I also tried using +, it looks good but still doesnt look natural

#

these are the results of multipliying to different noises together

#

this is using + operator but still doesnt look good

lament bloom
#

I'm looking for an idiomatic way to get access to information about a character and weapon when on the receiving end of an attack from said character and weapon. So I'm starting out with just the Collision that results from the weapon coming into contact with us, and from there i want to look up the weapon's stats as well as the character wielding the weapon's stats in order to compute the damage dealt to me

#

my naive approach would involve just making sure the weapon is actually a child of a character first of all, getting access to that character's game object by running up the tree and then calling GetComponent on that object to get the information i need

west lotus
#

You could simply store a reference to the character in the weapon itself and just get the weapon component

#

Then you can have a lets say Calculate damage method on the weapon and just use that

candid trench
languid crane
night harness
languid crane
#

i see, very interesting, thank you!

night harness
#

Ideally I would just call those OnTrigger functions directly but they have protection to stop that for probably good reasons but it does make it more annoying

languid crane
#

yeah, I remember trying to call ontriggers from other classes a long time ago, its cool to see a way to do it

orchid bane
#

How does scripting differ from common programming?

night harness
#

In a majority of conversations those terms are used interchangeably

orchid bane
#

but programming isn't scripting

potent sleet
# orchid bane but programming isn't scripting

Scripting is typically used for automating tasks or writing small programs, with interpreted languages and a focus on simplicity and readability.
Common programming is used for complex software development, with compiled languages and a focus on control and robustness.

thorny sparrow
#

Hello. In my game, I am trying to achieve an effect where Object A and B start off at 100% scale but when Object A is approaching 0% Object B will be approaching 50%

#

Anyone know how I can do this?

quartz folio
#

y = Mathf.Lerp(0.5f, 1, x)

thorny sparrow
#

thank you I will try it

cursive hemlock
#

can anyone tell how close codingame.com is to real game programming problems?

swift falcon
#

is there any way to call Unity API (setactive, getcomponent, etc.) from a intepreted language (such as LUA) ?

cold parrot
swift falcon
winged mortar
#

The noise function should be scaled such that the result makes sense for the use, I would expect the biomes to not change too frequently, and therefore use some scaled parameters, but if you for example want to add a little bit of texture to places (high variation, low in intensity) you'd do the exact opposite

#

Finding the right aprameters is 80% of the work

cold parrot
cursive hemlock
#

No? What kind of example?
If you know the Page. Is this what one can expect from programming a Video Game?

potent sleet
thin aurora
timid crater
#

Hello, I'm trying trace points for the first time, it's saying that the message is shown in the output window, where can I find it?

#

If that means the console window in Unity editor, I checked and it wasn't there

rough shuttle
#

How to replace a component in inspector to a child component?
example I have a weapon monobehave attached.
I made an inherited script called weaponMelee
I want to replace weapon to weaponMelee in the inspector without having to drag and drop all the fields

somber nacelle
#

you can copy the component values from the context menu, i would assume it would allow you to paste them onto the inheriting component

swift falcon
#

I need to add external code to my game at runtime. For Windows, I create an asset bundle of the dll and then when I need it I load the bundle and do assembly.load and it works. But I dont know how to do if for iOS. Any ideas?

quartz vessel
#

I am integrating google ads in my unity project but when i want to create a build it gives the classpath error.
Anyone can help me ??

somber nacelle
#

oh you already posted there. in that case you shouldn't crosspost

pastel bluff
#

how to make a plane detect collisions from both sides? it's not exactly a plane, but a flat mesh generated in a script.

somber nacelle
#

give it a box collider?

pastel bluff
#

I'm just checking if there is a solution without having to double up the plane to the other side

somber nacelle
#

yes, give it a box collider

pastel bluff
#

a box collider would be just a patch up, unfortunately

somber nacelle
#

well mesh colliders only collide from one side of each face. box collider for this situation would just be a better option. the mesh is flat anyway, right?

pastel bluff
#

it's a mesh in a complex shape

#

not just a box, unfortunately

#

I can make it to have two faces in code, just checking if there wasn't an option to make collisions against back faces

somber nacelle
pastel bluff
#

Thanks! 🙂

rustic ember
#

What does this mean?

#

My scriptableObject can't be loaded

somber nacelle
#

have you resolved the compile errors?

rustic ember
#

Yep

#

Is it because I have no scripts deriving from this one?

#

I haven't made them yet

somber nacelle
#

well that's one reason. another is that you cannot attach a scriptable object as a component

rustic ember
#

Alright. I'm not trying to attach it as a component. I am simple creating an asset with it

somber nacelle
#

ah, your screenshot was so cropped it looked like it was attached to a gameobject. but yeah, you cannot have an instance of an abstract class so no instances of that SO

rustic ember
#

Alright. Thank you 🙏

pastel bluff
#

I just fixed moving the raycast and reversing it 🙂

rustic ember
#

I am not sure why, but I can't assign an instance of this script to an AbilitySO field

rustic ember
thin aurora
#

Does it work if AbilitySO is not abstract, and you change its abstract methods to be virtual?

#

Do the file names of HealAbility and AbilitySO match the names of the actual class? Pretty sure this is the reason of the warning?

rustic ember
#

I changed the file name

#

It tried to tell me

#

Thank you

#

I always feel so stupid when that happens 😪

sour trench
#

How do you prevent a blocking collider from interfering with a trigger collider on the same gameobject? Feels like I've tried everything at this point but nothing works as long as the blocking collider is there.. either on the same object or as a child, or reversed so trigger is a child and blocker on the parent. I've also tried using layer masks when raycasting to exclude the blocking collider's layer like RaycastHit2D hit = Physics2D.Raycast(ray.origin, ray.direction, Mathf.Infinity, ~(1 << LayerMask.NameToLayer("Ignore Raycast"))); but same result. Also this approach won't work anything since hovers are done using OnMouseEnter and OnMouseExit in each Interactable script...

I need to be able to hover and click the ENTIRE crate while only the bottom of the crate blocks the player's movement. Any ideas? 😫

rustic ember
#

Here you can change the layers that collide with each other

#

(it's the grid at the bottom right)

#

.

How can I stop an IEnumerator from within the IEnumerator? Does it automatically stop when it reaches the end?

somber nacelle
#

yes, you can also use yield break; to end it early

tame zealot
#

public int PuzzelControllerIndex;

    if(PuzzelControllerIndex == 1)
    {
        /*Play animation*/
    }

    if(PuzzelControllerIndex == 2)
    {
        /*Play animation*/
    }
#

hello is there a way i can do somthing like this, I still cant figure it out : p

sour trench
#

@rustic ember Hmm never used this. I put the trigger on "Default" and the blocking collider on "Blockers", and then disabled the collision between them as seen in the image but I don't really see an improvement :/

thin aurora
#

Or a basic Array

#

Store the animations, and get is by index the same way you do there.

somber nacelle
rustic ember
#

Then when you do your raycast you want to use a layermask to only hit the clickable

#

Although, you probably don't want to use a Raycast for detecting clicked objects

#

Do this instead: ```cs
[SerializeField] private LayerMask clickMask;

        if (Input.GetMouseButtonDown(0))
        {
            // Left click detected
            Collider2D clickedCol = Physics2D.OverlapPoint(Camera.Main.ScreenToWorldPoint(Input.mousePosition, clickMask));

            // Do some stuff
        }```
#

@sour trench

#
            public class PathTile
            {
                public TileController controller = null;
                /// <summary>
                /// Whether or not the tile is walkable.
                /// </summary>
                public bool isWalkable = true;
                /// <summary>
                /// Where in the grid the tile is located.
                /// </summary>
                public Vector2Int gridPos;
                /// <summary>
                /// The distance traversed to get to this tile.
                /// </summary>
                public float cost;
                /// <summary>
                /// An estimate of the distance to the destination.
                /// </summary>
                public float distance;
                /// <summary>
                /// Equals cost + distance.
                /// </summary>
                public float costDistance => cost + distance;
                /// <summary>
                /// The tile we came from to get here.
                /// </summary>
                public PathTile previousTile;
            }```
I have a list of type PathTile. How would I go about creating a list from the gridPos of each PathTile? Preferably with a lambda expression
sour trench
#

@rustic ember Just found what the issue is, there a freaking trigger collider over the crate that's stealing the clicks... And of course the one crate I've been trying this with is inside of it 😠

rustic ember
#

🤣 Well... I'm glad you found the issue

hollow stone
rustic ember
hollow stone
#

var newList = yourContainer.Select(x => x.gridPos);

rustic ember
wraith vector
#

When I add a button listener:

                    () =>
                    {
                        UnEquip(laser);
                        OpenLaser(oldItem);
                    });```
if the function "OpenLaser" has some static variable that has changed after adding the Listener.
When I press that button, will the function use the old static variable value or the new one?
#

if so, is there a way to make it use the new one?

steady moat
#

That given it is a non reference type such as int or float.

wraith vector
#

Ty for the info, I guess somewhere else in my code is changing the variable to the old value AUcry

#

Nvm, I guess I found what could be the issue

#

Always good to discuss the code lol
makes me rethink about the whole process

heady iris
#

the exact behavior of anonymous functions can be very surprising

#

for example

#
for (int i = 0; i < 10; ++i) {
  CallMeLater(() => Debug.Log(i));
}
#

they will all log "9"

#

because they all captured the same variable

#

this was very surprising to me

oblique badger
#

I need some help solving this annoying thing, basically I cant click any buttons on my UI, I'm not missing an event system nor am I lacking any components in my canvas

heady iris
#

If you create a button, can you click on it?

#

GameObject -> UI -> Button (Text Mesh Pro)

#

(i forget the exact name there)

oblique badger
#

Ah "button" is missing

heady iris
#

as in, your own button objects were missing the Button component?

oblique badger
#

Seems like there was an error in the packages?

#

Ah

#

That was dumb of me, Yes I can click on the button that I created

#

Inside the canvas and on the same gameobject as the other buttons seems I cant

heady iris
#

Show me the inspector for one of your own buttons.

oblique badger
heady iris
#

well that looks reasonable

#

What if you make that new button you made a sibling of one of the old buttons that's not working?

#

so, put it next to one of them in the hierarchy

#

Something might be blocking the click

oblique badger
#

I'm a pure dumbass thanks mate

steady moat
heady iris
#

yea

#

i just kinda figured they'd capture by value (which is the default for a c++ lambda, iirc)

dim spindle
heady iris
#

we all have dumb-of-ass moments :p

orchid bane
#

Does OnTriggerEnter work when rb .isKinematic?

knotty sun
#

no

#

isKinematic means 'without physics' and triggers/colliders work with physics

heady iris
#

eh?

#

they work fine

orchid bane
#

👀

heady iris
#

consult this table

#

Note that two kinematic rigidbodies will NOT cause collision events with each other

#

but two kinematic rigidbodies WILL cause trigger events

orchid bane
#

Cool

#

Thanks

#

Am I correct in that the table says that 2 kinematic rigidbody trigger colliders will trigger each other?

heady iris
#

Yep, that's what it says.

tame zealot
#

When an object is inactive and active again, can it detect collision?

heady iris
#

once the game object is set to be active, it will start participating in physics again, yes

#

I'm not sure exactly when that happens

tame zealot
#

so does it work with trigger enter? I've been trying to make it work but doesn't seem so.

static matrix
#

any tips on optimizing rendering?

orchid bane
heady iris
#

super broad question :p

static matrix
#

good one
sorry sometimes its just "Everyone knows how to do this but I don't because I missed whenever they were all told"

But ok ill look elsewhere

heady iris
#

it depends on whether it's a 2D/3D project

#

and on what render pipeline you're using

static matrix
#

3d project

orchid bane
#

I think part of the problem with googling something for Unity is that part of the info is outdated, written in incomprehensible words or not even discussed. Also docs are rarely helpful for more advanced topics

heady iris
#

yes

#

unity has a serious problem with documentation for its newer systems

static matrix
#

I don't think im using URP but I might have it on but not being used

orchid bane
#

Nice

hexed pecan
heady iris
#

you can check by looking at the project settings

knotty sun
tame zealot
#

Here's how I have it set up, they player holds E and after that the book that I place is Active and I have a collider near the book slot with a script when it collides with the book shows a debug.log :p

heady iris
static matrix
knotty sun
#

you should not need to check,

static matrix
#

yes, but in this scenario, as I had not yet checked, it is logical that to know what I am using and how to proceed, I do in fact, need to check

#

ive removed cinemachine and URP as I'm not using them

#

let me mess with more settings

heady iris
#

um

#

just removing the URP package would leave your project in a very interesting state

knotty sun
#

this is a recipe for disaster

static matrix
#

its still working

#

I never used it for anything

heady iris
#

let me rephrase this with another metaphor

#

if I removed the transmission from my car, there would be very adverse effects

#

i guess it could still roll down a hill

#

I'm actually not sure what happens if you just rip out the URP package

orchid bane
#

I believe Unity has a guide regarding how to switch to URP and back

heady iris
#

I've converted a project from HDRP to URP, and everything was...interesting in the middle of the process

static matrix
#

i mean i imported it from the package manager, never touched it, and then uninstalled it

heady iris
#

i guess it might be ok that way..

#

if the project was not created from the URP template

static matrix
#

which tier does the graphics use by default?

soft shard
heady iris
#

we had a few materials to update the shader on

#

and I had to go copy the URP assets from the template project

#

this was a game jam game, so everything was already kind of wonky, lol

#

The hard part was replacing some post-processing effects

#

had to figure out how to make render features, since we didn't have the version of URP with the handy full screen pass render feature

soft shard
#

Changing pipelines during a game jam sounds like a... Bold choice, but im glad it wasnt too bad and you didnt have any package errors or code that depended on the pipeline

heady iris
#

oh, this was after the jam

#

we realized that we were using zero HDRP features and that it was making the game run horribly

#

we were fixing it up for GDC (our university had a few teams from the game development department travel there)

#

i did have fun learning how to do custom render features during a solo jam recently, though :p

#

that ate a good 90 minutes

soft shard
#

Oh nice! Only 90 minutes 😉

heady iris
#

And a mild amount of swearing

ember ore
#

Is there any free outline shader we can use?
All i can find are either not working anymore... or are paid

tame zealot
#

Nvm i got it to work with a simple bool : p

lethal plank
ionic hawk
#

Can anybody help me with this error message? I tried to add an rewarded ad and I got stuck on it.

heady iris
#

well, it sounds like placementId isn't correct!

ionic hawk
#

`using UnityEngine;
using UnityEngine.Advertisements;

public class AdsInitializer : MonoBehaviour, IUnityAdsInitializationListener
{
[SerializeField] string _androidGameId;
[SerializeField] string _iOSGameId;
[SerializeField] bool _testMode = true;
private string _gameId;
[SerializeField] RewardedAdsButton rewardedAdsButton;

void Awake()
{
    InitializeAds();
}

public void InitializeAds()
{

#if UNITY_IOS
_gameId = _iOSGameId;
#elif UNITY_ANDROID
_gameId = _androidGameId;
#elif UNITY_EDITOR
_gameId = _androidGameId; //Only for testing the functionality in the Editor
#endif
if (!Advertisement.isInitialized && Advertisement.isSupported)
{
Advertisement.Initialize(_gameId, _testMode, this);
}
}

public void OnInitializationComplete()
{
    Debug.Log("Unity Ads initialization complete.");
    rewardedAdsButton.LoadAd();
}

public void OnInitializationFailed(UnityAdsInitializationError error, string message)
{
    Debug.Log($"Unity Ads Initialization Failed: {error.ToString()} - {message}");
}

}`
This is my script and only think that I added was rewardedAdsButton.LoadAd(); but its not green as other functions so why can that be?

ionic hawk
#

Android

knotty sun
#

so I guess _androidGameId is null or empty

ionic hawk
#

oh I am an idiot. I forgot to change the build platform

#

THANKS

hexed pecan
#

But if you mean the scope shadow/vignette and the reticle, then you need to make some shaders most likely

stone rock
#

Hello, what would be a good way to check where i am creating a float with NAN? I don't have any divisions that can cause a NAN but have no idea what else it can be that causes it

heady iris
#

you'll need to trace it back to the source

#

one possibility: Mathf.SmoothDamp with a timescale of zero

stone rock
#

I know the variable that get's a nan and the only thing it is using is

_slipZ = _slipZ + ((_localVelocity.z - _slipZ) * (Mathf.Abs(_localVelocity.z) / 0.01f * deltaTime));
hexed pecan
stone rock
#

i don't have a time scale of 0 though

hexed pecan
#

So youre dividing with 0.01f * 0

stone rock
#

but i will add my little check

hexed pecan
#

Maybe deltaTime is 0 at the start of the game. Not sure

heady iris
#

log everything that line uses

stone rock
#

i am going to check the localvelocity variable

#

but deltaTime should be correct

heady iris
#

"should be" is not a substitute for "is" (:

stone rock
#

This is what i do for that

            float deltaTime = Time.fixedDeltaTime;
            float deltaTimeInverted = 1.0f / deltaTime;
#

i pass it from another script to that

#

It's also strange since it only happens for 1 because i am doing it twice

            // SLIP Z

            //-> SlipZ = SlipZ + (SlipZMax - SlipZ) * (abs(_localVelocity.z) / relaxationLength * deltaTime)
            _slipZ = _slipZ + ((_localVelocity.z - _slipZ) * (MathExtensions.SafeDivide(Mathf.Abs(_localVelocity.z), 0.01f * deltaTime)));

            // SLIP X

            //-> SlipX = SlipX + (SlipXMax - SlipX) * (abs(_localVelocity.x) / relaxationLength * deltaTime)
            _slipX = _slipX + ((_localVelocity.x - _slipX) * (MathExtensions.SafeDivide(Mathf.Abs(_localVelocity.x), 0.01f * deltaTime)));
#

The X variable never has this issue

fathom patrol
#

I'm trying to store a certain vector and string before changing a scene, and then having the position of my player object be updated, however even through after the scene transition I can get the right variables out of storeTransform and storeDirection, they are not being updated.

Vector2 storeTransform = tp1PlayerTransform;
string storeDirection = tp1PlayerDirection;
animator.SetBool("isMoving", false);
SceneManager.LoadScene(teleporter1Location);
transform.position = new Vector3(storeTransform.x, storeTransform.y, 0);
playerDirection = storeDirection;
#

Is there something I'm missing?

heady iris
#

LoadScene immediately switches the scene and destroys everything from the old scene

#

You need to store that data in static fields and then retrieve it from a component that lives in the new scene

fathom patrol
#

I see, I'll try that

#

Though when adding something like print(storeTransform) after the LoadScene, it prints the correct result, why can't I update transform.position if my variables are apparently still there?

heady iris
#

oh, I see

#

it loads the scene in the next frame

#

so it will finish running the function

#

...but that will be affecting stuff in the old scene

gleaming sparrow
#

hi im having some trouble writing a car mesh deformation script. i want to be able to shoot balls at cars and those balls should dent the car. i want the vertex to dent in the same direction as the ball's velocity. i currently have this code: im doing something wrong but i cant find out what. anyone any ideas?

if (distanceFromCollision < deformRadius && distanceFromOriginal < maxDeformDistance)
                    {
                        float distribution = ((deformRadius - distanceFromCollision) / deformRadius) * damageDistribution;

                        Vector3 deform = transform.TransformPoint(vertexPosition);

                        if (collision.rigidbody) deform += collision.rigidbody.velocity.normalized * distribution;
                        else deform += -transform.root.GetComponent<Rigidbody>().velocity.normalized * distribution;

                        Vector3.ClampMagnitude(deform, distanceFromOriginal - maxDeformDistance);

                        verts[i] = addedDamage * damageMultiplier * transform.InverseTransformPoint(deform);
                    }
heady iris
#

what is it doing wrong?

gleaming sparrow
#

easier to read

heady iris
#

I'm guessing the deformation is in the wrong direction

fathom patrol
gleaming sparrow
#

yeah at first it kept pointing the deformation towards the parent origin position

heady iris
#

what is vertexPosition ?

gleaming sparrow
#

its the position of the specific vertex im currently looking at (this is in a for loop foreach vertex)

#

vertex position is given in local space

heady iris
#

so you convert that to world space

gray vessel
heady iris
#

ah, I see the inverse transform at the end

#

I would start by applying a constant deformation

#

like, just Vector3.right

gleaming sparrow
#

yeah i tried to temporarily take it out of localposition

heady iris
#

see if it behaves as expected

gleaming sparrow
#

aight ill give it a try

#

both Vector3.right and up, and transform.right and up seem to point the same direction

#

i think something is off with the (inverse)TransformPoint

dense canyon
#

Im having trouble with web requests, here the only log that gets to the console is the first 'Hello', how can I fix this?

glossy basin
hexed pecan
spare badge
#

How can I detect unclamped mouse movement magnitude while the cursor is locked?

spare badge
#

Either. I'm currently using the old input system for testing, but intend to upgrade to the new one once I've finished experimenting. For now, just the old one.

hexed pecan
#

Input.GetAxisRaw("Mouse Y") etc should work even when your cursor is locked

spare badge
#

But doesn't that clamp the value between -1 and 1?

hexed pecan
#

Is it the Raw part? GetAxis and GetAxisRaw should work the same with mouse input

spare badge
#

You're right. I'm sorry, I must have been confusing it with joystick controls for some reason.

gleaming sparrow
#

when i collide with an object, will the colliding object's velocity still be the same in OnCollisionEnter or will the velocity be already be changed because of being stopped by the collision

#

like is the change in velocity in the other object handled before or after OnCollisionEnter

hexed pecan
#

collision.relativeVelocity exists btw, if thats useful for you

gleaming sparrow
#

hm yeah i finally see what u mean

gleaming sparrow
#

thx, i think this works

radiant marten
#

can someone help me understand the rect parameter for Sprite.Create(texture,rect)? Assuming I'm trying to create a sprite at sprite 3, I use Rect(32,16,16,16) yet it looks like it's drawing sprite 7 instead.

#

the manual's description kind of confuses me as well

#

The rect argument is defined in pixels of the texture. A Rect(50.0f, 10.0f, 200.0f, 140.0f) would create a left to right range from 50.0f to 50.0f + 200.0f = 250.0f. The bottom to top range would be 10.0f to 10.0f + 140.0f = 150.0f.

heady iris
#

Rect specifies the corner and the size

#

can you link me to the docs for that?

heady iris
#

the rect sounds reasonable

#

what happens if you do Rect(32, 0, 16, 16) instead?

#

oh right

#

the Rect is specified by the top left corner

#

it should really say "the top to bottom range" to make it more obvious

heady iris
radiant marten
#

new Rect(32,16,16,16);

#

new Rect(32,0,16,16);

heady iris
#

wait, I thought you said that this produced a 7

#

ah

#

right, the origin is in the bottom-left for sprites, then

radiant marten
#

yes, but when I tried texture.height - sy I was getting out of bounds errors

heady iris
heady iris
radiant marten
heady iris
#

i love coordinate spaces

candid forge
#

ok, quick question about OnMouseDown. i Have a script Tile, which holds a 2d square box gameObject amongst a bunch of other things, this gameObject has a component which has a OnMouseDown function. I want to call a function from the Tile script which holds the current gameObject and the component it's attached to. How could i do that?

radiant marten
#

thanks a bunch!

heady iris
#

no prob

heady iris
#

The object needs to get a reference to the tile

#

The Tile could tell the object about itself during setup

candid forge
#

makes a lot of sense, i will try it

#

it works, thank you

scenic hinge
candid forge
#

the gameobject is attached to a script, and the gameobject has no reference to the script it's attached to

scenic hinge
#

this gives a reference to “this” component

#

And gameObject gives you a reference to its parent gameObject

#

If your goal is to call a command from another script on click using that class

#

You can add [SerializeField] to the field “parent” on script “OnClick” and drag and drop it in the inspector

#

if you want to create links between scripts that’s the way you do it

heady iris
#

define "Attached"

#

Do you mean that the component (that's defined by that script) has a field of type GameObject?

scenic hinge
#

I think he is suggesting his GameObject has 2 scripts attached “Tile” and “OnClick”

candid forge
#

no

heady iris
thin aurora
scenic hinge
#

I think he’s got it anyways

thin aurora
#

Hence "possibly". I understand it's part of the same game object

candid forge
#

i modified it a bit

scenic hinge
#

I thought he was trying to do something else

candid forge
#

i want to dinamically do things instead of using the editor

scenic hinge
#

Why?

thin aurora
# candid forge

Advice against this. Don't expose a public field or a property with a public setter.

#

You're literally using AddComponent here, why not GetComponent?

scenic hinge
#

Why use Unity if you don’t want to use the editor

candid forge
#

yeah, for now i'm just testing to see if my logic works

candid forge
thin aurora
#

You're literally using AddComponent here, why not GetComponent in the OnClick?

#

The whole point is getting to the Tile

#

It's part of the same Gameobject

#

GetComponent is the answer

candid forge
#

it's not

#

Tile is not a component of anything

scenic hinge
static matrix
#

can I make navmeshes at runtime? Like for a procedurally generated level?

heady iris
#

Tile is just a blob of data.

#

It is not a Component.

thin aurora
#

#archived-code-general message

i Have a script Tile, which holds a 2d square box gameObject amongst a bunch of other things, this gameObject has a component which has a OnMouseDown function. I want to call a function from the Tile script which holds the current gameObject and the component it's attached to.

heady iris
#

I think the confusion is because "script" usually means "monobehaviour"

fluid swan
#

Does anyone know how to make an ai chase you but don’t go through walls

thin aurora
scenic hinge
#

I don’t think there is any confusion, I think this is just a weird way to create a literal 1 line solution

heady iris
scenic hinge
thin aurora
#

Where is Tile referenced though

fluid swan
static matrix
#

yeah its navemeshes, can I do navmeshes at runtime

candid forge
# thin aurora Then what is Tile?

it's because i use a List of tiles and i want to be sure whatever is in that list is Tile instead of a GameObject, which could be anything

scenic hinge
static matrix
#

k

heady iris
#

sounds pretty reasonable

scenic hinge
#

He’s trying to avoid using the editor

heady iris
#

not everything has to directly exist in the scene as a component

candid forge
scenic hinge
#

But why tho

heady iris
candid forge
#

because i want to code

heady iris
#

I like to make as much as possible automatic

#

I do not enjoy dragging stuff around in the editor if it could be easily made automatic

candid forge
#

yeah, i'm making it automatic, through code

scenic hinge
#

Then make it automatic, in the editor, it makes testing very easy

#

They are tools provided for a reason

candid forge
#

i am also new to unity and very used to only using code and still trying to wrap my head around the editor and stuff

candid forge
scenic hinge
#

Again, you could’ve solved this with literally one line of code if you did it through Unity, or you could’ve used Unity’s built in tile solution

heady iris
#

what is the "one line of code"?

#

i am not following you

candid forge
#

my tiles are not related

heady iris
#

i'm guessing this is something like chunks of a level?

scenic hinge
#

Add mono behavior to tile, add it to the object that you are “OnMouseDown” and literally you can do `OnMouseDown() => GetComponent<Tile>().WakeUp()

candid forge
#

yes, 10x10 chunks and i want to load and unload them easily, each square(tile) can be clicked to do something

#

if i have simple data types unlike gameobjects which i can create and delete on a whim my life is easier

#

thank you tho, idk how innefficient or efficient this is, but i'm not making a performance intensive game anyways

heady iris
#

I think it is reasonable. Perhaps the Tiles could get turned into components that exist in the world, but I don't see a life-or-death reason to do that right here (without more context, at least)

static matrix
#

do I need to download all the navmesh components or are they built into unity now?

heady iris
#

there is navmesh stuff built in

#

but you should install the AI Navigation package

#

it introduces navmeshsurface components and other new stuff

static matrix
#

oki

#

thats not built into the registry right

heady iris
static matrix
#

I didnt see it, but I probably did something wrong

heady iris
#

Ah, it might not be out of experimental for your version of unity

#

I see this in 2022.2.x

static matrix
#

oh lol

#

im in 2021

heady iris
#

you should be able to install com.unity.ai.navigation by name

static matrix
#

nice

#

how

#

I dont mess around much with packages

#

Ill just download it off github

heady iris
#

i would suggest doing it through the package manager

#

does 2021 not have the "install by name" option?

static matrix
#

let me check

heady iris
static matrix
#

ah

#

ok

#

one mo

potent sleet
#

that's old

#

use the one from package manager

potent sleet
open lake
#

Hey I have a camera which is rendering to a render texture and this render texture is assigned to a raw image, so essentially, camera output is going to a raw image. Problem is, this raw image can change its width and height on the screen. So when the raw image width is increase, it looks distorted and stretched. How do I fix this so that we can dynamically have this system working

hexed pecan
open lake
#

The Raw Image has stretched anchor presets but also theres offsets that offset it from each side, so when the game window is resized, the RawImage also changes

open lake
#

Looked into this already, turns out this doesnt work

#

altering W and H values seemed to work but I don't know what these W and H values are and how to calculate them w.r.t. an aspect ratio

hexed pecan
#

w.r.t.
?

open lake
#

with respect to*

#

my bad

hexed pecan
#

I usually figure out abbreviations but that one was tricky lol

#

Aspect ratio is just width/height

open lake
static matrix
hexed pecan
open lake
#

if W = 1.6 and H = 0.9 that would've made sense since thats my screen's aspect ratio

static matrix
#

com.unity.ai.navigation @potent sleet

heady iris
#

oh wait

#

was it not even available until 2022?

static matrix
#

maybe

heady iris
#

no, it was available back in 2019.4...

static matrix
#

odd

#

idk why it isnt showing up

heady iris
#

it ought to just be com.unity.ai.navigation

static matrix
#

let me look it up, maybe it changed names

#

ohhh It might have logged me out

#

let me log in again

#

worked now

#

thx

#

just had to read the error code lol

#

hmmm ive imported it but visual studio doesn't recognize it

heady iris
#

you may need to regenerate project files

#

preferences > external tools

static matrix
#

kk

#

you are the best!

#

let me close and re-open the project

#

still can't find it...

unborn flame
#

i dont understand why tolist has a error im using linq?

simple egret
#

What does the error say?

#

Nevermind lol

#

GetComponentInChildren returns one object

#

You need the version that returns multiple, GetComponentsInChildren

#

(notice the "s" to "components")

unborn flame
#

OH

#

thanks i would have been sitting here for hours looking for that

static matrix
#

I just had the import wrong nvm

ionic socket
#

is there a way to make a variable only accessible to select outside classes? IE, I have a GameAction class that I want to use to encapsulate gamestate changes (along with undo information), but the gamestate itself I want to store within my GameManager class. Is there a way to enforce this?

leaden ice
ionic socket
leaden ice
#

probably not

heady iris
#

an error that says "I can't use type X as type Y" should be a signal that you are misusing something

hearty sphinx
#

today i learned c# isn't the only language that unity supports for scripting

#

i wonder why i don't see the others often

#

or at all

leaden ice
#

C# is the only language Unity supports

#

since ~2017

weary marlin
#

how do i properly plug build of an external dll into the unity editor pipeline, so that it runs dotnet build and copies the output files into the Assets directory? the solution is in the same repository but outside of the unity project directory

i currently have a build target in the dll project, but ideally since its a dependency, it wouldnt know about unity and unity should handle the import.

i tried researching asset preprocessors, [InitializeOnLoadMethod] attribute and IPreprocessBuild but none of that seem to work like i want them to

hearty sphinx
leaden ice
#

yes

hearty sphinx
#

i see, thanks

heady iris
#

you used to be able to use JS

#

terrifying

knotty sun
knotty sun
heady iris
#

oh wait, isn't that just how to compile to WASM

knotty sun
#

nope

lament bloom
#

im still kind of confused about how to use different colliders on the same object for different purposes

heady iris
#

i'd just put them on their own game objects

lament bloom
#

and then for scripting purposes

leaden ice
lament bloom
#

you would just have a different script/component for each collider's object?

heady iris
#

I'm not aware of a way to differentiate between them, unless they collide with mutually exclusive sets of layers

lament bloom
#

okay maybe im approaching this wrong

heady iris
#

what do you want to do?

lament bloom
#

I have an enemy npc who I want to give a large sphere collider that determines whether they "see" the player, as a result they should draw their weapons

#

but I also want them to have a smaller capsule collider, which actually determines where they can be hit by a weapon

#

is there a better way to do this?

leaden ice
lament bloom
#

Hmm, okay

#

It's a little unfortunate I feel that this needs its own script since but it's not that inconvenient

leaden ice
#

i mean depending on what's going on if there's no other trigger interactions happening with the enemy you don't necessarily need a separate script

#

as the parent object (if it has a Rigidbody) will receive the OnTriggerEnter from a child collider

ashen yoke
#

and in general for queries

lament bloom
#

oh interesting

ashen yoke
#

its a single player?

lament bloom
#

for now yeah, if it were multi/network would this be unreasonable?

ashen yoke
#

if its single/low amount of players you can get away with just checking distance

oblique kraken
#

can anyone help me with this ?

west lotus
#

Error says how to fix it

oblique kraken
#

but I can't find "settings"

lament bloom
#

Project Settings ...

west lotus
#

Project settings

oblique kraken
#

sorry I feel dumb, but I can't find it

lament bloom
lament bloom
ashen yoke
#

until you have 500+ enemies on the map this wont matter

lament bloom
#

👍

ashen yoke
#

nonalloc version of physics queries is as fast as it gets from unity api

#

more performant solutions would require you to write custom code

#

tho a distance check would outdo all of those

ashen yoke
#

use fixed or custom ticker

heady iris
#

yeah -- for example, I have my enemies check once every second or so

ashen yoke
#

30-15 times a second is fine

proper pier
#

Hey, if I want to simulate a taught rope in unity, can I just apply a force towards a fixed point?

odd pecan
#

Any tips on how to export a mesh as an fbx file in a standalone application? I know there is a package called FBX Exporter but from what I understand I can't use it in a standalone application.

leaden ice
odd pecan
#

yeah

leaden ice
#

I don't think Unity has support for that in any form

#

you'd have to find some open source library for it or something

unborn comet
#

Hello, I really need help. I want to create a Crypto Trading Simulation Game just do not know how I should do it every ten seconds or so the share money amounts adjust and the wallet also adapts to it. I would be happy if I could get help as I found nothing that could help me.

odd pecan
#

unlucky. Right now I'm trying to export it as an .obj

heady iris
unborn comet
#

i ned help how i make it withe the wallet

hollow stone
unborn comet
#

ok

cinder monolith
#

which is better visual studio code or visual studio community

heady iris
#

Visual Studio is the name of the software

#

community is just a kind (that's free)

cinder monolith
#

oh

heady iris
#

unity officially supports Visual Studio, so I would go with that

cinder monolith
#

well visual studio code is also free

#

ook

heady iris
#

yeah

#

I use Code myself

#

since I already use it for many other things

#

but it's not officially supported

stone crypt
#

I think I am missing something basic. I have a game where I have an update loop. I want to put up a screen where the player has to interact and then continue the update loop. I have changed the Time.timeScale to 0, but the update loop continues without pause. Should I just kick off another program as a singleton and ignore the update loop? What is the right way to handle this in a 2D game that is screen heavy? Avoid the update loop?

heady iris
#

Update gets called all the time

#

once per frame

#

you cannot stop Update without freezing the game

stone crypt
#

I got that - what I wanted to know is how you handle screen input with the Update loop. I have tried a few options, but I was not sure about it.

heady iris
#

So you want the game to pause while you're messing with an interface

stone crypt
#

I was thinking that the best option would be to ditch the Update loop and write my own loop.

heady iris
#

setting the timeScale to 0 is, indeed, the way to do this

#

what is the problem?

stone crypt
#

If you have multiple screens that you are using at different time points controlled by the update loop, they all stomp on each other?

heady iris
#

I don't understand. Why not just disable all but one of the screens?

stone crypt
#

Might just be my design - I used the UIKit - built multiple panels for one section of my screen and then wanted to switch between them in sequence.

#

I have to capture user input on each one.

ancient summit
#
        if (!SimulationManager.UsingLumin())
        {
            TextAsset t_defaultSave = Resources.Load<TextAsset>("Default");
//Line 86   Debug.Log(t_defaultSave.text);
            LayoutData t_layoutData = JsonUtility.FromJson<LayoutData>(t_defaultSave.text);
            string t_saveText = t_layoutData.saveText;

            CreateObjectsFromSave(t_saveText);
        }

I don't understand why this is giving me an error.. all of the solutions online are telling me this is how i should be loading a json from resources but it always comes back as null. It is spelt correctly as you can see, and the file extension is .json

distant thicket
#

Hello everyone. Experiencing some strange behavior in Unity and was curious if anyone had any knowledge of unity changing things in regards to where gameobjects are loaded when instantiated in OnEnable.

I have the following test

        [UnityTest]
        public IEnumerator LoadSceneAsync_Leaves_GameObject_in_Old_Scene() => UniTask.ToCoroutine(async () =>
        {
            // Arrange
            var initialSceneName = "Test Scene";
            var initialScene = SceneManager.CreateScene(initialSceneName);
            await UniTask.WaitUntil(() => SceneManager.SetActiveScene(initialScene));
            
            // Act
            await EditorSceneManager.LoadSceneAsyncInPlayMode(
                GetPathToTestDataAsset($"Scenes/{SafeLoadSceneAsyncTestSceneName}.unity"),
                new LoadSceneParameters(LoadSceneMode.Additive));
            var gameObjectCallbackCreator = Object.FindObjectOfType<GameObjectFromUnityCallbackCreator>();

            // Assert
            Assert.AreEqual(gameObjectCallbackCreator.OnEnableGameObject.scene.name,initialSceneName);
        });

And the following script

    /// <summary>
    /// Creates a gameobject when a unity callback is fired and a appropriate flags are set
    /// </summary>
    public class GameObjectFromUnityCallbackCreator : MonoBehaviour
    {
        public bool createGameObjectInOnEnable = true;
        
        public void OnEnable()
        {
            if (!createGameObjectInOnEnable)
            {
                return;
            }
            OnEnableGameObject = new GameObject("OnEnable GameObject ");
        }

        public GameObject OnEnableGameObject { get; private set; }
    }

When I Updated from Unity 2020.3.12 to 2020.3.46 my test now fails alluding to the fact that instantiated gameobjects in OnEnable no longer respect scene active state 🤔.

Anyone happen to know if this is a bug or intended change on Unity end?

mystic lagoon
#

i made gaem

leaden ice
#

A bit unclear from your code exactly what you're doing or trying to test here.

distant thicket
#

Sorry, I'll clarify more because in 2020.3.46 I'm seeing that this is not the case.

Essentially I do the following in order

  1. Create a test scene
  2. Mark it as active.
  3. Load a scene additively, where an object inside the addtive loaded scene creates a gameobject in it's OnEnable method.

The gameobject created in the additive loaded scenes OnEnable method I expect to be in the test scene marked as active. However after my update it is loaded in the additive scene itself.

#

In 2020.3.12 of Unity I am seeing the intended behavior where the gameobject is loaded in the active scene

leaden ice
#
SceneManager.GetActiveScene()```
#

then you could confirm if it's a problem of the object spawning in a scene which is not active, or a matter of the active scene changing when you don't expect it to

distant thicket
#

Yup, that's what makes it strange

#

Check it out

#

The correct scene is marked as active, however the gameobject is instantiated in the scene that it is being loaded with

leaden ice
#

I think an interesting test @distant thicket would be if you throw an Instantiate call in there too

#

will the instantiated copy go in the active scene or not?

#

It could also be a bug

#

Including potentially a bug with EditorSceneManager.LoadSceneAsyncInPlayMode in particular

distant thicket
#

yeah I was thinking that myself 🤔 . Although it does look pretty clear cut to me from the documentation what should occur though

#

Which is why it's so strange to me haha

#

But I really apprecaite your help!

leaden ice
#

Right that's a bit unclear because it could mean any form of instantiation, or it could just mean Instantiate

distant thicket
#

Ah I see what you mean

#

that's a interesting thought though and one I was also thinking about

leaden ice
#

which is also why I was curious about if you call Instantiate

#

whether it also has the same issue

distant thicket
#

gonna see if instantiate yields the same results

#

hah great minds

#

I'll report back

#

Yup looks like both new GameObject("") and Instantiate(...) are borked

pseudo zodiac
#

Hello,
I'm asking my question here because I'm not sure where to ask it.
It's a question about design.
I am currently making a 2d RPG and I am implementing a quest system.
The problem I have is that my game has several scenes and each quest is different from the others (really different), and depending on the active quest(s), I have to change and edit my scene in the right way (with the right pnj) according to the quest. And I don't really see how to design the thing. I have already made a "Quest" class that includes the basics such as progress status etc for the UI. I also made a QuestManager (with dontDestroyOnLoad), but I have a problem. I don't know how to design my class the right way so that when I load a certain scene it changes depending on the active quests. I don't know how to store my quests, a ScriptableObject doesn't seem to be suitable since each quest has different loading functions, prefabs maybe? If someone could enlighten me, give me an hint...
I am a beginner on Unity.
Thanks in advance.

distant thicket
#

There are really several ways you could approach your quest issue. Actually utilizing scriptable objects is not a bad way to do necessarily as that would give you the ability to define static data for each quest. For example quest title, quest image, quest experience and so on in the unity editor. You can then add those quest so's to your quest manager and maybe have an ActiveQuest property exposed in your manager to determine which quest is active.

#

I'm really going very broad here haha, it's very hard to give a breakdown of a good architecture on discord, but hopefully that maybe gets you oriented a little

#

You could also just make quest a standard class if you have some sort of a backend defining your quests

molten thicket
#

Hey guys,

Brace yourselves; I have a WebRequest question:

How would you pass a user flag for an API using a UnityWebRequest?

I can set headers, but the user flag is something I've never dealt with in Unity, and can't find any helpful resources about it.

heady iris
#

doesn't that just translate into an ordinary header?

potent sleet
distant thicket
#

@molten thicket could you not send it embedded in the url via ?userFlag=flag

pseudo zodiac
heady iris
#

Authorization: Basic Zm9vOkJhcg==

#

that's what I got when I did curl -u foo:bar localhost:8001

#

you just base64 encode the username:password string

pseudo zodiac
molten thicket
heady iris
#

the server is expecting you to send an Authorization: header

potent sleet
molten thicket
pseudo zodiac
# potent sleet quest manager should deal with this no ?

Yes but how do I store the Quest knowing that it may need to instanciate certain GameObject for example ? Using ScriptableObject wont let me add custom code or attach GameObject to it and I cant make it a "Scene Object" because It must be scene-agnostic since Player may need to enter a shop and exit to talk to a PNJ

heady iris
#

Yes, but you need to base64 encode the APIKey + ":" + APISecret part

molten thicket
#

Noted @heady iris

I'll play around with it - Big thank you

potent sleet
#

then you make different implementations of it

#
public class DeliverItemQuest : Quest {
    public DeliverItemQuest(string name, int id) : base(name, id) {
        // Constructor implementation
    }

    public override void StartQuest() {
        // quest according to "delivering item"
    }```
#

etc

#
public abstract class Quest {
    public string questName;
    public int questId;
// all your other stuff you need or watever

    public Quest(string name, int id) {
        questName = name;
        questId = id;
    }

    public abstract void StartQuest();```
pseudo zodiac
#

@potent sleet Okay, and for example I add an abstact void OnLoadScene(string sceneName) and based on the sceneName I load my GameObjects into it?

#

Should I hard code a reference to the GameObject ?

#

And should I store all my Quest in a List in the QuestManager?

molten thicket
#

@heady iris Got it working!

Thank you again - Learnt something new today 😄

potent sleet
#
public override void OnLoadScene(Scene scene) {
        if (scene.name == "Level1") {
            // Load game objects for level 1
        } else if (scene.name == "Level2") {
            // Load game objects for level 2
        }```
 just a very rough example prob not ideal / optimized
pseudo zodiac
potent sleet
pseudo zodiac
#

@potent sleet So for example I could have an « QuestSetup » classes Inherited with ScriptableObject with inside a List of GameObject and I create one for each quest so I can use the one I want when calling onLoadScene ?

mellow seal
#

Hey guys can you help me please

    IEnumerator SurroundPlayer()
    {
        while (true)
        {
            for (int i = 0; i < ChasingEnemys.Count; i++) //Follow player until SurroundRadius
            {
                if ((ChasingEnemys[i].transform.position - Player.transform.position).magnitude > ChaseRange + 1.5f)
                {
                    ChasingEnemys[i].SetDestination(Player.transform.position);
                }
                else //Surround player
                {
                    ChasingEnemys[i].SetDestination(new Vector3(
                        Player.position.x + SurroundRadius * Mathf.Cos(2 * Mathf.PI * i / ChasingEnemys.Count),
                        Player.position.y,
                        Player.position.z + SurroundRadius * Mathf.Sin(2 * Mathf.PI * i / ChasingEnemys.Count)
                        ));
                }
                yield return new WaitForSecondsRealtime(Random.Range(1f, 5f));
            }
            yield return null;
        }
    }

I want to add delay inside for loop but it doesnt work

heady iris
#

in what does it "not work"?

mellow seal
#

They are not waiting and setting destination immediately

mellow seal
#

and i checked my calling courutine method and yes problem was there thanks

heady iris
#

ah, that would do it :p

#

i was going to say, this looks fine

mellow seal
#

you helped a lot actually was trying to find what is wrong 1 hours
thanks 😄

heady iris
#

at some point, you have to step back and start poking at other parts of your code :p

potent sleet
pseudo zodiac
cosmic ermine
#

is there a version of ApplyAndDisposeWritableMeshData that doesn't dispose of the mesh data?

proper pier
#

will a spring joint with 0f as spring value and a fixed max distance act as a taught rope?

harsh pasture
#

Has anyone using Unity 2020 LTS encountered a bug where they couldn't start coroutines?
Unity is throwing an argument exception on this line with the message "Coroutines can only be stopped [sic] on a MonoBehaviour"
StartCoroutine(PlayCutScene());
The class absolutely derives from MonoBehaviour. Any idea what could be going wrong?

cosmic rain
harsh pasture
#

I fixed it. It was really weird, definitely a bug in unity.
I fixed it by duplicating the object, deleting the original, and then using the duplicated version. 🤷‍♂️

distant thicket
#

I know you might not have cared, but I felt like I owed you a conclusion lol

red scarab
#

Hey guys, I have two code snippets -- the first adds a ChildClass to the children list, while the 2nd creates a ChildClass and the child adds itself to the ParentClass's list ... My question is: Should I avoid the circular dependencies introduced by the 2nd example? I'm in a situation where it would be really convenient... I just don't know if circular dependencies should be avoided?

public class ChildClass
{
    public ChildClass() {}
}
public class ParentClass
{
    List<ChildClass> children = new List<ChildClass>();

    ParentClass()
    {
        children.Add(new ChildClass());
    }
}
public class ChildClass
{
    public ChildClass(ParentClass _parent) 
    {
        _parent.children.Add(this);
    }
}

public class ParentClass
{
    public List<ChildClass> children = new List<ChildClass>();

    ParentClass()
    {
        new ChildClass(this);
    }
}
leaden ice
tawny elkBOT
#
Posting code

📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

leaden ice
potent sleet
#

Circular dependencies can make your code harder to understand and maintain no ?

dusk apex
#

If so, be sure to null out references on removal of elements to not have dangling references.

red scarab
#

It's not MEANT to be bidirectional, and I really avoided circular references as long as I could ... but I'm against a networking race-condition where it's REALLY tempting to pass the "parent" to the "child"

dusk apex
#

Approaching the subject as though it were a linked-list - top down tree/hierarchy etc.

potent sleet
red scarab
potent sleet
#

I'm no pro coder but I can assume interfaces or abstract classes would help minimize this ?

leaden ice
#

Again without actual context for why you want it, hard to say

dusk apex
#

I'd have a manager/lookup-tree/map of the entire tree and give those branches only a single direction of reference - a reference to it's children.
Best if the data isn't too deep else having a bi-directional "node" would be useful if you're just wanting to traverse the tree (especially in reverse) ect - be prepared for increased complexity.

mellow sail
#

Hi, I have just started on an aircraft marshalling simulator game and i am stuck in making the aircraft move with respective to the air marshaller wand does anyone know how to get started for eg.Player moves wand left aircraft turns left

leaden ice
#

I'd this like a VR game or something?

mellow sail
#

yea its a vr game

leaden ice
#

You'd need to do some kind of gesture recognition

#

Which is a bit complicated

mellow sail
#

but im stuck at finding a way for the gesture to move the aircraft

leaden ice
#

That's the easy part

mellow sail
leaden ice
#

The hard part is recognizing the gesture

mellow sail
#

yea

leaden ice
#

No idea it's something to start researching

mellow sail
#

would getaxis work?

leaden ice
#

...

mellow sail
#

or using Vector3

leaden ice
#

You're at the start of a very long journey if you're asking that

mellow sail
#

💀

mellow sail
leaden ice
#

Might I suggest trying something simpler?

mellow sail
#

yup sure

red scarab
# leaden ice Again without actual context for why you want it, hard to say

Specifically, I have some class which exists as some generic object:

class ConstructableElement {}

...which is currently a pretty dumb class. But, it's a networked object. So if the Server spawns it, it gets spawned on all Clients.

Now, each client needs to know about the ConstructableElements -- because if we want to make a new element, we need to check if an element already exists. this needs to occur on the client-side so the server isn't the one always checking if elements already exist at locations.

class ElementManipulator {
    SyncList<ConstructableElement> existingElements = new SyncList<ConstructableElement>();
    //...
}

...and that's where the race condition emerges. The SyncList (from the Mirror library) can't de-serialize the ConstructableElements in time so there's a race condition at Start(). So, instead of Synchronizing through a SyncList, I was thinking just let the elements add themselves:

class ConstructableElement {
    ElementManipulator elementManipulator;

    Awake() {
        elementManipulator.existingElements.Add(this);
    }
}

...which would mean that the ConstructableElement needs to know about the ElementManipulator, thus the circular references.

mellow sail
#

what would be easier to code

void basalt
#

@mellow sailFor gesture recognition, you'll likely be storing movement positions and running some sort of algorithm on them

mellow sail
void basalt
#

I wouldn't know

fervent furnace
#

Machine learning
I guest opencv has library for it

mellow sail
#

ooo i see thanks for the help

mellow sail
void basalt
#

Machine learning is an extremely advanced topic

#

just gonna throw that out there

mellow sail
#

hahahhahahhaha o shit

void basalt
#

Writing your own gesture recognition on top of that is even more complex.

mellow sail
#

the projects due in 3 months time

mellow sail
#

is there any simpler way to do it

void basalt
#

I mean

#

you could record yourself doing the gesture, store the positions of your headset or controller or whatever

#

and create a "template" for the behavior

#

again, I have no experience in the VR field.

mellow sail
#

pretty much im trying to do something like this

void basalt
#

I mean

#

it's going to take a lot of work

#

this isn't some one and done thing

mellow sail
#

yup

#

the project im doing has 3 people

#

working on it

void basalt
#

So basically you need to record yourself doing the movements, store them somewhere, and then find a way to compare your current movements to them

#

I guess we're getting into machine learning territory

mellow sail
#

yup

#

haahhahahhaha

#

im so screwed

#

alright thx for the help bro appreciate it

void basalt
#

@mellow sailTry this as a start. You'll need to record the positions of your controller, but only on a fixed basis. So like 30 times per second or something.
When you plot the positions, only save the deltas. So you'll only save the difference between x,y,z between each fixed tick.

#

When you want to run a command, make it so your user clicks a button on his hand controller, and then start recording

#

With the right search algorithm, you should be able to make something that works pretty decent.

mellow sail
#

thx for the headstart my dude

modest nova
#

can anyone tell me why I could be getting a null reference at
PhysicsWorldSingleton physicsWorldSingleton = SystemAPI.GetSingleton<PhysicsWorldSingleton>();

plucky karma
modest nova
#

oh its fixed, I was calling a method in ISystem through a monobehaviour

plucky karma
#

IService would sound better 😉

ionic socket
#

I'm having a big problem with Overthinking my game architecture and I could use some "just do X" talk. I'm making a 2-player strategy card game where players draw from a common deck. I want to use the command pattern to implement most card effects (which may be things like Draw a card, Score a point, Place a marker, etc). My problem is in the line between creating a command, and changing the gamestate. The first thing that happens in the game is that the players get dealt cards. Each player gets 5 cards, so I loop through and create a series of "Draw A Card" commands that get added to the stack of executed commands. Here's the question: Should the command modify the gamestate directly, or should it call a method on the GameManager that does the change? Anyways... I want a simpler way to do this that replicates the method that a pro-indie might use for a real game.

plucky karma
# ionic socket I'm having a big problem with Overthinking my game architecture and I could use ...

Does your game have any rules that it must obey? Create the rules and use it to shape your game out of. You can then implement appropriate functions in area that can be invoked by, or access to. Implement a ICard trait that basically invokes potential behaviour pattern. E.g. void OnStartPhase(GameStateArg args);

Then each of your card class would implement behaviour at the time of the phase. If the card needs to interface with the rules, or do other desire effects, you'd modify the argument class reference, which then process at the GameState level state. E.g. Invoke any pending action before I invoke next rules... And so forth.

#

Implement immutable, and complete behavior first. Then you can consider adding variations later.

ionic socket
plucky karma
#

GameManager would hold responsible for instruction player's turn. It can be reference via GameStateArg's parameters. In this case, it would also be responsible to know who drew the card.

modest nova
plucky karma
#

It shouldn't have to be!

modest nova
#

now im just stuck at the next step XD

plucky karma
#

Oof...

modest nova
sonic zinc
#

how do I rotate the bullets to align with the gun

potent sleet
somber nacelle
#

presumably you are using Instantiate to spawn them, you can pass the gun's rotation to Instantiate as the rotation parameter

sonic zinc
#

I was doing that but they were flying perfectly sideways

fallen lotus
#

how do I make a variable in a script show up as a dropdown menu in the inspector such as this exmaple:

somber nacelle
#

it's an enum

fallen lotus
#

would you mind giving me an example

#

with just like two options

fallen lotus
sonic zinc
#
            firedBullet.transform.localEulerAngles = new Vector3(firedBullet.transform.localEulerAngles.x, firedBullet.transform.localEulerAngles.y + 90, firedBullet.transform.localEulerAngles.z);
            Vector3 directionTravelling = (hit.point - firePoint.transform.position).normalized;
            firedBullet.GetComponent<Rigidbody>().velocity = directionTravelling * bulletSpeed;```
This is my current shoot script
somber nacelle
fallen lotus
somber nacelle
#

so you create your enum with the different options, then you create a variable of that enum type

#

there's nothing special you need to do after that

fallen lotus
#

is the enum delcared outside the monobehavcior class or inside?

somber nacelle
#

depends on where you need it

fallen lotus
#

im referencing the variable inside the monobehavior class

rain minnow
sonic zinc
#

I have one called firepoint but its rotation is all at 0

somber nacelle
#

make sure the correct axis is pointing directly away from the barrel

#

which axis is the correct one depends on which axis the bullet points along at 0 rotation

sonic zinc
#

IT WORKS THANK YOU

#

I just had to rotate the empty by 90 degrees

#

I thought I needed some insane math equation

candid trench
#

Ok, im having an abnormal ammount of difficulty figuring this out.

Im creating a sort of RTS.
Each unit can have spells.
Now i want to define these spells somehow.
After having googled for 3 hours im still no smarter than when i started.
I tried using ScriptableObjects, but that just leads to all units sharing the same "cooldowns" and stuff.
Anyone got any clever idea of how to implement a spellsystem without me having to create a new prefab for each spell, attach that to the unit prefab and referencing it by hand?

latent latch
#

you'd have a single prefab but with different SO profiles

#

then spawn instances of that prefab

#

and load them with the SO data

candid trench
#

okay, but how do i differentiate between the different effects the spells will have

#

like, one spell might reduce armor or whatever, and another spell might heal another unit.

latent latch
#

Ability systems are actually pretty hard, but there's a design pattern called meta magic(?) where you keep the effect of the hit independent of how the ability moves and behaves

candid trench
#

i did actually read something about metamagic somewhere

latent latch
#

So if you did want to make say a projectile that burns, you'd have a SO with the default variables for how the projectile moves/casted/collision, but also it should have another SO (the hit portion) inside of the SO which tells it what to apply on the hit

candid trench
#

hm.

latent latch
#

The SO is just basically a data container with the default data for the most part.

#

Which you'd only read from on the actual game object

candid trench
#

so one base SO that every spell shares? and then the spell has a different SO for the hit portion.

latent latch
#

A super class for abilities is what I kind of do, I just make sure everyone works together enough, and even though you can create some really busted abilities, it's less of a design problem and more that the programmer decided to make a spell that way ;)

#

Yeah, you'd have a function inside of the spell prefab that calls a onhit method to execute the logic with the other SO you've given it

candid trench
#

Ugh, i dont know if im just tired or stupid. I cant wrap my head around it.

latent latch
#

Ok so the spell prefab should just handle stuff mostly stuff like the velocity of the ability gameobject and the collision checking. When you hit a target you'd do something like this:

``
protected bool TargetHit(Collider[] colliders)
    {
       .....
        foreach (Collider collider in colliders)
        {
            //If enabled, deal damage and apply ActiveEffect(s)
            if ((ability.StorableSO.TargetMask & layerMask) == layerMask)
            {
                if (collider.gameObject.TryGetComponent(out IEntity entity))
                {

                    foreach(var activeEffectsDict in ability.ActiveEffectsDicts)
                    {
                        activeEffectsDict.Key.ApplyEffect(entity, activeEffectsDict.Value);
                    }
                }
            }```
#

I actually do have some functionality (mostly an init function) in my SO for the onHit, but you can do similar stuff like a static function

candid trench
#

Okay, lets roll back. Lets focus on targeted spells. as in, they cant really miss. I just select a unit and do stuff to it.

However, im not quite understanding the benefit of having the "effects" being SO's since i have to create new scripts for each effect anyways.
So maybe i should just stick to regular scripts

#

Im sorry if i may seem confusing or confused. But thats just because i am just that, confused x)

latent latch
#

Scripts are completely fine, I've just got a bunch of data usually on my on hit (status effect tags, duration and stack logic). They are useful for pumping out a bunch of different scripts quickly from the editor.

candid trench
#

yea okay, i get that. But how do i define different effects directly in the editor? Seems to me that i'd have to hardcode effects

latent latch
#

I've rewrote it a few times, but in the end you do have to hardcode a bit and specify very specific details. Originally I actually instantiated the details as soon as the spell was created, but since I've an upgrade system now I've had to rewrite it so I can grab some of that data and modify it.

#

Was midway writing a parser for complex formulas until I realized maybe I didn't need all of that.

candid trench
latent latch
#

But a few ideas if you want to look more into SOs. You can instantiate them if you want, despite what people say, and can edit them freely if you want to write to them afterwards. The only problem is that you can't start coroutines on them.

#

And, even though you can't run coroutines on them, you can still use them to spawn coroutines on other GOs and use the SO to keep* track of them

swift falcon
#

Any solution for this crash SIGSEGV?

modest nova
#

how do I add to a entity from monobehaviour. I have got reference to the entity, I just want to add force to it

tired drift
#

Guys i'm honestly a thought here. Which IEnumerables (List, Array, Dictionary can i serialize / see on the Unity's inspector without having to make a custom one

latent latch
#

List, Array

#

There's some implementations for a dictionary if you look around on the forums

thin aurora
tired drift
#

Hm ty! guess i'll try to transform my dictionary into a list first blush_cat but i'll have a look at that repo, seems pretty nice!

#

hmm guess i must be doing something wrong tho

#

just snippets, but for some reason it ain't showing the list

[SerializeField] private List<KeyValuePair<int,object>> _data => _gameData._saveData.ToList();
[Serializable]
internal class GameData
{
    public Dictionary<int, object> _saveData;
}```