#archived-code-general

1 messages · Page 30 of 1

terse venture
#

also here. Whats a manager class? i dont think im using one.

plucky inlet
digital mountain
#

Is there a way to make GUILayout.Button prevent clicking stuff below the button?

rapid brook
#

Hey @plucky inlet I just wanted to thank you for your help yesterday, I tried everything and it didn't work so I'm going to pixelate the model shader wise and then see if that makes some difference, anyway I didn't even thank you so I wanted to thank you now!

terse venture
#

not entirely sure what a single class is..

plucky inlet
terse venture
#

yeah 👍

#

thanks alot for the help guys!

compact verge
#

Yeah that still doesn't work. I've tried that already

plucky inlet
rustic ember
#

Damn that looks cool

terse venture
# rustic ember Damn that looks cool

thanks. Its actually a remake of a game, thought it would be a fun project just for some practice, and im already learning alot. The original game is called "A dance of fire and ice".. an excellent rhythm game!

#

So i thought id try and make a rhythm game in the style

rustic ember
#

Nice

rapid brook
#

Nah there is too many limitation on the render texture for it to be used alone 🥲, so I'll write a pixelation shader, that will give me more control over what is displayed, if I succeed I'll show what I have done in showcase or whatever channel you can display your work on 😉

compact verge
#

Whenever I try to open any windows in unity, it doesn't open. I'm trying to open preferences, but after countless attempts it still doesn't do anything when I click on it. None of the other windows open either. I've tried closing and opening unity, and resetting my layout, and it still doesn't work. This problem only occurs on my laptop (which I'm using right now) but not on my PC for some reason. Any help would be appreciated.

plucky inlet
thin aurora
#

I speak out of experience when it comes to losing an application window for half a day since it decides to open out of view

compact verge
polar marten
polar marten
#

@compact verge have you ever, in all of history, opened unity hub or unity as an administrator (if you're using windows) or using sudo on a mac?

compact verge
polar marten
#

it is very bad to do that

#

it will really break things

compact verge
#

Oh

austere cedar
#

hello, I have a problem with sound delay and cant seem to fix it even with the trouble shoot page

#

my sounds play like 0.1 sec late

#

is there any way to fix this?

dapper flower
#

Do your sounds have an empty noiseless space in the beginning?

austere cedar
#

nope

#

they sound just fine in the player

#

its just when i use them in game that they take a tiny but noticeable bit to play

dapper flower
#

when you press play, the sound noise plays right away in the player?

austere cedar
#

no

#

i have it so it plays when a key is pressed

#

i play it inside a if (input.getkeydown())

dapper flower
#

Which loop runs that if?

austere cedar
#

update

dapper flower
#

and the play sound instruction is also inside that update loop?

#

can you share the code?

austere cedar
#

yes can i send a capture?

#

screenshot i mean haha

dapper flower
#

Can you share the audio manager code? use `cs formatting, not a screenshot

austere cedar
#

ok

#

do you mean text?

#

ok

dapper flower
#

start with 3 `, add cs, follow up with your code and end with 3 again

austere cedar
#

sorry

dapper flower
#

it's `, not '

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

public class AudioManager : MonoBehaviour
{
    public static AudioManager instance;

    void Awake(){
        instance = this;
    }
    public void PlaySound(AudioClip clip){
        AudioSource.PlayClipAtPoint(clip, transform.position);
    }
}
leaden ice
dapper flower
austere cedar
#

when i inspect it it doesnt have one

dapper flower
#

share the sound wave picture

austere cedar
#

ok

leaden ice
austere cedar
leaden ice
#

you are

dapper flower
polar marten
#

it's in the docs

#

there's a lot of nuance in setting up an audio asset

austere cedar
#

ill try again

#

then

#

ive tried every combination and it still doesnt work

#

and i think in the docs it says that settings only affect the first time played

polar marten
#

what is your overall framerate?

#

and do you have any other audio effects enabled?

austere cedar
#

ok 1500 fps

#

just an empty scene

#

it wasnt working in my main project so i did a test one

#

but still

muted zealot
#

does the mathf.perlinnoise have some kind of seed? or will it give me the same outputs every time when i input the same numbers?

austere cedar
#

i think i fixed it but i dont know why it didnt work the first time i tried it

#

and its also not in the docs

#

i changed the buffer to best performance

#

thx for the help

worn bough
#

Can anybody give me tips on how to implement map "lenses" or "modes". Those that exist in Civ and Victoria for example.
I could not find any resources regarding that topic.
Do you simply assign a new material to every object or is there a simpler way?

polar marten
#

using an ubermaterial isn't necessarily giving you better performance. for example, some effects require transparency - depending on your scene, rendering everything with transparency support will perform worse than rendering most opaque things opaque

leaden ice
worn bough
plain moon
#

Hello there! Could someone explain what kind of shader is it (I mean while transition between wagons) ? https://youtu.be/ew4jsFJS5uY

Last Survivor : Zombie Game Android Gameplay - Gameplay Walkthrough Part 1 Tutorial Zombie Army Train Defense Game (iOS, Android)
Last Survivor : Zombie Game - Suup Games

👍Join And Become My YouTube Member https://www.youtube.com/channel/UCRf4-iCB2SXg9OsuFauzlsw/join

🔔Please Subscribe:
Pryszard Gaming https://www.youtube.com/channel/UCRf4-iCB2...

▶ Play video
wispy wolf
#

@plain moon You mean the way the roof disappears? There are a thousand different way to make something like that. Goole dissolve shader

plain moon
#

Yep 😄

faint scroll
#

hey guys, i have problems with a little rocket simulator i am making. I am trying to rotate the rocket based on input, and it works fine when rotating counter-clockwise but not when rotating clockwise. it is as if the rocket tries to smoothly clamp on 90 degrees. also when rotating counter clockwise, it rotates faster at the 90 degrees point
Code:

void FixedUpdate()
{
    rb = currentRocket.transform.GetComponent<Rigidbody2D>();
    rb.mass = currentRocket.getTotalMassOfRocket();
    CenterOfMass.transform.localPosition = currentRocket.getCenterOfMass();
    if (canControllRocket())
    {
        rb.AddForceAtPosition(currentRocket.totalAccelerationForce * Throttle, CenterOfMass.transform.position);

        rb.AddTorque(-rotF * currentRocket.totalRawAccelerationForce * Throttle * 0.005f, ForceMode2D.Impulse);
    }
}
leaden ice
#

it's also.. quite hard to read, as your code is quite verbose

#

would recommend adding some intermediate variables in there

faint scroll
#

wait ima make them more readable

#

better?

leaden ice
#

Still don't see anything in here that deals with input

faint scroll
#

input is recieved like this:

if (Input.GetKey(KeyCode.LeftShift))
    Throttle = Mathf.Min(Throttle + 0.005f, 1);
if (Input.GetKey(KeyCode.LeftControl))
    Throttle = Mathf.Max(Throttle - 0.005f, 0);

float RotL = 0;
float RotR = 0;
rotF = 0;

if(Input.GetKey(KeyCode.A)) RotL = -1;
if(Input.GetKey(KeyCode.D)) RotR = 1;

rotF = RotL + RotR;
#

let me check something

#

nvm, nothing found

#

the value in rb.AddTorque() doesnt change, i thought that was the problem

buoyant turret
#

Shouldn’t you be multiplying the rotation by a quaternion?

faint scroll
#

what rotation? i am dealing with Torque, not transform.rotation

buoyant turret
#

Yeah I see that now

faint scroll
buoyant turret
#

When applying torque either as a force or an impulse, you can use any value to get the required change in angularVelocity. However, if you require a specific change in degrees, then you must first convert the torque value into radians by multiplying with Mathf.Deg2Rad then multiplying by the inertia.

#

Wouldn’t this be it?

leaden ice
#

adding torque results in a change to rotational velocity

#

not a "specific change in degrees"

simple egret
#

That answer sounds AI-generated

buoyant turret
#

Lol it’s from the unity manual

faint scroll
#

even my confusion is confused, idk what to do

#

maybe its conflicting with rb.AddForceAtPosition() ?

buoyant turret
#

((-rotF * Mathf.Deg2Rad) * body.inertia)

#

Something like that right

rapid brook
#

If that's the case you could just add a force at the base of your rocket, and depending on whether you want it to steer right or left, that force would be negative or positive

#

That way the physics will be taken in account and your rocket will tilt right or left depends on the sign of the force

faint scroll
deep fable
#

How can I find the Camera.main in another scene? (I am writing a server that has multiple scenes loaded and I want to find the main camera of the player that requested something)

leaden ice
#

it just finds a GameObject (in any scene) with the MainCamera tag and a Camera component

signal wagon
#

I have a code related question, how does one functional in unity?

vagrant blade
#

What does that even mean?

signal wagon
#

Correct. A paradigm

#

In Javascript, I typically write in functions. But I wanted to know if unity has some functional friendly coding, if not, it's fine

#

Plus I am absolutely new >.<'

vagrant blade
#

Unity uses C#

signal wagon
#

A derivative I was told

vagrant blade
#

It's C#

signal wagon
#

From a Discord that led me here, some members expressed certain aspects of Unity C# isn't the same as .NET C#

#

Notably constructors are different in terms of retrieving any value?

rain minnow
# signal wagon Correct. A paradigm

your sentence structure is incorrect, that's why the confusion. unity uses the c# language which is similar in most aspects to javascript, but it's not a derivative or unity specific. there are certain aspects that are different, like constructors, but that is only for classes derived from a MonoBehaviour (a unity-defined class); it does not affect how they work in a regular c# class . . .

signal wagon
#

The latter portion, I also apologize for not being clear or specific upon entry x.x

#

But thank you for the clarification, I'll probably see if there's any good tutorials to get me started, thank you guys for your time!

vagrant blade
wispy wolf
#

How would I go about using an object pool for vfxgraph objects? How can I know when they are done playing and can return to the pool?

steep herald
#

Any good name for a class that contains data or assets and who's role is to provide requesting classes with the data/assets, with minimal logic.

E.g. my most recent need is a class that maps the gameobject layers internally to some enum so requesting classes can request layers/build a layermask dynamically based on enum values. Basically it provides layers info and does nothing else other than some internal mapping and some minor arithmetic to return layermasks.

Every time I end up with a dumb name like LayersHelper or LayersUtils or something along those lines. I was hoping someone who ran into a similar use case had a better name?

main shuttle
# wispy wolf How would I go about using an object pool for vfxgraph objects? How can I know w...

I think this is a #✨┃vfx-and-particles question. And as far as my research went, that wasn't practical there is a lot of overhead for a VFX component. What I made was a world wide VFX graph with the limit of particles set to millions, and made it so you could call a particular VFX i.e. Fireball or Explosion in that graph on a position in the world. That way I could have tens of thousands of fireballs in a single VFX graph. But maybe the #✨┃vfx-and-particles people can help you more with that, I just did it for fun.

topaz dock
#

Hey guys, I'm doing some profiling of my game... Trying to figure out what the colors in the profiler correspond to. Specifically, why does the "Scripts" category get two colors?

simple egret
topaz dock
#

Ah, got it. That makes sense.

rigid island
#

how to clamp my turret X position ?
This isn't working :\

  float degreesPerSecond = 90 * Time.deltaTime;
        Vector3 direction = target.transform.position - myne.transform.position;
        Quaternion targetRotation = Quaternion.LookRotation(direction);
        Mathf.Clamp(targetRotation.x, -45, 45);

        myne.transform.rotation = Quaternion.RotateTowards(myne.transform.rotation, targetRotation, degreesPerSecond);```
lucid valley
#

targetRotation.x = Mathf.Clamp(targetRotation.x, -45, 45);

simple egret
#

Clamp does not clamp the value you pass to it (in place), it returns a new one

rigid island
#

I see, so I need targetRotation.x = Mathf.Clamp(targetRotation.x, -45, 45); ?

lucid valley
#

yup

rigid island
#

Still not working unfortunately , what am I missing ?

main shuttle
#

You are clamping the quaternion, that goes from 0 to 1

rigid island
#

Oh..

#

I can't directly change myne.transform.rotation.x
How would I insert this clamp in between ?

main shuttle
rigid island
#

Ahh and so I'm back to the same results from last night's searches

main shuttle
#

The Slerp part seems janky to me at the end.

rigid island
#

can't believe it's this difficult to make a turret camera with limited angles :p

#

Quaternions man...

main shuttle
#

Quaternion math is a field in itself 😛

#

But I would expect his code to work to be honest, seems valid to me.

rigid island
#

The chosen answer in the thread ? I think I tried that last night, will try again with fresh mind

main shuttle
rigid island
#
        float degreesPerSecond = 90 * Time.deltaTime;
        Vector3 direction = target.transform.position - myne.transform.position;
        Quaternion targetRotation = Quaternion.LookRotation(direction);

            Vector3 look = target.transform.position - myne.transform.position;
        look.z = 0;

        Quaternion q = Quaternion.LookRotation(look);
        if (Quaternion.Angle(q, baseRotation) <= 45)
            targetRotation = q;

        myne.transform.rotation = Quaternion.RotateTowards(myne.transform.rotation, targetRotation, degreesPerSecond);```
civic ridge
#

It looks like you are clamping nothing. I believe it should be like... float f = Mathf.Clamp(targetRotation.x,-45,45);
And then use that float when setting your rotation.

rigid island
rigid island
main shuttle
rigid island
#

WTH

#

why not working for me like that ?

leaden ice
# rigid island

you're definitely worrying way too much about euler angles here. Use gizmos and visualize the rotation/direction its facing in 3D.

rigid island
rigid island
civic ridge
#

I have never had to set a quaternion angle. Too complex for me. I have only used Euler angles.

simple egret
rigid island
leaden ice
main shuttle
#
using UnityEngine;
using System.Collections;

public class Tracker : MonoBehaviour
{

    public Transform target;
    public float maxAngle = 35.0f;
    private Quaternion baseRotation;
    private Quaternion targetRotation;

    void Start()
    {
        baseRotation = transform.rotation;
    }

    void Update()
    {
        Vector3 look = target.transform.position - transform.position;
        Quaternion q = Quaternion.LookRotation(look);
        if (Quaternion.Angle(q, baseRotation) <= maxAngle)
            targetRotation = q;
         
        transform.rotation = targetRotation;
    }
}

This is my code, that made the GIF of the turret following the box.

steep herald
#

clamps in the sense that it won't go past a certain delta but it also wont likely reach its actual limits

main shuttle
#

Yeah that's fair enough, it completely stops rotating outside of the maxAngle range.

#

But a camera wouldn't know anything outside of its range anyhow.

rigid island
#

except I only set a diff transform

#
Vector3 look = target.transform.position - myne.transform.position;
        Quaternion q = Quaternion.LookRotation(look);
        if (Quaternion.Angle(q, baseRotation) <= maxAngle)
            targetRotation = q;

        myne.transform.rotation = targetRotation;```
#

what is this black magic fuckery

main shuttle
rigid island
#

wait it does work.

#

it only rotates when I'm within 45 tho

main shuttle
rigid island
#

that means in all directions too not just X

leaden ice
leaden ice
#

you should do this with pitch and yaw angles

#

as float variables

#

clamp those

#

and drive the rotation with them

rigid island
#

It sounds simpler this way but have no Idea what methods to look into, time to google then I guess

rigid island
leaden ice
main shuttle
#

That's quite an clever way to clamp it to 45 degrees, never seen that before.

rigid island
#

better than collapsing onto itself like before

leaden ice
#

some gimbal lock / roll going on too

#

might want to provide the second parameter to Quaternion.LookRotation if you aren't already.

rigid island
#

Will do some more testing and try to tune this . thanks for the help everyone!

polar marten
#

for example, you can add an AimConstraint to your security camera game object, then create a transform that it follows. limit the position of the transform such that the camera doesn't exceed its arted rotations, which is much simpler

#

right now it looks like you've reinvented AimConstraint

zinc parrot
#

whats the name of global gbuffer textures on urp?

thick socket
#

if I plan to go back to a scene later do I need to unload it?
running into random bug where my character isn't starting at the location hes supposed to when a scene is loaded
and not sure why

SceneManager.sceneLoaded += LoadState;```
```cs
public void LoadState(Scene s, LoadSceneMode mode)
{
player.transform.position = new Vector3(0,0,0);
}

When the scene is loaded...however that isn't happening (he spawned at like 5,-3 last time)

#

its almost like when built on mobile it isn't re-loading the scene...and thus not teleporting him back to 0,0,0

#

(aka go to scene1, then mainmenu, drop down to like -5y in main menu, go back to scene1 and he doesn't tp to 0,0,0)

#

this only happens on the apk and not inside of the play in unity which is why Im confused mostly lol

steep herald
#

Any splitscreen parallax techniques other than duplicating background objects and culling per-cam?

tiny orbit
#

Lets say I have a list of 10,000 object and a set of 30 conditions which I need to check. Is it better performance-wise to:

A. Loop through each object once and check all 30 conditions in each loop, applying the appropriate functions per condition
or
B. Check the condition, and if it is met, loop through all 10,000 objects and apply the appropriate condition function
or
C. They are the same

My initial instinct is A, because it is far fewer condition checks (30 instead of 300,000) However, part of me thinks that looping over 10,000 objects 30 separate times would be slower

polar marten
leaden ice
tiny orbit
prisma birch
#

Does anyone know how to search a project by tag? I have a tag that keeps reappearing and it's not in a scene, I think it's on a prefab but having a hard time hunting it down.

leaden ice
#

how and when do tags "appear"?

polar marten
#

just be succinct

#

what is the game/app and what part is this?

tiny orbit
# polar marten what is the game/app and what part is this?

The game is called Roll, you can buy and create dice, up to about 10,000 at once. Everytime you roll your dice, all 10,000 need to calculate their new value. The value can be increased by passive abilities which will usually multiply the value of all dice by some constant. So I am trying to apply these passive bonuses to all dice when they are rolled.

prisma birch
polar marten
leaden ice
polar marten
#

okay well it's sort of obvious to me that you don't have to roll each individual dice...

#

like i understand from the point of view of some starchiness that that makes sense

tiny orbit
polar marten
prisma birch
# leaden ice What is the tag? It could be a plugin adding it.

It's my own tag called "Deflect". It's something I was using on rocks and hard objects to have the player's sword deflect when striking. I found the prefab by searching one at a time but it would be nifty if you could search the project assets by tag. Seems you can only do it within an open scene.

polar marten
#

in other words, can something about the result of dice N affect dice N-1?

polar marten
#

are their effects always commutative? so are there any dice where (DICE TYPE A ROLL) . (DICE TYPE B ROLL) would not have the same result as (DICE TYPE B ROLL) . (DICE TYPE A ROLL) ?

#

for example, a dice that says "multiply your score by the side this lands on" is commutative. a dice that says "multiply your score so far by the side this lands on" is not

#

it sounds like you've basically made https://www.youtube.com/watch?v=6DORG3uIoH4 as a game (a parody of sushi go)

In this game tutorial, you'll learn how to play the gameless board game "Sushi Go!"

Buy Sushi Go!: https://amzn.to/2H92EzZ

Please consider supporting me on Patreon: https://www.patreon.com/TheDragonsTomb

Get your very own "Cards. Deal With It" t-shirt here: https://teespring.com/stores/the-dragons-tomb

Follow The Dragon's Tomb on social med...

▶ Play video
tiny orbit
polar marten
#

okay well

#

i think you should do whatever, because iterating through 10,000 items doesn't matter

#

a computer iterates through 10,000 things very quickly.

#

if your profiler starts to say that something matters, you know, then you can deal with it

#

just focus on making a fun game

tiny orbit
#

I have had optimization issues in the past

polar marten
#

well

tiny orbit
#

so I wanted to see if there was a clear answer here

#

but yeah its kind of like if sushi go had 100's of different cards

polar marten
#

someone sent me this meme today where it's daffy duck counting money with the heading, "asking a senior developer 4 questions and getting the answer 'it depends' each time"

#

that's you

#

there's a really high level way to optimize this, but it may exceed your math abilities, and it may constrain your design space in a way that is not fun

#

nobody wants to do math for fun

tiny orbit
#

so theres not 1 thats inherently better?
for
if
if
if

vs

if
for

if
for

if
for

polar marten
#

for example, if i had 10,000 six sided dice, and you asked me to roll all of them, i wouldn't call math.random 10,000 times

polar marten
#

they have performance problems due to colossal flaws in their code, which they don't share

tiny orbit
polar marten
#

like that function can be implemented in O(sides) instead of O(numberOfDice)

#

and

int RollNDiceAndReturnSum(int sides, int numberOfDice) {
 ...
}

is O(1)

tiny orbit
polar marten
#

okay, you're basically answering every question with "It depends," you don't need me to go through the "it depends" thread

#

you're totally capable of figuring this out yourself 🙂

#

go out there and make the game

tiny orbit
#

i mean the game is made, just working on an update

#

trying to bring it to mobile

#

and afaik optimization is quite strict on mobile platforms

tiny orbit
polar marten
#

so they're the same

#

it doesn't matter if it's an if statement. you must know that

#

the essential part is if they're commutative

#

you didn't miss anything here

#

your profiler isn't pointing any of this out

polar marten
tiny orbit
#

ok thanks

polar marten
# tiny orbit ok thanks

do you think you can implement this in O(sides) ?

? RollNDice(int sides, int numberOfDice) {
 ...
}
#

i think this is the first exercise you need to do

tiny orbit
polar marten
#

if i fill in ? i am going to give away the insight you need to have

#

on this journey

polar marten
#

what if i asked you to flip N coins?

#

can you do that in O(1)?

tiny orbit
#

Im not sure what the function is trying to achieve

polar marten
#

to learning how to optimize your game

polar marten
#

here's a question i dont' think gives anything away. if i ask you to flip 1,000 coins, about how many will be heads?

tiny orbit
#

If all you want to know is how many of 'numberOfCoins' will be tails and how many will be heads, you can just say
tails = rand(0,numberOfCoins)
heads = numberOfCoins - tails

polar marten
polar marten
tiny orbit
golden garnet
#

Hey! Could someone please help me fix a code like this to interpolate a sprite(or any object)'s alpha color from 0 to 255 when the player gets close?

  float MinDist = 5f;
 
  void Update () {
     if(Vector3.Distance(transform.position,Player.position) <= MinDist){
      *Colorlerp code goes here*
  }
}```
polar marten
#

like in real life

#

if you flipped 1,000 coins

#

about how many will come up heads

tiny orbit
#

500

golden garnet
tiny orbit
#

lmao

polar marten
#

so clearly tails = rand(0, numberOfCoins) is wrong

#

how did you figure 500 was the right answer?

tiny orbit
#

its odds*trials

polar marten
#

okay so

polar marten
#

there must be some way to still incorporate random right? like the method isn't

int ExpectedHeads(int numCoinFlips)

it's

int Heads(int numCoinFlips)
#

so on this journey

#

to optimize your game

#

if you truly want to optimize it

#

you have to be able to give me a random number of heads in O(1) time, that is at least correct

#

@tiny orbit is this helpful?

#

@tiny orbit do you see why tails = rand(0, numberOfCoins) is wrong?

fiery rover
#

Hey real quick what is going on with my raycast? it is not going out or anything i tried debugging it and everything it just does not want to go out

            RaycastHit hit;
            if(Physics.Raycast(rayStart, Vector3.down, out hit, Mathf.Infinity, whatIsGround)){
                
                Debug.DrawRay(rayStart, Vector3.down, Color.black, 1000);
                Debug.Log("Ray Start: " + rayStart);
                Debug.Log("Hit Point: " + hit.point);
                Debug.Log("Normal: " + hit.normal);

                if(hit.point.y >= minHeight){
                    GameObject tree = Instantiate(prefab, hit.point, transform.rotation);

                    tree.transform.SetParent(prefabParent);
                    tree.transform.Rotate(Vector3.up, Random.Range(0, 360), Space.Self);
                    tree.transform.rotation = Quaternion.Lerp(transform.rotation, transform.rotation*Quaternion.FromToRotation(tree.transform.up, hit.normal), rotateTowardsNormal);
                    tree.transform.localScale = new Vector3(
                        Random.Range(minScale.x, maxScale.x),
                        Random.Range(minScale.y, maxScale.y),
                        Random.Range(minScale.z, minScale.z)
                    );

                    prefabArray.Add(tree);
                }
            }
fiery rover
#

Like when i start the raycast will not even raycast it hits nothing and their is no Drawray debug i have Gizmos on

tiny orbit
polar marten
#

@tiny orbit if you can solve this problem you can go way further than "10,000" dice

leaden ice
#

and if that doesn't do anything you need to make sure the code is even running in the first place

#

which means Debug.Log but OUTSIDE the if statement

fiery rover
#

Yea its running i have iteration for the for loop debugs and when it starts and ends ill try it outside the if statement

leaden ice
#

what for loop?

#

I see no for loop

#

please share the full context of your code

polar marten
#

what would be the right "choice" for variance of a normal there?

fiery rover
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.

polar marten
leaden ice
#

infinity is infinity

#

infinity not being long enough is definitely not the issue

tiny orbit
polar marten
#

the snippet i shared that is O(coins) is meant to illustrate that you couldn't possibly need a variance like Normal(mean, variance) does, because Random.value is uniform

polar marten
fiery rover
fiery rover
#

The raycast line

leaden ice
#

and how is that being drawn?

#

and what layer is the "ground" on?
And how is the layermask set up?

golden garnet
leaden ice
fiery rover
leaden ice
#

it's also... super far in the distance. 7k?

#

Everything will start getting fuzzy out there

fiery rover
#

I have it is a system where the farther away it is from the player its disabled but the closer it is its enabled

leaden ice
#

well it's not going to get hit by raycasts when it's deactivated

fiery rover
#

heres one thats closer to the player

leaden ice
#

where's the mesh coming from

#

custom meshes, especially non-convex ones, can have messed up geometry

#

which could cause physics queries to fail

fiery rover
#

That would be the render Queue correct?

leaden ice
#

Not sure what you are asking

#

what would be the render queue?

fiery rover
leaden ice
#

What does this have to do with your mesh/mesh collider?

#

this is a material

#

it's for rendering

polar marten
fiery rover
leaden ice
#

I'm not talking about rendering

#

I'm basically talking about where you assign a mesh to the MeshCollider

#

which seems pretty sketchy - you're doing it in some callback, you need to debug if/when that runs and make sure that's actually happening

#

and of course - the mesh itself needs to not be messed up geometrically

thick socket
#

If I call scenemanager.load("Scene1"), then same for mainmenu, then load Scene1 again...why does Scene1 not "reload" and instead keeps continuing from last load? (Only happens on mobile)

fiery rover
#

Honestly i dont know much what that does i was just trying to get terrain generation so i started watching Sabastion leagues videos on it but it could probably be the way with the lod around line 194? i think the mesh its self is fine but i dont know

thick socket
#

(When a new scene is loaded my players position resets...it doesnt reset between main menu and scene1 rn)

#

Cant find amything online...I imagine if I unload Scene1 it may fix it...but is that bad practice?

barren void
#

Is there a documentation about the background threads in Unity?

tiny orbit
polar marten
cerulean mist
#

Hello everyone! I'm currently working on a weapon for my game which shoots mines similar to minesweeper. When the player shoots a mine, it should stick to the ground/wall it lands on and align itself along a grid. I've gotten the alignment working, however on certain surfaces things seem to break (angles and probuilder walls) Thoughts on what I could do to fix this?

private void CreateGridSpace(Collision collision)
{
    Vector3 pos = transform.position;

    int gridX = Mathf.RoundToInt(pos.x);
    int gridY = Mathf.RoundToInt(pos.y);
    int gridZ = Mathf.RoundToInt(pos.z);

    Vector3 result = new Vector3(gridX, gridY, gridZ);

    GameObject newGridObject = Instantiate(_gridObject, result, Quaternion.identity);
    newGridObject.transform.rotation = Quaternion.FromToRotation(newGridObject.transform.up, collision.contacts[0].normal) * newGridObject.transform.rotation;
}```
#

(as you can see, sometimes the spawned tile just floats or becomes burrowed into the ground, some elevated higher than others on the ground)

tiny orbit
runic swallow
#

Hello guys, I am creating a script for ending the game when going through a box 2d collider(trigger) but in the condition that the boss is first defeated. Any ideas?

cerulean mist
#

I recommend having a game manager class of some sort to control important parts of your game rather than random classes.

tiny orbit
polar marten
# tiny orbit Still not sure how this will help me though, because the probabilities for each ...

In probability theory and statistics, the binomial distribution with parameters n and p is the discrete probability distribution of the number of successes in a sequence of n independent experiments, each asking a yes–no question, and each with its own Boolean-valued outcome: success (with probability p) or failure (with probability

...

#

sampling from the binomial distribution gives you the exact answer "given a coin weighted p=0.5, how many heads to i see if i flip 1,000 times"

#

this is the answer to O(1)

tiny orbit
#

ok yeah makes sense

polar marten
#

you can then continue this journey to see how this generalizes to dice

young yacht
polar marten
#

you will have to express the player's collection of dice in a way that's useful for optimizing down the number of computations you have to do

#

so that you can do a mix of ordered and unordered computations, and simplify

#

fortunately, that is literally Algebra

#

for example, if the user had the following collection (i don't know anything about your game)

dice 0...16 are 6 sided, evenly weighted
coin 17 says, "0.75 weight, heads means double the previous score, tails means 0"
dice 18...29 are 6 sided, evenly weighted

you can seemingly do this in 3 steps instead of 30. but your game needs to be able to express the state of the user's collection in e.g. an algebraic way / appropriate format in order to be "simplified" into those 3 steps

golden garnet
polar marten
#

in this case, it would be

sum(multinomial(17,6)) * {0.75 ? 2 : 0} + sum(multinomial(11,6))

#

@tiny orbit does that make sense?

tiny orbit
polar marten
#

there is already algebra that can do
multinomial(x,6) + multinomial(y,6) = multinomial(x+y,6)

polar marten
#

it doesn't really matter

#

i am advocating for a framework of optimization

#

i brought 30 steps down to 3, which is a 10x speedup

#

you probably expected a 20% speedup, and i'm giving you a 10,000% speedup

#

do you see what i mean?

#

anyway just think about it

#

it's your game

#

i think it's a cool premise for a little game

#

i liked dicey dungeons, i like dice, i like this

#

it's intriguing to move dice around in this huge order

#

it's intriguing if this works for millions of dice

tiny orbit
#

yeah, I hear you

polar marten
#

kindly send me a link to the pre-existing build 🙂 feel free to ping me and pick my brain

hidden kindle
#

I need some AI coding help

#

I'm trying to get my enemy AI to jump if it detects a gap along the waypoint path

#

I came up with a solution but it seems to only work when the player is close to the enemy

tiny orbit
polar marten
# tiny orbit yeah, I hear you

doing the algebraic simplification would be O(dice), but only once. there's of course no free lunch. simplifying the marginal dice would be O(1). you would need to run O(dice) whenever order changes, if that's something you can do in your game

polar marten
#

i don't know if there's a more efficient approach than what i'm suggesting. it might be the general limit on how optimal this can get. i don't know how to "cache" random results, by definition those will be different each scoring

#

it may be that your game lets you do something of the form

random values * constant cached values

#

but i feel like the algebraic simplification will cover that. that is my gut

polar marten
polar marten
#

you can send me a testflight link to the appleid i sent you, or if it's not necessarily super sensitive, you can always add me to github and boot me later lol

#

i'm happy to share a game with you as collateral. i don't think this stuff is very sensitive

thick socket
#

Have a prefab thats instantiated once when it starts, not even ina scene

#

Just in game resources

thick socket
#

Tldr, do I need to unload scenes?

#

Have a bug happening as I thought I didnt

valid minnow
#

is there a way i can get my current scenes build index and assign it to an Int in my script?

golden garnet
#

Hey, my game is calling OnTriggerEnter twice for all objects in my scene, can anyone help explain why?

leaden ice
golden garnet
leaden ice
#

check your colliders

plucky karma
# tiny orbit Lets say I have a list of 10,000 object and a set of 30 conditions which I need ...

#archived-code-general message
If you truly care about mobile optimization, I highly implore you to use DOTS for this kind of stuff. You will never, in a million of years, be able to compete against DOTS's pure and raw performance power it can offer. (Plus, it improves your mobile battery lifespan due to sufficient usage of memory calls!)

#archived-code-general message
Sounds like you are relying on guarantee answer from your 10,000 rolls, or has already been calculated ahead of time before the animation plays? You either trick the dice to roll into the "expected" side by compute ahead of time and play the animation, or simulate into the correct alignment.
Otherwise, what's the point of expecting the rolls be 50% all of the time? Use Random.Range(0,6);, Always use pseudo random generated number to avoid people predicting your game behavior.

Back to your original question, which all of this should've been in a thread a long time ago... Read the first paragraph! Took me forever ago to read through all of this!
A. DOTS computes the whole entity at once. It doesn't have to iterate 10,000 monobehaviour objects.

B. See DOTS! Check it out.

C. What do you mean "They are the same"??? Can you please elaborate more on this, for clarity.

Please watch this! https://www.youtube.com/watch?v=yTGhg905SCs

Far North Entertainment is working on a third-person zombie horde shooter using the Data-Oriented Technology Stack (DOTS), which has brought great performance improvements and influenced the development team's mindset to be more data-oriented in general. This beginner to intermediate level talk explains why DOTS is able to process data much fast...

▶ Play video
golden garnet
#

I will, I'm sure it isnt a performance issue at least

leaden ice
valid minnow
pearl otter
#

Is it possible to check if a an object is colliding with another object without OnCollisionEnter?
I am instantiating objects in random positions, and some are being placed inside other objects

leaden ice
pearl otter
#

Can you please elaborate?

leaden ice
#

which part are you confused about

pearl otter
#

"direct physics queries"

leaden ice
#

Stuff like Physics.OverlapBox etc

pearl otter
#

Although, what if I don't know the scale of the object?

leaden ice
#

the scale of what object

plucky karma
#

I would consider making a scriptable object, which holds information that you can later modify and create collections, which expose size and shape of the object you're about to spawn.

#

It's super neat, and can be addressable 😄

#

Then whatever script you're spawning, would hold those scriptable class type. Implement a method inside your scriptable object script that can return you the size and shape you need to perform physics api in your scene. Having a container with necessary information helps solve complex problems.

wispy wolf
#

What's the type for a field that accepts a VisualEffect graph object? Because public VisualEffect vfx doesn't let me add the vfxgraph

leaden ice
#

which is usually what you actually want

plucky karma
#

Sounds like an X/Y problem...

wispy wolf
#

I want a gameobject to have a reference to a graph so it can play it whenever it needs to

leaden ice
#

so you can call Play() on it

plucky karma
#

See's @leaden ice response. Reference the component, and invoke it's implementation.

leaden ice
#

it's the analog to ParticleSystem

pearl otter
wispy wolf
leaden ice
leaden ice
#

Go to a GameObject

#

Add Component

#

VisualEffect

#

then drag your graph into the slot in that component

plucky karma
# pearl otter I don't know the unity scale of my object though lol

That's where you fill in the missing information! In the scriptable object, you can add fields along with the object you are going to spawn. Figure out how big your object, and record it down! Either that, or simply reference the collider that contains the information about size.

wispy wolf
#

So I need to make a gameobject for each graph I want to be able to use?

pearl otter
#

Alright

leaden ice
#

but if you want to play VFX graphs you need a VisualEffect component

wispy wolf
#

I will be playing different visual effects simultaneously, so it sounds like I need to make child gameobjects with players, then reference those players in the parent gameobject. Right?

leaden ice
#

think of VisualEffect like AudioSource
VisualEffectAsset is like AudioClip

leaden ice
thick socket
#
 void StartGame()
    {
        SceneManager.LoadSceneAsync("Scene1");
        SceneManager.UnloadSceneAsync(SceneManager.GetActiveScene());
    }

How should I be doing this?

runic swallow
thick socket
#

has like a little glitch/lag when doing it this way vs just doing LoadScene

leaden ice
thick socket
# leaden ice what are you trying to do

in short I am on my main game, scene1, I then click to go to mainmenu, I think try to go back to scene1 and scene1 hasn't "reset" and is just continuing from before I loaded mainmenu

#

so Im thinking I need to unload previous scene when loading a new one

leaden ice
thick socket
#

oh with the code

leaden ice
#

you want to load the menu scene, asynchronously? Then unload the first scene once the menu scene is done loading?

#

Or what

thick socket
#

reposting as I did typos

leaden ice
#

You're using async methods

#

you need to start acting like it 😉

#

you have to either wait for the operation to finish

#

or subscribe to the asyncoperation's onComplete event

#

before doing the next thing

thick socket
#

gotcha

thick socket
#

since if I do stuff like this, it doesn't seen to unload the Scene1

SceneManager.LoadScene("Scene1");
SceneManager.LoadScene("MainMenu");
SceneManager.LoadScene("Scene1");
leaden ice
#

I don't know what you're doing here

#

LoadScene should never be called consecutively like this, especially if it's not async

thick socket
#

well thats just essentially what it is

leaden ice
#

LoadScene takes a whole frame to complete

thick socket
#

basically Scene1 has a pause menu, I click menu then it loads MainMenu

thick socket
#

then in Mainmenu I click play which goes back to scene1

leaden ice
#

or did you do this for illustration

thick socket
leaden ice
#

ok then I don't understand the question

#

The scene will always load in its "default" state

thick socket
#

🤔

leaden ice
#

the only thing that will change that is any external data or objects your code is dealing with

#

like DDOL objects

#

or PlayerPrefs

#

or any data stored in any non-scene place that your code is accessing

thick socket
#
SceneManager.sceneLoaded += LoadState;
....
public void LoadState(Scene s, LoadSceneMode mode)
    {
        if (!PlayerPrefs.HasKey("SaveState"))
        {
            return;
        }
        string[] data = PlayerPrefs.GetString("SaveState").Split('|');
        // 0|10|15|2

        // Change player skin
        gold = int.Parse(data[1]);
        experience = int.Parse(data[2]);
        playerLevel = int.Parse(data[3]);
        // Change Weapon Level
        player.transform.position = new Vector3(0,0,0);
        Debug.Log("LoadState");
    }

main issue is just my player isn't being reset to 0,0,0 when new scene is called

#

which is confusing me

leaden ice
#

debug this

#

log the datsa

#

log what numbers you parse out

thick socket
#

the problem is that it works inside my Unity

#

it breaks when I build and do it on my phone

leaden ice
#

player.transform.position = new Vector3(0,0,0); < note this won't work if your player object has a CharacterController or something

leaden ice
#

you have some other script that is repositioning your player

#

and on the PC it's running before this

#

on the phone, after

plucky karma
thick socket
#

good to know thanks

thick socket
#

thanks though 🙂

thick socket
thick socket
plucky karma
thick socket
plucky karma
#

You can then create a class that handles parsing data from player pref, and slap that [Obsolete] tag on that.
Then in the future, you can create another connection to handle, say dropbox!

#

at the ease of changing the script reference.

thick socket
#

(Code in GameManager.instance)

SceneManager.sceneLoaded += LoadState;
public void LoadState(Scene s, LoadSceneMode mode){
player.transform.position = new Vector3(0, 0, 0);
}```
#

that doesn't successfully set the players position to 0 when loading scene

#

but this does...wtf?

#
SceneManager.LoadScene("Scene1");
GameManager.instance.player.transform.position = new Vector3(0, 0, 0);```
covert turret
#

Does this use playmaker or something?

teal knot
#

I have a dodge system in my 1st person game where pressing a key will dodge to the left and tilt the camera, however for some reason during the tilt if i move my mouse to adjust the camera during the tilt nothing happens, and it wont update until the tilt finishes. This happens with 2 different methods,

    StartCoroutine(CameraTilt(dodgeDuration, Quaternion.Euler(0,0,19f)));

    IEnumerator CameraTilt(float duration, Quaternion tilt)
    {
        float tiltTime = 0f;

        Quaternion startTilt = playerCamera.transform.rotation;
        Quaternion endTilt = startTilt * tilt;

        Quaternion newRot = playerCamera.transform.rotation;
        Quaternion oldRot = playerCamera.transform.rotation;

        while (tiltTime < duration)
            if (tiltTime <= duration/2)
                {
                    playerCamera.transform.rotation = Quaternion.Slerp(startTilt, endTilt,Mathf.SmoothStep(0.0f,1.0f,tiltTime/duration));
                    tiltTime += Time.deltaTime;
                    yield return null;
                }
            else
                {
                    playerCamera.transform.rotation = Quaternion.Slerp(endTilt, startTilt,Mathf.SmoothStep(0.0f,1.0f,tiltTime/duration));
                    tiltTime += Time.deltaTime;
                    yield return null;
                }
    }```

as well as when just using a simple tween

```playerCamera.transform.DORotate(new Vector3(0,0,10), dodgeDuration/2, RotateMode.LocalAxisAdd).SetLoops(2, LoopType.Yoyo).SetEase(Ease.InOutSine);```

any ideas what might be causing this?
leaden ice
#

so any other code that changes the rotation will be overwritten by that

#

playerCamera.transform.rotation = < forget this is a rotation for a second. Imagine this was just saying x = 5;. You're doing that each frame. Even if you wrote x = 7; in some other code, the x = 5; is just running every frame and will overwrite it

teal knot
#

ah i see what you mean

#

are coroutines a bad idea for this then

leaden ice
#

nah

#

nothing wrong with the coroutine

#

What I would do here is add an empty parent to the camer

#

the normal mouse look code would rotate the parent

#

the tilt coroutine would tilt the child

#

then it'll all work together

thick socket
#

atm I have all my movement in FixedUpdate because I use rigidbody stuff...however I think using FixedUpdate is causing a lot of movement blur when lowfps on my mobile game, what could I do to keep things like colliders, but not use fixedupdate?

leaden ice
#

You should use FixedUpdate for physics-based movement

#

Just make sure you turn interpolation on for your Rigidbodies

thick socket
#

I already have that

#

I have major blur when my character is moving and the background isn't moving rn

leaden ice
#

then that would not be the cause of any "movement blur"

thick socket
#

I've tried most every other fix I've found outside of "move everything out of fixedupdate"

leaden ice
#

"blur" is not something caused by this.

#

You would see stuttering

#

not blurring

thick socket
#

how could I possible fix the "blur"?

#

I've tried getting rid of cinemachine, no fix

#

just moving my character in pretty much an empty scene causes blur on mobile

#

I get lowfps maybe

#

could it be that all my animations have 60 sample rate and mobile devices have 30fps?

#

I've basically tried almost any fix I've found on the internet 😭

leaden ice
#

I'm not even really sure what you mean by "blur"?

#

It could just be a display artifact

thick socket
#

if you see, when background is moving the character appears to be a lot cleaner

leaden ice
#

nah

#

just when the character is not stationary in screen space

#

nothing to do with the bg

#

to be clear I don't actually see any blurring here

thick socket
#

huh, good to know thanks

#

yeah its harder to see in the gif

#

its super bad on mobile

hasty canopy
#

Do you have motion blur in post processing on?

thick socket
#

its borderline unplayable atm from the major blur when character isn't stationary in screenspace

teal knot
# leaden ice then it'll all work together

sorry just to clarify, do you mean adding the empty object to the camera then tilting that, or do you mean using that empty object for the mouse movement rotation instead? as if it’s the latter, that already is the case as the camera is already a child of an object which is being rotated by the mouse movement

thick socket
#

thinking moving animations down from 60 sample rate->30 might help? (at this point I have no clue what might help)

hasty canopy
thick socket
#

couldn't find it earlier

#

I've got Anti Aliasing disabled

steady thicket
#

I'm having bit of trouble trying to figure out how to change the import settings of a texture to Sprite(2D and UI) through code, but I'm getting a null reference exception on the line "importer.isReadable = true" which I assume means I'm not actually getting the TextureImporter. Any chance someone knows how to do this?

Here is my relevant code:

        importer.isReadable = true;
        importer.textureType = TextureImporterType.Sprite;```

Link to full script: https://gdl.space/amutahumak.cs
hasty canopy
#

Check maincamera, does it have "post processing" ticked on?

thick socket
#

I've never seen a post processing thing

hasty canopy
#

Wait is the project an HDRP?

thick socket
leaden ice
hasty canopy
thick socket
hasty canopy
thick socket
#

@leaden ice any ideas for fixing blur when character isn't stationary in screenspace?

leaden ice
#

I have no idea what is causing your blur so no

thick socket
#

(also I could send you the apk if you wanted to see how terrible the blur was...its bad in bluestacks also)

thick socket
#

in general what would cause blur when not stationary in screenspace?

leaden ice
#

maybe you need to be using the pixel perfect camera?

thick socket
#

what is with imgur and uploading every video as like 144p lol

#

recorded bluestacks

#

the blur is pretty apparent when you can watch 1080p lol

teal knot
thick socket
hasty canopy
#

Looks fine ngl

thick socket
hasty canopy
#

I watched at 720p

teal knot
#

it looks completely fine to me too...

thick socket
#

1440p, starting on the left and moving right shows how bad it is

teal knot
#

u sure its not a screen issue or something

thick socket
#

happens in bluestacks and on mobile

leaden ice
#

I watched it in 4k

#

looked fine

#

really think it's probably just a screen issue

hasty canopy
#

Watched on 2k and dammit praetor you beat me to it lmao

#

@thick socket also in platformer games people don't really look at player much, it's the surroundings that are the main focus so don't worry about it

thick socket
#

its at the 3-5s mark thats really bad imo

thick socket
#

but its super obvious to me which will drive me nuts 😄

thick socket
#

I can see it clearly on 2 very different monitors and 1 phone

#

its really not blurry for yall at that 3-5s stretch?

#

even if you are looking for it?

#

cinemachine fixedUpdate makes it better...however then the camera is jittery 😭

#

I just can't win lmao

plucky karma
#

also, definitely start using transform.SetPositionAndRotation(); methods if you plan on modifying both position and rotation at the same frame.

swift falcon
#

You can access transform anywhere, how are you able to do that, something to do with MonoBehaviour?

plucky karma
random gulch
#

want to shoot a raycast from the mouse but the position of the raycast seem to only be 0,0,0

leaden ice
swift falcon
#

@leaden ice @plucky karma Since MonoBehaviour implements it and it’s a part of Component, that’s why there’s no need to do GetComponent to access it? I know a long time ago .transform used to do GetComponent behind the scenes

plucky karma
leaden ice
swift falcon
#

Oh alright, thanks you guys

#

I kinda get it now

random gulch
plucky karma
#

I wonder if it's ideal to simplify the code for quaternion into two degrees angle for multiplayer solution?

random gulch
#

that is why I am using a raycast?

plucky karma
#

E.g. if I'm doing a first person shooter, I know the character doesn't needs all three degree of rotation.

leaden ice
#

but you don't need to

random gulch
leaden ice
#

ray.origin though

plucky karma
#

what about hit.point?

swift falcon
random gulch
plucky karma
leaden ice
plucky karma
#

Never could I find a reason why I need to rotate my character like a cartwheel

leaden ice
#

you can't use it like one

swift falcon
swift falcon
#

Is it just me or navmeshagent autobraking seems to do nothing?

#

Like allegedly you disable it and the agent won't suddenly stop, but nope, it suddenly stops when it reaches destination.

#

Max speed to 0 instantly

swift falcon
#

Stopping distance does everything, autobraking does nothing it seems

distant glen
#

I need some help regarding the implementation of ScriptableObjects.

I have a ScriptableObject called Item. I can create these in the editor.

But let's say that I want to have different types of Items which have different functions.

Should I create more ScriptableObjects which inherit the class Item, i.e.

Base: Item : ScriptableObject
New Type: Weapon : Item
New Type 2: Book : Item

Obviously, a book and a weapon are going to function completely differently, but are both a type of object that would be held within an inventory.

The alternative in my mind is having a public enum ItemType in my Item class. So each Item could be selected in the inspector as a Weapon or a Book, and execute different code according to that enum.

What is the standard way of going about this?

orchid bane
#

How do I invoke with delay in a scriptable object?

west lotus
vague tundra
west lotus
orchid bane
#

Tell it to Unity which put many methods into SOs

#

Working on tiles and having a bunch of methods here

#

And each tile is an SO

west lotus
vague tundra
west lotus
#

At best methods in an so should be connected to the data like return random between min and max values where min and max are defined in the so. Doing any gameplay logic inside a so is major code stink and leads to big problems

vague tundra
#

Class B inherits from abstract class A

I want a field or property on class A called "MyName". I want this field or property to be required to be defined and given a value in class B.
How do I set this up?

stable osprey
# distant glen I need some help regarding the implementation of ScriptableObjects. I have a Sc...

The enum thing is pretty standard in editors yeah. You could do smth like:

enum ItemType { Base, Weapon, Book, ... }
Dictionary<ItemType, Type> EnumTypeToCSharpTypeMap = new() {
    { ItemType.Base, typeof(Item) },
    { ItemType.Weapon, typeof(WeaponItem) },
    { ItemType.Book, typeof(BookItem) },
    ...
};

//Editor
Item CreateItem(ItemType itemType) => (Item) ScriptableObject.Create(EnumTypeToCSharpTypeMap[itemType]);
#

I assume your editor already handles the inspectors of different types, and you're just looking to create the different types

#

hi

main shuttle
west lotus
vague tundra
#

@main shuttle Thank you soldier, that is very close to what I am after

I am wanting to give MyInt a value in Father/Mother

west lotus
#

So just give it ?

vague tundra
west lotus
#

You dont need a abstract prop to so this

#

Are your clases Mono or regular

stable osprey
#
abstract class Parent { public abstract string Gender { get; } }
class Father : Parent { public override string Gender => "Male"; }
class Mother : Parent { public override string Gender => "Female"; }
vague tundra
#

scriptable objectiles

buoyant crane
vague tundra
#

Oh yes excellent thanks everyone for the code examples, that makes sense now!

west lotus
#

What pumpkin said or you can set it in the Awake of B

thin aurora
#

Abstract is the way to go with this, which is what @stable osprey perfectly described @vague tundra

plucky inlet
#

Hey everyone, is it possible to extend the Debug.Log to get the calling method without actively passing it to the extension?

eager cliff
#

hi everyone, I would like to ask how can I get vector b if blue point is moving around the centre (enemy) as a circle?
I have tried the following code in Update but it doesnt work.

float angle = 60;
Vector3 angularDirection = (transform.position - enemy.transform.position) / Mathf.Cos(angle*Mathf.Deg2Rad);
angle = angle + Time.deltaTime * 60;
stable osprey
# plucky inlet Hey everyone, is it possible to extend the Debug.Log to get the calling method w...

Unlikely to get the method itself without some VERY heavy reflection..
There's System.Environment.StackTrace and UnityEngine.StackTraceUtility.ExtractStackTrace which you can use to get the Call Stack as a string -- but you'll only get the related stack trace out of it

Also, even if you DO get it, depends on -- get it and do what with it?
You can create your custom Logger/LogHandler and even write the messages in a custom way with ILogWriter, so if you just wanna print the calling method it should be fine, but navigating to its definition will be even harder than getting it 😛

plucky inlet
stable osprey
#

then do: enemy.transform.position = player.transform.position + new Vector3(Mathf.Cos(angle * Mathf.Deg2Rad), 0, Mathf.Sin(angle * Mathf.Deg2Rad)); in Update -- before adding to angle

#

'getting' the position uh.... isn't that just enemy.transform.position?

#

oh you're looking to get the direction, I see -- so the tangent of the circle on point B

eager cliff
eager cliff
vague tundra
#

Oh nice, so B will be the line perpendicular to AB, at some distance along the line in the direction of B

stable osprey
#

one option is to calculate the position on angle = angle + 1, then normalize the difference between current point and next point 😛

#

pretty sure there's a math way, but cba rn 😄

vague tundra
#

First step is to get the vector AB, which is your enemyPos - playerPos
Then find the line perpendicular to to AB, which will be Vector2.Perpendicular(AB)

eager cliff
vague tundra
#

Nice

#

I feel like my explanation is incomplete but sounds like you'll be able to figure it out now

eager cliff
#

Long time away from school lol

#

Thank you

fiery warren
#

How do I check if an objects name contains the string "Tank". I may or may not have many clones with name Tank but I can use this.gameObject for it

vague tundra
#

tankObject.name.Contains("Tank"); @fiery warren

fiery warren
#

Thank you

soft shard
# plucky inlet Yeah I just extended the Debug.Log to output colors, its just for better visual ...

Just an idea, but if you did want the object, you could maybe make a extension function, like for example

public static string Log(this Transform me, string context) { Debug.Log(context, me); }

Then you should be able to do something like someObj.transform.Log("hi"); if your interested in getting the object, though that wouldnt give you any stacktrace info on its own, you could do what you need with he object from the static function, as a possible extended option - and you dont really need to pass "me" to the log line, if you dont need the object pinged from the console, but im assuming this is more for use in a build than the editor itself

plucky inlet
soft shard
plucky inlet
# soft shard Ah, I figured if your trying to call from the object, youd probably be on a tran...

Right now I am using this. As this is only for dev outputs , I will not put too much effort in here to make it prettier 😉

public static class Debug
    {
        public enum LogType { Data, System, User };

        public static void Log(object msg) => UnityEngine.Debug.Log($"{msg}");
        public static void LogError(object msg) => UnityEngine.Debug.LogError(msg);
        public static void LogWarning(object msg) => UnityEngine.Debug.LogWarning(msg);
        public static void LogException(System.Exception msg) => UnityEngine.Debug.LogException(msg);

        public static void Log(object msg, object caller, LogType logType = LogType.System)
        {
            string callerName = caller != null ? caller.GetType().ToString() : "Global";

            switch (logType)
            {
                case LogType.Data:
                    UnityEngine.Debug.Log($"<color=#FFFFFF>{callerName}: {msg}</color>");
                    break;
                case LogType.System:
                    UnityEngine.Debug.Log($"<color=#FFFF00>{callerName}: {msg}</color>");
                    break;
                case LogType.User:
                    UnityEngine.Debug.Log($"<color=#FFFF00>{callerName}: {msg}</color>");
                    break;
            }
        }
    }
#

How do you collapse stuff again, well, might be fine 😄

soft shard
#

Ah I see, well, if it works (and is largely for dev builds to make tracking runtime problems easier) then it seems like a good approach to me :p I would imagine youd be manually calling Debug.LogError or whatever in specific parts of your code anyway

plucky inlet
vague tundra
#

Can I set a const in Awake?

soft shard
soft shard
# vague tundra Can I set a const in Awake?

A const value is set when its declared, I dont think you can set it at any other point in a function, it wouldnt really be "constant" if you could - what are you trying to do?

vague tundra
#

Just want to grab the value of a UI elements rectTransform on startup and save that in a const

tired kernel
#

I found my game is stopped intermittently and quite frequently. So I did profiling about it and I got this result. It looks Text (Legacy) or Text Mesh Pro occurs lag but, I can't imagine and guess what is actually happening and what is wrong. May I get some insight?

soft shard
vague tundra
#

Yeah could do I guess, currently just using a field and its perfectly fine
Only reason I want it to be a const is cause I want it to kinda be a const, just one that can be declared on startup, and am wondering if thats possible out of curiosity

Can a property be setup such that it can only be given a value once and then it becomes readonly or something?

main shuttle
tired kernel
main shuttle
tired kernel
#

Really appreciate it!

soft shard
vague tundra
#

Cool cool, sounds good. Thanks!(:

summer helm
#

for some reason this isn't working, i have looked online and tried troubleshooting can't find a solution (it's a music slider btw). In the editor it works but in the build it doesn't work, there aren't any error messages

using UnityEngine.UI;
using UnityEngine;

public class SoundSettings : MonoBehaviour
{
    [SerializeField] Slider soundSlider;
    [SerializeField] AudioMixer masterMixer;

    private void Start()
    {
        SetVolume(PlayerPrefs.GetFloat("SavedMasterVolume", 100));
    }

    public void SetVolume(float _value)
    {
        if(_value < 1)
        {
            _value = .001f;
        }

        RefreshSlider(_value);
        PlayerPrefs.SetFloat("SavedMasterVolume", _value);
        masterMixer.SetFloat("MasterVolume", Mathf.Log10(_value / 100) * 20f);
    }

    public void SetVolumeFromSlider()
    {
        SetVolume(soundSlider.value);
    }

    public void RefreshSlider(float _value)
    {
        soundSlider.value = _value;
    }
}
summer helm
opal mesa
#

Hi! Just curious, you know when you create a Serializable C# class and try to make an array of those classes, you have your elements that are called "Element i" with i the index. Example on the screenshot.
I know that if you put a string (whatever the name, i put "name" but could be anything), the name of the element changes!
Anyone know what i could do to modify this?

tawny elkBOT
#

You can format your multiline code block with C# highlighting! Just add cs to the start of it. Highlighting example below!

class Fluffs : FluffyCat
{
    public void PetCat ()
    {
        Debug.Log ("Petting Cat.")
    }
}
thin aurora
#

How are you using this component?

summer helm
#

its a slider that changes the volume

thin aurora
summer helm
#

yes

thin aurora
#

How does it "not work"? Error, weird behaviour?

#

Need something to work with

summer helm
#

in the setting menu you can change the music volume, but it doesn't apply in other scenes

thin aurora
#

So you have a different menu in both scenes?

#

Why not apply Destroy on Load on the menu if you use it in multiple scenes?

#

Then you don't have the hassle of saving and loading being dependant on the scene

summer helm
#

i've never used destroy on load before

thin aurora
#

Calling this on your menu canvas is going to move it to a seperate additive scene, which you can't delete. It will then persist between scenes

#

This way you always have the menu. You could add disable/enable methods to it to disable it at moment when you don't actually need it.

somber nacelle
#

it should be fairly obvious how to use that. you clearly have to loop through the array returned by OverlapBox then use Physics2D.ClosestPoint passing in the position you want to get the closest point for (typically the position your overlapbox would originate at) as well as the collider then it returns a Vector2 representing a point on the perimeter of the collider that is closest to the specified position

flint needle
#

Hey, how can i highlight a quad of a plain using mouse?

knotty tulip
#

I have an gameobject taht I am rotating every frame through code for a smoother effect. Is there a way to stop rotating it when it EXACTLY rotates 90 degrees? Currently its 90.1 or something similar.

somber nacelle
#

once it reaches 90 degrees or higher just set it directly to 90

knotty tulip
#

yeah but sadly with my current implementation some objects have rotations from before.. it might start from 90 and need to rotate to 180

stable osprey
knotty tulip
#
 if ((initRot < 90.0f))
                {
                    if (!oppositeTurning)
                    {
                        if (timer > 1.5f)
                        {
                            initRot += onLeftRoad ? 21f * Time.deltaTime : 30f * Time.deltaTime;
                            transform.Rotate(onLeftRoad
                                ? new Vector3(0f, 21f * Time.deltaTime, 0f)
                                : new Vector3(0f, 30f * Time.deltaTime, 0f));
                        }
                    }
                    else
                    {
                        if (timer > 4.5f)
                        {
                            initRot += !onLeftRoad ? 25f * Time.deltaTime : 35f * Time.deltaTime;
                            transform.Rotate(!onLeftRoad
                                ? new Vector3(0f, -25f * Time.deltaTime, 0f)
                                : new Vector3(0f, -35f * Time.deltaTime, 0f));
                        }
                    }
                    
                        
                    
                }
knotty tulip
stable osprey
#

transform.Rotate then 😛

somber nacelle
#
  1. ClosestPoint returns a value so you have to assign it to something.
  2. have you never looped over an array before?
stable osprey
#

MoveTowards, RotateTowards, and xxxxxxTowards in general are super useful when you have a target and want to avoid overshooting

knotty tulip
#

Thank you sir! I will give it a go now

somber nacelle
# knotty tulip ```code if ((initRot < 90.0f)) { if (!oppos...

using transform.Rotate pretty much bypasses any clamping you might do. you'd want to track the rotation variable yourself and just assign the rotation so that you can clamp the angle before setting the rotation.
if you search "clamp camera" in this discord you'll find a bunch of different examples of how to do that (once you get past all the results of me suggesting people search that)

stable osprey
scenic hinge
#

Idk if this really belongs here, often in modern languages including c# fields and properties are combined, that being said Unity seems to punish this behavior. I’ve seen chatter on various websites that using fields directly is bad practice, so should I be creating a property for every field?

stable osprey
#

what.. why would u be doing that? 😄

scenic hinge
#

Also Microsoft seems to reinforce this logic

stable osprey
#

-- in any languages

somber nacelle
#

now you should still have compile errors because a transform is not a Vector3, but you're logic is backwards. also you should be passing the collider as the Collider parameter

stable osprey
#

I'm pretty sure making a property for every field is just a bad practice started by random youtubers making tutorials

somber nacelle
scenic hinge
stable osprey
somber nacelle
#

your array that you are looping over is an array of colliders

#

remember how i said to use the origin of the overlapbox for the position and the colliders in the array for the colliders used as the method arguments?

scenic hinge
#

By default declaring a property in C# will instantiate a related field, it’s built into the language, but inn Unity you need to declare fields to serialize them without just leaving them public

somber nacelle
#

you can serialize the field of an auto property by targeting the backing field in the attribute [field: SerializeField]

#

or you can serialize your explicit backing fields if you aren't using an autoproperty

scenic hinge
#

Oh interesting that would be far less time consuming

#

The second option has been my experience thus far

#

But it’s time consuming and a lot of code

stable osprey
#
public string myStr;              //WILL show on the inspector
[SerializeField] string myStr;    //WILL show on the inspector
string myStr;                     //WONT show on the inspector


public string myStr { get; set; }                                 //WONT show on the inspector
[field: SerializeField] public string myStr { get; private set; } //WILL show on the inspector
[field: SerializeField] public string myStr { get; set; }         //WILL show on the inspector
scenic hinge
#

So I know what shows up in the inspector it’s more about creating a SOLID code base now

#

Pun intended

stable osprey
#

what I like as rule of thumb for the inspector is to only expose variables that do not change at all in runtime -- so anything u set via the inspector will remain there forever

#

and if I need a public member that DOES alter in runtime, I use a public auto-property

scenic hinge
#

I’m less worried about the inspector, more about security

stable osprey
#

so I love that auto-properties don't get serialized

#

security in what sense? from human-error?

scenic hinge
#

Is having exposed getter and private setters risky at all

somber nacelle
#

access modifiers have nothing to do with the security of your application

stable osprey
#

well, if you think about it you're always in the 'risk' of a coworker simply deleting your script... lol

#

best you can do is minimize the access modifiers to the bare minimum while keeping the system functional

stable osprey
#

oh well right.. for max app security you want to hold all your data in a server, and only access it to render to the UI/game like so: public int Coins => MyServerAPI.RetrieveResult<int>("coins", userID); ..or something

#

anything less than that the player can alter it via some memory altering app or fake packets. but you really shouldn't care imo 🙂

thin aurora
#

Please just make sure that anything that has to be fetched from anywhere outside of your application (file, remote API, whatever) is done asynchronously

thin aurora
thick socket
#

So not sure I could use that method?

cerulean mist
# runic swallow Thank you for the idea. I sort used what you said and instead of a bool I used a...

That's a good idea! Again, I really push the idea of having a game manager to manage these game events. Also an interesting thing to look into is delegates and events. Delegates and events are helpful because other classes can subscribe to them and call their own functions from those calls. You could have an event that is called from the boss (OnBossKilled()) which other classes subscribe to and perform their own logic without needing to know the boss at all. Another thing you could do (a bit more of a hacky method) involves just checking whether or not the boss is null. When you destroy the boss, it will become null since the reference to the boss no longer exists. (if(bossGameobject == null) // logic here)

#

i strongly recommend delegates and events tho for clean, abstract, and reusable code!
https://www.youtube.com/watch?v=G5R4C8BLEOc&ab_channel=SebastianLague

In this two-part series we'll be looking at delegates and events.
This episode covers how delegates can be used to pass methods as arguments into other methods. It also very briefly touches on lambda expressions.

The next episode can be found here:
https://www.youtube.com/watch?v=TdiN18PR4zk

If you'd like to translate this video, you can do so...

▶ Play video
autumn cipher
#
    public static void AddAttachment(this Weapon weapon, string attachmentName)
    {
        bool AttachmentExists;
        for (ushort i = 0; i < weapon.WepData.AttachmentsData.AllAttachments.Length; i++)
        {
            if (weapon.WepData.AttachmentsData.AllAttachments[i].Name == attachmentName)
            {
                AttachmentExists = true;
                break;
            }
            AttachmentExists = false;
        }
        if (!AttachmentExists) return;
    }
``` Use of unassigned local variable 'AttachmentExists'
#

would it be fine if I just initialize that bool value? It's gonna change anyways so

mellow sigil
#

It should start out as false, there's no point in setting it to false every time in the loop

#

actually the entire thing is pointless, the function doesn't do anything

autumn cipher
thin aurora
#

Also ensures case sensitivity is not an issue

#

Linq's Any method returns true if anything matches the predicate

#

x => x.Name.Equals(attachmantName, StringComparison.OrdinalIgnoreCase) is the predicate, and means that if any name in AllAttachments matches the attachment name, return true

#

Linq is a good thing to understand

autumn cipher
#

eh, thank you

steady moat
thin aurora
#

I would agree with you if this was a method that would invoke often, and I don't think that it's the case.

steady moat
#

You know that, but the user that you are showing this might not know the difference.

#

Also, is there a reason why the function is an Extension ?

thin aurora
#

Even then, linq aint that bad as you're making it seem. There are more performant ways, but using linq is not gonna break your performance lol

#

The biggest problem comes from people using it wrong. I.e. with IEnumerable types

autumn cipher
#

this method will run once but LINQ seems like these python functions, they look very simple but also generating garbage a lot according to what I've heard

steady moat
#

Believe me, it is going to break your performance because of allocation.

autumn cipher
thin aurora
#

Again, I would agree with you if the method ran often

#

But in comparison with regular methods, speed and allocation are only slightly worse

#

And there are plenty of benchmarks that proved it

#

Also, as of .NET 7, Linq is faster than manual enumeration I believe

#

Too bad Unity is so behind

#

Also, no allocation at all

steady moat
#

Not, they are monstrously worse. Memory allocation is the slowest thing you can do. When you optimise, you remove ALL allocation that are not necessary.

thin aurora
#

It's literally benchmarked

steady moat
#

.Net 4x

thin aurora
#

Yes, Unity is behind, I said that

#

But linq is open source

#

You can always copy it, and I would prefer that over reinventing the wheel

steady moat
#

You cant... they would have use functionality from newer c# version.

thin aurora
#

But idc what you do. It's been used in every job I worked, even those still stuck in .NET Framework, and as long as you use it right there is no problem with it

thin aurora
steady moat
#

I use it myself. In Awake/Start/Event or editor tool.

thin aurora
#

So inform them

#

No need to inform me

steady moat
#

I wont be there for that...

supple ginkgo
#

Hi guys! I ran into a prob with my script, I followed a video tutorial about double jumping and did exactly like in the vid, the prob is that it didnt work for me unfortunately! Here is the script in the video.

#

using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
private float horizontal;
private float speed = 8f;
private float jumpingPower = 16f;
private bool isFacingRight = true;

private bool doubleJump;

[SerializeField] private Rigidbody2D rb;
[SerializeField] private Transform groundCheck;
[SerializeField] private LayerMask groundLayer;
[SerializeField] private Animator animator;

private void Update()
{
    horizontal = Input.GetAxisRaw("Horizontal");

    if (IsGrounded() && !Input.GetButton("Jump"))
    {
        doubleJump = false;
    }

    if (Input.GetButtonDown("Jump"))
    {
        if (IsGrounded() || doubleJump)
        {
            rb.velocity = new Vector2(rb.velocity.x, jumpingPower);

            doubleJump = !doubleJump;
        }
    }

    if (Input.GetButtonUp("Jump") && rb.velocity.y > 0f)
    {
        rb.velocity = new Vector2(rb.velocity.x, rb.velocity.y * 0.5f);
    }

    Flip();
}

private void FixedUpdate()
{
    rb.velocity = new Vector2(horizontal * speed, rb.velocity.y);
}

private bool IsGrounded()
{
    return Physics2D.OverlapCircle(groundCheck.position, 0.2f, groundLayer);
}

private void Flip()
{
    if (isFacingRight && horizontal < 0f || !isFacingRight && horizontal > 0f)
    {
        Vector3 localScale = transform.localScale;
        isFacingRight = !isFacingRight;
        localScale.x *= -1f;
        transform.localScale = localScale;
    }

    animator.SetFloat("Speed", Mathf.Abs(horizontal));
}

}

#

And here is my script

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.

supple ginkgo
#

!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.

knotty tulip
#

how do i round to the nearest 0? For example if I have 92 I want it to be 90 If its 87 I want it to be 90. if its -86 I want it to be -90. Is there a way?

prime sinew
prime sinew
icy sundial
#

is it possible, when deserializing JSON to a struct, to convert an array with 2 values into a class that has properties called x and y?

#

struct

public struct Position
{
    int x;
    int y;

    public Position(int x, int y)
    {
        this.x = x;
        this.y = y;
    }
}```

json = `{ position: [5, 13] }`
leaden ice
thick socket
thin aurora
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.

swift falcon
#

important question ... how do i make a rigid body change the gravity (despite what the physics settings of the project might be)

terse venture
#

how would i remove this certain tile from this array

#

I can only find "array.Remove(number)" on google

prime sinew
#

but if you're removing while iterating, it needs to be a reverse loop

terse venture
prime sinew
terse venture
prime sinew
#

and pay attention to what I said about looping in reverse

terse venture
terse venture
prime sinew
#

what type is tile..

eager cliff
#

I recently noticed that animator is expensive, and people suggest that you can actually implement simple animation(eg. walking) without using animator. How should it be done? Any keywords that i can search?

thin aurora
#

Arrays are a static size

terse venture
terse venture
thin aurora
#

Change Transform[] into List<Transform>

#

Be sure to initialize it with new List<Transform>

prime sinew
#

and you'll need Count, not Length

thin aurora
#

A list will change its size automatically when you add/remove items

thin aurora
#

But Count/Count() is recommended

terse venture
#

I see.

thin aurora
#

Arrays are only useful if the size does not change. Otherwise you need to create a new array

deep fable
#

Hi guys! I am trying to make a static class that allows me to receive the start callback from any class, even from Scriptable Objects (basically inside the static class I create a new gameobject with a custom script that saves in a list all the functions that want to be called on start and then on start I call all of them)

But Unity gives me this error: Some objects were not cleaned up when closing the scene. (Did you spawn new GameObjects from OnDestroy?) Why? (take in consideration that the SO could even call that function during edit time

thin aurora
terse venture
#

Why would this be? Im trying to find game objects with the tag "tile" and put it into my array

#
 tile = tileparent.FindGameObjectsWithTag("tile");
deep fable
thin aurora
#

That said, I don't think SO's should contain much behaviour, should they? Maybe you should move this code to whatever consumes the SO

thin aurora
terse venture
#

I also managed to fix it

thin aurora
#

tile = tileparent.FindGameObjectsWithTag("tile").select(x => x.transform);

#

What was the issue?

deep fable
terse venture
# thin aurora What was the issue?

I was trying to make "GameObject" "tileparent" to try and get it to only look for child gameobjects under the tileparent gameobject. I fixed it by just making it GameObject, and i guess it still works, just looks for every object

#

I was previoulsy just getting the child tiles, and was trying to remove specific tagged ones, not sure why i didnt think of this earlier

#

however this is no longer working.... It was working when it was transforms, but now they are gameobjects

autumn cipher
#

unity editor question, how do you reset an instance's values without changing the name of the instance?

#
public AttachmentsData.Attachment LaserSight = new AttachmentsData.Attachment { Name = nameof(LaserSight).AddSpacesBetweenCapitals(), Type = AttachmentsData.AttachmentType.Laser };```
I know this might look like a useless question but it would save me tons of time afterwards
terse venture
#

not sure why

thin aurora
#

And maybe explanation on what you're doing

polar marten
#

you should describe your laser sight with a prefab

#

if you need to clear values, you can go ahead and write the initial values you need to the object. but it's not clear to me why you need to reset them

terse venture
#
public class Tiles : MonoBehaviour
{
    public GameObject tileparent;

    public GameObject[] tile;

    public int currentIndex = 2;

    public AudioSource audios;
    // Start is called before the first frame update
    void Start()
    {
        tile = GameObject.FindGameObjectsWithTag("nexttile");
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    public void OnTile()
    {
        if (currentIndex + 1 >= tile.Length) return;
        tile[++currentIndex].gameObject.tag = "tile";

        if(!audios.isPlaying)
        {
            audios.Play();
        }
    }
}

Basically its getting all of the tiles tagged with "nexttile" and when i call "OnTile" from my other scripts, it should add 1 to the current index, and tag the current index as tile (the next tile).. it also plays a sound

#

@thin aurora

polar marten
polar marten
#

and in its start method, write what you need to do to initialize the things you need

thin aurora
polar marten
autumn cipher
polar marten
woeful leaf
polar marten
#

might be as few as 4 lines

autumn cipher
glad mirage
#

Hey guys, I am unable to get any form of text (legacy or TMP) working on Unity 2022.2.x. These boxes show up. It works on any other Unity Editor version though. Anyone knows what's going on?

#

Tested on Unity 2022.2.5, 2022.2.1, 2020.3.29, 2022.1.3

#

only fails on 2022.2 :/

west sparrow
#

We haven't had a 2022.x pass our internal QA (yet). But if it does that with clean / new projects it may be good to submit a bug

glad mirage
#

Okay, it seems to be a project bug. Reimport all didn't fix it, but a git clean -fdX did. Found out when I converted a 2020 project to 2022 and it suddenly works. Mind you, a fresh project of 2022 didn't work.

swift falcon
#

How can I make a navmeshagents decelerate gradually instead of stopping instantly at its destination? Autobrake is supposed to affect this but it doesn't.

hexed oak
swift falcon
#

I have a MarchingCubes algorithm for generating minecraft chunk meshes.

I call it every time a block gets placed/broken. To place/break blocks I just modify a blocks array and re-call the method

Problem is when i place blocks like

⬜⬜⬜
⬜ ⬜
⬜⬜⬜

And then place a middle block then i get a problem where the mesh.triangles is too big cause not enough vertices and the UV array isn't the same size as the vertices array

I guess I'll make this a thread and post the MarchingCubes code tomorrow

west sparrow
# hexed oak You guys have QA for new versions of Unity that come out?

Yup! we have some automated tests on our build server. If that passes, we go onto a checklist. 2011 only passed for us about a month ago now.

For a long time it was failing due to broken interface issues with Lists. Issues with Android builds. And issues with SteamVR. Both those all finally passed and we could upgrade.

hexed oak
#

As my name implies, I'll also be setting up jenkins for CI/CD for the builds

polar marten
#

you should probably use unity cloud build

polar marten
#

2022 is really in alpha

glad mirage
polar marten
#

i'm trying to impress on to you it is buggy as hell

peak pivot
#

I'm writing some code to validate types that aren't following certain rules, this won't execute at runtime so any reflection that can get the job done works.
Is there a way to get which file/linenumber a class is defined in via System.Type?

polar marten
#

what are you actually trying to do?