#💻┃code-beginner
1 messages · Page 751 of 1
perfect
ty
events will be good here
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)
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
guys i think ill stop right there for today thanks for helping
could always make a thread in #1390346827005431951 and others might see / reply it while you're away
(as long as all the info is there)
yeah that's good, + switching the vehicle component in the camera follow script as well like nav suggested
yeah good idea
btw you dont really need a follow script if it just does that, cinemachine has a follow feature without needing a script
Is it bad practice having a class that inherits another class that inherits MonoBehavior? As in Goblin : Enemy : MonoBehavior?
normal inheritance? why would it bad practice
its like one of the important features of the language
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
Erm no I think inheritance with mono behaviours is fine
Ah, I see, thanks and sorry for the random tag lol
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
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
When play mode ends the objects get destroyed and remade. The managed object will still exist so you may be able to locate it post play mode end and copy the properties over.
Or just look at what cinemachine does to achieve this 😆
https://docs.unity3d.com/ScriptReference/EditorUtility.CopySerialized.html
#↕️┃editor-extensions ask here in future
Will do
quick question I will create a horror game 3d built in render pipe or urp?
generally URP, the game type makes no difference
if you look for shaders though they have to be urp compatible and not Built In

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
2D Platformer Collision Detection
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;
}
i dont think the you can deregister with the lambda
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.
i think another can handle it.. I may be wrong
movementAction.cancelled += theInput => MovementInput = Vector2.zero
thats another event now
No, this creates two subscriptions
cool deal, thanks, both of you. i will stick with the usual way, (verbose)
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.
Ouch! super cool. you've saved me an endless headache. thank you 🙂
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;
It’s .linearVelocity in newer versions of Unity
Btw, What is this part of the code accomplishing?
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
just google. IDK how else to say this.
ok i try now
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
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
Sanity, make sure that says Both. Its in your project settings.
My project only uses New Input (I will not use old) so I am not changing mine to Both, you should change yours to Both and for now forget the difference, but realize that New Input is legitimately better than Old in every aspect.
oh i see
yeah that does work but tbh i would recommend learning the new input system right away, it's good to know
ok
Its going to seem confusing at first, I will not lie.
Most tutorials for it are really bad at explaining it.
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
[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 🤣
https://docs.unity3d.com/6000.0/Documentation/Manual/create-source-generator.html
It says use CodeAnalysis 4.3 but that version isn't available anymore. Can someone verify which version of CodeAnalysis they're using for incremental source generators with unity?
Or just let me know which version is compatible?
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
This isn't the visual scripting section, and you should consider learning C# if you want a serious future in game development.
visual scripting almost always turns into a spaghetti mess if you want to do anything serious with it
Not for pity. But I have MD and its hard to type at all. But I do wanna devolop games. Which is why I wanna learn visual script.
you can still download it from the page on the right
when your programming in an unclean fish tank
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();
}
}
you need to specify which of the namespaces you want to reference when using Scene, both contain Scene, you can write your namespace infront
You should just remove using UnityEditor.SearchService; because it will cause problems and may be causing this ambiguity issue too
your ide probably put it there for you by mistake
yeah i was about to say get rid of it but wasnt sure if they need it or not
Is that because UnityEditor.SearchService and UnityEngine.SceneManagement have aligning references?
probably but also the UnityEditor namespace wont exist in builds and will cause compile errors then
so clearly a mistake
So delete! 🗑️
I have no clue why it was there to begin with lol. maybe it was the keyword static? anyways.
thanks for the help 👍
VS and other ides auto add using statements when you write things so you may have selected something by mistake
!compile
There's no command called
compile.
There's no command called `compile
using`.
ah-
@turbid plover that isn't a feature here. what are you trying to do?
yeah I clicked the wrong server lol.
sorry
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)
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.
Best I can think of is using the position of the player when the trigger happens to imply the side it happened on
yeah, I thought about that too. feels cringy ngl, but who cares.
oki, thanks!
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
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
They don't need to be thin
Oh like have it a tad inside the room
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
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.
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
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
anyone willing to hop on a vc and review my movement code?
: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
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
understood will send in a bit
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.
it obviously depends on the exact case, but you could start with an algorithm like wave function collapse
here's a few videos (tho not necessarily implementation tutorials, just to get a gist of the concept) to get you started:
https://www.youtube.com/watch?v=TO0Tx3w5abQ
https://www.youtube.com/watch?v=zIRTOgfsjl0
https://www.youtube.com/watch?v=8WFuFohmVcw
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!
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.
Unity's official tutorials are great. I only know python and dart but they have helped get a grasp on unity very quickly.
check your drivers, make sure your device meets the minimum requirements
!learn 👇 is a good place to start
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
Thanks a lot. I have found that on google as well. But my drivers are up to date and my PC is a Ryzen 9 3900x and a RX7600 so prettey modern.
did you check the cpu?
just in case
wait is ryzen the cpu
god i need to learn hardware sometime
Honestly no, lol. But will do! I just can't think that would be causing it
compatibility is the main concern here rather than low specs
You think it's an AMD thing?
nope
Well, input and camera would be related to the Unity API so just getting more comfortable with the Unity api overall should help you be able to read the docs more easily. State machine, you would be able to lookup and isn't solely dependent on Unity.
I think for now I'll start with unity's official pathways to get comfortable with the engine itself. I can learn more general concept like state machines later. thank you for advice
Oh I just remembered. Yeah they are up to date too. AMD Adrenaline Updates Everything. Maybe it's BIOS related?
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
oh whoops, didn't notice this was #💻┃code-beginner - i shouldve redirected
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.
but your O/S isn't Windows
is it not? there's C: and .exe
Oh sorry didn't know
ah, the text is too small for me to read.. I was going off the top right, those buttons look wrong for Windows
maybe unity's cache is corrupted and it gets stuck somewhere while loading? have you removed the cache files and reinstalling it?
read the channel names and channel topics
Yes, When I completely remove all files and sanatize my whole system of any unity files and then reinstall. Then it works fine. But only for the first launch again.
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?
I would probably delete unity-hub stuff as well and reinstall that too. and maybe try to install 6000.2 next time. maybe it's a bug related to 6000 lts that should be addressed
6000.0 is LTS, if it were a bug that was "fixed" in 6.2 then that fix would be backported to 6000.0
True that
anyways let's continue in #💻┃unity-talk
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
}
you should not have multiple unity Objects (specifically, MonoBehaviour/ScriptableObject or classes that derive from those) defined in the same file
any reason to that?
so that would be putting the 4 InventoryItems in separate files
because the file itself is referenced as the source of a given object
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
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
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
Place each class in their own file . . .
that sounds a bit too advanced but yea i get the point thanks is it fine to have atleast one enum in there?
sure, it's specifically stuff that derives from ScriptableObject and MonoBehaviour (iirc) that unity enforces to be in separate files
Understood thanks
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?)
I would just get used to using a separate file for everything. It makes it easier to find and edit the type when needed . . .
its still corrupting
its to maintain the current item state in another file
maybe that was some old cache issue
@tender mirage you'll also need to answer this
Oh sorry, i didn't think that was for me.
😅
but nah, i'm good, don't need help anymore
👍
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
;
}```
don't worry about efficiency
think about what makes sense
consider if it might be triggerable again while it's still going on
That is possible for both methods
i mean, do you want it to be
A third option would be subscribing some function to an event where you'd invoke those behaviors in some update method etc
and how do you want to handle the logic for that
Also, I wouldn't check equality with a float value . . .
draw/plan that logic out, and implement it according to the logic
It snaps, don't worry
i mean it's technically fine with MoveTowards, no?
ooh but it might not work if it were parented
I will get to that later. I'm trying to get the hang of coroutine
It would be similar to the bool alternative but allowing you to interchange the behavior, if necessary.
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?
does it make a difference?
no
use what makes sense
just use .Contains ?
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
no need for a loop of a dictionary when checking if it contains a key
i iterate through every value anyways
okay thanks
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
ahh okay that makes sense thanks
hi 
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?
Not really. It's fairly common to have empty objects for various systems or managers. You could maybe reuse the same object for all your systems/managers including timeline, but it could become messy from the organizational point.

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)
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)
rasterizer ? 
You need to profile it. But generally, 90fps is good enough. Start worrying when you can't get stable 60.
*9. it drops to 9
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
i think i doint have to explain which frame it dropped to 9 frames right?
what should i do instead?
maybe you can split all this stuff over multiple frames?
thought about that too but how do i do that? IEnumerators? thats the only thing that came to my mind
yeah as john said, you can maybe use a async fonction?
whats that?
or as said, coroutine
You need to look at the profiler details. See what's taking most of the time. It seems like you ultimately need to loop all these tiles/voxels, but it doesn't have to be done on one frame as mentioned.
tbh i have no idea how i should implement a coroutine into this
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
}
}
width is 32 and height 128. i could definitely shave down the height though
jesus
but in task is same
so it's running the task 1966080 times
it not worst than the screen size
sounds about right
are vertices and triangles Lists?
yes
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
that's gonna be a lot of copying internally
marching cubes algorithm
if you do need the data, you could pre-allocate it to avoid copying
what do you mean with allocate?
do you know how lists work internally? just briefly
not exactly tbh
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
thats about what i thought it would do but as i think about it it doesnt really sound very great
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
so width * width * height?
no, it'd be width * height * width * 5 * 3, going by the loops it's in
oh yea ur right
so i just call that function somewhere? i didnt understand it fully i think
you call that after you clear it
doesn't we call it before asigning ?
..which is after the Clear call
oh
if we are in c i had use reallocate lmao
you can use .Capacity = ... instead
that seems to work thanks
do i do that with my triangles too? what size should i give it?
must be in .net constructor
the same, since you're adding to it the same amount
i'm talking about ensurecapacity, not the initial capacity
oh okk xD
okay
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?
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
bro what
hahahaa
i like your funny words magic man
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
i think we still need to address the elephant in the room meaning all this being executed in a single frame
it is too heavy for one frame
yea thats what i mean
how do i break it up into a little less giant tasks for my cpu?
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
}
}
coroutine is very easy
dont have a lot of experiences with them to be honest
i used them in my chunkManager but thats mostly it
try this before , i am also learning so maybe there is better way
prolly because i usually dont make algorithms as expensive as this one
okay ill try
if you want it go faster ( because here i split it into a lot) you can move the yield return one line down
how do i check if a gameobject is enabled or not?
gameobject.actifself
thankss
gameObject.activeSelf or gameObject.activeInHierarchy depending on which functionality you want
i dont know what happened but my algorithm completely broke and no chunks are generated 😂
Because it take a lot of time
You have height x width x width frame before it finished
I said here if you want going faster but your cpu will have more task
Unitask is faster but is more complex
yeah thats not optimal i think that comes out to around 46 minutes for one chunk 😂
tried putting the yield return in a different loop then?
its in the first loop now but its still taking to long to notice somethings happening
Di you still crash ?
performance is great but at what cost

make it trigger every 100 loops then for example. or something like that, idk how many loops you got in total
you can try different numbers and see how that does
how do i do that?
you can add a variable that you increment with every loop, and if it reaches 100, you set it back to 0 and call yield return null
ah yeah
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 ...
}```
i tried printing out something when it returns but nothings happening idk whats going on here
You know what? Use async 
i thought implementing marching cubes is hard but making it not slow is a lot harder
prolly a good idea
It is same but the return is a bit different
i changed it back to how it was before and it still doesnt work 😭
not even gonna try this tho? 😭
you might even be able to combine it with async too i think

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
show us then?
if you wanna continue doing it, that is 😔
Im just so confused how this shows up on one image but doesnt on the other
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
how what shows up exactly? the event in the inspector?
One second I think i figured it out.
sure, that would work
i mean, if you aren't talking about code, then any way that makes it clear and unambiguous works
since there's only one Feet object, you could say "Feet's collider" too
I want to avoid confusion in case someone might think Feet has a collider component that is different from its child, but I guess that's up to me to clarify to begin with
Thank you for trying to help but I realized I just forgor to make something a public void.
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 ^
why does it loose ref once in game?
is the slider in the scene?
or did u assign it from a prefab or something in the project window?
as in?
i made the change in the prefab
as in is it a GameObject that's already in the scene..
no
show the instantiated gameobject's inspector in edit mode
hows that done?
u can't assign prefabs to scene references..
and u cant assign scene references to things contained inside a prefab
edit mode
u have to make those assignments @ runtime
pretty sure that's not what's going on
the ui is part of the prefab
edit mode is just when you aren't in play mode
show the inspector for the UI gameobject in the scene, while outside playmode
seems to be fine
click the PlantIndicator and show us what gameobject it shows
its inside Plant isnt it?
so it isn't being overridden by the instance - it's probably (most likely) getting reassigned at runtime then
if it were an asset referencing a scene object it'd be showing Type Mismatch
Question how would I reference this to this.
ahh ok
then my 2nd guess is somethings setting it to null
what do you mean by "reference"
why would it get reassigned?
most likely code you wrote
code reassigning it to something it cant find
you told it to assign something there
Like have the random range number be where the 1 is.
it happens to assign null
if u assign it in the editor u shouldn't need to assign it in script
exactly
thanks
what exactly do you want
what's the goal
all good.. this is how u troubleshoot 😛
To have the random number that was generated be in the numbers place.
so this is always the case?
for scene objects referencing script/project objects
you want beans to be a random number, randomly selected when the object is created...?
Should I send a bit of context.
this is sounding like an x/y problem
context always helps 👍
wouldn't you want to update beans to some random number upon something happening, rather than it being set once?
well, the inverse, but afaik yeah
ok cool 👍
`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()
{
}
}`
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
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()
{
}
}```
what is the goal
yea theres no context there lolio
(btw copy text is a thing)
The goal is to have the output of Beans++ be whatever the random number is example
Random number is 8
Beans = Random number/8
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
you're still thinking about the code. what is this for
when should this happen
when AddBeans is called? when CreateBeansPercent is called?
what is the flow supposed to be here
Okay so I want the random number to be added to total beans and whatever the output of the random number should be how many is added to the total number of the beans.
you want to add a random number of beans to the total
Yes.
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.)
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??
isn't AudioListener a singleton
ya i had no clue
I try to get the random number output from another script but it does not notice it.
what do you mean by "notice"
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
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
see above
put a little thought into the structure and flow of your code
ohhh QualitySettings.SetQualityLevel((int)user.quality); works like that too
wow.. the things u learn.. 😅
Elaborate?
Im still confused
hmm isn't that like an Application-level kind of setting, so it would have to work that way
which part?
The part on how to turn it into a variable.
ya i believe so.. im still lookin for sources that spells it out a little better
Yes.
what's the name of the class that has CreateBeansPercent, for ease of communication
'public class RNG : MonoBehaviour'
you would have an audiosource that you trigger there
for basic stuff regarding that you can just google audiosource, or really just unity audio
okie dokie
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
{
// --- 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
}```
thanks
making a member into a local variable would be like this
- int x;
void Method() {
- x = y;
+ int x = y;
}
✨ lets encourage people to look at the docs
https://docs.unity3d.com/ScriptReference/AudioSource.Play.html
might want to check out the two different Methods.. and see which one fits ur use-case better
Idk if this matters but i have it like that to display the Random number you got to a TMpro.
OneShot() can call a clip just once regardless of what clip u already have assigned
then you would do that via in the class that manages beans too. if it's a centralized text object, you would have a reference that other classes can use to display text
keep ur logic and ur UI/Display seperate
do all the logic u need to do first
and then convert to strings or use string interpolation or w/e you need to to display those values
@mortal grove you really need to just step back and plan things out so they're in places that make sense
Ima try to figure this out give me a second.
why is the class you sent before "MORE_BEANS"
pretty easily to do.. since u alrady have variables
i have a feeling it just..doesn't need to exist
// --- 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}
Well it's not the same, it's better!
lol.
ngl there.. It is better.. never went back to concatenation
always had to go back and add extra spaces between the +s
js string interpolation is similar but a bit weird
var awesomeString = new StringBuilder("Hello ");
awesomeString.Append("world! ");
awesomeString.Append("c# ");
awesomeString.Append("is ");
awesomeString.Append("awesome!");
Console.WriteLine(awesomeString.ToString());``` 
distribution of $
yea and I dont like how you use ` instead i always forget when i return to do some javascript
JS is just weird, so weird infact that we need TS to make it acceptable
i implemented 9.81[m][s[-2]] into ts a few hours ago, for fun
there's a more horrendous version focusing on Date, too.
i can ace the jsisweird thing since there are still rules even if they're really weird
but the Date one, man..
https://jsdate.wtf/
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
you should not do it like that, no
you would make it use the return value
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?
Whats wrong with the approach?
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
..maybe? that really shouldn't be happening. you sure you aren't modifying the scale anywhere?
You got 3 out of 25 correct!
holy crap, im glad i don't use js
that syntax is crazy af
try the date one 😈
Yeah but im not sure how id use the value if its assigned to a local variable? I usually use passthrough if i want my variable to be equal to the return value of the method
Ima take a break because I do not understand anything yall are saying.
not sure what scenario you're referring to there?
Im not sure how you call the "return type" from a method
You call the method if you want it to return a value
Thus i would need to use passthrough yeah
whoops, didn't mean to send that yet
beans = BeansGenerator()
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;
}
Oh i see
Slightly different
Memory wise this is more efficient than passthrough if im dealing with such small data i suppose?
Mmmhm
what "passthrough" method are you referring to anyways
that's not a term used for singular function calls
what the hell is a "passthrough" I never heard of it
Passing
yeah no, not the same thing
Your use of pass-through is the confusing part . . .
Uh huh
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
pass what to what?
Do you mean, pass the variable assigned as an argument for the method?
His method
I suggested that as a fix instead of using void
its possible hitting something else.. we dont know until you provide info on the setup
Yup
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
Mmmmhm
gonna need a bit more context than that
seems overconvoluted for a simple usecase
What? That's even more confusing . . .
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?

(what's this referring to, i lost the plot)
ya thats what I meant
as in...
not enough info to decide
probably not static though, were you thinking of singleton
Im not sure how? How is my programming logic so bad?
Static methods and fields can be called/accessed from any script without needing a reference to the class. Is that what you need?
class static itself means you cannot use any inspector reference or anything
i mean, it could go either way. up to your design
i just want to access the manager from any script via the players code
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
did you reply to the wrong message here or something
just use a singleton
thanks
Ohh I was talking about the passthrough thing seemed over convoluted .
They said, "it depends," because we don't know if the class will have variables you need to edit/inspect from the editor, or if it saves state, etc . . .
most times my static classes are like utilities that have "self-containted" method
kinda how unitys Random works
I think a singleton mono manager is a better way to go for a beginner
So I'm following a tutorial I had added a Gameobject and then added a 2drigidbody component which the tutorial said should make it fall down but instead it flashes up
That's kinda what you use methods for. They should really focus on one thing. Keep them small, modular, and easy to expand . . .
what about colliders ? and what other components on it
a rigidbody without collider ? 🤔
Let me make sure
Without a collider, it should fall through the world . . .
Sorryabout rhat
I was asking more why pass is overcomplicated
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
Oy component on it
so it just flies up ?
Yes
check the Y value to make sure it's going up and not down
Mmmhm
If using with a value type, you already run into a problem. You'd need a ref modifier to retain its value since value types are copied when used as arguments . . .
is the camera parented to it ?
use scene view when checking if stuff is going down/up
lmao
If its y value is going down, then it is indeed moving, otherwise, its position would not change . . .
just FYI next time this go in #💻┃unity-talk at minimum. this is a code channel
Thanks
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
Test the audio file in Unity to ensure it plays correctly . . .

I have, it does
is this channel for help with anything related to the unity engine or just code (or C#) ?
just code
oh okay
Make sure your AudioSource has the clip (file) assigned to it and the volume is set . . .
I have
do you have an AudioListener in the scene
The channel is for beginner coding . . .
Make sure there is an AudioListener in the scene . . .
yeah ik now, sry
where's the listener
No problem. You can always read the channel name and click on it to see its description . . .
on the camera
yeah
it's on the camera
oh wait, the screenshot you showed isn't the camera lmao
you sent that right after the "yes it's on the camera"
xD
try making it 2d sound, to check if it's just too far away to hear
How would I do that
oh wait it is 2d
xD
i saw the 3d sound settings window open and thought it was 3d lmao
sanity check - the Played log is being triggered, right?
yes
do you see the audiosource being cloned?
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);
}
}
was it asked check just the scene view / gameview muted ?
that hasn't been confirmed yet, yeah
I'll be back in 5 mins
have you set the instance yet
Ah i see... im just wondering what possible unintended consequences are of this
Does this mean to imply that I wont actually be able to update the source value/original variable for beans? It seems like it should work if i pass the value and just assign that returned value to my variable
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];
}
}
just to be clear
TeamManager.Instance.addPlayersToTeam(gameObject, 0); //Here is the error pointing to why does it not know what Teammanager
It knows about TeamManager but it doesn't know which Instance you wanted
yes just making sure
I see how edited the 3D Sound Settings. I would reset them to check if the sounds plays correctly . . .
it's set to 2d
I've moved it to another object (one that never moves)
why cant i see these fields in the inspector?
editor bug
select a different object and reselect this one
properties need an attribute to be serializable: [field: SerializeField]
Team wasn't made non-serializable in the 10 minutes since the last question, right?
thats for pvt tho
Dictionaries aren't serializable in the editor and neither are properties (unless you add the field: SerializeField attribute to the property
is team an enum ?
not really, no
umm its not monobehavior anymore yes
ok, then nothing there is both serializable and marked to be serialized, so nothing got serialized
and you need to serialize Team for it to display from the inspector . . .
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
it still needs to be serializable
Either way, it must be serialized . . .
cool, wouldn't solve it though - you need to also mark it Serializable
do we need 3 people saying the same thing?
well one of them was wrong
no. maybe 4 will do
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
damn, forgot that was a thing. i was typing that out 💀
I hate that this docs doesnt let you link / anchor the headlines..
this can't be an SO, you're referencing scene objects
the docs for Packages does, this doesn't. I hate it
Everyone happened to respond at the same time. At least it gets the point across . . .
scriptable objects was working fine ig ill just use that
probably a poco
whats a poco?
and why do u think thats the best
don't add complexity where it isn't necessary
they are easier to create different settings at runtime if thats what you want to do and make new teams
up to you though, use whatever is easier
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
Those variables look like they are gonna change in runtime. Ain't that a no for a SO?
you probably need some sort of state management so the falling doesnt play during a double jump
You'd use a ScriptableObject for a specific reason, namely, immutable data, base/default values or settings
Struct would be for a small collection of data (mostly, if not all value types)
Class for many fields, usually a mix of value and reference types, and mutable data . . .
you mean to change something in the animator window???
It could be how your animation states are setup . . .
What are the best method to store the datas for player inventory? Should I make them as scriptable objects, json, playerprefs or anything else?
btw you probably wont laast long here with that Profile
loaded question
there is no "best method" either
Store items in a collection and save the data to json . . .
That's not the best, but the typical way people do it . . .
storing where exactly? is this runtime ? between sessions ? both etc.
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 . . .
is there a way to see the values inside of these elements in the inspector?
naughty attributes or your own custom inspector
what is naughty attributes?
okay i see
tho how hard would be making my own inspector?
depends on your skill level
lets say average
could you tell me the solution pls??
Just try it and see. Thou if it’s not something important u can just skip it
look up tutorials and it's easy, will take some time though
what should i exactly look for
custom inspector
You mean collection as in like an array or list of classes?
lookup the source for https://github.com/dbrizov/NaughtyAttributes?tab=readme-ov-file#expandable
and you can probably do it similiar or just use that
Yes: array, list, dictionary, etc . . .
I dont know much about animation... also what exactly am I supposed to help someone racist
That sound easier
I was following a tutorial and it asks me to use scriptable object
okay its jst an joke vro . Dont take it seriously now okay?
Is using the N word supposed to be cool or edgy for you ? I don't get it..
I already seen it, tbh I dont wanna help you
I should've just called a mod before anything 🤷♂️
When creating items for an inventory, a lot of people use SOs to represent the immutable data. Usually, the item has an Id, so when stored in the player's inventory, you reference the Id to look up the SO and retrieve its data . . .
did i said it to you? I know its not okay and yeah i am sorry okay now? Jst help me out mann 😭
ask someone else then. I'm not helping a racist
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
!ide
If your IDE is not autocompleting code or underlining errors, please configure it.
Select one:
•
Visual Studio (Installed via Unity Hub)
•
Visual Studio (Installed manually)
•
VS Code
•
JetBrains Rider
• :question: Other/None
show entire line
there used to be a debug box here but its gone how do get it back/
you can connect the console in editor to dev builds
id do that instead to see the exception msg
how do i do this
click the lil dropdown that looks like [Editor \/]
then pick your build thats currently open
done that but im not getting any error messages
im so confused ive been tryna solve this shit for so long
put some logs and debug color and indexOfItem
you can also attach a debugger if you enable script debugging before building
either way more information would help narrow down what is null
there's gotta be more to it..
so its working log
you should probably debug also dropdown to see if thats not null
though if its grabbing the correct values its probably not null
!ide
If your IDE is not autocompleting code or underlining errors, please configure it.
Select one:
•
Visual Studio (Installed via Unity Hub)
•
Visual Studio (Installed manually)
•
VS Code
•
JetBrains Rider
• :question: Other/None
it does unless you reloaded it via PlayerPrefs
objects reset on scene switch
is that why?
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
PlayerPrefs is unaffected by scenes. Even I am confused by what you just said
I'm saying if you save a value in sceneA, you need to Set PlayerPrefs there, then run playerprefs.get in SceneB to get the same value
so they should make sure its running Get again in second scene to grab their stored int
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
yea I had a feeling that might been case too
cause the logs are printing and they are not mentioning any NRE now 😔
so what is appearing in the Console window in editor ? should be able to see a stack trace
what steps you did to cause this error to appear
then dropdown is null
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)
it's the :14 that refers to line 14, the .cs is just part of the filename fyi
do you happen to know if this problem is resolved? it's not clear to me from the issue comments.
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
its making a copy when you modify it
is there a way to not create a copy
and have it apply the changed material to the target
you modify the sharedMaterial
that will change it to every object with that same material though
wait targetColour is a material it should be changing it globally no ?
I forget how Unity does it
i have no clue
anyway first it worry about fixing your NRE lol
then test the material thing
Materials are shared until instanced (so modifying the material asset will affect everything using it)
no only when you access material from mesh renderer
THEN unity makes an instance for you
didnt it depend on whether you access .material or .sharedMaterial?
yes but we're talking about an asset not the renderer
Here they have a serialized ref to a material so this is not relevent
so changes to color of the serialized material will persist in project ? (at runtime)
changes to assets do yea even post play
right..makes sense
anyway like I said, the doc page for renderer.material mentions that it makes an instance for you
oh thats interesting, how do you access asset via code though? .material and .sharedMaterial are not the asset as far as i understood now.
.sharedMaterial just ensures it wont make an instance unique for this renderer for you
.sharedMaterial will not create a new instance
.material does when modified
yes.
and to be clear. UI graphics have no such behaviour, no auto instancing happens for them
yeah but only a runtime instance right
for .material
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()
anyway did you search your hierarchy for second script ?
t: changeTargetColour in your hierarchy
Nah, you would need to just like if you created a new material
ah okay thought so 
ye
I just ended up making materials in editor and just swap them instead of directly changing material properies.. avoids heaaches
you found the copy ?
i dont think there is a copy
atp that might be the easiest way
if its saying line 14 is null. the only thing that can be null is dropdown
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
weird..do you have collapsed on ?
whats thta
in the console, it says "Collapse" check thats not toggled on
I added a hasJumped bool in my script and it doesn't work "properly" when I jump the bool is check then immediately unchecked. any ideas?
how did you verify that
it not
ima be honest i think i might just create seperate materials for each colouir will that sovle my problem?
with the NRE ? probably not.. you need to narrow down whats causing nre
i want to push my code to github where can i find a gitignore file?
on github / google
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
okay i was using this i still have like 10000 files in there 😭
So is there a way to map a ulong to a long then back again?
depends.. you have to put it in the root of your project
They are both 64 bit values so there should be a way right?
and are they like, actual assets?
this place right?
(long)x
(ulong)x
when you jump it doesnt go checked?
yes
no randomass stuff
such as?
That wont work will it? wont it just trunctuate the data?
just fyi you need it there before doing an initial commit , otherwise its too late and should redo it
it does but only once and it happens in a split second
no, it'll overflow/underflow, but reversibly
do i need all this stuff?
yes
those are not "randomass files", those are parts of assets
without them all your references will break
okay then seems fine now thanks
if they're under /Assets, chances are you want them
does this mean that if value of ulong is greater than long.maxValue it will make it a negative value?
you don't want stuff under Library
yes
perfect
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
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
are you chaning it only on grounded?
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
Its only public so I can call it in the groundslam script
This is what I've got in the ground slam script and it doesn't work anymore when I add hasJumped
you need hasJumped to stay true until you land
Does my script not already do that? when grounded it becomes false when not its true
put a log inside where you do hasJumped = false
and see if thats called at some point, maybe on the way up ?
just a debug.Log?
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);
}
}
}```
you can't modify a collection while iterating over it
in a foreach loop*
with its enumerator* (which a foreach uses)
basically foreach makes it immutable
for loop works, but you want to do it in reverse because you will have items being skipped
should i add it to another collection and and remove it after iterating over it?
that doesn't work here, it's a dict
that could work, sure
oh true true
okay thanks
So its working then? When I add it to slam script the player can no longer slam anymore
hmm, some languages have the iterator (or enumerator in c#'s case) implement a delete method, seems like c# doesn't
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
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 $$$
have you considered using the fps animation framework?
🤔 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
this is the code channel, wouldn't this be an #🏃┃animation question
No because this is a coding question, doing a full body controller is codewise
I want to avoid using Frameworks to allow customization down the line for my changes, FinalIK would be my limit of any assets to use if it would solve the simplicity of doing things.
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
Fair, but I want to avoid those to be honest. There will always something down the line that will be blocked because of limitations of an asset, as much as I want to use something like that I've just hit blockers and blockers using some assets and have just had to write my own solutions for weeks to get it to a state I want to do.
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
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 🤣
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
yea FinalIK is a bit more polished than the one unity made (Animation Rigging)
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
ouch it looks dead argh
how much could you really be talking about a simple asset.. its pretty straight forward
Let me buy and try lol
I'm sure if you have specific issues you can always DM or Email them
i feel like the documentation is pretty standard
all things considered
theres also a shit ton of youtube videos
Bought it, will give it a try thanks guys.
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/
Not sure the setup is pretty different, I'm still on Unity animation rigging package. 😢
I heard good things from a few dev friends
Ah fair enough
Is there a way to set a variable in the inspector using binary?
0bXXXX doesn't work
Wouldn't an integer suffice?
not built into Unity. You could make a string field and parse it yourself if you want. What's the use case here? A bitfield of some kind?
Ah, unless you wanted ones and zeros.. string.
you could make a bunch of checkboxes with a custom editor - one for each bit
It would, but it'd really be awesome if I could use binary
That sounds like a good idea
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
#↕️┃editor-extensions if you want to go down that path
Sure, thank you
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.
Don't worry about it, unity editor issue doesn't affect game
https://docs.unity3d.com/6000.3/Documentation/Manual/performance-gc-avoid-reflection.html
Is this true for typeof() too?
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
did they change the syntax? cuz earlier it was like this only
okay found the docs nvm
why isn't my game loading in the web site? they're inside the same folder
https://paste.ofcode.org/3aLZA7EY36LEPqKbqkJKE4W
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
(we don't know what the errors are)
That's the thing, is not giving me an error on the console only the code. And it just seems like it doesn't recognise it as a parameter you can edit
