#archived-code-general
1 messages ยท Page 275 of 1
again, it's trying to open a box using the knife which is inside the box
But the JSON is the message I receive from my websocket server. I think I can only send strings to the ws client
JSON is not the issue, if you have an arbitrary payload that you do not know the type before hand, there is no way for you to deserialize it regardless of format, and always requires you to add a tag to indicate what type it is.
I can use bytes for sure but I think WebsocketSharp which is the package I am using parse the bytes into an string because I am receiving a string from the function
Networking messages are like ogres, you know
This pattern is very common, some languages call it tagged union, some languages call it discriminated union, Rust simply calls it enum, but they are all the same thing.
except json, like xml, is an all or nothing format. binary serialization using a competent binary serializer does not have this problem
im new to unity and coding is there anything that can help me get more info about the code ?
Newtonsoft and STJ both support this.
In that they have layers
So is there any solution to implement a ws or cross connection between two clients and a server without the need of serialize strings
WebSocket protocol supports binary messages, so presumably that library you are using would support it too.
No. Serializing is how you store data in a transferable way. So Sending data without serializing is a paradox
How you serialize is up to you though
Okey and with that I won't have any problem? As I could sent an int (message type) an then set the payload as the type I want
actually the .Net JSON source code is available from git and iirc it allows deserialization to json objects thus removing the need to have a defined class
You just need a tag to indicate what type the payload is, and then the payload.
So like ```cs
int myType = type I get
if(myType == 1){
Type1Payload payload = mypayload
}
you can serialize your type as byte array then send it directly
switch(type){
case Enum.Int:
int val=*((int*)buffer);
break;
case Enum.Float:
float val=*((float*)buffer);
break;
....
}
Basically yes, and both Newtonsoft and STJ have features for this already.
So you don't need to reinvent the wheel and write that giant switching on type yourself.
Why not just cast the payload and see if its valid, else try another type
Sorry for the ignorance I am not used to work with those things in c#. The enum contain the possible int types for all the messages I will send? And then why are you setting a variable that could be a float or either a int?
In my case I thought about a possible solution by making messages to have a metadata property and having all the possible payloads as properties but only the right payload been set so I could check if the payload property is set to check the message type and making only one class as the type of the deserialized string
you cannot cast it to check if it is valid since a byte array can be everything
so you need a header
What de/serializer are you using? Newtonsoft, STJ, or just JsonUtility?
Im still assuming the payload is json string ๐
you are trying to parse, though this is valid option but costs you much time in parsing.....
that's one way, i think you could also hack it by having a single "base" class with just the type ID, deserialize to that first then deserialize again to the proper type when you know what it is... whether or not that's particularly efficient probably depends on whether the JSON library ignores the other fields or not
Newtonsoft and STJ both support polymorphic deserialization without you having to reinvent the wheel.
NewtonSoft
Oh sorry I want to convert a string representation of a JSON into an object. Not converting the object into a string
Yes, the page's example also includes deserialization.
thank you, first person here who actually helped me and wasnt rude. I appreciate it loads! โค๏ธ
So ```cs
public abstract class Message {}
public class SessionMessage: Message {
public SessionMetaData metadata; //custom metadata
public SessionPayload //custom payload
}```
And with this it would fit in?
You don't need the metadata, Newtonsoft adds the type information for you.
Well, assuming you are also using Newtonsoft on the server.
In that case go with https://www.newtonsoft.com/json/help/html/SerializeSerializationBinder.htm
It allows you to specify what $type strings map to which classes.
So I can make a $type property to be set as the type in the metadata?
And then check and re-deserialize with the correct type?
No, Newtonsoft will do that for you
On the server side, you need to send a message with "$type": "itsABurrito"
On the client side, you need to implement a binder that says "if you get itsABurrito, use the Burrito class"
And that's it, Newtonsoft will do the rest for you.
By implementing a binder, see the example linked in the doc.
yeah
I saw it
I will implement it using a dictionary for the types
thanks for the help
I think I'll come with another error as I think the problem with the use of dynamics of yesterday is not the source of my error with binding a null reference
You don't have to use a dictionary unless you plan on adding types dynamically at runtime.
You can simply use a switch expression:
return typeName switch
{
"itsABurrito" => typeof(Burrito),
"itsATaco" => typeof(Taco),
// ...
_ => null,
};
Hey guys, i'm having a discussion with a friend regarding queues, and we are not the smartest tools in the shed, so we chatgpt'd. i said that If you peek twice, you get the same object, but he and chatgpt say otherwise. Also, the discussion started regarding if it would be more performance efficient to cast a big queue to array list, or to dequeue and enqueue in an aux queue until reaching the needed object when random accessing. it would be only once in a specific use case when we apply predefined attributes to a random object. But then he pulled the "peek twice and save in reference and you'll get both peek and peek+1" argument
I'm not home so i can't test it right now
Peeking doesn't affect the queue
and how I can access to data.payload as in the example the deserialized result is represented by object type which don't have payload prop
You don't need a payload property anymore
It's definitely hallucinating about calling Peek twice
and how I can access to the data on the payload. I'm using dictionaries for test then I will switch to what you were saying.
Look at the example in the binder documentation, you don't need a payload property anymore.
and this is why you don't use AI spam bots, they sound authorative but spout bullshit
Now that you have an object, what to do with it is up to you. You can either switch/pattern match its actual type, have a base class/interface and call the methods directly, or do whatever.
In the example there is not log or anything related to the output when deserializing
yeah I don't know what is the output
and how to access those properties that were in the payload field
Either of these.
Eg:
switch (data)
{
case SessionWelcomeMessage sessionWelcomeMessage:
DoSomethingWith(sessionWelcomeMessage);
break;
// ...
}
Or:
interface ISessionMessage
{
void DoSomething();
}
class SessionWelcomeMessage : ISessionMessage
{
// implement DoSomething() for your messages
}
var message = (ISessionMessage)data;
message.DoSomething();
so newtonsoft is returning me a class? okey
@chilly surge thanks I'm getting the class now I will create a method handle() or anything like that to handle each message and only make like data.handle();
Do keep in mind it might be a bad idea to hard couple your messages with their handling (conceptually it also doesn't make sense for a message to "handle itself")
okey I used the switch you made
๐
my doo doo brain cant understand the docs, how do i get offset vectors values of the tiles to set to camera position?
i have tried the following script:
themats1.SetVector("Offset", new Vector4 (0, Camera.main.transform.position.x,Camera.main.transform.position.y , 0));
am i doing this wrong?
how do i get offset vectors values of the tiles to set to camera positio
Can you first explain what this actually means?
What are you trying to do?
also "Offset" is definitely not the correct name for that property
to set the texture offset of the tiling to camera position
i cant find anywhere how to do it
what does that mean though? That makes little sense
texture offset is in UV space for this particular mesh
camera position is in world space
what are you trying to accomplish
why would that involve the camera position
Set your inspector to debug mode to see the shader properties
oh, hold on
mainTextureOffset should work based on that yes
it does not work,
this is how i tried
themats1.mainTextureOffset = new Vector2(0, Camera.main.transform.position.y);
(small notice: themats1 has assigned value with the material of the object's texture)
What's not working about it?
are you sure the camera position is changing?
open this inspector while your code is running
you should see it update
the vector2 works well, tried debugging the camera position, but it does not move the texture
but it does not change the maintextureoffset
Add Debug.Log
did like this
themats1.mainTextureOffset = new Vector2(0, Camera.main.transform.position.y);
Debug.Log(themats1.mainTextureOffset);```
i did the mats debug log before change value
looks like it's working
no idea what you're logging though
i expect a Vector2
its the Y of the vector changed, the X is always 0 as it's set every frame
Debug.Log ("The material offset: "+ themats1.mainTextureOffset.y.ToString());
well looks like it's changing just fine
i believe the best solution is changing the value from material like i tried before, but i dont know how to get to that offset
this is the current attempt:
themats1.SetVector("Offset", new Vector4 (0, Camera.main.transform.position.x,Camera.main.transform.position.y, 0));
isn't this the same thing? As I mentioned before doesn't that change as your code runs?
It's Definitely NOT called offset
as you can see in the inspector
i know, but i dont know what to put there
_MainTex but i believe it wont change the offset if i put it between ""
nowhere in the docs specify about getting the.... "child" (Second then Offset) of the _MainTex
for me the docs are alwasy confusing, i cant understand it, unless it's basic simple stuff
based on this SetTextureOffset or jsut mainTextureOffset should work just fine
I mean I did point that out before... #archived-code-general message
how can I make in game objects clickable if I am viewing the game thru a canvas?
void Update()
{
if(Input.GetMouseButtonUp(0)){
Physics.Raycast(ClickCam.ScreenPointToRay(Input.mousePosition), out RaycastHit hit, maxDistance: Mathf.Infinity, layerMask: Buttons);
if (hit.collider){
Debug.Log($"{name} Clicked");
hit.collider.GetComponent<ButtonGame>().OnClick();
}
}
}
heres the code that worked for a project that wasn't thru a canvas
now I am facing an error which at trying to get a tmp text by its name https://pastebin.com/qBhux2Hz. I don't know why, I'm facing this error since yesterday and when I try to develop another method always is throwing me this error. I have the object created as you can see in the image. And the questionbody is a tmp_text.
the first question to ask is what is in your layerMask?
same result whether or not I include layermask
however I do get some result, in that it will end up either clicking the far wall or the wall to my right, but nothing else
even when I click on say the left wall
You can start with some basic debugging, by figuring out when it's getting called, if it's unable to find the game object or if it's unable to find the component.
hmm it may have something to do with the fact that my main camera is rotated? because when I change the rotation different objects come up
it's such a werid thing that I attach the text into another script from another singleton I log it in the start method and it logs but then I log it in another method and surprise, null
ok so it clearly has something to do with the cameras rotation
but im not sure where to go from there
pretty sure this can be done in a shader (according to material local pos or world pos) which is faster I'm pretty sure
this is done in a shader...
he if offsetting the texture using a c# script
Materials are just a shader and a set of parameters around the shader
yes a C# script is required because he is basing the offset on the position of an object in the game world
which is an object in the game world
You can get camera position in a shader
Sure you can but all we're doing is setting a shader property which is very cheap
It is cheap but there is always cheaper
cheaper is better the lower the specifications you are targetting after all
hmm got it closer
but now its like offset
how can i scale a Sprite/Spriterenderer to fit the bounds of a rect transform?
public class MapBackground : MonoBehaviour
{
public Sprite sprite { get; set; }
void Start()
{
sprite = GetComponent<SpriteRenderer>().sprite;
}
void Update()
{
RectTransform mapContainer = GameManager.Instance.InGameUI.MapContainer;
//scale to fit the map container while maintaining aspect ratio, focus on width then height, this is a simple sprite that exists in the world while the mapcontainer is a UI image
float containerAspectRatio = mapContainer.rect.width / mapContainer.rect.height;
// Calculate ratio of sprite dimensions
float spriteAspectRatio = sprite.bounds.size.x / sprite.bounds.size.y;
// Determine scaling factor based on which aspect ratio is larger
float scaleFactor;
if (containerAspectRatio > spriteAspectRatio)
{
// Container is wider, scale based on container height
scaleFactor = mapContainer.rect.height / sprite.bounds.size.y;
}
else
{
// Container is taller or equal, scale based on container width
scaleFactor = mapContainer.rect.width / sprite.bounds.size.x;
}
// Apply the calculated scale while maintaining aspect ratio
transform.localScale = new Vector3(scaleFactor, scaleFactor, 1f);
}
}```
mfw forgor highlighting
that is my current code, but the background sprite is much too big
```cs like this instead of just ```
im aware how to do it
its currently doing this onupdate so i can use hot reload and see the changes live
in the future it should only be called once
I could try and do it my just making a box of screen coords but that seems terribly inneficient and would struggle to work if the resolution changes
basically i just want my background sprite within the clear area there
thats a better example
it is an image, if that helps
maybe I just try to do it with UI buttons but that would look off
i need physics though
no idea why this script isn't working on this project I would think it should
its gone through many iterations from gh copilot, chatgpt, bard, whatnot they all say its correct
thats what ya get for trusting AI
is the background expected to change? like the amount of space it needs to fill
no
different resolutions
so different resolutions shouldn't matter?
the background is a sprite
so resize it to fit in the box
still no idea why this isnt working
I'm sending the camdata to a rendertexture does that mean that I cant do Camera.ScreenToWorldwhatever or anything similar?????
ugh I'll just do this the slow way
It could be possible as I am testing my game via websockets running the build executable and the game in the editor that when I focus my window on the build executable and my app change a text in the build game it changes but in the game of the editor an error is thrown as there isn't an instance of the text. I think is because of that as I am focusing on one window instead both so, how I can know with an script when the text loads successfully and how I can set the screen size from full to other one in my build application?
Anyone know why this never makes it past the yield return uwr.SendWebRequest(); ? I tried a bunch of random image links
Is it possible that whichever GameObject is running this coroutine is being deactivated or destroyed?
ah I think thats it thanks
that's also the very first yield, if this coroutine isn't being started correctly (such as by just calling the method directly instead of using StartCoroutine) it would stop at the first yield
gotcha thanks
!code
๐ Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
๐ Inline Code
Surround code with three backquotes. Not quotation marks.
To 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.
So right now, when I move and smoothing is on, the hands kind of fall back, because their coordinates are in world space and they have to catch up to the body first. How can I fix this? (This is the One Euro Filter that I'm using: https://github.com/DarioMazzanti/OneEuroFilterUnity)
using UnityEngine;
public class FilteredObject : MonoBehaviour
{
public bool filterON;
public Transform noisyTransform;
OneEuroFilter<Vector3> positionFilter;
OneEuroFilter<Quaternion> rotationFilter;
public float filterFrequency = 120.0f;
public float filterMinCutoff = 1.0f;
public float filterBeta = 0.0f;
public float filterDcutoff = 1.0f;
void Start()
{
positionFilter = new OneEuroFilter<Vector3>(filterFrequency, filterMinCutoff, filterBeta, filterDcutoff);
rotationFilter = new OneEuroFilter<Quaternion>(filterFrequency, filterMinCutoff, filterBeta, filterDcutoff);
}
void FixedUpdate()
{
if (filterON)
{
positionFilter.UpdateParams(filterFrequency, filterMinCutoff, filterBeta, filterDcutoff);
// Use localPosition instead of position
transform.localPosition = positionFilter.Filter(noisyTransform.localPosition);
rotationFilter.UpdateParams(filterFrequency, filterMinCutoff, filterBeta, filterDcutoff);
// Use localRotation instead of rotation
transform.localRotation = rotationFilter.Filter(noisyTransform.localRotation);
}
}
}
So essentially, I only want to filter small movements. I tried distance/velocity based stuff, but nothing works
would it be possible to make a CRT material via shadercode?
I:E, materials with the shader on function basically the same as normal materials but they will have a crt texture or something overlaid and might flicker or smth
make it less static
Static fields cannot be serialized
its static you cant
you cant
say you could, where would you expect it to display, since the UI is per instance
but then i wouldnt be able to use it in other scripts, right?
but static is global to all instances
you do it better
sure you can get a reference to it
im currently using it by doing Script.canFinish
you absolutely can, you just need to learn the basics of referencing.
*don't mention singleton, don't mention singleton...*
instead you will do it with someReferenceToSomeParticularInstance.canFinish
DI ๐
somewhat..lol
DI and singletons are both just ways to get a reference to the object though!
ofc ofc ๐
Singletons are a valid pattern, especially in game development
But it wouldn't be the best choice for this, it looks like
Just getting a reference to the object holding the bool would be best
Singletons are โค๏ธ I agree ๐
anyone familiar with localization can help me?
i have a table with names of items
and a popup for selling these items
i want the popups have their own table and this one specifically to be for example "How many {item_name} do you want to sell?"
i have a localizestringevent on the popup with a string reference to it and inside it a local variable which is also a localized string, how can i change its table key?
is my approach even right?
are you using the localization package?
yes
tl;dr i want to be able to change a local variable localizedstring's key
since I'd expect you to have one table of all of your items
yea
but you can definitely change the TableReference as well
but itll always be the same table
You can update an existing variable like this:
if (someString.TryGetValue(key, out var variable))
{
if (variable is LocalizedString target)
{
target.SetReference(itemName.TableReference, itemName.TableEntryReference);
}
}
someString could be localizeStringEvent.StringReference, in this case
ohh youre casting
yeah, I'm downcasting from IVariable
This is different from the alternative in a big way...
target.Add(key, itemName);
yea
This literally puts itemName in as that variable
for this i'd have to remove too right
rather than just copying over its table and entry
This is important if itemName has its own variables
I wound up writing two extension methods for this
line 9 is interesting...iirc, i was having problems with the new string variable appearing as blank
so i called GetLocalizedString first to force it to be loaded
not a huge fan of that
CopyFrom copies over every variable from the original localized string
hmm i see what you did there
recursively doing so for string variables
I'm not very confident this is the "right" way to do it
I did this because I was having problems with multiple users of the same LocalizedString object stepping on each other's toes
I had to create individual LocalizedString objects so that they could have a different value for that variable
The LocalizedStrings are stored on scriptable objects that many things refer to
If each instance already has its own LocalizedString, then this isn't an issue
i see you saved me some time if i had run into this issue
im wondering about why if i do
if (someString.TryGetValue(key, out var variable))
{
(LocalizedString)variable.SetReference(itemName.TableReference, itemName.TableEntryReference);
}
it doesnt act like this a localizedstring
wait how do i make it codelike
its backticks followed by cs
```cs //Code ```
The order of operations is wrong.
You're trying to cast the result of variable.SetReference(itemName.TableReference, itemName.TableEntryReference) to a localized string
The precedence of the . operator is higher than the precedence of the (cast) operator
((LocalizedString) variable).whatever will behave properly
ohhh right right im dummy dumb
what a weird syntax i guess i learned that today
i thought its supposed to be
(LocalizedString)(variable).something
That would not change the meaning of the expression
(variable).something
the left side is (variable) and the right side is something
it's roughly like writing
well, actually, no it's not roughly like writing -3 * 2
unary minus has higher precedence than the times operator!
this lists every single operator that C# has
gotcha ty so much for the informative response
can someone help me with Error .theproductnam JNI ERROR (app bug): global reference table overflow (max=51200)global reference table dump ihave read some threads and they were saying it is bug from unity side
without context it will be diffcult to help
there's a known issue related to that in 2022 related to IAPs and 2022.3.20f1 looks like it has a possible fix for your issue: https://unity.com/releases/editor/whats-new/2022.3.20
these are the errors in logcat
I'll take this as the last option
oh android.right. i meant more when does it occur? etc.
seems the link sent above might have a fix
it happens while playing the game and in between of the level the game crashes and the link is actually of a different version i had to change the version of the game i wanna take as the last option
at a guess you have an infinite loop there
ok i'll look for it thx
look specifically for infinite recursion
ok got it
Im running into a problem where this command is instantiating two gameobjects.
I know this through debugging and naming the gameobject after instantiating.
gunPack.gameObject.name = "Gun Pack";```
Its showing up in the scene as New Game Object
new GameObject() does that on its own
is there a way to create an empty game object without making a duplicate?
oh wait
I see what you mean now
thanks I got it
hello how can i make it move from left to right not right to left
public class CircularMovement : MonoBehaviour
{
[SerializeField]
Transform rotationCenter;
[SerializeField]
float rotationRadius = 2f, angularSpeed = 2f;
float posX, posY, angle = 0f;
// Update is called once per frame
void Update()
{
posX = rotationCenter.position.x + Mathf.Cos(angle) * rotationRadius;
posY = rotationCenter.position.y + Mathf.Sin(angle) * rotationRadius;
transform.position = new Vector2(posX, posY);
angle = angle + Time.deltaTime * angularSpeed;
if (angle >= 360f)
angle = 0f;
}
}
presumably negate your angle
- Do note that the angles you pass to
CosandSinmust be in radians
like give it a value
You can just change the angularSpeed to a negative number
i will try
and you don't need to/shouldn't reset the angle to zero
it works now thx
their is a issue with google ads when i disable adsmanger the build is working without crashing
I have a bobbing script on this image object, it just makes it float up and down on a curve. For some reason, having this script enabled warps the SFlag object downwards through the ground, though it worked in a different scene with flat terrain. Is there any reason why this would be happening?
Yeah the code literally just positions the object at some specific y coordinate
it has no knowledge of the height of the ground
you probably want to be doing something like a raycast to the ground to see the ground height, and have the curve height be additive with the ground height
oh
Does anyone know of any available functions for generating a specular and occlusion map for a texture?
I've created a function that will modify a texture's brightness, contrast, and saturation - the only issue is that I'd like to generate spec/occ maps for all my textures in one batch. Currently my script just takes one Vector3 (brightness, contrast, saturation) for all spec maps and one Vector3 for all occ maps, but this has lead to some spec maps looking perfect, while others are fully black or fully white. Basically - is there a way to make the script dynamically adjust the brightness, contrast, saturation values for each individual texture's spec and occ maps for the best results?
I'm getting a weird problem where my scene (or at least the UI) is slightly more zoomed in in a build than in editor (Compare the e in the editor sreenshot to the build on the right). This is making figuring out the right size to make my UI a real pain in the butt. Has anyone experienced an issue like this?
is 848 by 477. a 16:9 rez?
according to my calculator and this table online
also which rez settings do you build
close enough ig
I would still put a bigger resolution like 720p at minimum. well ig depends on which device you plan on targeting
make sure you have anchored everything properly as well
I was using 854x480 but it's actually not quite true 16:9
I'm hosting a build on itch and making the itch viewport 1280x720 makes it too big to fit in the window
makes sense
other than anchors I'm not sure what else you can check, UI is a bit of pain to get just right.
hmm maybe test the specific resolution you export at in the Game View to make sure its all anchored accordingly
that's what I'm using. My itch viewport is 848x477
when you export under Player Settings
I tried Auto-detect size but it says this when I try to run it
also I meant here
to test UI at that rez
found this, but changing it doesn't help
no luck
how so you had the wrong number when building
well now you have to anchor everything to match this
oh wait that's for builds. It didn't change the editor but yeah it probably changed the build to match the editor, lemme check
btw this isnt a code related issue and should prob be in #๐โweb or #๐ฒโui-ux
oooh sorry
Bruh I figured it out I'm actually extremely stupid it wasn't even an issue it was that that specific button is scaled up when it's selected which doesn't happen when the game is not running ๐
Need help from Dungen library
Where did you find a library in a dungeon??
And how did you get there?
It is about the Procedural dungeon generation asset.
I am looking for a way to obtain the data of the rooms generated from code, to start I am specifically looking for the "floors" of the prefabs in the 2D demo, because I want to implement the Terraing Grid System on each floor of each generated room.
I need this because I want to know which room is linked to another and transfer or move the character between rooms using the Terrain Grid System linked on the floors generated by Dungen.
Something like, I move from point A to B, and not from A to C.
I need help with dropshadow 2d for TMP text and button
the shadow component is not working and idk why
not really a code question
sorry
btw TMP has its own shadow shader iirc
can someone help me figure this error out?
MissingReferenceException: The object of type 'Student' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
Student.TeleportAllStudentsToClasstimeDestination () (at Assets/Scripts/Student.cs:919)
AttendClass.sitOnSeat () (at Assets/Scripts/AttendClass.cs:35)
UnityEngine.Events.InvokableCall.Invoke () (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:165)
UnityEngine.Events.UnityEvent.Invoke () (at C:/buildslave/unity/build/Runtime/Export/UnityEvent_0.cs:58)
PromptManager.updatePromptControls () (at Assets/Scripts/PromptManager.cs:301)
PromptManager.updatePrompts () (at Assets/Scripts/PromptManager.cs:133)
PromptManager.LateUpdate () (at Assets/Scripts/PromptManager.cs:30)
nowhere in my code is anything destroyed, especially not a "student" object, and the line it references at Student:919 is a debug line, and AttendClass:35 is a line that teleports students to their respective desks.
The code will work perfectly fine twice. I run the game, go to class, go to class again since there's a lunch break, and then I use a debug command to go to the next day. The next day loads in by saving the day, reloading the scene, and then loading the day. That way everything can run almost exactly the same every day but up the day of the week.
public Transform classDeskPos;
^ this seems to be the actual line that's coming up as "empty", but every student always has this included, none of them share the same desk, and because all students are on the map and following their proper logic, none of the student objects or scripts were removed or deleted.
Loading a new scene destroys everything and creates new objects
Unless you exlicitly keep them loaded
i added in a line that would prevent objects from being destroyed on load, and even added it to it's own script so i can attach it to objects, but the error still occured
DontDestroyOnLoad(gameObject);
this
That may contribute to the issue.
If something is in DDOL, its awake and start will not run. Does the object that the reference is to go into DDOL?
Sorry, that is worded weird.
The reference that is LOST, is THAT object in DDOL?
I added DDOL and removed it from the Student file, since that file keeps track of classDeskPos, which is the value that seems to be the issue
Alright. At this point, I recommend sharing !code then.
๐ Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
๐ Inline Code
Surround code with three backquotes. Not quotation marks.
To 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.
public static void TeleportAllStudentsToClasstimeDestination()
{
foreach (Student student in AllStudents)
{
if (student.classDeskPos != null)
{
if (student.transform != null)
{
student.transform.position = student.classDeskPos.position;
} else
{
Debug.LogError("Student Transform is null for student: " + student.name);
}
}
else
{
Debug.LogError("classDeskPos is null for student: " + student.name); //This is line 919, mentioned in the error
}
}
}```
[SerializeField] public Transform classDeskPos; is added at the start of the file, outside of any methods, and every Student has the value filled in the editor
```cs
player.references.fadeManager.alphaGroup.alpha = 1;
player.references.fadeManager.fadeSpeed = 1;
foreach (Student student in Student.AllStudents)
{
Student.TeleportAllStudentsToClasstimeDestination(); //Where the game hickups on day 2
}
Debug.LogError("The code teleported all the students!");
timeManager.SkipTime(3, 30, true);
timeManager.currentEvent.eventName = "After School";
StartCoroutine(FadeCallback());
``` This is the code that's calling upon the above method
```cs
public static void advanceScene(string sceneName, DayWeekManager dayWeekManager)
{
SceneManager.LoadScene(sceneName);
dayWeekManager.AdvanceToNextDay();
}
``` Then there's this method
I might try adding DDOL to all of the classDeskPos areas again, maybe i missed one or smth last time i tried
welp, i fixed it by removing the debug lines
There's very little chance that there's anyone that has experience with and active knowledge about that asset. You're best bet is to check their documentation or contact the devs.
Is there a List type like dictionary that doesnt have value?
I want to store a list of enums, but they cant repeat.
you are looking for a Set
Hashset
yep
Thanks
but I don't even move. Like in description. I can just rotate the camera by mouse. I can even turn off the whole movement.
This bar material is visible in the Editor window for this UI element.
But it's not visible in the Game view during play.
What could cause that?
The bar is animating in the editor window as well
this is a code related channel
Where do you suggest I go?
Thanks
hey guys, i made an android game and i wanted to publish it on google play store, but when i tried to put the aab file it says that its bigger than 200 mb and doesnt let me, to avoid this i now use addressables, but now i want to get the addressables from a server, is there a way to use addressables with play asset delivery ? if not can anyone help me make the unity cloud content delivery work ? i have made the code to load the addressables and stuff i just need help with getting it from the server, its giving me an invalid URI: invalid port specified, even though i chose the correct loadpath that unity gave me in the addressables profile
why do you ask that question in code related channel?
When I drag/drop my prefab sword to the equipment slot on my model all looks good.
So I put that prefab into a property of a component in the inspector.
Now I have this logic to do the same but by script:
_currentModel = Instantiate(weapon.model);
Debug.Log($"[CLIENT] PRefab Transform {weapon.model.gameObject.transform.position}");
Debug.Log($"[CLIENT] PRefab Transform {weapon.model.gameObject.transform.rotation}");
Debug.Log($"[CLIENT] PRefab Transform {weapon.model.gameObject.transform.localScale}");
Debug.Log($"[CLIENT] PRefab Transform {weapon.model.gameObject.transform.lossyScale}");
Debug.Log($"[CLIENT] Weapon Transform {_currentModel.transform.position}");
Debug.Log($"[CLIENT] Weapon Transform {_currentModel.transform.rotation}");
Debug.Log($"[CLIENT] Weapon Transform {_currentModel.transform.localScale}");
Debug.Log($"[CLIENT] Weapon Transform {_currentModel.transform.lossyScale}");
_currentModel.gameObject.transform.SetParent(weaponSlotRight.transform, true);
However things are weird. The scale is completly off the chart and same for the position. I tried many overloads of the SetParent method but nothing does the trick
My goal is simply to have that drag/drop gameobject parenting behaviour I experience in the editor but with code
Hey, I'm trying to add the ability for items in my inventory system to have "inventories" of their own. For example so a gun can have a slot for a magazine, which should have slots for bullets. However, I'm getting the warning "Serialization depth limit 10 exceeded", and I'm not sure how to get around it. Any help appreciated.
SerializableInventory class
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class SerializableInventory
{
public List<SerializableItem> items = new List<SerializableItem>();
}
SerializableItem class
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class SerializableItem
{
public List<Vector2> slots = new List<Vector2>();
public List<ItemAttribute> instanceAttributes = new List<ItemAttribute>();
public string itemDataKey;
public bool rotated;
public SerializableInventory inventory = new SerializableInventory();
}
The "public SerializableInventory inventory = new SerializableInventory();" in the item class is what's causing the warning.
using Unity serialization you cannot get around this, it's a restriction built into Unity
Isn't there a way to add some sort of barrier, so the Inventory -> Item -> Inventory -> Item cycle can't go on forever? I'm assuming that's what's causing the warning, correct me if I'm wrong.
you are correct, the solution is not to use Unity serialization
i think SerializeReference might be able to do it because the items in the list are nullable then? but there's usually a better way than SerializeReference
one way to do it is lay it out as a flat list of items with unique IDs, then give them an optional parent ID, a bit like a database
I'll try that, thanks.
Just read a bit about SerializeReference, and it seems the way to go. Are there any limitations or dangers I should be aware of?
mainly the default inspector support for it is not good, at least last time i checked, so you have to write your own editor tools (odin user here, that handles it pretty well)
it's also a bit more likely to break if you change the data types because it's not just storing values any more like regular unity serialization, it saves type information too
All right, that's fine. Thanks
Getting the same problem but with my non serialized fields. What do I do here?
public class Item
{
public List<Slot> slots;
public ItemData itemData;
public List<ItemAttribute> instanceAttributes;
public bool rotated = false;
[System.NonSerialized] public Inventory itemInventory = null;
public Item(List<Slot> slots, ItemData itemData)
{
this.itemData = itemData;
instanceAttributes = new List<ItemAttribute>(itemData.instanceAttributes);
this.slots = slots;
}
}
public class Inventory
{
public string name;
[System.NonSerialized] public List<Item> items = new List<Item>();
public Slot[,] slots;
public Inventory(Vector2 size, string name)
{
this.name = name;
slots = new Slot[(int)size.x, (int)size.y];
for (int x = 0; x < slots.GetLength(0); x++)
{
for (int y = 0; y < slots.GetLength(1); y++)
{
slots[x, y] = new Slot(x, y, this);
}
}
}
I don't get why this is happening, since the classes/fields it's complaining about aren't serialized?
i think unity will serialize them anyway, eg to show in the debug inspector ๐
Damn, know any way around this?
Nevermind, I'm stupid. The warnings are from before I deleted the serialization attribute from my classes. Just forgot to clear the console.
Hey peeps, maybe you can tell me what i am doing wrong: Im not used to using scriptable objects but i wanted to try on this project with this.
I made a SO with a few public attributes, but also some functions for behaviours. Im loading them into the code via [SerializedField] List<MyScrptableObject> sos;
So far so good, I can use them. The problem is, every time I change values it also changes the values on the Scriptable Object itself - so on the next exacution all values are changed.
Im clearly not doing using them correctly... So should I use the SO just to copy the values on an actual game object?
I always describe scriptable objects like "blueprints for building something", you usually dont want to modify the blueprint, but you might want to reuse the blueprint to make copies of something, so they are great for something like setting the values of a weapon or character type or item etc (and in a build, the modified values will be reset back to the original when the app is re-launched again) - if you did want to modify the values, I normally setup a serialized class and use that, then you can clone the values in another class, for example:
[System.Serializable]
public class SomeData
{
public int someValue;
public float someOtherValue;
}
public class SomeSO : ScriptableObject
{
public SomeData data;
public SomeData Copy()
{
var copy = new SomeData();
copy.someValue = data.someValue;
...
return copy;
}
}
public class SomeUseCase : Mono
{
public SomeSO source;
SomeData session;
void Start() {session = source.Copy();}
}
There are other ways, though this hopefully shows the general idea
A scriptable object is for static data in my mind, so yeah I would pass it to another class and put the functions on there. But this would be typical of the editor's odd behaviour like when you edit a material at runtime and it changes the core material 
makes al ot of sense, thanks peeps
Because you are referencing an asset (just as scriptable objects are an asset), and not an instance in memory (unless GPU Instancing is enabled before you edit the material), the same is true for any assets that are referenced
except outside the editor this is not a problem, the material will always start the same...
afaik
Right, once you build your game, your assets get compiled into it "as-is" (unless IL2CPP is enabled I think), so I would imagine modifying a material in a build would also revert back to the settings it was built with when you re-launch the game, but in the editor your references point to a specific asset, so your changes would directly affect that asset, unless you do something similar to the example with a "Copy" or "clone", where you create a new instance, fill that instance with data from the asset, and modify/return the instance instead (which for materials, is similar to what GPU Instancing does)
yeah I just find that inconsistent - editor run is different to standalone run, but anyway as long as you know this
True
I don't understand a thing about rigidbodies.
I have ragdolls with rigidbodies, but when I apply a force to one of the rigidbodies sometimes it doesn't move.
For example, if I use AddForceAtPosition(new(13.17, -2.66, -6.22), new(-103.86, 37.26, 161.98), ForceMode.Impulse) at a rigidbody at position (-103.70, 37.22, 161.95) with mass 0,9090909 , velocity doesn't change at all... I may not know much about math, but the amount of force aplied is quite hight, and the distance of the force position and the actual rigidbody is super close, it should apply some velocity, but the result is (0.00, 0.00, 0.00)...
is there an #if UNITY_EDITOR_NOT_IN_PLAYMODE ? or something of the sort? except UNITY_EDITOR
No, because editor mode and play mode both use same code, there is no recompile.
But you have Application.IsPlaying
Are you sure you aren't manipulating the velocity of the rigidbody anywhere else?
Also, have you checked how AddForce compares? Does it also sometimes do nothing?
Are you Adding the force in FixedUpdate() or Update()
So I'm trying to convert my project over to URP on Unity 2019, but the video I'm following from the Unity YouTube channel right clicks and has an option for "Rendering" in the context menu, I do not have that option, and I've made sure I have the URP addon installed in my project first
it might be from an older version? there's a Rendering category with URP stuff under "Create" , does that have what you're looking for?
The first screenshot I provided is what I'm seeing, I'm looking under the "create" menu
I'm applying it in Update, but I'm using ForceMode.Impulse not .Force so it should not be a problem
The tutorial is using 2019.3.0b1, I'm using 2019.4.39f1, but I don't think there'd be that much of a change between those versions
oh right, i misread... it's present for me on 10.10 and 14.09, which URP version are you on?
Oh, I should check
not sure why it would be missing from your version then, have you restarted unity since installing it?
restarted the editor yes, hub no
any errors in the log?
like when installing the addon?
like, at all
well....yes but shouldn't be related to the URP, all of them are just "Assembly with name XXXXX already exists"
if the scripts aren't currently compiling successfully you won't see editor scripts loading either
standby I'll try without any scripts running
You must have zero compile errors.
I think it's working now......just a waiting game at this point -_-
Thanks, it was that
I am using Unity 2022.3.19f1 and there seems to have been an editor-only cursor regression or API change.
When the screen is maximized hiding and locking the cursor has no effect.
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
"Summary of What's New in this Release of Visual Studio 2022 version 17.8.7
Visual Studio is able to run form under the SYSTEM account."
can someone briefly tell me why i would want this?
jesus
i'd imagine there is some very good technical reason for it, but i do not know enough to know why. To my limited knowledge, it just sounds like a security issue. Some further reading suggests that maybe it has been able to for a while, and a regression broke it? IRDK
Do you know any good services to get in touch with a mentor? I want to ask some thing about my understanding of managing Unity Codebases for a team (have never done this before)
maybe try the forums
!collab
We do not accept job or collab posts on discord.
Please use the forums:
โข Commercial Job Seeking
โข Commercial Job Offering
โข Non Commercial Collaboration
Humm interesting, will look at it!
but if you just have questions, ask them here
They are a bit concrete to the project, and I feel like the solutions I have implemented need a bit of refinement ( I have never done something at that scale so I would like some extra opinion)
I would sorta prefer to schedule a meeting or something for this ๐ค
sounds like you want a consultant , that cost money
Yep... I know...
But I think I need it right now, I was seeking options to look at
Thanks for the insights though! Will look at them for sure!
def check out their e-books, they go over stuff like that too for teams
I have read some of them but the one you passed wasn't on my radar, reading it right now ahaha
Sometimes I feel you really need to dig down for finding out advanced concepts
very true lol
yeah, i wish they spent more time on documentation of that nuance tbh
https://docs.unity3d.com/ScriptReference/Rigidbody.MovePosition.html
This for example, is waaaay too scant for for important it is, and how much nuance there is to using it
I recently found out this youtuber: https://youtube.com/@git-amend?si=shcC0oNuA9O2zUSK
This dude is the one that made me thing: Maybe I should get a consultant or something, I feel like my knowledge on Unity can be upgraded a lot for some price
Ready to master high-level Unity3D techniques?
Our advanced Unity3D tutorials will help get your game in front of your playtesters faster!
Build your indie game like an expert with:
- comprehensive core mechanics
- programming patterns
- proper architecture
- software engineering principles
- advanced C# language features
Learn how to take yo...
this page has basically none of the information that you really need to use MovePosition
you cannot buy knowledge, only experience can do that for you
tru
But sometimes with plain experience you lose a lot of time, or you track the wrong knowledge. Or even worse, you get bad habits from what you learn
Experience is important tho
But I feel like sometimes you need some sort of external opinion to get fresh ideas
do you have any kind of formal training?
you hire a consultant to give you an answer.
you hire a teacher to teach you (eg school)
As much as it may be better, and as someone who tutored/taught others, it is also usually costly. A lot of the time it's not really worth it just for someone to be telling you "yes this works"
Yep, but I also like to keep learning an improving too :(
a consultantโs main job is not to train/teach
you miss my point, if you have had formal training that should have taught you how to learn
a consultant consults
I think I had the wrong idea of a consultant then
i think he means he wants a course on the topic
True, I do, but sometimes is like, how can I get to this point ? I am doing it good? Who is telling me I'm doing it wrong?
Maybe I just need more experience tho
I just had this insecurity recently
that is, indeed, what it sounds like
In game dev, really there isnt a wrong way if your game is running fine. The only thing that matters is the end product of what people see
Yeah ahaha
Future you will ๐
you do want to organize and use good technique, and good architecture.
You donโt want to end up like YandereDev, with one script with >15k lines of code, and a giant if else if else chain with 100โs of numbers
Probably ahaha right now im in the phase of I'm learning that I know nothing
absolutly, forget all the style police and the CS students who don't know their arse from their elbows, game dev is all about making it work and nothing else
style is important because bad style gets you in deep shit
if your strategies and styles actually help you to make it work, then go nuts
Altho I like to create a good architecture and stuff
good style is even more important when working as a team
but especially when you're a novice, you will have no idea what is and is not important
if we are on a team, and you write spaghetti, I cannot be bothered to sift through your crap to help you
there is a balance, and it is better to overdo it (overdocument, overengineer architecture), and then step back to a more normal workflowโฆ. This is better than starting with shit style, and later trying to go to a better workflow while fixing a bunch of garbage
Go back to your old work and think about what's making it hard to understand and extend
Start hard and relax > start lazy and then suffer
DOn't start, never worry
Don't even think, just breath
Don't breath, no need to think!
but if you have shit style, and never give a fuck, no one will want to work on your code, especially you
Pffft, that's a problem for Future Bean!
on the other hand, nobody is born knowing style and, in my experience, those who blindly follow others never learn it
style is something you are almost exclusively taught in university. few people learn style outside of that, outside of a very slow process of osmosis
if my professors never taught me style and what to look for 15 years ago, i would probably not write very clean code today
not true, style is learned from people who are more experienced than you, you are unlikely to find that in an academic environment
i do not recall being taught code style very thoroughly
you are also very likely to learn terrible style, from other people who have bad style putting out code
it was drilled into me
i cannot forget
most of my "style" is just running the auto-formatter and the rest is loosely following microsoft's C# style guide
everything else is design, not style
design =/= style
but certain designs are shit style. eg 100 if else if else if in a row
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class menuservera : MonoBehaviour
{
MenedzerPolaczen mp;
public InputField Ifnick;
// Start is called before the first frame update
void Start()
{
DontDestroyOnLoad(gameObject);
mp = GetComponent<MenedzerPolaczen>();
}
// Update is called once per frame
void Update()
{
}
public void startgra()
{
if(Ifnick.text.Length >= 4)
{
PhotonNetwork.playerName = Ifnick.text;
mp.polacz();
}
}
}
I still think you need to learn from references and people who are better than you... The same like an artist who watches other people art, I like to think this translates to code too
why
yes, but if you do not know what constitutes good style, you are equally likely to learn bad style from someone incompetent as you are good style from someone who knows what they are doing
which is a major hindrance to the process of learning style outside of academia
use TMP_InputField
Thats totally true!
thatโs why i most highly value style learned via academia, even though it can be overbearing. The core principles are at least correct
were?
I hate to disillusion you, in the real world, they are not
for the type of Ifnick
any way I can replicate this in the inspector using shadergraph?
So I managed to get my project converted to URP, but now all my textures are missing from the scene lol
my professors in academia knew their shit. that might not be true everywhere, but they are still more qualified than the average Unity youtuber from which most people learn what C# code is โsupposedโ to look like
switch the shaders from every material
to URP equivalents (if exist)
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class menuservera : MonoBehaviour
{
MenedzerPolaczen mp;
public InputField TMP_InputField;
// Start is called before the first frame update
void Start()
{
DontDestroyOnLoad(gameObject);
mp = GetComponent<MenedzerPolaczen>();
}
// Update is called once per frame
void Update()
{
}
public void startgra()
{
if(TMP_InputField.text.Length >= 4)
{
PhotonNetwork.playerName = TMP_InputField.text;
mp.polacz();
}
}
}
``` it doesn`t work
The reason I had all this doubts btw is that we are starting a project which is more "professional" with my collegues. I have been given sorta the role to manage the codebase and think about the structure.
I want to do it as good as I can but I feel it might start to be too much for me as I cannot find a solution I like and I don't know if I will tbh which thats good ๐ค. Anyway I'm learing a lot just wanted to make sure i'm on the right path ๐
my solution is experiment on your own to find your own reasoning
the type, not the name
in theory, you should use all the tools available as much as you can, until you learn where you can step back and use them a more normal amount
In practice I think tutorials are useless and most of the time dont teach you anything
hence the most in that sentence
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class menuservera : MonoBehaviour
{
MenedzerPolaczen mp;
public TMP_InputField ifnick;
// Start is called before the first frame update
void Start()
{
DontDestroyOnLoad(gameObject);
mp = GetComponent<MenedzerPolaczen>();
}
// Update is called once per frame
void Update()
{
}
public void startgra()
{
if (TMP_InputField.text.Length >= 4)
{
PhotonNetwork.playerName = TMP_InputField.text;
mp.polacz();
}
}
}``` again, it doesnt work
nahh bro wtf is this lol
like thank you I now have a step by step guide on how to achieve this very specific thing with no suggestions on how to deviate
but why did I do any of this
I think why is a much more important question to have an answer to compared to how
your TMP_InputField reference is stored in ifnick @dull quarry
why are you using the class itself
you didn't change the reference to it in startgra
They're not pink anymore but....the diffuse maps are gone lol
man, go away and learn c# please
this is not a code question btw
yea ik, was just responding to who was helping me before
That case 100% falls under "game does not run properly". His game was shown to run at like 1fps.
wtf men were i have to put it TMP_InputField
please go do beginner courses again and learn how references work.
and this def doesnt belong in #archived-code-general
i dont undertand it in eng
references wtf
then look it up in your native language or translate it idk what to tell you
you're missing the fundamentals of coding
references should be one of your top lessons
just write in the code where to enter TMP_InputField
No one is gonna write your code for you
you already added it..
you just aren't using it properly..
You do not use the Class unless it was static or its method/members were
You use the instance of the class
fuck u i donta have tooths
be respectful towards others or catch a boot ๐ข #๐โcode-of-conduct
if that was even intelligible I might respond, as it is, fuck u too
if your game does not run properly/quickly or with bugs etc, and your style is poor, your ability to fix any issues with it is limitted
because any code written with poor style takes much longer to read and understand (and understand what is wrong) to then fix
i have to wonder if some of that game's code was the result of codegen
there's no way a human being would write such a catastrophically long if / else if / else if / ... / else chain
that tech was too primitive when he started so many years ago
it is almost certainly man made
good style vs bad style is basically the difference between these two pictures. If it works, everything is fine. The difference only becomes apparent if you need to fix/change anything.
That all still goes under "game does not run properly". My message said "if your game is running fine"
every game will almost certainly have a time in development where it doesnโt run fine. Which requires you to be able to fix it.
so if you write working code which is difficult to fix, you will eventually have a game that does not function
Hello guys! i need help
hello
how would i go about making my movement input (which is a vector2) relative to the cameras view instead of world-space?
i tried to start a game, hes not working
this isn't a code problem, but...there's no data folder at all
Camera has functions to convert between camera space and world space. start there
It looks like you moverd the executable into the data folder?
dude, i just download file from my game jam team programmer
and i try to start this game
the built game folder should contain GameName_Data and GameName.exe in it
im currently profiling my UI, and noticed that .SetActive is expensive? Is it better to disable canvas component on UI object to hide them instead of the whole gameObject?
Then they should send you an unmodified build folder
With everything in it, where the build process put it
And also this still isn't a code question
iirc yeah, toggling an object to active/inactive can cause layout rebuilds etc, so just making it invisible is way cheaper, you should get the same benefit if you put a CanvasGroup on it and set the alpha to 0
One problem with this is if you use layout groups, they wont resize spacing.
From where do you get your sounds for the games ?? Or any tips for like making audios? I never gone deep in that audio creating stuff
Probably best for #๐โaudio
Certainly not a code question
oh jeah right thanks
hello everyone, I have been struggling with a problem where the player is dying the moment the damagePlayer() method is played, it is connected to an animation event (the player health is 100.) https://hatebin.com/hwkvdagtcj
well, have you checked how many times the method is being called?
e.g. by logging when it's called
and the problem is?
why are your functions not capitalized? itโs so confusing lol
I see nowhere where you log the value of playerHealth
so?, atm you are just assuming it's value
playerHealth should be a property that automatically invokes an event Action called OnPlayerDeath when health is zero. Animation script should subscribe the death animation to that event
JS/Python user ?
prove it, log it
The debug.Log() should be in damagePlayer()
Why not just make the text Player Damaged?
i felt like it sry
player health should not be a public field, btw. It should only have a publicly accessible property, at most.
my brain turned off
Its ok ur just making harder to read for us
yes but it needs to be a global variable
@swift falcon sry bout that
Its fine
my brain turned off
why
so it can detect beign punched
will you please stop being the style police, you are not the arbiter of good code/design
wait is the animation event playing before and after the event plays
iโm trying to show him that you donโt just need to make everything public -.-
The animation event gets called wherever u put it on the animation
i made it public so it can be accessed from the cowboy script
that is not what you are doing
If playerHealth is a public property with private backing field, then you can run code whenever the health changes. Which allows you to do things (like print out when it changes) whenever it gets modified
even without an event system, this gives more control
U have a tendency to do information overload
public int Health {
get => _health;
set {
_health = value;
Debug.Log(โNew health is โ + _health);
}
}```
please can we just focus on the question rather than the code layout
that code will literally let you know wtf is going on with the health and when it gets modified
which is one of the things you need to do to solve your problem
Whats ur current problem
so it is playing the damage method twice instead of once
Whos calling the Damage method
cowboy script
Can we see that?
what method
thatโs not what we are asking
Wait what
what is calling that method twice
This code doesnt make any sense
how?
Show me ur Player script
why not debug the start and end values of playerHealth instead of outputting a completely meaning less string?
the moment it makes contact
U did what?
stack animation event
U had two events?
I had a feeling
Ofc
answered already in #๐ปโcode-beginner
try netcode
Don't post the same question in multiple channels. You need some kind of networking protocol. Unity provide some. Ask in #archived-networking for more information. Be wary that it complexifies programming significantly, and is not recommended for beginners.
LAN will not make it any less difficult than over Internet
the only differences is the port opening . You're better off learning couch Co-Op first
https://gdl.space/bimicoqeru.cs
I'm randomly generating my map but I get a issue when I try to rotate it the object. With no rotation, the pivot is at like the bottom right of the prefab so it fills up the cells but how do I change the pivot when it rotates.
I believe this is actually a common issue in unity
Theres packages that let u dynamically change the pivot point on objects u cant do this out of the box in unity
Probuilder can, I wonder if you can extract that function for runtime
Ah ok forgot about probuilder
only when creating the mesh i think
https://docs.unity3d.com/Packages/com.unity.probuilder@6.0/api/UnityEngine.ProBuilder.PivotLocation.html
bummer
https://docs.unity3d.com/Packages/com.unity.probuilder@6.0/manual/Vert_SetPivot.html
This would make a neat runtime function..but yeah limited to only ProBuilderized meshes
hey im coding an 2d Platformer and im having my player as a prefab and the moment i execute my script to load the next scene it crashes and says (that my rigidbody was destroyed and im trying to acces it) but i have no clue how since i have a new player (with the same prefab) in the nwe scene and the player controller script assigned to it
see #854851968446365696 for what to include when asking for help, because this isn't really enough context. we'd need to see the relevant code
ok my apologies
MissingReferenceException: The object of type 'Rigidbody2D' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
UnityEngine.Rigidbody2D.get_velocity () (at <8a082034ac0e43f7a55898853ac40f9e>:0)
Videogames2024.PlayerController.RemoveTransientVelocity () (at Assets/Scripts/PlayerController.cs:171)
Videogames2024.PlayerController.TickFixedUpdate (System.Single delta) (at Assets/Scripts/PlayerController.cs:73)
Videogames2024.PhysicsSimulator.FixedUpdate () (at Assets/Scripts/PhysicsSimulator.cs:45)
still need to see the relevant code
put it in there
i dont exactly know where the error is
it tells you right there 171
https://unity.huh.how/stack-traces
its trying to do a Get on the velocity property but rb is destroyed
yeah it seems like you add the objects to a hashset on your PhysicsSimulator singleton but then you don't remove them when they are destroyed
and since the singleton is DDOL it is the same instance in each scene so it keeps those references to the destroyed objects since you never clean them up
ah i see ty
man if you're using regions, you got too much code tbh
what you mean by that?
this is kind of an odd take ๐ค
idk I feel like thats when you know this class does too much
like its gathering inputs? it should only receive them not necessary track them
ig its preference lol
sure but that's irrelevant to regions. in this case regions are a symptom of the problem, not necessarily an indicator that there is a problem though.
regions are convenient to fold large sections of code in an IDE
yeah true I meant it differently, my wording sometimes ๐ Regions are very useful just meant the class was a monolith and yeah symptom for sure . I def use them too
didn't mean it like regions = bad code , but yeah it come off that way
https://gdl.space/upimejicoq.cs
The problem:
Once PlayerCrouchHit is done playing it goes to idle for a very quick moment rather than back to PlayerCoruch
seems to be an issue with line 117. The warning I get:
seems you don't have a state called PlayerCrouch
That is indeed what it says, however
it plays it fine just not when its after playercrouchhit
maybe i should just remove that line?
after all once player crouch hit ends the only animation parameter that can be true if user is pressing down is the crouch anyways so..
maybe that will work?
in the animator controller though what is the state named
btw canMove = animator.GetBool("PlayerCrouch") ? false : true;
can just be canMove = !animator.GetBool("PlayerCrouch")
Ternary unnecessary here ๐ค
you mean here?
dam, true
I meant here
well it still same name..?
right
ion get it
looks to be same name
how would it even change name
Just wanted to check the names in the actual controller
oh alr
i should note this wasnt a problem before i introduced a second layer + a few things that were connected to this
well are you checking for layer 2?
ever
since here you only check the one with index 0
GetCurrentAnimatorStateInfo(0)
would index 0 be "Base Layer" in this case?
cuz it is suppsoed to only check there
I think it is the order of the array
Baselayer seems to be on (1)
so layer 2 is index 0?
You can double check this
like so
Debug.Log($"layer1: {anim.GetLayerName(0)} layer2: {anim.GetLayerName(1)}" );
Layer2 seems to be index 0 though and BaseLayer index 1
Is there a data type that works in the editor like a layer mask does, where I can make multiple selections out of a list of options? I plan to use it as possible game modes for a map represented with a Scriptable Object.
flags enum
Thank you!
bingo
nice
so i should be checking in index 1
yeah
since i am not providing an index it uses 0 as default
make your index a param or make it a separate method
i use layer 2 only for invincibility animation when hit
yea you know your project best 
ok thanks
one small problem tho
its not playing the animation at the end like it used to
so the last paranmeter of the animation.play is the time of the animation it is suppsoed to start playing the animation, right?
this animation is 20 frames
wait length doesnt matter
not sure on that one, I dont use Play. Usually I do transitions
cuz 0 is beginning and 1 is always the end
dang
its still not playing the animation at the end ๐ค
The normalized time.
What do you mean, 'at the end?' What exactly are you trying to do?
Hey this is kinda embarrassing, but I'm getting a simple
NullReferenceException: Object reference not set to an instance of an object
error, however, it's pointing to a blank line in VSC? I've checked editor references around that section of code and everything seems fine. I haven't even been touching that part of my project, so I'm really confused why it started randomly
I tried restarting Unity & my PC, didn't help
ok i found a fix, changing some initialization of a struct to Awake rather than Start for one of my monobehaviors... however, I'm unclear on why this started in the first place? I was adding more gameobjects to a particular scene that appeared to trigger this
it seems that maybe adding more GOs changed the random order it was creating other ones in the scene?
I think I'm confused about how to properly preserve order of important things, I guess as a rule of thumb, if I need to initialize any data structs, always do this in Awake rather than Start?
Hi, what is the correct implementation of a one line event subscription using lambdas and how do i unsubscribe from that event?
I believe what I have attached works but how do I go about unsubscribing if there isnt a function "name" / "tag"?:
_player.GroundChecker.ReturnGrounded += value => { if (!value) _player.UpdateState(PlayerStateEnum.FallState); };
Just write the logic in a method, with value as your parameter. Then you can unsubscribe
you cannot unsubscribe if you subscribe using a lambda expression like that. you'd have to store the lamdba in a delegate and subscribe that then you can unsubscribe that delegate. otherwise use a method
mm ok thanks, i was trying to avoid having methods for every subscription but its probably just the simplest. all goods
if the event is not static and both objects are destroyed at the same time and you only plan to unsubscribe on destroy, then you don't actually need to unsubscribe so you could use lambda expressions there no problem. but if the method is static or the subscriber is destroyed before the object with the event then you'd have to unsubscribe so you'd need either a method or a delegate variable
Yep, you can't assume unity will initialize individual objects in any sort of consistent order. You can manage the order of specific components if you want to (https://docs.unity3d.com/Manual/class-MonoManager.html), but generally you should initialize stuff in Awake and then connect stuff in Start. So if you have data which needs to exist you should ensure that it is does in awake so that any script trying to access it can rely on it being ready when Start() runs.
Ty! I'll look into the MonoManager too, really appreciate it
FWIW I tend to toss an Init() method on my monobehaviors and initialize them myself so that i can manage all that without dealing with unity's stuff, but that doesn't make sense for every setup
Interesting! In which class do you initialize all of them, and how do you make sure that one happens first?
I generate them from the gamestate, so there are various views which are responsible for querying that data and then building/initializing/updating the objects to represent it in the game world
and then i guess the order doesn't matter? dependencies are linked together already in prefabs for the most part
or resolved much later when everything definitely exists
i guess i could initialize or render the views in a particular order if i cared to by registering them in that order but it's never come up
So if I understand correctly, you're using MVC with Unity?
that's very interesting indeed
Hey guys so i have a big problem i'm trying to make a dialogue system for my game and i use
public void TriggerDialogue ()
{
FindObjectOfType<DialogueManager>().StartDialogue(dialogue);
}
Everything work well if i start the dialogue from a button on the UI.
but if i try to call TriggerDialogue(); from anywhere else like Void Start()
I get this error
NullReferenceExceptiton: Object reference not set to an instance of an object
DialogueTrigger.TriggerDialogue() (at Assets/Dialogue System/Assets/DialogueTrigger.cs:16
is this line 16
FindObjectOfType<DialogueManager>().StartDialogue(dialogue); ?
seems like at the time you call that method there is no DialogueManager in the scene
yes
or at least none that are active in the scene
Then there is no DialogueManager in the scene
no everything is there and everything is working when i'm using the UI input system but if i try to use it from a void start it don't work
you can say that it is there, but the evidence points to it not being there or not being active
computer says otherwise
If that is the line the error is on, and that is the error you are getting, then it is 100% irrefutably confirmed that at the time that code runs there is no active DialogueManager in the scene
From Start, not void start
But perhaps it is not there that early? Start runs fairly early
no it in void start just accidentaly said start
What?
Start is the method name. You don't need to (and should not) say void
no that not what i mean't
I guess so, though 'controllers' don't really fit in conceptually because unlike a web app where resources tend to be accessed directly, games tend to be more about abstract actions, so that's where my state updates come from. It might be closer to CQRS? But I don't know the exact definitions for everything.
Ok, well you are not being very clear. Explain better?
Because this makes very little sense:
no it in void start just accidentaly said start
ok so i litteraly change nothing and now it work?
idk why
I did not change anything and just start it again but this time it work
also last time everything was active or existing just it wouldn't work for some reason
There is no set order to when each Start will run
Sounds like last time it ran in an order that caused an error
I was using this bit of code but each time i was putting TriggerDialogue(); in start to start the dialogue when i start the game it wouldn't work for some reason but now it does?
which object is DialogoueManager on? and why is it not just assigned in the inspector ?
i'm using a tutorial so why it not just assigned to the inspector idk but i thing it in case you have multiple dialogue and the name of the object is DialogueManager too
if you need the tutorial link i can send it
Ok so i'm having the problem again
when i press the button everything work but not when the game is starting
Why? IDK
it shouldn't be null if it work when i press the button but not on start
The NRE is triggered from a different class from the one posted check in there
it telling me about this but i don't see the problem about that
and when i remove it it tell me the same for sentences.Enqueue(sentence);
i don't know why it work when i trigger it with a button but not with the void start it weird
racing condition
both of your dialoguetrigger and dialoguemanager are using start to initialize the variable and calling the triggerdialogue
You can move you sentences initialization to Awake
Oh that'll do it
Awake is called before Start
you don't even need Awake for this. just initialize the sentences queue in the field initializer
That to
YEAH
IT WORK
DUDE IT BEEN 1 WHOLE DAY I'M WORKING ON THIS
THANK YOU SO MUCH
I was litteraly about to go crazy XD
it would maybe have been easier to use an other way but i really wanted to use this one
and it finaly fixed thank you so much guys
idk why tho but i have an other project having the exact same file but it actualy work it weird but yeah?
Is there a way of locating assets from code without storing it as an explicit reference variable and without the need to dump everything into Resources folder?
heyya wsg
addressables. or if this is for editor-only stuff you can use the AssetDatabase class
Ah... Shit. I'm on 2021.3.6
you can still use addressables. it is available for many versions, you're just looking at the page that lists the latest version that is for 2022.3
Funny thing, I ask precisely because I found out that AssetsDatabase is editor-only.
Oh, that's a relief, thanks!
...It only supporting async loading kinda throws a wrench into my idea though, but I think I can try to work around that...
I've rewrote it as such, but IDK if it's fine this way. I think it should be fine if I call "Get" from my game manager singleton on the first chance it gets though...
static GameObjectsList instance;
private static AsyncOperationHandle<GameObjectsList> asyncLoad;
public static GameObjectsList Get()
{
if (instance == null)
{
if(!asyncLoad.IsValid() )
{
asyncLoad = Addressables.LoadAssetAsync<GameObjectsList>("Assets/Cliffworld/GameplayData/GameObjectsList.asset");
asyncLoad.Completed += h => { Get().Rebuild();};
}
else if(asyncLoad.Status != AsyncOperationStatus.None)
{
instance = asyncLoad.Result;
if (instance == null)
DevLog.LogError("GameObjectsList scripted asset not found in GameplayData folder! Did you forgot to create it?!");
}
}
return instance;
}
that's not going to work. LoadAssetAsync does not take the path to the asset. that path will also not even exist in a build either. that is also just not going to work in general to get the object because you cannot return from the lambda expression to the object that actually called this method
see the documentation pinned in #๐ฆโaddressables to learn how to properly use it
But it's what it gave me back as address in Unity?
where do you see that
Unless I misunderstood?
you cannot return from the lambda expression to the object that actually called this method
Can you elaborate? I don't think I understood that.
asyncLoad.Completed += h => { Get().Rebuild();};
this line will not return the instance object to whatever initially called Get()
Maybe I should just put the content of "else if" portion into that lambda, then?
that lambda will be entirely unrelated to whatever has called Get in the first place. whatever calls Get will end up receiving null if you enter that first inner if statement
Ah, yes, this, no, this is my problem with it being async, this part I know. I thought that workaround would be to just call it in my gameManager script on it's Awake(), then hopefully by the time the actual in-game scripts that will refer to this container to get NPCs or items, it will be loaded already.
Saving throw is that there are no such scripts on my loading screen and main menu scenes, where GameManager is being instantiated...
just call WaitForCompletion on the async operation handle returned by LoadAssetAsync to make it run synchronously
and for further addressables related questions, you should ask in #๐ฆโaddressables
Oh, thanks!
is there any way to do the SelectionChanged callback on runtime?
There is no such thing as selection at runtime
Implement whatever your selection system is yourself
well basically wanted to do an OnUnselect, found out IDeselectHandler existed
yeah that works
Ah, UGUI
UGUI = unity graphical user interface
UUGUUIUU = unity user graphical unity user interface for unity users
is there any way to check if the mouse is hovering over a non-UI object
Physics Raycaster + IpointerHandler
you still need collider for that tho
UI uses rect transforms somehow, no idea how it works on the back end
Can someone help me figure this out? I'm trying to represent hours and minutes and floats (i.e 1 hour = 1.0 , 1 hour 30 min = 1.5 , 1 hour 45 min = 1.75, an so on)...
I'm getting timestamps and trying to get the diffrence in hours and / or minutes
public void CalculateHoursWorked()
{
TimeSpan timeDifference = clockInDateTime - clockOutDateTime;
hoursWorked = timeDifference.TotalHours;
Debug.Log("hoursWorked Time difference in hours: " + hoursWorked);
}
public void CalculateLunchBreak()
{
TimeSpan timeDifference = startLunchDateTime - endLunchDateTime;
lunchBreak = timeDifference.TotalMinutes;
Debug.Log("lunchBreak Time difference in minutes: " + lunchBreak);
}
but you can see in the screenshot the values as a double but if i convert to a float with a cast I'll get values like 17734516.83
Should I just use a float to count and convert to times for displaying?
your calculations are wrong. they should be end - start not start - end
Then I'll get a similar value with a negitive
I'm still going to make those changes and try again
how could you get a negative result from
BigNumber - LittleNumber
?
Idk , I made your mentioned changes and running it again
public void CalculateHoursWorked()
{
TimeSpan timeDifference = clockOutDateTime - clockInDateTime;
hoursWorked = timeDifference.TotalHours;
Debug.Log("hoursWorked Time difference in hours: " + hoursWorked);
}
public void CalculateLunchBreak()
{
TimeSpan timeDifference = endLunchDateTime - startLunchDateTime;
lunchBreak = timeDifference.TotalMinutes;
Debug.Log("lunchBreak Time difference in minutes: " + lunchBreak);
}
I'm not casting anything here either , these values are doubles currently , not floats
And the pictured values above don't match up to me , even if they were positive
try this
TimeSpan timeDifference = new TimeSpan(clockOutDateTime.Ticks - clockInDateTime.Ticks);
How do you guys typically handle collectables? Aka you collect a thing and the game remembers you got it and doesn't spawn it again.
Just ID the shit out of everything?
Add it to a dictionary maybe?
private dictionary<string , gameobject> collectedItems;
I mean it needs to be saved.
Id's seems to be the way people are describing online , the few I found
I like TextMeshProโs auto-size feature, but I need to make a bunch of canvas texts (TextMeshProUGUI) all use the same, smallest needed size of the bunch. Is there a pre-made class/component to do that?
this got me closer for hoursWorked , not on lunchBreak... still ngetitive values... I'll try casting as a float next
post your latest code
I dont think you need .Ticks
public void CalculateHoursWorked()
{
TimeSpan timeDifference = new TimeSpan(clockOutDateTime.Ticks - clockInDateTime.Ticks);
hoursWorked = timeDifference.TotalHours;
Debug.Log("hoursWorked Time difference in hours: " + hoursWorked);
}
public void CalculateLunchBreak()
{
TimeSpan timeDifference = new TimeSpan(endLunchDateTime.Ticks - startLunchDateTime.Ticks);
lunchBreak = timeDifference.TotalMinutes;
Debug.Log("lunchBreak Time difference in minutes: " + lunchBreak);
}
yeah, no .Ticks TimeSpan timeDifference = new TimeSpan(endLunchDateTime - startLunchDateTime); at least non on example page
that's posted above
@clever lagoon
#archived-code-general message here? not exactly
DateTime start = DateTime.UtcNow;
DateTime end = start.AddHours(1.5);
Console.WriteLine(start);
Console.WriteLine(end);
TimeSpan diff = new TimeSpan(end.Ticks - start.Ticks);
Console.WriteLine(diff.TotalHours);
yep
Just a bunch of scriptableobjects with an ID field?
yeah, you can generate guids for them or i like to give them a string id that is somewhat descriptive
for something as simple as collectibles though maybe even bothering to come up with names is overkill
Nah I've got to track quite a few things.
Specific items across maps, as well as enemies.
Probably worth it to have something a little robust.
i'm just imagining like...if you are placing coins in a mario level, you probably don't want to have to come up with a string name for each coin
but if it's like a weapon or something that is unlocked, that you need to be able to persist so it needs an ID and you may as well have it be something descriptive
Moons from Mario Odessey would be a better comparison.
Objects that need to be tracked.
And should not reappear.
yeah, those having names would be nice because it would make it easier to keep track of how accessible specific ones are and whatnot
Any suggested naming scheme? Some short prefix to imply the type of item and then a number?
Like for the Moon example
Mn-107
the alternative would be to fully serialize each pickup, which you could do but might regret later if they end up having more data in them
nooope
In the scriptable object I can just have a reference to the prefab that it's supposed to represent.
In the case of an enemy or a "Moon".
As well as the ID.
hmm i think i would probably try to do something like mapname_moon_highjump_above_fountain if i could, but maybe i'd give up
that also can get annoying if you are moving them around a lot and then want to change their id
ah yeah, if you need a reference to the prefab then that sounds right
yep, and you could always have 'special' ids for certain ones if you wanted to but maybe consistency is more important
ultimately though it's pretty arbitrary, so do whatever is useful for you
Incoming Smith
why not use an enum?
Not a fan of enums when the "collection" naturally expands.
mapping an enum to an SO is kind of annoying
and uncessary
but you need the SO since it has the prefab ref
a damn sight easier and cleaner than relying on strings
you don't actually use the strings directly, except in cases where that's useful (like a command line interface)
there should be asingle source of truth
I'm pretty sure the souls games and Elden Ring use a numbered ID system
Lots of card games also use internal string Ids.
though Ive sen some with enums
i usually number id things that i'm spawning at runtime and string id or enum (if they are realtively constant) things i set at design time (usually as SOs)
yeah, like my 'cards' have string ids for the SO they are based on, but the instance of the card has a number id since those are spawned at runtime
cards all have names so it makes sense to give the canonical versions string ids
and so that you can have a debug CLI in your game to do stuff like addCardToHand flailing_blow
but for something like moons which are only placed at level design time and don't really get instanced, i could go either way
Looks like i was getting date time wrong I have something more reasonable here
hours worked is in hours
lunch break is in minutes
with this ```cs
public void CalculateHoursWorked()
{
TimeSpan timeDifference = new TimeSpan(clockOutDateTime.Ticks - clockInDateTime.Ticks);
hoursWorked = (float)timeDifference.TotalHours;
Debug.Log("hoursWorked Time difference in hours: " + hoursWorked);
}
public void CalculateLunchBreak()
{
TimeSpan timeDifference = new TimeSpan(endLunchDateTime.Ticks - startLunchDateTime.Ticks);
lunchBreak = (float)timeDifference.TotalMinutes;
Debug.Log("lunchBreak Time difference in minutes: " + lunchBreak);
}
so it was how I was geting DateTime originally
PlayerCrouch has is an animation that shows the player goong from a standing pose to crouching
PlayerCrouchHit is an animation that plays that basically has the crouch player move his shield so it looks like the fireball has been deflected, but when going back to crouch (both are non loop animations btw) it snaps from crouched (cuz thats how player crouch hit looks like) to standing then it crouches again cuz thats how the crouch animation goes
Thats why if the last animation is crouch hit i wanna play player crouch but at the end of the animation where the crouchong part is done and the player is already crouched so it becomes a seemless transition
I'd make a crouched state that is just the crouching, then, and transition to that from both.
Is it more effecient to play the animation at the kater stage? That way i avoid making yet another animation cuz i already have a bunch
you need to make your own property drawer for that
or use some online serializable dicitonaries
sad
i gonna look for another way to do this then
basically what i need :
- read a int value from parameter
- find a texture in a collection
- map it onto a material
<enum, <int, bool>>
so dictionary should be better
just make serializable dictionary
it's pretty easy
plenty of tutorials
Hello all, quick question, is there still no straightforward way to use anaylzers/generators without needing an intermediate dll?
Fairly certain that's still needed yeah.
Although building the dll isn't that much of an issue, presumably you are not changing your analyzers and generators often.
Erh, I guess I'll make a tool to build the solution and apply the tag to the dll then
No, fair, but still ๐ญ
Can't you just copy and overwrite the current dll?
I don't really want to store the .dll in VCS
Hmm, fair.
It's what I do, it's ugly yeah but I don't change them often, and not needing to rebuild it whenever I checkout the project is worth that ugliness.
And if you don't, then I don't want everybody that need to boot up Unity to know how to compile the other solution, copy the .dll in the right place, and tag it properly, especially artists etc.
as weird as it feels checking in DLLs is pretty normal in unity, even with an automatic build system or something it's so much easier to know that everyone on the team is getting the exact same DLL and you don't have to worry about build issues or everyone having build tools installed
hi actually i have removed the google ads from a project and created a build but the apk is crashing with the android runtime error on the logcat
is their some thing wrong with my gradle file?? i'll attach it with this message
apply plugin: 'com.android.library'
APPLY_PLUGINS
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.android.gms:play-services-ads:20.4.0'
constraints {
implementation('androidx.work:work-runtime:2.7.0') {
because '''androidx.work:work-runtime:2.1.0 pulled from
play-services-ads has a bug using PendingIntent without
FLAG_IMMUTABLE or FLAG_MUTABLE and will fail in Apps
targeting S+.'''
}
}
// Android Resolver Dependencies End
DEPS
}
android {
ndkPath "NDKPATH"
compileSdkVersion **APIVERSION**
buildToolsVersion '**BUILDTOOLS**'
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
defaultConfig {
minSdkVersion **MINSDKVERSION**
targetSdkVersion **TARGETSDKVERSION**
ndk {
abiFilters **ABIFILTERS**
}
versionCode **VERSIONCODE**
versionName '**VERSIONNAME**'
consumerProguardFiles 'proguard-unity.txt'**USER_PROGUARD**
}
lintOptions {
abortOnError false
}
aaptOptions {
noCompress = **BUILTIN_NOCOMPRESS** + unityStreamingAssets.tokenize(', ')
ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:!CVS:!thumbs.db:!picasa.ini:!*~"
}**PACKAGING_OPTIONS**
}
IL_CPP_BUILD_SETUP
SOURCE_BUILD_SETUP
EXTERNAL_SOURCES
I have quite strange bug. I have sound source that has mixer connected. First sound on that source gets played but others dont. Anyone encountered this behaviour?
this is a code related channel man
Morning all. I'm evaluating water depth for players using FindWaterSurfaceHeight. When running as a server, with no active camera present, it seems this function doesn't work. Does anyone know how you could still return depth at a specific point in a water plane when no camera exists?
Hey! I have this annoying problem with VS Code putting starting braces on a new line, instead of if (foo) {. I've set csharp_new_line_before_open_brace = none in .editorconfig, and some days it works! Very random, very inconsistent. I worked on this yesterday, and everything was working. Started VS Code today, and when I save it reformats the whole file.
Not sure how to debug this, and it's driving me mad. Do you have the same experience?
Are you using C# Dev Kit or only the C# extension?
Although I do have to say, braces on new line is the C# convention, you should probably get used to it and follow it like rest of the community ๐
I've tried both. Is any preferred?
Ah, hate that convention. So very verbose, and leads to people skipping braces completely, which is a problem on its own.