#archived-code-general

1 messages · Page 13 of 1

terse venture
#

i disabled 1 of my enemies that was flooding console ( i havent assigned its animation controller yet ), to check that it was putting it in console (which it was), and it just suddenly started working

#

thanks for the help anyways

#

@lucid valley

lucid valley
#

yeah that error might have stopped it somehow. Always fix/catch errors

terse venture
#

Just did some further testing, and weirdly it only destroys half the time when colliding. Thats a bug i shall now fix

mental rover
#

yeah, just any piece in the new section would do, as you'll end up needing to do some kind of bfs/graph search to find all connected pieces to it, and that will find any/all of them

rain saffron
#

BFS?

#

YES

mental rover
#

breadth-first search

rain saffron
#

That's exactly what I'm after!

#

Thank you, this will be an immense help 😄

mental rover
#

you may want to look into other graph algorithms as well as there's a lot of very helpful and powerful things 👍

devout solstice
#

how could i have a proper drop-down menu, not that thing where you click the dot, and detect which option is selected out of the drop-down

modest jay
#
if (CanMove(speed))
        {       
            _animator.SetFloat(SPEED, _id == 1 ? -speed : speed);
            Debug.Log(_id);
        }
            
        else
            _animator.SetFloat(SPEED, 0);

This function returns values between 1 and -1 but if I add the player controller script and a second player using input system the function only returns values between -1 and 0 never +1. It works as expected if the player controller script is not used.

Here is the full code:
Movement controller: https://hatebin.com/isrhtubukh
Player Controller: https://hatebin.com/scfmvqmgyb

devout solstice
#

then i’m sure it’s something with your player controller. Are they talking to each other?

#

so when you add the player controller it seems like it’s never reading the speed as positive

#

least that’s what i’m interpreting

#

probably not though i don’t see how that could be

swift falcon
#

imgUI[i].sprite = Sprite.Create(filtered[i].normal, imgUI[i].rectTransform.rect, imgUI[i].transform.position);

Im trying to give my uimage one of my default textures types… this has no errors but isn’t working either

#

Help

devout solstice
short badge
#

Hey guys, so I've got an orthographic camera with a zoom that is managed by altering the orthographic size, but I'm facing a problem with Audio Sources. Essentially, I need to adjust the volume of world placed Audio Sources depending on how zoomed in the camera is. At the moment, the volume doesn't change since it's just effecting the size of the camera instead of the position. Anyone advice would be much appreciated 👍

woeful leaf
spark flower
#

hey guys

#

why is tghis giving me null refrence? line 100

#

the stages.length is 4 as it shuld be

short badge
woeful leaf
#

Take the variable that changes and base your volume on that

#

Which you seem to imply size in this case

#

I might be understanding your issue wrong though

main shuttle
spark flower
main shuttle
#

You make the stages array the length of the keys

spark flower
#

doesnt that make instances or something

main shuttle
#

Afaik, you currently have an array that can have Stage objects in it, it currently has 4 places in that array, and they are all null.

#

Just set a breakpoint there. And check what's in the array.

spark flower
#

ok

short badge
woeful leaf
#

Do you want it based on position or size?

#

Does the position remain the same for the camera during the entire scene? But each have their own position?

#

Same goes for the size?

main shuttle
woeful leaf
#

(if the cameras remain on the same position for the entire scene, you only have to run it once in start, for each seperate camera)

short badge
short badge
lethal plank
#

guys im having problem
unity error log told me that the UpdateValue is the problem

lethal plank
gray fjord
#

Where can I ask questions related to license?

lethal plank
#

ohhh i see

prime sinew
lethal plank
#

because i put the call before set parent so it cant get component in parent

lethal plank
prime sinew
#

show the error in the console

lethal plank
#

alright that might be long
avg open project time is about 25m xd

#

but i fixed it bro

#

oh nvm

coarse umbra
#

anyone knows how to combine some sprites with their positions and sizes to a one sprite?

devout solstice
#

anyone know how i could get a proper drop-down box in the inspector and check which option is selected?

woeful leaf
devout solstice
woeful leaf
#

Google can

#

It's quite simple though

#
public Enum MyEnum
{
  One,
  Two,
  Three
}
[SerializeField] private MyEnum myEnum;
#

@devout solstice

devout solstice
#

Alright

#

And how do i check which is selected? And most importantly how do i assign what each selection does

#

i tried to look it up but couldn’t figure it out

lethal plank
#

it will be longer if use string xd

devout solstice
#

Oh and that’ll return a bool?

lethal plank
#

yes

devout solstice
#

ok

rain minnow
#

you can look at enum vids and blogs in beginner c# tutorials . . .

lethal plank
#

very weirdo

#

working on Instantiate object is pain

#

assigned from this

rain minnow
lethal plank
rain minnow
rain minnow
lethal plank
#

lemme check

lethal plank
bitter valley
#

Hey guys, can't seem to find informations about Unity's grid system. I have to use if for an educational but can't find any ressources on using it in a 3D space, can someone help me do that? The goal is making a sokoban 3D where I need a grid to know wether there's a wall or the player for example in a cell at any given moment

bitter valley
#

I just can't seem to understand how to initialize it in a 3D space and how to manage it

#

I can't use rigidbodies or colliders in the project

rain minnow
devout solstice
leaden ice
#

you put it on a GameObject like anything else

rain minnow
leaden ice
#

WDYM by "manage" it?

bitter valley
#

Ok but how do you use it after that?

leaden ice
#

you interact with it through calling its methods of course

bitter valley
#

There's my problem, even after reading the documentation a couple of times, I don't understand how to use it

leaden ice
bitter valley
#

I'm trying to create a game board

#

For a sokoban game but in 3D

leaden ice
#

that's all

bitter valley
#

I would like to use the grid to detect where is the player, walls and limits of the board at any given time so I can restrict movements

leaden ice
#

it's not going to "detect" anything

lethal plank
leaden ice
#

your game logic should simply take place on a 2d coordinate system

leaden ice
#

the point of the grid is to just help you translate that 2D coordinate system into 3D positions @bitter valley and vice versa

lethal plank
bitter valley
devout solstice
leaden ice
#

to just help you translate that 2D coordinate system into 3D positions and vice versa

bitter valley
#

Yeah but right now I can't think of a way that would help me for the project I'm working on ^^"

lethal plank
devout solstice
#

ok

leaden ice
#

I think it seems obvious to me

bitter valley
#

Ok thank you for the infos 🙂

steady granite
#

Not sure where to ask for help, I have world space UI that partially disappear when moving/changing resolution, looked into pixel perfect features but this requires screen space overlay and removes size scaling from what I understand

golden vessel
#

Is there a way to make a sprite brighter? I can set RGB so that the sprite is darker, but not brighter. Is that a feature of RGBA?

leaden ice
#

you can't make things brighter through multiplication, only darker

#

You'd need to brighten the original sprite asset

golden vessel
#

Interesting, thanks for the info

golden vessel
late lion
#

If SpriteRenderer.color allowed for HDR colors, as in not clamped between 0-1, this would be possible. (and I think it should)

leaden ice
#

yeah not sure if it allows hdr or not

golden vessel
#

Isn't there something for that? On the sprite renderer's material

leaden ice
#

possibly

#

also with a custom material/shader anything is possible

late lion
#

If your material allows for HDR colors, you can multiply it there too. But SpriteRenderer.color definitely clamps.

golden vessel
#

I thought so ^^ I'd rather not use material just for that, I'll work around it. Thanks 🙂

echo steeple
#

please help, unity says: error CS0246: The type or namespace name 'WebGL' could not be found (are you missing a using directive or an assembly reference?)

rancid jolt
#

I created a function for enemy to shoot when the ray hit the player. Enemy is not shooting. The ray is not hitting the player despite of everything is aligned.

potent sleet
echo steeple
potent sleet
echo steeple
potent sleet
echo steeple
#

i have two gameobjects which are webgl

#

2 nativeinputfields

potent sleet
#

wdym 2 objects are webgl
webgl is a rendering engine

echo steeple
#

i think the problem is unity doesnt recognize webgl as it says it couldnt find it

#

wait

potent sleet
#

WebGL is a class at most.. Never seen WebGL in a namespace.

echo steeple
potent sleet
#

where did you get this from...what is it for,

echo steeple
potent sleet
echo steeple
#

well how am i supposed to learn

potent sleet
echo steeple
#

im just learning

#

CryptoGrounds: Coding and Gaming, for Everyone!

Hello! In this video, I will be showing you guys how to make our import and export system supported for WebGL builds.

WebGL is a Javascript API used for rendering 2D and 3D games on the web, which is what Unity uses to run its games on the web!

Currently, normal input fields are not accessible i...

▶ Play video
obtuse cedar
#
    IEnumerator EmitRoutine(ParticleSystem.EmitParams @params, ParticleSystem.ShapeModule shape)
    {
        print("starting emit routine");
        float timer = 0;
        print("time at emit start is " + Time.time);
        float timestart = Time.time;
        float particleDur = ParticleDuration * 60;
        print("particledur is " + particleDur);
        while (timer < particleDur)
        {

            shape.rotation = TargetTransform.rotation.eulerAngles;
            @params.position = TargetTransform.position;
            Particles.Emit(@params, ParticlesToEmit);
            print("timer is " + timer + " at " + (Time.time - timestart));
            yield return new WaitForSeconds(EmissionRate);
            timer += 60 * EmissionRate;
            //yield return null;
        }
        print("time at end is " + Time.time);
        float timediff = Time.time - timestart;
        print("time diff is " + timediff);
        print("emit routine finished");
    }

I made this coroutine for intermittently emitting particles but the time difference is about 1 second longer than the duration I specified
I'm guessing I should rely on delta time and check if I passed a certain amount of seconds instead of relying on waitforseconds?

potent sleet
echo steeple
#

so, what now?

potent sleet
potent sleet
#

these dont teach you shit tbh

#

just "do this and this and this , now ur done"

echo steeple
#

how did you learn

potent sleet
#

having a configured IDE

#

etc

echo steeple
#

i know those

#

the fundamentals

potent sleet
#

idk I've made many WebGL projects, never Did i have the need for WEBGLNativeInputs

#

this some weird shit rn

echo steeple
potent sleet
echo steeple
#

yes, i know the fundamentals, but could you please elaborate

potent sleet
#

talk about a contradiction...

echo steeple
#

come on, dont be like this

#

im trying to ask nicely

potent sleet
#

do you want me to hold your hand the whole way, If that is the component then you add it in..

#

just like you add any other custom component

echo steeple
#

the last one?

main shuttle
potent sleet
#

they even link the package u need in description..

echo steeple
#

I have that in my project!

#

i put the folder in!

#

(sowwy for being an idiot)

potent sleet
#

then you didnt install it correct, you should be able to see the component

#

ur intellisense in VSCode is not even configured...

#

how would you even know if script is reading the component..

#

did you put this folder in Assets ? @echo steeple

echo steeple
#

yes

potent sleet
echo steeple
potent sleet
potent sleet
#

"I know the fundamentals"

#

you see why it's annoying when ppl lie

echo steeple
potent sleet
#

its unity 101

#

look itup and come back when you know what inspector and add component button is

polar marten
#

are you trying to have a text input field on a mobile webgl game?

echo steeple
#

its not mobile

polar marten
#

hmm

#

why aren't you using a regular input field?

#

if you have input system handling set to both, it works.

#

i can add that to my tips and tricks

echo steeple
#

ok i think i can do that without breaking the game i will try

polar marten
#

okay

#

i actually am authoring a fixed input field righ tnow

swift falcon
#

does anybody know a tutorial for a 2d bomb explosion tutorial? I can't seem to find except for one which won't work.

polar marten
#

the underlying issue with input fields on webgl and many of the odd platforms is that tmp_inputfield and inputfield both use IMGUI Event to poll characters instead of input system. @heady marten but yet again, the cantankerousness of ticketing all of this and getting to a conversation with a unity engineer that isn't sales-led is so dire

echo steeple
#

(and putting up with my stupidness)

kindred flower
#

I'm researching showing html elements over a full screen web unity instance but can't get things working. I'm unable to find a way with absolute position and/or zindex. The elements render on top of the game when not in full screen, but disappear once the game is full screen... has anyone done this before?

polar marten
echo steeple
#

sure ^.^

royal radish
#

how can i setup vs code to work with unity?

leaden ice
rain minnow
devout solstice
#

pretty simple, unless you’re asking about the explosion effect itself

orchid turtle
#

Hello, I would like to ask

#

I'm drawling lines with GL

#

why does it only show when gizmos is on?

#

in game view

leaden ice
orchid turtle
#

I

#

I want to send a screenshot of unity and

#

it stuck in

orchid turtle
#

I know that if u put it in camera, it's OnPostRender(), but I need to easily change it's place

#

so I opted for gameobject

#

the gameobject

leaden ice
#

Can you show the code?

orchid turtle
#

hmokay, it's pretty long thoguh

leaden ice
orchid turtle
#

okay

#

does gists work?

leaden ice
#

sure

orchid turtle
#

here's the code

#

the function responsible for drawing the lines is

#

drawLines()

#

o, I did do it in OnDrawGizmos()

#

my bad'

#

but why didn't OnRenderObject works?

leaden ice
#

yeah was gonna say

#

OnRenderObject probably isn't working at all

orchid turtle
#

okay, I am gonna check

leaden ice
#

Idk the docs are confusing. They say one thing and the code example does something else

orchid turtle
#

GL isn't talked as much, sad, so I harder to find wha ti Wnat

#

yeah, OnRenderObject isn't being called

#

alright

#

okay, turns out it needs a renderer

earnest gazelle
#

How do you name tags in git? v1.1.1?
what about if you build your app for several markets? market/v1.1.1? market-v1.1.1?
I prefer v1.1.1 but how I can distinguish them between markets?
Should they have same version?

orchid turtle
alpine oasis
#

Let's say we're making a large number of, let's call them pokemon-style attacks

#

Lots of moves that can alter the battle in as-of-yet unpredictable ways, such as damaging, applying status effects, modifying stats, creating ongoing passive effects, placing traps, etc

#

The point is that I need to be making a lot Nouns that will each be performing multiple Verbs that may affect an ever-growing list of types of Nouns

#

And I'm trying to figure out how to represent that

#

Right now I'm imagining a few- or potentially a lot- of ScriptableObjects all inheriting from the same base class that represent actions, potentially even ScriptableObject scripts that are only expected to be used once since their exact effects are so specific

#

But I'm having trouble working out the nuances of having all that polymorphic behavior, with many different function signatures, often requiring state information about the battlefield, be represented as something I can pass an entity as like, a list of Actions they're allowed to take

#

I guess more specifically each "Action" could be made up of multiple "SubActions" performed at once (attack, modify stats, inflict status effect) so as not to have to make an SO script for each fiddly combination, but details, details

leaden ice
#

A few pieces:

  • an enum for "effect type" (e.g. damage, chance to inflict status effect, etc..)
  • an "Effect" object. It's basically an EffectType + a number.
  • An attack just has a list of effects.
    So a particular Attack would be something like:
Fireball
  pp: 10
  effects:
    - Damage: 50
    - BurnChance: .5

Then to execute this you just loop through the effects and each enum value is mapped to a function. You can essentially think of that just as a big switch statement

#

you can easily mix and match any list of effects you want this way

#

Then it's just one ScriptableObject per Attack (The SO has a name, a cost, a PP amount, and a list of Effects as above)

orchid turtle
alpine oasis
#

I suppose I am having a hard time coming up with a "weird attack" that couldn't in some manner be put in a list of status effects or a list of Battlefield Effects

alpine oasis
orchid turtle
leaden ice
leaden ice
#

In my case I'm using my system for a tower defense game

alpine oasis
#

Mmhm

#

Interesting. Yeah, this should work.

#

Hey, it's been months since last time, but I always see you around here and it's always really helpful talking through things with you. Thanks for that.

leaden ice
# alpine oasis Interesting. Yeah, this should work.

You'll also want to think about how to handle "typed" damage, and things like "status effect type". It could either be different effect types, e.g.:

  • Fire Damage
  • Electric Damage
  • Normal Damage
    etc...
    OR you could add a third field to the Effect which is like a "tag".
    So you'd have e.g.:
    EffectType: Damage, Amount: 50, Tag: Electric
    or
    EffectType: StatusEffectChance, Amount: .5, Tag: Burn
    Something to think about
#

assuming that matters in your game

alpine oasis
#

Mmhm, we'll see if I decide to go forward with implementing that

#

I am notorious for complaining to my friends that elemental damage in games like D&D and Dark Souls are mostly pointless and not a fun moving part to deal with

plush abyss
#

Hey everyone,

I need help with disabling my parallax effect in Unity when my screenbox is disabled, so it doesn't disrupt my UI. Tried using SetActive() and disabling components but nothing seems to work. Any Idea? I'm sending the code 😄

#
using UnityEngine;
using System.Collections.Generic;

public class ScreenBoxManager : MonoBehaviour
{
    public GameObject frame1;
    public GameObject frame2;
    
    
    private void OnTriggerEnter2D(Collider2D collider){
    if (frame1.active == true){
        frame1.SetActive(false);
        frame2.SetActive(true);
        //disable parallax layers
        var parallax = GameObject.Find("ParallaxBackground").GetComponent<ParallaxBackground>();
        foreach (ParallaxLayer layer in parallax.parallaxLayers)
        {
            layer.gameObject.SetActive(false);
        }
    } else if (frame1.active == false){
        frame1.SetActive(true);
        frame2.SetActive(false);
        //enable parallax layers
        var parallax = GameObject.Find("ParallaxBackground").GetComponent<ParallaxBackground>();
        foreach (ParallaxLayer layer in parallax.parallaxLayers)
        {
            layer.gameObject.SetActive(true);
        }
    }
}

}

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
 [ExecuteInEditMode]

 public class ParallaxBackground : MonoBehaviour
 {
   public ParallaxCamera parallaxCamera;
   public List<ParallaxLayer> parallaxLayers = new List<ParallaxLayer>();
  
   void Start()
   {
       if (parallaxCamera == null)
         parallaxCamera = Camera.main.GetComponent<ParallaxCamera>();
       if (parallaxCamera != null)
         parallaxCamera.onCameraTranslate += Move;
       SetLayers();
   }
  
   void SetLayers()
   {
       parallaxLayers.Clear();
       for (int i = 0; i < transform.childCount; i++)
       {
           ParallaxLayer layer = transform.GetChild(i).GetComponent<ParallaxLayer>();
  
           if (layer != null)
           {
               layer.name = "Layer-" + i;
               parallaxLayers.Add(layer);
           }
       }
     }
     void Move(float delta)
     {
         foreach (ParallaxLayer layer in parallaxLayers)
       {
           layer.Move(delta);
       }
   }
 }
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

 [ExecuteInEditMode]
 public class ParallaxCamera : MonoBehaviour 
 {
     public delegate void ParallaxCameraDelegate(float deltaMovement);
     public ParallaxCameraDelegate onCameraTranslate;
     private float oldPosition;
     void Start()
     {
         oldPosition = transform.position.x;
     }
     void LateUpdate()
     {
         if (transform.position.x != oldPosition)
         {
             if (onCameraTranslate != null)
             {
                 float delta = oldPosition - transform.position.x;
                 onCameraTranslate(delta);
             }
             oldPosition = transform.position.x;
         }
     }
 }

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

 [ExecuteInEditMode]
 public class ParallaxLayer : MonoBehaviour
 {
    public float parallaxFactor;
    public void Move(float delta)
    {
        Vector3 newPos = transform.localPosition;
        newPos.x -= delta * parallaxFactor;
        transform.localPosition = newPos;
    }

 }
#

If anyone have an Idea how to cancel the fact that my Layer are moving when the Box is inactive or help me find how to change the Axis position when I enter a new box, It would be really great !

leaden ice
#

you've kinda dumped a ton of code here without context

plush abyss
#

frame 1 and frame 2 are two ScreenBoxes

#

and My problem is that when frame 1 is active, the Layer of frame 2 moves even if it's off

#

so I wonder I someone have an idea how to change the Parallax axis when the frame changes 😄

leaden ice
#

isn't this the code that's moving them?

plush abyss
#

yes it is

leaden ice
#

I don't see anything here that would care about whether the frame objects are active or not

plush abyss
#

well I tryied to check it with IsActive() but it didn't work either

leaden ice
#

I don't really understand what you're trying to do here tbh

#

why not just remove the ones you don't want to move from that list

plush abyss
#

I'm trying to have different boxes into a scene likeso they are not too many object and the player isn't lagging

plush abyss
leaden ice
plush abyss
#

I want them to move but frim a different axis only when the box is active

plush abyss
#

but it doesn't fix the Parallax Axis :c

plush abyss
polar marten
#

they mutate their transforms... you don't want to do that in edit mode

#

that's not going to work

#

first remove execute in edit mode

#

before anything else

plush abyss
#

okk I used it to see where to put my colliders 🐸

polar marten
#

you are also adding event listeners and never removing them in an executeineditmode script

#

which is really bad*

#

the delegate is not an event either. it doesn't have to be but that's surprising

plush abyss
#

well I removed them

polar marten
#

onCameraTranslate is redundant

#

don't use an event at all

#

setlayers is also surprising

#

what is a screenbox? what do you mean a disabled screenbox?

#

a bunch of your issues are coming from this event

#

don't use them

#

it is surprising to you

plush abyss
#

well a screenbox is a box that have a part of the scene and is only active when the player enter inside it

#

It's usefull not to generate everything at the same moment

polar marten
#
void LateUpdate() {
 if (transform.position.x == oldPositionX) {
  return;
 }

 foreach (var parallaxBackground in parallaxBackgrounds) {
  parallaxBackground.Move(transform.position.x - oldPositionX);
 }
}
#

don't use the delegate, it is what is causing your issue

#

the delegate ( the event) is still going to execute even if a game object is inactive

plush abyss
#

but even without that my problem is about the parallax axis when I enter a new place because It keep his first position and don't know how to change it

polar marten
#

well

#

a lot of the problems you are having are Programming

#

you have to deal with all these issues

plush abyss
#

haha

polar marten
#

nobody said parallax would be simple lol

plush abyss
#

Okk, will try to find my issues this evening then

junior bobcat
#

Android question here, I'm trying to use the System.IO to read the filesystem on an Oculus Quest.... but I keep getting permission error. I added the code below into the AndroidManifest.xml but I don't see the pop up for permissions when I launch in debugger and I still get the Permission denied error.... What could I be missing?

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
leaden ice
#

also WRITE_EXTERNAL_STORAGE seems like it's for writing only

#

what about reading?

junior bobcat
#

READ is implied with it

#

/

leaden ice
# junior bobcat `/`

I don't think any app is allowed to read/write to / under any circumstance in Android

junior bobcat
#

yes, they are

potent sleet
#

why would this be a thing then

junior bobcat
#

The Quest 2 is running Android 10, tried including android:requestLegacyExternalStorage="true" but still doesn't have the permission pop up

#

are permissions supposed to pop up when running in debug mode?

#

I supposed if you only wanted to READ and not write?

potent sleet
#

wait..

rain minnow
potent sleet
#

guess it is explicit with WRITE_EXTERNAL_STORAGE

junior bobcat
#

I know it's possible to at least read root... Skybox VR does it and I know that's running unity

#

granted, it has the permission pop up when you open the app

potent sleet
junior bobcat
#

which is from the AndroidManifest.xml..

potent sleet
junior bobcat
#

the OS grabs it

potent sleet
# junior bobcat the OS grabs it

ok so they're injected in but don't you still have to make a request on whatever components you declared wanting permission from

junior bobcat
potent sleet
#

I don't think that one works does it ?

#

you need the native method

rancid jolt
#

I have changed my strategy and instead using ray now I am using viewPort to check if the enemy is visible in the main camera or not. if it is visible it should start shooting to the player. But it is shooting even when it is not visible in the main camera.

potent sleet
junior bobcat
#

hm... I could try to verify if it's working... but I'm wondering if I'm misunderstanding what WRITE_EXTERNAL_STORAGE means here. I just found this in the player settings

potent sleet
#

I've only exported to APKs to playtest, never actually messed with permissions tho 😫

potent sleet
#

looks like unity took care of the methods and have a Permission class..

swift falcon
#

android 10+ requires special permission

#

MANAGE_EXTERNAL_STORAGE

hasty haven
#

When detecting collision with OnTriggerEnter() is it possible to check the layer of the other collider or would it be more performant to just use tags and CompareTag()?

woeful leaf
#

Unless you're doing some extremely whacky major collision events

hasty haven
#

Mostly for differentiating things like hitting a wall, character, boundary, etc

woeful leaf
#

In which case you should use the profiler to determine it

woeful leaf
#

Unless you plan on building an absolutely massive game

devout solstice
#

is there a way to cut out part of a block without editing the model file obviously

hasty haven
#

This is for a (networked) projectile system so I'd like to make it as performant as possible.

#

I have already stress tested it with a shotgun that shoots 100 projectiles 10x a second in the past.
this iteration should be a lot more performant on the network side too

#

I disabled the on hit effects in this video

#

But you can see all of that info going over the wire no problem

#

The sort of square ish breaking on the end has to do with tick rate

#

In general players wont have more than a few dozen projectiles active at once

unique jolt
#

Hi guys, somebody can help me with this error please?🙈

leaden ice
simple egret
autumn cipher
#
public GameObject LoadoutButton;
    public GameObject[] LoadoutButtons = new GameObject[20];
    public override bool Active
    {
        get => base.Active;

        set
        {
            base.Active = value;

            if (value)
            {
                List<byte> notNullindexes = new(), Nullindexes = new();
                for (byte k = 0; k < LoadoutButtons.Length; k++)
                {
                    if (LoadoutButtons[k] != null)
                    {
                        notNullindexes.Add(k);
                    }
                    else
                    {
                        Nullindexes.Add(k);
                    }                    // player.playerData.LoadoutDatas.Count is dynamic, could be 20 max                                    
                    for (byte i = 0; i < player.playerData.LoadoutDatas.Count; i++) 
                    {

                    }
                }
            }
        }
    }```
#

I'm trying to create buttons based on player.playerData.LoadoutDatas.Count

#

to avoid any index out of range errors, I've instantiated LoadoutButtons' size as 15 and made two Lists that contains null/not null indexes separately

leaden ice
#

and why would the array contain null elements?

autumn cipher
#

and remove the extra ones if LoadoutButtons has more buttons than player.playerData.LoadoutDatas.Count

leaden ice
#

Use Instantiate(somePrefab) to create them

#

Destroy to destroy the excess

#

Just put them in a List

#

not sure what all this nullIndexes and nonNullIndexes thing is about

#

Don't use an array when you want something resizable

autumn cipher
#

oh one more thing, the most important part

#

I'm trying to keep the button indexes fixed

#

that's why I did that list crap

leaden ice
#

not sure what that means or how it's related

#

why would the indexes change?

#

also why byte for the indices 😵‍💫

autumn cipher
#

my brain feels like mashed potato right now

#

brb in few mins

full scaffold
#

Confused

#

Is it meant to be some sort of inventory

autumn cipher
#

basically the create a class system from call of duty

#

trying to replicate it

full scaffold
#

Probably explain your approach

#

I would have used SO or something for the data then utilize it under a separate place

autumn cipher
#

alright so I have these scriptable objects with a LoadoutData struct

#
 public List<LoadoutData> LoadoutDatas = new List<LoadoutData>();``` got this
#

created 10 of them

#

but this amount may change

#

so I'm trying to make a UI system that will bring me the right amount of buttons related to those LoadoutDatas indexes

#

each button will open the respective LoadoutDatas

leaden ice
#

the simple approach is something like:

MyButtonScript buttonPrefab;
List<MyButtonScript> buttons = new();

void SetLoadouts(List<Loadout> loadouts) {
  for (int i = 0; i < loadouts.Count; i++) {
    MyButtonScript theButton;
    if (i >= buttons.Count) {
      // we need to add a new button instance
      theButton = Instantiate(buttonPrefab);
      buttons.Add(newButton);
    }
    else {
      // we already have an instance in the list.
      theButton = buttons[i];
    }
 
    theButton.Initialize(loadouts[i]);
  }

  // now make sure we don't have any _excess buttons_
  while (buttons.Count > loadouts.Count) {
    Destroy(buttons[buttons.Count - 1].gameObject);
    buttons.RemoveAt(buttons.Count - 1);
  }
}```
autumn cipher
#

that's why I'm trying to keep the indexes of buttons fixed while also making the resizable

autumn cipher
#

thank you

#

I've been going nuts about this

#

thanks to everyone else as well

zinc parrot
#

Does anyone know a way to test if the z component of a normal map in unity is flipped automatically?

leaden ice
zinc parrot
#

no

#

I have a few normal maps but one is different from the others, for one of them to be correct in my program I have to do 1 - its z component
unity seems to handle this automatically and idk how

leaden ice
#

No idea. I feel like that'd be in the realm of like "Is there a way to tell automatically if the colors of a texture are correct?". Aren't all textures "correct"? It just depends on the intention, which the computer cannot know.

zinc parrot
#

thats fair

#

I just dont know how I can feed 2 normal maps to unity standard shader and they both display one thing
but if I use my compute shader project thingy to display them one of them has its y component wrong

leaden ice
#

that's a really good question and I have no answer for you

#

is the z component ignored by the standard shader maybe?

#

(you said z above and y here so not sure which you mean)

zinc parrot
#

sorry I mean z

#

since y is up in unity, I ignore that component

#

also theres no way to get like dxt render textures right? I need to compress these runtime created atlas's so that they aint like 3 gigs each

formal coral
#

I keep on getting this error that says that the enemy's script is destroyed, and to check if it is null, so I did that, but it still gives me the error and idk what to do

    //Stuff called from Actions
    void ChangeEnemySpeed(float change, float timeUntilNormal)
    {
        float initialEnemySpeed = enemySpeed;

        if (gameObject != null)
        {
            enemySpeed *= change;
            StartCoroutine(speedToNormal());
        }
        

        IEnumerator speedToNormal()
        {
            if (gameObject != null)
            {
                yield return new WaitForSeconds(timeUntilNormal);
                enemySpeed = initialEnemySpeed;
            }
                
        }

    }
formal coral
#

starting the coroutine

StartCoroutine(speedToNormal());
proper oyster
#

wired
what object is that script on?
can you log what gameObject is in that case ?

zinc parrot
#

so is there a way to create a texture2d without causing a freeze?

proper oyster
zinc parrot
#

16k

#

i notice if i create a rendertexture it doesnt freeze for a second but if I do a texture2d it does

proper oyster
#

CPU VS GPU menory?

zinc parrot
#

I need texture2d instead of rendertexture because its much faster to sample a texture2d in a compute shader for some reason

#

hmmm

formal coral
proper oyster
formal coral
proper oyster
formal coral
#

but would that not matter since I already check if its null?

zinc parrot
#

I cant because I cant send an unknown amount of textures to the compute shader

#

cuz unity doesnt support bindlesss...

proper oyster
mossy snow
formal coral
#

but then what should I do to make the Coroutine work then

proper oyster
formal coral
#

so would there be another way to do this then? since the enemy has to die if its health falls below 0.

proper oyster
#

or run the code on a different object

formal coral
#

I did that but instead I got an error that it couldn't access the enemy script

#

so I turned to this way and used Actions

proper oyster
formal coral
#

It shouldn't

#

this function is called when one of my power-ups stuns the enemy it hits

#

so it shouldn't work against enemies already destroyed

proper oyster
proper oyster
formal coral
#

k thank you

tawny jewel
#

hey, so i have a floppy bird game where pipes are spawned every 3 seconds. i also have a powerup spawning on random timer, how can i make the powerup always spawn right between the pipes

hexed oak
#

How big is your terrain? might be imprecision, try breaking it up into smaller chunks and rebaking

potent sleet
hexed oak
#

if the pipes are every 3 seconds then only spawn a powerup if a timer counter mod 3 == 0

#

Maybe add a little wiggle room since it's unlikely to be exactly 0

tawny jewel
#

welp i want it to be roughly in a middle an that should be enough, i just dont want it to spawn on the pipe

#

so i could potentially spawn it only when, say, pipe counter is equal to 1,5

hexed oak
#

You could add an empty transform in between your pipes that is exactly where you want to spawn it

#

then if you're rng dictates to spawn a powerup, go ahead and spawn it using the empty's location

rain minnow
tawny jewel
rain minnow
hexed oak
#

idk just the first thing that came to mind

tawny jewel
#

oh i apologise for misunderstatement, i ment between the pipe clones

#

so in a free space from before another pipe spawns

hexed oak
#

Yeah I'd try smaller sizes if possible. I've had that frustration before of little gaps

tawny jewel
hexed oak
#

space between bottom of rect and top of rect

tawny jewel
hexed oak
#

it will move up and down with the prefab clone

tawny jewel
#

if that matters

tawny jewel
#

well more in the middle but yea

tawny jewel
formal coral
leaden ice
#

presumably the condition is false

formal coral
#

i already checked that and the Debug.Log("running"); runs

leaden ice
#

they're also after a yield

formal coral
#

so it has to do something with the yield return new

leaden ice
#

a coroutine won't resume from a yield if the object running it is destroyed or deactivated

formal coral
#

That would be true but it doesn't even work for objects that aren't destroyed

leaden ice
#

so presumably your object is being destroyed or disabled

#

also check how long stunTime is

#

it's also kinda weird to use a local function for this

formal coral
#

I did a debuglog and it is always 2

#

so the time it takes should only be 2 seconds

leaden ice
#

Ok so... which GameObject is this script attached to

formal coral
#

an explosion that appears and disappears after a short amount of time

#

could it be because I Destroy() it after a second?

#

yeah that was the case

leaden ice
#

and you said it wasn't destroyed

leaden ice
formal coral
#

I thought you meant by like the enemy that it is colliding with was being destroyed

leaden ice
#

that doesn't seem relevant but alright

twilit hamlet
#

Hey im just trying to figure out how the save/load work flow works. I can turn all my objects into json and stick them in a string list but then how do i store the list of json strings to be read in by the loader?

leaden ice
feral flax
#

please help me

leaden ice
#

then reverse it to load

twilit hamlet
leaden ice
#

and throw them into the main save data object

#
[Serializable]
public class SaveGameData {
  // whatever data you want to save goes in here. ALL OF IT.
  public List<Whatever> whatevers;
}```
#

your loader can read through the whatevers list and instantiate GameObjects or whatever it needs to do

twilit hamlet
leaden ice
#

like my example

#

you can't use it directly on a list.

twilit hamlet
leaden ice
#

yes

#

your save/load code need not be any more complicated than:

string json = JsonUtility.ToJson(saveData);
File.WriteAllText(json, filepath);```
and
```cs
string json = File.ReadAllText(filepath);
SaveData loadedData = JsonUtility.FromJson<SaveData>(json);```
twilit hamlet
# leaden ice yes

that just seems like more work to then have to decode the object then decode the data within that object, i feel like writing each on to an array would have been a faster way to save it to a text file

leaden ice
#

loadedData.whatevers < this is not work

#

this is one .

#

Work would be some crazy string concatenation scheme you probably are about to try

#

work with the parser, not against it

#

there's no further "decoding" to do

twilit hamlet
#

do you mind if I ask, why are you always in here? Every time I come to this discord you are always on answering tons of questions in multiple channels. Is unity like paying you or are you just super motivated to help people?

twilit hamlet
leaden ice
#

they should be paying me

#

tell them to pay me

twilit hamlet
leaden ice
#

I'm working on an asset store asset right now and my code isn't working as i'd like it to so instead of fixing it I'm in here fixing other people's shit

soft shard
twilit hamlet
void basalt
#

So I'm writing a netcode framework and I'm working on audio, but I have no idea where to start. Looking for ideas.

If I literally roll back the audio source state, and fast forward it's time attribute during the rollback stage, do you think the audio will be poppy or glitchy?

#

There's like nothing on the internet about this stuff

leaden ice
leaden ice
#

Or are you talking about... voice chat or something?

void basalt
#

generally guns have a shoot sound

#

basically everything in my NetworkFixedUpdate() loop gets rolled back

#

so right now it would basically just play a bunch of overlapping sounds

#

since I don't know how to properly rollback audio

neat lagoon
#

you just dont play the audio while replaying from a rollback

leaden ice
#

I don't think you can really "roll back" audio but you can stop the clip that's playing in progress

void basalt
#

Yeah I thought about just skipping new audio playback during rollback

#

but how? Without a code generator?

#

If I disable the audio source, currently played audio stops playing even when re-enabled

leaden ice
#

I feel like you as the framework author just need to notify the user that their state was rolled back somehow and handling the audio consequences of that are up to the user

void basalt
#

I mean I could include in the documentation that you need to wrap your audio.play in a if (!Networking.isrollingback)

#

that just seems sort of gross

neat lagoon
#

usually you literally have a boolean for your game state logic like "isReplaying"

void basalt
#

alright yeah

#

I guess that works

#

Does Physics.Simulate() also tick particle systems?

#

the particle systems have their own Simulate() so I'm gonna assume it doesn't. The docs just don't state anything about it

leaden ice
leaden ice
twilit hamlet
hoary sparrow
#

How would you like it to move instead?

#

I have a weird issue with Gizmos, as I'm trying to draw spheres in a circle, but at certain intervals they start not drawing a full circle, where did I mess up the maths/code?

#

(the third pic shows up how it should be)

quartz folio
#

You should make sure your divisions always use floating point maths

safe knoll
#

@void basalt Some ideas: You could have some sorta effects manager that you trigger your effects through. (sfx, vfx whatever you dont want to replay during a rollback). It could track the ID of a sfx and the frame it was played,
when you do a rollback and replay through the frames it will have the info to know that an sfx of that id was already triggered on that frame, so ignore it.

hoary sparrow
#

oh, so I just gotta add the "f", right?

quartz folio
#

360 should be 360f, yes

hoary sparrow
#

it works now, thank you!
I always forget about adding it

potent sleet
#

dont crosspost next time :p

void basalt
#

I wonder if its possible to directly alter the unity API. Like run some custom code right after AudioSource.play gets called

cosmic rain
#

Unless you have the The Enterprise license(I think), you don't have access to the source code. At least not to modifying it. So, no.@void basalt

void basalt
#

all on a dynamic basis

cosmic rain
void basalt
pine coral
#

So im sending data to unity through a serialport with an arduino, although while reading the line, it appears to be either reading it twice or somehow getting another line (which is giving me errors about the index being out of bounds)

plucky karma
frigid anvil
plucky karma
#

Or why not OnAudioFilterRead()?

frigid anvil
pine coral
devout solstice
#

Im in a bit of trouble here

pine coral
#

So it logs 2 entrys, the main one which is right, then a second one that is just wrong and im not sure where its coming from

devout solstice
#

Its kind of hard to explain but I'll try

#

I have a rectangle right, and I'm trying to set the variable LoadingBarObjX to the rectangles current size, so I have it getting set every frame, however I also want to subtract a value from LoadingBarObjX and apply the new value to the rectangles current size

#

However it seems due to LoadingBarObjX constantly getting set to the current size I can't subtract the value

devout solstice
#

Actually might've just found something

pine coral
# frigid anvil Buffer overflow?

Well, I figured out the issue, just not sure why the issue occurs, I have 2 if statements that shouldn't be active, but for some reason, those not being commented out sends a shorter array in the debug log

#

But the thing is, the thing they send to the debug log isn't even what shows up

frigid anvil
#

Debugging: Why doesn't this work? Ah! I see the problem! Wait... Why did this EVER work? 😉

devout solstice
#

Ah shit nevermind still doesn't work

pine coral
#

Yea true, but im honestly confused because why do 2 if statements not being commented out send an extra array to the debug log?

frigid anvil
pine coral
#

Give me one moment

devout solstice
#

Anyone got any ideas for me?

frigid anvil
pine coral
ionic socket
#

me reaping: "I don't need to make these classes and function calls flexible for a wide range of uses, i'll just code up specific ones as needed. I'll be able to get moving faster, I'll come back and refactor them later!"

me sowing: "Aww man I did Step C like 5 subtly different ways, now I really need to refactor this code to cover the core use cases in a generic, reliable way"

devout solstice
#

I am beyond confused, I have variable LoadingBarObjX set to 1 and an if statement that should activate if LoadingBarObjX > 1 however when I put LoadingBarObjX > 1 in the if statement it doesnt work, what does work is LoadingBarObjX < 1

frigid anvil
pine coral
frigid anvil
frigid anvil
pine coral
#

Ah I see

ionic socket
devout solstice
#

Alright I figured it out for some reason the script thinks that the localscale x is negative

devout solstice
#

Is there a way to only activate a method when the script is added to an object? Not when the scene loads or anything ONLY when the script is added to an object, I want the method to be run once and that is it

devout solstice
#

Alright well I got it working how I want it

#

No there wasn't an easier way to make a loading bar fuck you

#

My loading bar is best loading bar

ionic socket
#

how to check if a List<T> is a list of any type (or a HashSet, Stack, etc)?

leaden ice
#

Do you want to know if it's an IEnumerable?
An IList?
An actual List?

ionic socket
leaden ice
#

List<T> implements all of these interfaces

ionic socket
#

shorts answer is I wanted a List of lists where each individual list may be of a different <T>

leaden ice
#

List<IList> would do it

ionic socket
#

gotchya!

obtuse cedar
#
    IEnumerator EmitRoutine(ParticleSystem.EmitParams @params, ParticleSystem.ShapeModule shape)
    {
        print("starting emit routine");
        float timer = 0;
        print("time at emit start is " + Time.time);
        float timestart = Time.time;
        float particleDur = ParticleDuration * 60;
        print("particledur is " + particleDur);
        while (timer < particleDur)
        {

            shape.rotation = TargetTransform.rotation.eulerAngles;
            @params.position = TargetTransform.position;
            Particles.Emit(@params, ParticlesToEmit);
            print("timer is " + timer + " at " + (Time.time - timestart));
            yield return new WaitForSeconds(EmissionRate);
            timer += 60 * EmissionRate;
            //yield return null;
        }
        print("time at end is " + Time.time);
        float timediff = Time.time - timestart;
        print("time diff is " + timediff);
        print("emit routine finished");
    }

I made this coroutine for intermittently emitting particles but the time difference is about 1 second longer than the duration I specified
I'm guessing I should rely on delta time and check if I passed a certain amount of seconds instead of relying on waitforseconds?

#

Or is my math wrong?

south crag
#

Anyone has code examples on how to update a mesh using the new API every frame that varies in #vertices? My concern is I'm not sure if I should recreate the VertexAttributeDescriptor each frame and set it via SetIndexBufferParams/SetVertexBufferParams, or there is other better ways. Would be nice to see what the optimal way of doing this.

simple edge
# obtuse cedar Or is my math wrong?

Your math is a bit wrong, but I would do like you said
You'd have to take into account that WaitForSeconds is not super accurate, and typically is slightly delayed by a few ms
I don't see what EmmisionRate is, but if this is very low, then eventually this may add up

vague tundra
#

Does anybody know where I can find a big list of Unity Exceptions?

obtuse cedar
merry sierra
#

i am trying to load asset bundles from the server and now it downloads every time i open game any solution for this?

thin aurora
#

If you want it to be accurate, rely on Time.DeltaTime within Update

#

You can replicate a second by doing something like this:

float _interval;
void Update()
{
  this._interval+= Time.DeltaTime;
  if (this._interval < 1) return;
  _interval -= 1;

  // Behaviour here
}
#

_interval -= 1; is important as setting is to 0 can still make it inaccurate, since it's never going to be exactly 1 second

#

I think this is as accurate as you will get it

obtuse cedar
#

ah cool I get it
thank u very much

#

here i was thinking i needed to use modulo

sour trench
#

I have a problem that I can't come up with a good solution for. Basically I have scriptable objects for my weapons, each weapon has a set of abilities it can perform. The problem is that some of the ability properties should come from the editor, such as icon, description and cooldown so you can easily change them without diving into the code, while the name and method have to be set through the code because I can't expose the method (it can't be a UnityEvent because I need a return type other than void). The issue I'm having is that if I create the abilities list in the constructor any changes later after the scriptable object is created it won't obtain. Equally with the OnValidate I have to check for existing abilities in the list before I attempt to add them or replace the list entirely, otherwise I will always lose info that I set via the editor.

One way I could work around this would be to have a separate list altogether where you specify the icon, description and cooldown which are then mapped to the abilities list. However I don't think this is optimal either if the abilities list changes then the lists would be out of sync instantly..

Does anyone have a good idea how I can approach this?

thin aurora
#

But yeah there are other ways. This is just what I thought of

obtuse cedar
#

yeah can't, i was just overthinking it

thin aurora
#

You can probably use Coroutines in some way too

obtuse cedar
#

yeah i got it working thanks

#

time difference is a lot better now

frigid anvil
sour trench
#

@frigid anvil Not sure what you mean by that?

frigid anvil
sour trench
#

@frigid anvil Well if I could I would, but I can't get it to show up in the inspector without using UnityEvent, since I need bool as a return type and not void I have to use a custom delegate:

    public delegate bool MethodAction(BaseController caster, BaseController target, bool canPerformAbility);
    public MethodAction method;

    public AbilityInfo(MethodAction method, ... other stuff)
    {
        this.method = method;
        ...
    }

Which is then used like:

    new AbilityInfo(nameof(Stab), Stab);
    ...
    public bool BasicAttack(BaseController caster, BaseController target, bool canPerformAttack) { ... }
frigid anvil
thin aurora
# obtuse cedar time difference is a lot better now

Just remember it's never exactly one second since you will always be frame depentent. So _interval can end up as 1.1 for example, because Time.DeltaTime was around 0.1 because of a lag spike, but there is no way around that as far as I know

sour trench
golden vessel
#

Hey, got a question about code design. I'm struggling to think of a way to make my character not move because there's so many reasons why he shouldn't move. I initially had one boolean, but that doesn't work very well since multiple scripts interacted with it, for example quitting a dialogue would make him move while the player was still in a cinematic part. The way I make it work now is to have lots of booleans for the check on the condition, like if(inTransition || inDialogue || ...){movement = new vector2(0,0)}, but it's still very confusing. Any tips on how to make it simple?

frigid anvil
golden vessel
#

(there's supposed to be || instead of spoilers)

sour trench
# frigid anvil So...for instance, a player's gun would have...'shoot' and 'bash' options? I'm ...

Yeah or a sword could have "stab", "slash", "swirling tornado" etc etc. The bool is used to determine whether or not the attack was actually performed or not, which I can then act on:

        bool didPerformAbility = abilityToPerform.method.Invoke(GameManager.instance.player, currentTarget, CanPerformAbility);

        if (didPerformAbility)
        {
            if (abilityToPerform.cooldown > 0)
            {
                PlaceAbilityOnCooldown(abilityToPerform);
            }

            ...
        }

I'm trying to think if the CanPerformAbility logic should be refactored out of each ability though.. that way it could be possible to skip the return type because the ability would always be performed.

frigid anvil
#

...and then leave it up to the weapon's performAbility code to figure out which ability to do? That pushes the behavior to...where the behavior lives, really, instead of pushing the complexity of behavior to...everywhere else.

frigid anvil
slow tree
#

can we trigger bake lightmap with code?

sour trench
#

@frigid anvil Yeah that is fine, usually if I run into a wall I have to do a complete rethink of the design which usually works out. I can't remember why I baked it into each ability to begin with, will check the possibility of breaking it out again.

frigid anvil
sour trench
#

@frigid anvil That rings too true.. 🥹 Trying to future-proof your code is not worth it I've found, still struggling to get the habit out of my system but I'm slowly getting there...

solemn glade
#

is there a way to save a dictionary to a json file?

low scaffold
solemn glade
#

thanks both of you ill try out :)

frigid anvil
solemn glade
#

yea ok

vague slate
#

How do I make a LocalizedString with specific arguments through code?

hoary crest
#

How can we save the light state between scenes?

autumn cipher
#

when you create different ScriptableObjects as .asset files, do the methods inside them also get instantiated?

#

holding methods on another regular class would be better I guess

hexed pecan
#

They have the methods that that particular scriptableobject class has

low scaffold
#

What are you looking to achieve?

autumn cipher
#

even if that's what's happening

low scaffold
plain yacht
#

@autumn cipher If you have a method that doesn't require state then you can mark it as 'static', that way all objects will share that method.

plain yacht
#

No problem!

Do keep in mind though that having objects that encapsulate both state and behaviour is what OOP is all about. If you want a set of data containers to execute methods defined elsewhere against then I think thats probably closer to the ECS way of doing things.

autumn cipher
plain yacht
#

As often in programming you don't get "more" you get "different".

autumn cipher
#

I want to learn ECS but I fear that not many employers might want ECS from me

#

so I'm doing it the common OOP way

plain yacht
#

Last I looked at the Unity dots/ecs side of things it didn't feel very mature.

#

But that was like 3 years ago.

autumn cipher
#

should be a lot better now but yeah, best to go with the stable way

plain yacht
#

ECS can be more performant, so if you want to build a strategy game with thousands of units on screen then ECS is a better fit.

frigid anvil
#

Yeah; that's the whole, 'Build it the old way, because you can get more help with it. If you ever get to the point that you need ECS, then you'll know you need it, and be better prepared to change to it.'

autumn cipher
#

what is a proper way to make a backup of the project, is it just copy pasting the folder?

#

I'll try implementing a networking solution so I wish to make backup in case it gets ruined

thin aurora
#

And push it to a repository over on GitHub

#

Git supports "branches" and your networking solution can be developed in a seperate branch whilst your main branch is left unchanged

autumn cipher
#

damn, it's time to dive into that git stuff

#

thanks

thin aurora
#

Not just code related either

autumn cipher
#

or was it something else related to github? I don't remember

frigid anvil
#

Yeah, version control is...pretty key. Even for test projects, if I get to more than one or two scripts, or I start customizing assets, then I create a git project, and commit regularly, even if I don't push it anywhere.

thin aurora
#

Init in a folder, add a gitignore for the language you use, and done

#

Optionally create a dev branch and start development

#

You can't really go wrong with it. Just fix your mistake and commit the changes

rancid pond
#

I am adding line renderer in runtime. The thing is that line is purple since there is no material getting added to line renderer component. how to fix this

thin aurora
#

Or, you know, revert

hexed pecan
frigid anvil
#

Git has...some pretty spectacular failure modes, but for simple use, it should indeed be...simple. Just...commit regularly, and make sure all your assets are tracked in it. There are publicly available .gitignore files for Unity that will be very helpful, because there are folders you don't want to track.

vast matrix
#

Is there a way to combine a UploadHandlerFile with the multipart form data?

var webRequest = UnityWebRequest.Post(requestData.url, new List<IMultipartFormSection>() {
            // new MultipartFormFileSection("vanillaZip",await File.ReadAllBytesAsync(tempPath) , "0.0" + ".zip", "application/zip"),
            new MultipartFormDataSection("version", "0.1"),
            new MultipartFormDataSection("bundleHash", "asfasfas")
        });
        webRequest.uploadHandler = new UploadHandlerFile(tempPath);
        webRequest.uploadHandler.contentType = "application/zip";

e.g moving from the FormFileSection to the UploadHandler. The file in this case is large (1-5GB) and the file section won't chunk or stream, requires the entire thing in memory

devout solstice
autumn cipher
#

I should probably upload the resources on dropbox or something

#

nvm this is getting too out of topic

frigid anvil
#

That's what git lfs is for, but yeah...

thin aurora
#

You can make a pretty big repo, but not push files like this in a regular repo

#

Although you might get an email from them if your repo becomes too big

autumn cipher
thin aurora
#

Why do you have a 100MB file anyway

devout solstice
#

how would i make a proper loading bar? because rn i’ve just got it so the dev sets how long they want it to load, how do i make the loading bar actually go based off how much has loaded?

hexed pecan
#

Looks like a model file with textures embedded.

autumn cipher
devout solstice
#

I don’t even know if there would be a point in that because it seems like unity instantly loads everything

hexed pecan
devout solstice
#

really that’s it?

#

Oh wait

hexed pecan
#

Well, otherwise it will load in one frame

devout solstice
#

the loading

#

how tf would i do that

hexed pecan
#

What are you loading?

devout solstice
#

the scene

#

I want it like a loading bar you see in games

hollow stone
#

Scene you can load async and use the loading % to update the bar.

autumn cipher
# devout solstice I want it like a loading bar you see in games

Let's create a progress bar!

● Download the scene: https://www.assetstore.unity3d.com/#!/content/40756?aid=1101lPGj

● Written tutorial by Alan Zucconi: http://www.alanzucconi.com/2016/03/30/loading-bar-in-unity/

♥ Support my videos on Patreon: http://patreon.com/brackeys/

······································································...

▶ Play video
#

also has percentage showing (optional)

hollow stone
#

Other loading operations you would need to manually compute how much you've completed and update the loading bar accordingly (in turn requiring it to be async to update the rendered bar)

devout solstice
#

I have a loading bar made just need to get it to go based off how much has loaded

#

wdym other loading operations? like loading scripts or something?

hexed pecan
autumn cipher
hollow stone
devout solstice
devout solstice
#

which is kind of annoying but playerprefs is annoying to deal with and idk how else to do it

hexed pecan
#

If you want values to persist between scenes, you can use DontDestroyOnLoad

#

Or another way of saving

devout solstice
#

does that include stopping and playing the scene in the editor?

hexed pecan
#

Like entering/exiting playmode?

devout solstice
#

yea

hexed pecan
#

No, DDOL doesnt help with that

#

You need to save it to the disk

devout solstice
#

damn

hexed pecan
#

You can always learn to save data?

devout solstice
#

yea

#

oh also

hollow stone
devout solstice
#

How do i have a method in my script only run when the script is added to a game object? onenable seems to also run it when the play mode starts

devout solstice
#

oh alright nice

#

idk it seems like it’s what i need

#

alright well thanks for the help

mighty ivy
#

Hi, is there a version of TryGetComponent where the output is a list/array of components? (e.g. used for getting all colliders from an object)

#

A bit like GetComponents

hexed pecan
mighty ivy
#

mmh okay thanks

#

like that?

hexed pecan
azure heath
#

I've a basic form of Snake, where the body parts follow the player head position using a Vector 3 List of positions - however, as I pick up body parts, the distance between the body parts and the head seems to increase. Any idea why that might be happening?

#
// Move body parts
        int index = 1;
        foreach (Follower body in Convoy)
        {
            int queuePosition = Mathf.Min(index * Gap, PosHistory.Count - 1);

            Vector2 point       = PosHistory[queuePosition];
            Vector2 pointAhead  = PosHistory[queuePosition - 25];
            body.MoveFollower(curSpeed, point, pointAhead);
            index++;
        }
merry sierra
#

currently i am downloading the file which is in File format is there any way that we can change the format of that file in unity at runtime?

main shuttle
#

You are missing using statements? Your IDE should suggest which one you should be using.

#

If not, do you have the advertisements asset installed?

#

The piece of code you took must match the version you have installed in the package manager.

#

So you do have the using statement then

#

This is getting rather confusing for me too 😅

#

Sorry, I can't help then. If you have the using statements, the package is installed, and the SDK is initialized that's all there is to it afaik. That last part isn't needed for it to recognize your interfaces. So I don't know 🤷‍♂️

hexed pecan
#

He said he does not have the using statements 🤔

#

.

main shuttle
#

Yeah, I would think that means he added them after noticing that. 😛

hexed pecan
#

I'd hope so heh

#

Nah you don't need System.Collections.Generic etc if you don't use those (List<T> etc)

main shuttle
#

This is fine, you have the Advertisements statement.

#

Is your IDE configured? If so, your code editor does recognize the interface.

#

I never know with VSC

hexed pecan
#

Also not sure how "Restricted mode" affects things, might wanna disable that

#

If you cant get it to work, switch to VS 2022 or something

blazing radish
#

hello

main shuttle
#

Then it's not configured, VSCode is a pain in the ass to setup, that's why I would advise against it.

blazing radish
#

is there an coding help channel?

main shuttle
#

I have no idea, don't think the ids by itself are harmful, but you can delete them for safety

#

Don't hand out the passwords though 😛

thin aurora
#

I mean you probably just need to put using UnityEngine.Advertisements; at the top of your file

#

The docs that were linked mention it and it's pretty obvious since everything has their namespace

main shuttle
#

He has that, we checked.

thin aurora
#

Then he has not properly loaded the dll

main shuttle
#

Yeah, his IDE wasn't setup. VS Code again..

#

So either the code he used isn't valid with the advertisement package he downloaded, or the dll isn't loaded.

blazing radish
#

is there anyone familiar with photon?

prime sinew
devout solstice
#

How do i make my code look more professional? I look at unitys code and it looks like something idk what, and mine still looks like the code i was writing when i started learning c#

#

By that i mean the layout of it all

vagrant blade
#

You'll create your own style over time. The important thing is to be consistent with it.

fringe ridge
#

So, you cannot set a block of pixels on texture2d.SetPixels without having a huge array filled with colors? What if I need only one color to be set for a block of 200x200? DO i have to fill a 40000 array with just color32.black?

#

this seems just plain stupid

rain minnow
main shuttle
#

Why not make it 1x1 then? And just let it stretch out?

fringe ridge
#

but that would still take 40000 iterations

#

it's just an example,

late lion
main shuttle
#

Well, the example is weird, this is like saying a hammer is bad at cleaning a floor.

fringe ridge
#

no wait

late lion
#

Oh sorry, you mean you want to set the same color to all pixels?

fringe ridge
#

I need one color to be set on a block of pixels

#

this will need to be done a lot on blocks of 40 x 40, so i'm worried on performance

#

I really doubt i need to fill 1600 arrays with one color or iterate 1600 times to set a block of pixels to one color

late lion
#

I misunderstood, my bad.

fringe ridge
#

no worries

woeful leaf
late lion
fringe ridge
#

ah, well thanks

#

I will have to find a better solution then, because killing old android phones just for a pixel art canvas sounds excessive 😄

#

I still don't understand how there isn't a better solution to setting a block of pixels to one color

main shuttle
#

Repeating information is always bad. So I have no idea why you think you need 40x40 of the same information. Just stretch it out when you use that information somewhere.

devout solstice
wet furnace
#

That is, if these two red objects collide with each other, then the objects, i.e. the black boxes, will be perfectly connected. firstChild.transform.position = secondChild.transform.position + Vector3 offsetValue (HOW calculate?) (it is 2d game)

fringe ridge
rain minnow
rain minnow
main shuttle
# fringe ridge I need it to be drawn on users screen

So divide everything by 40, and all pieces are 1x1, and if you use that on a pixel perfect/no aniso/no compression texture it should still look the same.
Then you don't have to repeat anything and it's hundreds times faster.

fringe ridge
#

That might work. Dont have a lot of experience with textures, thanks.

vagrant blade
devout solstice
#

I’m not I just want my code to be neat and organized

#

and categorized, i probably want to categorize things too much

#

but to me categorized is organized

#

and it tells me what everything does and what it’s apart of

woeful leaf
late lion
# fringe ridge I still don't understand how there isn't a better solution to setting a block of...

If you're only ever writing to this texture and never reading from it, then it would be faster to do it with a RenderTexture on the GPU. You won't be able to read pixels, because it will be stored in GPU memory, but writing will be much faster because the GPU is designed for that. Then you can do something like:

RenderTexture.active = yourRenderTexture;
GL.Viewport(new Rect(x, y, width, height));
GL.Clear(clearDepth: false, clearColor: true, backgroundColor: Color.black);
#

The GL.Viewport will constrain the clear operation to the rectangle you specify.

devout solstice
#

what is record used for? Usually you guys explanations are easier to understand then microsoft

#

also what does mutable mean?

late lion
swift falcon
late lion
devout solstice
#

So what i thought static was and then realized wasn’t

#

the actual definition of static

swift falcon
late lion
# devout solstice but what about this?

record was added to make it easier to define classes that behave like immutable value types, which has more obvious benefits in more business oriented software development, like interacting with databases.

#

record is a class, but automatically generates boilerplate code you would otherwise have to write.

devout solstice
#

Ok, god so much of this stuff isn’t what it’s name would suggest

woeful leaf
# rain minnow Thanks, got it . . .

I think in general it was just more examples of just using the instance without replacing the instance/without using all the static functions

#

(iirc)

devout solstice
#

what does this mean?

leaden ice
devout solstice
#

oh wait i see

leaden ice
#

e.g. instead of a * b / c do a * (b / c) to make it clear

devout solstice
#

i didn’t read the example right

devout solstice
#

instead of b/c * a

leaden ice
#

sorry yes this will change it

devout solstice
#

yea

leaden ice
#

I'm tired

devout solstice
#

i was about to say oh shit my codes wrong

#

because i have something that needs to be divided and then multiplied by another number in that order and not divide the sum of the two multiplications

azure heath
#

I've a basic form of Snake, where the body parts follow the player head position using a Vector 3 List of positions - however, as I pick up body parts, the distance between the body parts and the head seems to increase. Any idea why that might be happening?

#

Relevant code's probably in Fixed Update...

leaden ice
prisma birch
#

When making an array of a custom class or struct, Unity makes this messy looking inspector. Is there any way around this other than making the array [NonReorderable] ? That works fine but obviously you lose the ability to reorder which is nice 😅

polar marten
#

this is a known bug in early 2021 LTS versions

prisma birch
trim schooner
#

'twas fixed ages ago

#

I wanna say around 2021.3.5..?

prisma birch
#

Ha of course. I've been on 2021.3.4 forever

polar marten
#

i was just as livid as you

#

"how could this be around for 4 versions"

prisma birch
#

Thought that was just something I had to deal with! I've been making all of my arrays non reorderable

#

was getting sick of it

polar marten
#

i don't know dude. QA is a clusterfuck

prisma birch
#

Switched from Visual Scripting to proper C# after going on 2021.3.4 and haven't known anything different, just thought it was something I had to deal with lol

azure heath
#

Also, can anybody remember what the parent class for a TMPro text component is?

polar marten
#

ugh i wanted to teach this man to fish!!

leaden ice
#

oh sorry

polar marten
#

lol

azure heath
#

I'm using Visual Studio - help me fish! =)

polar marten
#

i think Visual Studio has Show Hierarchy somewhere

azure heath
#

But I appreciate the fast response from Praetor, I'm trying to get this done.

leaden ice
azure heath
#

Wilco.

#

I've got 'View Call Hierarchy', but I don't think that's the same.

polar marten
#

do you have Resharper?

azure heath
#

Doctor, I don't know what that is. Is it fatal?

polar marten
#

it's the jetbrains C# plugin for visual studio

#

it was big even in 2013

#

give it a try if you like VS

polar marten
azure heath
#

I'll look into it. I don't really have a preference for an IDE, happy to take suggestions.

leaden ice
azure heath
#

Either way, delighted to have TMP_text - I know you'd told me that before, Praetor, but I was wading through TMPro docs and trying to find that piece of info and going a little crazy.

#

Rider, c'est combien?

polar marten
#

it's like $25 or something

#

i don't know

azure heath
#

I'll look it up, thanks anyhoo.

polar marten
azure heath
#

Eep:

polar marten
#

or is it that you finally configure VS Code and then shoot hartman?

#

i don't know

#

joker: "Are those... live prices?"
pyle: "seven six two euros... including VAT"
(pyle smiles grotesquely)

#

@leaden ice pretty nuanced

azure heath
#

Not looking to rush you, @leaden ice , just checking - are you taking a look at those scripts, or can I check in on an friend?

#

I'm gonna phone a friend, will check back shortly--!

celest crystal
#

Hello,is there anyone know how to convert quaternion from ue4 to unity?(I want to use the characters in ue4 to control the characters in unity to do the same action,tried many ways,but failed)

honest plinth
#

Hey. Can you tell me please how i can get child object (Blue Key) with Box Collider in parent (Object) with Box Collider by Raycast? ( Two objects have Interactable layer ). Try get name child object by 'hitInfo.collider.transform.name' don't work. You have any idea?

sweet current
#

But make sure to somehow use a layermask to make sure that you don't do that on everything. Like if you have a raycast-collision with a humanoid rig, GetComponentInChildren<Interactable> would search every bone that thing has.

honest plinth
sweet current
#

Okay "bad performance" yeah. In tutorials, people tell you to cache components that **can **be cached, like your playerControllers rigidBody where you use the same component every frame, it would be a waste of processing power to fetch that thing every frame.

In other cases like when you run around in game and you point at things and you want to check if they are interactive, theres no way to have cached that, you need to GetComponent<> on that object your raycast hits, like you already do. That's okay.

GetComponentsInChildren can be more expensive, especially if it is used on objects with a bigger hierachy where nothing is found, so the whole hierachy is searched. That's why i recommended to use a mask to make sure the ray only hits gameObjects that are okay to search.

crystal sky
#

Hi Im Working on Script That Reset Player Stats Every Monday is This Will Work ??

devout solstice
sweet current
honest plinth
azure heath
#

@devout solstice , whatever gets the job done, right? =)

devout solstice
#

Yea, i never configured visual studio code and it works fine for me

azure heath
sweet current
honest plinth
spiral robin
#

I'm trying to get the text from an Input field but I get the "Object reference not set to an Instance of an object" error. What's wrong here?

using UnityEngine.UI;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GetFieldInput : MonoBehaviour
{     
       void Update()
       {

        Debug.Log(gameObject.GetComponent<InputField>().text);

       }

}```
hexed pecan
hexed pecan
#

Change InputField to the correct type

leaden solstice
spiral robin