#archived-code-general

1 messages · Page 26 of 1

mental rover
#
  1. you will need a VR headset - there's a bunch of tutorials for getting it set up to be recognised in Unity, do this in an empty project so you can test what you make
  2. look into the XR Interaction Toolkit package - it's Unity's out-of-the-box solution for XR input and interactions, and can be a starting point for understanding how VR input works

otherwise it's mostly overlap with standard C# and Unity concepts - the only real difference is a very different way of processing input

woeful leaf
#

Quick question, do IPointer Events handle rotations well?

#

e.g if an object is constantly slowly rotating, does it still register IPointerEnter properly?

woeful leaf
#

Idunno

#

Wonky hitboxes but it could be other issues ¯_(ツ)_/¯

kindred pollen
#

Ehyy
Apparently I cannot build any project, can anybody help me?

slow crag
#

I've got a bit of a tough problem that I'm not sure how to approach. When my perspective camera is angled down, I grab screen positions of the 4 corners and project them onto the world. I need to find all regions inside of those 4 corners. Regions are just sets of 12x12 tiles.

I could draw a straight line from each corner,, see what tiles that line crosses and get the edge regions like that, but how can I get the center regions?

#

For example, the region in the center (111) isn't touching any corners, but I still need to check if its inside
This will be checked basically every frame and will be used for a system to cull the shadows outside of the player's view to improve performance, so this should be as fast as possible

thin aurora
#

What goes wrong

#

Error

#

Anything

kindred pollen
#

I can paste the errors, they are pretty long

#

Internal build system error. Backend exited with code 2.
STDOUT:
Finished compiling graph: 243 nodes, 756 flattened edges (756 ToBuild, 0 ToUse), maximum node priority 152
[ 1/242 0s] WriteText Library/Bee/artifacts/emscripten/gjrl9/wrapper_emar.bat
[ 2/242 0s] WriteText Library/Bee/artifacts/emscripten/v7znj/wrapper_emcc.bat
[ 3/242 0s] MakeLump Library/Bee/artifacts/WebGL/il2cpp/master_WebGL_wasm/3o8n_System0.lump.cpp
[ 4/242 0s] MakeLump Library/Bee/artifacts/WebGL/il2cpp/master_WebGL_wasm/5ay2_System1.lump.cpp
[ 5/242 0s] MakeLump Library/Bee/artifacts/WebGL/il2cpp/master_WebGL_wasm/y8mn_vm6.lump.cpp
[ 6/242 0s] MakeLump Library/Bee/artifacts/WebGL/il2cpp/master_WebGL_wasm/wj5b_System1.lump.cpp
[ 7/242 0s] MakeLump Library/Bee/artifacts/WebGL/il2cpp/master_WebGL_wasm/wj5b_System0.lump.cpp
[ 8/242 0s] MakeLump Library/Bee/artifacts/WebGL/il2cpp/master_WebGL_wasm/y8mn_vm4.lump.cpp
[ 9/242 0s] MakeLump Library/Bee/artifacts/WebGL/il2cpp/master_WebGL_wasm/jkdf_Posix0.lump.cpp
[ 10/242 0s] MakeLump Library/Bee/artifacts/WebGL/il2cpp/master_WebGL_wasm/wj5b_System2.lump.cpp

#

BuildFailedException: Incremental Player build failed!
UnityEditor.Modules.BeeBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args) (at <11d97693183d4a6bb35c29ae7882c66b>:0)
UnityEditor.WebGL.WebGlBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args) (at /Users/bokken/build/output/unity/unity/PlatformDependent/WebGL/Extensions/Unity.WebGL.extensions/BuildPostprocessor.cs:179)
UnityEditor.Modules.DefaultBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <11d97693183d4a6bb35c29ae7882c66b>:0)
UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.Int32 subtarget, System.String installPath, System.String companyName, System.String productName, System.Int32 width, System.Int32 height, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at <11d97693183d4a6bb35c29ae7882c66b>:0)
UnityEditor.GenericMenu:CatchMenu(Object, String[], Int32)

#

Build completed with a result of 'Failed' in 113 seconds (112880 ms)
UnityEditor.GenericMenu:CatchMenu (object,string[],int)
UnityEditor.BuildPlayerWindow+BuildMethodException: 3 errors
at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002da] in <11d97693183d4a6bb35c29ae7882c66b>:0
at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in <11d97693183d4a6bb35c29ae7882c66b>:0
UnityEditor.GenericMenu:CatchMenu (object,string[],int)
[Version and Build] Build failed! 00:01:52.8795867
UnityEngine.Debug:LogError (object)
Unity.Play.Publisher.Editor.PublisherBuildProcessor/<WaitUntilBuildFinishes>d__7:MoveNext () (at Library/PackageCache/com.unity.connect.share@4.2.3/Editor/PublisherBuildProcessor.cs:77)
Unity.EditorCoroutines.Editor.EditorCoroutine/YieldProcessor:MoveNext (System.Collections.IEnumerator) (at Library/PackageCache/com.unity.editorcoroutines@1.0.0/Editor/EditorCoroutine.cs:80)
Unity.EditorCoroutines.Editor.EditorCoroutine:ProcessIEnumeratorRecursive (System.Collections.IEnumerator) (at Library/PackageCache/com.unity.editorcoroutines@1.0.0/Editor/EditorCoroutine.cs:134)
Unity.EditorCoroutines.Editor.EditorCoroutine:MoveNext () (at Library/PackageCache/com.unity.editorcoroutines@1.0.0/Editor/EditorCoroutine.cs:115)
UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()

#

Also, I looked online for solutions and tried to apply them but none worked

#

They were like reinstalling the hub, the version, Disabling Development builds, Changing the IL2CPP Code Generation to Smaller (Faster) builds, changeing the Managed Code Stripping level in the player settings to a higher value

#

Or even deleting Bee folder

#

This is the error screenshot

#

(Thank you guys in advance)

#

Like, it doesen't even allow me to build blank projects

next seal
#

If someone could help me here I'd be so happy

kindred pollen
#

Yeah Kinda forgot the existence of threads, I'll open one in hope anyone can help me, since this problem makes me unable to do pretty much anything

#

Unable to build

swift falcon
#

What's the next best thing to a null Vector2? I want to declare it but don't want to initialize until I check if it's null in Awake(). If it's not I want to leave as is

woeful leaf
#

Vector2.zero

swift falcon
#

Aight thanks

lucid valley
lucid valley
#

makes it nullable

swift falcon
#

Oh great

lucid valley
#

value types by default cant be null, but you can make them be able to be

swift falcon
#

Makes it better. Will avoid possible hiccups. Thanks

swift falcon
lucid valley
swift falcon
#

I got an if right before that assigns it a value. And thanks 💯

long fox
#

!ide

tawny elkBOT
#
💡 IDE Configuration

If your IDE is not autocompleting code
or underlining errors, please configure it:

Visual Studio (Installed via Unity Hub)
Visual Studio (Installed manually)

VS Code*
JetBrains Rider
Other/None

*VS Code's debugger plugin is unsupported.
We recommend using VS or Rider instead.

ember cedar
#

why my player following script for enemy doesnt work

warm wren
halcyon nimbus
#

looks like it inherits

warm wren
#

oh wait nvm

ember cedar
lucid valley
ember cedar
#

oh thanks

halcyon nimbus
#

how does Start method work with inheritance?

#

especially if its private

lucid valley
#

it follows the top most class, otherwise you'll need to make it virtual and override and call base

#
public class Base : Monobehaviour 
{
    public void Start()
    {
      Debug.Log("0");
    }
}
 
public class Inherit : Base 
{
    public void Start()
    {
      Debug.Log("1");
    }
}
 
public class LastInherit : Inherit 
{
    public void Start()
    {
      Debug.Log("2");
    }
}
#

e.g "2" will be the only thing printed in this example

vague slate
#

I'm looking for a way to have some callback on play mode stop. Is there a way to do so?
I tried this, but no OnDestroy is called for this game object for some reason

                var disposer = new GameObject { hideFlags = HideFlags.HideInHierarchy }
                    .AddComponent<CustomSourceDisposer>();
ember cedar
lucid valley
ember cedar
#

no

#

programming isnt my strongest side

halcyon nimbus
lucid valley
# ember cedar programming isnt my strongest side

I got some requests on how to use debugging for C# code in Unity projects and Visual Studio so here is an example project with a UI panel in which I show you how to use the debugger and breakpoints.

You can download the free community edition of Visual Studio 2019 here:
https://visualstudio.microsoft.com/de/downloads/

Debugging is essential wh...

▶ Play video
lucid valley
ember cedar
halcyon nimbus
lucid valley
#

good to know

zinc parrot
#

so I havent touched native plugins yet, but I want to for one reason: bindless textures
so I am wondering if there is a way to pass a compute shader from unity to the native plugin, have the plugin assign a bindless texture array to the compute shader, and then unity run the compute shader?
I am having a hard time finding what is exposed to native plugins

swift falcon
#

Does drawing over a tile using the 2D TilePalette replace the tile or does it add a layer?

swift falcon
potent sleet
#

you need to add another tilemap to "draw" ontop

#

or it replaces it

swift falcon
#

Ok ok

#

Thank you 🙏

digital gull
#

OnFoo += Bar; OnFoo += () => Onfoo -= Bar;

is that a valid way to make sure I unsubscribe to the event right after the event happens?

#

I mean it works I'm just worried it's bad practice. For example if the event delegates get calld in not the subscribed order

mental rover
#

the anonymous delegate wont be unsubscribed this way

#

I'm not sure if that would manifest as a problem depending on use though

digital gull
digital gull
leaden ice
mental rover
digital gull
#

ahh i see

#

still wrapping my head around lambdas, thanks for the heads up

#

i thought the content of the lambda was OnFoo -= Bar

#

oh nvm

#

i think i see what you mean. the lambda isnt being unsubscribed

leaden ice
#

And it never can be since you don't have an independent reference to it

digital gull
#

right the unsubscribe event isnt being unsubscribed too heh. xzibit moment

tawny jewel
#

hi, so im really hoping someone could help me. so im basically making a floppy bird and trying to spawn a powerup with code provided below, but obviously i dont want it to spawn in the view of camera, or behind the player. so im trying to make it spawn only if x axis if center is bigger than 20, and if it isnt, instead of wasting the timer, i want it to wait a while until next set of pipes spawn and generate the new center and powerup there instead. ive tried coroutine and invoke repeating and both just ended up breaking unity. any ideas, tips how i can achive the desired effect in the easiest way?

the code:

Instantiate(revivePowerup, center, Quaternion.identity);```
ember cedar
lucid valley
#

sometimes it does seem to get stuck

ember cedar
#

well this window disappeared but my project is still frozen and i dont wanna close it because i didnt save it in like 4 hours

potent ridge
#

I have a question regarding the Line Renderer. I use the Line Renderer for a Power Indicator, to show how much power you're applying atm by multiplying the length of the Line Renderer. Though, this issues a problem, since sometimes if I am too close to a wall, and I try to shoot to the left, the indicator would go through the wall. This is not what should happend. How can I manipulate it so, the line is visible at all times, without it going through walls?

https://media.discordapp.net/attachments/763495187787677697/1067875747877892126/image.png

https://media.discordapp.net/attachments/763495187787677697/1067875909174042797/image.png

I tried using different layers, but when adding a new layer, and assigning the indicator to that layer, the line renderer still goes through the wall

lucid valley
covert shard
#

hi there, i have a problem with the code and functionality of ads. basically, the ads button works well for the first time i enter the game over scene, but when i play again and die and come back to the scene, the button just doesnt work and doesnt show ads anymore, can anyone help?

tawny jewel
mossy snow
tawny jewel
#

thanks that changes everything

mossy snow
#

I'm not sure what you expected, coroutine would be the simplest solution but you didn't provide whatever code you tried with it so there's not much more to say

tawny jewel
#

sure, i can provide what ive tried so far
so heres the coroutine way

  {
      Vector3 center = Vector3.Lerp(pipespawnscript.lastpipe.transform.position, pipespawnscript.secondPipe.transform.position, 0.5f);
      if (isPowerupInstantiated == false)
      {
          StartCoroutine(RevivePowerup());
          Debug.Log("coroutine started for revive");
      }
  }

  IEnumerator RevivePowerup()
  {
      while (true)
      {
          Vector3 center = Vector3.Lerp(pipespawnscript.lastpipe.transform.position, pipespawnscript.secondPipe.transform.position, 0.5f);
          if (center.x > 10) 
          {
              Instantiate(revivePowerup, center, Quaternion.identity);
              isPowerupInstantiated = true;
              setRandomReviveTime();
              Debug.Log("instantiated revive");
          }
          yield return new WaitForSeconds(1f);

      }
  }

} ```
mossy snow
#

your coroutine never yields, so you have created an infinite loop that will freeze Unity

tawny jewel
#

oh sorry wrong code

ember cedar
#

i cant even minimalise it

tawny jewel
mossy snow
# tawny jewel i edited the message now its good

the way you are doing this is weird. I assume it's the pipes that move and not the player. Since you never end the coroutine in this code, I would at least assume that more and more revive powerups are getting spawned if the pipe locations are accurate and moving

ember cedar
tawny jewel
#

if it hits 0 the revive powerup should spawn, but it would sometimes spawn behind player with just two lines of code so i basically tried to prevent this

wild vigil
#

How do I link a file through code from assetdatabase?

mossy snow
tawny jewel
# mossy snow that sounds like something is wrong with your pipe positions, then. Debug the sp...

alright, i ll add a couroutine ending, tho im not sure if its the pipe spawning issue. the next set of pipes just isnt generated yet, so it spawns the powerup at the only avaible center, with at some times is in the camera view already. i assume i could fix that by just moving the pipe spawner, but that will result in player waiting ages at the start of the game before the pipes get to him

digital gull
#

` int x;

void Main()
{
    x = 0;
    OnFoo += Bar;
    x = 1;
    OnFoo(); //prints 1
}

void Bar()
{
    Debug.Log(x);
    OnFoo -= Bar;
}`

Is there a way to subscribe to an event with specific current value and not the value when the event is called?

I know I can do OnFoo+= () => Debug.Log(x)

But I am trying to subscribe a method with the values of variables on time of subscription

#

My option is specifying the parameters of my delegate and inputing those but I'm trying to make my delegate parameterless and handle different logics inside.

#

` int x;
string s;
void Main()
{
x = 0;
s = "foo";
OnFoo += Bar;
x = 1;
s = "bar";
OnFoo += FooBar;
OnFoo(); //prints 1,bar. hoping to get 0,foo

}

void Bar()
{
    Debug.Log(x);
    OnFoo -= Bar;
}

void FooBar()
{
    Debug.Log(s);
    OnFoo -= FooBar;
}`
devout nimbus
#

Does Unity still not support default method implementations for interfaces?

potent sleet
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.

valid minnow
#

im getting this error for this line of code and idk why, tbh i dont really understand what it means, can i get some help?

proper oyster
valid minnow
proper oyster
proper oyster
valid minnow
proper oyster
valid minnow
valid minnow
#

like this?

#

ohh that fixed it:)

#

welp

#

now i have a new issue

#

when i export and build the game the player falls through the ground. but when i test the game inside of unity nothing like that happens, idk why

#

@proper oyster

proper oyster
#

i dont know
i know noting about your scene or setup

valid minnow
#

i do get this tho

#

maybe that has something to do with it?

valid minnow
kindred pollen
dusky spear
#

will collider2d.overlapcollider return tilemap colliders or no?

leaden ice
dusky spear
#

huh

#

cuz im doing thisCollider2D[] colliders = {};
lightArea.OverlapCollider(filter, colliders);

#

Collider2D[] colliders = {};
lightArea.OverlapCollider(filter, colliders);

#

and not getting shit

#

even tho the shape is big enough to be overlapping a tilemap collider

leaden ice
#

an empty array has no space to store any results

#

The size of the array determines the maximum number of results that can be returned.

dusky spear
#

ohhh

#

is there a way to not limit the number of results?

leaden ice
#

Maybe you want to use the List version?

dusky spear
#

ah ye

#

does unity have its own version of lists or do i just use c# lists

#

or do i want to use arraylist or smthn

dusky spear
#

ok

hard sparrow
#

Why doesn't this work?

leaden ice
#

the second one takes a list

leaden ice
hard sparrow
#

it doesn't say anything useful

leaden ice
#

sure it does

#

it tells you why you can't do that

leaden ice
hard sparrow
#

this also works apparently

dusky spear
hard sparrow
#

Don't know why

leaden ice
#

it's a special thing

leaden ice
dusky spear
#

i used to not be this much of a unity noob but i took a break from a bit

#
lightArea.OverlapCollider(filter, colliders);
Debug.Log(colliders[0]);```
leaden ice
dusky spear
#

its set in editor

leaden ice
#

find out what is null]

leaden ice
#

is from the Unity editor code

#

it's not your code

dusky spear
#

oh ok

lucid valley
#

don't need to loop through just the keys and do the extra lookup for the value, i always forget to do it and then wonder why it errors

dusky spear
#

i think i accidentally compiled while game was running

#

and it didnt like that

hard sparrow
leaden ice
#

well, only if the modification doesn't change its definition of Equality

#

But it really just depends on if the Cell type is a class or a struct

hard sparrow
#

It's a class

leaden ice
#

then you don't need to make any copies of anything

hard sparrow
#

oh that's right. The thing I wanted to modify is private and I assumed it was because of dict XD

leaden ice
lucid valley
#

you sure Cell is a class, from your colouring it looks like a struct (or have you got classes and structs the same colour?)

hard sparrow
#

Oh well it's a struct composed of classes. So... a struct actually XD

leaden ice
#

unless the modifications are to the classes the struct is referring to

#

and not the struct itself

hard sparrow
#

It's fine, I've got it now 👍

timber cloak
#

For methodes like Instantiate(), I noticed that it can take in an object as parameters or the object and a parent ect ect, how can I do that to my own method

leaden ice
dusky spear
#

ah yeah

leaden ice
#

usually have them call each other

dusky spear
#

in unreal if you compile c++ while the editor is open at all

#

it will possibly irreversably corrupt your entire project

#

but nothing anywhere tells you that

leaden ice
#
int MyMethod(int x) {
  return MyMethod(x, 5f);
}

int MyMethod2(int x, float y) {
  
}```
For example
dusky spear
#

and there is even a button in editor to do just that thing

#

but it gives you no warnings when clicking it

leaden ice
mental rover
dusky spear
#

apparently they fixed it in unreal 5 tho

scenic creek
#

Will this cause a compile error when UNITY_EDITOR is not defined in my build?

public class myClass : MonoBehavior
{
#if UNITY_EDITOR
    public int myInt;
#endif
    public void OnDrawGizmos()
    {
         Gizmos.DrawSphere(new Vector3(0, 0, 0), myInt);
    }
}

How does Unity handle OnDrawGizmos? Is it still compiled into the code but never called, or is it compiled out?

proven plume
#

Yes, since myInt won't have been declared

quartz folio
#

It is generally a bad idea to define different serialised values for the editor or runtime, regardless of the fact this also won't work

proven plume
#

Yes, you can get build errors because the serialization no longer matches. It would be better to have this value exposed somewhere else, like in a custom editor where it doesn't get serialized.

#

or in some custom project settings

scenic creek
#

Thanks

outer nimbus
#

How can i change my FireRate in this code?

Hastebin if it's easier to read: https://hastebin.com/iqojuvufix.csharp

Code:

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

public class Player1Handler : MonoBehaviour
{
    //Variables
    [Header("Objects")]
    public GameObject bullet;
    public GameObject bulletSpawnPos;
    [Header("Customizations")]
    public float moveSpeed;
    public float rotSpeed;
    public float bulletSpeed;
    [Header("KeyCodes")]
    public KeyCode Forward;
    public KeyCode Left;
    public KeyCode Back;
    public KeyCode Right;
    public KeyCode Shoot;

    void Start()
    {
        
    }

    void Update()
    {
        //Movement
        if (Input.GetKey(Forward))
        {
            transform.Translate(Vector3.forward * Time.deltaTime * moveSpeed, transform);
        }
        if (Input.GetKey(Left))
        {
            transform.Rotate(Vector3.down * Time.deltaTime * rotSpeed);
        }
        if (Input.GetKey(Back))
        {
            transform.Translate(Vector3.back * Time.deltaTime * moveSpeed, transform);
        }
        if (Input.GetKey(Right))
        {
            transform.Rotate(Vector3.up * Time.deltaTime * rotSpeed);
        }
        if (Input.GetKeyDown(Shoot))
        {
            StartCoroutine(ShootBullet());
            Thread.Sleep(5);
        }
        IEnumerator ShootBullet()
        {
            var Bullet = Instantiate(bullet);
            Bullet.transform.position = bulletSpawnPos.transform.position;
            Bullet.GetComponent<Rigidbody>().AddForce(transform.forward * bulletSpeed);
            Thread.Sleep(1000);
            yield return null;
        }

    }
}```
mossy snow
#

you didn't test that at all, did you?

outer nimbus
#

I tested it

#

And it kinda work but the whole game like stops

#

I forgot to delete the Destroy bullet, but it like kinda works but the whole game freezes.

#

SO i still need help

mossy snow
#

its previous behavior would've been: press the shoot button to freeze the game for 5,005ms and the bullet travels nowhere, so I'm not sure about the kinda works part. Don't put the main thread to sleep. Use coroutine to delay. Move your nested coroutine out of that method. Keep track of the last time you shot, and don't shoot again until enough time has passed

outer nimbus
#

Could you send the fixed code for me if you can? You dont have to but im a bit new but still not really a beginner.

leaden ice
#

Why is there a sudden influx of people doing that 🤔🧐

weak spoke
#

When do tags get loaded in?

leaden ice
#

Wdym by that

weak spoke
#

Are they loaded in before the awake func

leaden ice
#

Yes

weak spoke
#

ie can i use them in there

#

weird

leaden ice
#

Why

weak spoke
#

so im making a table and for some reason it's not setting it

leaden ice
#

A table?

weak spoke
#

hashtable

leaden ice
#

Setting what?

#

Show your code and explain what you're trying to do

weak spoke
#
private void buildPanelTable()
    {
        for(int i = 0; i < 4; i++)
        {
            GameObject panel = GameObject.FindGameObjectWithTag("PlayerDemon" + (i + 1));
            if (panel.activeSelf)
            {
                Demon demon = panel.GetComponent<PlayerDemon>().demon;
                demonToPanel.Add(demon, panel);
            }
        }

        for (int i = 0; i < 4; i++)
        {
            GameObject panel = GameObject.FindGameObjectWithTag("EnemyPanel" + (i + 1));
            if (panel.activeSelf)
            {
                Demon demon = panel.transform.parent.gameObject.GetComponent<EnemyDemon>().demon;
                demonToPanel.Add(demon, panel);
            }
        }
    }
#

this gets called in the awake

leaden ice
#

What is demonToPanel

weak spoke
#

thats the dict <Demon,GameObject>

leaden ice
#
GameObject panel = GameObject.FindGameObjectWithTag("PlayerDemon" + (i + 1));``` this is super fucking weird tbh
#

why are you doing it this way

#

why don't you just assign the references in the inspector

#

This requires you to make a whole bunch of tags

#

and do string concatenation, which is slow and creates garbage

weak spoke
#

I thought dict didnt work with inspector

leaden ice
#

it won't

weak spoke
#

thats getting called once

leaden ice
#

make a list of a struct containing the key/value pairs

#

populate the dictionary from that

#

or just two arrays/lists

weak spoke
#

Yeah ill just do that

leaden ice
#

possibly your code was failing due to FindWIthTag's inability to find inactive objects though

weak spoke
#

oo

#

yee

#

thats probably it

unreal temple
#

Does anyone know what is meant here?

On Windows, use -logfile - <pathname> to direct the output to stdout, which by default is not the console.

#

Is it literally suggesting Unity.exe -logfile - <pathname>

#

What would pathname be for stdout??

#

-logfile - stdout?

leaden ice
#

but not totally sure

unreal temple
leaden ice
#
-logfile 1```
unreal temple
#

so the docs are just confused?

leaden ice
#

Maybe?

#

oh I see what you mean

unreal temple
#

I mean what on earth does "On Windows, use -logfile - <pathname> to direct the output to stdout, which by default is not the console." mean?

leaden ice
#

yeah I have no idea lol

unreal temple
#

still nothing

#

Well, not nothing

leaden ice
#

rofl

#

what about &1?

unreal temple
#

I'm doing this through git-bash

leaden ice
#

-logfile &1 I mean

unreal temple
#

I think that's trying to run command 1 in a new process

leaden ice
#

indeed

leaden ice
#

people are just printing it to a file and printing the file

unreal temple
leaden ice
#

oh

unreal temple
#

I'll try tyhis

leaden ice
#

wait that says Mac though

unreal temple
#

oh whoops

leaden ice
#

worth a shot

unreal temple
#

nope

#

this is so annoying

unreal temple
weak spoke
#

@leaden ice so the issue was that in the awake i was calling priv funcs

leaden ice
weak spoke
#

this is so weird, im doing 2 arrays and then building the table

#

and still null

leaden ice
#

what is null

#

show

#

explain

weak spoke
#

ye one sec

#

[SerializeReference] public GameObject[] demonToPanelPanelPlayer;
[SerializeReference] public GameObject[] demonToPanelPanelEnemy;

leaden ice
#

why use GameObject[]

weak spoke
#

i put everything into the inspector

leaden ice
#

why not Demon[]

#

also why SerializeReference???

#

wat

weak spoke
#

Demons a SO

leaden ice
#

so?

#

Then you definitely don't want GameObject

#

you want Demon

weak spoke
#

Demon is a field in a script

leaden ice
#

also how can one array represent "demonToPanelPanelPlayer;"

#

when I said two arrays I meant like this:

[SerializeField] Demon[] keys;
[SerializeField] GameObject[] values;```
#

then you do:

for (int i = 0; i < keys.Length; i++) {
  myDict[keys[i]] = values[i];
}```
#

note that you don't need public and it's [SerializeField] not [SerializeReference]

weak spoke
#

ye that was a typo

#

the demons get loaded in from another scene

#

how would i put the demons that will be loaded in the panels into the list through the inspector

leaden ice
#

I thought you said demons were ScriptableObjects

weak spoke
#

they are

leaden ice
#

I guess I don't fully understand what's going on here

#

you'd have to share more of your code

#

Also you didn't explain what exactly was null and where

#

and how it had been assigned

weak spoke
#

Thats a script, demon is a SO

leaden ice
#

It is? If it was an SO it would appear as a refernece here

#

not a foldout

#

unless you're doing some custom editor scripting

#

by "SO" do you mean "plain old C# object" / POCO?

weak spoke
leaden ice
#

as in - a class that doesn't derive from MonoBehaviour?

#

Yeah that's not an SO

#

That's just a regular class

#

SO means ScriptableObject

weak spoke
#

oo ok so tech my db is the so

leaden ice
#

DemonDatabase is an SO

weak spoke
#

ok ok

leaden ice
# weak spoke

but here it looks like your PlayerDemon script has a Demon field directly

#

it's not using DemonDatabase

weak spoke
#

so before the scene with all of that

#

i drag and drop from the db

potent sleet
weak spoke
#

and then from the first scene into that scene it will loaded it in

leaden ice
#

you are trying to map what to what here with your Dictionary?

weak spoke
#

So all this gets saved from dontdestory once the first scene is done (a random encounter occurs)

#

and thats where those get populated from

leaden ice
#

the EnemyParty script?

#

gets populated by demons from DemonDatabase?

#

is that what you're saying?

weak spoke
#

WorldScene starts first

#

nothing in battle is loaded in

#

after some steps in the 3d world, it will load in the battle scene

#

(ignore that its loaded atm in the inspecotr)

leaden ice
weak spoke
#

Yes

#

Both the player and the demon party does

leaden ice
#

ok so again - what is the Dictionary you are trying to make here?

#

mapping what to what

weak spoke
#

So i want to be able to know the panel of x demon

#

So given a demon, i want to know its panel

#

hence the mapping from demon to go

leaden ice
#

shouldn't you be doing something like this?

GameObject[] panels;

void PopulatePlayerPanels(List<Demon> playerDemons) {
  Dictionary<Demon, GameObject> panelMapping = new();
  for (int i = 0; i < playerDemons.Count; i++) {
    Demon playerDemon = playerDemons[i];

    // populate the UI planel
    panels[i].GetComponent<MyDemonPanelScriptOrWhatever>().Initialize(playerDemon);

    // Establish the mapping
    panelMapping[playerDemon] = panels[i];
  }
}```?
#

Though again I wouldn't use a GameObject[], probably an array of the UI script on each panel (which I called MyDemonPanelScriptOrWhatever in this example)

#

Now you need to be really careful here because if you're not creating copies of these demons, you have a bunch of references to the same demon object all over the place

weak spoke
#
public class EnemyDemon : MonoBehaviour
{
    [SerializeField] public Demon demon;

    private void Start()
    {
        int idx = transform.GetSiblingIndex();

        if (BattleManager.Instance.enemy.enemyParty.Count > idx)
        {
            demon = BattleManager.Instance.enemy.enemyParty[idx];
            transform.gameObject.GetComponentInChildren<Image>().sprite = demon.demonImage;
        }
        else { transform.gameObject.SetActive(false); }
    }
}
#

heres how the demons get loaded in to the panel

leaden ice
#

so not only with this Dictionary not really work, but you'll be changing the HP of all demons who share that reference etc, including the Database

weak spoke
leaden ice
weak spoke
#

im just gonna use initaite func whenever i pull them in from db

nimble dome
#

Does anyone know why in the world this code makes the game object flicker randomly and fast? I don't work with coroutines often so i feel like i might be missing something obvious...

    {
        WaitForSeconds wait = new WaitForSeconds(markerFlashSpeed);

        while (!trackingPlayer)
        {
            destinationIndicator.SetActive(false);
            yield return wait;
            destinationIndicator.SetActive(true);
            yield return wait;
        }
    }```
weak spoke
#

ig one issue could be the load order of scripts

leaden ice
nimble dome
#

yep so I was missing something obvious. I think i might have been too sleep deprived last night to realise i was calling the function many times over. my bad 😂

#

forgot to set a variable to true which would stop that.

weak spoke
#

something weird is going on lol

#
private void buildPanelTable()
    {
        foreach(GameObject x in demonToPanelPanelPlayer)
        {
            demonToPanels[x.GetComponent<PlayerDemon>().demon] = x;
        }

        foreach (GameObject x in demonToPanelPanelEnemy)
        {
            demonToPanels[x.GetComponent<EnemyDemon>().demon] = x;
        }
    }
#

@leaden ice so i put a break point here at the first foreach

#

and i started stepping in

#

and when it hit the getcomponent, the game just started running and broke out of the entire loop

leaden ice
#

anything in the logs?

weak spoke
#

oh yes i did

leaden ice
#

also instead of doing a GameObject[] just do PlayerDemon[]

weak spoke
#

oki

leaden ice
#

then you don't have to do GetComponent

#

You can just do demonToPanels[x.demon] = x.gameObject;

weak spoke
#

if i copy the component

#

does it copy it as a ref?

#

cause atm rn its empty

#

until the first scene is complete

leaden ice
#

it's the same as doing the GameObject

#

just with a direct reference to the script instead

leaden ice
weak spoke
leaden ice
#

define "component" here

weak spoke
#

the playerdemon

leaden ice
#

the only thing here that is a Component is the PlayerDemon script itself

#

yes

weak spoke
#

so that gets loaded in

leaden ice
#

wdym by "copy the component"

weak spoke
#

if i copy it and paste it 2 the field in the manager

leaden ice
#

you mean drag and drop?

weak spoke
#

yes

leaden ice
#

it's a reference

weak spoke
#

okay wanted 2 make sure

leaden ice
#

also those type mismatches are just because we changed the type

#

just drag it in again

weak spoke
#

ye

swift falcon
#

How can I make player movement not freeze when loading chunks?

leaden ice
swift falcon
leaden ice
#

loading chunks
You'd have to revisit your technique for doing this and optimize it

#

make it asynchronous wherever possible, etc..

weak spoke
#

im losing my sanity

swift falcon
#

I have a loadchunks method
There's a dictionary with all chunks, logged with their vector2 locations
void LoadChunks()
{
//add the nearby chunks with a roundOff method to a loaded chunks list. If it doesn't exist in the dictionary, create it

//Loop through the loaded chunks list and if a chunk is too
far, unload it. After removing far chunks, load the chunks in the list that are unloaded
}

swift falcon
leaden ice
#

explain how you do "loading" and "unloading"

leaden ice
swift falcon
#

You can imagine the reload one

leaden ice
#

you're jsut activating/deactivating?

#

How do the chunks get spawned in the first place?

swift falcon
#

I already said this, but
If the chunk doesn't exist in the dictionary, aka hasn't been generated yet, it instantiates a new one

leaden ice
#

also for any performance problem, you need to pull out the profiler

swift falcon
leaden ice
#

It could be the Instantiate itself that is slow, it could be generating the data for it. It could be a script in Awake or Start doing something slow etc...

#

You have to profile it

#

then you'll know where to look to optimize it

swift falcon
#

It uses a double for loop that starts at -renderdistance and ends at +renderdistance

weak spoke
#

its gotta be a load thing

swift falcon
#

Then it rounds off a chunk position and if it doesn't exist, it generates it

#

GenerateChunk

swift falcon
#

ok

#

will that help me make it faster?

#

And how to make something async

leaden ice
#

then you will know what to focus on

weak spoke
#

@leaden ice cs has a default hash func right

leaden ice
#

every object has a GetHashCode and object has a default implementation of it

#

which more or less corresponds to object identity

weak spoke
#

And these objects are == if they're at the same address?

leaden ice
#

if it's a class, yes

#

not if it's a struct and not if you've overridden == for your specific type

weak spoke
#

Ye so that can't be the issue

leaden ice
#

do note that when you serialize things, it can get weird

#

unity may be breaking the "sameness" of the objects

weak spoke
#

When do u want to serialize vs just set to public

#

Before I started I thought I needed to serialize to have the field active in the inspector

leaden ice
weak spoke
#

Seems like just public does it

#

Ah ok

leaden ice
#

yes, making it public causes it to be serialized

weak spoke
#

im just going to make a public dict

#

and have the panels reach in and add themselves

#

kidna feel stupid i didnt do that from the start

#

yeah its good now

#

all the panels had a depedence on the battlemanager, and then the battlemanager needed a dependence from the components for the table so ofc it would shit itself

fleet fern
#

while making a game with a snake ai, I ran into an issue with the segments' scripts reacting only once every couple of frames. I assume with has something to do with too much running at once, but there aren't too many other scripts running. Is there a potential other reason for them lagging behind?

leaden ice
fleet fern
#

I was, then switched to update, and it continued to happen

leaden ice
#

well how do you know the scripts are only "reacting once every couple of fframes"

#

what do you mean by that

#

Update runs every frame, no matter what

#

the gaps you are seeing are probably due to something in your code, like assuming frames land on perfect even boundaries of time or something

#

it's actually kind of tricky to get snake right

fleet fern
#

the only code I have running for the segments is this

#

I'm not sure if that would require something too strenuous

leaden ice
#

stop thinking about "strenuous"

#

this isn't a performance problem

#

it's a math/logic problem

fleet fern
#

yeah, I just realized it

leaden ice
#

that position calculation looks pretty sketchy

fleet fern
#

it's a bit messy

#

apparently somewhere the size got set to 10, making them react only a tenth of the time

#

ty though

weak spoke
#

@leaden ice btw since i dont want a SO for my demon db, i should use a prefab right?

#

cant tell what i want lol, sorta need a place where i can just make some demons in and drag and drop, but need copies of them

quaint rock
#

if its just something you want to reference SO

#

if its something you want to have in the scene Prefab

weak spoke
#

gotcha, so i should make my demons prefabs

#

and then i can make my db a normal class that has a list of demon prefabs

swift falcon
#

I just found out about UShort in C#. Do you guys ever use it often? It’s basically just an empty data type

leaden ice
swift falcon
#

I worded it quite wrong I think

“Holds unsigned 16-bit (2-byte) integers ranging in value from 0 through 65,535.”

leaden ice
#

mhmm, just a basic numerical type

swift falcon
#

Unassigned integers is what I should of said

#

Yeah

#

I don’t think it’s that useful I guess?

leaden ice
#

uint, ulong, byte etc also exist

#

It'd mostly be useful for applications where bandwidth or memory are limited and you have a value you can fit in that type, such as in networking or when dealing with large arrays to cut down on memory usage

swift falcon
#

Oh yeah I see

#

Cuz in this example they use UShort to store triangles

leaden ice
#

yeah it makes sense there because there's a vertex count limit of ~16k for Meshes anyway

#

so ushort is plenty to hold a vertex index

swift falcon
#

So basically If you need very big arrays it could be good

swift falcon
#

Well thank you

#

Very much for explaining

zinc parrot
#

whats the directive for conditional compilation if its dx12?

leaden ice
zinc parrot
#

sorry I mean in hlsl
I want to do use dxc if I am compiling for dx12, but not for dx11 as it doesnt work on dx11

leaden ice
zinc parrot
#

hmmm darn there doesnt seem to be one to ddifferentiate between dx12 and dx11

zinc parrot
#

OH
thank you!!

#

and... still no differentiation between dx11 and dx12 darn

leaden ice
# zinc parrot and... still no differentiation between dx11 and dx12 darn
leaden solstice
#

What is the third parameter of OverlapSphere

next seal
#

Getting this error "Resolve of invalid GC handle. The handle is from a previous domain. The resolve operation is skipped.
UnityEngine.GUI:Window (int,UnityEngine.Rect,UnityEngine.GUI/WindowFunction,string)
NodeEditor:OnGUI () (at Assets/Scripts/Editor/NodeEditor.cs:107)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
"

https://pastebin.com/q66adAYW

#

And im like how is that possible the thing I pass in is literally an i of a list that makes sure that they really really really exist

#

so how can this be possible >_>

#

this is an editor window btw

#

also tried this and still not working still same error

next seal
#

well I still have not been able to find the answer and at this point I also cant find anything what this error could possibly mean

#

there isnt a lot of info on it

inner yarrow
#

I have tried stuff with portals several times, and in every video I have watched, the camera will make the portal it's behind invisible before taking a picture, and then make it visible again afterwards. I have tried this:

myWormhole.Renderer.enabled = false;
//positioning stuff
cam.Render();
myWormhole.Renderer.enabled = true;

However, it still ends up taking a picture of the portal. Please ping me if you have any ideas?

#

Also this is being called in Update, not sure if that's causing problems.

leaden ice
inner yarrow
#

I must go to bed, so if I don't see someone's answer that's why, but I'll check here again tomorrow.

cosmic rain
slow crag
#

I need to check whether some regions of the tilemap are in view of my cameras frustrum when it is angled downwards (2.5D perspective.) This needs to be done every frame and will be used for manual culling.

I'm wondering if it's faster to check if those regions are intersecting with a line, or, if I should compare their bounds to the bounds of the camera with TestPlanesAABB. Intuitively, I really can't tell which would be faster. They're both a bit of math calculation, but it's done every frame so I'd like the faster solution

kindred pollen
#

Ehyy, anyone can help me understand why I cannot manage to build? 😬

wide fiber
#
 private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.collider.gameObject.CompareTag("enemy"))
        {
            HealthPoint--;
        }
    }```

hi, this script is from my parent object but when the CHILD of this parent object got hit by "enemy", it still healthpoint-- 
Is there something wrong?
cosmic rain
plucky iron
#

dammit dlich to fast

cosmic rain
wide fiber
kindred pollen
kindred pollen
#

Thank you in advance 🙂

wide fiber
# cosmic rain Not without you actually sharing any details.

so far i only found this 😭 https://answers.unity.com/questions/829821/how-to-disable-compund-colliders.html

but this doesnt explains anything. I just want my child collider to be not affect by a parent. It didnt tell me to disable the compound. im really sorry

#

is it ok if u leave me a clue? sorry

rich nymph
#

I spent a good 2 hours trying to figure out why I cannot use IPointerClickHandler in my project, and it seems that the culprit was this specific TMP text object - because after disabling it, the game was recognizing my mouse clicks on all game objects in the game scene. Any idea why that is?

hasty canopy
rich nymph
hasty canopy
#

But Regardless, TMP was probably blocking it

rich nymph
rich nymph
hasty canopy
rich nymph
exotic burrow
#

does the null-coalescing operators (??=) work well with unity

#

Here is an example

object foo = null;
foo ??= new object();
#

does it have any cons ?

mellow sigil
#

Destroyed gameobjects are overloaded to equal to null but aren't real nulls so any question mark operators shouldn't be used with them

lucid valley
#

only using != and == is safe

#

but you can make it safe by doing something like this

#
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T OrNull<T>(this T unityObject) where T : Object
{
    return unityObject == null ? null : unityObject;
}

Then you can then do this for unity objects and it is safe (but you wouldnt do new for unity objects anyway):

  Object foo = null;
  foo.OrNull() ??= new Object();
#

Allows you to chain null checks too (not the best example but here's one)

#
if(FooGameObject.OrNull()?.GetComponent<BarScript>().OrNull()?.ClassThing == null) return;
compact socket
#

hello : i need to find the closest point of a collider to a line , i have a method that is already good but it looses accuracy on larger colliders, what would you do to find this closest point ?

jaunty needle
#

How do I generate a random number between 1 and 4 and have it not repeat the same number twice?

compact socket
exotic burrow
#

hmm interesting thank you guys

compact socket
# jaunty needle previous

roll once , save the number in a variable (r) and re roll again, if the second rolled number is == to the saved number reroll again, otherwise save the new rolled number in the (r) variable and repeat

jaunty needle
#

that's...straightforward damn imma try that

compact socket
lucid valley
#

private int lastRandom;

public int GetRandom()
{
      var newRandom = lastRandom;

      while(newRandom == lastRandom)
      {
          //Random.Range for ints is exclusive for the max value, so this will get 1,2,3,4
          newRandom = Random.Range(1, 5);
      }
      
      //Cache for next generation
      lastRandom = newRandom;

      return newRandom;
}
#

something like that should work

compact socket
#

tho i recommend doing one roll of last random before calling GetRandom() so that you have a starting point

lucid valley
jaunty needle
compact socket
#

hello : i need to find the closest point of a collider to a line , i have a method that is already good but it looses accuracy on larger colliders, what would you do to find this closest point ?

compact socket
jaunty needle
#

It worked, thanks guys

left adder
#

I really love working on 2.5 D games its really nice in unity 😮

weary heron
#

Hey all, trying to make a procedurally generated island which can be large. I've watched through Sebastian lagues video about it, but I can't seem to make one large island. I have been able to limit the max chunks created, just don't know how to give the outer chunks a falloff map to give the world a border and not a jangled mess. Anyone know what I can do?

spice aspen
#

https://pastebin.com/G894M8Cy
the cooldown is working only one time after that the cooldown is not working any idea why also i have referred the function in update()

lucid valley
spice aspen
#

Yes

#

Update

#

Well I actually figured it out i just had to stop the coroutine

lucid valley
#

i'm sure you could combine you Dashing and DashCooling into one coroutine

spice aspen
mental rover
tall scroll
#

for some reason despite my extremely simple code having public GameObject prefab; as a line, I cannot assign a gameobject in the UI

weary heron
#

Where have you put it in your code, and do you have any errors in the console?

tall scroll
#
public class CopyLightmaps : MonoBehaviour
{
    public GameObject myPrefab;
    public int test;
    // Start is called before the first frame update
    void Start()```
#

oh yep console errors dead

#

someday I will unity correctly istg lol

weary heron
#

That would be the problem then 🙂

swift falcon
#

I'm trying to clean up my code right now for it to be more readable and make more sense. I've never made a big project before, what's considered good practice? Some people are for comments and others aren't, I know my variables and functions should be self explanatory. Should I also comment my code?

tall scroll
#

ok that fixed it, onto the next channel for my next issue dead

winged karma
#

Hi all,

When using OnTriggerEnter, how would you identify the object that was hit? The function parameter is the one that triggered the function, but I'd like to point to the object that contains the trigger

prime sinew
prime sinew
#

you use gameObject to get the object that the script is on

winged karma
#

Perfect, thank you

vagrant goblet
#

Hello, I need a prefab x to instantiate new copies of prefab x.

With a regular setup:

[SerializeField]
protected GameObject ChildPrefab { get; set; }

Then plugging a reference to the prefab from the assets folder.

I've noticed that new instances have increasing amounts of x(Copy) x(Copy)(Copy) x(Copy)(Copy)(Copy) with each iteration, as well as same values of its fields. This means that the script doesnt reference the prefab but the instance of itself. Is there any good way to go around this?

leaden ice
#

You should just copy the prefab

#

You're doing this prefab = Instantiate(prefab);

#

You should be doing this:

var newInstance = Instantiate(prefab);

thorny marlin
#

i was just importing an particle asset and it gives me this erro

vagrant goblet
#

It feels like a unity bug, ill record a little gif for you sec

leaden ice
#

And what's this about

#

This is normal

#

References internal to the prefab become instance references

#

This is not a bug

#

It's intended, expected behavior

#

And well known

#

If you want to give the instance a reference to the prefab you'd have to do it after instantiation, e.g:

#
var newInstance = Instantiate(prefab);
newInstance.originalPrefab = prefab;```
vagrant goblet
# leaden ice References internal to the prefab become instance references

But if "References internal to the prefab become instance references", then that means I'm instantiatating a copy of the instance and not a copy of the prefab no? The first instance of the prefab already instantiates itself, so this will not work, the code you wrote plugs the first instance as a reference.

leaden ice
#

Not to the instance

vagrant goblet
leaden ice
#

It is in my example

#

I'm telling you to put this code on the code that spawns the first instance

#

Not the script on the prefab itself

vagrant goblet
#

The prefabs spwawn copies of themself, to imitate reproducion

leaden ice
#

Something spawns the first one though

#

Right

vagrant goblet
#

Ah, i see what you mean now.

#

So theres no way for me to plug a reference to a prefab inside of the prefab?

leaden ice
#

No because if that worked prefabs would be super broken

#

You wouldn't be able to have any internal references in the prefab

#

You just have to assign the reference to the prefab after instantiation, as per my example

vagrant goblet
#

Could I somehow use the Resources.Load() method?

short timber
#

I created an IJob and i have this [ReadOnly] public NativeArray<Vector2Int> availablePositions;.
According to the documentation on package "com.unity.collections@1.4", we have Class NativeArrayExtensions.

Why if (availablePositions.Contains(new(0, 1))) {, Contains method points to System.Linq, instead of recognizing Unity.Collections; ???

The 4th method on NativeArrayExtensions documentation is exactly what i'm trying to use.
Is this a bug/issue or am i missing something?

lucid valley
lucid valley
# short timber No.

do you actually have the Collections package installed? As NativeArray is part of the unity core module but the extention class is in the collection package

hard sparrow
#

This ends up resulting in weird, unexpected movement. Am just trying to get it to go from startposition to endposition like a lerp (and add curves after)

#

It's not even heading to the right spot despite endingtransform being correct

#

or is this not how you do AnimationCurves?

swift falcon
#

How to make something run asynchronously

compact socket
short timber
lucid valley
short timber
#

true.

leaden ice
steep scarab
#

I've been thinking about making multiple falloff maps for different island borders but I'm not sure how to even go about that 💀

weary heron
#

idk how to do corners as of yet

steep scarab
#

yeah thats what I'm thinking

steep scarab
wispy badger
#

just a quick question about moving objects in NGO.
right now, i want my character to carry an item if you click on it .

/*checks if the object has the "carryable" tag, if an Object is already equipped and if the object is within the players proximity*/
if(c.transform.gameObject.tag == "carryable" && !CarriedObject && Vector3.Distance(c.transform.position, Hand.position) < 4)
                {
                //saves the objects original pos. and rot. 
                orgP = c.transform.position;
                orgR = c.transform.rotation;
                
                //actually equipps the object
                CarriedObject = c.transform;
                coName = c.transform.gameObject.GetComponent<item>().name;
                CarriedObject.GetComponent<MeshCollider>().enabled = false;
                }
if(CarriedObject)
            {
            //makes the object move with the Hand
            CarriedObject.position = Hand.position;
            CarriedObject.rotation = Hand.rotation;
            }

it should work in theory and it actually does, until you run the script in multiplayer. What should i do to make this work in multiplayer? or should I just use a completely different concept, like making the carried object the Hands child or attaching a movement script to the Object itself?

steep scarab
#

keep in mind I haven't started at all I literally just imported the scripts and I'm getting texture errors

#

but

#

I think it could be possible to get rounded corners with a bit of geometry

#

but I think its going to need a couple of things

#

like calculating the distance from whichever corner we are supposed to be "rounding"

#

so like

leaden ice
wispy badger
leaden ice
#

so the host will need to be the one to attach it, or the object needs to be given to the client's authority at that time

wispy badger
#

does this work with server rpc? (i tried, but it cant serialize transform)

wide star
#

Would someone help me understand how I would have to make a script on playerprefs to save toggle please?

leaden ice
#

and why would you serialize Transform

#

you'd send the NetworkObject / id

wispy badger
west sparrow
wide star
wispy badger
# leaden ice you'd send the NetworkObject / id

i think, i found the problem. when the object is clicked, the "CarriedObject" is only set on the client. the Host gets a NullReferenceException and if i inspect the clientplayer in the Hosts window, "CarriedObject" is still null.

limber stag
#

Hi if i add script to object type mi Cant add script how can i fix it?

lucid valley
#

are you trying to ask why you can't add a script to a gameobject?

somber nacelle
#

does the script name and file name match and do you have any errors in the console?

limber stag
#

i fix it and work

#

thanks

#

and sorry for mi english

dense vessel
#

Hello,
Is there a way to autofit a text but to tell it to avoid other objects?
Here for example, I would like the text to automatically take as much space as possible in the white rectangle but to not go over the archer image. Is this possible?

#

Basically something like that. But automatically since the text can change

lucid valley
#

maybe this?

#

have the sprite actually part of the text and resize it?

dense vessel
#

Hmm yes but then the image must be the size of the text, right?
Like if I have a small text, the image will be small and if I have a big text, it will be big

#

In this case, it would be really small...

lucid valley
#

well you can use the size tags to increase the sprite i think

dense vessel
#

Oh. I didn't know about that. But what if it has to take several lines?

#

The line bellow will still go over it, right?

lucid valley
#

humm i'm not too sure

dense vessel
#

Oh well I was wrong, it looks not too bad

#

I mean it's way too big but I just have to adjust it

dense vessel
lucid valley
#

might be the best way for you

dense vessel
#

You're better than me at searching on Google 😂
Thanks a lot!

potent sleet
#

googling is a dying skill

#

😦

jolly niche
#

Hey, my scriptable objects always keep their changed values after i exit play mode. Is there some easy way to reset them?

regal marsh
#

i have a spawner gameobject that spawns things inside a sphere. the player controls a car, and i want to make sure that when i choose a random point inside of the spawner, the car doesn't occupy it. how do i do that? i'd check if the point is inside a collider but it will always be since the bounds of the spawner are represented by a sphere collider

jolly niche
#

i'm using them for an inventory system

potent sleet
#

they're meant for immutable data

jolly niche
#

but they're soo cool

regal marsh
#

i would not use scriptable objects for an inventory

frank kayak
wispy badger
#
if (Input.GetMouseButtonDown(0))
        {
        Ray ray = Camera.GetComponent<Camera>().ScreenPointToRay(Input.mousePosition);
        RaycastHit c;
        if (Physics.Raycast(ray, out c))
            {
            if(c.transform.gameObject.tag == "carryable" && !CarriedObject && Vector3.Distance(c.transform.position, Hand.position) < 4)
                {
                        orgP = c.transform.position;
                        orgR = c.transform.rotation;
                        CarriedObject = c.transform;
                        coName = c.transform.gameObject.GetComponent<item>().name;
                        CarriedObject.GetComponent<MeshCollider>().enabled = false;
                }  
        }
if(CarriedObject)

            {
                moveObjectServerRpc();
            }
[ServerRpc(RequireOwnership=false)]
    private void moveObjectServerRpc()
    {
        CarriedObject.position = Hand.position;
        CarriedObject.rotation = Hand.rotation;
    }

still doing something wrong here. it works on the Host and on the client, the Variables are set as soon as I click the object. but on the host, the variables of that client are still null and i just receive a nullreferenceexception while trying to move the object

frank kayak
#

So the original one stays clean, it's probably a workaround tho

jolly niche
#

So should i just store my inventory list as a regular scene instantiate variable?

lucid valley
polar marten
#

you might want to use an asset that supports multiplayer already

frank kayak
# jolly niche whats init()

It's just a name, what I mean it's to create inside your scriptable object a new function that receives an object of the same type as a parameter and then set all the values from that object. Then when you need that object, spawn a new one of that type and call that function to set everything up. So you have a fresh object with the same values but the original one stays as it is.

polar marten
wispy badger
# polar marten what kind of game is it

competitive cooking. you play in a kitchen with 4 players and need to cook your dish as fast as you can while the other players will try the same thing and sabotage each other

#

the code is for picking up (e.g.) knifes and carrying them around

wispy badger
polar marten
#

okay well i would strongly recommend making it local multiplayer, and then focusing on other stuff

wispy badger
#

thats what it was supposed to be. i wanted to start working on multiplayer games with a simple LAN-game

polar marten
#

hmm

wispy badger
polar marten
#

i mean same machine local multiplayer

#

no

#

i didn't say that

#

it's just that unity is bad at realtime networked multiplayer, period full stop

#

it's sort of a huge waste of time

#

make it local, not networked multiplayer

#

and focus on the game

lucid valley
wispy badger
polar marten
potent sleet
#

or make a simple p2p communication app

#

like a chat thing

polar marten
#

anyway, i am trying to be helpful

#

there are assets.

frank kayak
#

Draggable Object conflict with Tilemap Collider

wispy badger
# potent sleet LAN isn't "simple"

compared to singleplayer games: yes. compared to playing it via wifi and doing this whole "join the lobby from anywhere in the world by just clicking one button": no.

wispy badger
#

guess i gotta have to do some explaining to my teacher and the group 😬

jolly niche
#

from a Unity tutorial about lists, what are those values?

polar marten
#

just think about how to make it simpler

#

way simpler

#

in fact i can think of a great game design for a cooking game

#

have you ever played spaceteam?

wispy badger
lucid valley
somber nacelle
lucid valley
#

presumably it has a string and an int that needs setting

potent sleet
jolly niche
#

ah my bad

polar marten
#

make a local (or single) player cooking game. you place orders for the kitchen on a website

#

that's it

wispy badger
#

thanks. this actually sound more practicable

polar marten
#

yeah let people just write freeform

#

it'll be funny

potent sleet
#

lemme get an Ass Burger

polar marten
#

lol yeah exactly

kindred plume
polar marten
#

if you want a real game you make each player (which can be many, single copies of the game that all poll the same url for the current order) submit their own thing

#

and the person who orders picks which creation is best

#

kind of like cards against humanity

wispy badger
polar marten
#

how much time do you have?

potent sleet
#

is this a code question?

wispy badger
#

about a month. but i did the entire assets, the character and the scripts within 2 weeks. also i am highly motivated to finish the game

polar marten
#

okay

kindred plume
polar marten
#

i think this is a lot of time if you're putting in lots of hours every day so that's all fine

#

have you ever authored a website with an api

frank kayak
#

sorry to ask, how does it works for threads? Do i need to share it in the chat to keep it up or anyone goes to see them sometime?

potent sleet
#

dang what kinda school want you to do p2p and u cant even crud

hexed pecan
frank kayak
#

bump it as in...? 😆

polar marten
#

to make it simple

#

it's tricky

wispy badger
#

basically, the only thing i have to worry about is to make it use some sort of network. so i could also just make an offline game and add something like an online highscore board

simple sable
#

hey guys, I've got a little problem here, thought maybe someone could help
so I have this piece of code that changes the transparency of a specific tile from my tileset to semi-transparent
I want to change the code a bit and use DoTween's DoFade but I'm not sure how to do it. I tried using GetTile but that didn't work.

If anyone could help, I would greatly appreciate it!

outer nimbus
#

How can i delete a instantiated object?
I tried this but it didn't work.

#

If i do that i get the error: The name 'Bullet' does not exist in the current context.

simple sable
outer nimbus
#

Yeah i thought that could be the problem but idk how i can wait in a if statement.

simple sable
#

Maybe try declaring it before, and just assign to it what you want in the if statement.

outer nimbus
#

ohhh

#

ill try

#

Uhh now i get this..

inner yarrow
#

I have tried stuff with portals several times, and in every video I have watched, the camera will make the portal it's behind invisible before taking a picture, and then make it visible again afterwards. I have tried this:

myWormhole.Renderer.enabled = false;
//positioning stuff
cam.Render();
myWormhole.Renderer.enabled = true;

However, it still ends up taking a picture of the portal. Also this is being called in Update, not sure if that's causing problems. Please ping me if you have any ideas?

simple sable
#

See if that works.

leaden ice
simple sable
#

But I'm not sure what you're trying to achieve so I might be wrong.

leaden ice
#

No need for the coroutine

outer nimbus
#

Then i wont get a bullet.

leaden ice
#

Yes you will

#

Why wouldn't you get a bullet?

simple sable
# outer nimbus Uhh now i get this..

Just a tip here, you might want to try and set the variables you don't need to be public to private. Maybe even add a "_" before their names. Just to keep things clean. You can use [SerializeField] to make them visible in the inspector.

leaden ice
#

You will have your bullet

outer nimbus
#

My bullet is getting deleted right after it spawns now.

ebon timber
#

got a timer?

outer nimbus
#

yus

#

he said i dont need

#

it

ebon timber
#

using delta time?

outer nimbus
#

no

ebon timber
#

what's the deleteTime you're sending it?

#

is it seconds or float

outer nimbus
#

Uh i use yield return new WaitForSeconds

#

Wanna see my script?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Threading;

public class Player1Handler : MonoBehaviour
{
//Variables
[Header("Objects")]
public GameObject bullet;
public GameObject bulletSpawnPos;
[Header("Customizations")]
public float moveSpeed;
public float rotSpeed;
public float bulletSpeed;
public float deleteTime;
public float fireRate;
public bool countdown = true;
[Header("KeyCodes")]
public KeyCode Forward;
public KeyCode Left;
public KeyCode Back;
public KeyCode Right;
public KeyCode Shoot;

void Start()
{
    
}

void Update()
{
    //Movement
    if (Input.GetKey(Forward))
    {
        transform.Translate(Vector3.forward * Time.deltaTime * moveSpeed, transform);
    }
    if (Input.GetKey(Left))
    {
        transform.Rotate(Vector3.down * Time.deltaTime * rotSpeed);
    }
    if (Input.GetKey(Back))
    {
        transform.Translate(Vector3.back * Time.deltaTime * moveSpeed, transform);
    }
    if (Input.GetKey(Right))
    {
        transform.Rotate(Vector3.up * Time.deltaTime * rotSpeed);
    }
    if (Input.GetKeyDown(Shoot) && countdown == true)
    {
        countdown = false;
        var Bullet = Instantiate(bullet);
        Bullet.transform.position = bulletSpawnPos.transform.position;
        Bullet.GetComponent<Rigidbody>().AddForce(transform.forward * bulletSpeed);
        StartCoroutine(timer());
        StartCoroutine(deleteTimer());
    }
    IEnumerator timer()
    {
        yield return new WaitForSeconds(fireRate);
        countdown = true;
    }
    IEnumerator deleteTimer()
    {
        yield return new WaitForSeconds(deleteTime);
        DestroyImmediate(Bullet,true);
    }

}

}

#

How can i delete my bullet

#

The bullet stuff is at the bottom.

ebon timber
#

is WaitForSeconds built into unity?

outer nimbus
#

Idk

ebon timber
#

i usually just do something real quick and be done with it

outer nimbus
#

Can you help me!

#

Please

cedar pivot
#

hi how can i make a formation system for a soccer game

ebon timber
#

hrm bullet

#

is the collision for bullet handled in hitscan?

cedar pivot
#

if the value is "4-4-2"

players needs to spawns at the formation position

ebon timber
#

store the intended formation position offsets there

prime sinew
outer nimbus
#

5

#

Ik why it doesn't work but i dont know how i can make it work.

prime sinew
#

you dont need DestroyImmediate..

#

just use Destroy

outer nimbus
#

yeah ik.

#

But it still doesn't work

prime sinew
#

show what you have now

outer nimbus
#

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

public class Player1Handler : MonoBehaviour
{
//Variables
[Header("Objects")]
public GameObject bullet;
public GameObject bulletSpawnPos;
[Header("Customizations")]
public float moveSpeed;
public float rotSpeed;
public float bulletSpeed;
public float deleteTime;
public float fireRate;
public bool countdown = true;
[Header("KeyCodes")]
public KeyCode Forward;
public KeyCode Left;
public KeyCode Back;
public KeyCode Right;
public KeyCode Shoot;

void Start()
{
    
}

void Update()
{
    //Movement
    if (Input.GetKey(Forward))
    {
        transform.Translate(Vector3.forward * Time.deltaTime * moveSpeed, transform);
    }
    if (Input.GetKey(Left))
    {
        transform.Rotate(Vector3.down * Time.deltaTime * rotSpeed);
    }
    if (Input.GetKey(Back))
    {
        transform.Translate(Vector3.back * Time.deltaTime * moveSpeed, transform);
    }
    if (Input.GetKey(Right))
    {
        transform.Rotate(Vector3.up * Time.deltaTime * rotSpeed);
    }
    if (Input.GetKeyDown(Shoot) && countdown == true)
    {
        countdown = false;
        var Bullet = Instantiate(bullet);
        Bullet.transform.position = bulletSpawnPos.transform.position;
        Bullet.GetComponent<Rigidbody>().AddForce(transform.forward * bulletSpeed);
        StartCoroutine(timer());
        StartCoroutine(deleteTimer());
    }
    IEnumerator timer()
    {
        yield return new WaitForSeconds(fireRate);
        countdown = true;
    }
    IEnumerator deleteTimer()
    {
        yield return new WaitForSeconds(deleteTime);
        Destroy(Bullet);
    }

}

}

prime sinew
#

and !code

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.

prime sinew
#

please use a paste bin

prime sinew
#

Bullet does not exist in deleteTimer

#

you have errors, or you're coding in discord

ebon timber
#

check your console for the errors

#

usually those answer more questions than a stranger can

#

tbh i'm a novice at this engine but an expert in game dev and coding

#

always check between your chair and your computer

prime sinew
ebon timber
#

whatever i'm paid to code

#

i just came off a typescript engine and now my employer has me on roblox, which isn't very fun

outer nimbus
#

Ik the problem, It is because it's because I've declared the Bullet in the if statement and therefore it's not accessible in the coroutine.

ebon timber
#

at least lua has globals

#

that last engine had no globals

prime sinew
#

so your code didn't even compile?

#

i just came off a typescript engine and

boreal bone
#

I'm a very experienced user with Unity and C#, and I'm trying to make a fast paced multiplayer game. I've tried doing it before but every time I tackled a multiplayer project, it ends up becoming extremely non-scalable down the road and I give up because of the immense amount of refactoring that I'd have to do.
So my question is, are there any recommended papers, articles, or documentation that I could reference that cover the design strategies for a scalable multiplayer game?

next steeple
#

So for people who use composition over inheritance, I've been wanting to try switching to composition but this one scenario keeps tripping me up. In my game I have a weapon class that all weapons inherit from. The player can equip any of the weapons since they inherit from the weapon class. The player can fire the weapon because the parent abstract weapon class has a fire method on it and each weapon implements their own fire method. Is that actually possible with composition?

fallow abyss
#

Hi. Is there a way to create SO with a default value based on another SO? Basically I want to create Item SO that will look at list of items in another SO and get the count of that list.
EDIT: I mean create in Editor not in game.

next seal
#

what does it mean that I hold on to the objects through the domain reload >_> and htat it prevents the GC from collecting them

#

which list should I clear before domain reload callbacks and recreate after, and how do I even do that like i know how to clear lists in theory but I dont know how to do that before or after any domain reload callback

main shuttle
# boreal bone I'm a very experienced user with Unity and C#, and I'm trying to make a fast pac...

You are aware of Unity Gaming Services: https://unity.com/solutions/build-backend#multiplayer / https://unity.com/solutions/gaming-services
It has hosting, matchmaker, lobby system and more that all can scale the way you would want if you use Unity Netcode, and is free up to a point afaik.
For the networking questions, I would suggest asking in #archived-networking, if there are any networking experts they would hang out there.

ocean swallow
main shuttle
ocean swallow
#

ayyyyyyyy

main shuttle
ocean swallow
#

yeah it shoots now

main shuttle
#

Just remember, isKinematic kills all simulation of your rigidbody. You need to use the specific methods for isKinematic to move it.

ocean swallow
#

what do the kinematic methods allow you to do that makes the distinction relevant?

main shuttle
# ocean swallow what do the kinematic methods allow you to do that makes the distinction relevan...

https://docs.unity3d.com/ScriptReference/Rigidbody-isKinematic.html

Controls whether physics affects the rigidbody.
isKinematic kills the physics of the rigidbody. With the kinematic methods, you can move the rigidbody and still have the physics checks in place that you would not get when you would reposition it with .position. So you can never teleport through a wall with the kinematic methods, which would be possible with the .position style.

shell scarab
#

Hello, how would I either have Quaternion.Slerp NOT affect the Z axis, or Vector3.Slerp take the shortest rout?

I am by no means familiar with Quaternions, although I am understanding them a bit better each time I work with them, as well as having watched some basic videos explaining them.
I know that Quaternion.Slerp will take the shortest rout, but I want to do that without affecting the Z rotation if both z rotations are the same from rotation a to rotation b, like how Vector3.Slerp does, but if I use Vector3.Slerp it does not take the shortest rout because, as far as I am aware, it reads 0, 0, 0 as well 0, 0, 0. I've tried Slerping from the negative of the rotation based on the signed angle between rotation a and b, but that only works some of the time. Any help or advice?

Also I cannot just set the z rotation to 0 after the quaternion slerp because if there's a change of rotation on the z axis it needs to do that, just not if there's no change.

inner yarrow
#

Need help with portals.

unreal notch
#

Hey, im working on writing myself an enemyAI and animation controller, because I hate using the animator mecanim for 2D sprites.

In the mecanim, you can transition between states with exit time
set that to 1, and the animation automatically goes to the next state when the current animation is finished.

How can I achieve this through code? I DO NOT want to be setting custom delay timers for every unique animation, I just want some way in code to confirm that the current animation has finished

rain minnow
unreal notch
woven ocean
#

Hey I was wondering what counts as code-beginner, general and advanced. Im fairly familiar with C#/Java as a backend dev, but not super familiar with good Unity practices and all of its features. Where would my questions belong?

unreal notch
#

but I think I found the answer

#

if(anim.GetCurrentAnimatorStateInfo(0).normalizedTime > 1)

this might do what I'm looking for

rain minnow
rain minnow
# woven ocean Thanks

Based on beginner or intermediate c#, you can kind of tell where your question may belong. Mostly architecture and systems design talk, or performance ends up here

Beginner is mostly syntax, formatting, collision, and a bunch of mechanics (not entire systems)

Advanced is anything beyond, like working with packages, some low-level stuff, ecs, graphics/core systems. Crazy stuff. You'd know if your question was advanced though . . .

dusky spear
#

if i call this function multiple times once for each shape in the shape group, but with the same list every time, will it add all of them together or just overwrite it each time

woven ocean
somber nacelle
dusky spear
#

ok

#

hmm i could use this function instead

#

if i pass null or none or whatever as the first list since i dont care about the shapes i just want the vertices would it complain?

somber nacelle
dusky spear
#

ok

#

il just make a list and then not use it

karmic bloom
#

I know you can click to move using the NavMesh agent on your player in 3D, does anyone know of a video/tutorial/website that does this but also uses grid based movement? Or if anyone has any suggestions. Thanks

potent sleet
karmic bloom
#

Right I can do grid based using WASD, but point and click I can't seem to get. I can get the player moving to the point I click, but they go in the straightest path

potent sleet
#

navpoints will def be harder

#

you'd have to mess with the navmesh algorithm

#

I think it's still Astar

dusky spear
#

wait if im getting the shapes from a collider2d, when i initialize the physicsshapegroup2d first, what do i put in the parameters if i dont know how many vertices the collider has

karmic bloom
# potent sleet you want the navpoints or destination to be on grid

Gotcha. I have WASD working fine, the only issue is I then am having a tough time wrapping my head around how to tell the script if the player can or can't walk to the next tile on the grid.. I was using a raycast, but then I would have to check all 4 directions and I think it's just too much. I felt like clicking would be the easiest way?

#

Because then I can just check the clicked location (I think).. I've only ever done regular player controllers (WASD, space to jump) so this is my first attempt at this

potent sleet
#

which grid

karmic bloom
#

Navmesh seems to be what most suggest online, but it doesn't have to be navmesh

potent sleet
#

you can check if the path is reachable

karmic bloom
#

grid meaning the grid I've created in unity

#

Using 3d objects.

#

They're just spaced apart specifically to where right now when the player presses "W" for instance it moves one tile

potent sleet
#

do the aStar pathing on the tiles

karmic bloom
#

I guess I don't know anything about it?

#

Also wasn't aware you could tilemap in 3D

#

I thought that was a 2D feature.

potent sleet
#

it is kinda

#

im using it here

karmic bloom
#

hmm do you know of any videos that explain it well?

#

Are you using click to move or just the grid for something else

potent sleet
#

my click to move cheats tho

#

it's navmesh

#

but Im sure you can use the same method on the tiles itself with Astar pathing

steady moat
#

You should start by using Unity Navmesh.

#

If you have performance issue, you can then try to implements your own pathfinding solution

karmic bloom
#

I have used it and it works.

#

Just not the way I want.

#

I am asking if I can get the player to move on a grid vs taking the straightest path.

steady moat
#

So you want your player to move 1 tile ?

karmic bloom
#

1 would work for now.

potent sleet
#

you just cant directly modify the navmesh generated points as far as im aware

steady moat
#

Do you limit your movement ?

karmic bloom
#

No I have no limits set. So inside NavMesh I can tell it to only allow the player to move 1 tile?

potent sleet
karmic bloom
#

gotcha

potent sleet
#

if its greater than 1 tile size, dont move

placid ridge
#

I've been trying to make a bullet, but i've been having trouble, and i can't figure it out. Could one you guys help me?

public override void Shoot(Vector2 _shotDirection, Vector2 _shotMomentem, int playerId)
    {
        Bullet bullet = Instantiate(GameManager.instance.bulletPrefab).GetComponent<Bullet>();
        GameManager.bullets.Add(bullet);
        Vector2 direction = _shotDirection + _shotMomentem;
        // Rotate Gun
        float rotZ = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
        bullet.transform.rotation = Quaternion.Euler(0f, 0f, rotZ);
        if (rotZ < 89 && rotZ > -89)
        {
            bullet.spriteRenderer.flipY = false;
        }
        else
        {
            bullet.spriteRenderer.flipY = true;
        }
        bullet.transform.position = GameManager.players[playerId].transform.position;
        Debug.Log(GameManager.players[playerId].transform.position);
        bullet.transform.position = bullet.transform.right * GameManager.instance.bulletSpawnTeleportDistance;
        bullet.transform.position = new Vector3(bullet.transform.position.x, bullet.transform.position.y, -1f);
        bullet.Init(speed, damage, _shotDirection, _shotMomentem, bulletSprite);
    }```
main shuttle
clever lagoon
brittle sparrow
#

I'm not sure if this is the right channel for it, but I was wondering if, instead of using Collider Components for collision, the mouse can check if it's within a sprite's rect boundaries, and if the pixel of the sprite it is currently touching is transparent or not (and just in case, using an alpha threshold of at least 0.05 or something). The pixels of the sprite would be of the camera's resolution, not of the Texture2D's.

If it's not a thing, I could implement it but I'm not sure how I can get the reference of the Camera-resolution-processed Texture2D objects
Or I could just give up and use the normal Texture2D? But it won't always work out