#archived-code-general

1 messages Β· Page 163 of 1

orchid island
#

wait fr?

#

ill try to unpack it

leaden ice
#

Also instead of doing [SerializeField] GameObject _idleParticles and then GetComponent<ParticleSystem> you should just do:

[SerializeField] ParticleSystem _idleParticles;```
leaden ice
#

an instance in the scene would be fine

#

it seems like you're referring to a prefab from the project folder

orchid island
leaden ice
#

but whatevs

orchid island
#

true

#

i still get the same error

simple egret
#

What are you dragging into _idleParticles, in the Inspector?

orchid island
#

oh wait...

#

mb

#

the particlesystem is on a child of it πŸ˜…

teal knot
#

does anyone know why Directory.CreateDirectory(Path.GetDirectoryName(fullPath)) seems to think the directory already exists even if the capital letters are different? (for example, it will write in the directory named "tesT" rather than create a new directory called "test")

teal knot
#

windows 10

leaden ice
#

and which filesystem

#

I think Windows 10's filesystem might not be case sensitive

teal knot
#

even if visually the folder can use capital letters?

leaden ice
#

yes

#

See if you can even create two folders in the explorer that differ by capital letter

#

This is what happens when I try to do that on my Macbook

teal knot
#

🀯

leaden ice
#

thats not windows ofc

teal knot
#

ur right yeah

#

surprised i didnt know that xD

#

that explains it then, thanks a ton!

rancid kindle
#

i cant see my gizmo
how do i fix it
can anyone help me w this

lapis egret
#

Have tried for a couple hours, every lightmap on every object in my scene is full black. The scene itself is lit, but all the lightmaps are black

#

what stupid thing am I doing

lapis egret
rancid kindle
#

ye

#

im tryna see if it is there

lapis egret
#

in the top right of the scene view are gizmos enabled? Is this a custom gizmo or something?

rancid kindle
#

like this

lapis egret
#

uncheck 2d πŸ™‚

rancid kindle
#

NA IM MAKING IT IN 2D

#

caps

#

sry

lapis egret
#

The gizmo is used for 3d navigation. It disappears when the 2d button is toggled on

somber nacelle
#

that's not true

soft shard
# rancid kindle

That circle looks like it may be from the "Rect" tool (used for UI), which tool do you currently have selected? (should appear in the top left of the Scene window by default)

rancid kindle
soft shard
#

That might be why you are not seeing gizmos, that tool is meant for Canvases/UI, try switching to the 2nd from top, which should be the 3-arrows you showed earlier (the hotkey for that I think is W as well)

lapis egret
#

oh i thought they were talking about the 3d thingy

rancid kindle
#

damn this still aint working

soft shard
somber nacelle
#

are you actually zoomed in enough to see it?

rancid kindle
#

like i just wanna see that it is there

soft shard
somber nacelle
#

doesn't matter, it will still show the gizmo they selected for it

#

provided they aren't zoomed out hella far

last peak
#

has anyone messed with the idea of merging sprites?

rancid kindle
#

wait one sec

#

let me try make another project

#

cuz i did mess w sprites

#

yo can i stream to u?

#

cuz it aint even working in a new unity

copper blaze
#

how would one go about making sprite animations for ui elements since you're not able to use the SpriteRenderer component?

rancid kindle
#

it works with other game objects

pure cliff
#

That's Coroutines, not Tasks

vagrant blade
somber nacelle
pure cliff
#

I was wondering if unity had one for specifically Tasks that serves the same purpose

await Task.Frames(5)
Etc

soft shard
copper blaze
rancid kindle
somber nacelle
rancid kindle
#

on the bottom is a spirt rendere

#

on the top there is a empty game object

#

idk why its not giving me a gizmo for the top

somber nacelle
#

at this point you should probably post your issue in a relevant channel with all of the relevant info all in one message

pure cliff
somber nacelle
#

only works in 2023 though

rain minnow
pure cliff
#

Yeh I'm on latest stable 2023.whatever

#

Easy enough to make a static extension that is something like Awaitable.NextFramesAsync(n); with that method existing

rancid kindle
#

do unity acc hates me i go to the help section to let them know my problem and it fixes itself

#

les go

#

was the empty game object suppost to be the child of the camera????

somber nacelle
#

it wouldn't need to be just to see the gizmo. i use empties with gizmos on them quite frequently to mark stuff like attach points, spawn positions, etc and have never needed to do anything special to be able to see them. even when they have no parent object

rancid kindle
#

my unity must be buggin cuz i cant see it when it is out of the camera's heirarchy

woeful dagger
#

Hi, weird question, but why do I only have input field tmp and not input field?

somber nacelle
#

you do have the legacy one, but use the TMP one instead

#

it's Betterℒ️

#

use the correct type. also !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.

somber nacelle
#

the type for a TextMeshPro UI object is TMP_Text or TextMeshProUGUI (the latter inherits from the former)

upper pond
somber nacelle
woeful dagger
#

Sorry, I'm completely new with Unity. Trying to help Fiance with her uni project. So I'm a bit lost with this all.

somber nacelle
#

it is against server rules to get help with AI generated code

woeful dagger
#

oh, my bad. Sorry.

somber nacelle
woeful dagger
#

Will do, thank you very much

#

And thanks for the link. It seems very useful.

gusty jackal
#

is doing 'LoadScene' in an async function essentially the same thing as doing 'LoadSceneAsync'

#

asking because i want to get the referance to the scene

torn eagle
#

Can anybody tell me what's goofing up the code to make it go backwards?

#
public class Slingshot : Manager, IDragHandler, IBeginDragHandler, IEndDragHandler
{

    public Camera m_cam;
    public GameObject objectInSling, holder;
    Rigidbody babe;
    public Transform slingMid;
    Vector3 slingPos;
    public float power = 10f;

    void Start()
    {
        //m_cam = Camera.main;
        babe = objectInSling.GetComponent<Rigidbody>();

        babe.isKinematic = true;
        if (m_cam.GetComponent<PhysicsRaycaster>() == null)
            Debug.Log("Camera doesn't have a physics raycaster.");
    }

    public void OnDrag(PointerEventData eventData)
    {

        Ray R = m_cam.ScreenPointToRay(Input.mousePosition);
        Vector3 P = R.GetPoint(1f);
        P.z = 0.1f;
        Vector3 pN = slingMid.position - (slingPos - P);
        Debug.Log(pN);
        
        holder.transform.position = P;
    }

    public void OnBeginDrag(PointerEventData eventData)
    {
        Ray R = m_cam.ScreenPointToRay(Input.mousePosition);
        Vector3 P = R.GetPoint(1f);
        P.z = -0.1f;
        slingPos = P;

        Debug.Log(slingPos);
    }

    public void OnEndDrag(PointerEventData eventData)
    {
        var.slingSlung = true;
        Vector3 slingStuff = (holder.transform.position - gameObject.transform.position) * power;
        
        babe.isKinematic = false;
        babe.AddForce(slingStuff, ForceMode.Impulse);
        objectInSling.transform.parent = null;                
    }
}```
#

I want it to only be able to be pulled back

last peak
#

probably flipped a value somewhere

vapid pawn
#

Hello! Does anybody know if there's a way to get the closest point on a bounding box from within the bounding box itself? Using ClosestPointOnBounds from a point within a collider just returns 0.

jade phoenix
#

why can't i change this?

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.

somber nacelle
jade phoenix
#

its a code related question

#

my code requires a universal architecture selected

somber nacelle
#

then show your code

jade phoenix
#

that wouldnt help you

somber nacelle
#

lmao because this isn't a code issue. it's an issue with changing your build settings.

#

but that option that is greyed out is likely influenced by whatever platform you have selected

jade phoenix
#

hmm

swift falcon
#

could someone tell me what i am trying to jump on the ground but it wont let but then when i go to the side ofo a block it has me jump

jade phoenix
#

i get an error when building that in xcode that the functions arent correct

last peak
#

hey boxfriend, where can i find the discord for the c# book you told me about?

somber nacelle
#

on the book's website

last peak
#

gotcha

#

ty

oak prawn
#

How do i setup a proper achiteture to deal with animation triggers?

For example, i do have my playerController

public class PlayerController : MonoBehaviour
{

    public Animator animatorFoo;
    private void Move()
    {
        //Do move...
        animatorFoo.SetTrigger(1);

    }
}

Its usually the way i do to trigger animations, but it does not respect SOLID principles. What's the proper way to setup this? Tried doing using Observers, but it messes up with my state machines.

vale wharf
#

(reposting since I forgot a few details in my first post)

Trying to modify and 'improve' a dungeon generating algorithm to fit my needs.

The algorithm as it currently stands works like this:

  • Place a starting module and add it's exits to a list (pendingExits)

  • For a certain amount of iterations, go through every pending exit and place a new module at them. Exits define which type of module can be attached to them (i.e. only a "room" type can be attached or only a "corridor" type can be attached)

  • If the new room doesn't overlap anything, add the new module's exits to the pending exits list (skipping if it finds no room that doesn't overlap anything when placed)

The changes I want to make are:

  • Allow a way I can force there to be only a certain amount of a specific type of module placed(so I can define 'special' module's which only appear once or twice throughout the generated dungeon)

  • Remove the iteration based generation and replace it with something that guarantees the amount of module's generated

How can I modify the algorithm as it currently is to achieve this?

steady moat
#

Your problem is a Constraint Satisfaction Problem (CSP) if you want more information. It is well documented.

last peak
# somber nacelle on the book's website

im honestly really suprised at how well this is keeping my attention, and its also an amazing resource to look at when you need to know how something works

runic granite
#

hi, so i already create earth map that pin point some country like japan, how to set "look at" for spesific country?

vale wharf
#

My main issue right now is it generating stuff like this.

#

Nothing can be placed on the remaining junction exits (left) and nothing can be placed on the exit of the curved corridor (right)

#

The only solutions I can think of are recursive in nature, i.e. don't place a corridor if nothing can be attached to it's exits when it's placed, and then also do that check again for whatever can be attached to that corridor

rare turtle
#

hiya. I have a TextMeshPro element where I'm trying to change the colour of individual words. I'm updating the colour32 elements and calling UpdateVertexData, but nothing is happening on screen. I can't see any missing steps from the handful of examples online, does anyone know what to do? I can change all of the text tint at once, but not individual quads.

My base colour is white so it should be working as multiplicative, right?

rare turtle
#

hadn't heard of it until now, is it part of textmeshpro?

quartz folio
heady iris
rare turtle
#

chur thanks πŸ™‚

heady iris
rare turtle
#

with rich text is it possible to get word screen position so that individual words can be linked to clicks?

heady iris
#

doesn't TMP have a "link" system already

#

i'm very fuzzy, but it's come up before

leaden ice
#

yes it does

rare turtle
#

not sure, I'm pretty new. I'll look for that too, thanks πŸ™‚

prime sinew
rare turtle
#

I'm so mad. this took 5 minutes to set up, but I'd spent a week kicking around vertices under the impression that was the only way. thanks google

#

more than a week

#

MAD

#

thanks everyone

rare turtle
woeful slate
#

Hi all, for the A* Pathfinding Project by arongranberg, how do I update the node's tags to add penalties? I've tried using a GraphUpdateScene component with the modify tags setting but it doesn't seem to be working for me

last peak
#

how do i return a tuple of enums?

quartz folio
last peak
#
Enum randomDrink = (drinkBase: randomBase, drinkSyrup: randomSyrup, drinkTopping: randomTopping);
#

i think im doing it wrong somehow

quartz folio
#

Yeah, why are you assigning that to Enum?

last peak
#

ohh i see

#

the reason i did that is because i didnt know what variable could store it i guess?

leaden ice
last peak
leaden ice
#

You want vertx's link then

#

though I recommend simply creating a custom struct or class for this

last peak
#

tyty yall

trim fox
#

https://hatebin.com/pcgnocpukq

Hey, question about decisiontrees here -

I'm currently making a nodebased tree, but I'm not fully sure how it works (the guy who was teaching me didn't fully explain it).
In particular, I don't actually think/know that the code I have in the link shows if the tree actually knows how to go to a specific branch in the node. I also don't know if I should be adding the leaf nodes to the nodes with checks on them, (pardon the nodes at the very end, I've yet to add them to any existing nodes as children).

If someone has answers, please ping me/ping reply, thanks in advance. I can provide clarification on specific things as needed, but otherwise I've tried to snip it down to the relevant parts.

jade phoenix
#

is there a wrap operator like %= but for when numbers go below a threshold?

leaden ice
#

% is a remainder operator btw

#

a % b gives you the remainder when a is divided by b

jade phoenix
#

dk if you remember this, but you gave me this code earlier to change the hue values of a material's color

                h += Time.deltaTime * 2f;
                h %= 1f;```but i want to do the same for saturation, except some objects are glowing outlines and their values need to be reversed from the rest of the object's saturations
leaden ice
#

uhhh meaning what exactly?

#

Does the saturation need to change over time?

jade phoenix
#

yes

#

to achieve a flashing pattern

#

it kind of works here, however the outlines of the blocks are out of time with the insides

leaden ice
#

shouldn't it just be s = 1 - (sOfTheOtherThing);

jade phoenix
#

no

#

it does some weird flickering thing

jade phoenix
#
    [Range(-1f, 1f)]
    public float glowSat = 0f;

    void Update()
    {
        renderers.ForEach(r => {

            float h, s, b;
            Color.RGBToHSV(r.material.color, out h, out s, out b);

            if (r.gameObject.tag == "outline")
            {
                //if (s >= 0.01f) s += Time.deltaTime * 2f;
                //if (s > 1.49f) s = 0.01f;
                s = glowSat;
            } 

            r.material.color = Color.HSVToRGB(h, s, b);
        });
    }```why does the saturation not update whenever i mess with the slider in the inspector?
leaden ice
#

is the game running?
Do your renderers have the "outline" tag? (btw you should use CompareTag)

jade phoenix
#

yes and yes

#

i get this fun thing in consoleFormatException: Input string was not in a correct format. System.Number.ThrowOverflowOrFormatException (System.Boolean overflow, System.String overflowResourceKey) (at <492e64214f0c42f2b51bf2d39219ebe6>:0) System.Number.ParseInt32 (System.ReadOnlySpan`1[T] value, System.Globalization.NumberStyles styles, System.Globalization.NumberFormatInfo info) (at <492e64214f0c42f2b51bf2d39219ebe6>:0) System.Int32.Parse (System.String s) (at <492e64214f0c42f2b51bf2d39219ebe6>:0) BubbleSpawner+<>c.<Update>b__8_0 (System.Char c) (at Assets/Scripts/BubbleSpawner.cs:34)

leaden ice
#

Looks like an error at Assets/Scripts/BubbleSpawner.cs:34

#

you are trying to do int.Parse with an invalid string

jade phoenix
#

oh

quartz folio
#

Can I also ask why you're using the lamda ForEach instead of a normal one?

jade phoenix
#

because i come from java and its engrained in me

#

is there a downside using it here?

leaden ice
#

there's a downside in Java too πŸ˜‰

quartz folio
#

Creating a delegate is unecessary

leaden ice
#

Some people decided in Java 8 that regular for loops were an antipattern and that's a damn tragedy.

jade phoenix
#

alright well the int parse thing was a bit unrelated, just accidentally put some extra stuff in a config

#

i still cant get this saturation thing to update

#

oh its not updating

#

changing the slider doesnt update the variable in the script

quartz folio
#

what's with the NRE in your video?

jade phoenix
#

NRE?

quartz folio
#

NullReferenceException

jade phoenix
#

should be fixed

leaden ice
#

that's a different error

jade phoenix
#

well im not getting it now

#

if i have this slider script attatched to the prefab of an object will it not affect all instances of it?

#

at least during runtime

leaden ice
#

each instance has its own independent internal state

#

that's why they're called instances

#

the only time a copying happens is when the objects are first created:

  • when the scene starts
    or
  • when you Instantiate the prefab
jade phoenix
#

for some reason when i change the brightness of an object with an emissive shader on it, it loses the glow

leaden ice
#

Do you mean Bloom postprocessing?

jade phoenix
#

possibly

#

a teammate made the glow

leaden ice
#

bloom is based on the brightness of the pixels relative to the rest of the image

#

it needs to be brighter than the rest of the screen by a certain (configured) threshold to be affected by bloom

jade phoenix
#

ah ok

#

but i thought brightness gets capped at 0-1

#

whenever i set the slider to 1, it still doesnt bloom

#

yeah the threshold is 0.75 right now

cobalt gyro
#

whats the record keyword used for

somber nacelle
#

not fully supported in unity though

leaden solstice
#

Modern .NET when πŸ˜„

river wharf
#

I want to convert a string to UI text and I want to insert a new line in the text, I am editing this string in the inspector and tried using \n but this just actually writes \n into the text. Is there any way for me to put a new line into the string through the inspector ?

river wharf
# cobalt gyro Are you using TMP

Unfortunately no because i am working on an older project, but if its necessary, I could just go and replace the text with tmp.

cobalt gyro
#

cuz if you are then make sure rich text format is enabled on the text object and use <br> instead of \n

river wharf
#

yeah no Im using legacy text

river wharf
leaden ice
#

you can also do:

[TextArea]
public string MyString;``` to get a better editor for it
river wharf
leaden ice
#

it does if you use TextArea

river wharf
#

ok ok

#

thanks

river wharf
soft shard
#

Is there any way to use an Assembly Definition file exclusively as a auto-namespace (or any other way to setup auto namespaces in Unity), or would the best solution be to inject into the AssetPostProcessor and check "if script file, re-import with desired namespace" or create a custom editor window to essentially create "script templates" that already have the namespaces I want? I have a "Assets > Scripts" folder organized into sub-folders for each feature of my game and my end goal is to be able to create new C# scripts, and already have the class nested in a "namespace ..." for them, is there maybe a common approach for this?

somber nacelle
#

if you're creating your script files in the unity editor just set the root namespace setting in the editor project settings

soft shard
#

Oh interesting, didnt know that existed - im guessing that would be globally? So it wouldnt matter where in the project a new script file is created it will always use the same root namespace?

somber nacelle
#

yeah

soft shard
#

Ah perfect, thatll help a lot then, thanks

somber nacelle
#

if you want it based on folder structure you should create the files in your IDE. you just have to make sure to set up whatever the relevant settings for that are (i cannot remember what they are off the top of my head and it will also likely depend on the ide you use)

soft shard
#

I use Visual Studio (2019, and sometimes 2022 but I dont think the version would matter too much), would these be like "templates" or some keyword I can lookup in VS to do that?

soft shard
#

I may have found something, though looks like ill have to mess with XML and file systems, might have to look into it further, thanks for the insight btw

crisp iron
crisp iron
timid narwhal
#

I have a question. What is Mathf.PerlineNoise range of definition? In other words, in what range do the x and y parameters need to be?

thin aurora
#

Between Single.MinValue and Single.MaxValue

tidal rapids
#

Anyone have any idea if you can code for unity to throw a warning? Like the yellow "!" ones not the red ones

spiral ibex
#

Debug.LogWarning

tidal rapids
#

I tried that and it seems to be the same as debug.log

lean sail
tidal rapids
#

I believe I was but Ill try again

#

Unity crashed while trying to reload from saving the code😒

tidal rapids
#

Thank you

mellow bane
#

can't wrap my head around this: I have a static Initialize() function in a script that i need to run before any Start() functions in the scene... is there an easy way to do that?

spiral ibex
#

Awake executes before start

thin aurora
#

If you spawn an object and want to pass data to it, calling initialize after spawning it should work fine

mellow bane
#

Awake() does the job for now, thanks!

trail torrent
#

hello guys, does anyone know how i can get the volume of the microphone?

surreal valve
#

How do I make this script load a different scene and unload the current one?

prime sinew
surreal valve
daring verge
#

Let's say I have a component that is in an Editor folder. When I make the build, that component would not be part of that build, right?

spiral ibex
#

Yes, unless you have assembly definitions in place.

prime sinew
#

could be that OnTriggerEnter doesn't get run at all. Or it didn't pass the Tag check

#

or the number of unlocked levels

surreal valve
#

most likely

prime sinew
#

then check

surreal valve
daring verge
spiral ibex
thin aurora
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.

deep karma
#

i have a bullet spread system, it takes two angles (right and up) and adds them to the camera forward rotation to get the direction for raycast, but for some reason when the forward rotates, the 20 on the x starts inverting, coming to become -20 in the 180 angle. How can i stop that from happening? Quaternion temp = Quaternion.Euler(20, 0, 0); Debug.DrawLine(transform.position, transform.position + (temp * transform.forward*5), Color.blue); this is test code but it has the same issue

deep karma
#

it also does nothing at angle 90, it just stays at zero, it looks like the x value is being passed through a cos function

ashen yoke
#

i just cant pinpoint why it fails

#

help me here

#

euler constructed there is absolute offset

#

which should work properly with a local Vector3.forward

#

transform.forward is a worldspace vector

#

the problem happens when you try to rotate the global forward by local euler

#

so what happens is, the rotation flips gradually when going from z+ to z-

deep karma
#

but isn't Vector3.forward just 0,0,1 how is it influenced by an object's rotation? Or is that some quaternion magic i don't understand i still have no idea how those things work mathematically

ashen yoke
#

yes if it was local coords system, Vector3.forward would be local

#

but since its global, there is no local, and you already have a world vector in transform.forward

jovial moon
#

How could I get OpenFracture to work with my custom mesh? It's a very simple mesh. 6 points 8 faces. An extruded Triangle.

I use a MeshCollider for the collisions, which I have tested for physics and it's exactly what I would expect. But when I use OpenFracture, no Mesh is assigned to the fracture objects.

deep karma
#

ok so i did some random things with code and stumbled upon this solution Quaternion temp = transform.rotation * Quaternion.Euler(val, 0, 0); Debug.DrawLine(transform.position, transform.position + (temp * Vector3.forward * 5), Color.blue); it works... for some reason, i really don't understand how, or what's changed but it does, not complaining tho

ashen yoke
#

here

#
        var offset = Quaternion.Euler(20, 0, 0) * Vector3.forward;
        var rotation = transform.rotation * offset;
        Debug.DrawLine(transform.position, transform.position + transform.forward + rotation, Color.blue);
#

oh you came to the same solution

#

haha

#

it works because it avoids using transform.forward

#

builds a local rotation, and adds it to current world rotation

deep karma
#

makes sense

ashen yoke
#

my guess is there is some "math loss" in the process of using already "final point" world forward to compute something

#

skill or mmr based?

#

different things

rigid island
hasty canopy
#

MMR based I guess? Like trophy system

hasty canopy
lone laurel
#
  void OnTriggerEnter(Collider other)
      {
          if (effect != null) {
            effect.Play(); 
            
          }
          Debug.LogError("coll");
          Destroy(missile);
          
      }

how i can add delay after effect.play

ashen yoke
#

coroutine

lone laurel
#

ty

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

public class CRASHMISSILE : MonoBehaviour
{
    public GameObject target;
    public GameObject missile;
    public ParticleSystem effect; 
    private IEnumerator WaitAndPrint(float waitTime)
    {
        while (true)
        {
            yield return new WaitForSeconds(waitTime);
        }
    void OnTriggerEnter(Collider other)
      {
          if (effect != null) {
            effect.Play(); 
            
          }
          coroutine = WaitAndPrint(2.0f);
            StartCoroutine(coroutine);
          Debug.LogError("coll");
          Destroy(missile);
          
      }
    
    void Update()
    {
        
    }
}
}
rigid island
# lone laurel ty

btw if you just want to destroy something with time, Destroy method has adelay parameter on it for seconds

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.

rigid island
#

you ddin't need to copy and paste the whole code without understand how it works lol

simple ridge
#

Hi everyone, I spent this yesterday but didn't get a reply so thought about asking again. Does anyone know if there is an easy way to render handles on top of gizmos? I'm using draw line to render some debug data for a level generator in the editor, and I'm also using handles.label to render some text in regards to this. However the text is always rendered behind the draw lines. Is there a way to change this?

ashen yoke
autumn shuttle
#

what is effect.play

simple ridge
#

Should handles be placed else where?

ashen yoke
#
 SceneView.duringSceneGui
 SceneView.beforeSceneGui
simple ridge
#

Ah thank you!

#

I'll see if I can find some docs on when SceneView is used so I understand this all a bit better, thanks!

ashen yoke
#

its a wrapper around the viewport in editor

chrome flicker
#

Can someone help me understand why my update method isn't repeating the threshold check? It works the first time, but once the main function ends, it doesn't repeat the process like I want it to. It just starts the record again, but I want it to wait anch check the threshold until it's exceeded again. It seems like it might be holding a value and just restarting automatically.

ashen yoke
#

so brace for a lot of info

leaden ice
next salmon
#

hello. im trying to implimante crouching into my rigidbody charachter controller and it works like this :
when the crouch key is pressed change the players scale to 1,0.5,1 then move the player up by '0.875f' so the camera does not change its position and the player drops down on the ground. but for some reason the player only moves up by '0.875f' some times. not all the time. whats the problem here?

http://pastie.org/p/7eh2aECVn0iDMRXy50BAwL

placid island
#

where should I ask questions about compute shader?

#

is it ok here?

robust dome
#

there is #shader

placid island
placid island
#

ok thanks

robust dome
#

good to know.

heady iris
#

i need to get into that a little more

royal temple
#

Hello guys, has anyone been faced with a problem regarding Screen.width and height values as well as the safeArea values?
I am seeing some weird results in the Simulator as well as the Android builds. Anything I find online says it has been fixed in an earlier version of Unity but it doesn't seem that way.
Screen.width (in editor) seems to be the size I put in Game tab, not the actual screen size of the simulated device.
And in a packaged build, it's also not the right values (Safe Area is bigger than Screen.width and height)

chrome flicker
# leaden ice It looks like you are setting `loudness = 0;` but that variable is unused accord...

I believe so? Full disclosure, I’m doing something very complicated with basic coding knowledge and GPT supplementing that lack of understanding.

When the program starts, I have a threshold check which I confirm using a visual object which scales with mic input. It works until the process completes, then it doesn’t scale anymore until the function is restarted manually as opposed to via threshold.

chrome flicker
royal temple
brittle sparrow
#

Since this involves scripting api stuff, I chose this for tilemaps. Basically, I'm doing a raycast on a tilemap, and I want to get a bunch of information about that specific tile, but its Sprite in particular. How should I go about doing this? I'm pretty sure my raycast grabs the whole tileset if it succeeds..

jovial moon
craggy veldt
jovial moon
#

Ohhh good idea, thank you! ❀️

late rivet
#

Is there an EventSystems interface that would allow me to click and drop UI elements? I need the same thing that IDragHandler does but instead of dragging things, i want to click on them and then click where i want them to drop.

leaden ice
#

e.g. track if you are currently in the "waiting to drop" state

#

and handle that on the next OnPointerDown

potent moat
#

Hello! So i have a very simple and direct question but cant find a way to do it in any of my research.: So I love this zipback project and use it in allll of my projects now, https://github.com/mukaschultze/unity-zip-backup - The only thing I want to change is that when it creates a zip file of the project, I would like it to put the contents into a folder with the name of the project before making it a zip file. Right now it just puts the backup folders (assets etc.) directly into a zip file without being contained in a folder. ANY help appreciated

GitHub

Unity extension to backup projects into zip files using 7z or fastzip - GitHub - mukaschultze/unity-zip-backup: Unity extension to backup projects into zip files using 7z or fastzip

tawdry jasper
#

I'm working on dynamically loading scenes via triggers, and I wonder what is the purpose of setting the active scene?

late rivet
#

Is there a function like GraphicRaycaster.Raycast but that returns the first element hit by the raycast instead of a list of elements?

copper blaze
#

how would one play an animation over a given amount of time?

green grove
#

Hello! I want to rotate red object on collision so its top face always be turned to the surface. How i can do that?

late rivet
# green grove

For example, you can check if it's transform.x is bigger than than the transform.x of the white object. If it is, then you know the red object is to the right of the white object, so you rotate the red object by 90 degrees. Understand?

pure cliff
green grove
late rivet
pure cliff
# green grove yes

I would create trigger collider boxes with a script I make that has a serialized vector made public.

OnTriggerEnter of the player Id check if the other object has that component, and if so change the players gravity direction to be said components vector value.

green grove
pure cliff
#

Id maybe also create a circle one without any value, and instead use OnCollisionStay2D or whatever its called and continously point their gravity vector towards the center of the circle collider

#

Oh I guess you could also add a float for gravity strength too

#

(to said component)

green grove
pure cliff
#

Finally you'll need to swap controls around depending on the rotation ideally, which is a fair bit of work but feels pretty slick once you get it working

late rivet
green grove
pure cliff
#

Oh actually no, you may also want a "push away from center" one

late rivet
pure cliff
#

You use "pull to center" for convex curves.

You use "Push from center" for concave curves

and you use "Uniform direction" field for straight lines

#

!collab

#

oh hm, bot is ded?

green grove
#

I tried setting red object transform.top to collision.contacts[0].normal but it changed object proportion

distant crest
#

?

pure cliff
pure cliff
green grove
#

I dont even understand what gravity field you talking about

pure cliff
covert linden
#

I hope someone here can help me, I have made a character in Blender and gave it ShapeKeys (called BlendShapes in Unity) which all function perfectly in Blender, however when I change the values (weights) in unity, it only works when the game is not running. So I can use the BlendShape sliders to let my character blink, but if I want to change the value, use the slider, or change value through code all while running the game, it does not work.. I have tried to find solutions but haven't found anything. I stumbled across a comment from 5 years ago that said to export the FBX as ASCII, and then it should work, however this export is not an option anymore in Blender. Hopefully someone has a solution.

pure cliff
#

Hrrrm, do namespaces break Editor scripts?

Assets/Scripts/ShowOnlyAttribute.cs:

namespace Assets.Scripts
{
    public class ShowOnlyAttribute : PropertyAttribute
    {
       ...
    }
}

Assets/Scripts/Editor/ShowOnlyDrawer.cs:

using UnityEditor;
using UnityEngine;
using Assets.Scripts;

namespace Assets.Scripts.Editor
{
    [CustomPropertyDrawer(typeof(global::ShowOnlyAttribute))]
    public class ShowOnlyDrawer : PropertyDrawer
    { .... }
}
#

using Assets.Scripts; is greying out and its failing to find ShowOnlyAttribute inside of ShowOnlyDrawer.cs

#

Im getting the "type or namespace could not be found" error for `ShowOnlyAttribute" inside ShowOnlyDrawer

lucid wigeon
#

I have 2 rigidbodies: player and vehicle. When player is in vehicle seat i make him a child object of vehicle so that it "sticks" to the vehicle. But then I want to disable player physics and gravity. If I set isKinematic = true then it seems player blocks movement of the vehicle. I see disabling Rigidbody is deprecated.

How would I implement this? Do I need to remove & reattach Rigidbody each time?

pure cliff
#

Oh ffs I missed the global:: on that type, derp derp, have to remove that and it works

knotty sun
knotty sun
#

what code do you have?

covert linden
#
public class EmotionsController : MonoBehaviour
{
    private float mSize = 0.0f;

    private void Start()
    {
        InvokeRepeating("Scale", 0.0f, 0.01f);
    }

    private void Scale()
    {
        
        if (mSize >= 100.0f)
        {
            Debug.Log("Done Running");
            CancelInvoke("Scale");
        }

        GetComponent<SkinnedMeshRenderer>().SetBlendShapeWeight(0, mSize++);
        Debug.Log("Running");
    }
}
#

Used this from someone's old tutorial on youtube to see if it would work, but at the moment it doesn't

knotty sun
#

that looks ok for setting toungeOut, should work

covert linden
#

When I run the game it changes the weight for a split second but more in a 'glitchy' way, not how it should

knotty sun
#

you may be better using a coroutine rather than invoke repeating

covert linden
#

That is what I used before trying this

#

I have tried the most ways to change a value through script, and none of them could change the value

#

But GetBlendShapeWeight does work correctly, so it reads the weights properly, and gets the correct blendshape counts

#

But SetBlendShapeWeight does not work

green grove
knotty sun
knotty sun
#

and I would definitely use a coroutine for this

covert linden
#

This project is just that, I wanted to see if it works so there's nothing else atm

pure cliff
covert linden
swift falcon
#

Can you tell me what it differs NativeArray to an Array with simple examples and how memory handles that?

potent sleet
#

internet says NativeArray offers more control over memory and usually goes in par with JOBS

covert linden
#

@knotty sun

public class EmotionsController : MonoBehaviour
{
    private SkinnedMeshRenderer EmotionsRenderer;

    private float mSize = 0.0f;
    private float mSizeUpgrade = 10.0f;

    private void Awake()
    {
        EmotionsRenderer = GetComponent<SkinnedMeshRenderer>();
    }

    private void Start()
    {
        StartCoroutine("TongueEmote");
    }

    private IEnumerator TongueEmote()
    {
        for (int i = 0; i < 3; i++)
        {
            Debug.Log("Forloop check");

            EmotionsRenderer.SetBlendShapeWeight(0, mSize);
            mSize += mSizeUpgrade;
            yield return new WaitForSeconds(1f);
        }

        yield return null;
    }
}

Made this real quick and still is not working, the coroutine works as the debug.log prints three times

fervent furnace
#

Array lives in managed memory while natives array live in cpp kernel

leaden ice
swift falcon
#

Hm so its used for manage its lifetime by manually. Thank you

knotty sun
covert linden
knotty sun
covert linden
#

None work, and the sliders are 'stuck' when game is running

knotty sun
#

hmm, no idea, theres nothing wrong with the code or setup. maybe ask on the Blender discord

covert linden
#

Will do, thanks anyways

pure cliff
#

Trying to figure out a solution here to an issue for my UI code, might need some insight.

Tile based game, the player can select a given tile to move to it. With mouse they click on it, but I also have built in KB / Controller support, which lets them move around the "selected" tile before they can submit and then it acts like they have clicked said tile.

All this logic works the same way, the mouse click vs submit with KB/Controller should do the same thing.

I draw a highlighted path of Tiles from Player -> Target, to show the route the player is going to go as well.

All of this works fine, except for one hiccup: I have logic so that if they move the mouse anywhere that isnt a valid tile, I erase all highlights and set GameState.UI.SelectedTile back to null.

Problem is, every frame Im doing these checks and thus if they have these conditions:

  1. Mouse is hovering over an invalid square
  2. They press WASD to move their selection

It first moves their selection over (using player as the starting point), but then it goes "Oh wait, your mouse is over an invalid square, actually erase all those tiles now"

#

I need to figure out a way to remember if it was KB vs Mouse that was the last input, and its looking like I may just need to straight up save this to a variable :/

#

However, perhaps I can first check if the mouse has moved or clicked since last frame, and only use its position then?

#

Nevermind, thanks for rubber ducking yall haha, it was actually straightforward after I reasoned that out above:

private Vector3 _lastMouse = Vector3.zero;
private Vector2Int? GetSelectedTile()
{
    var currentMouse = Input.mousePosition;
    if (currentMouse == _lastMouse)
    {
        return GameState.UI.SelectedTile;
    }

    _lastMouse = currentMouse;

    var mouseRaw = Camera.ScreenToWorldPoint
    (
        Input.mousePosition,
        Camera.MonoOrStereoscopicEye.Mono
    );
    // and then I do the thing
    ...
}
glossy wave
#

Hey! i have this variable in my code: public UnityEvent questGoalReached = new UnityEvent();. I would like this event to get invoked when a specific boolean changes to true. is it possible to set this up using the Inspector?

#

like so?

    public void CheckIfComplete()
    {
        quest.goal.IsReached(); // this line will return true/false
    }
pure cliff
glossy wave
pure cliff
#

Specifically something like

CheckIfReached() {
   if (IsReached) {
      QuestGoalReached?.Invoke();
   }
}
#

Or however it is unity events work, I dont use em, I use normal C# delegate events personally as then I can utilize in T for structs to make the event as lightweight and smol as possible

glossy wave
#

thanks!

#

could you give an example of how this would be done the way you do it?

pure cliff
#

no probs, I declare this delegate on its own, to start, which lets me create events of in T

/// <summary>
/// Custom Delegate for Property Change Events, utilizing "in structs" for minimum memory usage and maximum performance
/// </summary>
public delegate void ReadonlyEventHandler<T>(in T propertyName);

And you can set up the event on your class via:

private event ReadonlyEventHandler<SomeVarType> MyEventName;

And then you invoke that event via the usual:

MyEventName?.Invoke(myVarOfThatType);
#

in my case SomeVarType is a string, so I would pass a string into the invoke, but you can make it whatever you want

#

and then you subscribe to it via:

ClassReference.MyEventName += (in SomeVarType e) => {
  ...
};

Or

ClassReference.MyEventName += OnMyEvent;

public void OnMyEvent(in SomeVarType e)
{ ... }

Both work

glossy wave
#

thank you

#

(in what part do you define what "myVarOfThatType" must be in order for the event to trigger?) thx

somber nacelle
#

events can only be invoked from the object that owns them. so in this case myVarOfThatType would either be a local variable or field on the object that owns the event

pure cliff
pure cliff
cold parrot
pure cliff
#
protected void InvokeMyEvent(string value) => MyEvent?.Invoke(value);

So annoying that I have to do this so often if I want inheritance to work, lol

pure cliff
cold parrot
pure cliff
#

Also then that means non-inheritted members can invoke the "event", which we dont want. We only want that class and its children to invoke it

#

purely just want to be able to invoke events on subclasses without being forced to make a wrapper method

cold parrot
pure cliff
heady iris
#

It's a consequence of how event works, yeah.

#

Mildly annoying.

#

I've run into that before.

pure cliff
#

I hope they eventually fix that to have like a { invoke } decleration or something

#

Id imagine it as like

public event MyDelegateType MyEvent { private/protected Invoke; }

Would be nice

surreal valve
heady iris
#

GameObject.Find is static.

surreal valve
#

Should I make the Singleplayer object static?

heady iris
#

No.

#

Do what the error message tells you to: qualify it with the name of the type (GameObject), rather than a specific instance of the type (the gameObject variable)

leaden ice
# surreal valve

it's very unclear what you are trying to do in that line of code

#

also your IDE is not configured !code

#

(is the bot still dead? Ofc it is...)

heady iris
#

it's on its union-mandated smoke break

leaden ice
#

that line of code is crazy/nonsense for several reasons:

  • your GameObject.Find issue
  • the fact that you are passing a parameter into GetComponent
  • the fact that the parameter you are passing into GetComponent is a nonexistent variable
  • the fact that you are assigning the result of GetComponent to an int variable
#

basically in its current form that line is just nonsense.

heady iris
#

I mentally papered over all of those problems, somehow

leaden ice
#

proably because the IDE isn't configured and isn't noting any of them!

heady iris
#

I imagine the goal was to get the "target kills" field from that KillTracker

leaden ice
#

I imagine that whole thing is unnecessary, and that you would/should do all that in OnTriggerEnter

surreal valve
#

also, updated version

leaden ice
#

and that you would/should do allthat in OnTriggerEnter

leaden ice
#

But the first issue you need to solve is that Visual Studio is not set up properly

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.

heady iris
#

it's alive!

#

sort of

surreal valve
heady iris
#

well, trying to do this isn't going to work:

#
KillTracker tracker = /* something that gets it */;
tracker(TargetKills);
#

that's what you tried to do

surreal valve
#

So what's the solution?

heady iris
#

you want to access the targetKills field

#

so, do that.

surreal valve
#

thanks

heady iris
#

you've accessed fields several times in that screenshot above

#

e.g.

#

PlayerTransform.position

surreal valve
#

I'm still very new to Unity and C# so pardon my ignorance

heady iris
#

this retrieves position from PlayerTransform

surreal valve
#

While we're still here, how do I get KillTracker from Player specifically?

somber nacelle
#

configure your !IDE πŸ‘‡
and () to invoke a method

#

damn is the bot still dying

#

also you cannot use GetComponent in a field initializer, do that in Start or Awake instead

woeful slate
#

Hi all, is anyone familar with how to tag nodes in the A* Pathfinding project?

#

trying to apply a penalty to non-paved sections of the map

wintry grove
#

Random quick question. Using unity Camera.main.WorldToScreenPoint to place reticles on the screen in relation to large coordinates. Is there a reason why if you choose a large coordinate (I did 0, -2000, 0) it makes the UI element disappear? It's probably a simple reasoning but I'm confused.

leaden ice
#

why are you manually choosing coordinates?

wintry grove
#

for testing purposes

#

it won't actually be manually selected, but the actual coordinates would be a lot larger

#

the short reasoning is because I want the illusion the world is bigger than it really is, so if an object were to theoretically be thousands of km away I want a dot to represent that

leaden ice
#

if it's in view of the camera, it will be on screen

#

if it's not, it won't

wintry grove
#

if the coordinate is in view of the camera you mean?

leaden ice
#

yes

wintry grove
#

gotcha. Would there be a potential workaround for something like this then?

#

Not sure how games like Eve: Online do things like this

leaden ice
#

if an object is not visible in the camera, why would you want to draw a thing over it?

wintry grove
#

Okay...

So in Eve: Online as an example. There can be objects multiple Astronomical Units away from the user. They can represent those as dots / reticles of some kind as UI elements in the "direction" of the element.

leaden ice
#

this is the scenario in which is is not visible

#

it's not a question of distance

wintry grove
#

yes that's not what I'm talking about

leaden ice
#

it's a question of the camera is literally not looking at it

wintry grove
#

yeah that's wrong then lol

#

then you're not understanding what's wrong

#

uhhh

leaden ice
#

you said earlier you did (I did 0, -2000, 0) as a testing scenario

#

I find it unliekly your camera was in a position to see that position

wintry grove
#

yes and I'm looking in the direction of that coordinate

leaden ice
#

then it will work

wintry grove
#

but it does not

leaden ice
#

maybe show your scene layout and the code

wintry grove
#

I tested this with zooming out

#

and it would show then unshow weirdly

leaden ice
#

and what WorldToScreenPoint returned

wintry grove
#

sure one sec

leaden ice
#

if you just plugged that directly into your UI element's position, it might literally be too far away to see

#

according to the camera's far clipping plane

wintry grove
#

oh hmm

#

wait that might be it

leaden ice
#

you can/should just zero out the z coordinate

wintry grove
#

yes okay let me try that. I saw things regarding that on the web but wasn't sure if it was applicable

#

that was entirely the issue lol

#

Thanks so much, sorry if I was unclear initially. Hard to convey my problems lol

leaden ice
wintry grove
#

Yeah it was obvious to me but I didn't consider directly outlying that was part of the problem. Thanks again!

turbid delta
#

alright, I'm fairly lost here

#

I'm working with tilemaps, and I often forget which tilemap is currently active, which leads to all kinds of problems during level design

somber nacelle
#

this is a code channel

turbid delta
#

scripting could work around that, that's why I'm posting here

somber nacelle
#

what? do you want a script that makes you read what tilemap you are currently editing?

#

juka.Eyes.LookAt(tilePallette);

turbid delta
#

I mean, if I change the palette, it changes the tilemap also

#

so I don't have to manually change it every time I change the palette

#

or maybe there's an easier way around this

#

or maybe scripting is the way, and I should write a class that does that through the editor

#

I am clueless unfortunately

#

but I honestly can't figure out what's going on

#

maybe I'm missing something

dusky crypt
#

Hey, I have a very basic Mesh that represents a grid. For this example, every square is made up of four vertices, and the square are all connected to each other via two triangles.

The UVs for a Square are: (0,0), (1,0), (0,1) and (1,1). I'm wondering what the best approach for controlling how materials render on these connecting faces are. Right now they just appear as duplicates of the texture on the main face, which isn't ideal.

leaden ice
dusky crypt
#

Ah so for example two cells in a line, I'd split the X 3 ways to account for the connector in the middle

#

How would that actually turn out in implementation though? I'm struggling to visualize all this UV stuff.

I'm guessing if I wanted to connecting face to have a different texture I would either need to modify the existing texture to 'fit' in, or create duplicate vertices and a new submesh

leaden ice
#

yes

#

submesh might be a good option

ashen yoke
#

how do you want it to look?

leaden ice
#

with a second material

#

yeah it really depends on that^

dusky crypt
#

I already submesh for every cell that needs a different material. I'm just not a huge fan of duplicate vertices.

I'm going for a 'fit everything' solution (This is purely a learning project for me and I like to make them 'framework/library'-y). I don't think I'm very bothered by the texture having to be designed with the grid in mind though

ashen yoke
#

whats the purpose of the connectors?

dusky crypt
#

A cell can extrude on the Z axis

#

So one might be more forward then the next, etc.

ashen yoke
#

would a world space shader fix it all?

#

triplanar perhabs

dusky crypt
#

I'm pretty sure using shaders would make a lot of things a lot simpler but I am deathly terrified of them

#

I reckon I'm going to have to rewrite this mesh generation stuff a couple time irregardless, I was feeling very confident about it and then made the mistake of going online and looking at other solutions.

ashen yoke
#

other potential solutions i had in mind also were shader based

#

as for uvs, they extend indefinitely

#

so you can go 1.25 for example

#

for the connector

#

and scale it with height

dusky crypt
#

It's really tricky to wrap my head around because the connecting face doesn't have any extra vertices and I can only have as many UVs as vertices.

So if we take the picture above, the cell to the left will add:

(0,0) (1,0) (0,1) and (1,1) to the UVs. What else would it be expected to add if I wanted to treat this face as apart of the texture (so any material on it will kind of wrap around, it won't look good- but it'll make sense.)

ashen yoke
#

in any case, this is deeply tied with shaders

#

if you avoid developing a shader that helps you achieve this task you will be stuck with 2000s problem solving

#

you can do the above without shaders, you can just use a single massive atlas where each "tile type" texture is tiled several times

#

so tiles uvs are offset into the center of the tiled group

#

if the height is limited

dusky crypt
#

I'll make sure not to use any outdated Unixtime formats. My apprehension to use shaders is just a temporary restriction, I do plan to get around to it at some point, it's just a little off topic for what I'm trying to learn right now.

So, with two cells next to each other my UV array looks like this:

[(0,0) (1,0) (0,1), (1,1), (0,0) (1,0) (0,1), (1,1)]

1.25 references to (0,0) ? Or in other words, 'One extra to the right'

My UVs can be larger but I'm assuming the .25 is just 1 / Count of UVs

ashen yoke
#

uvs are not limited to 0-1

#

shader will simply loop the texture after 1

leaden ice
#

well that depends on the shader right?

ashen yoke
#

oh i think i understand

#

if its an atlas yes this is just a template layout

#

you mult it by tiles, offset inside the atlas etc

#

and 0.25 becomes scaled by height

#

so if you have height limited to say 3 units, you can pack 7*7 tiles in one tile group

#

you can also use a 3d texture btw to split the tiles so you dont have to use atlas, and can use uvs as is

#

but that requires a shader that will sample the texture from array based on something

#

like vertex color

dusky crypt
#

I am listening, but I feel like it's a bit past what I'm looking to do. Right now, I'm really not looking to exit the boundaries of just 'Setting Vertices, Setting Triangles, Setting UVs', but I do pledge to make the people who made all this wonderful technology possible proud and actually use it afterwards.

Right now the top crudely drawn picture is what I have, and the bottom one is what I want.

ashen yoke
#

yes the picture i posted solves this

#

the uvs will be continuous

#

wait a sec, in your case even if the top connector started at 0

#

it should be continuous

#

you possibly have winding order issue?

dusky crypt
#

I think I might, because if you notice the orientation of those materials isn't quite how I would like it either.

#

Actually I think I drew that right- which is wrong :P

ashen yoke
#

uvs might be mapped to wrong verts

dusky crypt
#

I'm a little confused on what maps them at all. This is where I'm getting caught with all of this actually, and I'm sure it's you not me- but it is a bit tricky to warp my head around.

It's mainly the 'You can only have as many UVs as Vertices'

#

And I don't have any extra vertices. There is four in a cell, and then, for this example- two to its right

#

But those two are used in the proceeding cell. I'm not sure what UV is telling anything to appear on these connecting faces.

ashen yoke
#

then you can only use the approach i suggested

#

since you cant break the strip

#

1.25 and so on, go over 1, below 0

dusky crypt
#

Help me here though,

So, two cells next to each other:
[(0,0) (1,0) (0,1), (1,1), (0,0) (1,0) (0,1), (1,1)]

Are you saying rather than repeat, the second (0,0) should become (1.25,1)

Or

[(0,0) (1,0) (0,1), (1,1), (1.25, 1)... etc... (0,0) (1,0) (0,1), (1,1)]

Which exceeds the amount of UVs I can have

ashen yoke
#

if its one big continous mesh that is not broken but is a strip, then first

dusky crypt
#

Just to be clear, I do want each cell to have it's own UV space. There is only about the connecting faces sharing that cell's material.

For example, I don't want this:

ashen yoke
#

you cant create a uv space if its one island

#

you can overlay islands on top of each other, so each one will start at 0,0 but it has to be a separate island

dusky crypt
#

Is what you're saying, if I want the behavior I'm describing- I'm going to need an extra row of vertices inbetween each cell?

ashen yoke
#

you technically can its just going to look broken because interpolation will fail to flatten it over uv space properly

dusky crypt
#

I might be misunderstanding you completely but would adding these extra vertices make all of this a lot easier?

ashen yoke
#

this is what happens with uvs when its continous mesh and youre setting the uvs to 0 on verts of a strip

#

that face which ends up at 0,0 from whatever uvs it was to, will be warped

ashen yoke
#

you can hack around it by having a face of 0 length in there that hides the transition, but at that point why not break it

dusky crypt
#

Some Jargon here is throwing me for a loop. Apologies if it is frustrating. What exactly does breaking it mean in this context?

What I know right now is that, when I don't 'try' at all, and simply set the UVs for the front face, the other four duplicate, and so on. As far as I'm aware (1,1),(0,0) is the same as (1,1)(1.25,1.25) because the UV loops.

That's what is in my head right now, other than the glimpses into what I want in Ms Paint.

ashen yoke
#

2 faces share 2 verts

#

if its 2 faces and 8 verts, its 2 separate faces, they dont share verts

#

so there is a "break" or hard edge in the mesh

#

where 2 verts coexist in one spot but are not connected to each other

dusky crypt
ashen yoke
#

it introduces its own set of problems

dusky crypt
#

It does. For example, if I ever wanted to add any sort of offset to the edges of a cell- suddenly I need to move two sets of vertices

leaden ice
#

why are you manually encrypting something

#

because I have no idea what you mean by "the final block"

abstract timber
#

when I build the rig builder on player for second time after host with netcode for gameobject i get this error

MissingReferenceException: The object of type 'UnityEngine.Animations.Rigging.RigBuilder' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.

so i hit host then i hit disconnect and then host agian and in my code build the rigbuilder after setting both arms target from code

            leftArmIk.data.target = gun.leftHand;
            rightArmIk.data.target = gun.rightHand;

            rigBuilder.Build();
simple egret
#

The final block encrypts the last plain bytes of data, adding padding if it's not long enough to fit a single block's length

#

But yes, you don't call these manually

abstract timber
leaden ice
#

right my link includes examples for full string encryption

simple egret
#

It's the old way yeah. You might also see some examples where they use a byte[] buffer to encrypt blocks of data to keep the RAM usage low. You don't need it with streams anymore, these are buffered internally.
The docs example have the right way of doing it

solid ledge
#

How do I display the current player coordinates while the "S" key is held down?

solid ledge
#

ah right, HUD

#

Popup text

#

Ideally in a box

leaden ice
solid ledge
#

For in the game

#

The player needs to be able to view their coordinates, but not always on

leaden ice
#

just make a ui text element and do myText.text = myPlayer.position.ToString();

#

that's the basic gist of it

solid ledge
#

alr ty

#

BRO I just set the background colour to black and

#

Tanked from 500

#

anyways to another channel!

devout harness
#

I have a game with characters defined by being an object with a bunch of fields, only the values differing on each character. Is it good practice to read those in using external data storage rather than baking them into the game (e.g. reading JSON files instead of declaring them at runtime)?

#

I.e. Something similar to RimWorld, which uses Reflection to link up code references on load after reading in all value fields

lean sail
devout harness
#

No, they're purely arbitrary (e.g. "maxHealth" or "backstory")

#

Lemme take a look at those πŸ‘

lean sail
#

What you were thinking with json is pretty much what you'd do with a scriptable object

devout harness
#

I take it they work similarly, just with proper integration with the editor?

lean sail
#

Saying they work similarly is a major stretch, but in this use case yes

devout harness
#

Functionally they reach the same goal?

lean sail
#

Json is just a file format, while a SO can run code. Its use case though is just to be a data container

devout harness
#

That sounds convenient, can they have their fields changed at runtime?

#

Or would the game need to be recompiled to edit one

lean sail
#

Yes but you should more so treat it as immutable, because these dont exactly save their values in an expected way. In a build the values dont save, while in the editor they seem to

devout harness
#

Ahhh I see

lean sail
#

The values persist between scenes only if the SO is used in the scene I believe

devout harness
#

I see-- if I need to retain the ability to permanently modify fields, would it be wiser to use JSON or is there another design pattern I can use?

lean sail
#

You would need to write to some file for this, regardless of the format you choose (formats being like json). I just wouldnt write to a file everytime the value changes

#

For something like max health or just general player stats, that value should just be read from your file at the beginning, persist through your game in some script, and write to the file every so often like end of level, maybe at checkpoints, when the user presses save

devout harness
#

Makes sense- thank you!

solid ledge
#

There has to be a better way of doing this. It's a way to let players place building components

devout harness
#

I'd like to know this too ^

leaden ice
#

I use an array of scriptableobjects for this kind of thing generally

#

or an array of prefabs

#

no need to specifically call each out in code

#

Using a Building script as your reference instead of GameObject will also make your life much easier

solid ledge
#

Well they currently just press num keys 1-5 to indicate hotbar position

leaden ice
solid ledge
#

I also need to store a calculation to work out the way it's facing based on rotation (pipe pieces) so if they rotate a straight segment, the neighbours are now north and south rather than east to west

#

Ideally it would be an object

leaden ice
#

sounds like just data that should be on your SO or on a script on the prefab

solid ledge
leaden ice
#
public Building[] buildingPrefabs; // add them in the inspector```
solid ledge
leaden ice
#

that's the simplest way

solid ledge
#

Like ideally I want it in an object {}

#

So I can have other properties

leaden ice
#

there are of course other ways but that's for later

leaden ice
#

what is an object {}?

#

what do you mean other properties?

#

The properties would be on the Building script

solid ledge
#

So I can easily do:

{
  "prefab": GameObjectHere
  "neighbours": 5
  "health": 100
}
leaden ice
#
public class Building : MonoBehaviour {
  public string BuildingName;
  public Sprite MenuIcon;
  public PipeDirection PipeDir;
  public int Health = 5;
  // etc..
}```
solid ledge
#

This can go in the same file?

leaden ice
#

Then when you do cs public Building[] BuildingPrefabs; you can just read that data directly

leaden ice
solid ledge
#

The other building code

leaden ice
#

sure

solid ledge
#

ty I'll give it a go

solid ledge
# leaden ice sure

I'm a little confused if I've done this right as nothing comes up in the inspector

leaden ice
solid ledge
#

Ah that explains a lot

leaden ice
#

yes you have an empty list of them

#

you need to make a separate file for Building

#

and then you need to attach the Building script to all of your Building prefabs

#

and set the values on them all in their own inspectors

solid ledge
#

ohh

leaden ice
#

it's a script that goes on the prefab

#

make sense?

solid ledge
#

Put the Building thing on the prefab

leaden ice
#

yes

solid ledge
#

ty

#

Slightly off topic question that I'll ask while it's on my mind. How would I "shift" this enum? For example, north, east, south, west but then I want to rotate the object 90 degrees. Is there a mathematical way to do with without a ton of maths?

public enum BuildingNeighbours : byte
{
    None = 0,
    North = 1,
    East = 2,
    South = 4,
    West = 8,
}
#

I guess something similar to bitshift

#

Maybe bitshift right 1 then add 4?

leaden ice
#

Oh wait nvm

#

i see

#

it can have multiple neighbors

solid ledge
#

Yeah

leaden ice
#

you can shift it then just if (x > West) x = North;

solid ledge
#

ty

lean sail
#

if the object itself rotates, doesnt the neighbours still stay the same?

solid ledge
#

Not in this case because I need to know it's neighbours relative to the global gridspace for calculations

quartz folio
# solid ledge Slightly off topic question that I'll ask while it's on my mind. How would I "sh...
public static BuildingNeighbours Rotate(this BuildingNeighbours directions, int rotation)
{
    int value = (byte)directions;
    for (int i = 1; i <= rotation; i++)
    {
        if ((value & (int)BuildingNeighbours.West) != 0)
        {
            value <<= 1;
            value |= (int)BuildingNeighbours.North;
        }
        else
            value <<= 1;
    }

    const BuildingNeighbours all = BuildingNeighbours.North | BuildingNeighbours.East | BuildingNeighbours.South | BuildingNeighbours.West;
    return (BuildingNeighbours)value & all;
}```
This is what I do. Hopefully it works for you
solid ledge
#

Thank you!

#

I also can't tick one with this...

quartz folio
#

Your enum is missing the [Flags] attribute

solid ledge
#

ahhh ty

#

All set!

quartz folio
#

Also my method only accepts positive integers. In my actual code it's an enum

solid ledge
#

ahhh I see, thank you.

#

The enum still doesn't let me tick "everything"

#

maybe if I add an "everything"

#

nope

leaden ice
versed loom
#

is it possible to cache a list of FieldInfo and make it not be cleaned by unity when entering play mode?

abstract timber
#

Rig builder doesn't work after destroying once

somber nacelle
#

or the obligatory "use cinemachine"

jaunty sleet
#

Does anyone have any advice for where to start to setup a server in C#?

lean sail
jaunty sleet
#

For my current game, I'm going to make a server for the leaderboard, so less complicated then multiplayer

lean sail
jaunty sleet
#

Yeah, that's true

lean sail
#

a quick google search shows theres a good amount of tutorials exactly for this

jaunty sleet
#

I'll look into doing it that way

lean sail
# jaunty sleet I'll look into doing it that way

just a warning though, leaderboards like this are gonna be extremely easy to manipulate. if you want this to be for a competitive game, you'll have to have a lot more than just a simple leaderboard

#

otherwise you'll quickly get spam entries of people submitting fake times/scores

jaunty sleet
#

By hacking my game? Is that easy to do? I'm just making a mobile game

#

I don't think anybody would want to go to the trouble to do that though

lean sail
jaunty sleet
#

lol

lean sail
#

but if its a mobile game, i doubt its really gonna be competitive so i wouldnt worry about it

#

you could just occassionally clean the leaderboard from clearly fake entries

jaunty sleet
#

Fake entries would not be distinguishable based on the way my game is, as a perfect score is pretty easy to get

#

I'll just keep copies of it incase someone does something to it

spring creek
#

I have an enum for InputModes (for what happens when you click), and I want to cycle between them
Is this stupid? It works, but it feels stupid:

if (Input.GetKeyDown(KeyCode.T))
{
    _inputMode = (InputMode) (((int)_inputMode + 1) % (Enum.GetValues(typeof(InputMode)).Cast<int>().Max() + 1));
}
pastel patio
#

enums are pretty much integers

spring creek
#

Should I just use an int instead?

pastel patio
#

I thought that you don't even need to cast it

spring creek
#

Oh, I did get an error when I didn't

latent latch
#

General question about the c# garbage collection, if I have an object listening onto changes from another via events I would assume I need to unsubscribe for this object to be cleaned up, right?

pastel patio
#

I just wrote for some random enum in my project to add by 1, it didn't get errors?
Although you'd have to deal with looping back, modulo will do: i % length.
Idk how to get the count of enums though, lemme check

spring creek
#

One sec, I'll copy it over

#

CS0019: Operator % cannot be applied to operands of type InputMode and int

lean sail
#

yes u do have to cast it

pastel patio
#

Huh... Alright, my bad.

#

I have a player that can swap what he's holding, the animations of items have Events, indicating times like StartSwing, EndSwing, Shoot etc, but since the item isn't always there, I can't directly "tell" the items.

I suppose that I needed to make a script on the player, that could pass the events down to the current held item.
I see multiple options available to me here, but I can't decide on which to use, or if there's a better way to do this.

  1. Make a generalized EventBus system, meaning that it could be used elsewhere if ever necessary. However, this would certainly be less performant and costs more memory too. As different events are added across animations the amount of Events in the event bus would increase no matter if the event is used by the current held item or not.

  2. Make a EventBus system that is specifically meant for this, that the event busses aren't registered in a list, but are independent variables instead. No more looping through a list (Nor creating dictionaries)

  3. A minimalistic way, it's likely the most performant and cheap in memory: Create a script that simply passes an integer to the held item. However you wouldn't really know what the signal stands for without checking the animation.

  4. Slightly better then 3, just pass a string instead. At least then you know directly what the signal stands for. But you'd still need to check how exactly it's written. And comparing strings are less efficient.

So... Is there a way that is "meant for this purpose"? Or at least something that can keep the readability without adding too much unnecessary costs?

white gyro
#

Have an IItem interface that contains OnPlayerEvent(PlayerEvent) where PlayerEvent is an enum. Then if you need to fire the event, just do someItem?.OnPlayerEvent(PlayerEvent.Shoot)

lean sail
pastel patio
#

Huh... Yeah, lol didn't think about usings enums

#

Yea I guess I'll use that then, thank you.

latent latch
wintry crescent
#

What could be a cause of mesh renderers randomly turning off when instantiated? I'm not doing it through code anywhere

lean sail
wintry crescent
#

when I enable it, everything works well, I don't know why it turns off now

lean sail
#

first check the prefab to see if its even enabled on there, otherwise id just create a copy of the scenario and try removing features until you can locate what specifically is causing it

#

if you really dont know where the problem originates from that is

wintry crescent
#

oh wait it has a recttransform for some reason

#

That wasn't the issue :(

dusk apex
#

Else you'll have to show code if you're accessing it but convinced it's not something you're doing.

lean sail
#

unless theres a null check, but yea i just assume theres something secretly referencing it. or some error causing it to disable πŸ€”

wintry crescent
lean sail
#

ah glad you narrowed it down

pure cliff
#

@hard viper just a heads up I made a small tweak to that PropertyWatcherBase code I shared with you prior, might be worth it to snag the latest version if you used it already.

halcyon pelican
#

Hi I'm trying to do this coroutine but it keeps telling me errors. If I try to remove one thing, other things get affected. Help!

prime sinew
#

you dont need to

#

just StartCoroutine(FadeCo(_scene))

halcyon pelican
#

<----- complete newb and is basically trying to ramshackle code together

prime sinew
#

either way, that should be the problem. you're just passing in parameters wrongly

halcyon pelican
#

okay, soryr about that

#

I thought this was a more bigger issue than I thought. Thank you

swift falcon
#

I have been using Rider for one and a half years only using free trials and do not plan to ever pay for it.
Can anyone here explain to me how I can apply a floating origin system to a multiplayer game?

mortal grove
#

i have a 3d array i would like to edit in the inspector, any ways to do that?

#

i know you can create custom editor things but im not very experienced with that

latent latch
#

You can create a struct that hold three int variables, and when you run the game, take those values and instantiate the array.

mortal grove
#

ooh good idea

#

ill see if i can get that working

#

yep that worked out! i think structs were better for my use anyway

#

thanks sm!

prime widget
#

Hey guys, I wrote some code to run around and jump using a rigidbody. But for some reason if you press the move forward key and the jump key at the same time "sometimes"(i guess depending on timing) you jump super far and the velocity of the character goes nuts. whats causing this?

#
if (isGrounded == true)
            {
                var inp = gameInput.PlayerMap.Walk.ReadValue<Vector2>();

                var moveDirection = new Vector3(inp.x, 0, inp.y);
                moveDirection = moveDirection.normalized;
                moveDirection = transform.TransformDirection(moveDirection);
                moveDirection *= speed;

                rb.velocity = moveDirection;

                

                //Jump
                if (Input.GetKey(KeyCode.Space) && isGrounded)
                {
                    rb.AddForce(transform.up * jumpForce, ForceMode.VelocityChange);
                }

            }
lean sail
#

and isGrounded would be false at that point so you are no longer overwriting the velocity

prime widget
#

any tips on how i Can fix this issue? I tried using AddForce for the movement, but every frame makes the character move faster every frame

lean sail
#

you'd also want this in fixed update

worldly hull
lean sail
prime widget
prime widget
lean sail
worldly hull
#

velocity manipulation will force the character to move with that speed instantly

prime widget
#

ok funny enough

#

im not sure why this happened

#

but simple structuring the code this way fixed my issue

                //Jump
                if (Input.GetKey(KeyCode.Space) && isGrounded)
                {
                    rb.AddForce(transform.up * jumpForce, ForceMode.VelocityChange);
                }
                else
                {

                    var moveDirection = new Vector3(inp.x, 0, inp.y);
                    moveDirection = moveDirection.normalized;
                    moveDirection = transform.TransformDirection(moveDirection);
                    moveDirection *= speed;
                    
                    rb.velocity = moveDirection;

                }
lean sail
#

Is there some way to auto generate GUID's when I add an object to a list in my scriptable object? Also is there some way to guarantee I never change them? Or do I just have to manually generate them and try to never touch them again
Havent really used guid's before but basically im just storing a bunch of hats to spawn for the player in an SO, and I want to store which one they chose to wear in a file + send the ID over the network. I dont want to store index of the list incase i end up changing the order later

pure cliff
slim basalt
#

Sorry to dump in the middle of a discussion. Does anyone know of any resources related to large-scale terrain systems in Unity, or even in general?

I already know that many games achieve large scale environments pretty well. Ones that come to mind are MSFS 2020, DayZ/Arma, Rust, Stalker, etc. I already know 2D games can manage long or large maps pretty easily (especially side-scrollers) by keeping the player at the origin and moving the map around.

Is doing this in 3D a similar concept? I have an idea of how to do this by keeping the player at 0,0, though I can see potential performance issues in calculating/translating relative distances between players and updating tons of objects.

I did find this, and someone suggested storing global offsets of chunks and I guess relocating the player. I can probably engineer a solution myself, but wanted to know if there's knowledge on how to do this or any pitfalls before I begin.
https://forum.unity.com/threads/the-way-unitys-precision-works.1287797/

lean sail
pure cliff
#

Like you just want a consistent Guid per hat forever?

green grove
pure cliff
#

You can use Guid.Parse and straight up store em in a constants file tbh, that's what I do, I use an online guid generator and just generate a whole bunch and just have a bunch of constants in a cs file

prime widget
pure cliff
#

Can also store em in an actual sql dB if you want performance for lookups

whole dawn
#

Hi,

I would like to create a plane and set its size using a bounding box, how can I do that ?

I tried modifying meshrenderer.bounds, but it's not accessible for set, only get

lean sail
#

ill probably just use an online generator then

#

performance isnt an issue, i got like 10 hats atm

lean sail
#

actually i think lossy doesnt let you write either so it might just have to be local only

pure cliff
#

You want chunks anyways to help out with culling to reduce draw calls

slim basalt
#

I see. I found another person that mentioned storing position in a matrix. i.e: every 100,100, you can store a reference to the chunk it's in, and relocate the player + environment back to 0,0.

Is there anything I could look into for more information on chunk programming? I get the concept in my head and have an idea of how to program it, but I can totally see massive bugs by moving tons of game objects at once.

Also, more about mesh optimization, I know someone that managed to do dynamic subdivison (or un-subdivision) using Quad Trees. https://www.youtube.com/watch?v=Dy-Zn5XUZ_w

prime widget
#

you can make maps up to 19999 x 19999 km this way

slim basalt
#

Well I do know at least in VRChat, some worlds can have the problem incredibly fast. Hop in a plane, fly for 1 minute, and your entire game is jittering around.

20kmx20km is pretty good and I can probably have that for now, but I wanted to see the feasibility of going larger than that, and if it's something worth doing now just so I have the functionality, or if I should just try to patch it in later if needed. Especially since the game I want to develop would have some air vehicles

prime widget
#

There are some tricks that games like grand theft auto use with aircrafts to make the map feel larger

#

there is a whole video about it somewhere on youtube

slim basalt
#

Yeah, they make them fly horrendously slow πŸ˜‚

#

My idea based on what that reddit post said, I guess it to have the chunk position as 2 Ints, and then a relative positon as floats I guess, or I guess I wouldn't need that since I have player position already.

prime widget
#

your'e g oing to run into issues with the ram the map consumes before floating point

#

have you figured out how you're going to stream the level in and out based on position?

slim basalt
#

Not specifically, but I know that I would need to stream the assets

prime widget
#

basically

slim basalt
#

I haven't worked super deeply with Unity to understand how the main thread handles this, but my hope was to offload as many things as I can to other threads using DOTS

prime widget
#

you can do it all with dots using subscenes

slim basalt
#

So I could store chunks as sub-scenes and load/unload them together over time?

prime widget
#

yeah

slim basalt
prime widget
slim basalt
#

whoa! sick! Thank you

#

Ah yeah, crap, I remember seeing this demo a couple years ago. Can't believe I forgot it πŸ˜‚

prime widget
#

but you could store eveyr object in each scene inside of an empty gameobject

#

that you just position based on position if you need to worry about floating point

slim basalt
#

I see

#

I think I will consider the options and come up with a solution. I can see potential issues with physics or other things with moving the player every X amount of chunks. Though maybe if I do this every 1km or 2km it'd be less of a problem (for the re-positioning).

#

The other problem I can see is the terrain itself. I have zero experience with the workflow for creating a seamless terrain (I was hoping to make it in blender). I also really do not enjoy working in the unity editor to place objects and manage some of that stuff.

But I guess I can decouple the terrain from the subscenes, and the terrains can be larger with dynamic LOD.

prime widget
#

the problem im forseeing is how do you know when you reposition the player/world the player wont be inside of a building

slim basalt
#

hmm, good point

#

Well, I mean. The idea is to have a chunk, and the position of the player in the chunk is relative. So when you "reposition", you re-position both the player and the scene around them. But I am not sure how to handle that with player networking/projectiles across chunks, etc, and obviously that is prone to latency issues with updating all those game objects.

prime widget
#

with networking you'd just send what chunk they're in and the offset

#

tbh

#

you could probably make really nice system that takes care of level streaming, network culling and floating point error all at once with this

slim basalt
#

Oh yeah for sure!

prime widget
#

good luck

slim basalt
#

thanks

#

Honestly, my main goal is not even to finish the game. It's more to explore the possibilities and learn skills along the way.

#

I mean, it would be totally great to have a more open, moddable FPS platform akin to DayZ, Stalker, etc., which really is my goal. But I anticipate that I won't finish it at all, and if I do probably not for years.

#

Like I think: "We have the technology to do multi-threading with ease and huge processors with tons of capability, plus tons of optimization techniques. Why don't we have a game like this yet?"

#

Like I look at Tarkov quite often and I am like: How do they manage to make their game run so poorly? πŸ˜‚

#

So I want to push myself into those architectual challenges to really determine "is it really that hard?"

#

Also John Carmack has given me a lot of (maybe unrealistic) expectations and inspiration for pushing optimization to the limit to achieve incredible experiences. I look at Doom (especially the modern ones) and think "wow"

lean sail
delicate fulcrum
#

i’ve compiled a project that works with mono with il2cpp and it crashes after the made with unity bit

#

i’m on macos and unity 2022.3.4f1

#

log says SIGTRAP

delicate fulcrum
#

please ping me if you have a solution ^_^

regal flame
delicate fulcrum
#

hm?

regal flame
delicate fulcrum
#

it finishes building

#

the actual built code doesnt work

regal flame
#

i may be mistaken there, haven't run into this recently enough to remember

delicate fulcrum
#

its on minimal

#

and i dont think stripping would affect it since the error is SIGTRAP

regal flame
#

you could be right, i'm only guessing

#

not sure what sigtrap even indicates

delicate fulcrum
#

pretty sure its breakpoints in a debugger

#

stuff like that

#

no clue why it gets triggered though

main shuttle
#

Doesn't it say more in the Player.log? Can you post the whole thing?

limber wharf
#

hey guys I am doing Photon PUN2 multiplayer game, first player creates a room then joins a game, second joins room and then the game, my problem is when the second player joins, his avatar spawns twice(when you are first player then you spawn correctly only once)

#

this is my code

#

the script is attached on a gameobject that is already on the map, so it instantiates the player, when he loads the scene

main shuttle
limber wharf
#

oh ok

hexed sparrow
#

Anyone know of a fix for this?

Unity.Entities.Analyzer references netstandard, Version=2.1.0.0, Culture=neutral, A roslyn analyzer should reference netstandard version 2.0

Started happening when I migrated to a new pc.

delicate fulcrum
#

ok yeah makes sense

#

how come it doesnt out of memory with mono though?

versed loom
#
public void Execute()
        {
            float targetSpeed = _isSprinting ? sprintSpeed : moveSpeed;
            
            bool isMoving = _playerDirection != Vector2.zero;
            if (!isMoving) 
                targetSpeed = 0f;

            float inputMagnitude = _playerDirection.magnitude;
            SetSpeed(targetSpeed, inputMagnitude);

            _animationBlend = Mathf.Lerp(_animationBlend, targetSpeed, Time.deltaTime * speedChangeRate);
            if (_animationBlend < 0.01f) 
                _animationBlend = 0f;
            
            if (isMoving)
                RotateToInputDirection();

            var targetDirection = Quaternion.Euler(0f, _targetRotation, 0f) * Vector3.forward;

            a.Begin();
            _characterController.Move(targetDirection.normalized * (_currentSpeed * Time.deltaTime) +
                             new Vector3(0f, _controller.VerticalVelocity, 0f) * Time.deltaTime);
            a.End();

            _animator.SetFloat(MovementController.SPEED, _animationBlend);
            _animator.SetFloat(MovementController.MOTION_SPEED, inputMagnitude);
        }```

this generates me 80B of garbage and i dont understand why
```cpp
_characterController.Move(targetDirection.normalized * (_currentSpeed * Time.deltaTime) +
                             new Vector3(0f, _controller.VerticalVelocity, 0f) * Time.deltaTime);```
ashen yoke
versed loom
#

wdym by deep profiling?

#

a is ProfilerMarker

delicate fulcrum
#

it doesnt seem right

#

it works on mono but not il2cpp???

#

this is so weird

ashen yoke
versed loom
ashen yoke
#

there you go

versed loom
#

but why

ashen yoke
#

because unity, marshalling, editor

versed loom
#

but if i pass just a Vector3.up, it doesnt allocate garbage

ashen yoke
#

pass where?

versed loom
#

in characterController.Move

ashen yoke
#

do you have any collision receivers that receive collision data?

versed loom
ashen yoke
#

ControllerColliderHit is?

versed loom
#

this is the only part im interacting with the collisions of the character controller

ashen yoke
#

i mean is it a class/struct?

versed loom
#

a class but its built in unity

ashen yoke
#

thats what allocates most likely

main shuttle
versed loom
#

yea i guess

ashen yoke
#

maybe also some GetComponent from collision.collider

versed loom
#

thanks a lot :DD

ashen yoke
#

hm no m_Collider cached

delicate fulcrum
#

thats like

#

in the millions of gigabytes?

main shuttle
delicate fulcrum
#

damn

#

il2cpp is kinda buggy if a restart fixes it

main shuttle
#

No idea if it does in your case, but he has the same 18446744056630378496B allocation as you

ashen yoke
#

@versed loom ~60 b

    public class ControllerColliderHit
    {
        internal object m_Controller; // 8
        internal object m_Collider; // 8 
        internal Vector3 m_Point; // 12
        internal Vector3 m_Normal; // 12
        internal Vector3 m_MoveDirection; // 12
        internal float m_MoveLength; // 4
        internal int m_Push; // 4
    }
#

80 may come from padding or RTTI

versed loom
#

they use object? kinda weird

ashen yoke
#

i converted changed to object

#

for linqpad

#

irrelevant both are 8

delicate fulcrum
ashen yoke
#

update all packages