#archived-code-general

1 messages · Page 61 of 1

late lion
#

I think a capsule overlap makes more sense for a cone. It will always be a smaller volume than a sphere, while still encompassing the cone.

swift falcon
#

Looks more efficient. 🤔

bronze rampart
#

just curious. Does it need to be more complex than something like this at this stage?

void Update()
{
    switch (currentState)
    {
        case CharacterState.Idle:
            // Code to execute when in the Idle state
            break;
 
        case CharacterState.Walk:
            // Code to execute when in the Walk state
            break;
 
        case CharacterState.Run:
            // Code to execute when in the Run state
            break;
 
        default:
            break;
    }
}```
whole gull
#

but its the most practical solution for me right now

cosmic rain
swift falcon
cosmic rain
#

And you could even make it faster with a square magnitude comparison

hexed pecan
late lion
swift falcon
#

am i going insane

#

yes i am never mind eeveefacepalm

#

I didn't add all

leaden ice
#

Not sure what this has to do with C#. Make your image transparent.

crimson agate
# bronze rampart just curious. Does it need to be more complex than something like this at this s...

There's a set of rules that a lot of programmers use called SOLID. In most instances where you use a switch statement, you're very, very likely breaking the O in that principle which is the open/closed principle. In this case, every single time you modify, add, remove player states then you would have to change the update method.

A more ideal way to setup a State pattern in C# is to actually use encapsulation to allow different states to have their own class and their own update method. So anytime you need to add a new state, you simply create a new class that inherits from an interface. That interface would force the new class to have an update method so there's no funny business and it's impossible to forget a step when implementing new states.

IE.

public interface ICharacterState
{
    void Update(Character character);
}

public class IdleState : ICharacterState
{
    public void Update(Character character)
    {
        // Code to execute when in the Idle state
    }
}

public class WalkState : ICharacterState
{
    public void Update(Character character)
    {
        // Code to execute when in the Walk state
    }
}

public class RunState : ICharacterState
{
    public void Update(Character character)
    {
        // Code to execute when in the Run state
    }
}

public class Character
{
    private ICharacterState currentState;

    public Character()
    {
        currentState = new IdleState();
    }

    public void SetState(ICharacterState newState)
    {
        currentState = newState;
    }

    public void Update()
    {
        currentState.Update(this);
    }
}

Now you can way more easily extend the character states when you inevitably add other things like jumping, crawling, climbing, shooting, etc

fluid coyote
#

I have a couple hundred prefabs that I could either load dynamically through Resources.Load() or through making a prefab singleton with a Dictionary<prefabNameString,prefabGameObject> and loading them all at the start of the game.

When I load a prefab, I usually won't have to load it a second time and the amount of loading I do is pretty spread out. Also, the vast majority will not be loaded in a game as it is a roguelite. This is all due to adding scripts to my character dynamically.

Is one of the approaches strictly better or is it so negligible in my situation that it doesn't matter?

crimson agate
#

I think in your situation it's not a huge deal. I'd just do resources though since it's better for memory, only loading prefabs when you actually need it. If you were loading hundreds at one time then i'd change my mind possibly, but as you said, it's spread out.

#

Either way though, it's not like loading them all at the start is gonna increase the startup time of your game by very much, you could always benchmark it

west sparrow
#

Just mentioning, but you want to avoid storing things in Resources if you can, especially if there are a lot of them. But what you are talking about is more or less a pooling system. It's used a lot, and people swear by them (we use them sometimes). But when I've benchmarked it, the difference is pretty minimal.

#

Usually they come with colliders. And in benchmarking the slowest moment usually isn't instantiating a mesh to the screen, it's the initial physics check when it appears. So disabling/enabling from a pool doesn't help, as that check still happens.

But yes, a loading screen pooling the resources is common. Just keep in mind it also impacts garbage collection and memory use that way

#

Imho of course

#

I would say though, given your workflow, you could benchmark it pretty easily to see if it's worth it

fluid coyote
#

Thanks for the great advice you two! I'm happy to hear that I won't have a big headache down the line if I maintain my current approach. Will definitely benchmark when most of the prefabs are finished.

glad marsh
#

Hi all! Today is the 3rd day as I'm trying to deal with zenject.
Such a question, if the projectContext itself automatically appears on the stage and cannot be added manually, which means I can’t just drag the necessary dependencies onto it, how can I throw global dependencies into it? Through delegates? What if the sceneContext is loaded along with the scene in the prefab?

unreal temple
#

I haven't checked it, but that's what I've been told. Apparently it's a fine way to do things. 🤷

#

I wish they'd just straight up explain how it works

cosmic rain
#

Yeah, if you need to load something dynamically, you should use addressables

unreal temple
#

Instead of saying vague things like "performance degrades"

#

"makes memory management more difficult"

#

etc

#

Does anyone know how to get a list of triangles in a NavMesh?

cosmic rain
unreal temple
#

For example

#

Not being able to unload specific assets is obviously a downside haha

#

Actually, I don't care about resources, I don't use it. Don't bother answering me, just a general complaint about the docs.

unreal temple
#

Trying to write a function that will get an evenly weighted random point on a navmesh

cosmic rain
dire marlin
#

Making a unity first person horror, I want my monster with ai to have a jumpscare, any idea on how I can make it so if you touch the monster the monster plays an animation and the camera zooms to the monster's face?

unreal temple
dire marlin
leaden ice
#

use cinemachine

unreal temple
leaden ice
#

switch to a camera that is configured as a closeup

unreal temple
#

yeah, that's good too.

#

But you'll probably want to freeze all input too

#

Assuming that's a thing?

#

Or you can just set a tracking camera that follows the monster's face with a zoomed FOV

dire marlin
#

Oh true

#

So I basically disable the camera script and make the camera turn to face the monster

unreal temple
#

If you're using cinemachine you can have a separate virtual camera for the monster facing thing

potent sleet
#

put a higher priority

#

it should autoblend

dire marlin
#

Autoblend?

#

Sorry I am a bit new to gamedev

unreal temple
#

like... slide it over to the position you want

dire marlin
#

Ohhhh ok ok

unreal temple
#

and zoom it etc smoothly

potent sleet
#

it can be adjusted

unreal temple
#

Cinemachine is really good, pretty much a must-have for most games

finite hollow
#

Hey guys! I just have a general question about unity. I've only just started but I want to make a VN with it. Is it correct to assume that if my game is sectioned into different segments like chapters that you can access at any point and in any order, I should use multiple scenes for each segment and then make a manager that allows players to start a specific segment/scene?

potent sleet
#

what is VN ?

dire marlin
#

Alright thanks guys

finite hollow
#

a visual novel

potent sleet
#

oh visual novel

finite hollow
#

yeah haha

potent sleet
#

different scene could be cumbersome but probably easier to keep track in terms of chapters

finite hollow
#

oh it would? I thought it would be as simple as pasting prefabs of a dialogue system and scripts that cater to a chapter. Is there an easier way of going about it then? Because I'm not sure how else players can choose to hop into specific chapters

potent sleet
finite hollow
#

ohhh gotcha. well that's a relief! thanks!

potent sleet
#

never made VN though so idk what gameplay you need

finite hollow
#

Oh ink! I have played with it before and I love how it works with Unity. I was thinking of using this and either Yarn Spinner-- although the latter is something I haven't used yet.

#

Ink would definitely be enough for a VN though

potent sleet
#

yea! Ink is great they added a few cool features to run special code easier now without tags (old way) I never used Yarn tho , looks interesting as well

finite hollow
#

I only thought to try Yarn because Night In the Woods used it and I'm curious to see how I could replicate it. But maybe it's not the time to experiment haha

potent sleet
#

it's worth a shot

swift falcon
#

Alright, I'm now attempting to do a cone angle check, but I'm struggling to find the proper variables to use here.

#

In GZDoom, I would set this sort of function up for an angular check:

            Vector3 PosDif = Vec3To(Mo); //Difference in position between inflictor and victim.
            Double RelAngle = AbsAngle(Angle, atan2(PosDif.Y, PosDif.X)); //Difference in angle between inflictor and victim.
            If (RelAngle >= AngThresh)
            {
                Continue;
            }
#

(Keep in mind, in a Vector3 as defined by GZDoom, X represents forward/backward, Y represents left/right, and Z represents up/down.)

#

(Simply put, GZDoom's X equals Unity's Z, GZDoom's Y equals Unity's X, and GZDoom's Z equals Unity's Y.)

#

To get AbsAngle, all I'd need to do is get the absolute value of DeltaAngle (so, Mathf.Abs(Mathf.DeltaAngle(first_float, second_float)).

#

For finding the difference in position between the first and second objects (as I'd do with Vector3 PosDif = Vec3To(Mo); in ZScript), I'd just need to subtract both GameObjects' transform.position vectors from each other, correct?

#

Also, the Angle variable in there represents the caller's yaw (so it'd be represented by the Y-axis rotation in Unity).

#

While I'm at it, how would I go about making a pitch variant of this same check?

static crown
#

I need to know something about a piece of code: ``` for (int i = -rayCastAngle / 2; i <= rayCastAngle / 2; i += 5)
{

        Vector3 axis = new Vector3(0f, 0f, 1f);
        Vector3 direction = Quaternion.AngleAxis(i, axis) *-transform.up;

        RaycastHit2D[] rays = Physics2D.RaycastAll(transform.position, direction, 1f) ;
        foreach (RaycastHit2D ray in rays)
        {

            if (ray.distance < shortestRayDistance || shortestRayDistance == Mathf.Infinity)
            {
                shortestRayDistance = ray.distance;
                print("srtdisray"+shortestRayDistance);

                
            }
        }

        Debug.DrawRay(transform.position, direction * 1f, Color.white);
    }```
#

Firstly, I want to confirm that the RaycastHit2D[] is only shooting one ray for every iteration of the for loop, each in a different direction?

leaden ice
leaden ice
static crown
#

Secondly, if I were to use the direction variable in the if statement, would it be the direction in which the ray is shooting? Because if that is the case, wouldn't that mean that rays are being used in the foreach statement multiple times for each iteration of the for loop?

leaden ice
static crown
#

Yes, but I am using all the rays in the foreach statement, does that mean the first ray's distance is being checked for every itteration of the for loop?

leaden ice
static crown
#

oh.

leaden ice
#

Likewise for the "rays" variable

#

Poorly named

static crown
#

but still, for each of the RaycastHit2D, would the distance be checked multiple times per frame due to the foreach statement being placed inside of the for loop?

leaden ice
#

Each RaycastHit2D is being checked once

#

Each RaycastHit2D in each Raycast. You are doing multiple Raycasts.

static crown
#

All the RaycastHit2Ds are being saved in an array right? The foreach statement is checking all the "ray in rays." Wouldn't that mean the entire array is being checked per iteration of the for loop?

leaden ice
#

You are getting a brand new array every iteration

#

They're not all being added to a single cumulative array

static crown
#

Wait so there's only one value in the array for every iteration?

leaden ice
#

No there's as many values as the RaycastAll hits

static crown
#

Ohhhhhhhhhhhhhhhhhhhhhh

leaden ice
#

But each RaycastAll gives you a fresh array for just that Raycast

static crown
#

Ohhh... I thought the collisions of all the RaycastHit2D per frame were saved in the array, thank you so much, that makes sense

warm mesa
swift falcon
#

Vector3.Angle asks for two Vector3 inputs...

#

Shouldn't I just use their transforms?

warm mesa
swift falcon
thin aurora
#

Oh wait they have ZScript nowadays

swift falcon
thin aurora
#

I'm too used to ACS 😄

potent sleet
warm mesa
potent sleet
#

unless you persists this with DontDestroyOnLoad

#

I would personally use a file

#

it's quick and easy

#

scales up ok

warm mesa
crimson agate
#

@warm mesa There's also a cool C# structure called TimeSpan that you could use to make the resume part more pretty. Could do something like this:

if (isPaused)
        {
            // When paused
            pauseDateTime = DateTime.Now;
        }
        else
        {
            // When resumed
            TimeSpan timeDifference = DateTime.Now - pauseDateTime;
            TimeStart -= (float)timeDifference.TotalSeconds;
        }
potent sleet
#

crazy was just about to mention this ^

#

timespan would be good here

crimson agate
#

my indentation is fubar'd but ye

thin aurora
# warm mesa The timer gets reset when i switch scene or exit game.

That's because the script is part of that scene, and the current reference is deleted when the scene unloads. You can do what null said, and call DontDestroyOnLoad on the script, or you can make a seperate MonoBehaviour for any information that must be persisted between scenes, and call said method on that instead. Assuming your script must be reset properly for anything else, of course. Alternative to DontDestroyOnLoad is creating a scene manually and to use additive scene loading. This gives more control, if you want that, which might be nice if you want to completely reset your scenes. Note DontDestroyOnLoad basically makes this seperate scene for you, which is quicker.

wispy fable
#

Hello, I have a problem where I want to find a point that lies on the intersection of a plane and a mesh a defined direction and distance from another point. I have made a simple illustration.

I have previously tried to use a MeshCollider on the mesh for something else and unfortunately the mesh exceeds the the collider's complexity limit.

I'm not sure how to start, any tips?

leaden ice
swift falcon
leaden ice
swift falcon
#

Switching that around made it work right. 😄

#

Thanks!

ruby compass
#

youre a fucking life saver cant belive it was that one damn small thing

mossy condor
#

Anyone knows how I can make the phone vibrate 1 tick when I click a button?

#

Handheld.Vibrate(); vibrates too long

#

I just want a single tick

thin aurora
#

Note it's for Android

#

Suggest you just copy-paste the whole script, try it with some different values, and then strip what you want specifically, or keep it if you want all of it.

balmy nacelle
#

This is my "Building System" & i have a bug where it doesn't place objects on the "first clicked tile"
I have to run the mouse back over while holding it down to "place the item"

Placement Code:

void OnMouseEnter()
    {
        _highlight.SetActive(true);

        if(buildManage.isEditing == true && Input.GetMouseButton(0))
        {
            buildManage.PlacePreset(_highlight);
            _renderer.color = Color.clear;
        }
    }
#

Better Image

hollow stone
hollow stone
#

You should probably change it to OnMouseOver - which is called every frame, or OnMouseDown which eliminates the requirement to check for the Input mouseButton is pressed down, if you only want it to trigger on the first time you press and not while holding & dragging.

balmy nacelle
vague slate
#

Is there a way to get a list of all currently loaded scenes?

thin aurora
vague slate
#

it's deprecated

late lion
thin aurora
# vague slate it's deprecated
int countLoaded = SceneManager.sceneCount;
Scene[] loadedScenes = new Scene[countLoaded];
 
for (int i = 0; i < countLoaded; i++)
{
  loadedScenes[i] = SceneManager.GetSceneAt(i);
}
vague slate
#

ah, I see

#

thanks

thin aurora
# vague slate thanks

No problem. Note that you're probably not the only person with the issue when it comes to questions like these. The answer I just gave you came from Google.

#

Google is very useful.

obsidian saddle
#

hey, sorry I'm a little new to bitwise operators since I haven't needed to use them before. If you have an int foo, why is foo & 0xffffffff not equal to foo?

#

It seems like it should return a value which is 0 where foo is 0, and 1 where foo is 1, right?

mellow sigil
#

That's what it does

obsidian saddle
#

that's strange. That's not what I'm seeing here

#

when using foo & 0xffffffff I'm getting zero

mellow sigil
#

You'll have to figure out why the value of foo is not what you expect

obsidian saddle
#

no, foo's value is correct

#

So, I'm doing this in HLSL, the operator should function exactly the same. I've got a set of pixels that I'm drawing as white if foo & 0xffffffff isn't equal to zero, and black otherwise. My actual code for this is this: Result[id.xy] = foo & 0xffffffff != 0 ? float4(1, 1, 1, 1) : float4(0, 0, 0, 0);

#

(I'd normally ask a question like this in #archived-shaders but I'm asking here since most languages, regardless if they're shader or not, have a bitwise &)

obsidian saddle
mellow sigil
#

The precedence of & is lower than != so your code is equivalent to foo & (0xffffffff != 0)

obsidian saddle
#

OH

#

i had no idea

#

thank you so much!

hollow stone
#

And today I learned this x) cs unchecked((int)0xffffffff);

charred flax
#

@everyone Hello. It is possible change banner ad for something else via script ??

simple egret
thin aurora
thin aurora
#

I don't see any method specific to setting the content, anyway

thin aurora
hexed pecan
#

If you dont need it monetized or anything

charred flax
hexed pecan
#

Nevermind. Not sure what you meant with your own ad

simple egret
#

Here you don't have the word on what ad it shows, because Unity's controlling it. The advertisers reach out to Unity, which then dispatches the ads to the game.
If the advertiser reached out to you directly you'd have control on what shows, here you don't.

frosty pawn
#

Hi! Is there a way to call a method by clicking in <a href> in console?

thin aurora
#

Or is your question how to simulate the anchor tag?

crisp minnow
#

Is there a general design pattern that is applicable when you want two objects A which contains collections of B and you want B to do some general operations on A?

I understand it's achievable via either Singleton, but that's a poor fit in this case and directly passing the reference of collection A to all instances of B, but if I'm going to do that, might as well have the functionality present in A which manipulates B. Any other alternatives I can read up on to see if they might fit?

frosty pawn
hollow stone
maiden breach
#

If what you're asking is whether you can call methods dynamically from attributes on the link, the answer is yes. But you'll need to use reflection.

thin aurora
lethal plank
#

guys i have a problem
this IEnumerator broke after i set active it to false

#

anyway to wait script?

lethal plank
thin aurora
#

And I think yield return null is better. It will wait a single frame.

thin aurora
lethal plank
#

it will not run after i set active to true again

lethal plank
maiden breach
lethal plank
#

alright

lethal plank
lethal plank
thin aurora
#

You should Debug.Log your steps and check what plays, or not

#

Check if it restarts, and if the coroutine is running

lethal plank
thin aurora
#

Perhaps you can share your code?

lethal plank
#

lemme check it

lethal plank
thin aurora
#

Please share your !code like 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.

lethal plank
#

ah i forgot

#

here

thin aurora
lethal plank
#

wait a bit ResetOptions() still run when outside an if

thin aurora
#

There's a lot wrong with the code. Do you want this to run for a long period or just once?

#

Because currently it runs once and not again

lethal plank
thin aurora
#

Then it must stop?

lethal plank
lethal plank
thin aurora
#

The whole Coroutine

#

Perhaps change your ResetOptions method to this, and test it again:

private IEnumerator ResetOptions()
{
  while(true)
  {
    yield return null;
    if (m_requiredDropdown == null)
    {
      continue;
    }

    if (m_requiredDropdown.prevValue == requiredDropdown.value)
    {
      continue;
    }

    Debug.Log(requiredDropdown.gameObject.name + " Changed Value");
    Set();
    return;
  }
}
lethal plank
#

alright

thin aurora
#

This runs until m_requiredDropdown.prevValue != requiredDropdown.value, then calls Set, and then stops.

lethal plank
#

understood

thin aurora
#

A while loop runs as long as whatever inside it is true. Since we literally pass true, it runs forever. Just make sure to add some delay or you break your application (which is what yield return null does). return; makes sure we stop the loop. continue; resets the loop.

lethal plank
thin aurora
#

My mistake

#

Or change to break;, which will end the while-loop itself

lethal plank
#

alright

#

does it work in void?

thin aurora
#

Considering Unity's Coroutines work with IEnumerator, it works here.

lethal plank
#

oh damn its not work

thin aurora
#

What does not work exactly?

lethal plank
#

after value changed Set() was called

thin aurora
lethal plank
#

oh my bad i mean was not called

#

hmm some of my gameobject could call it

thin aurora
lethal plank
#

alright

thin aurora
#

As some point it should show values. Otherwise something is wrong. You can verify that way if you actually get the proper values

lethal plank
#

uhh does it really need 2 "?"

thin aurora
lethal plank
#

wait a bit i accidently press ctrl T

thin aurora
# lethal plank

Lame, then just test with Debug.Log($"{m_requiredDropdown"}: {m_requiredDropdown?.prevValue} == {requiredDropdown?.value}");

wooden spoke
#

Hello guys, I would like to assign some GameObjects to 4 prefabs that I created while the level of my game is running: since it is a procedural level the GameObjects should instantiate into my prefabs script, I did it for the player with "GameObject.Find("Player_Mobile").GetComponent<Transform>();" and it works, but for the other gameobjects it doesn't work
They are different GameObjects to assign to the different 4 prefabs but everything is on one script only attached to the 4 prefabs, how could I do that?

thin aurora
lethal plank
#

ah alright

wooden spoke
#

I tried to use the GameObject.Find("")GetComponent<>(); for the other GameObjects that I need but it doesn't work at allù

lethal plank
lethal plank
thin aurora
lethal plank
#

ye but set() still not called xd

thin aurora
#

Because there's no change

#

Now when I look at the code they share some resemblance, so perhaps they share the same value?

#

So if you want to call set() when it changes, why not make your own variable?

#
private int _previousValue;
private IEnumerator ResetOptions()
{
  while(true)
  {
    yield return null;
    if (m_requiredDropdown == null)
    {
      continue;
    }

    if (m_requiredDropdown.prevValue == this._previousValue)
    {
      continue;
    }

    Debug.Log(requiredDropdown.gameObject.name + " Changed Value");
    Set();
    this._previousValue = m_requiredDropdown.prevValue
    return;
  }
}

Something like this

#

Or figure out why m_requiredDropdown.prevValue is not actually the previous value. Perhaps it changes the next frame?

#

Lets ask a whole different question: why not do all of this in an Update method? Perhaps it works there?

lethal plank
#

i called it self

#

hmm im still not understand it but somehow it worked

#

thanks my man

#

im going to figure it out

#

oh understood

stable rivet
#

Will a method finish executing even if the root GO is disabled? Just as a basic example, will this log?

gameObject.SetActive(false);
Debug.Log("I am inactive");
thin aurora
#

Scripts don't stop like that

#

"Disabling" objects are purely for Unity, and Unity specific methods like Update

stable rivet
#

Assumed not, just wasnt on PC atm so couldn't write it up

#

I never know what magic Unity does behind the scenes to make C# things behave in unexpected ways, so 🤷‍♂️

stable rivet
keen warren
#

Alright, will ask there, ty.

polar marten
#

you should use object active / inactive for

  • rendering, where showing something for 1 extra frame doesn't matter
  • time insensitive gameplay logic. for example, you can represent the active improvements on your Puerto Rico board as game objects; the contents of your inventory in an RPG; a building in your city sim
  • user interface elements

you should carefully use object or script active/enabled for

  • time sensitive gameplay logic. for example, you should not use it for hitboxes in a realtime shooting game. people do, and because they are not really aware of the player loop or script order in a sophisticated way, they have all sorts of bugs, like "ghost shells" in a tank game a user once asked about here.
  • tightly coupled things like singletons. game controllers, accounts management, etc.
ember ore
#

I have two ints, i wanna check if any Bit from the first int is present in the second int. If thats the case, return true;
E.g. 11001,10001 -> True (since the first and last bit were set in both)

How exactly do i do that? I always was bad at logical operations...

#

Oh wait, thats a & operation... isnt it?

#

But how do i check it then, if the result was appropriate?

dusty badger
#

if it's > 0, there is a match

#

(a & b) > 0

ember ore
#

Ah alright, thanks 😄

dusty badger
#

Is there a way to deal with these domain reload times whenever I change a single line in a script? I thought that by using assembly definitions it was supposed to only recompile that assembly, but its like the entire project gets reloaded and using the Editor Iteration Profiler is not really telling me anything useful. I have a pretty simple project with basic 2D and URP packages on 2022.2.6f1 with VS 2022, and basic scripts that don't reference any packages in their own assembly, and it takes 15 seconds to reload domain when I modify a script, why is this a thing now?

leaden ice
ember ore
#

Great, thanks 😄
And what if i have two different sized arrays of ints? Like large bitsets? ^^ Is it the same procedure?

dusty badger
#

ahh right, typically you use uints for bitmasks

ember ore
#

E.g. : 10101,10111 and 10101,10111,11111

dusty badger
#

depends on how youre trying to compare these

swift falcon
#

quick question, I have a message that I need to send in a webrequest, I want to change it to a link format (for example spaces will become % ) ... can someone point me in the right direction, I dont know other examples than the space one

dusty badger
#

you cant really do (array1 & array2)

swift falcon
#

Does anyone know why im getting this error?

leaden ice
polar marten
polar marten
#

that's what you said earlier

#

right?

#

you're working on this with someone else and you were trying ot understand what addressables does

#

what's your big picture goal?

trim schooner
maiden breach
# swift falcon

Probably missing a using namespace. But you've also got some basic syntax problems going on.

polar marten
#

you're jumping right into stuff it doesn't look like you know quite yet, but you can learn it

#

it looks like you haven't used C# before

dusty badger
swift falcon
trim schooner
polar marten
trim schooner
polar marten
#

doing hard shit is okay

#

just stay focused for a sec and say the big picture

swift falcon
polar marten
#

okay

#

and why?

#

not why you specifically

swift falcon
#

no clue lol we have barely any assets in the scene lol

polar marten
#

but what was observed that anyone needs to deal with this

#

okay

swift falcon
#

idk what's the point of doing it now

polar marten
#

okay

swift falcon
#

Im using addresables

polar marten
#

i mean your brain is in the right place

#

you know this is stupid

#

so here's what i suggest

dusty badger
polar marten
#

delete the files that you created that are immediately causing hte game to not even compile

#

don't do that

swift falcon
polar marten
#

don't do anything where you are put immediately into jeopardy

#

you can delete this whole file because it isn't going to do anything for you

trim schooner
polar marten
#

it's going to undo things for you

#

like it will break things in vague ways

#

even when it compiles

trim schooner
#

or just add the namespaces required and move on

polar marten
#

my suggestion is to create a script called MemoryManagement, a default one with Start and Update

trim schooner
#

deleting this class might cause other issues if it's required by other clases..

maiden breach
#

Seriously, just fix the very fixable errors listed in the console

polar marten
#

and write // todo: implement memory management into it

#

you can have it print some stuff. but since this isn't a problem that exists yet, and you don't know how to program, you wouldn't be able to tell if you were doing "it" "right" anyway

#

you can also create a visual scripting thing

#

which will be completely opaque to your colleagues

#

and focus on something high yield for yourself

maiden breach
#

Yes, lie to your bosses and coworkers \s

polar marten
#

you shouldn't use addressables

dusty badger
polar marten
#

@swift falcon are you guys using git?

polar marten
#

i am using it now, and i have complex native plugins

swift falcon
polar marten
trim schooner
polar marten
trim schooner
polar marten
# swift falcon na PlasticSCM

and can you maybe give a super brief description of what the game is? like a logline? just so that what i am saying, i know it makes sense?

swift falcon
#

Can I send you the screenshot tru dm

dusty badger
polar marten
#

it's in your Project Settings -> Editor rollout

#

this is what i'm talking about

dusty badger
#

yeah im talking about modifying a script, i have that set already

trim schooner
#

I haven't touched 2022 yet, I stay away from tech stream versions unless I absolutely need something that's only in the tech stream version.. no idea if 2022 has longer recompile times atm

polar marten
#

it's true you should probably use 2021 LTS

#

it's hard to say. what is your game? what are you trying to do...

#

are you on a mac by chance?

dusty badger
#

im on windows, ill try going to LTS, its just a basic prototype at this point

bronze rampart
#

since when is 15 seconds to recompile astronomically high? relative to nothing maybe its a lot but unless your changing minor things constantly

maiden breach
#

@swift falcon you're at 1/3 through the beginning-middle of a journey, multiple journeys, at least 12 of being talked at in circles

dusty badger
#

also, i did import fishnet at one point and removed it, maybe it was the cause and removing the asset kept "leftovers"?

trim schooner
dusty badger
#

when i was using unity 2018 i was not getting these issues at all

polar marten
#

@swift falcon i guess you're learning the most important lesson of all

dusty badger
#

15 is not that bad but i imagine as the project grows it will get way worse

trim schooner
polar marten
#

if you're being asked to do something that makes no sense, and you're confident it makes no sense, you can focus on doing what you do well (3d modeling) or if you want to learn to program, if that is the goal, focus on a programming goal that's fun for you to do so you do it every day without stress

#

even if it's hard

dusty badger
#

i dont know if this gives you guys any information that could help but i may as well post it

polar marten
#

addressables doesn't sound that fun to me personally

trim schooner
dusty badger
#

yeah i was working on a voxel engine for 3 years in 2018 and it was not even getting close to 15 seconds

polar marten
bronze rampart
dusty badger
trim schooner
#

Modified? No

dusty badger
#

and no sharing for this

polar marten
trim schooner
#

but don't.

polar marten
#

you can also do it in control panel but i don't remember how

#

from a practical point of view, the realtime monitor causes unusually high performance penalties for developers

#

you can always turn it back on if it doesn't improve anything for you

#

right now odds are it's that your computer is slow

#

Set-MpPreference might be a windows server cmdlet and not work on windows 10/11... so forgive me if that errors out and doesn't do anything

dusty badger
#

ah so you think its just using CPU, i doubt that's the case since it was doing fine on an older version of unity, my CPU is probably 3-4 years old i dont remember

polar marten
#

you just have to be trying this stuff a million times faster

#

instead of writing here lol

dusty badger
#

im pretty sure its already turned off but i guess i could try, seems like a weird attempt

polar marten
#

well you can punch it into google and read all about it

stable rivet
#

Quite a basic Q, but my architecture fundamentals are terrible and I'm trying to build better habits:

I'm trying to stray away from using frequent singletons in my projects and find myself often struggling for alternatives. In my current situation, I'm building a roguelite deckbuilder & when the player starts a new game a RunContext is created. This is a plain C# class that needs to be injected into various other classes & monobehaviours. What are some other ways for dealing with common dependencies like this? I've played around with DI in Unity and I'm not a big fan, and service locators just feel like singletons with extra steps.

thin aurora
#

I would suggest a GameManager that holds an instance of your RunContext

#

You can then delete that reference when you restart the game

polar marten
#

right now i simply pass the context down, since it's the least ambiguous

thin aurora
#

GameManager itself holds no data but references to data, like that

#

And it can end the game etcetera

polar marten
#

it's verbose but i couldn't think of a simpler alternative with fewer surprises

#

i am also using interfaces to have the same object (a RunContext for example) but only permit the user of it to do limited things

stable rivet
polar marten
#

yeah

#

i actually put this all in one object, Context

#

and if the method needs to only know about the player's position and the battlefield objects, the object that method is passed is an IMethodNameContext : IBattlefieldContext, IPlayerContext (c# doens't support & on interfaces)

stable rivet
polar marten
thin aurora
stable rivet
thin aurora
#

Well either way, that project implements dependency injection into Unity

#

So you can pass your context down with it

polar marten
polar marten
stable rivet
polar marten
#

i'm writing this with other people authoring cards in mind (this is like Clash Royale)

#

made good progress, today is day 4

stable rivet
polar marten
#

as you can see this is multiplayer

#

not sure if you're in my match

stable rivet
#

quality dropped a lot

#

I think so

polar marten
#

hit refresh

#

i think a few people clicked on this link lol

#

so we'll see

stable rivet
#

LOL

#

that's great

polar marten
#

so i'm testing all these ideas now

#

✅ networked multiplayer ✅ plain unity physics ✅ perfectly synchronized ✅ test easily in editor

bronze rampart
#

cool

polar marten
#

✅ works since day 1

stable rivet
#

Would you be interested in me sharing the repo for my current WIP with you? 😄 I'm very early days so there's not an awful much to go through, and I don't expect you to fine comb it - but I'm trying out a lot of your recommendations that I'm not used to (UniTask, prefabs > scenes, custom game event loop), and I'd like to see if you think it's coming along or if there's any screaming red flags with my approach

bronze rampart
#

a simple multiplayer from the ground up project has always been something I wanna do but its so boring and unrewarding feeling I never get through the wall

stable rivet
polar marten
#

appmana sdk is free

#

and i don't have a way to collect payment

#

local multiplayer game --> networked multiplayer

bronze rampart
polar marten
#

gotta remove rayfire and some of the paid assets

#

but otherwise there's nothing sensitive about it

bronze rampart
stable rivet
flint needle
#

i have a script that selects the closest vertex to the mouse position, i wonder how can i select the faces this vertex belongs to?

#

or how can i select a face (its four vertices) of a mesh?

polar marten
#

same as spellsource

#

clash royale except community contributed cards

#

and i don't think you'll have to be an engineering genius to do it

#

if it works in editor it'll work multiplayer

dusty badger
#

there will be multiple faces that use the same vertex

bronze rampart
#

very cool. im interested for sure. feel free to DM/ping me when you feel its ready 🙂 @polar marten

flint needle
#

how can i do it with triangles so i can get the full face? i guess itll be 2 triangles

dusty badger
#

so youre raycasting onto this mesh and iterating through the whole vertices array? is this a flat plane that you know the order of the vertices and can determine their position by their index without looking it up?

flint needle
#

yeah exactly

dusty badger
#

is it a heightmap? as in, the vertices only change in Y direction?

flint needle
#

well im not so sure about the last thing, because the vertices array isnt in any particular order is it?

swift falcon
#

guys can someone tell me why an https request isn't working when I send a unity web request

#

after reading i found out about this class CertificateHandler

flint needle
#

i basically want the tool to select faces in square (1x1, 2x2, 3x3) instead of vertices in a radius (it misses the corners)

swift falcon
#

but i dont know how to use it

dusty badger
#

so instead of using Vector3.magnitude, you check Vector3.x and Vector3.z individually

#

i think that may do what you want based on what you said, but if youre looking for more refined functionality you probably have to implement a grid system

flint needle
#

i see, thats some insight.
im gonna look into those, thank you.

dusty badger
#

then getting the face is just finding the vertices' index in the triangles array

polar marten
# bronze rampart very cool. im interested for sure. feel free to DM/ping me when you feel its rea...

yeah lots of exciting stuff to try that clash royale cannot do.

  • what if you could summon a little war cart, and summon archers on top of it? it would literally be a unity vehicle
  • multiple 3d levels of units. navmesh pathing over an actual castle structure you start building with ramps. instead of attacking the walls, enemy soldiers would path to a "softpoint" inside the castle, up some ramps, attack that, and when it dies, the whole castle crumbles
  • a literal flood (obi fluids)
jagged laurel
bronze rampart
thin aurora
hollow stone
#

Application.isEditor or use #if UNITY_EDITOR

maiden breach
#

Do you need to [ExecuteInEditMode]?

#

Honestly, your check should work. Probably something else going on

#

You didnt mention it was a ScriptableObject...

tardy echo
#

Hi. I have the following code snippet: [SerializeReference] private List<Node> _nodes; inside of a ScriptableObject. However, after adding the [SerializeReference] to that so I could preserve types, Unity crashes (no error message or anything) immediately when I try to play my game. I have no clue what's happening lol

maiden breach
#

sounds like you might be abusing ScriptableObjects. What are you trying to do with them? @round kelp

#

yeah, this sounds not good. But you could always ClickEvent -= UpdateProgress; right before.

hollow stone
#

OnDisable?

maiden breach
#

well, OnDisable gets called right before OnEnable for ScriptableObjects, so basically the same

leaden ice
leaden ice
hollow stone
tardy echo
maiden breach
leaden ice
leaden ice
tardy echo
#

Idk. I'll have to check it out when I get back to my computer. My only thought is some recursion oversight because anything dealing with the list functioned fine before allowing node types to be preserved

fresh hull
#

I am trying to make Client Side Prediction with RigidBodies, i made a system that creates a empty Idle Scene at runtime and places all players in there, when it's time to simulate the movement it moves the selected player to the physics scene applies the forces and does GameManager.Singleton.simulationPhysics.Simulate(minTimeBetweenTicks) simulationPhysics is the physics scene, but the problem is when i simulate it also affects the Idle scene

#

How can i stop the Idle scene from being simulated

kindred flax
#

Does anyone know any classes that are good for beginners? Mainly online classes

ember pond
#

Brackeys

fresh hull
kindred flax
#

ok

#

btw do you have anyone who's good for 2D?

fresh hull
#

same thing with 1 less axis

kindred flax
#

got it

#

thanks!

ember pond
#

Setting Inspector Values?

fresh hull
kindred flax
#

Help Me With 2D Please!

swift falcon
fresh hull
kindred flax
#

btw do you have anyone who doesn't use assets from the store? I wanna learn from scratch, but I went through the 2D tutorials and it didn't have much

#

I'm not sure if I'm not seeing something or looking hard enough, but a lot of the tutorials that have that basics in it seem to have store-assets

somber nacelle
#

that's because putting together a tutorial focused on the code is easier if you don't have to make the sprites yourself. you are incredibly unlikely to find a tutorial that shows you how to not only code but also how to create your visual assets because those are two completely different skill sets

kindred flax
#

do you know anywhere that I can find online classes maybe?

polar marten
#

kodeco has good written unity tutorials

kindred flax
#

I'm kinda lost when it comes to trying to learn where I can find tutorials

polar marten
#

otherwise you probably want to use the unity learn resources since they are free

kindred flax
polar marten
#

when you say how to create sprites

#

do you mean like, artistically?

#

the tutorials will cover tech art

somber nacelle
polar marten
#

but not drawing

kindred flax
#

As in being able to put a character made from gimp for example

polar marten
#

that's tech art

#

which will be covered in some tutorials for unity

#

however, nobody uses gimp

kindred flax
#

oh lol

polar marten
#

so that's going to be more rare than say photoshop, which unity has a specific importer for characters arted in photoshop

#

you can save a psd in gimp, i'm sure, and it's the same thing

#

and you can learn from a photoshop tutorial how to do something in gimp

#

in the same way you can watch a maya video and learn how to do something in blender

kindred flax
#

ok

#

thanks for the suggestion

#

do you know any specific videos that are from him? Like those that help with creating maps & coding characters

polar marten
#

no but the written stuff is really really good

#

it's all written

#

it's not videos

#

that's why it's so good

kindred flax
#

oh

#

wait

#

so where do I find them? Is there a website

polar marten
#

hmm

#

i think the first thing you should learn is google

#

also, if you want to program, you better get used to reading things extremely carefully too

#

not just tutorials but messages on chat lol

kindred flax
#

got it

polar marten
#

Learn how to get started creating your own games in Unity, a powerful and professional cross-platform game engine! In this Unity learning path for beginners, you will learn the fundamental techniques in Unity development, such as Animation, Sound, Particle Systems, Scripting, UI, and much more.

kindred flax
#

tysm

polar marten
#

the last thing i'll say is seriously, stop with the videos sooner rather than later

kindred flax
#

I was getting really confused with them

#

so I think I kinda had to

#

I feel like whenever I watched tutorials, I always ended with more questions than answers

#

And I never could remember what I "learned" from them, no matter how many times I watched

wintry stone
#

Im using my microphone In unity but its not picking up the right one how can I change the microphone in the unity editor to the correct mic?

potent sleet
#

Microphone.Start("yourDeviceName", true, 10, 44100);

wintry stone
zinc parrot
#

Can you run and dispatch compute shaders in an async task?

solemn raven
#

hey,
do List<> s reorganize themselves after removing one object?
for example : if i have a list of (10) counts and I decided to remove the first item list.RemoveAt(0) .
would item of index (1) became item of Index (0) ?

dusk apex
#

They wouldn't get organized. They just wouldn't get unordered. The first element would be removed and index zero would start at where the second element was.

hexed pecan
ripe bloom
#

I have a chicken that I want to animate in a 2D game and almost got it working. I have two blend trees to switch between walking and idling animations, but for some reason, only the walking animation plays.

Here is my code, it's pretty short:
https://pastebin.com/7SLprW2y

I think the problem may be linked to the animMoveMagnitude as it stays at 1 and goes up to 1.7 when moving. The condition for moving is if its over or under 0.1
The node setup for the animations are set up correctly, the issue relies in the code somewhere.

Edit: Problem solved! I changed the animMoveMagnitude to rb.transform.magnitude

winter bramble
#

Anyone using vscode over vs for editing scripts?

#

Curious if the vscode integrations are as ergonomic / reliable as visual studio

stable rivet
stable rivet
#

wow, that was fast

winter bramble
#

Haha

stable rivet
#

@winter bramble if you have the income to support it, I would suggest trying out Rider on their free trial. it's a very nice experience. I use VS at work and have done for the last year* - still prefer Rider

winter bramble
#

Oh cool, well I do love jetbrains stuffs. Might consider it - thank you.

kindred flax
#

Hey guys, just a thought, but where did you guys learn to code? From Youtube, coding classes, where? I'm trying to figure out where's a good place to start to code, I already have a few sources, but I'm trying to see if there's more that are good.

solemn raven
#

hey ,
should I force close the program or wait ?

kindred flax
#

sometimes it takes a bit

#

only if you saved

solemn raven
#

everything is saved, and the scene is very small usually takes less than 5 sec

kindred flax
#

oh

#

in that case yea

solemn raven
#

passed 3 mins now

#

done , hopefully everything is ok

somber nacelle
#

do you happen to have any infinite loops or recursion happening in an object's Awake method

solemn raven
somber nacelle
#

if the loop doesn't end or if it isn't in a coroutine with a yield in it, then probably

solemn raven
void basalt
#

In ECS, do you still get the same performance boost when using references instead of direct value types inside of components?

void fog
#

belay that... that's zilog =/

void basalt
#

So I'm confused how the hybrid ECS works. You still use GameObjects, but there's like a proxy to sync the struct values with the actual GameObject's transform. Isn't this still slow? Because the backend still has to find the actual GameObject in non contiguous memory?

maiden breach
#

You're only using GameObjects for authoring. Once it is baked, your GameObjects become entities and your Monobehaviours become components. There is no syncing back to GameObjects.

void basalt
#
If it exists, the transform matrix in the LocalToWorld component of the entity is copied to its companion GameObject’s Transform. Those GameObjects are always in world space, the transform hierarchy only exists on the ECS side.```
maiden breach
#

I think that docs page answers your question though. There's no performance benefit to using Hybrid components over GameObject-Component architecture.

glass halo
#

attempting to implement a "shrink" powerup in my unity game that scales down the player when used for a limited time, but if the powerup ends while theyre in small spots theyll get stuck when going back to normal size, any thoughts about workarounds to un-stuck them? i could make all small spaces unaccessable but that kinda defeats the point of shrinking i feel

#

not using rigidbodys if that changes anything, character controller with capsule collider

wicked scroll
glass halo
warm ravine
#

Tl;dr: I need to make a physics engine without collisions, the unity physic engine is not useful for what I am trying to do, does anyone got experience making them?

echo quartz
#

Unity keeps resetting my object's pivot - does having an animation on the object do this?
Nothing else on the object, just the basic stuff + animation

cosmic rain
void fog
cosmic rain
void fog
#

i do like the idea of suffocating them or something like in minecraft

#

you build a block on your dome, you sufficate 😛

echo quartz
warm ravine
#

I tried using it already but it freaked out super quickly so, yeah

cosmic rain
cosmic rain
warm ravine
cosmic rain
# warm ravine yeah, but I am not looking to make it just appear realistic, I need the simulati...

Well, using unity provided components would be the easiest solution, but you could implement your own simulation. It shouldn't be too complicated, you just need velocity and position parameters for each link as well as references to the connected links. Then you just simulate each link every frame by applying forces(like gravity) to velocities, constraining the velocities such that the links are maintained and applying the final velocity to positions. For a more or less realistic simulation, you'd probably need to make several iterations of simulation per frame, as each link will be moved and adjusted several times.

#

For more technical/academic info, try searching "rope simulation" or "rope tensions forces simulation" or something.

warm ravine
#

Thanks, much appreciated

formal dust
#

Vector2 size = new Vector2(transform.localScale.x * colliderSize.x, 0.001f);
RaycastHit2D[] results = Physics2D.BoxCastAll(start, size, 0, Vector2.down, Vector2.Distance(start, end), layermask);

#

there should be incorrect on Vector2 size because transform.localScale.x but if scale is 1. it shouldn't have any problem
with this 2 line of codes, it mean I use the box to find object by drag it down, right?

#

and with size.y there shouldn't be hit.point that is higher than start.y more than 0.001f, right?

#

but this is the result

#

it'll get the result like this when it near the wall

#

unit y is start.y

hexed pecan
#

@formal dust Maybe Debug.DrawLine from start to hit.point, so you get an idea where it is detecting the hit

#

Not sure if the 2D BoxCastAll detects hits that initially overlap the box or not.

formal dust
#

sorry

#

I send the y that doesn't have a problem

#

red box is area that this boxcast go from start to end

#

The axis in the image is y=0.01520102

#

when I move out of the wall it work correctly

formal dust
warm wing
#

Morning, is anyone able to help with a problem I'm having with configurable joints? In short if my parent object is sat at 0,0,0 its fine. But the further I move it from zero the further the connectedAnchor moves out of position. Here's a short snippet

cosmic ermine
#

Given an index how could I get a point in a square spiral? Certain there must be a simple solution to this. The closest thing i could find would be this desmos graph: https://www.desmos.com/calculator/20cexqlcyy but sadly i don't speak math, so i don't know how to convert it into something useable

earnest gazelle
#

One question about grouping your codes.
Do you prefer to group them like UI, Core, Data, etc.
All UI scripts in UI folder/namespace, etc.
or first categorize them component wise
MechanicA/Core,MechanicA/UI
MechanicB/Core,MechanicB/UI
For example for inventory.
Gameplay/Inventory/UI, Gameplay/Inventory/Core.

I mean you consider first layers (it is a UI script, service, core, data, etc.) or first split them into components/usecases

latent latch
#

I got to a point where I just dumped all my scripts into one folder cause I couldnt bother navigating them all

#

I keep SO data separate though

soft shard
# earnest gazelle One question about grouping your codes. Do you prefer to group them like UI, Cor...

Both are pretty good ways of organizing your assets, I think it depends on the scale of your project - if it has a lot of features/game mechanics, grouping all the assets related to that mechanic may be a good idea to make it easier to find the assets that mechanic needs to reference

If you have a larger scale project, where multiple things share multiple assets, and your project may be largely managed by the design and art team, it may make more sense to have assets grouped by type so its easy to find general assets and prefabs, but could make finding certain assets require you to use the search bar more and remember names - that said, I personally prefer the first option for the scale of projects I make as I find it helps keeps me organized and know that every script and asset has a place thats easy to navigate or even move out the project, knowing I took all dependencies with it

swift falcon
#

can someone tell me the representation of a string that has two return presses* after each other ... like "\n\n"
I need to know to solve the current problem

mellow sigil
#

"\n\n"

swift falcon
# mellow sigil `"\n\n"`

I tried thaat... it didnt' work.. I was trying to replace it with "" (delete it) but it didn't work

mellow sigil
#

Either the string doesn't contain what you think it does or you're doing something wrong

swift falcon
#

i will check for spaces but i dont think there is

quartz folio
#

Depending on the platform newlines can be represented differently. \r\n is the windows newline (CRLF, carriage return + line feed)

swift falcon
#

didn't work

swift falcon
#

also didnt work

#

is there a website that I can put the file in and it will give me the values \n or \r or something else

daring nymph
#

is it possible to reference a prefab from a script attached to that same prefab? when I drop the prefab onto the field in inspector it references the object in the scene instead of the original prefab

mellow sigil
swift falcon
#

what's @"\n"

mellow sigil
#

Replace newline and carriage return characters with literal text \n and \r so that you can see them

#

@"\n" is "insert the literal characters \ and n, not a newline character"

swift falcon
#

AAAAAAAAAH Thank you... now this is what I got as a debug "\n\n" (etc... about 900 of them)
why am I unable to replace them

quartz folio
#

What does your code look like

mellow sigil
#

I'm giving it about 80% chance that you're not assigning the replaced value back to the variable

swift falcon
#

        string fileData = File.ReadAllText(Application.persistentDataPath + "/file.csv");


        Debug.Log(fileData.Replace("\n", @"\n"));
        while (fileData.Contains("\n\n"))
        {
            fileData = fileData.Replace("\n\n","");
        }

mellow sigil
#

huh, not that

quartz folio
#

So what's happening?

mellow sigil
swift falcon
#

the string isn't getting the new lines removed for some reason

#

i was thinking it is the characters' representaion

#

now i know it is something very little and stupid

#

ill rewrite the code

void fog
#

string fileData = File.ReadAllText(Application.persistentDataPath + "/file.csv").Replace("\\n", "").Replace("\\r", "");

mellow sigil
#

Show what the debug log prints (and what it prints after that while loop)

swift falcon
#

yep... it was a stupid thing from me...

mellow sigil
#

It's also a bit strange to replace newlines in a CSV file, are you sure it's what you need to do?

swift falcon
#

i only update the value of the file if there's a line that's not \n\n

#

thank you all

swift falcon
#

thank you @mellow sigil and @quartz folio

void fog
swift falcon
#

I didn't even see it 😂

void fog
#

ahh, yeah lol

#

he was wondering why the removal of the new lines from a csv when that's the denotation of a new record

quartz folio
#

If you're under a canvas already then it's the canvas which performs sorting, so to do selective sorting below that you need subcanvases

#

You can also use a CanvasGroup to hide part of a hierarchy or stop it being interactable

rancid jolt
#

I am instantiating hit effect vfx at the point of bullet collision on enemy but it is instantiating wierdly at the back of the enemy

velvet quartz
earnest gazelle
#

I mean there are namespaces and folders like UI/featureA, Core/featureA, data/featureA and also FeatureB/UI, FeatureB/core

earnest gazelle
static matrix
#

Can someone help me out with the builtin buttons? I have no idea how to get them to run the function i want them to, or to do anything at all

stuck robin
#

your scene needs an Event System gameobject (under UI) to function properly if you use this route

static matrix
#

Oh

#

Let me add that to my canvas

stuck robin
#

usually if you add a canvas the event system also gets added

static matrix
#

Yeah i added an empty and gave it a canvas so it wasnt

#

Let me try this again

stuck robin
#

kk

static matrix
#

I still only get the options for MonoScript -> string name

stuck robin
#

hmm

static matrix
#

Or will onmouseup work now with the event system

stuck robin
#

it should

static matrix
#

Oki

stuck robin
#

that sort of functionality should work out of the box with minimal setup, to call whatever code you need to call

static matrix
#

Im testing hold on

stuck robin
#

the docs on these functions are useful as well

#

o right

#

shit you need a collider too

#

my bad lol

static matrix
#

Yeah adding it

#

Nope

stuck robin
#

hmm

static matrix
#

Just clicks the thing behind the button

formal dust
#

Vector2 size = new Vector2(colliderSize.x, 0.001f);
RaycastHit2D[] results = Physics2D.BoxCastAll(start, size, 0, Vector2.down, Vector2.Distance(start, end), layermask);
with this 2 line of codes, it mean I use the box to find object by drag it down, right?
and with size.y there shouldn't be hit.point that is higher than start.y more than 0.001f, right?
red box is area that this boxcast go from start to end
The axis in the image is y=0.01520102
when I move out of the wall it work correctly

#

anyone know what's the problem?

static matrix
#

The not canvas ones work

stuck robin
static matrix
#

But i need canvas bcause overlay

#

Screenspace overlay

stuck robin
#

whats the sort order of the canvas and the objects behind it?

formal dust
#

why hit.point is on the opposite side of direction?

stuck robin
#

tho i wonder if the sort order does anything beyond impact rendering, I'm not actually sure here

static matrix
#

Maybe

#

Let me crank it up

stuck robin
#

usually you jsut need to offset it by atleast 1

static matrix
#

Yeah the canvas ia above

stuck robin
#

right, okay hmm

static matrix
#

I could try having an object that follows the cursor scaled to the canvas and detect a click

#

But that seems wrong

stuck robin
#

ye

#

the event system does work

#

hmm

static matrix
#

Maybe it is working but im not detecting it right

#

Inheritance problem perhaps

#

Nope

#

Odd

#

Ill keep trying

stuck robin
#

okay so I:

  1. added an empty scene
  2. added the button
  3. setup the OnClick in the button component to call the code I want from a gameobject in the scene with the script and code I want to call being set in the event (see screenshot)
    and the event calls as long as the event system is in the scene
static matrix
#

Ok let me try and copy this exactly

stuck robin
#

the code I wrote to be called is v simple too, but realistically you could call anything

static matrix
#

OH OH OH

#

You have an object

#

I was trying to use the script directly

#

Hold on

stuck robin
#

ahh yeah, the script has to be on an object in the scene to be accessible

#

otherwise theres no reference afaik

#

I shoulda included it as a step to set up this object, my bad

static matrix
#

No it's cool

#

Let me add collider again

#

Hold on im fandangleing

stuck robin
#

haha no worries

#

you got this hopefully, just take a min

static matrix
#

Thanks

#

Is it because its an override void?

#

For me

#

Still not working

#

Im probably missing something stupid

velvet quartz
#
public static event EventHandler OnAnyCut;

    new public static void ResetStaticData() {
        OnAnyCut = null;
    }

Someone can explain the goal of reset a static event variable ?

soft shard
# earnest gazelle Thanks but my question is about specifically scripts not other assets like textu...

Ah my bad - I use namespaces for features that can exist independent of others, for example a spell system doesnt need to know about the AI system, which doesnt need to know about the game settings, those 3 might be in different namespaces, organizing the scripts related to that spell system I might have a "System" folder for the namespace code as a base class and data class (ScriptableObject, JSON file, etc) and then a "Gameplay" folder that uses those base classes and data structure, for example:

//Might exist in: Assets/Systems/Scripts/Spells (with a "spells" assembly defintion file that uses a "Project.Magic" namespace)
namespace Project.Magic
{
public class Spell {} //base class for spell logic
public class SpellData : ScriptableObject {} //base class for data related to a spell, some Editor script could make it easier to customize this
}

//Might exist in: Assets/Gameplay/Scripts/Spells (no defition file, no namespace, instead it uses other namespaces)
using Project.Magic;

public class Fireball : Spell
{
public ProjectileSpellData data;
}

This is just how I would personally organize my code cause I find it easier using a "feature folder" to organize all assets of a project, including scripts, using both namespaces and a folder structure for your scripts is fine, there isnt really a "one size fits all" approach as the use-cases may be different and depend on different factors, though unless your organizing your assets by type or feature, where your scripts exist should be whatever is the most organized for you, unless your using assembly definition files as either auto-namespaces or to isolate code or optimize compile times, if I understand your concern correctly, hopefully that helps

static matrix
#

I think im missing more stuff on the canvas

#

Yes i was

#

Its working now

#

Thanks guys 🙏

#

Bro i hate how gameobject.find cant find inactive objects

mellow sigil
#

One of the many reasons why using Find at all is a bad idea

static matrix
#

Yeah

#

Im gonna phase out my usage of it

lyric barn
#

Can anybody help me regarding procedural dungeon generation (in 2D)? Am looking towards a dungeon generation like in Enter the Gungeon or similar games, which is generating using premade rooms of different sizes and premade hallways, and tilemaps. I was searching for a tutorial which covers this type of dungeon generation, but didn't find any covering this specific way, if you know a tutorial that covers this type of dungeon generation then I would be very happy to know. If you don't know any resources that could help me make a dungeon generator, I would appreciate a tutorial or tutorials on coding with tilemap itself, so I could maybe make my own dungeon generator.

stuck robin
# lyric barn Can anybody help me regarding procedural dungeon generation (in 2D)? Am looking ...

Learn how to procedurally generate a 2D dungeon in Unity using Random Walk and Binary Space Partitioning algorithms! In this tutorial we will use unity Tilemaps to create single and multi room dungeons connected by corridors using Corridors First and Rooms first approaches.

Resources
https://github.com/SunnyValleyStudio/Unity_2D_Proecdural_Dun...

▶ Play video
lyric barn
grizzled needle
#

Is it a good idea to keep collectionchecks as always true for objectpool?

#

I was reading the documentation and it says that it only runs in the editor

velvet quartz
#
GameObject zombieController = sender as GameObject;
        RemoveGameobjectInList(zombieController);

IS THE SAME AS

ZombieController zombieController = sender as ZombieController;
        RemoveGameobjectInList(zombieController.gameObject);

OR NOT ?
leaden ice
#

Not the same no, sender is a different type in each

velvet quartz
copper shoal
#

Is there a reason why Input.GetKeyDown is not always registering the input for me? I have an if statement in Update and it doesn't always register the fact the I press E
Like, I sometimes need to press the key multiple times (the amount of presses is random) for it to notice that. Sometimes it works on the first try, sometimes on 10th

copper shoal
#
private bool Epressed;

private void Update()
    {
        if (Input.GetKeyDown(KeyCode.E))
        {
            Epressed = true;
        }
        else
        {
            Epressed = false;
        }
    }

This is literally it. I use Epressed bool later in an if statements in OnTriggerStay, but I checked with Debug.Log that the OnTriggerStay works correctly

mellow sigil
#

Put a debug.log inside the if statement to confirm that it's this part that's not working

#

ah, nevermind. OnTriggerStay runs during the FixedUpdate phase. This can set the flag to false before OnTriggerStay gets to run.

#

Set the flag to false in the OnTriggerStay code, not here

copper shoal
#

I'll try that

#

Still doesn't work. I've put it in OnTriggerStay and the Debug.Log doesn't always activate

#
if (Input.GetKeyDown(KeyCode.E))
        {
            Epressed = true;
            Debug.Log("E pressed!");
        }
        else
        {
            Epressed = false;
        }
mellow sigil
#

So you didn't remove the part that sets the flag to false

copper shoal
#

I'll check it without that part

#

Still doesn't always work. I need few presses sometimes to activate that bool

#

I mean, in Debug tag I can see that the bool doesn't activate when I stay on trigger and press E

mellow sigil
#

Show what you have now, including the ontriggerstay

copper shoal
mellow sigil
#

no

restive pawn
#

I made a program that if the player touches a collider (which is set on tirgger), it respawns the player and adds money through another script i made. Whenever the player touches the collider, nothing seems to be happening, does anyone know why? here is the script:

mellow sigil
#

show the relevant parts

restive pawn
#

using UnityEngine;

public class FinishLine : MonoBehaviour
{
public int moneyToAdd = 10;
public Transform respawnPoint;

// Called when the player enters the collider
void OnTriggerEnter2D(Collider2D other)
{
    // Check if the other collider belongs to the player
    if (other.CompareTag("Player"))
    {
        // Get the player's money manager component
        MoneyManager moneyManager = other.GetComponent<MoneyManager>();

        // Add money to the player's current amount
        if (moneyManager != null)
        {
            moneyManager.ModifyMoney(moneyToAdd);
        }

        // Respawn the player at the respawn point
        other.transform.position = respawnPoint.position;

        
    }
}

}

#

MoneyManager is the other script i made

#

for some reason the player wont respawn or add money, i even checked using a debug.log and it doesnt even do that

#

Why is there no output being sent when the player touches the collider (which is set on trigger)?

warm wren
restive pawn
warm wren
restive pawn
#

Lemme see if that fixes it

copper shoal
# mellow sigil show the relevant parts
private void OnTriggerStay2D(Collider2D collision)
    {
      if (Input.GetKeyDown(KeyCode.E))
      {
        Epressed = true;
        Debug.Log("E pressed!");
      }
      
      if (_shootScript.guns == Shoot.Guns.SMG && Epressed)
      {
        //Do somethingg
      }
    }

The last if statement is repeated few times with different requirements from _shootScript.guns

#

Only 2 other if's need the Epressed

mellow sigil
#

Ok you moved everything to the OnTriggerStay method. You were only supposed to move the part that sets the flag to false

copper shoal
#

oh

mellow sigil
#
private void Update()
{
    if (Input.GetKeyDown(KeyCode.E))
    {
        Epressed = true;
    }
}

private void OnTriggerStay2D(Collider2D collision)
{
    if (Epressed)
    {
        // do whatever
        Epressed = false;
    }
}
restive pawn
copper shoal
brisk marsh
#

Does the Multiple Selector support pseudoclasses?

tawny mountain
#

Looking for assistance here if anyone knows what i need

velvet quartz
lucid valley
#

otherwise just use a integer to store the faction id

velvet quartz
#

I don't see how you can do this with int.

lucid valley
#

e.g team 1 is 1

#

shouldnt be that hard to understand lol

#

just means you don't hard code the amount of factions as an enum

#

you know your game better than me so you'll know how many factions is possible

velvet quartz
#

Yeah so enum is better.

#

And if you want some faction to be friendly together you need to store it

#

With dynamic int that look strange to do

lucid valley
#

well at that point i'd make a factions manager and store faction data on that which can then have all that custom stuff in it

#

you shouldnt really touch the team stuff in code outside the manager so using a int would be fine (not hardcoding stuff)

#

You'd actually have a faction class to store the faction data

public class Faction
{
    public int FactionId;

    public List<Faction> FriendlyFactions = new List<Faction>();

    //Other faction dependent stuff
}
mystic ferry
#

isn't this the burst compiler? can I just delete the package for it or something?

#

or gitignore? or is that gonna cause issues

#

in case it's not apparent, I'm not using the burst compiler

mellow sigil
#

You shouldn't commit library files to git. Either you don't have a gitignore file or there's something wrong with it

lucid valley
#

^

mystic ferry
#

I mean, my gitignore is a standard unity ignore file, and it's supposedly already ignoring the library folder

#

not sure what's wrong with it

mellow sigil
#

Is it in the pong-clone directory?

mystic ferry
mellow sigil
#

so no

#

it needs to be in the Unity project directory (pong-clone)

#

usually the git root directory is also there

mystic ferry
#

yeah that worked, obviously

#

I've been using bitbucket for a long time and just recently switched to github so I guess I screwed up the repo somehow

#

thanks @mellow sigil

fiery path
#
    {
        RayCasting();
        if (isGrounded)
        {
            rb.constraints = RigidbodyConstraints.FreezeAll;
            cameraShake();
            Debug.Log("Frozen"); 
            if (!GameManager.instance.isTrapped)
            {
                StartCoroutine(ResetCage());
                Debug.Log("Reset");
            }
        }
    }


    IEnumerator ResetCage()
    {
        theCage.transform.position = Vector3.MoveTowards(theCage.transform.position, cageOriginalPosition, Time.deltaTime * 2);
        yield return null;
    }```

I may be stupid but anyone know why the IEnumerator isnt moving theCage's position
#

wait

#

loop

#

i am just stupid

outer plinth
#

When I multiply a quaternion by a quaternion am I rotating the initial quat by the 2nd similar to how it rotates a vector?

outer plinth
#

Tyvm for the resource

median folio
#

So I have a list of blockPositions I then randomly pick one and add it new a new list newRandomPositions I can see that my blockPositions list has 6 items in it but after debugging it seems to only add 3 to the newRandomPositions list.

Any thoughts on what I might be doing wrong?

        List<Vector3> blockPositions = new List<Vector3>();
        blockPositions.Add(block_Slot3_level2);
        blockPositions.Add(block_Slot6_level2);
        blockPositions.Add(block_Slot5_levle2);
        blockPositions.Add(block_Slot4_level2);
        blockPositions.Add(block_Slot1_level2);
        blockPositions.Add(block_Slot2_level2);

        List<Vector3> newRandomPositions = new List<Vector3>();

        for (int i = 0; i < blockPositions.Count; i++)
        {
            int ran = (Random.Range(0, blockPositions.Count-1));
            newRandomPositions.Add(blockPositions[ran]);
            blockPositions.RemoveAt(i);
        }
high violet
#

when i load a new scene asynchronously the progress goes to 0.9 and then it stops for a long time . how can i reduce that loading time?
i saw a brackey's video about loading scene and he said the first 0.9 is for loading gameobject and other 0.1 if deleting previous and activating new objects so is that causing this time and if yes then how can i improve the time?
i am using this code

public void LoadScene(string sceneName)
    {
        StartCoroutine(LoadSceneAsync(sceneName));
    }

    IEnumerator LoadSceneAsync(string sceneName)
    {
        AsyncOperation operation = SceneManager.LoadSceneAsync(sceneName);
        Loadingscreen.SetActive(true);
        while (!operation.isDone)    
        {
            float progressValue = Mathf.Clamp01(operation.progress/0.9f);

            LoadingBar.fillAmount = progressValue;

            yield return null;
        }
    }
daring nymph
median folio
#

Thanks @daring nymph that's a really smart approach. Is there a way to use this without making my class static?

daring nymph
#

or if you keep it as an extension method, then you can just do blockPositions.Shuffle()

#

edited

median folio
#

Wow that's really cool thanks so much @daring nymph you solution works perfectly and is much cleaner than my solution!

Even better I can already see how this Utils class will be useful going forward. I haven't really came across extension methods before but will do a little reading into them.

My current project has taught me a lot of new concepts - Inheritance, state machines, singletons etc so I'm always excited to see new techniques.

daring nymph
median folio
languid hound
#

Someone said I should use delegates if I wanted to pick a random function out of like 20. How would I do this?
Like I know how to define a delegate function and that you can use them in an array but like
How does that help pick a random function

mellow sigil
#

If you get as far as having the delegates in an array then picking a random one from there is the easy part

languid hound
#

That sounds stupid but if I have multiple voids how can I use a single list of a delegate to run those?

mellow sigil
#

I don't know what you mean by "a single list of a delegate"

languid hound
#

Wait hold on

#

So I just saw an example of someone making a delegate void and then doing delegatevoid(function)

#

Is that how they work lol?

#

An array of a delegate even

#

Goddamnit

#

This is so confusing

mellow sigil
languid hound
#

How can I use a delegate to pick a random function and run it though

#

That's where I'm stuck

solemn raven
#

hi ,
is it possible to clear the entires of an enum and replace it with a newer ones via script/editor script?

mellow sigil
#

You speak of "a delegate" so I think that's what's tripping you

#

If you want to pick one from 20 functions you make 20 different delegates and put those in an array

#

each delegate runs one of the 20 functions

languid hound
#

Ohhhhh

#

I completely misunderstood

#

I was thinking people somehow stuffed multiple functions into one delegate

#

Ok just to be certain though I don't have access to my PC currently

#

How would you make an array of delegates

#

Oh wait nevermind it seems to be like any normal thing

#

Alrighty then

mystic ferry
#

instantiating a prefab and then modifying it's rigidbody after the fact, but for some reason I'm getting "the variable rb has not been assigned" anyone know why?

#

not sure how I'm supposed to assign a variable I'm creating at runtime

#

just realized I made a float an int but ignore that

#

I have the rb field and use GetComponent in awake like you would normally

hard estuary
inner otter
#

Hey guys I'm really new and using visual script. On the tutorial in unity the guy types the code and suggestions pop up such as vector3 ect. Does anyone know how to enable that

mystic ferry
daring nymph
mystic ferry
#

well I screenshotted the method that the staketrace gave as giving an error, but I do have a getcomponent call in awake

ebon dagger
#

Any ideas on creating shotgun shoot script on 2D. Struggling with the randomness on the rays

mystic ferry
# daring nymph there's no `rb = GetComponent<Rigidbody>()` in your screenshot though

[RequireComponent(typeof(Rigidbody2D), typeof(CircleCollider2D))]
public class DefaultPuck : MonoBehaviour, IPuck
{
   private Rigidbody2D rb;
 
   private void Awake()
   {
      rb = GetComponent<Rigidbody2D>();
   }

   public void Punch()
   {
      float direction = Random.Range(0, 1);
      if (direction >= 0.5)
      {
         rb.velocity += GameManager.instance.puckSpeed;
      }
      else rb.velocity += Vector2.left * GameManager.instance.puckSpeed;
   }
daring nymph
mystic ferry
#

yes

#

does that avoid an Awake call or something? that would explain the error, although not make sense lol

daring nymph
#

yeah that must be it, according to unity docs:

Awake is called either when an active GameObject that contains the script is initialized when a Scene loads, or when a previously inactive GameObject is set to active, or after a GameObject created with Object.Instantiate is initialized.
mystic ferry
#

wow. Okay.

#

thank you, that's somewhat frustrating but not as bad as I thought it was @daring nymph

daring nymph
#

yeah well not a big deal is it, you can just move that GetComponent into a new Init method and then just AddComponent<DefaultPuck>().Init()

mystic ferry
#

good idea. Thanks for the help

daring nymph
#

I keep getting these in editor whenever I open any prefab, regardless of what's in it. Any thoughts?

potent sleet
#

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

potent sleet
#

so you didn't read the bot message did you

#

you're flooding this entire chat no one will read this

#

put them in links

median folio
outer plinth
#

Hey, wondering if I have this right, I want to apply 2 rotations simultaneously, so I have to negate the first rotation when applying the second right?

Quaternion.LookRotation(smoothedMoveInput) * (Quaternion.AngleAxis(angle, axis) * Quaternion.Inverse(Quaternion.LookRotation(smoothedMoveInput))

daring nymph
daring nymph
solemn raven
#

hey,
is it possible to make a slow AsyncOperation ?

solemn raven
# somber nacelle *why*

trying to design a loading screen based on heavy asyncOperation , so I need one of a few to test it.

potent sleet
solemn raven
potent sleet
# solemn raven hmm , I'll try that , I have no idea what is concidered as a AsyncOp and what is...
 private AsyncOperation asyncLoad;

    void Start()
    {
        StartCoroutine(LoadSceneAsync());
    }

    IEnumerator LoadSceneAsync()
    {
        asyncLoad = SceneManager.LoadSceneAsync("MainScene");
        asyncLoad.allowSceneActivation = false;

        while (!asyncLoad.isDone)
        {
            Debug.Log("LOADING...");
            if (asyncLoad.progress >= 0.9f)
            {
                yield return new WaitForSeconds(3.4f);
                Debug.Log("Done");
                asyncLoad.allowSceneActivation = true;
            }
           
            yield return null;
        }
    }```
#

mayb

solemn raven
inner relic
#

is it better to have decoupled code or performant code?

#

cause I'm making some systems within my game in which they both have shared functionality

#

I could have it so that these 2 systems communicate with each other and share functionality, but that will make it harder when I introduce assembly definitions later down the line

tawny mountain
cosmic ermine
#

just received this warning, should I be concerned? (I haven't deleted any scripts or anything so I don't know why this appearing)

solemn raven
#

hey,

int A =2 ;
int B 20;
float result = Mathf.Round((float)A / (float)B) * 100;

why result == 0 ??

#

that was suppose to be 10

cosmic ermine
#

cause you rounded before the multiplication

#

round(2/20) = 0

#

0*100 = 0

solemn raven
#

ohh

solemn raven
cosmic ermine
#

np

cosmic rain
soft shard
# inner relic I could have it so that these 2 systems communicate with each other and share fu...

I would say separating your logic into reusable classes as often as possible is always good, even better if you can find ways to make that class generic so its not specifically built around the dependency of one other specific system - for example, a save system could be generic enough to save any kind of data, then your settings, level manager, player progression like stats and unlockables etc can all use it without needing their own specific save/load class - for context though, what are the 2 systems in question? And how do you intend to use your assembly definitions where just a namespace may not be be enough?

torn eagle
#

Hey!! Anyone know how I would go about using Render Textures to generate a texture where this flower image is overlayed over another?

cosmic rain
dawn nebula
#

What would be more efficient? OnTriggerEnter/Exit, or using Physics.Overlap every fixedupdate?

torn eagle
cosmic rain
torn eagle
#

I want the one I shared to be rendered as the foreground to a background texture

cosmic rain
#

Ok, so what is the problem?

torn eagle
#

At the moment my main problem is just getting the scaling right, pretty sure I'm setting something wrong with the width and height somewhere along the line

#

Lemme pull up my current code it'll probably help lol

#
int randomIndex = UnityEngine.Random.Range(0, imagePaths.Length);

            string randomImagePath = imagePaths[randomIndex];
            byte[] bytes = File.ReadAllBytes(randomImagePath)
                ;
            Texture2D flower = flowerImages[UnityEngine.Random.Range(0, flowerImages.Length)];

            Texture2D texture = new Texture2D(flower.width, flower.height);
            texture.LoadImage(bytes);
            texture.Apply();
           
            AddWatermark(texture, flower);

 public Texture2D AddWatermark(Texture2D background, Texture2D watermark)
    {

        int startX = 0;
        int startY = background.height - watermark.height;

        for (int x = startX; x < watermark.width; x++)
        {

            for (int y = startY; y < watermark.height; y++)
            {
                Color bgColor = background.GetPixel(x, y);
                Color wmColor = watermark.GetPixel(x - startX, y - startY);

                Color final_color = Color.Lerp(bgColor, wmColor, wmColor.a / 1.0f);

                background.SetPixel(x, y, final_color);
            }
        }

        background.Apply();    


        Rect rec = new Rect(0, 0, background.width, background.height);
        img.sprite = Sprite.Create(background, rec, new Vector2(0, 0), 1f);
        Application.Quit();


        return background;

    }

#

If possible I want the output texture to be of the same width and height as the flower texture, however, the outputs rn are pretty wonky

#

Example of current output

cosmic rain
#

If you want to have more control over the width/height and offset, why not just have 2 sprites with your textures set up(so that you can configure it in the scene view) and render the result to a render texture.

torn eagle
#

So sorry I'm a bit of a moron when it comes to render textures how would I exactly set that up so it can then be exported as a png

ancient rock
#

Anyone know how to force Unity to run at max possible FPS on android devices?
On my android phone, it's defaulting to 30FPS when it supports 120FPS.

cosmic rain
#

It's a pretty bad idea though

ancient rock
#

That sounds like a stupid solution...

#

Since what if I run it on devices that don't support 120fps.

cosmic rain
#

There's no such thing. All devices support any frame rate.

#

You might be confusing screen refresh rate with the frame rate of the application

#

These are 2 different things