#💻┃code-beginner

1 messages · Page 751 of 1

rich adder
#

just have them listen for a switch and pass the component from the switched vehicle

rich adder
#

events will be good here

edgy sinew
#

Deactivate current car GameObject
Move position / rotation of other car GameObject to this one
Activate other car GameObject

#

^ method that avoids any Component transfer

#

(You do have 2 copies of the same Component with this way though)

rich adder
#

I think they mean if they have scripts referencing the vehicle1 component, now if you activate object 2 they dont know not to interact with vehicle 1

hallow acorn
#

guys i think ill stop right there for today thanks for helping

rich adder
tidal lily
rich adder
spring otter
#

Is it bad practice having a class that inherits another class that inherits MonoBehavior? As in Goblin : Enemy : MonoBehavior?

rich adder
#

normal inheritance? why would it bad practice

#

its like one of the important features of the language

spring otter
#

I think I saw someone saying this here before, @grand snow I think? I'm not sure, could be fake news, sorry if it wasn't you
I think the person said that composition was better most of the time and keeping inheritance strictly to non-monobehavior classes

grand snow
#

Erm no I think inheritance with mono behaviours is fine

spring otter
#

Ah, I see, thanks and sorry for the random tag lol

rich adder
#

just know the limitations of inheritance and use it where it makes sense to do

#

some things using interfaces makes more sense , say a ITarget and so on

orchid trout
#

How do I FORCE Unity to write some data from play mode into a prefab?
I have data I can only get in play mode and I need to save it.

#

I can't just copy-paste it because its more than one field and I need to make sure the data is completely identical, no chance of floating point truncation changing it because I need reproducable data

#
        visualizer.savedBugStartPosition = buggedPacket.StartPosition;
        visualizer.savedBugEndPosition = buggedPacket.EndPosition;
        EditorUtility.SetDirty(visualizer);
        UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(visualizer.gameObject.scene);```
#

I tried this but you cant run it in play mode

grand snow
orchid trout
#

Will do

south mural
#

quick question I will create a horror game 3d built in render pipe or urp?

rich adder
#

if you look for shaders though they have to be urp compatible and not Built In

south mural
#

thanks

#

getting started

rich adder
eager stratus
#

So if I make a mesh from scratch in code is there a reason it might end up all weird and see-through like this? I know it's not the material because it doesn't do this when placed on primitives and I'm absolutely certain that I called for the normals to be recalculated. The only thing I can think of is the order of the vertices to make triangles, but I thought that only dictated what direction the face is facing. I was under the impression that triangle 2, 6, 7 would have the same normals as triangle 6, 7, 2

pliant abyss
#

2D Platformer Collision Detection

near wadi
#

beginner coding question.
I have not done much beyond the basic with InputSystem.

from a future proofing standpoint, or even just a coding one, is there any reason Not to use the Lambda over the verbose?

movementAction.performed += theInput => MovementInput = theInput.ReadValue<Vector2>();

should i use the more verbose way since perhaps i may need to add other things to the functions?

 HandleMovement(InputAction.CallbackContext theInput)
{
    MovementInput = theInput.ReadValue<Vector2>();
}

void OnEnable()
{
    movementAction.performed += HandleMovement;
}

void OnDisable()
{
    movementAction.performed -= HandleMovement;
}
tranquil forge
#

i dont think the you can deregister with the lambda

dark laurel
#

You use the verbose method because you can "unsubscribe" from it later, and the garbage collector can clean up the objects in memory when you're done with them.

If you're subscribing and not unsubscribing - that's a memory leak. How bad it is depends on how big the objects are and how many of them you make.

near wadi
#

i think another can handle it.. I may be wrong

movementAction.cancelled += theInput => MovementInput = Vector2.zero
tranquil forge
#

thats another event now

dark laurel
#

No, this creates two subscriptions

near wadi
#

cool deal, thanks, both of you. i will stick with the usual way, (verbose)

dark laurel
#

There's actually another side effect / bug, beyond just the memory leak - if you accidentally subscribe to something twice (or more) then you'll get your lambda called for each of them.

near wadi
#

Ouch! super cool. you've saved me an endless headache. thank you 🙂

finite anchor
#

hello, i am following a tutorial of unity made at the end of 2022 and i copyed this line of code and it's giving me an error

#

myRigidbody.velocity = Vector2.up * 10;

edgy sinew
finite anchor
#

oh

#

i will try it and see if it's good

edgy sinew
finite anchor
#

moving a bird up

#

InvalidOperationException: You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings.
UnityEngine.Input.GetKeyDown (UnityEngine.KeyCode key) (at <da9f38ff05704aa39409e488c3569f6d>:0)
Bird_script.Update () (at Assets/Bird_script.cs:15)
ummm...

#

i think i will try a newer tutorial

near wadi
#

just google. IDK how else to say this.

finite anchor
#

ok i try now

near wadi
#

your quickest fix is probably to set the input to Both. instructions will be in the search results

#

also, you should probably use the official Unity tutorial Pathways on the learning site.
Check out Essentials, then Junior Programmer Pathway

#

!learn

radiant voidBOT
plucky copper
finite anchor
#

oh i see

fast relic
plucky copper
#

Its going to seem confusing at first, I will not lie.

#

Most tutorials for it are really bad at explaining it.

fast relic
#

tbh the thing that made me actually understand how to use it was the official docs page

#

it explained it better than all the tutorials i watched

languid pagoda
#
        [MethodImplAttribute(MethodImplOptions.AggressiveInlining)]
        public static unsafe TDest ReinterpretCast<TSource, TDest>(TSource source)
        {
            var sourceRef = __makeref(source);
            var dest = default(TDest);
            var destRef = __makeref(dest);
            *(IntPtr*)&destRef = *(IntPtr*)&sourceRef;
            return __refvalue(destRef, TDest);
        }

how terrible is this 🤣

meager gust
#

Or just let me know which version is compatible?

blazing ruin
#

Could someone help me with visual scripting? Im new to unity. Its kinda driving me nuts watching YouTube tutorials. Theres some nodes that dont exist in my version

meager gust
#

visual scripting almost always turns into a spaghetti mess if you want to do anything serious with it

blazing ruin
zenith cypress
naive pawn
#

bro that shade of green

#

just woke up and that gave me a jumpscare lmao

sour fulcrum
#

when your programming in an unclean fish tank

tender mirage
#

anyone know why i'm getting an error here?

using UnityEditor.SearchService;
using UnityEngine;
using UnityEngine.SceneManagement;

public class GameOverUIScript : MonoBehaviour
{



    public void GameOver()
    {
        Scene CurrentScene = SceneManager.GetActiveScene();



    }

}
frail hawk
#

you need to specify which of the namespaces you want to reference when using Scene, both contain Scene, you can write your namespace infront

grand snow
#

your ide probably put it there for you by mistake

frail hawk
#

yeah i was about to say get rid of it but wasnt sure if they need it or not

tender mirage
grand snow
#

probably but also the UnityEditor namespace wont exist in builds and will cause compile errors then

#

so clearly a mistake

#

So delete! 🗑️

tender mirage
#

I have no clue why it was there to begin with lol. maybe it was the keyword static? anyways.

thanks for the help 👍

grand snow
#

VS and other ides auto add using statements when you write things so you may have selected something by mistake

turbid plover
#

!compile

radiant voidBOT
#
<:error:1413114584763596884> Command not found

There's no command called `compile

using`.
turbid plover
#

ah-

naive pawn
#

@turbid plover that isn't a feature here. what are you trying to do?

turbid plover
#

sorry

short gust
#

how to handle entering/exiting before passing trough the same trigger zone, like moving into the zone and immediately move back instead of coming trough it?
feels like a trivial problem, but I can't come up with something not very dirty, because I'm using triggers very rarely, lol.
(I'm making something like a trigger volumes for camera switch btw)

grand snow
short gust
# grand snow whats the actual issue, detecting entry/exit or something else?

I don't want to fill my rooms with the trigger colliders in every corner to enable the camera, so I want to use the zones only on entrances to the camera view angle. but, I need somehow filter "passing trough the trigger" from just "touching the trigger and move back".
like, I tried with counters and bools, but it feels a bit dirty, heh. maybe I'm overthinking it.

grand snow
short gust
keen dew
#

Often you'd have two triggers, one inside the entrance and one outside. Entering the inside trigger enables the inside camera and the outside trigger enables the outside camera

grand snow
#

If both thin I don't think it would be reliable

#

Which is why I'd just have trigger colliders to mark the areas themselves

keen dew
#

They don't need to be thin

grand snow
#

Oh like have it a tad inside the room

keen dew
#

The inside trigger can be as large as the room and the outside trigger as large as needed as long as it doesn't overlap, if it only sets the camera. It doesn't matter if you enter the same trigger again if the camera is already set

#

Like this, the blue trigger sets the inside camera and the green sets the outside camera

short gust
#

oh, yeah, sounds better than some hacky count/position shenanigans, heh.
thanks!

#

I just wanted to setup it with a single trigger to detect all fo that for no reason, heh.

grand snow
#

But what if the player is inside the green, touches the blue and exits the blue back to the green?

#

You need sufficient space so you can't enter one and still be inside another

spiral narwhal
#

How do I code a button so that it blocks the OnMouseClick event if it has been clicked?

#

See the button here registers a click, but the dots (sprites) ALSO get called on their OnMouseClick

sonic dome
#

anyone willing to hop on a vc and review my movement code?

naive pawn
#

no

#

just ask your question

#

!ask

radiant voidBOT
# naive pawn !ask

:thinking: Asking Questions

:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #🔎┃find-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.

-# For more posting guidelines, go to #🌱┃start-here

naive pawn
#

share code appropriately as well 👇

#

!code

radiant voidBOT
sonic dome
#

understood will send in a bit

iron mango
#

Hey y'all I am trying to create a boomer shooter-ish game where you go trough a lot of rooms and I have made a couple of presets for rooms in blender but I am trying to figure out how the hell I am going to make a couple rooms generate and snap them together correctly to create levels or sometimes infinit terrain. Does anybody know good articles or videos on this topic? Looks like magic to me.

fast relic
toxic radish
#

Hi, when I open up my Unity editor a black window opens along with it in full screen. It looks like a terminal but I can't type in it and it's very wierd. Is that normal behavior?

I already tried restarting and even completely reinstalling the editor from scratch. It wasn't there on the first start but after simulating once it came back. If I close it the whole editor closes too!

queen adder
#

hi. does anyone know a good place to start learning game scripting that is not on youtube? youtube videos barely let me understand the code and always leave me with no useful information. I'm not new to programming. I just don't know how to write most things related to video games like state machines, input, cameras, etc.

toxic radish
naive pawn
naive pawn
radiant voidBOT
toxic radish
naive pawn
#

did you check the cpu?

#

just in case

#

wait is ryzen the cpu

#

god i need to learn hardware sometime

toxic radish
#

Honestly no, lol. But will do! I just can't think that would be causing it

naive pawn
#

compatibility is the main concern here rather than low specs

toxic radish
#

You think it's an AMD thing?

hexed terrace
#

nope

ivory bobcat
queen adder
toxic radish
hexed terrace
#

this is a code channel, the question should really be in #💻┃unity-talk ... but your O/S isn't Windows? It's more likely an O/S compatability issue than some random h/w config

naive pawn
toxic radish
#

I'm on windows 11. The wierd thing is that the first start it works fine. Only the second start after I closed it once it happens.

naive pawn
#

but your O/S isn't Windows
is it not? there's C: and .exe

hexed terrace
queen adder
hexed terrace
toxic radish
#

That's why it's so wierd. Maybe I intalled some packages twice or wrong that are requiered and as soon as it accesses them something get's fd up?

queen adder
toxic radish
#

I did actually..

#

Tried both versions as well

naive pawn
#

6000.0 is LTS, if it were a bug that was "fixed" in 6.2 then that fix would be backported to 6000.0

naive pawn
sonic dome
#

Why does it get corrupted everytime?

using UnityEngine;

public abstract class InventoryItem : ScriptableObject { }

[CreateAssetMenu(fileName = "GunItem", menuName = "ScriptableObjects/GunItem")]
public class GunInventoryItem : InventoryItem
{
    public float fireRate = 0.2f;
    public float bulletDamage = 20f;
    public AudioClip bulletSound;
    public float range = 100f;
}

public class UtilInventoryItem : InventoryItem { }
public class SpecialInventoryItem : InventoryItem
{
    public GameObject prefab;
}

public enum ItemType
{
    Weapon,
    Special,
    Util
}
naive pawn
naive pawn
naive pawn
#

if there are multiple definitions in the file, then the reference becomes ambiguous

#

please use the "large code blocks" section below for showing large snippets of code

#

!code

radiant voidBOT
naive pawn
#

and could you be more specific as to how exactly it "isn't working"? do you get errors, does it do something weird, does it not do anything at all? etc

cosmic dagger
sonic dome
naive pawn
#

sure, it's specifically stuff that derives from ScriptableObject and MonoBehaviour (iirc) that unity enforces to be in separate files

sonic dome
#

Understood thanks

naive pawn
#

c# allows you to put multiple classes in a file (hence no compiler error) but you still shouldn't have them all in a single file for the sake of logical grouping - here, the enum directly relates to InventoryItem, so it could be in the same file as that

(though, do you need the enum at all?)

cosmic dagger
#

I would just get used to using a separate file for everything. It makes it easier to find and edit the type when needed . . .

sonic dome
#

its still corrupting

sonic dome
sonic dome
naive pawn
#

yeah it might be pointing to the old file

#

try remaking it

naive pawn
tender mirage
#

😅

#

but nah, i'm good, don't need help anymore

#

👍

hot wadi
#

For a task that runs each frame after an event (button pressed for example), is it more efficient to use coroutine or just a bool to check whether it should be running?

{
    while (transform.position.x != _currentLane)
    {
        transform.position = new Vector3(
            Mathf.MoveTowards(transform.position.x, _currentLane, Time.deltaTime * _speedChangeLane),
            transform.position.y,
            transform.position.z
        );
        yield return null;
    }
}```
or
```if(transform.position.x != _currentLane)
{
    transform.position = new Vector3(
            Mathf.MoveTowards(transform.position.x, _currentLane, Time.deltaTime * _speedChangeLane),
            transform.position.y,
            transform.position.z
    ;
}```
naive pawn
#

don't worry about efficiency

#

think about what makes sense

#

consider if it might be triggerable again while it's still going on

hot wadi
#

That is possible for both methods

naive pawn
#

i mean, do you want it to be

ivory bobcat
naive pawn
#

and how do you want to handle the logic for that

cosmic dagger
naive pawn
#

draw/plan that logic out, and implement it according to the logic

hot wadi
naive pawn
#

ooh but it might not work if it were parented

hot wadi
ivory bobcat
#

It would be similar to the bool alternative but allowing you to interchange the behavior, if necessary.

hot wadi
#

I see

#

Thanks for the help

hallow acorn
#

is it more efficient to use nested for loops to check a dictionary with a vector2Int as a key, or to use a foreach? does it make a difference?

naive pawn
#

use what makes sense

hexed terrace
#

just use .Contains ?

naive pawn
#

there is a difference if the entries of your dictionary are sparse, but in that case, it wouldn't that much sense to use a for loop anyways

hexed terrace
#

no need for a loop of a dictionary when checking if it contains a key

hallow acorn
naive pawn
#

the nested for treats it like a grid
the foreach treats it like a dictionary
if the dictionary represents a grid, there's no difference - use what makes sense for the specific task

hallow acorn
#

ahh okay that makes sense thanks

floral garden
#

hi UnityChanwow
I am currently working on the timeline of unity to make some cutscene but is there better way than just creating a empty object with the timeline on in the scene?

teal viper
floral garden
#

yeah , the organization will be really messy, how about i create a scene only for a timeline?

#

(i will get a lot of cutscene so i am searching a cleaner way to make it)

hallow acorn
#

how can i make this part of my code less heavy on the cpu and more suitable for generating in realtime? rn my fps drops from 350 to 90 as soon as a new chunk is generated. https://paste.ofcode.org/LMMSHXj3FJDEwTgBRSnLYV thanks in advance

#

(ik its prolly a complete mess)

floral garden
#

rasterizer ? UnityChanThink

teal viper
floral garden
#

the biggest problem in your code is you have 6 loop

#

3 extremely big

#
        for (int x = 0; x < width; x++)
        {
            for (int y = 0; y < height; y++)
            {
                for (int z = 0; z < width; z++)

those are what making your fps drop intensly

hallow acorn
#

i think i doint have to explain which frame it dropped to 9 frames right?

hallow acorn
cosmic quail
hallow acorn
floral garden
#

yeah as john said, you can maybe use a async fonction?

hallow acorn
#

whats that?

floral garden
#

or as said, coroutine

teal viper
hallow acorn
#

tbh i have no idea how i should implement a coroutine into this

naive pawn
#

oh good lord 5 nested loops?

#

out of curiosity, what are width and height here

floral garden
# hallow acorn whats that?

async is not managed by unity but work on multiple threat , coroutine is managed by unity and execute the function every frame
an exemple

    private IEnumerator DisplayLine(string line)
    {
        for (int i = 1; i < lineLen; i++)
        {
            dialogueText.maxVisibleCharacters = i;
            if (_playerInputHandler.GetSubmitPressed() && i > 3)
            {
                dialogueText.maxVisibleCharacters = lineLen;
                break;
            }
            yield return new WaitForSeconds(typingSpeed); // wait n second
        }
    }
hallow acorn
naive pawn
#

jesus

floral garden
#

but in task is same

naive pawn
#

so it's running the task 1966080 times

floral garden
hallow acorn
floral garden
#

well

#

i think , in this case, use async UniTask is better than using coroutine

naive pawn
#

are vertices and triangles Lists?

hallow acorn
naive pawn
#

do you need to make 2M element lists

#

what are you using that data for

finite pond
#

I was wondering if anyone has a way of setting up a Wheel controller and force feedback or have any assets that I can use to get it to work with different types of wheels

naive pawn
#

that's gonna be a lot of copying internally

hallow acorn
#

marching cubes algorithm

naive pawn
#

if you do need the data, you could pre-allocate it to avoid copying

hallow acorn
naive pawn
#

do you know how lists work internally? just briefly

hallow acorn
#

not exactly tbh

naive pawn
#

so basically, lists work by having an array inside
if that array gets full, it creates a new one that's bigger and then copies all the data to the new one

#

so if you do like, for (int i = 0; i < 200000; i++) list.Add(i);, a lot of work is being done just to move existing data to a new array

hallow acorn
#

thats about what i thought it would do but as i think about it it doesnt really sound very great

naive pawn
#

you can avoid that by telling the list to reserve a large array to begin with, if you know how much space you'll need, like in this case

naive pawn
hallow acorn
naive pawn
#

you call that after you clear it

floral garden
#

doesn't we call it before asigning ?

naive pawn
#

..which is after the Clear call

floral garden
#

oh

#

my bad

naive pawn
#

you don't need to ensurecapacity 2M times

#

just once is enough

hallow acorn
#

how do i call that? i dont understand

floral garden
#

something like this i think

#

list is same

naive pawn
#

don't need to reconstruct it

floral garden
#

oh

naive pawn
#

bruh what this is a new method?

#

this is a fundamental operation, what is .net on

floral garden
#

if we are in c i had use reallocate lmao

naive pawn
hallow acorn
#

do i do that with my triangles too? what size should i give it?

floral garden
naive pawn
naive pawn
hallow acorn
#

dont feel any noticeable difference but its probably a lot more efficient than before. how do i use an async function or coroutine for my functions?

naive pawn
#

well since you're reusing the list, this'll only really help with the first time it's called

#

oh, though another thing.. i guess you could also reassign instead of clearing...

#

hm one sec

#

a new list could defer the O(n) clearing to the GC, but also require a new allocation.. that may or may not be worse

hallow acorn
#

bro what

floral garden
#

hahahaa

hallow acorn
#

i like your funny words magic man

floral garden
#

GC mean garbage collector, he is removing every instance that you are not using anymore

#

O(n) mean the nombre of iteration your computor need to claim the task

#

or something

hallow acorn
#

i think we still need to address the elephant in the room meaning all this being executed in a single frame

floral garden
#

it is too heavy for one frame

hallow acorn
#

yea thats what i mean

#

how do i break it up into a little less giant tasks for my cpu?

floral garden
#

a simple use of coroutine is

    private IEnumerator MarchCubes()
    {
        vertices.Clear();
        triangles.Clear();

        for (int x = 0; x < width; x++)
        {
            for (int y = 0; y < height; y++)
            {
                for (int z = 0; z < width; z++)
                {
                    float[] cubeCorners = new float[8];

                    for (int i = 0; i < 8; i++)
                    {
                        Vector3Int corner = new Vector3Int(x, y, z) + MarchingTable.Corners[i];
                        cubeCorners[i] = heights[corner.x, corner.y, corner.z];
                    }

                    MarchCube(new Vector3(x, y, z), GetConfigurationIndex(cubeCorners));
                }
            }                    
            yield return null; // < == this prevent that loop being call in one frame and late it to the next frame
        }
    }
hallow acorn
#

thats a lot simpler than i thought

#

thanks a lot

floral garden
#

coroutine is very easy

hallow acorn
#

dont have a lot of experiences with them to be honest

#

i used them in my chunkManager but thats mostly it

floral garden
hallow acorn
#

prolly because i usually dont make algorithms as expensive as this one

floral garden
#

if you want it go faster ( because here i split it into a lot) you can move the yield return one line down

sonic dome
#

how do i check if a gameobject is enabled or not?

floral garden
#

gameobject.actifself

sonic dome
#

thankss

cosmic quail
hallow acorn
floral garden
#

You have height x width x width frame before it finished

hallow acorn
#

oh yea ur right

#

but 800k frames is also a bit crazy i think

floral garden
#

Unitask is faster but is more complex

hallow acorn
#

yeah thats not optimal i think that comes out to around 46 minutes for one chunk 😂

cosmic quail
hallow acorn
floral garden
#

Di you still crash ?

hallow acorn
#

performance is great but at what cost

floral garden
cosmic quail
floral garden
#

2m

cosmic quail
#

you can try different numbers and see how that does

cosmic quail
hallow acorn
#

ah yeah

ivory bobcat
#

Or evaluate relative to time and yield when the time limit is up - 16ms or something.

#
if (Time.time > limit) 
{
    limit = Time.time + delta;
    yield ...
}```
hallow acorn
#

i tried printing out something when it returns but nothings happening idk whats going on here

floral garden
#

You know what? Use async UnityChanBye

hallow acorn
#

i thought implementing marching cubes is hard but making it not slow is a lot harder

hallow acorn
floral garden
#

It is same but the return is a bit different

hallow acorn
#

i changed it back to how it was before and it still doesnt work 😭

floral garden
#

I am going work, i lend this problem to my elder hahaha

cosmic quail
floral garden
hallow acorn
#

oh wait it didnt work because i set baseHeight higher than my maxHeight

#

idk what happened there

#

still doesnt work with the coroutine though

#

man i dont wanna do this anymore

cosmic quail
mortal grove
#

Im just so confused how this shows up on one image but doesnt on the other

feral shuttle
#

I want to communicate about the GameObject named "collider" who is a child of the GameObject named "Feet", who is a child of the GameObject named "Player". How do I most simply communicate that specific GameObject to you? Would I write to you, "The GameObject Player.Feet.collider"?

sorry that I am asking this question in a weird way

naive pawn
mortal grove
naive pawn
#

since there's only one Feet object, you could say "Feet's collider" too

feral shuttle
mortal grove
rocky canyon
#

public function/method
void is a return type.. its the wrong terminology to use..
just a tip for later 👍

#
public void Deploy()
{
    // executes logic, returns nothing
}``` vs
```cs
public int GetAmmoCount()
{
    // executes logic, returns an int
    return 10;
}```
#

both are methods ^

sonic dome
#

why does it loose ref once in game?

rocky canyon
#

is the slider in the scene?

#

or did u assign it from a prefab or something in the project window?

sonic dome
#

as in?

sonic dome
rocky canyon
#

as in is it a GameObject that's already in the scene..

sonic dome
#

no

naive pawn
sonic dome
#

hows that done?

rocky canyon
sonic dome
#

edit mode

rocky canyon
#

u have to make those assignments @ runtime

naive pawn
naive pawn
#

show the inspector for the UI gameobject in the scene, while outside playmode

sonic dome
#

seems to be fine

rocky canyon
sonic dome
rocky canyon
#

its inside Plant isnt it?

naive pawn
naive pawn
mortal grove
#

Question how would I reference this to this.

rocky canyon
#

then my 2nd guess is somethings setting it to null

naive pawn
naive pawn
rocky canyon
#

code reassigning it to something it cant find

naive pawn
#

you told it to assign something there

mortal grove
naive pawn
#

it happens to assign null

rocky canyon
#

if u assign it in the editor u shouldn't need to assign it in script

sonic dome
#

thats all that touches it

#

OOOO

#

the awake

#

my bad

rocky canyon
#

exactly

sonic dome
#

thanks

naive pawn
#

what's the goal

rocky canyon
mortal grove
rocky canyon
naive pawn
mortal grove
naive pawn
rocky canyon
#

context always helps 👍

naive pawn
#

wouldn't you want to update beans to some random number upon something happening, rather than it being set once?

naive pawn
rocky canyon
#

ok cool 👍

mortal grove
#

`public class MORE_BEANS : MonoBehaviour
{
public TMP_Text BeansText;
private int beans = 1;
// Start is called once before the first execution of Update after the MonoBehaviour is created
public void AddBeans()
{
beans++;
BeansText.text = "Beans = " + beans;

}
void Start()
{

}

void Update()
{
    
}

}`

naive pawn
#

that isn't really any context at all

#

write a description of what you want to happen

#

step away from the code for a second

rocky canyon
#
public class MORE_BEANS : MonoBehaviour
{
    public TMP_Text BeansText;
    private int beans = 1;
    // Start is called once before the first execution of Update after the       MonoBehaviour is created
    public void AddBeans()
    {
        beans++;
        BeansText.text = "Beans = " + beans;
    }
    void Start()
    {
    }

    void Update()
    {       
    }
}```
naive pawn
#

what is the goal

rocky canyon
#

yea theres no context there lolio

mortal grove
# naive pawn what is the goal

The goal is to have the output of Beans++ be whatever the random number is example

Random number is 8

Beans = Random number/8

rocky canyon
#

laying out a script is a great idea.. i do it all the time...

// this should happen first
// now i want this to happen
// this method should do this```

and then you fill it in a little at a time
naive pawn
#

when should this happen

#

when AddBeans is called? when CreateBeansPercent is called?

#

what is the flow supposed to be here

mortal grove
feral shuttle
#

you want to add a random number of beans to the total

naive pawn
#

that's all you had to say man

#

that's what we're looking for when we ask "what are you trying to do"

#

this does not relate to the private int beans = 1; line at all (hence the x/y problem)

#

beans++ adds exactly 1.
if you want to add a random number, you would do beans += [random number]; in place of that

#

if you want that random number to come from CreateBeansPercent, then that should also return an int (and BeansPercent should maybe not be a member, but a local variable instead.)

rocky canyon
#

holy crap.. does this affect all audiolisteners? 👀
(im working on a loading/menu/setup)

i thought this was an error and my IDE just wasn't catching it.. but after making sure it was configured it seems like it applies to all the audiolisteners??

rocky canyon
#

ya i had no clue

mortal grove
naive pawn
#

well, not exactly a singleton

#

you can have at most one in the loaded scenes

rocky canyon
#

yea "enforces behaviour like a singleton

#

but still

#

interesting.. i never knew

rocky canyon
#

i think imma still use a master mixer and do it that way

#

but its interesting i could simply change em all at once via the listenors

mortal grove
naive pawn
#

well first off, it's in a different class, so that wouldn't work
secondly, you spelt it differently

#

thirdly, having BeansPercent as a state of sorts just doesn't make sense

naive pawn
#

put a little thought into the structure and flow of your code

rocky canyon
#

wow.. the things u learn.. 😅

mortal grove
#

Im still confused

naive pawn
naive pawn
mortal grove
rocky canyon
naive pawn
#

you should not do that

#

oh you mean BeansPercent?

mortal grove
naive pawn
#

what's the name of the class that has CreateBeansPercent, for ease of communication

mortal grove
worthy raptor
#

Can someone help me? How would I make a sound play in Start()

#

(ping me)

naive pawn
#

for basic stuff regarding that you can just google audiosource, or really just unity audio

worthy raptor
#

okie dokie

naive pawn
# mortal grove 'public class RNG : MonoBehaviour'

so right now what you have has BeansPercent as a member of RNG, meaning that each RNG has a "beans percent"
that doesn't really make sense - beans percent is the result of the specific operation, create beans percent, not something to do with RNG as a whole

so first off, RNG does not need to exist at all, let alone as a component. you're pulling responsibility over beans into a separate class

rocky canyon
# worthy raptor Can someone help me? How would I make a sound play in Start()
  {
        // --- PLAY METHOD ---
        // Plays the clip assigned to audioSrc.clip
        audioSrc.clip = clip;
        audioSrc.Stop();  // Redudant here, but useful in other places to stop any audio thats already playing.. and then..
        audioSrc.Play();  // plays the clip from the start

        // --- PLAYONESHOT METHOD ---
        // Plays a clip immediately, without affecting the currently assigned clip
        audioSrc.PlayOneShot(clip, 1f); // 1f = volume scale
    }```
naive pawn
#

making a member into a local variable would be like this

- int x;
  
  void Method() {
-   x = y;
+   int x = y;
  }
rocky canyon
# worthy raptor thanks

might want to check out the two different Methods.. and see which one fits ur use-case better

mortal grove
rocky canyon
#

OneShot() can call a clip just once regardless of what clip u already have assigned

naive pawn
rocky canyon
naive pawn
#

@mortal grove you really need to just step back and plan things out so they're in places that make sense

mortal grove
naive pawn
#

why is the class you sent before "MORE_BEANS"

rocky canyon
#

pretty easily to do.. since u alrady have variables

naive pawn
#

i have a feeling it just..doesn't need to exist

rocky canyon
# mortal grove Ima try to figure this out give me a second.
    // --- logic method ---
    public void UpdateBeans()
    {
        // do the math/logic to your actual variables
        DisplayBeans(); // now Update the UI w/ those new values
    }

    // --- display method ---
    public void DisplayBeans()
    {
        beansText.text = $"Beans: {beans}";
    }```
#

beansText.text = $"Beans: {beans}"; is (String-Interpolation) btw, same thing as saying
beansText.text = "Beans:" + beans.ToString(); (Concatenation)

#

makes it easier to add ur variables into a string
The time is: {time} on the day of: {day}

grand snow
#

Well it's not the same, it's better!

rocky canyon
#

lol.

#

ngl there.. It is better.. never went back to concatenation

#

always had to go back and add extra spaces between the +s

grand snow
#

js string interpolation is similar but a bit weird

rich adder
#
    var awesomeString = new StringBuilder("Hello ");
    awesomeString.Append("world! ");
    awesomeString.Append("c# ");
    awesomeString.Append("is ");
    awesomeString.Append("awesome!");
    Console.WriteLine(awesomeString.ToString());``` ![thinksmart](https://cdn.discordapp.com/emojis/1202247906455982142.webp?size=128 "thinksmart")
naive pawn
grand snow
naive pawn
#

` is such a weird case

#

languages use it in such different ways

grand snow
#

JS is just weird, so weird infact that we need TS to make it acceptable

naive pawn
rocky canyon
#

lol

#

imma fail..

naive pawn
#

i implemented 9.81[m][s[-2]] into ts a few hours ago, for fun

naive pawn
#

i can ace the jsisweird thing since there are still rules even if they're really weird

errant knot
# mortal grove

Youre not going to be able to return a value from the randomly generated number if you use a void
If you were to have a method to do random generation and addition and then pass your value of beans through that method i think it that would work
You wouldnt be able to set beans = to the local variable in the method youd pass your beans through the method i think

naive pawn
feral shuttle
#

In runtime, when I set the parent of my Player gameobject (that may be rotated on its Y axis) to a gameobject that is rotated on any axis, the scale of my Player gameobject changes by really small amounts (eg: from 1 to 1.000001). As a result, if I repeatedly change parent to and from rotated objects, the player's scale may gradually increase or decrease. Also note that the scale of the player and the scale of its parent in all scenarios is (1, 1, 1).
Is this something I should worry about?

errant knot
naive pawn
#

passing a reference just to add to it with a single value?

#

just use the return type

#

it makes much more sense, it's straightforward, it's logic that you actually expect

naive pawn
rocky canyon
#

that syntax is crazy af

naive pawn
errant knot
mortal grove
#

Ima take a break because I do not understand anything yall are saying.

naive pawn
#

not sure what scenario you're referring to there?

errant knot
#

Thus i would need to use passthrough yeah

naive pawn
#

it's just using the method call as a value

#

it's a very basic thing

errant knot
#

Yeah thays what i meant

#

It would be like BeansGenerator(beans) ya?

naive pawn
#

whoops, didn't mean to send that yet

rich adder
naive pawn
#

one of these scenarios is a lot simpler and much easier to read

void A() {
  int x = 0;
  B(ref x);
}

void B(ref int x) {
  x += 2;
}
``````cs
void A() {
  int x = 0;
  x += B();
}

int B() {
  return 2;
}
errant knot
naive pawn
#

probably not

#

but it doesn't matter

#

the point is, this makes way more sense

errant knot
#

Mmmhm

naive pawn
#

what "passthrough" method are you referring to anyways

#

that's not a term used for singular function calls

rich adder
#

what the hell is a "passthrough" I never heard of it

errant knot
#

Passing

naive pawn
#

yeah no, not the same thing

cosmic dagger
errant knot
#

Uh huh

hollow shard
#

Hey just a quick question sorry for interrupting I was following a tutorial and when I added a 2d rigidbody my game object goes upward

rich adder
cosmic dagger
errant knot
rich adder
naive pawn
#

passthrough afaik is just, well, passing through a layer unaffected

A(x, y, z);

void A(int x, int y, int z) {
  for (int i = 0; i < x; i++) B(y, z + 4);
}

void B(int y, int z) { /* ... */ }
```in this case, there is passthrough on `y` in the call to `B`

it is not the same as just *passing* an argument
naive pawn
rich adder
#

seems overconvoluted for a simple usecase

cosmic dagger
#

What? That's even more confusing . . .

sonic dome
#

when should i make a class static as in rn im making a TeamManager which keeps track of all the teams should i make it static?

rich adder
naive pawn
rich adder
sonic dome
naive pawn
#

probably not static though, were you thinking of singleton

sonic dome
#

ohhhh

#

yea

#

singleton

errant knot
cosmic dagger
rich adder
#

class static itself means you cannot use any inspector reference or anything

naive pawn
#

i mean, it could go either way. up to your design

sonic dome
#

i just want to access the manager from any script via the players code

errant knot
#

I mean i wouldnt invent a whole method to do rng for one value for one number but it it looks like thats what he was doing kinda

naive pawn
sonic dome
#

thanks

rich adder
cosmic dagger
rich adder
#

most times my static classes are like utilities that have "self-containted" method

#

kinda how unitys Random works

grand snow
#

I think a singleton mono manager is a better way to go for a beginner

hollow shard
cosmic dagger
rich adder
hollow shard
#

That's the only one

#

No collides yet

#

That I know of

rich adder
#

a rigidbody without collider ? 🤔

hollow shard
#

Let me make sure

cosmic dagger
#

Without a collider, it should fall through the world . . .

hollow shard
#

Sorryabout rhat

errant knot
naive pawn
#

what benefit does it give over just using the return value to provide 1 value

#

you have to deal with ref parameters for whatever reason now

hollow shard
naive pawn
hollow shard
#

Oy component on it

rich adder
hollow shard
#

Yes

naive pawn
#

check the Y value to make sure it's going up and not down

cosmic dagger
hollow shard
#

Actually right now it doesn't move at all

#

But y value goes down

naive pawn
#

ok then it is going down

#

your camera is probably just following it

rich adder
#

is the camera parented to it ?

naive pawn
#

use scene view when checking if stuff is going down/up

hollow shard
#

I figured it out

#

My freaking camera has a rigidbody

#

Yo I'm an idiot

naive pawn
#

lmao

cosmic dagger
hollow shard
#

Yo I figured it out

#

Mb yall😅

rich adder
hollow shard
#

Thanks

worthy raptor
#

How do I play a sound? Everything is in order (my unity is not muted), and yet it still isn't playing the audio I want

using UnityEngine;

public class bulletScript : MonoBehaviour
{
    public static bool isBulletOnScreen = false;
    public float bulletSpeed = 2f;
    
    public AudioClip shootSound;
    private AudioSource audioSource;
    
    void Start()
    {
        if (isBulletOnScreen)
        {
            Destroy(gameObject);
            return;
        }

        isBulletOnScreen = true;

        audioSource = GetComponent<AudioSource>();
        if (audioSource != null && shootSound != null)
        {
            audioSource.PlayOneShot(shootSound, 1f);
            Debug.Log("Played");
        }
        else
        {
            if (audioSource == null)
                Debug.LogWarning("No AudioSource found on the bullet prefab!");
            if (shootSound == null)
                Debug.LogWarning("No AudioClip assigned to shootSound in the Inspector!");
        }
    }

    void Update()
    {
        // Frame‑rate independent movement
        transform.position += new Vector3(bulletSpeed, 0, 0) * Time.deltaTime;

        if (transform.position.x > 9.3f)
        {
            isBulletOnScreen = false;
            Destroy(gameObject);
        }
    }
}

You all will hate me, I tried to fix the problem with AI, and it still didn't work. Need some better programmers than AI xD

cosmic dagger
edgy sinew
potent portal
#

is this channel for help with anything related to the unity engine or just code (or C#) ?

potent portal
#

oh okay

cosmic dagger
worthy raptor
#

I have

naive pawn
cosmic dagger
#

Make sure there is an AudioListener in the scene . . .

worthy raptor
potent portal
naive pawn
cosmic dagger
worthy raptor
#

on the camera

potent portal
#

yeah

naive pawn
#

you also need an audiolistener

worthy raptor
naive pawn
#

oh wait, the screenshot you showed isn't the camera lmao

#

you sent that right after the "yes it's on the camera"

worthy raptor
#

xD

naive pawn
#

try making it 2d sound, to check if it's just too far away to hear

worthy raptor
#

How would I do that

naive pawn
#

oh wait it is 2d

worthy raptor
#

xD

naive pawn
#

i saw the 3d sound settings window open and thought it was 3d lmao

#

sanity check - the Played log is being triggered, right?

worthy raptor
#

yes

naive pawn
#

do you see the audiosource being cloned?

sonic dome
#
    public override void OnNetworkSpawn()
    {
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible = false;

        wr = GetComponent<WallRunning>();
        useItemScript = GetComponent<UseItem>();
        speed = walkSpeed;

        TeamManager.Instance.addPlayersToTeam(gameObject, 0);  //Here is the error pointing to why does it not know what Teammanager 

        if(!IsOwner)
        {
            _camera.SetActive(false);
            _cmCam.SetActive(false);
            _vol.SetActive(false);
            _ui.SetActive(false);
        }
    }
worthy raptor
#

oh

#

shit

rich adder
#

was it asked check just the scene view / gameview muted ?

worthy raptor
#

I figured it out

#

I need it to be on the player, not the bullet

naive pawn
worthy raptor
#

I'll be back in 5 mins

naive pawn
errant knot
sonic dome
# naive pawn have you set the instance yet
public class TeamManager : NetworkBehaviour
{
    public static TeamManager Instance { get; private set; }

    public bool friendlyFire { get; private set; } = false;

    public Team[] teams;
    private Dictionary<GameObject, Team> teamMap = new Dictionary<GameObject, Team>();

    public override void OnNetworkSpawn()
    {
        
    }

    public void addPlayersToTeam(GameObject player, int teamNumber)
    {
        teamNumber++;

        if (teamNumber > teams.Count()) return;

        if (teams[teamNumber].players.Count >= teams[teamNumber].maxPlayerCount) return;
        teams[teamNumber].players.Add(player);
    }

    public bool inTeam(GameObject you, GameObject other)
    {
        return teamMap[you] == teamMap[other];
    }
}
naive pawn
#

so no

#

you haven't done Instance = ... anywhere

#

so it'll stay null

sonic dome
#

ooo okay thats how u do it

#

thanks

rich adder
rich adder
sonic dome
#

i got it to work

#

thanks

rich adder
#

yes just making sure

cosmic dagger
# worthy raptor

I see how edited the 3D Sound Settings. I would reset them to check if the sounds plays correctly . . .

worthy raptor
sonic dome
#

why cant i see these fields in the inspector?

naive pawn
#

select a different object and reselect this one

sonic dome
#

didnt do anything

#

i even restarted

grand snow
#

properties need an attribute to be serializable: [field: SerializeField]

naive pawn
#

Team wasn't made non-serializable in the 10 minutes since the last question, right?

cosmic dagger
rich adder
#

is team an enum ?

naive pawn
sonic dome
naive pawn
#

ok, then nothing there is both serializable and marked to be serialized, so nothing got serialized

cosmic dagger
#

and you need to serialize Team for it to display from the inspector . . .

sonic dome
#

wait im dumb

public class Team
{
    public List<GameObject> players;
    public int score = 0;
    public int maxPlayerCount = 5;
}

i can just make this a struct

rich adder
cosmic dagger
naive pawn
#

cool, wouldn't solve it though - you need to also mark it Serializable

grand snow
#

do we need 3 people saying the same thing?

naive pawn
#

well one of them was wrong

rich adder
sonic dome
#

Im so confued i have so many approaches, idk if i should make teams a scriptable object to make it easier to make new modes or make it a struct and do it from there or just make classes for each one of them do u have any one u would like to recomm

naive pawn
rich adder
naive pawn
rich adder
#

the docs for Packages does, this doesn't. I hate it

cosmic dagger
sonic dome
#

notlikethis scriptable objects was working fine ig ill just use that

sonic dome
#

whats a poco?

rich adder
#

plain c# object

#

class / struct

sonic dome
#

and why do u think thats the best

naive pawn
#

don't add complexity where it isn't necessary

rich adder
#

up to you though, use whatever is easier

sonic dome
#

fair nuff

#

thanks

turbid comet
#

Guys I have a problem with my double Jump animation I am new to unity . And I am facing some issues with my double jump. the issue is that my jump animation plays normally when i press the spacebar but when I press it one more time for double jump the animation is weird like the falling animation starts playing for few frames . Could you guys Help me Out?? I am making a 2D platformer

hot wadi
#

Those variables look like they are gonna change in runtime. Ain't that a no for a SO?

rich adder
cosmic dagger
turbid comet
cosmic dagger
turbid comet
#

should i send an screenShot?

kind skiff
#

What are the best method to store the datas for player inventory? Should I make them as scriptable objects, json, playerprefs or anything else?

rich adder
rich adder
#

there is no "best method" either

cosmic dagger
#

That's not the best, but the typical way people do it . . .

rich adder
#

storing where exactly? is this runtime ? between sessions ? both etc.

cosmic dagger
#

How you choose to make those items and the data to represent them is the real work. That can be with SOs and/or POCOs . . .

sonic dome
#

is there a way to see the values inside of these elements in the inspector?

rich adder
sonic dome
#

what is naughty attributes?

#

okay i see

#

tho how hard would be making my own inspector?

rich adder
sonic dome
#

lets say average

turbid comet
hot wadi
cosmic quail
sonic dome
#

what should i exactly look for

cosmic quail
sonic dome
#

found it

#

thanks a bunch

kind skiff
rich adder
cosmic dagger
rich adder
kind skiff
#

I was following a tutorial and it asks me to use scriptable object

turbid comet
rich adder
#

I already seen it, tbh I dont wanna help you

#

I should've just called a mod before anything 🤷‍♂️

cosmic dagger
turbid comet
rich adder
solid oyster
#

this code works perfectly fine when in runtime. but after building changing material colour doesnt work?

#

when built it says that object instance wasnt being referenced

grand snow
#

!ide

radiant voidBOT
solid oyster
grand snow
#

you can connect the console in editor to dev builds

#

id do that instead to see the exception msg

solid oyster
grand snow
#

click the lil dropdown that looks like [Editor \/]

#

then pick your build thats currently open

solid oyster
#

done that but im not getting any error messages

#

im so confused ive been tryna solve this shit for so long

rich adder
grand snow
#

you can also attach a debugger if you enable script debugging before building

#

either way more information would help narrow down what is null

solid oyster
#

does this help

#

this is the result i get in console after switching dropdown

rich adder
solid oyster
rich adder
#

you should probably debug also dropdown to see if thats not null

#

though if its grabbing the correct values its probably not null

solid oyster
#

maybe the colour data is being lost when switching scenes?

naive pawn
radiant voidBOT
rich adder
#

objects reset on scene switch

solid oyster
rich adder
#

if you change it in one scene, then move into another scene, unless you are runing playeprefs.Get again all is lost unless it was DDOL

grand snow
rich adder
#

so they should make sure its running Get again in second scene to grab their stored int

grand snow
#

Ah right. Their script uses Start() to get and apply so its probably okay

#

if the error isnt even related to that script i will smh

rich adder
#

yea I had a feeling that might been case too

#

cause the logs are printing and they are not mentioning any NRE now 😔

solid oyster
#

this is what i was trying to get

#

and ss

rich adder
#

what steps you did to cause this error to appear

solid oyster
#

im assuming cs:14 refers to line 14

rich adder
#

you probably have a copy of this script somewhere
(if second script has null ref above changeColor() its not gonna run that function and probably why you dont see the second logs that print dropdown as null)

naive pawn
hardy wing
#

do you happen to know if this problem is resolved? it's not clear to me from the issue comments.

solid oyster
#

i just realized this now but the actual prefab that has the material changing colour doesnt get updated in the project window

#

but in runtime it does

rich adder
solid oyster
#

is there a way to not create a copy

#

and have it apply the changed material to the target

rich adder
#

you modify the sharedMaterial

#

that will change it to every object with that same material though

solid oyster
#

thats what i want

#

so this is modifying material? how do i modify shared material

rich adder
#

wait targetColour is a material it should be changing it globally no ?

#

I forget how Unity does it

solid oyster
#

i have no clue

rich adder
#

then test the material thing

grand snow
#

Materials are shared until instanced (so modifying the material asset will affect everything using it)

rich adder
#

but is it instanced at runtime ? i forget tbh

#

i usually go through the renderer

grand snow
#

no only when you access material from mesh renderer

#

THEN unity makes an instance for you

hardy wing
#

didnt it depend on whether you access .material or .sharedMaterial?

rich adder
grand snow
#

Here they have a serialized ref to a material so this is not relevent

rich adder
#

so changes to color of the serialized material will persist in project ? (at runtime)

grand snow
#

changes to assets do yea even post play

rich adder
#

right..makes sense

grand snow
#

anyway like I said, the doc page for renderer.material mentions that it makes an instance for you

hardy wing
#

oh thats interesting, how do you access asset via code though? .material and .sharedMaterial are not the asset as far as i understood now.

grand snow
#

.sharedMaterial just ensures it wont make an instance unique for this renderer for you

rich adder
grand snow
#

yes.
and to be clear. UI graphics have no such behaviour, no auto instancing happens for them

hardy wing
#

yeah but only a runtime instance right

rich adder
#

I forgot if you have to dispose it manually or unity does it for it

#

nvm I think thats only if you create it with new()

rich adder
slender nymph
rich adder
#

ah okay thought so UnityChanThumbsUp

rich adder
#

I just ended up making materials in editor and just swap them instead of directly changing material properies.. avoids heaaches

rich adder
solid oyster
#

i dont think there is a copy

solid oyster
rich adder
#

the logs in changecolour method say dropdown is there but thats probably from the script in which is assigned

#

put Debug.Log($" {name} trying to access {dropdown}", gameObject); in start before the PlayerPrefs line

#

could be.. the other one runs start, dropdown is null, doesnt run anything else underneath (changeColour)..

and changeColour method if you're calling it again via Inspector / Unity event thats only linked to one script and why it wont try to run on the second script

solid oyster
#

the canvas is called settingmenuui

rich adder
solid oyster
rich adder
red igloo
solid oyster
#

ima be honest i think i might just create seperate materials for each colouir will that sovle my problem?

rich adder
sonic dome
#

i want to push my code to github where can i find a gitignore file?

naive pawn
red igloo
# rich adder how did you verify that

well the bool is visable in the inspector and I see it not checked and in the other script where my player could slam the ground I did a if statement that only when the player hasjumped the slam button can be pressed. Tried it out and I could no longer slam

sonic dome
languid pagoda
#

So is there a way to map a ulong to a long then back again?

rich adder
languid pagoda
#

They are both 64 bit values so there should be a way right?

naive pawn
sonic dome
rich adder
rich adder
sonic dome
naive pawn
#

such as?

languid pagoda
rich adder
red igloo
naive pawn
sonic dome
#

do i need all this stuff?

naive pawn
#

yes

rich adder
#

meta files are very important

naive pawn
#

those are not "randomass files", those are parts of assets

rich adder
#

without them all your references will break

sonic dome
#

okay then seems fine now thanks

naive pawn
#

if they're under /Assets, chances are you want them

languid pagoda
naive pawn
#

you don't want stuff under Library

languid pagoda
#

perfect

naive pawn
#

basically - they both have 2^64 possible values, and half of them map to different ranges of integers

#

0x1000 0000 0000 0000 read as a ulong is 2^63, but read as a long it's -2^63
0xFFFF FFFF FFFF FFFF read as a ulong is 2^64 - 1, but read as a long it's -1

languid pagoda
#

My scripting language uses long* for the parameters of methods calling the host, so im using this as a way to pass ulongs to the scripting runtime and back which does not care what the value is it just needs to store a reference to it.

#

so this will work perfectly

#

thank you

rich adder
#

also [SerializeField] public

#

you dont need to serialize public variables, also since its public make sure you aint changing this elsewhere

#

if you need things to be public, its usually better to just keep them as read only / public get and private set variables

red igloo
#

This is what I've got in the ground slam script and it doesn't work anymore when I add hasJumped

rich adder
red igloo
rich adder
#

and see if thats called at some point, maybe on the way up ?

red igloo
rich adder
#

yup that should be fine, debugger is good too

hallow acorn
#

can someone tell me what this means and how to fix it? the foreach is causing this error: "InvalidOperationException: Collection was modified; enumeration operation may not execute.
System.Collections.Generic.Dictionary`2+Enumerator[TKey,TValue].MoveNext () (at <59bd7c40c082431db25e1e728ab62789>:0)
ChunkManager2.CheckChunkDistance () (at Assets/Scripts/chunkManager2.cs:68)"

private void CheckChunkDistance()
    {
        foreach (var pair in chunks)
        {
            int playerPosX = Mathf.FloorToInt(transform.position.x / width);
            int playerPosZ = Mathf.FloorToInt(transform.position.z / width);
            Vector2Int playerPos = new Vector2Int(playerPosX, playerPosZ);

            if (Vector2Int.Distance(playerPos, pair.Key) > viewDistance)
            {
                GameObject chunk = pair.Value;
                Destroy(chunk, 5f);
                chunks.Remove(pair.Key);
            }
        }
    }```
naive pawn
rich adder
#

in a foreach loop*

naive pawn
#

with its enumerator* (which a foreach uses)

rich adder
#

basically foreach makes it immutable

#

for loop works, but you want to do it in reverse because you will have items being skipped

hallow acorn
#

should i add it to another collection and and remove it after iterating over it?

naive pawn
rich adder
#

oh true true

hallow acorn
red igloo
# red igloo

So its working then? When I add it to slam script the player can no longer slam anymore

naive pawn
#

hmm, some languages have the iterator (or enumerator in c#'s case) implement a delete method, seems like c# doesn't

rich adder
# red igloo

not sure how this helps.. did you put the log where I said ?

#

Debug.Log($" hasJumped ? {hasJumped}");
where you call
hasJumped = false
on landing

#

if its being called then you will know its doing it prematurely and should probably fix the bigger problem

stray fog
#

Hi,
Need opinions of this, I am implementing a full body player controller and I am trying to understand if the Unity 6 provided rigging package is sufficient or is it a must to have finalIK? Looking at finalIK there's not much of documentation.

What I am trying to achieve is full body controller such as ArmA / Tarkov, but on top of that the hands placement is different per gun right, so need to be able to solve hand placement on the rifle grip and if the weapon has a front grip, if not then use handguard etc. Doing the logics for it is straightforward, just check gun components etc but not sure how to deal with IK for the body movement and different grip styles plus if finalIK makes it much easier and is more performant or its a waste of $$$

solar hill
#

🤔 its pretty much a great solution for getting full body true fps working correctly

#

its not a one click template or anything but its a huge set of tools including ik implementations for exactly the things you mention such as different grip styles etc.

#

its pretty robust and gets updated regularly

naive pawn
stray fog
naive pawn
#

was the question not about IK

stray fog
solar hill
#

this isnt that kind of framework.

#

thats why i specifically noted its not a one click template

#

the great thing is that its a set of tools that you can use individually, like you can use their ik system and nothing else

#

its very modular and easily expandable

stray fog
solar hill
#

i mean thats fair yeah having a dependancy on someone elses systems is not that great in the long run

#

however i still implore you to at least check out some of their videos and skim the documentation

#

before skipping on it completely

stray fog
# solar hill before skipping on it completely

Sadly I will skip this one, I rather implement a solution purely from my own work for my requirements
A) Actually learn something
B) Not worry about blockers down the road

But I do appreciate the input and I hope you'd have more inputs towards a own system or gists I can look at 🤣

solar hill
#

welp good luck then lol

#

but to answer your original question finalik might be a worthwhile investment then

#

if youre planning on doing everything else from scratch

rich adder
#

yea FinalIK is a bit more polished than the one unity made (Animation Rigging)

stray fog
#

Awesome I'll buy it now but is there a like discord or somewhere I can get help with it? I look at their website and their doc is very very lacking

solar hill
#

yes they do have a discord

#

its listed on the unity page

stray fog
#

ouch it looks dead argh

rich adder
#

how much could you really be talking about a simple asset.. its pretty straight forward

stray fog
#

Let me buy and try lol

rich adder
#

I'm sure if you have specific issues you can always DM or Email them

solar hill
#

i feel like the documentation is pretty standard

#

all things considered

#

theres also a shit ton of youtube videos

stray fog
#

Bought it, will give it a try thanks guys.

stray fog
#

Hey @solar hill @rich adder im getting there with finalIK but seeing some sort of offsets between camera and view. This is my code https://gist.github.com/Alwandy/3bcd7050cd3baac1501cb6fa445009a4 what would be the best approach? Or am I doing it wrong? Trying to base it some off https://matthew-isidore.ovh/unity-tutorial-full-body-fps-controller-part-2-upperbody-ik/

Gist

GitHub Gist: instantly share code, notes, and snippets.

This is the second part of a tutorial series about creating a Full Body FPS controller. It covers the head stabilization, weapon sway, an ADS system and more.

rich adder
stray fog
#

Ah fair enough

nocturne parcel
#

Is there a way to set a variable in the inspector using binary?

#

0bXXXX doesn't work

ivory bobcat
#

Wouldn't an integer suffice?

wintry quarry
ivory bobcat
#

Ah, unless you wanted ones and zeros.. string.

wintry quarry
#

you could make a bunch of checkboxes with a custom editor - one for each bit

nocturne parcel
nocturne parcel
wintry quarry
#

you could also write a custom property drawer

#

that takes a string

#

and parses it as binary into a byte or int field

#

e.g.

[MyCustomAttribute]
public byte myField;``` and write a custom property drawer for the MyCustomAttribute attribute
nocturne parcel
#

Sure, thank you

outer wigeon
#

Anyone able to help me figure out why I'm getting this error each time I open up my project? I tried remaking my camera entirely but it doesn't seem to help once I reopen the game.

Screen position out of view frustum (screen pos 1256.000000, 159.000000, 0.000000) (Camera rect 0 0 1527 518)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
#

Nothing seems wrong per se, the camera still seems to operate normally. Just wondering if I should fix something.

winged ridge
grave frost
sour fulcrum
#

Not to stackoverflow you with an indirect answer but curious on what your use-case is for using typeof() in build in a scenario where your considering potential overhead?

#

Not inherently a wrong thing to do im just curious

sonic dome
#

did they change the syntax? cuz earlier it was like this only

#

okay found the docs nvm

rotund root
keen dew
#

Open the browser console and check the error messages. #🌐┃web for followup questions

sharp ridge
#

Hi!! So I am working on a project and I don't know what is going on but it seems like Unity is deleting the TMP system? Is giving me errors all over the code and I don't know how to fix it. I am working on GitHub and I already had to scrap a branch because of this issue

sour fulcrum
#

(we don't know what the errors are)

sharp ridge