#💻┃code-beginner

1 messages · Page 424 of 1

zenith crown
#

Using a variable i called Current speed

#

These

polar acorn
#

this is a bunch of variables on a different object, what does this have to do with the question

#

Do you have another canvas in front of this one?

#

And does this canvas have a GraphicRaycaster component?

winter tinsel
#

ill check

winter tinsel
#

should i change anything in it ?

winter tinsel
zenith crown
#

that i then multiply

#

by the current speed

polar acorn
zenith crown
#

and then move that way

polar acorn
zenith crown
winter tinsel
winter tinsel
#

should i send each individually or is there something specific you need?

#

like as much info into one pic cause i cant get the full inspector in one

zenith crown
#

Idk he just used public CharacterController Controller; then proceeded to use Controller.Move(move * Current_Speed * DeltaTime)

polar acorn
zenith crown
#

Yes

polar acorn
zenith crown
#

You can see it here except that its before adding current speed and delta time

#

cause it didnt work without them

winter tinsel
polar acorn
zenith crown
#

Now i did it

#

and it still didnt work

polar acorn
# zenith crown

Did they name their script CharacterController in the tutorial

zenith crown
#

I now see the problem

polar acorn
zenith crown
#

wow that is an embarassing mistake

#

holy

winter tinsel
#

h o w

#

i havent touched it???

polar acorn
winter tinsel
#

are you kidding me???

#

how did that happen??

polar acorn
#

Misclick maybe?

winter tinsel
#

i literally havent touched it

#

no i havent opened it at all lmao

#

this is crazy

grizzled gale
#

Unitypackage file not opening sumthing error

zenith crown
winter tinsel
#

ugh

zenith crown
#

fixed that problem

winter tinsel
#

thanks

zenith crown
#

still doesnt work

#

its exactly like in the tutorial the code

polar acorn
# zenith crown

Did they name their script CharacterController in the tutorial

zenith crown
#

Bro i literally changed it and its still the same

#

omd

#

one sec

#

Now it works

#

thank you man

#

im blind

polar acorn
winter tinsel
#

and while that scene is running, the other one with the actual game wont right?

polar acorn
winter tinsel
#

simplest one for right now

#

point is yes it can be

#

okay uh

polar acorn
#

Simplest is probably just a canvas you toggle

winter tinsel
#

ehh, rather not

polar acorn
#

but an additive scene is probably better for organizational purposes

winter tinsel
#

yes

#

and while that scene is running the actual game scene wont right?

#

the scene that has the game

polar acorn
#

If you change scenes, the scene that gets unloaded ceases to exist and every object in it is destroyed

#

You could use additive scene loading to have multiple scenes at once

winter tinsel
#

what if i change BACK to that scene?

#

does everything get reloaded?

polar acorn
#

You would be loading that scene from disk as it was defined in the inspector

winter tinsel
#

question, if i was to make a game with multiple indivually explorable areas that are big on their own

#

this would require mulitple scenes right?

polar acorn
#

Probably

winter tinsel
#

or atlesat it would be better with them

#

im just asking if itll work on build

#

like will it work if the base scene is the main menu and you load into the GAME scene ig

#

it changes to it ig

lunar crater
#

it was because charactercontroller, your script was a class inherited from monobehavior and charactercontroller, the component is also a class so they were causing conflict and i'm guessing your script is like a higher priority class

sleek marten
#

I'm having this UI overlapping issue and can't find a reliable fix

#

What do I do about this?

modest dust
#

Since this is a code channel, post the code related to the issue

#

If you're using a custom property drawer, then you probably didn't override GetPropertyHeight or made a mistake

sleek marten
late compass
#

hello , i have a list of Components i want to make foreach loop and then disable every component in the list in the foreach loop like this :

            foreach(Component componentcomp in NonNetComps)
            componentcomp.enabled = false;

but i get an error on enabled why i cant access it ?

modest dust
sleek marten
#

like an editor script?

queen adder
#

@sleek marten you don't have to serialize the second class like that?

#

You can just serialize the fields themselves

#

See if that fixes your issue

modest dust
#

The thing he does is perfectly valid

queen adder
#

Oh no I see what your doing my fault

sleek marten
modest dust
#

Try updating your unity editor version then

queen adder
#

What version of unity are you using?

modest dust
#

You're 36 versions behind the latest LTS version for 2021

sleek marten
sleek marten
sleek marten
modest dust
#

Not necessarily

#

2021.3.40f1

#

You can try 2022 if you want, but backup your project

desert plinth
#

Is there a way to get the gizmo box to rotate with the game object? When I rotate the object that has the gizmo, the gizmo stays at the same orientation

modest dust
#

Pretty much backup your project every time you update your editor

sleek marten
#

I got like 8 versions of unity installed

#

I have .4f1 AND .40f1

modest dust
#

Are you using ALL 8 versions?

sleek marten
#

nope

modest dust
#

Then uninstall them

sleek marten
#

but everytime I start a group project they always want to use a different version

sleek marten
#

circumstances won't let me

modest dust
#

And how many group project are you in at once

mint remnant
#

@desert plinth if you can use a sphere instead of cube, no need to rotate it

sleek marten
#

uhhh 3 atm

#

plus a solo

modest dust
#

Then you can remove half of these versions

#

And politely ask others to use the latest LTS in the next projects

desert plinth
sleek marten
#

into the trash they go

#

I'll change to 40f1 and see how it goes

lilac ocean
#

say you create a class in script a, is it possible to create an instance of that class through script b?

lilac ocean
#

how?

polar acorn
#

new

#

Assuming the class in Script A isn't a MonoBehaviour

lilac ocean
#

ok yeah

ionic zephyr
#

Should I make my resources and my tools different ScriptableObject scripts?

#

or is it better to make an "item" scriptable object?

#

this is because I want my tools to have atributes like strength, durability

short hazel
#

Then derive from it, for each different item type that has specific properties (a gun would have an initial magazine capacity, and armor would have strength)

sleek marten
hybrid tapir
#

is there a way to run a script without play mode? i wanna change the text size of a button when the screen resolution changes. (in this case when i drag the editor window from my 1080p monitor to my 720p tv) i finally figured out how the anchors work.

short hazel
#

You may not need to, you can check the "Auto font size" in the button's underlying TextMeshPro Text component

hybrid tapir
#

oh

short hazel
#

That way it will adapt to the container (the button) size

hybrid tapir
#

thank you

#

why does it make the text bigger when i switch screens

#

thats literally the opposite of what i want to happen

#

-_-

ionic zephyr
#

Can I rename all the appeareances of a CLASS name?

#

I know you can with variables but what about classes?

slender nymph
#

use the refactoring tools to do so

short hazel
#

Same way as renaming variables. The keybind depends on which code editor you're using

ionic zephyr
#

Visual Studio

#

(not code)

short hazel
#

With the caret (blinking text edition cursor) over the name, hit Ctrl + R twice to begin the rename operation

ionic zephyr
#

It says I can´t rename this

short hazel
#

Make sure the caret is over the class name

#

Not the mouse cursor, the caret

ionic zephyr
#

still not working

slender nymph
#

are you doing it from the class or from some other file?

short hazel
#

Show a screenshot of what you're doing

slender nymph
#

yeah so that's likely the problem

ionic zephyr
#

oh okay, it is

lilac ocean
#

Atom is a class and atoms is a List<Atom>, when i run foreach(class Atom in atoms) it gives me a ton of errors, and when i run foreach(Atom in List<Atom> atoms) it doesn't change anything

short hazel
#

!vscode

eternal falconBOT
#
Visual Studio Code guide

If your IDE is not underlining errors in red or autocompleting code,
please configure it using the link below:

https://on.unity.com/vscode

lilac ocean
#

i followed the steps

#

its not showing any errors tho in vscode

tame jolt
#

how should i add a momentum system while using character controller

eager spindle
#

momentum?

#

like the player walks for a while and takes time to stop?

#

you can access characterController's velocity, such that when input keys are released you can keep moving the player based on velocity

flint python
#

How can i get the correct x,y of the rotated triangle?

slender nymph
#

transform.TransformPoint

#

and pass in the local position of (0, t)

limber robin
#

I’m pretty new to Unity/c# and every time I try to make a simple game, I get stuck for hours trying to figure out why my code doesn’t work, often to no avail. Is it better to just abandon my work and start over, or try to stick it out even when feeling totally lost and helpless?

raw token
eager spindle
eager spindle
raw token
limber robin
#

Okay thanks. I guess I’ll post one of my questions here in case someone knows: For some reason when I run my game and click the mouse button, my objects’ gravity scale changes. I used to have a code that did that so I disabled the code, removed the script component, and then even deleted the code, none of which worked. This wasn’t a problem until I changed my GameObject into a prefab, does that have anything to do with it?

languid spire
stuck palm
#

these replay files are massive man is there any way i can compress them at all?

raw token
#

Apply compression :P

stuck palm
#

how can i do that?

raw token
#

I'm not entirely sure - I'm looking into it now, out of curiousity. But it would seem reasonable to me to zip/gzip/7zip them

stuck palm
#

28mb per replay is wild

#

thats with like 4 people for a 6 minute match

#

just a bunch of input data

rich adder
#

Anotber reson saving binary data is better suited. filesize should be a lot smaller

steep rose
#

this code gives me my speed at which my rigidbody is moving, is there any way to split this in 2 to check what speed my forward/backward, left/right speeds are?

        var vel = rb.velocity;      //to get a Vector3 representation of the velocity
        speed = vel.magnitude;
slender nymph
#

each axis is already the speed it is moving along that axis

steep rose
#

that works but i need it to not go in the negatives

slender nymph
#

then get its absolute value

steep rose
#

can i find that by using mathF.abs()?

#

yup that works ty guys 👍

sharp abyss
#

any ideas for how can I make my ragdoll take steps manually and make walking a little bit a skill issue in my game?

sharp abyss
#

I already have an active ragdoll

#

I am trying to do something like the game steppy pants

rich adder
#

I'm sure there are videos/ instructions on getting motion

sharp abyss
#

I'll take a look

steep rose
#

!code

eternal falconBOT
sharp abyss
#

is there a way to make something happen when you release getkey? because getkeyup only works when you press and instantly release.

rich adder
#

GetKeyUp works usually

#

if you mean you want some actions to happen across time after release, then enable a bool, put it update if statement

sharp abyss
#

sorry it works

#

it stopped working normally thats why I asked but then I saw a line made that

lilac ocean
#

in this loop, i am running through a list of instances of the Atom class. i want to add the electrons and protons variables of all the instances of the Atom class within this list to the totalElectrons and totalProtons variables. im doing this through a foreach loop, but am getting this error

rich adder
#

nvm

lilac ocean
#

ok

rich adder
#

you need to use the instance

#

since those are not static

lilac ocean
#

wym?

rich adder
#

do you know what at instance is ?

#

atom would be the instance

lilac ocean
#

yes, but how to i count up all the electrons/protons from all the instances in my list?

#

using "the instance"?

rich adder
#

if you want to add them up you use +=
oh nvm I see your doing var + var

#

share !code properly cause its hard to paste line of code to show you

eternal falconBOT
lilac ocean
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;



public class Molecule {
    public string moleculeID;
    public Molecule(string MoleculeID) {
        this.moleculeID = MoleculeID;
    }
    
    public List<Atom> atoms = null;
    public float totalAtoms = 0;
    public float totalElectrons = 0;
    public float totalProtons = 0;

    void Start() {

    }

    public void AddAtom() {

    }

    public void GetStats() {
        totalAtoms = 0;
        totalElectrons = 0;
        totalProtons = 0;

        foreach (Atom atom in atoms) {
            totalAtoms = totalAtoms + 1;
            totalElectrons = totalElectrons + Atom.electrons;
            totalProtons = totalProtons + Atom.protons;
        }
    }
}

public class Atom {
    public float protons;
    public float electrons;
    public string atomID;

    public Atom(float Protons, float Electrons, string AtomID) {
        this.protons = Protons;
        this.electrons = Electrons;
        this.atomID = AtomID;
    }
}```
eternal falconBOT
rich adder
steep rose
#

i didnt

rich adder
#

you can just tel them that they used the wrong one

rich adder
lilac ocean
#

oh i see mb

rich adder
steep rose
#

ah

#

😅

lilac ocean
rich adder
#
 foreach (Atom atom in atoms) {
            totalElectrons += atom.electrons;
            totalProtons += atom.protons;
        }
#

technically you dont need totalAtoms in the loop..

#

just count the totalatoms = atoms.Count

lilac ocean
#

alright, that isnt the problem though

#

i get this error every time i save my code

rich adder
#

paste what i wrote

lilac ocean
#

OHHH im stupid

rich adder
#

you are using the CLASS

#

thats the blueprint

lilac ocean
#

my bad

raw token
# stuck palm how can i do that?

It sounds like you would generally need to include the relevant dlls for a compression library to your project (possibly multiple libraries to support multiple target platforms), after which you could utilize whatever functionality they offer.

I see Unity also provides a com.unity.sharp-zip-lib package wrapping SharpZipLib - it looks like to compress you'd use a StreamWriter to write your JSON string to a MemoryStream, run that through one of the library's compression interfaces, and write the output stream to disk... And for decompression, I would think the same in reverse, but starting with a FileStream and the corresponding decompression method instead.

Depending on how large a replay can become, it might also be necessary to perform this work in a separate thread to avoid hanging the application 😬

It looks like there are also a number of assets available on the store which could tackle the problem.

This is all somewhat out of my wheelhouse and I reckon that I'm overlooking important things and alternatives. I lean towards navarone's suggestion of using binary serialization first. And then maybe applying compression on top of that, if necessary.

stuck palm
short hazel
#

The built-in classes in System.IO.Compression should also work in Unity

#

And for the game freezing, offload the task to another thread or use the async methods

queen adder
#

Hello I am trying to get a button to change to a bool to true then to false alternating on each click is there a way to do that

short hazel
#

Sure thing, in the button's click handler method: val = !val; where val is your bool variable you want to toggle

#

"val is now equals to the opposite value of val", which effectively toggles the value each time this line is executed

steep rose
#

this is suppose to clamp the vector right? my character accelerates fast so im limiting speed but it doesnt clamp it

                xvel = Mathf.Clamp(xvel, -maxairspeed, maxairspeed);
                rb.velocity = new Vector3(xvel, rb.velocity.y, rb.velocity.z);
#

am i doing something wrong?

queen adder
short hazel
#

Each time this line is executed

steep rose
#

yeah thats what i want

#

but it doesnt

queen adder
short hazel
#

If that line is put in the button's click function, yes

rich adder
queen adder
steep rose
#

here are the xvel values

        var xvel = rb.velocity.x;
        var zvel = rb.velocity.z;

        speedX = Mathf.Abs(xvel);
        speedZ = Mathf.Abs(zvel);

#

i dont know if its because my character accelerates to fast but that shouldnt be a problem for clamping
i dont think

queen adder
short hazel
#

Well yes, NOT false is true

short hazel
#

Scroll back up at my example

raw token
queen adder
rich adder
#

like SRP2 said above so it would be isPanelShown = !isPanelShown

steep rose
#

i have a public float telling me what my x and z movement is in an absolute value, so yes i can verify its going over limit. It could be my acceleration

queen adder
steep rose
#

it actually may be clamping

#

give me a minute

lilac finch
#

Hello Together!
For the past year, I have been learning C# because I was curious about how real programming is, and I really like it. So, I thought about learning Unity so I could maybe live my dream of becoming a small indie developer. I started watching tutorials and noticed that the guy in the tutorial had a list with the methods he was typing. I didn’t have such a list, so I would love to know if someone knows if this is a setting or a plugin. To understand what I mean, I will send a picture with the list.
Thanks!

queen adder
#

yep that was it now it disapears on click and comes back thank you!

raw token
eternal falconBOT
lilac finch
steep rose
#

ah it seems to be clamping it just looks funky because of my rigidbody acceleration.

eternal falconBOT
native hill
#

ill send a video

desert temple
#

I've got an object I want to look at a target, but it will not work, so I'm trying to see what the matter is. Here's the code:

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

public class lookAtPlayerBlank : MonoBehaviour
{
    //Variable for our look at target
    public GameObject player;
    // Update is called once per frame
    private void OnTriggerStay(Collider other)
    {
        // Tell gameobject to look at the target.
        if (other.gameObject.CompareTag("Player"))
        {
            transform.LookAt(player.transform);
        }
    }
}```
worthy dome
#

Hello, can you send me a code to open and close the door in my Unity game by pressing the E key?

rich adder
rich adder
#

btw if other is player you don't need the player since its already inside other if tag is found

#

transform.LookAt(other.transform)

merry spade
#

https://paste.ofcode.org/t2p2TwhT54VW8gEBVt22r6
Iam trying to check whether the fillings in the cocktailglass are what they should be in the recipe
I printed out the fillings that are currently in the glass with: "Key-Filling: " ...
Then it goes over every ingredient in the recipe and checks if the ingredient is even existing in the glass fillings
if yes it goes over to the else statement and checks if the filling is in a 0.1 range

But in the console output It instantly returns false it prints(no such ingredient in recipe) but it definitely is as printed with key-filling and key-recipe

I hope smb can help me, I would be really grateful

short hazel
# merry spade https://paste.ofcode.org/t2p2TwhT54VW8gEBVt22r6 Iam trying to check whether the ...

It's probably due to the fact that ingredients in one dictionary aren't the "same" as ingredients in the other dictionary. See, when you create objects with new, a new space in memory is made to contain it. You might have two ingredients with name "WATER", but they're not at the same place in memory so they're deemed different, that's most likely why it's not found in the dictionaries.
Can you post the definition of the IngredientTags class here?

#

To make sure my theory actually holds

stuck palm
#

how can i draw custom shapes with debug?

#

like a custom concave shape or somethong using coordinates

merry spade
native hill
#

could someone help me?

rich adder
native hill
#

ive tried freezing rotations but it doesnt work

verbal dome
#

Multiple Handles.DrawAAConvexPolygon for a convex shape

desert temple
short hazel
# merry spade But how do I fix it then? I have no idea

Make that class implement the IEquatable<IngredientTags> interface. That will force you to implement a custom Equals and GetHashCode method, in which you can provide your own logic to determine whether two IngredientTags are considered the same (maybe by comparing their Ingredient property?). Once you do that, the Dictionary will recognize that you implemented this interface, and should start using it.

verbal dome
stuck palm
verbal dome
#

Handles.DrawAAPolyLine/DrawPolyLine lets you draw multiple lines at once

stuck palm
#

i see

#

i was just trying to draw a 2d shape for a custom fixed point number collider im making

verbal dome
#

Bunch of lines would be easiest then

merry spade
stuck palm
verbal dome
#

Sure, or just DrawPolyLine like I said

short hazel
stuck palm
merry spade
raw token
# native hill im having trouble with this

On a subjective note, I find myself substantially less inclined to assist someone who presents themselves as "dick rider." You might find that more people are willing to help if you choose a less vulgar nickname for this space.

It's not clear how the objects in your video relate to the code you posted. It's also not clear what the "grapple state" of the player is within the video. Capturing the video directly on your computer instead of with a phone is also nice - not only is it easier to watch, but we could see additional context such as your hierarchy, and console messages which might have been logged.

native hill
desert temple
#

Alright, had to makie an edit, but I'm trying to make it so my script ensures that a projectile is shot out of the given gameObject at the right trigger, which is a player entering. Anything I need to do or add?

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

public class LaunchProjectile : MonoBehaviour
{
    public GameObject projectile;
    public GameObject player;
    public float launchVelocity = 700f;

    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.CompareTag("Player"))
        {
            GameObject ball = Instantiate(projectile, transform.position, transform.rotation);
            ball.GetComponent<Rigidbody>().AddRelativeForce(new Vector3(0, launchVelocity, 0));                               
        }
    }
}
native hill
#

I only think it’s related because when I started writing it that’s when everything got glitchy

raw token
raw token
native hill
desert temple
raw token
native hill
#

I can send my components too

raw token
# native hill sorry that took a while

That is some nutty shaking... I don't think that this script is responsible however, as it happens without the grapple joint, and the script really doesn't perform any work outside of creating/destroying the joint

native hill
#

oh okay

#

i think ill try changing the movement script to something more advanced and see if that fixes it

tame jolt
#

how do i make a variable increase slowly
like not instantly

raw token
#

Like a float?

ionic needle
tame jolt
#

oohhh

#

i see

rich adder
#

easily googleable btw

tame jolt
warm condor
#

Hey, can someone explain to me why I am getting this error?

thorn lake
#
public Room GetRoomScriptAt(Vector2Int index)
{
    GameObject roomObject = roomObjects.Find(r => r.GetComponent<Room>().RoomIndex==index);
    if(roomObject !=null)
        return roomObject.GetComponent<Room>();
    return null;
}

I need some help breaking down the Find function here.

I'm looking at the webpage that describes how Find() works but I'm not sure what the "r => r" portion means. A "Lambda expression...?"

Find seems like some search function that returns a match but I'm not sure how to interpret the function's input here

raw token
warm condor
eternal needle
#

look at the spelling

desert temple
raw token
eternal needle
warm condor
# eternal needle look at the spelling

oh hahaha. I did not even notice that. But I am still getting errors here even after changing everything. Is it because I has to actually add them in the class or is there something else going on here?

raw token
# desert temple I set it on isTrigger, but it didn't make anything happen.

From your screenshot, it looks like your collider is on the tip of that red thing. If that's correct, it seems like maybe it's kind of high - does the player really hit it clear up there?

You might want to throw a Debug.Log("Hit!"); at the top of your OnTriggerEnter() method, just to help narrow down the space in which the problem might be.

raw token
warm condor
desert temple
#

That was exactly the problem.

stuck palm
#

can you serialise a property?

slender nymph
#

unity cannot serialize properties, but it can serialize the backing field. if you are using an auto property you can target its backing field for an attribute using field: otherwise. a full property has an explicit backing field so you'd just serialize that

#

note that the auto property cannot be readonly otherwise the generated backing field will be readonly as well which cannot be serialized

steep rose
#

so this is some code to calulate speed on the x axis but can i change that to be local right/left or forward/backward?

    IEnumerator CalcVelocity()
    {
        while (Application.isPlaying)
        {
            // Position at frame start
            Vector3 prevPos = new Vector3(transform.position.x, 0, 0);
            // Wait till it the end of the frame
            yield return new WaitForEndOfFrame();
            // Calculate velocity: Velocity = DeltaPosition / DeltaTime
            Vector3 currVel = (new Vector3(transform.position.x, 0, 0) - prevPos) / Time.deltaTime;
            Newspeed = currVel.magnitude;
        }
    }
merry shore
#

How do I make a variable that contains an object component?

verbal dome
#

Maybe you want the Component type. But that is kind of unusua - what are you actually trying to do?

steep rose
#

public GameObject Obj;?

merry shore
verbal dome
#

If you want a copy of it then do a Vector3 field

#

If you want it to stay updated then reference a Transform instead, and access its position when you want

merry shore
#

Ok, thanks.

bitter sage
#

Not sure if this is the place, but I've been getting a ton of trouble with WebGL in Unity 2021.3.8f1. All the way until this recent project webGL was able to export flawlessly. Now it can't. Not sure why.

Tried uninstalling and reinstalling the package. Leaving compression methods to disable, deformation fallback and minimalized stripping Here is the usual errors when I try :

#

Also can't export an empty project. Not just the project I'm working on.

ionic zephyr
#

How can I check if a SO that heritates from an abstract class has that component (the own, not the abstract)?

rich adder
ionic zephyr
#

but I can only access the mother class

rich adder
ionic zephyr
#

thTempVar?

ionic zephyr
rich adder
#

if mySO (original abstact) is Something (the childclass SO)

ionic zephyr
#

can you put me an example?

rich adder
ionic zephyr
#

yeah, that´s it

rich adder
#

and you want to know if the SO is Human?

ionic zephyr
#

yes

rich adder
#
public class SomeContainerClass : MonoBehaviour{
    public void SomeMethod(Animal animal)
    {
        if(animal is Human human)
        {
            // do something with human var
        }
    }
}```
steep rose
#

how would i get a local position?

rich adder
#

literally first result

rich adder
ionic zephyr
#

it is really intuitive

zealous widget
#

can someone help me install unity

#

its stuck on validating and Its driving me crazy

rich adder
#

not a code question though

zealous widget
#

direct me to the proper channel then please

steep rose
#

new Vector3(transform.localPosition.x, 0, 0) doesnt give me local x position?

steep rose
#

how do i know? what

rich adder
steep rose
#

im testing it and its not giving me local position

#

its giving me global

rich adder
nova swift
steep rose
#

fixing

nova swift
#

Newbie question here:

Should you update a time based boolean that affect physics in update or fixed update?

For example, say you have a timer, and when timer > 0.5f, timerCondition = true. If timerCondition = true, say the physics would change, like the player's speed doubling or a force being applied. Should the timer > 0.5f condition be in Update() or FixedUpdate()? Im inclined to say FixedUpdate as that would seemingly make it deterministic?

rich adder
#

update

#

do the forces in fixedupdate, unless its Impulse that is fine in Update or 1 frame event

nova swift
rich adder
nova swift
# rich adder what does deterministic have to do with a bool

What I mean is like, the physics in my game aren't determistic. Unless that's Unity normally, Im led to believe the reason it's not deterministic is because of frame dependencies, and playing at 5fps compared to 60fps would have the boolean set to true at different intervals in between fixed update?

rich adder
mint remnant
#

I doubt there are any deterministic physics engines out there

nova swift
#

Those are fair points

rich adder
#

pretty sure ECS one has deterministic package

#

don't quote me on it

nova swift
#

I do have a final question tho, would I be in correct in saying the following:

timer += Time.deltaTime

At 1 fps, it takes the timer 1 second to pass 0.5
At 2 fps, it takes the timer 0.5 seconds to pass 0.5

If I conduct a check if it has passed 0.5, wouldnt the check return true a frame earlier, impacting FixedUpdate?

mint remnant
#

you kinda don't want them to be either, imagine dropping a ball on another and it always falling hte same way

rich adder
nova swift
rich adder
thorn lake
#

How does one reference variables from other scripts without making those variables changeable? Do I have to make them public?

nova swift
#

If by changeable you meaning them being in the inspector, you can do it still

rich adder
nova swift
#

You need them to be public to access them from elsewhere

#

but if you put [HideInInspector] before the public or private bit it wont show up in the inspector

thorn lake
mint remnant
#

set readonly

nova swift
#

My bad then

thorn lake
rich adder
#

making them public and hide in inspector is such cringe when i see it

eternal needle
rich adder
#

almost always opt in for props when I need something public

#

not a fan of pub fields

thorn lake
#

"props?"

teal viper
rich adder
#

properties

thorn lake
#

hmm, I still need to learn about what those are then

rich adder
#

they are just fancy methods , look into them they're extremely useful

nova swift
nova swift
rich adder
teal viper
eternal needle
#

And if its single player, you simply wont have players if its running at 5fps

nova swift
#

Fair enough, thanks for tips yall

thorn lake
teal viper
rich adder
#

just gotta get used it

eternal needle
#

c# and c++ are written pretty similarly. if anything python is the unique one

thorn lake
rich adder
#

yeah not a fan of python due to its syntax

#

fr I get lost without brackets kinda joking but not

mint remnant
#

you have to be sadistic to enjoy memory management lol

eternal needle
#

well in most cases you dont use c/c++ because you want to

rich adder
#

C# the C++ relax mode UnityChanLOL

teal viper
thorn lake
rich adder
#

doesnt C++ have getter and setter?

nova swift
rich adder
#

python has properties iirc

thorn lake
#

wait a vector is just a one-dimensional array? That's it?

eternal needle
#

no

rich adder
#

its just 3 floats

#

in a struct

#

oh you mean a vector in general in math

thorn lake
#

what no, I mean i programming

#

I know what it is in math

teal viper
rich adder
#

oh c++ vector

gentle bison
mint remnant
#

c++ doesn't even have lists, it's in the STL added in

thorn lake
#

Dang. Well a list and a one-dimensional array are like....synonomous to me rn so I think I need to do a big refesher

eternal needle
thorn lake
#

since c++ is my coding foundation

rich adder
#

isnt that basically how vector database work?

thorn lake
#

idk, they're all still synonomous to me atm lol

#

list, vector, one-dimensional array...

rich adder
#

i think vector storage stores 1 or 2 demenisonal array

#

for like LLMS n whatnot

teal viper
#

No. C++ vector from std library is basically the same thing as a List in C#.

rich adder
#

ahh ok

thorn lake
#

This conversation is making me feel like I need to go back to college

rich adder
#

college what that?

teal viper
#

You don't need college to learn properly. The documentation is publicly open and free

rich adder
#

just need 🍕 🧠 ⌛

steep rose
#

i tried to draw a cube in c++ and it fried my brain, very cool

#

but fun

rich adder
#

i had to learn(some) C++ to mod source ended up stumbling on unity to have more flexibility and c# seemed easier

steep rose
#

c# is easier 😅

#

c++ is faster though

rich adder
#

childs play in comparison

steep rose
#

i have a c++ book but ive never used it

#

dunno why

rich adder
#

we should probably steer back to unity c# coding qs 😛

thorn lake
queen adder
#

can someone help me with this error message?

teal viper
steep rose
rich adder
#

this might not be a code problem

thorn lake
rich adder
#

Library cache is usually somehing else going wrong

steep rose
#

oh

queen adder
steep rose
#

i didnt notice that

#

ask in @unity-talk

teal viper
rich adder
queen adder
rich adder
#

Assets menu

steep rose
rich adder
#

cause its hashtags

steep rose
#

ok

#

oh

#

yeah

#

so i tried the local position but it didnt work out due to it being the parent, can i convert the position to local position?

    IEnumerator CalcVelocity()
    {
        while (Application.isPlaying)
        {
            // Position at frame start
            Vector3 prevPos = new Vector3(transform.position.x, 0, 0);
            // Wait till it the end of the frame
            yield return new WaitForEndOfFrame();
            // Calculate velocity: Velocity = DeltaPosition / DeltaTime
            Vector3 currVel = (new Vector3(transform.position.x, 0, 0) - prevPos) / Time.deltaTime;
            Newspeed = currVel.magnitude;
        }
    }
eternal needle
steep rose
#

scroll up

eternal needle
#

and what does the local position have to do with any of this

#

ask your question in a complete message or at least link the context, im not scrolling through a ton of messages to find it

rich adder
#

why do you need local position if its not parented ?

#

that makes not much sense

#

if you need the difference get the two world? still same distance no?

steep rose
#

then it will say the Z axis is 8 meters a second

#

instead of X

rich adder
#

cant you just get the velocity then count a second and compare the two ?

eternal needle
#

still none of what you're saying makes sense, itd probably be a lot easier if you just got the velocity from whatever script is actually moving the object

rich adder
#

velocity is in m/per second anyway no?

steep rose
#

it is in the same script

eternal needle
#

then why do you need to read its position, you have a script which moves the object so the script knows how far its moving the object

steep rose
steep rose
rich adder
#

well in unity 3D its always in meters per second
1 unity unit = 1 meter

steep rose
#

alr ty

rich adder
#

they tried matching real life, thats how vel is calculated

eternal needle
# steep rose i can use rb.velocity but the same problem persists

🤷‍♂️ you still really havent clearly said what the problem even is. "didnt work" and the stuff above is all without actual context. Rotating your character has nothing to do with its position unless you're rotating some parent object with a child object that isnt centered

#

the rb velocity gives exactly what its velocity is. If you think its wrong, then you're likely doing something wrong elsewhere

rich adder
#

yes rb velocity is doing what ur doing (currentPos - prevPos )

steep rose
leaden lake
#

Hello.
Trying to create a mouse mov, but don't understand what is wrong!

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

public class NewBehaviourScript : MonoBehaviour
{
    
    [SefializeField] Transform PlayerCamera = null;
    
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update() {
        void UpdateMouseLook();
    }
    
    void UpdateMouseLook(){
        Vector2 mouseDelta = new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y"));
    }

}
#

And the field don't appear

steep rose
#

the names are different?

leaden lake
#

What names?

eternal needle
#

configure your !ide

eternal falconBOT
steep rose
#

you are showing a Player Controller script but the name in the script you posted is NewBehaviourScript

rich adder
#

I think new unity doesn't care now does it?

#

i think this is the issue
void Update() {
void UpdateMouseLook();
}

#

declaring a method without a body

eternal needle
#

theres more than that

#

SefializeField

steep rose
#

unity screams at me if my names are not correct

rich adder
#

im blind

rich adder
#

although I still keep them consistent

steep rose
#

i have zero clue what unity version im using 😂

leaden lake
#

'0'

merry shore
#

Whats the best free unity C# course ya'll know of?

rich adder
#

seriali zad?

merry shore
#

cool

steep rose
#

this should convert global to local will it not?

            Vector3 currVel = (new Vector3(transform.localPosition.x, 0, 0) - prevPos) / Time.deltaTime;
            Vector3 locVel = transform.InverseTransformDirection(currVel);
            Newspeed = locVel.z;
#

mb

rich adder
#

i dont understand why not just grab it from rb then transform direction that? what reason ur manually checking vel

wintry quarry
steep rose
#

i didnt post it correctly

#

mb

wintry quarry
#

Also it's unclear what prevPos is or why you're taking localPosition.x

wintry quarry
#

It doesn't make much sense

steep rose
#
    IEnumerator CalcVelocity()
    {
        while (Application.isPlaying)
        {
            // Position at frame start
            Vector3 prevPos = new Vector3(transform.position.x, 0, 0);
            // Wait till it the end of the frame
            yield return new WaitForEndOfFrame();
            // Calculate velocity: Velocity = DeltaPosition / DeltaTime
            Vector3 currVel = (new Vector3(transform.position.x, 0, 0) - prevPos) / Time.deltaTime;
            Vector3 locVel = transform.InverseTransformDirection(currVel);
            Newspeed = locVel.x;
        }
    }
wintry quarry
#

transform.localPosition is a position in the parent's local space.
InverseTransformDirection converts a direction in world space into the local space of the object itself.

In short, no this doesn't make sense

steep rose
#

the script is on the parent obj so it converts it back to global position, lemmie fix it

steep rose
eternal needle
#

you probably just think it should be something else, but again everything you've written is too vague and you arent describing the actual issue. Nothing more can really be said

leaden lake
frosty hound
#

Nope

#

Use visual studio, which you can install from Unity Hub

steep rose
leaden lake
#

There is no place to install VS using Unity Hub!

frosty hound
#

Yes there is

#

Why would we suggest it otherwise?

leaden lake
#

Where?

frosty hound
#

Click the gear, add modules, install Visual studio.

eternal needle
frosty hound
#

Does that say Visual Studio?

steep rose
#

bro im debugging as we speak, im still getting the same results, unity is telling me the rb.velocity and the LocVel and they are exactly the same from what the float is saying.

leaden lake
#

ah.. ok.. this thing just download the installer, but don't install it

steep rose
#

i know how to debug

eternal needle
steep rose
#

can i send a video?

#

or only pictures

#

if i can send video i need to reinstall the recorder app i had

leaden lake
eternal needle
# steep rose can i send a video?

🙄 so you arent gonna show the debug lines?
Im just gonna point out that the #854851968446365696 says

Don't
Directly give answers to users who will not troubleshoot.

and im truly not gonna beg you to answer what ive been asking. Someone else can help you

steep rose
frosty hound
steep rose
#

they constantly update so a picture wont give a lot

frosty hound
leaden lake
eternal needle
# steep rose i never said i wasnt gonna show debug lines, all i asked if i can either send a ...

the lines of code is what i meant. the last thing ill say about this is if your global and local direction are the same then that implies your object is at the default rotation.
You can show a video, but still it wont really answer what ive been asking the whole time. What the actual issue is. Because youve said lately is the vector is still global, which is what you assume and not even true to begin with

frosty hound
#

This isn't visual studio, this is visual studio code which is not what is installed from Unity Hub.

#

So not sure how you got here, but either way, it counts as one of the programs you can use for Unity. Just make sure you configure it !ide

eternal falconBOT
leaden lake
bold plover
leaden lake
#

Don't know what I did wrong if the Unity Download it.

teal viper
# steep rose

What's the issue? The local velocity would be the same as a global velocity if your object is not rotated.

leaden lake
#

Maybe it works. .

steep rose
#

i showed it in the video and a a little above the video

teal viper
#

Local and global would be the same if the object is not rotated

steep rose
#

local should be local to where to object is facing, it should not be global. thats why i did inversedirection on it

leaden lake
#

I'm on the right place?

steep rose
#

so the local velocity isnt local, its global velocity

steep rose
teal viper
leaden lake
steep rose
#

thats what global is for

teal viper
#

If it's orientation matches the world orientation, then global is the same as local

#

makes sense?

leaden lake
#

Thanks @frosty hound!
You gimme the right means to solve this! +1

steep rose
bold plover
#

So if I were making reference to the current player state as the CurrentPlayerState in the main player script, would that suffice for having said state data from said state be sent the main one? That's worded poorly. But basically.

#

Info from this.

#

Is sent here.

#

And I make reference to say the acceleration in current state as the value to use for my player's speed calc in the main script?

#

Trying to avoid using a bunch of bools and losing track of everything in the process.

raw token
# bold plover Trying to avoid using a bunch of bools and losing track of everything in the pro...

You could always access like baseAcceleration in the "main script" from a reference to your state machine like playerStateMachine.CurrentPlayerState.baseAcceleration, sure.

But if you're saying you want to store a reference to the state machine's CurrentPlayerState in like a field and just always try and get the current value from that, that might not, as when CurrentPlayerState changes in the state machine, the field in the "main script" would still be referencing the whatever state the field was initialized with.

bold plover
#

Ok. I'll stick with the former to avoid any issues then.

#

Thank you. Felt like I was overthinking it and potentially adding a middle man that would cause problems. I'll just reference it with the playerStateMachine.CurrentPlayerState.baseAcceleration.

devout flower
#

Can someone explain a specific case where singletons can mess things up? I’ve looked at articles, but they give very general and hypothetical examples

raw token
raw token
devout flower
#

Ohhh ok, so it’s the development proccess

eternal needle
# devout flower Can someone explain a specific case where singletons can mess things up? I’ve lo...

all the examples will be hypothetical, until you make one and then realize its messed things up. "mess things up" is also kinda vague, like if we're talking about actual logic issues then that could be "i made my player a singleton so enemies could find him. now i want the player to have an ally that can be targetted!" Basically i had one now I want 2.
Other issues people bring up is more with like industry code where you are testing. I found it mostly doesnt really apply in indie game dev

devout flower
#

Oh i see i see

#

Yeah, the two players example was the only one i saw mentioned

eternal needle
#

One annoying thing also is having singletons that u have to create in every scene, but this part is somewhat tedious to have an alternative. Like if a script creates a bunch of stuff at the start of loading a scene, and you need to call a function for it to run, then you have to find the script somehow. Or take the script out of the scene and associate a scene to this function elsewhere

devout flower
#

Ah i see

#

I’m fine since i never use more than one scene 😂 (I probably should but i never felt the need to so far)

queen adder
# rich adder Try doing a Reimport all

it doesnt work i tried making a new project and it says it insalled all pakages but now the error is happening tto all of them wont let me boot it up without going into safe mode

#

it told me to run unity with tempmemoryleakvalidation so i did but i dont know what to do next

teal viper
# queen adder

First of all, you can get rid of the test related errors, by removing the tests package.

#

Unless you're using unit tests in your project

queen adder
void thicket
queen adder
#

should i upgrade to a different version? i was using this one because a friend was using it

void thicket
#

Otherwise at lease use the most recent fix version 2023.2.20f1

queen adder
#

ok ill try this

void thicket
queen adder
#

yes im using version control, how do i back it up?

void thicket
safe radish
#

is there a way i can check if 2 shapes on a 3d grid are touching eachother without iterating over each cell in each direction?

eternal needle
#

you could always use the bounds to see if they overlap but if the shape itself is completely unique then the bounds might not be entirely accurate

safe radish
safe radish
rotund forum
#

Nevermind I am a fool I used the wrong namespace

#

😅

#

Will delete this

eternal needle
safe radish
#

also could be checking between multiple shapes

eternal needle
safe radish
eternal needle
#

Which is pretty similar to your initial question, of iterating over every cell but im not fully sure what you're trying to do with iterating in each direction if you just need to know what's touching

safe radish
#

by touching i meant that they could be occupying neighbouring positions. with overlap that would be both occupying the same position

queen adder
tiny rain
#

Hi guys, I'm not quite sure how I'm meant to hash a Vector2Int into unique values, how are you supposed to combine the x and y axis into a number that isn't recurring accross the map in any way?

x+y would mean that diagonal lines would have the same output...
x+y*... will only modify the way it repeats by squashing it down?
x+y%... will just make it trunciate across y...?

void thicket
#

Unity Hub should have it

queen adder
#

oh

void thicket
#

Oh you checked to install VS

queen adder
#

now it says complete

#

thats weird

void thicket
#

Oh it’s just hashing then it doesn’t need to be unique

#

Hashes can’t be unique

eternal needle
#

With checking every adjacent cell

queen adder
tiny rain
eternal needle
eternal needle
tiny rain
eternal needle
#

i dont really know what a decorator is in this case, but could you not just store this by some ID? What would hashing a Vector2Int even do for you here?

tiny rain
void thicket
# queen adder

Yeah that sounds like downgrading issue, you probably want to modify some package.json :/

void thicket
tiny rain
#

I intend to generate a rng instead as in that case I don't need to save anything

eternal needle
tiny rain
#

Seriously I think that not even terraria saves the rng for each tile

void thicket
#

"hash" is meant to be non-unique

teal viper
eternal needle
#

4mb is a waste? dear lord

teal viper
#

Depends on what you need it for

void thicket
queen adder
tiny rain
eternal needle
#

i dont think you know what hashing is

void thicket
#

Hash is not compression

tiny rain
#

With same output from the same input each time?

#

So what I want is a random number for each tile, but to be able to get that same number whenever I load the tile

void thicket
eternal needle
# tiny rain Storing 1000000 integers is kinda absurd '^^

and also, this seemingly came out of nowhere. Either way you're gonna need to save the same amount of data. Again, what is this Vector2Int and why are you hashing it? What is a decorator, can you not just give it a specific ID and save that ID?

teal viper
tiny rain
void thicket
#

Hashing is making your variable, of any size, to fit in certain size
It does not guarantee uniqueness, you cannot recover original value from it

teal viper
#

But you can't get that seed after the generation

#

Or have manual control over it

tiny rain
#

I seriously thought that it's called hash functions tho?

eternal needle
teal viper
tiny rain
teal viper
tiny rain
#

All three values are meant to generate a rng that doesn't show some visibly repetitive/incrementing patterns

eternal needle
#

notlikethis theres no way you need a random number here if you're trying to store information about what was generated

teal viper
tiny rain
teal viper
#

For example, you could use the first 2 bytes of the int for the random number and the 3d and 4th for the x and y positions

eternal needle
#

you havent even accurately said why you cant just store a single ID. You were also told that hashes cannot give you the original number back. How do you expect to use this data if you're storing a number generated with a one way function? What do you think you're actually gonna do with this number

teal viper
#

Thought, that would limit the range of tile positions that you could use

teal viper
tiny rain
eternal needle
#

if you're building to anything better than a samsung toaster, really just cut the crap and make what works simply. All of this is "i think its bad" with 0 experience in it

eternal needle
#

Whats the point of even storing this

tiny rain
teal viper
tiny rain
#

Told you that I want the same number for the same seed, x and y, without needing to store it and without them showing an obvious relation to eachother

tiny rain
#

Usually utilizing bit shifts, modulos and multiplications

eternal needle
tiny rain
tiny rain
teal viper
tiny rain
#

And reload them in runtime too, just like in minecraft

eternal needle
#

1000 x 1000 can easily all just be generated at once

tiny rain
#

You'd be adding at least 16mb per world, even if this is a small addition, it'd add up significantly when saving things unnecessariliy too often

teal viper
eternal needle
#

🤷‍♂️ what other unknown aspects am i supposed to account for? Im going purely off information you've said

sour fulcrum
#

I have an int and I'm trying to lerp it into a usable index in a list I have but something here seems to be rounding weird,

float lerpResult = Mathf.Lerp(0f, (float)(gizmosColors.Count - 1), (float)intValue);

The List is 6 in length and i'm giving it 1-8 and this always results in 6, What am I goofing up here

teal viper
#

It still saves a lot of data normally as well

sour fulcrum
#

I know I gotta turn it back into a clean int after this but this is where my issue is

tiny rain
teal viper
tiny rain
#

I assumed that hash128 is the kinda thing used for it

#

But it takes 1 input

teal viper
sour fulcrum
eternal needle
tiny rain
#

Ah, right... Um... I guess, that's why I said that maybe I could just compress them together before hashing by x + y / worldSize, or x+y*worldSize if I'm making it an integer

sour fulcrum
#

ah fuck right

#

thank you

#

i forgot third param was 0-1

teal viper
tiny rain
#

Cus y++ might give a very linear change to the value, thus making the grass pattern visibly repetitive

teal viper
#

And that being said, I'm not sure that hashes would help you with that anyways

#

Like, what exactly do you want to use them for?

tiny rain
teal viper
#

Hashes are not random numbers. They're very much deterministic and preserve patterns. In addition they are not unique and could correspond to several of the same values.

tiny rain
#

Like in minecraft where the same seed always gives the same map, that's what I'm seeking

teal viper
tiny rain
tiny rain
teal viper
#

unless you're trying to write your own noise library

teal viper
raw token
#

It sounds like you might using "hash" interchangeably with like "procgen algorithm" or maybe just "pure function"

raw token
#

Same output for same input without side-effects

tiny rain
tiny rain
#

PerlinNoise is an extension on it, a hash function isn't a perlin noise itself, as it's specially programmed to make the wave effects

teal viper
#

I'd still use the dotnet one, as you don't need to reset the state every time.

tiny rain
# teal viper Also, you can do it with unity random as well <https://docs.unity3d.com/ScriptRe...

I'm pretty sure that setting the seed for each position in that UnityEngine.Random's case would do something like what happened in this video... Can't tell for sure
https://www.youtube.com/watch?v=ZZY9YE7rZJw&t=1688s

In this video I look at how we can manipulate randomness to generate coherent and well formed structures on demand, which allows truly vast and complex resources to be created with no effort from a designer

Source: https://github.com/OneLoneCoder/Javidx9/blob/master/PixelGameEngine/SmallerProjects/OneLoneCoder_PGE_ProcGen_Universe.cpp

Patreon:...

▶ Play video
#

At 10:35

#

They set the seed but the result is visibly not random, as it relies on jumping states to make it seem random

teal viper
tiny rain
teal viper
#

You seem to be confusing many pieces of information technology. Keep it simpler. Start simpler. Learn how random seed work and how you can have multiple random generators with different seeds.

teal viper
#

You do realise that you would need to save at least something, right??

#

at least the initial seed

tiny rain
#

These kinda functions

teal viper
#

Otherwise you would never get the same map ever again(in realistic time range)

tiny rain
#

They are deterministic, yet they don't rely on hopping states x times starting from x seed to seem random

#

And they look random

teal viper
#

Well, that's exactly what a random function does

#

It just has a different algorithm under the hood

#

in your case nLehmer is the seed

#
  • the hexadecimal at the function start
tiny rain
teal viper
#

Your algorithm would also have a visible pattern depending on what values you feed it

tiny rain
tiny rain
teal viper
#

Random wouldn't have a visible pattern either. It's white noise

tiny rain
#

Which makes it obviously repeat in diagonal strokes

tiny rain
#

That's the problem I was talking about

#

Rand relies on the previous state to generate a decent looking rng

#

Which, if you set the seed for each position, destroys the purpose of it

teal viper
#

Anyways, it seems like you already have all the answers yourself, so I don't see any point in continuing this conversation.

tiny rain
#

Rand() when fed that as seed gives diagonal strokes, while Lehmer gives a white noise

teal viper
#

Great. Then I guess you've got your answer.

#

I'd also point that srand/rand is C++, and there's absolutely no guarantee it has the same implementation as the C# Random

tiny rain
#

Yeah, that's why I mentioned that it might cause issues

#

Not that it certainly will

teal viper
#

I can't believe I spent that much time on that meaningless conversation with arguments relying on a different function from a different language in a very specific scenario...

half egret
#

C'est la vie

spare mountain
raw token
#

viva la fromage

eager spindle
half egret
#

Almost definitely is

spare mountain
eager spindle
#

if its that important you might as well make a backend server that handles all this for you

eternal needle
half egret
#

The source of entropy on Unix is different than the source of entropy on Windows, and that's not even considering the hardware

pliant sleet
#

So I have certain prefabs that I spawn every several seconds and I want them to be destroyed when they're out of bounds. The problem is that when I try using a separate gameobject to destroy everything it touches it simply doesn't work. I have also tried destroying that prefab after 5 seconds but it still doesn't work. Any suggestions ?

eager spindle
pliant sleet
eternal needle
pliant sleet
#

because i am making a 2d game

eager spindle
#

could you add a Rigidbody2D, with Kinematic on?

#

to the trigger

#

one of the objects on this needs rigidbody

pliant sleet
tiny rain
#

In my point of view y'all seemed confused, I think that it was a communication issue instead

eternal needle
half egret
#

If several people are misunderstanding your question, maybe the other people aren't the problem as a note.

eager spindle
#

an object with a collider but no rigidbody is not expected to move. thus the physics engine will not take that into account

tiny rain
eternal needle
pliant sleet
#

that is all the code for the gameobject that is supposed to destroy the prefabs

#

i have also set the isTrigger

#

on

tiny rain
tiny rain
#

Only going off track to explain what I needed it for

pliant sleet
#

thank you so much

#

but why does the trigger need a rigidbody ?

eager spindle
#

look into how physics engines work too

#

making one is fun

pliant sleet
#

I will

#

because I barely understood that

eager spindle
#

unity uses nvidia physx, a physics engine that uses your GPU

eternal needle
#

you also might wanna consider having the rb's on the moving objects rather than the destruction area

#

unless you want it to destroy truly everything that comes into contact, and not just those select objects

pliant sleet
#

nah, truly everything, because only the prefabs that are moving can touch that trigger

#

Thank you for the advice

#

on 3D games it doesn't work like that

eager spindle
#

oh it works the same way in 3d actually

#

one object needs a rigidbody for the trigger to work

pliant sleet
#

then it's just on me because I didn't take that into account

topaz mortar
#

For some reason every time my code throws an error, it sets the Scale of the items the next time I start the game to 0
When I set the scale back to 1 in play mode and exit without error, the items load properly the next time
But every time I have an error, it will set all items that were in the hierarchy the previous play to 0 scale the next time it runs
Even though all items are Instantiated in code from a prefab, the prefab scale is set to 1 and my code does not touch scale

#

So none of these items are in my Hierarchy while in edit mode, they are created while in play mode

eager spindle
#

Some values driven by VerticalLayoutGroup

tiny rain
#

Whelp, guys, after testing, yep, there're you go, exactly what I meant

  1. UnityEngine.Random will show a very consistent pattern when seeded with (x << 16 | y)
  2. System.Random is repetitive too, except in another pattern
#

However, to prove the other part of what I was saying, this is what Lehmer does, with the exact same input:

#

I'm just telling this only as a final statement to prove my points correct honestly, else I wouldn't've even bothered

#

I was only hoping to find a built-in, which I suspected to be hash128, else I'd be using Lehmer

topaz mortar
eager spindle
#

ok ill spoonfeed a little but your parent object has a verticallayoutgroup

#

you'll need to play around with the values a bit

#

also see the Layout Element component which gives you control over what happens in a layout group

topaz mortar
#

not sure what I should change to make it stop setting my child scale to 0?

eager spindle
#

remove control child size

#

and put a layout element component on your child

teal viper
tiny rain
#

They're using it the exact same way

#

And this is exactly what I was asking for- Converting a position into a psuedo random number, without them showing an obvious pattern

#

Both Dotnet and Unity's random doesn't cut it, likely made to be faster but with this weakness

teal viper
tiny rain
#

If you used that to try get the rng it'd give at a position, you'd either need to generate till the xth rng from the same starting seed

#

Or set the seed to a number made with the position, but that fails to look random

teal viper
tiny rain
#

However, the wavy look comes at a cost, which isn't worth it for this purpose

#

That's why, there need to be another algorithm to generate a rng from an x and y value, one that doesn't perform such redundant operations

#

That's where Lehmer comes in, I knew that I could use it, but I wanted to see if I could get away not writing custom noise functions

#

Sorry that it's a waste of time after all, I guess, thanks for trying 😂

eternal needle
#

Anyways isnt noise just a hash function?

tiny rain
slender nymph
#

you should show your actual implementation to ensure there were no flaws in it

tiny rain
#

Also, no, not all noises are just a simple hash function

#

Perlin noise have some sort of lerping between points, those hills

#

Voronoi noises, despite being able to use hash to determine the position of the points, still need extra checks to know the value in between

eternal needle
eternal needle
tiny rain
#

While I said that I wanted the same rng for the same x y, without storing the value

#

Please, I don't know why y'all keep thinking that there was another way or whatever stuff I was saying, can't we just stop talking gibberish over stuff that's already done?

eternal needle
eternal needle
#

This kind of talk genuinely has beginners think it has flaws and they try to go find other methods when it's perfectly fine to use

tiny rain
#

And I didn't start about those two tools in the first place, okay?

tiny rain
slender nymph
#

so for every position you initialize the random instances with a new seed? that is literally the definition of using them wrong

tiny rain
#

And I didn't even think of using them before, it was on dlich's suggestion

slender nymph
tiny rain
#

To me it was already unlikely a good idea

tiny rain
slender nymph
#

you can't reasonably expect actually random numbers if you just feed it similar numbers as the seed every single time you get a new number

tiny rain
#

Try writing me a function that takes in x and y, and gives the same output consistently for the same x and y values, while looking random

tiny rain
teal viper
slender nymph
#

"guys, i'm going to misuse these random number generators then complain when they don't look as random because i am consistently misusing them"

tiny rain
tiny rain
teal viper
#

I can imagine it causing visible patterns on different scales, but you do you.

tiny rain
#

So I imagine it to be quite reliable

#

There're better hash functions... But they are usually slower

eternal needle
tiny rain
eternal needle
#

can't we just stop talking gibberish over stuff that's already done
you can also stop responding, but we all know this was written as a "im the bigger person" message

tiny rain