#archived-code-general
1 messages · Page 53 of 1
that's not helpful. We understand that part
but do you see logs, etc.
be more specific and let's not play 20 questions here
there is no error in logs
Confirm it gets through the code.
Confirm m_strImagePath is a valid location.
Confirm pngBytes builds a proper image, or has any bytes at all.
Anyone got any ideas about this custom pass issue? HDRP chat is very slow 🙂 #archived-hdrp message
Okay question. Is there anyway to get a projected position for a PlayerCharacter? Like I could do the math, but I am hoping there might be something built in for physics. Like what the position will be in a fixedUpdate later then the current one?
I am wanting this so I can have the camera/character graphics still be moving every frame, while the physics collider is between calls.
As the graphics/the camera renders at 120fps currently.
and physics is 40
Or possibly have physics update at 120fps for only the player character object?
Kind of depends on your PlayerCharacter.
Extrapolation will predict the position of the rigidbody based on the current velocity.
https://docs.unity3d.com/ScriptReference/RigidbodyInterpolation.Extrapolate.html
There are a whole bunch of extrapolate or interpolate functions, you could study those if they fix your issue.
But afaik the basic extrapolate can't predict far into the future, but its probably a good starting point.
Ah nice. Yeah I don't need more than an an update or two, so that might do the trick
I'm trying to use the GL system to draw lines but can't seem to get GL.Multmatrix method to work. The lines won't leave the default world rotation/position.
Right now my code is as follows: (abreviated)
//class GLLines
void drawLine(Color color, Matrix4x4 matrix,Vector3 Start, Vector3 End)
{
GL.PushMatrix();
//GL.LoadIdentity(); //tried both with and without
GL.MultMatrix(matrix);
GL.Begin(GL.LINES);
GL.Color(color);
GL.Vertex(Start);
GL.Vertex(End);
GL.End();
GL.PopMatrix();
}
void Update()
{
GLLines.drawLine(Color.red, transform.localToWorldMatrix,Vector3.zero, new Vector3(512,256,0));
}
what am I doing wrong here?
So I try that on another computer and it shows this
Does that mean there is something wrong with my codes or VS?
you have to also multiply your matrix by the camera worldToCameraMatrix
you can use Camera.current if you want it to also work in the scene view
but you will want to call the method in OnDrawGizmos also
you are recreating the behaviour of Gizmos.DrawLine though, just so you know
It refers to AssemblyInfo.cs which is not that file
Which is weird
Interesting to know, but I want to use this code in a build so gizmos wouldn't be usable.
Sadly enough, it doesn't seem to change the result
what is your new code?
void Update()
{
GLLines.drawLine(Color.red, transform.localToWorldMatrix * Camera.current.worldToCameraMatrix,Vector3.zero, new Vector3(512,256,0));
}
The other code has not changed
uncomment the load identity line in the drawline method
and I think you can use OnPostRender() if your script is attached to a camera
Uncommenting load identity doesn't change the result :(
I thought that OnPostRender didn't work in URP?
you never said you were on URP, but regardless I have no idea
[UsedImplicitly]
private void OnPostRender()
{
var matrix = m_lineParent.localToWorldMatrix * m_camera.worldToCameraMatrix;
DrawLine(Color.red, matrix, Vector3.zero, Vector3.up, m_material);
}
private static void DrawLine(in Color color, in Matrix4x4 matrix, in Vector3 start, in Vector3 end, Material material)
{
material.SetPass(0);
GL.PushMatrix();
GL.LoadIdentity();
GL.MultMatrix(matrix);
GL.Begin(GL.LINES);
GL.Color(color);
GL.Vertex(start);
GL.Vertex(end);
GL.End();
GL.PopMatrix();
}
this works fine for me though (I am on standard pipeline)
the math should at least work in OnDrawGizmos though
then you could figure out how to make it work in the build
that doesn't work on my end, at this point I'm stumped as to what it could be that causes it to not work. Thanks for help though, really appreciate it
weird, I blame some URP magic, not sure
unfortunately don't have a URP project for testing
yeah, seems like there is URP weirdness interfering, you might have to experiment a bit
the math is fine though, it's just a matter of where the code gets ran
Hey, I'm trying to stop a coroutine before starting again, but somehow the coroutine I stopped still runs, and interferes with the next one.
combatEffect.currentBubbleCoroutine = StartCoroutine(combatEffect.CombatDialogue(buckAI.dialogueBuck[5]));```
Any idea what could be the problem pls?
Is your coroutine maybe starting another one inside?
Oh...
Yeah I didn't think about that, I need to stop both then
How do you call the other one?
{
List<(int, bool)> sentenceCut = CutSentence(text);
bool ponctuation = false;
bubbleObject.SetActive(true);
bubbleText.text = text;
bubbleText.color = new Color(0, 0, 0, 1);
bubbleRend.color = new Color(1, 1, 1, 1);
SetVoices(sentenceCut);
int letterCountToNextSound = 0;
bubbleText.text = "";
foreach (char letter in text)
{
if (letter == ' ')
{
bubbleText.text += letter;
yield return new WaitForSeconds(0.025f);
continue;
}
if (letter == ',' || letter == '.' || letter == '?' || letter == '!')
{
ponctuation = true;
bubbleText.text += letter;
yield return new WaitForSeconds(0.025f);
continue;
}
else if (ponctuation)
{
yield return new WaitForSeconds(0.25f);
letterCountToNextSound = 0;
ponctuation = false;
}
if (letterCountToNextSound == 0)
{
PlayNextSound();
letterCountToNextSound = 4;
}
letterCountToNextSound -= 1;
bubbleText.text += letter;
yield return new WaitForSeconds(0.025f);
}
yield return new WaitForSeconds(3f);
StartCoroutine(FadeBubble());
}```
!cs
ah so your fadebubble is the one that is still running, right?
Basically it makes a bubble pop and fill it with text, than it makes it fade. But I guess there's a timing where the FadeBubble is running while the other one has stopped
Makes a lot of sense, I didn't think about that thanks a lot
you are welcome 🙂
I'm trying to set the simulation time for HDRP Water Surface so I can sync it in multiplayer but I don't see anything for that...
What's the point of making a material synced in multi? I thought that was a client side thing
Maybe for something like Sea of thieves to have the same waves going on
exactly
if not synced, one might see a big wave but host sees nothing and it gets weird
Did you check the shader and its values? Like the code version of the shader to see what modified it actually makes available?
where is the shader?
right click you rmaterial of your water and edit shader or script or something should appear
Let me check
Well, for a case like this I thought you'd base the shader on the physics
But yeah I'm not knowledgeable about multiplayer to say I'm confident about it
You rather set the values for all palyers and the client will react physically.
it doesn't have a material i can assign a custom one
Oh okay, let me check, never used the hdrp water itself. Can you link it real quick?
no documentations on Water Surface component either
seems like a new thing
Ohhh, its a totally unique component. welp, can you right click edit script?
yes i did check the script
there seems to be a section for simulation time which is private...
But maybe you can overwrite the full renderingparameters?
Like you have to do with particlesystem emission modules, maybe this is also some kind of module
there is nothing for that
Well it is quite new, gonna look at that myself in the next days. I would just tinker and test around with the scripts and see if I can overwrite anything or create from scratch in a script
Do you think there's something wrong with this code?
var go = new GameObject("_Guardian")
{
transform =
{
position = transform.position
}
};
var constraint = go.AddComponent(typeof(PositionConstraint)) as PositionConstraint;
if (constraint != null)
{
var source = new ConstraintSource
{
sourceTransform = transform
};
constraint.AddSource(source);
constraint.constraintActive = true;
}
It creates a GameObject called "_Guardian" and adds PositionConstraint component to it which has another gameobject (transform) as source transform. For some reason this _Guardian gameobject does not follow sourceTransform even though when I do exactly the same setup in the Unity editor it works.
You can't assign the Transform of a GameObject.
You should just use the generic form of AddComponent
Did you mean to make the object the script is attached to be the constraint target?
also not sure why you are checking for a null constraint when you just created it
Probably because of the as cast
Which is a side effect of the whole not using the generic form of AddComponent thing
Generic form?
go.AddComponent<PositionConstraint>();
You should probably set the weight of the constraint source too?
It is 1 by default and in the inspector everything looks like when done manually
I will try with generic approach if that makes a difference
There's other fields too like https://docs.unity3d.com/ScriptReference/Animations.PositionConstraint-translationAxis.html
Maybe this constraint is somehow broken in Unity 2022.2.x which I'm using... no luck
Show the inspector of your object
After creation
I really think your field initializer for the Transform is fucked though
All position axes are frozen
Isn't that wrong?
Also the source weight is 0
That's also wrong
Actually that might be the reason, source weight.. I thought it was source index
But axis is set like that also when it's working when done manually
Yep, working now that I set source weight
Thank you, I missed that one when trying to figure out what is the difference between manual setup and scripted 🙂
Following the player nicely now.
What would happen if I try to deserialize a json file, containing a deriving class as their base class. Can I cast it into the deriving class afterwards, or will it just throw an error?
Depends on which serialization framework you use
In general you would need to store type information with the data
Newtonsoft JSON has support for this
Okay thanks! But I am using JSONUtility so I guess will have to find some sort of workaround then.
jsonutility is pretty barebones tbh. i'm not even certain it supports polymorphic deserialization. you'd probably have a better time switching to newtonsoft
Unity now holds newton as a package itself, you can just use it instead of JSONUtilitiy
Forgetting JSONUtility has ever existed is the best thing you could ever do
Unity has a Newtonsoft package which is a million times better
The limitations of JSONUtility is so laughably bad that I am surprised Unity even still has it available as an actual feature
I will give Newtonsoft a try then; thanks guys!
How can I serialize an SO into the UserSettings/ folder?
I still rock it
The novelty of JSONUtility is that it uses Unity's standard serialization mechanism. It's also faster than Newtonsoft
I have a frustrating bug that googling doesn't seem to find anything.
I'm loading images (sprites) from a 'Resources' folder using, 'Resources.Load<Sprite>'
This function/method is called once, when the card is created. It sets the image, and all is good. At a later time, it's called once, setting the image/sprite of another object. Which works. It finds it's own image, and it finds the other object's image. But... it then changes what it's own image is. It never actually does it, it only runs this search again. Which gets applied to both objects for whatever reason. It's retroactively changing the variable of the first one.
In short,
Image1 = Image1.png
Image2 = Image2.png
Now Image1 and 2 both equal 2.
public Sprite SearchDownloadCardImage(string cardName)
{
// In the future, this will actually search for and download images. Right now it can only pull files that are already downloaded.
try
{
Sprite result = Resources.Load<Sprite>("Card Images/" + cardName);
if (result != null) return result;
}
catch
{
Debug.Log("Failed to find '" + cardName + "' in the Resources file.");
}
return DefaultImage;
}```
With a bunch of debugging, I'm 99% sure it's only this line of code breaking things.
Anyone knows where to find navigation algorithms for such a node map?
A visual of what happens btw. The large image on the side should be a zoomed in picture. Finding that picture (when no sprite of it exists), requires I search the files again. Which changes the original.
https://gyazo.com/2d2db811d80a6554b8b8d82f38285fb0
Poor guy
Yeah my game is also 100 times faster than the next triple A game but it's not gonna beat that game any time soon when it comes to actual features and such
Because as soon as my shit game is actually going to function like it's supposed to it will encounter a lot of features that will chew on that performance
Now take a guess how JSONUtility relates to this
Unity is throwing an error up in a class I made when I try to make a public image variable saying "the type or namespace 'image' can't be found" but I have got using UnityEngine.UI; at the top. It's a 2nd class inside the same file as another class. A tutorial done in 2020 Unity shows this working but it's not in 20201 LTS Unity.
make sure you're spelling it correctly
It's a PlayerNeeds class file with a 2nd class of "public class Need"
public image uiBar;
Make sure that image is uppercase.
make sure that your !IDE is configured so you don't make spelling mistakes like that
using UnityEngine.UI; is at the top of the file
If your IDE is not autocompleting code
or underlining errors, please configure it:
• Visual Studio (Installed via Unity Hub)
• Visual Studio (Installed manually)
• VS Code*
• JetBrains Rider
• Other/None
*VS Code's debugger plugin is unsupported.
We recommend using VS or Rider instead.
the loading part itself should create 2 distince sprites that dont share anything, i assume even if you load the same sprite twice
oh yeah umm I changed the editor in unity preferences before to visual studio community but the change didn't stick 😦 no idea why not
so thats not the cause. the DefaultImage could become a shared object
all in all, i smell that this method is probably not the cause
you may need to launch unity as admin if the setting didn't stay after restarting. you can do so by completely closing unity and the hub then launching the hub as admin
ahh ok cool ty 🙂
Default image is never used. This method is the only thing that sets the card's image, and sets the zoomed in one, when it's alone (in play). When the one line that calls this method is commented out, everything is fine. (It just doesn't display anything when the card is in play. If I were to skip calling this method during the in play exception, and skipped right to giving it the Default image, everything is good.
This method is retroactively changing what it found the first time.
sprite and cardname are local to the methods scope. it cant change them that way. can you show the surrounding code?
It should make two distinct spite variables, but that's not what happens for some reason
I can... but I just left for work. So I can't do it for a few hours sadly. Ttyl
any idea to implement AI that you pointed
I have done the previous steps just creating the AI is left which seems to be important 😅
How do I give such red and green outlines dynamically?
This is a standard graph and will work with standard graph algorithms like Dijkstra's, A*, DFS, BFS etc
can't even serialize dictionaries smh
Can't even serialize arrays without wrapping it in an object first
it can just not as the root object
Yes that's what I mean
when the game moves from lvl 2 to 3, the transition animator controller gets removed from the inspector. It works fine from lvl 1 to lvl 2.
I dont think the issue is on that code
all the errors that are thrown, reference it. I'm certainly not saying your wrong, but I am def stumped.
tbf
you didn't share the errors
MissingReferenceException: The variable transition of LevelLoader doesn't exist anymore.
You probably need to reassign the transition variable of the 'LevelLoader' script in the inspector.
UnityEngine.Animator.SetTrigger (System.String name) (at <b492836710f1493ca0190fe9374a37da>:0)
LevelLoader+<LoadLevel>d__5.MoveNext () (at Assets/Scripts/LevelLoader.cs:27)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <db7f68c084e842d98504c53b2b4dd3db>:0)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
LevelLoader:LoadNextLevel() (at Assets/Scripts/LevelLoader.cs:19)
LevelLoader:Update() (at Assets/Scripts/LevelLoader.cs:37)
Where are you setting that transition variable?
Find All References
look for ones that write
How do I get the prefab of a prefab instance?
click the select button in the inspector
at the top, Animator transition.
I mean with code
If you instantiate an instance of the prefab you must have a reference to it somewhere
What exactly do you want to do?
It tells you what to do, doesnt it?
You're not referencing it anywhere else in code? make it [SerializeField] private instead of public and see what happens
I have a serialized list of references to prefabs and I need to get index of my GameObject's prefab (original) from this list
is is assigned and when the lvl changes, it gets unassigned.
the list of referenced prefabs is runtime prefabs or drag dropped from the project view?
drag n drop
then you can just pass in the indexOf your prefab to your runtime reference
Does your new level also have the thing assigned correctly?
Can you rephrase?
If you have a list, you can use IndexOf(yourPrefabSource) to pass in a value to your prefabInstance. So you set it when instantiating.
I don't understand what "to pass in a value to your prefabInstance" means.
As I see it, I need first to get the prefab of my prefab instance
you might wanna reprhase your question. Why do you need the index of the source?
yes, all scenes it is assigned.
did you change from public like I said?
How did you assign it? Do you open multiple scenes in edit mode and assign frmo scene A to scene B? So crossscene references?
Because Popup from UI requires working with ints so I need to pass there an int, the index in my case
do you have some code to look at? where you instantiate and where you need the index?
Something like this for the moment
int currentIndex = Array.IndexOf(agent.nodeMap.nodeData.agentPrefabs, agent.agentPrefab);
_agentTypeIndex = EditorGUILayout.Popup(currentIndex, agent.nodeMap.nodeData.agentPrefabs.Select(x => x.name).ToArray());
agent.agentPrefab = agent.nodeMap.nodeData.agentPrefabs[_agentTypeIndex];```
Let me lookup the popup function, never used it. Should have told you are working in editor scripts 😉
Sorry
yes, I got the same errors, Im trying to find other refs, but I had some other stuff come up.
So what part of the code is your issue now? The currentIndex value? Is it wrong, do you get any error?
its a game that is built one island. each scene/lvl is a duplicate of the first and then objects are moved around to create new tracks to drive on. I have opened each scene to make sure it is there before testing.
Want to simplify the insides of Agent. It now has reference to the created GameObject so I was thinking of calculating the index using it instead of keeping reference to the prefab in Agent
Your problem might be, that you close one level and then it loses the reference. when you click on Scene B on the reference that gets missing in playmode, does it direct to scene B or another one?
Are switch expressions just lambda expressions for a switch statement, or something more?
Oh well, looking at the microsoft docs, they might be a little different as you can convert values to a desired target value on different types
public static Orientation ToOrientation(Direction direction) => direction switch
{
Direction.Up => Orientation.North,
Direction.Right => Orientation.East,
Direction.Down => Orientation.South,
Direction.Left => Orientation.West,
_ => throw new ArgumentOutOfRangeException(nameof(direction), $"Not expected direction value: {direction}"),
};
Hence this example here
Im sorry, im not following you.
Just answer the last question 🙂 You set the references in the inspector. What is reference from Scene B pointing at? At an object on scene B or another scene?
Is it possible to modify/preview a material property block in the editor?
if you can invoke the code for it while in editor mode sure
I want the optimisation without losing the nice material editor.
That's what I thought.
Yeah, I can do that haha, going to be annoying in prefabs though.
Well yeah.
But that doesn't mean you don't want an artist to pick the colors and preview them
Or is there no difference between property blocks and authored materials for performance?
but yeah you could easily hook it up in OnValidate or something
so it changes during edit time
Yep, it's easy enough to do for sure.
Depends if you're using SRP Batcher or not
SRP Batcher prefers material instances
Is that something that's on by default in URP?
I imagine so. I think it's a hidden setting.
Okay, so we're probably using it. In that case it will be easier to just create materials.
Seems I have wasted some time here.
Yeah, I said "prefers", but MPB actually breaks batching when using SRP Batcher. It just doesn't know what to do with it so it doesn't combine it with anything.
It can still fallback on GPU instancing if the material supports it.
I'm not even concerned about performance, I'm just mildly worried about artists authoring a whoel bunch of the wrong kind of asset.
Material variants in 2022 will help with this.
Prefab Variants and Material Variants have much the same functionality, ... There are two key differences between them:
You can reparent a Material Variant.
You can lock Material Variant Properties.
Beautiful
Uhh the second one is nice
Hey, is the Time.time accurate for audio? I'm pretty sure music still runs in most game when having a freeze, so I suppose it's not.
I'm trying to count the time so that I can switch music on a beat
Just answer the last question 🙂 You set
I've got text with a content size fitter inside a layout group (so the textbox resizes automatically). But it doesn't correctly update the first time text is posted. I'm even doing THIS
There's AudioSettings.dspTime
Yeah I just noticed it in the example for AudioSource.PlayScheduled
Any idea on how I could procedurally generate a desert? (like the one in the photo, source: https://blenderartists.org/t/procedural-desert/1321823)
I was thinking about using cellular noise to generate the dunes, and then use a "zoomed out" perlin noise to offset the dune height (and avoid that every dune has the same height), but dunes don't seem to have straight edges like cellular noise does
This is (I thought) forcing the text to update and the layout group to update... but it still doesn't do anything initially
you could offset the x z values depending on the y value in a "wind direction"
How many of these timelines are they btw? Cos I can count at least the usual one, the physics one, and the audio one
and make the wind like a bit of a randomized sine function.. it seems like it could work!
Maybe I could something like a 1d perlin noise to offset the dune
Thanks!
But that's a feature that also cellular noise has (don't mind the 3d sphere)
Maybe it's not that good the cellular noise.. I'll see
you could just have a range decreasing for the x values too while that range gets offset depending on the y value
Physics tries to keep up with Time.time, in fixed steps.
like decrease the range to get sharper edges AND shift that range to get those steep cliffs
I think Audio is the only one that's completely separate.
So should this be having the effect I want it to have? actionDescription being the text itself and actionAttributeLayoutGroup being the vertical layout group of the parent object which the text is childed too.
Makes sense, freezes would be horrible in gameplay
Thanks, I'm pretty sure I'll just adapt the example of PlayScheduled on the unity docs, but I wanted to understand it beforehand
First time this menu is brought up (first time text is populated)
Second time. (This is correct)
Is this a normal issue or
That's what happens when you don't do ForceRebuildLayout
!!!
You might not rebuilding the correct parent
Maybe you change stuff before the rebuild? Idk I've had trouble with that as well and ended up doing it in editor rather than code
Hm? Don't you want to do the rebuild as the last thing?
Yeah that's what I meant
Maybe show your full code
Does ForceMeshUpdate on the text do anything relevant?
It updates the TMPro but not really playing into the UI recalculation at first I think
It's basically just inserting a bunch of text from places and then doing the layout rebuild
I'll play around with it some more
I'll just put that link there, I followed the tutorial and it saved me a lot of troubles
Do you reubild after the bunch or after every text?
NullReferenceException: Object reference not set to an instance of an object
OfferIcon.SetAmount (System.Int32 tmpamount) (at Assets/Scripts/UI/MainMenuScripts/Offers/OfferIcon.cs:28)
OfferIcon.Spawn (UnityEngine.UIElements.VisualElement tmp, OfferIconTrees offerIconTrees) (at Assets/Scripts/UI/MainMenuScripts/Offers/OfferIcon.cs:33)
Offer.Initialize (OfferData data, UnityEngine.UIElements.VisualTreeAsset tree, OfferTypes tmptype, OfferIconTrees offerIconTree) (at Assets/Scripts/UI/MainMenuScripts/Offers/Offer.cs:38)
ShopOffers.InitialAddOffers (OfferData item, OfferTypes tmpType, System.Int32 timeOffer) (at Assets/Scripts/UI/MainMenuScripts/Offers/ShopOffers.cs:88)
ShopOffers.InitialAdd () (at Assets/Scripts/UI/MainMenuScripts/Offers/ShopOffers.cs:48)
ShopOffers.Start () (at Assets/Scripts/UI/MainMenuScripts/Offers/ShopOffers.cs:25)
assuming you see somehting like this error
is there a fast way to get to the "top" aka jump to OfferIcon.cs:28
instead of jumping into ShopOffers.cs:25?
Still having an issue with being able to set the "plant" GameObject to be 10 below the current y value of a TunnelArray object, it moves to the spot, just not 10 below.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Lol, yes, it appears I was overcomplicating it. Had an unnecessary content size fitter which apparently was messing things up
What do you mean by "not 10"? I think the problem is between local and non local scale
Like it should be subtracted by 10.
If the object is not root of the hierarchy, and one of its parents scale is not 1, the position will get affected by the scale
Like say if it was put at 0,10,0, the code should just have it be 0,0,0.
I'm not sure I follow.
Say you have 2 objects, one parent and one child
If the parent scale is (1,1,1), and you code child.transform -= new Vector3(0,10,0), the transform will be the same, -10 on the y axis
If the parent scale is (2,2,2), the child transform will be the same, -20 on the y axis
If you want the child to be the same -10 on the y axis, you need to use transform.localPosition
Rather than transform.position
I'll try that, thank you.
So I have a line like this
where Unit is a general Unit script. Recently I refactored some stuff so that now different units have their own unit classes that just inherit the general Unit
(so UnitMage : Unit, UnitWarrior : Unit, UnitGoblin : Unit)
I think that's a bad practice in Unity in general to use polymorphism that way 🤢
how do I get that component without knowing the actual name of the class?
Yep it does but when I try to get unit.skillArts[0] for example, I don't think that works anymore?
yeah, so it should work? hmm
Better practice btw would be for those GameObjects to just have multiple components:
Unit AND Goblin
Unit AND Warrior
composition > inheritance for Unity
It should not
that's the point I'm making
don't use inheritance like that
What happens if you want a GoblinWarrior
or a Goblin with a shield
Do you make GoblinWarriorWithShield: GoblinWithShield : Goblin : Unit ???
It's not a good model
the better model is you have a GameObject named GoblinWarriorWithShield that has multiple components attached:
- Unit
- GoblinAI
- Shield
But in my case I have like 50 heroes/units that all share the basic rules for everything, like default movement, taking damage, having two skill buttons (one of which can be disabled) etc.
Still does not appear to be working, but I'm wondering now...
Would the Start method override anything?
So what if I want to override something in Unit? Let's say that Warrior doesn't use default movement but a slower movement instead
and it has the Unit and Warrior components
what does the Warrior component do if it can't inherit the default movement even (to be overridden)?
Make movement a separate component entirely
or movement is handled in Warrior / Goblin, not in Unit
And can't "slow" just be handled by a public float speed; variable on one of the scripts?
You don't need inheritance to have a different speed value
No because the movements are tile-based and might be in different shapes, not a value
So you have:
TilebasedMovement
LMovement
etc. components
these should not be part of Unit
//The "Tunnelling" section for the Plant. Plant burrows down, selects spot before coming up in later section.
public void PlantTunnel()
{
plantIndex = Random.Range(0, 3);
plantStatus = 1;
transform.localPosition = tunnelArray[plantIndex].localPosition + new Vector3(0, -10, 0);
}
public void PlantUntunnel()
{
transform.localPosition = tunnelArray[plantIndex].transform.localPosition;
plantStatus = 2;
}
Was this what you meant when using transform.localPosition?
or maybe Unit just has a MovementStrategy enum field
etc..
I'm throwing things out there because I don't know how your game really works but, reaching for inheritance to solve every problem is a bad instinct in Unity.
Well the core issue is... my Unit script is like 3000+ lines long, and it's structured so that each different hero or unit has a "UnitID" which is just an integer.
Then we come to the "CheckMovement()" function for example that checks which tiles the hero is allowed to move to based on their movement rules, and inside it there is a massive if else chain (not even switch for christ's sake) that checks if unitID = 30, check these tiles: if unitId = 35, check these tiles:
etc.
Post it in Pastebin
doesn't that sound horrifying? And that goes for everything
and I figured I'd make a base Unit class that has the defaults for everything, and then each unit has an inherited UnitWarrior for example that might override the default CheckMovement() in some unique way
right so - this does sound horrifying. That's why all of the different units should be in separate scripts.
What I disagree with is that those separate scripts should inherit from Unit
movement rules in particular can be one script or a separate script hierarchy (BaseMovement, GridMovement, whatever)
I figured it out
things dealing with basic health/unit targetting can be another script (the Unit script)
if(plantStatus==1 && plantStatus < 5)
{
transform.position = tunnelArray[plantIndex].position + new Vector3(0, -10, 0);
}
My solution.
So, it didn't update it... but did?
I put this in the update method just in case and it fixed it.
Welp, I'm happy now.
Also… 3000+ lines…
Why
That… I get maybe having 100+ if it’s like a really heavy script and it needs to be all in one.
But 3000+?
Okay this makes sense but it circles back to my original problem.
Let's say I have a function that should check movement of ALL units currently on the field
it would need to call the CheckMovement() (or similar) of each different Movement component
How do I do that?
Or actually... should Unit have a reference to it's correct movement checking script
foreach (Movement movement in allMovementComponents) {
movement.CheckMovement();
}```
Unit can have a reference to the Movement script if they are separate, yes
That would actually make a lot of sense I think. So for each different hero I will go and have Unit component which has a Movement script reference, and for units that don't use the DefaultMovement script (for example) I just set WarriorMovement there. Would this make sense? So then I could make all units check their movement and they will do it using the attached movement script
Is this a sensible solution or am I still gonna do something horrifying
yes something like that sounds sensible
I think for Movement in particular inheritance might make sense within that area
it would then be super easy for you to mix and match things
like a Goblin with a TileMovement and another Goblin that has JumpMovement (just making things up)
Thank you so much for the help. Actually awesome explanations and I feel I learned something from this
I'm in for some insane labor though because movement is only one of the many things Units have. So gonna have to split the current gigantic Unit script to tens of other scripts but oh well this is a hole I've dug myself into
how can i use .FirstOrDefault() on a NetworkList or at least convert the NetworkList into a standart list?
hello, i am struggling to wrap my head around this problem, I want this cleaver to slice the fish in half, but the user will have control over where to slice. How could I dynamically slice the mesh? I was thinking of duplicating the object and hiding part of it, but cant find a way to do that. Would really appreciate advice (or point me to the right channel)
Was afk, not really sure since idk what tunnelArray is. If that's something you define in editor, like storing the value that you see of the object at its right place, yes.
Is there a way to have 1 particle follow a path or game object. Example if i spawn a glowing knife that is supposed to chase a unit. Does that knife need to be a game object or can i do it with particles? the unit can run anywhere i just need the knife to chase it
why would you want it to be a particle instead of a game object?
I have no preference. I just downloaded some cool effects and wanted to use them. they are all particle systems so i was wondering if that would work
just make a gameobject with the same texture and material and all that
and then look up on youtube how to make it follow another gameobject depending on if you want it to just go in a straight path or act like a missile or whatever
could try using something like this https://github.com/DavidArayan/ezy-slice (I've never used it personally but it's an option)
oh! awesome! thanks! I also ended up finding this : https://www.youtube.com/watch?v=InpKZloVk0w which ill put in case anyone else has the same issue
🌍 Get my Complete Courses! ✅ https://unitycodemonkey.com/courses
👍 Learn to make awesome games step-by-step from start to finish.
🎮 Get my Steam Games https://unitycodemonkey.com/gamebundle
💬 ProBuilder has an awesome feature that is surprisingly hidden.
You can make various Boolean operations on your Meshes allowing you to easily Slice, Cut, B...
does anyone know how i'd go about combining multiple images into one procedurally in script, but not just overlayed on top of each other or anything, but where each image takes up a portion of the image?
so if it's 3 images combined into one, each one takes up a third of the image
there are several paths of varying difficulty you could take. For what reason are you trying to do this?
for example, if you simply must have them combined into one image, it's certainly possible. But if you're just trying to show multiple images in the ui as one image, you could use Masks and it would be a lot easier and flexible
oh i think having them be multiple images but show as one would work just fine
how would i do that using masks?
Set them up in whatever arrangment you want and each mask gets a child with the image you want to show in their section
I figured it out, update wouldn’t run the stuff well enough.
It triggered it, but didn’t update fully
Idk
i don't want to have them in sections like that though, i want all of them to be in the same spot but different parts of each be visible, if that makes sense
imagine a pie chart kinda deal
you can do that
oh i see what you're saying
i'm not sure how to get them in the arrangement that i want though
splitting it up like that i mean
I believe unity provides a circle sprite that you can radially fill
bet i'll check that out ty
@swift falcon no code necessary
doing it procedurally based on a variable number of images would be a different story
i would want to do it procedurally but i don't think it'd be too hard
is it possible for something to have a SortingOrder only within its context?
i.e. ive got a panel with sorted stuff and I put this panel on top of itself, i dont want the things from the behind panel to show through
sorry
Does anyone know any good Unity beginner guides for people who already know how to code?
I'm looking for something like a series of tutorials on creating an example project that doesn't also teach you basic coding..
There's a lot to unity that isn't just API stuff
Not a dumb question. Unity development is conceptually different than traditional application development. Case in point - frames.
That said, Unity Learn is a good place to start @quasi stirrup
where did he say he doesn't know c#?
I know C#..
and since when is C# somehow unique from all other languages
and even if I didn't Java is extremely similar
most of them are quite similar
thats why they are asking for beginner guides
to Unity
I'm trying to find something for unity that doesn't try to teach me what a variable is for the 50th time, not exactly groundbreaking
imagine this scenario: you are an experienced 3D modeler, but you switch from Blender to Maya... You don't need to relearn basic topology rules and general good practices, you just need to learn the new tool
so naturally you would ask for beginner maya tutorials that already assume you know things about modeling
instead of starting from complete scratch
Hi, I'm trying to make an object swing like on a rope
Transform attachedRigidBodyTransform = _attachedRigidBody.transform;
Vector3 offsetToAttachedRigidbody = attachedRigidBodyTransform.position - transform.position;
Vector3 directionToAttachedRigidbody = offsetToAttachedRigidbody.normalized;
// Set the distance to the rope length.
if (offsetToAttachedRigidbody.magnitude > _ropeLength)
{
Vector3 newPosition = transform.position + directionToAttachedRigidbody * _ropeLength;
_attachedRigidBody.transform.position = newPosition;
}
// allow swinging of the object,
// by adding a force in the opposite direction of the offset.
float forceMultiplier = Vector3.Dot(Physics.gravity.normalized, directionToAttachedRigidbody);
_attachedRigidBody.AddForce(-directionToAttachedRigidbody * Physics.gravity.magnitude * forceMultiplier, ForceMode.Acceleration);
this is my rope code, the rope object is located at the anchor
the attached object swings, but it stops at the midpoint instead of swinging the other way
the rigidbody has no non-angular drag on it, and there is no other things affecting the swinging object
Why doesn't it swing properly?
code is run in fixedUpdate obv
I'm not asking to skip learning API I'm looking for a tutorial that doesn't make me re-learn C#
hi ,
I wanna run function on a button is Pushdown/pressed even not on click
basically, I want to manually activate some animation/sound on press
you may say I want to create a custom PressedColor effect for the button
Add an EventTrigger component
and add a PointerDown event
(you can even delete the Button component if you don't care about normal button stuff)
Thanks ❤️
can someone help me with this please?
I'm not sure where to even begin looking for the bug
what's the point of the force you are adding?
to make it swing instead of fall, to simulate the pull of the rope on the object
Are you not using a joint?
nope, just 2 objects with a script
that said, I could look up joints, didn't have a chance to use them before
typically ropes are made with HingeJoints
I do not need to visualise the rope itself, I just need the object to float as if it was swinging, while still colliding with other objects
I didn't say anything about visualizations
I mean - many hinge joints would require me to make a string of objects between the anchor and the attached object, correct?
I do not need that, even though it would maybe be more accurate, I just wanted to make a simple rope swinging with a bit of math
Or is using hinge joints the easiest way?
many hinge joints would require me to make a string of objects between the anchor and the attached object, correct?
That's the typical approach yes
I do not need that, even though it would maybe be more accurate, I just wanted to make a simple rope swinging with a bit of math
Sounds more like a rigid pendulum than a rope then. In which case you can just do ONE hinge joint
I just wanted to make a simple rope swinging
there are lots of good unity assets that tackle this problem
paid ones, unfortunately :/
I'll play around with that then, thanks
yeah i would roll with a paid one
it's complicated
there's no "just" and rolling your own
obi rope is pretty mature
this isn't exactly a project for paid stuff
and my budget is very tight rn, so I can't really afford spending on unity assets :/
especially with the conversion rate of my currency to usd
How do you folks handle chaining transient modifiers together? An example would be MovementSpeed which can be modified by powerups, the "sprint" button, equipment the player is wearing, etc. Since these things modifiers are transient (I expect them to change often during the course of the game) and numerous, I'm trying to design an easy-to-maintain system which can reliably apply modifiers.
The system I've prototyped is a list of delegates related to the attribute being modified. Each delegate represents a modifier and it is identified by an enumeration. A list of the active modifiers, identified by their enumerations, iterated through to determine the current value whenever a modifier is added/removed. For example, one delegate would multiply the current value by 2, another would add +1 to the base value, and a third would divide the current value by 2. This turns the determination of current state into something of a functional mathematical problem instead of embedding it elsewhere in the game logic, and it also provides a mechanism for checking active states for problems that are simple enough that they don't require a full-blown FSM with transitions and what not. I do see a few disadvantages. however, and I'm wondering what other folks do.
Thanks for any response!
basically something like:
float baseValue;
HashSet<AdditiveModifier> additive;
HashSet<MultiplicativeModifier> multiplicative;
public float EffectiveValue => (baseValue + GetSumOfAdditiveMultipliers()) * (1 + GetSumofMultiplicativeModifiers());```
then you Add/Remove modifiers as needed
you can make a float cachedValue too, and only calculate once when adding/removing a modifier
Fantastic! That's almost exactly what I have. I was wondering if I was overcomplicating things in an attempt to achieve what I thought was an intuitive solution, but seeing that you do something similar puts me at ease. Thanks for the response!
Is there any way to have 2 functions with the same name and same arguments types and order but implemet 2 diffrent logic on the same class ?
Why HashSets? My first instinct would be to have a sorted list where each modifier can specify a priority.
but addition and multiplication are associative commutative* always get those mixed up
This was quick and dirty but HashSet to facilitate efficient arbitrary addition and removal operations
If you use sorted list then when you remove you have to do so by the priority as the key? That's funky
anyway this implementation is commutative so order doesn't matter
no, can't have two methods with the same parameters. you need to have different parameters, especially if each method does smth different . . .
So what else can i do do acheive this ?
have different parameters for each method . . .
the real question is what does each — method — implementation do?
why you trying to tie two different implementations to the same method name? trying to confuse someone?
@hollow junco if they do different things, they should have two different names. the parameters can be the same if you want . . .
Because they implement a function with that specific name@in the base interface. But in the class this function behaves diffrently depending on some circumstances
if (someCircumstance) {
// something
}
else {
// something else
}```
then check the circumstance and call the class method . . .
Yea that was my thought but its gona be “alot of those so i thoguht sth might be better than if or switch
how on earth would the program know which one to call if they have the same name and same parameters?
I was asking to see if there is some@magic somehwhere 😂
no magic.
i was just thinking this . . .
public void SomeMethod(MyType myParam)
{
if (circumstance)
{
this.SomeMethod(myParam);
return;
}
// Non-circumstantial stuff ...
}
They are commutative respectively, but it does matter whether you add or multiply first.
(1 + 2) * 3 = 9
(1 * 3) + 2 = 5
And Praetor made the assumption that all addition should happen first, and then all multiplication, but I don't see why that would be a given.
Shouldn't you be able to get a modifier that adds a +1 after all other modifiers?
Again my example was a quick and dirty thing I threw together in like 15 seconds lol
naturally you'd tailor the implementation to your actual requirements
Shouldn't you be able to get a modifier that adds a +1 after all other modifiers?
Maybe your game needs this, maybe it doesn't.
still considered cross-posting to do so
Hello, I´m currently having an issue with raycast and colliders. My player´s colliders are so big that they´re in the way of the raycast. And I wanted to ask if there´s a way to make that raycast ignore the players Collider ? Thanks
Okie dokie
A fair point, I must have misread the example you gave. In hindsight, I guess you were mainly showing the "baseValue field" and "EffectiveValue property" approach as the solution, with the two HashSets as just fluff to get that point across.
The field and property approach seemed obvious to me, so I focused on the wrong part.
ofc there is a LayerMask just seriliaze it in inspector, inside the raycast signature you will add it, add a layer and put player in Player layer it should take care of it
Does anyone know how to check if an AssetBundle is cached before attempting to download it?
no not at all
you want player excluded it shouldn't be part of LayerMask for the ray
you want Every other layer but the Player layer
[SerializeField] private LayerMask allOtherLayer
if(Physics.Raycast(... , allOtherLayer)
oh riight. Got it 😄 I thought that the layer should be player only. I changed it in the inspector and it´s working now 😄
Thank you !
if you want to do exclusively ignore layer and not worry each time you add a layer to update this serialized struct
you can only put player inside and do playerLayer = ~playerLayer
playerLayer = ~playerLayer
if(Physics.Raycast(... , playerLayer)
Ok, I´ll probably use just that one layer. But Thank you.
Hi, i dont know if this is the correct chat, but id like to know how could i scale a texture depending on the object scale, like in this game https://youtu.be/kikY4DiZD6o
Let me know in the comments below if you want me to make a tutorial
Combat Online OFFICIAL server: https://discord.gg/N66kA9hDjb
My public server: https://discord.gg/c4SKthE5ze
hey guys, i'm trying to use JsonUtility.FromJson to parse a json string containing mesh data.
my json looks like this but i'm getting nonsensical values after parsing. could it be because of the many decimal places?
huh isnt that how normally it works
!code
📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.
wtf lol
that's exactly what i thought 😄
this might be a localization issue. Is your computer interpreting . as a comma?
actually I don't think JsonUtility takes regions etc into account 🤔
i switched to JsonUtility because i thought it wouldn't care about region
Nope, the texture keeps the same
It streches
can you show the code
isn't "stretching" part of resizing with gameobject
Let me explain with a draw, give me 1 min
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
In Parse(), can you print the json string (or at least the first 100 characters of it or so) to make sure the json is what you expect coming in?
(sorry for the bad presentation, im on mobile phone)
ok so resizing is what confused me, You want the pattern to stay the same size but tile
Sorry for my explanation, yes
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
you'd have to change manually the tiling option in the material
when you resize an object you're also stretching the UVs
hence the stretch look
So i cant do it in player?
You could yeah , you have to access the material and as the object stretches you change the tiling
ok, so what sould i search to get a tutorial?
Ah I see what youre saying. I thought you meant priority within separate lists
or you can try ProBuilder, i believe it has options where you can keep the UV stretch-independent
Ok, thank u :)
so i am not just being stupid again? 😄
With the RayTracingAcclerationStructures, is there a way to have a TLAS or top level acceleration structure?
ah and i just noticed that the parsed values change everytime i run it
I have attached three instances of a basic custom sound randomizer component to a weapon of mine. I have a fourth script that does everything else whenever I fire the weapon.
How would I get the weapon to play a sound from each of those sound randomizer components upon firing the weapon?
get all of the components then iterate and play a sound from each of them . . .
And how would I have it distinguish between the three of them?
Does GetComponent fetch all components under the listed name?
well, you shouldn't have more than one of the same component on a GameObject. they should be placed on children . . .
GetComponent is for a single component. use the plural version to get multiple components . . .
I'll come back later.
if it doesn't matter which custom sound component plays first, then it's nota problem . . .
or, you can create an array on the 4th script and manually drag each custom sound component (from the inspector) into separate slots of the array to get the correct reference . . .
I can do that with components?
🤔
Could someone help me figure out why the UI looks fine in the editor but not in the build?
The 2 players tags should be next to each other like the editor
sure . . .
not really a coding question but try to uncheck low resolution aspect rations in your free aspect dropdown, then experiment with different view sizes.
ok, I'll try
yeah it looks weird when I change the aspect ratios
found the option
child force expand
unticking height has fixed 👍
i'm accessing my data class on my Manager singleton, which works fine except for when i open the gameobject in the inspector, where it lags a lot due to how much data there is/ how many fields there are, what are some solutions to this?
It works, thanks! 😄
don't make monolith classes
anything above 300 lines, already doing too much in one class
not sure if it relates to your issue though
That's arguably subjective to each individual case.
I guess so
How many fields are there?
How powerful is your computer?
It's a good guideline, though.
Yeah mainly, just makes it easier to debug as well
This is the function/method I'm having a problem with:
public Sprite SearchDownloadCardImage(string cardName)
{
try
{
Sprite result = Resources.Load<Sprite>("Card Images/" + cardName);
if (result != null) return result;
}
catch
{
Debug.Log("Failed to find '" + cardName + "' in the Resources file.");
}
return DefaultImage;
}
When the card is created, it calls this method.
public void FlipOrShow(string flipDirection)
{
string cardName = cardNamePair;
if (isSecondPairImage) cardName = cardNameTop;
Sprite CardFront = SearchDownloadCardImage(cardName);
Sprite currentSprite = gameObject.GetComponent<Image>().sprite;
if (flipDirection == "Front")
{
gameObject.GetComponent<Image>().sprite = CardFront;
}
else if (flipDirection == "Back")
{
gameObject.GetComponent<Image>().sprite = CardBack;
}
And when you hover over the card, it's meant to display it's own image onto a larger card. (A hover and zoom mechanic). It's also supposed to display it's parent or child.
public void OnMouseHoverEnter()
{
ZoomedInSprite = gameObject.GetComponent<Image>();
ZoomCardTop.GetComponent<Image>().sprite = ZoomedInSprite.sprite;
// [It searches for it's pair here.]
if (cardPair != null)
{
ZoomedInSprite = cardPair.GetComponent<Image>();
ZoomCardPair.GetComponent<Image>().sprite = ZoomedInSprite.sprite;
}
else
{
Debug.Log("Found Neither!");
string cardName = cardNameTop;
if (isSecondPairImage) cardName = cardNamePair;
ZoomedInSprite.sprite = SearchDownloadCardImage(cardName);
ZoomCardPair.GetComponent<Image>().sprite = ZoomedInSprite.sprite;
}
It lags? How many fields/much data is in the class? 🤔
But when that exception happens, when it can't find a parent/child that's a card object, it has to call that original method again. Doing so causes the original card image to change. Even though the card's own image is never touched in the hover display method.
https://gyazo.com/2d2db811d80a6554b8b8d82f38285fb0
If you right-click the script component bar, and select 'Properties', a separate window will pop up for only that component. (Perhaps this lags less).
A more direct approach is to expose less fields at the same time.
NaughtyAttributes has an attribute for Foldout groups (https://assetstore.unity.com/packages/tools/utilities/naughtyattributes-129996)
public class NaughtyComponent : MonoBehaviour
{
[Foldout("Integers")]
public int firstInt;
[Foldout("Integers")]
public int secondInt;
}
Actually, you were right. As a test, I just replaced the method call with a default image. The default image shows... and also replaces the card's original image.
I changed only one part of one line:
public void OnMouseHoverEnter()
{
ZoomedInSprite = gameObject.GetComponent<Image>();
ZoomCardTop.GetComponent<Image>().sprite = ZoomedInSprite.sprite;
// [It searches for it's pair here.]
if (cardPair != null)
{
ZoomedInSprite = cardPair.GetComponent<Image>();
ZoomCardPair.GetComponent<Image>().sprite = ZoomedInSprite.sprite;
}
else
{
Debug.Log("Found Neither!");
string cardName = cardNameTop;
if (isSecondPairImage) cardName = cardNamePair;
ZoomedInSprite.sprite = DefaultImage; // This is the line I changed.
ZoomCardPair.GetComponent<Image>().sprite = ZoomedInSprite.sprite;
}
so i should split my data class into a bunch of different classes? i'm not sure how i'd serialize and deserialize that, and it'd be annoying needing to reference different data classes for every little thing
Which gives this result:
https://gyazo.com/3870095768000891a42b861cf5386cbb
This is entirely up to you , there is no "Right way"
But I typically breakdown a Game Manager into smaller managers instead of 1 giant class
oh yeah no i have several managers, but just one data class
I send events to a singleton EventManager so i dont couple anything
since writing that i tried changing to just a singleton Data class not on the Manager class, which i guess reduced the lag since i can't even open it in the editor now lol
oh that's really cool i'm gonna get that for sure
a lot
pretty damn good
Would you mind screenshotting this to give us an idea?
Lagging inspector doesn't sound right. Which Unity version is this on?
2021.3.5f1
i already moved it to its separate class and changed every reference so i can't really screenshot
i can send a save file though which would give a decent idea
How much? I do find it hard to believe a single class lags the editor . . .
10, 100, 200, etc.?
!code
📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.
that's not code it's a save file
Sounds like a mess. What have you got in there?
Ah, alright.
70k lines or file size?
lines
file size is 892kb on a fresh save
the biggest perpetrator is the cell data which saves the 20x20 grid and the contents of the cells
you still use a paste or bin site to post code, it's a json file. no one will download links . . .
without it it'd be like less than 1-2k lines
it's over the pastebin file size limit
wow, never seen that before . . .
i'll paste it with the all cell data removed except for one
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
See a lot of redundant data (blank fields) being recorded
which specifically?
Practically the same data for many objects:
Data that doesn't need saving or that are always default should just not be serialized?
1: idk how to not serialize it
2: if i don't serialize it then i'll need to check for if it's not there and create it when i do want to use those stats
Unless this sample's a coincidence..
nope
every object that can hold the seed class has its seed serialized even if it's null
lol
it works fine in saving and loading but now you might see why the inspector was lagging lol
do you need to see the data class from the inspector? makes sense to just check the save file . . .
it's useful for debugging but no i don't need to, that's why i moved it to its own class
Right-click the Inspector tab, and you can switch to Debug mode, which shows everything.
To reduce the amount of serialized fields visible in the inspector, use the attribute [SerializeField, HideInInspector]
A fold out group could reduce clutter - not sure if it'll reduce inspector delay.
Linked him NaughtyAttributes for that earlier
oh i meant i moved it to its own non monobehaviour class since i can't deserialize to a monobehaviour
i thought it was already a c# class, not a MonoBehaviour . . .
yeah but earlier it was on the Manager monobehaviour
now it's not on one so i can't see it in the inspector
it's fine like this tho not a big deal
that data would gzip down probably 98% since it has so much repeated data
i'm not sure what gzip is but yeah compressing with 7-zip cuts the size by 16 times
That's what I was getting at. It seems a lot of fields were saved for no particular reason.
GZipStream
Lot's of empty strings and zeros
you zip and unzip it as part of the save process after serializing to json
i could not save the cellData that's just the default state, but the object i care about saving most (Seed) i want to save all of its stats because they might be accessed in the future, and checking to see if it has the stat or not and then creating it would be more of a hassle than the few kb i save
oh interesting i'll look into that
trying to pastebin an example
what's the byte[] data parameter supposed to be?
this is in the LoadData() function
string json = reader.ReadToEnd();
Data.Instance = JsonUtility.FromJson<Data>(json);
I'm so annoyed
I have an object that has locked all movement and rotations blocked by rigidbody constraints (except for y rotation) but when I apply upwards torque to it, it still rotates a little bit along the other axes
why is it doing that?
when you compress it you get a byte[] array, I was saving that to disk with File.WriteAllBytes, and File.ReadAllBytes to read the file gives the byte[] array that you pass to get the json string back from the compressed bytes. compressed = bytes, you take the compressed bytes to get back decompressed string of json
With a raytracingaccelerationstructure how do you have it so objects inside it can move? UpdateInstanceTransform doesnt seem to work
can't really test this right now since i made the change to the Data class, now it fucks up initialising everything when there isn't a save file to start with
right on, that's just the process for gzip if you wanna use it, for me it took my saves from 100kb to 7kb from all the repeated data
damn
This might be a more advanced question, but I just want to ask it here in case it isn't. So I have an enemy (GameObject) that fires a projectile towards the player's position due to following the player's position. How might I be able to adjust the height and/or speed so that the further the player goes, the further the projectile will go? This is how the current script works to instantiate and then add force to the projectile:
GameObject poison = Instantiate(poisonProj, poisonSpot.position, transform.rotation);
poison.GetComponent<Rigidbody>().AddRelativeForce(Vector3.forward*500);
what do you mean the further the player goes?
you want the speed of the projectile to increase depending on how big the distance to the player is?
Yes
I do have a distance registry:
playerDistance = Vector3.Distance(player.position, transform.position);
if(playerDistance <= plantRange && plantStatus == 0)
{
transform.LookAt(new Vector3(player.position.x, transform.position.y, player.position.z));
if (fireCountdown <= 0f)
{
GameObject poison = Instantiate(poisonProj, poisonSpot.position, transform.rotation);
poison.GetComponent<Rigidbody>().AddRelativeForce(Vector3.forward*1000);
fireCountdown = 10f / fireRate;
}
fireCountdown -= Time.deltaTime;
}
But it is mainly in use to regulate that it fires within a certain range and to look at the player.
calculate the distance to the player, take its magnitude, then multiply the speed with that magnitude and some additional factor
you can also lerp between two values (min speed max speed) based on the distance and some max distance that you expect
you have the distance
you can start by changing the *1000f into, for example, *100f *playerdistance
or something
and go from there
So vector.forward*(100f *playerDistance)?
There's meant to be more of the stars-
God dammit discord
return recur(recur(x * 3)); can anyone explain when a method replays in a method
GameObject poison = Instantiate(poisonProj, poisonSpot.position, transform.rotation);
poison.GetComponent<Rigidbody>().AddRelativeForce(Vector3.forward*(100f *playerDistance));
Like this?
Recursion. There's not much to explain.
instead of writing * you can write \* to make it ignore the star for italics
yea something like this
Thanks
then you can look up things like Mathf.Lerp, Mathf.Clamp and other things
ik what currsion is but when it call itself twice in the same method
idk what that means
see what could be useful to you
especially Mathf.Lerp - you're gonna end up with this one, I almost guarantee it
It doesn't mean anything special. It's simply is called twice.
As for why it's done in that particular case, no clue. Need to research the code.
Would a vector3.up also help it if its moving further away too?
In case terrain is uneven?
Or would turning off gravity or lowering gravity help?
you can add vector3.up to the vector3.forward, you'll probably want to multiply it by magnitude as well in parentheses Vector3.forward + (Vector3.up * magnitude) * force * magnitude
if it's at the same level as the player, you can turn off the gravity
If anything I might try to flatten the Terrain a tad.
is this like a turret
But I'll make sure to look back if I want to mess with it.
Kinda
It's a plant monster that shoots poison
So, effectively a turret
I'll mess around and play with it a little
I don't need it complete by tomorrow, just doing milestone presentation for the project.
I got next week free due to spring break
So I'll be deep diving if I don't get distracted with video games
*too distracted
hi, is there a way, from inside the abstract MainMenuScreen class, call Register<ClassDerivingFromMainMenuScreen>() if my code looks like this?
public abstract class MainMenuScreen : MonoBehaviour
{
private void Awake()
{
Register<???>();
}
protected void Register<T>() where T : MainMenuScreen
{
MainMenuController.Instance.RegisterScreen<T>(this);
}
}
I want every instance of a class that derives from mainmenuscreen to register itself automatically, while providing its own type
Is there a way to have a #define in one file affect multiple other files without changing the settings?
Couldn’t you do Register<MainMenuScreen>()?
nope - I need the actual derived type, because I later use as a key to a dictionary
why provide T at all? Register(this), get the type via GetType() inside RegisterScreen
I ended up doing a screen.GetType() in the MainMenuController class
yep, that's how I ended up
I'd probably make Awake protected and virtual rather than have a separate Register method too, Awake is easy to shadow accidentally and then your register system will silently break
unless the derived type calls Register itself directly, which would be easy to forget
https://gdl.space/jinuvefaxu.cpp how do I combine these two things together?
the problem is the if statment is asking for x or y
yeah, I was wondering how to prevent overriding it by accident
is there a better way than just protected virtual?
it just squiggles a line right now, but does nothing about it otherwise
you could use clamp rather than an if statement, but this logic is weird. If either x or y velocity magnitude exceeds maxMovespeed, you set BOTH velocity directions to the max? So if I'm moving 1.1 units in x direction and 0.1 units in y direction with a max speed of 1, my new move speed should be (1, 1)?
anyone know how to make drawray and drawlie stop flashing
Hi - is there a way to load a scene, using LoadSceneAsync, but hold off the actual... enabling of the scene?
I want to load the scene, and when it's ready I want to do some things, then when I'm done - switch to it immediately, without loading or any further delay
So.... I implemented a basic custom swipe. My dilemma now is, I have a few horizontal scroll containers on some of the views. I wonder what the best way is to detect if their finger started in any of the scrollable containers so it doesn't change screens on them.
Example, if you were determined to use generics... https://hatebin.com/pyzlldjjys
Track the container that the pointer down event was registered in and reset it on pointer up.
Since there are multiple gameobjects in the horizontal containers, it would seem I would need to traverse up the hierarchy to see if the parent is a scrollable container using something like EventSystem.current.currentSelectedGameObject? I really only need to know if the Phase.Began happened in one of the horizontal scroll containers.
Not sure what you mean. I'd just have a script on each container, catching the pointer events and reporting to some kind of Manager up the hierarchy. And before allowing any dragging in the container, ask the manager if it's allowed.
I was able to get it working using this. It detects if the mouse is over a scrollview by tag and stops my swipe code from running.
var pointerEventData = new PointerEventData(EventSystem.current) {position = touch.position};
var raycastResults = new List<RaycastResult>();
EventSystem.current.RaycastAll(pointerEventData, raycastResults);
if (raycastResults.Count > 0)
{
foreach (var result in raycastResults)
{
if (result.gameObject.CompareTag("ScrollView")) return;
}
}
id say its probably expensive but my players wont be on this screen very much
Getting pointer data from the even system like that is crude, but if it works for you, then ok.🤷♂️
I'd use IPointerEnterHandler and it's friends.
just clamp your degrees? before angleAxis
How do I put a variable from a script to a panel on my camera that changes (ammo)
how would i go to making a attack animation when i have basic anim's for movement? i have basically no idea how to to do 2d anims lol
no i dont think i do
i dont know yet i want to see what is better for the game
bet thx mg
m sorry what
im so confused
ignore flip and update animationstate but in my animation i have a bool named isAttacking from all states of anim if you press mb 0 it attacks so i made a pub void end attack. in side making "isAttacking" to be false. in the attack animation i set an event at the end making it so it stops the animation and going back to idle using a transition of isAttacking = false. the event is set up and this is too its staying in a constant loop.
https://hatebin.com/pjvqiscuql
heres the code
never mindddd
create your own global rsp and put it in your assets
hey could someone help me with an issue
?
I am having an issue with an editor script
Uh not rn im in the bus going to school
Its from Natty's youtube series
I have a script that can be placed on some objects but not the one I need and it seems to delete the component right after I add it
Hm idk tbh
Just wait until someone thats knows a little more about this can help you
What's interactable.useEvents?
did u change the file path for your projects?
not really coding related. but try to remove it and readd it in unity hub
ok
ok Imma try that
why are you crossposting everywhere but the right channel?
idk
well don't it's against the rules
Hi guys. I'm willing to pay someone to show me how to convert game object prefabs that have already been placed into my level, into Terrain Trees, while keeping their original locations, rotations and scales.
I'm a noob and have spent all day trying to figure this out. Is there a Job channel somewhere?
!collab
bot is taking a nap..
#📖┃code-of-conduct find them here @fallen knot
Thanks!
I think they got the opposite
they have prefabs and want to switch with terrain trees with same pos/rot/scale?
Actually, that class seems rather useless. Doesn't really give any GO info.
beyond pos/rotation
Well you can use this to place trees with the module based on the list of GOs transforms
Basically you would instantiate the trees https://docs.unity3d.com/ScriptReference/Tree.html based on that I guess
Oh, right so the terrain also changes the size and such as well too, so you can't really get all that information from the GO.
so you get the prototype and grab the size the terrain is changing it to.
Not sure what you mean? He just wants to create trees on the already done terrain while using his gameobjects transform values. Nothing on the terrain is changing besides the terrainData holding the trees
Oh, rofl. Ok, yeah probably an easier problem in this case then.
yeah hiring is prob overkill lol
https://docs.unity3d.com/ScriptReference/TerrainData.SetTreeInstance.html
Well, this would seem like the func to use, but then there's this line
Sets the tree instance with new parameters at the specified index. However, you cannot change TreeInstance.prototypeIndex and TreeInstance.position. If you change them, the method throws an ArgumentException.
So, basically useless unless I'm understanding it wrong.
I understand this function as replacing an existing tree with a new one but keeping its values persistent cause you cant change it.
Ah, that's probably it then
What i want has to be very specific. Its not about instantiating my prefabs, its about getting them into the terrain tree system.
Because afterwards im converting the trees in the Terrain system into a plugin - but they need to be in the Terrain tree system first.
Im doing a conversion from Unreal to Unity
Either way, you cant just init a tree onto the terrain, you need to assign it to the terrain first to give it the prototype. So, there's this extra bit of overhead.
optimization reasons I'd assume
The reason I'd be willing to pay for it, is because time is money, and im not adept at using Unity. Im barely even a beginner.
But Im a pro at Unreal, and i have a bunch of my Unreal assets on the marketplace that need converting to Unity.
I have an employee already doing this, but this the last issue in the pipeline that i need to resolve
If someone already knows how to do this, it'd make sense to just shoot through 10-20 bucks to just have the issue resolved, rather than spending countless hours trying to learn how to code.
Ive already spent 3 hours trying to search a solution to this online
I'd rather spend my time earning money doing what i do best, and just pay someone who is good at unity to solve it for me 🙂
May be better off looking at the paid assets unity store has to offer
Im trying to sell on the Unity store. I cant use other peoples work
Im an Unreal Asset developer looking to convert my Unreal projects to Unity, to sell on the Unity store
actually, i see what you mean
If its a once-off thing and the code isnt in the product itself, that would be fine
I use this but the result position is only 1 unit far from the camera, how do I fix it?cs public void OnDrag(PointerEventData eventData) { transform.position = _cam.ScreenToWorldPoint(eventData.position) + _posDiff; }
https://vimeo.com/362108451?embedded=true&source=video_title&owner=103216634
How can I make projectile move like in the video, initially spread out, and then flying to the cursor position. I know how to make projectile fly to the cursor position straightly but I dont know how to make the spread out things and the curve movement.
A quick demonstration of Magic Missiles and Lasers Asset. You can find it on the Unity Asset Store.
looks a bit like vfx graph and world simulation space, so emit particles stay on their world position. Or what exactly do you mean by spread out?
like magic missile?
some projectile is flying to the top at start and some are flying downward
Ah, got it. So you need a start and endpoint and with those you gotta spread out the local values of the particles by using like a bezier animation curve that starts and ends at 0 and in the middle the spread as you like. from there you can randomize the spherical spread with that curve values to get the desired spreading effect.
You could also let them spread to the middle distance and then modify the particles from there to move towards the target back with simple lerping
its a animation thing? but not the actual gameObject movement?
I want the projectile hit enemy in the middle of flying if they touch the enemy
So imagine you have a default line from A to B, that is your moving particle system or vfx origin. And with the time from start (0) to end (1) you can lerp the spread to be bigger at 0.5 and almost 0 at time 1.
so I want to code it but not just animate
I would start using a particle system and read about how to access those and how to modify their position depending on the lifetime
Particle is always flying from point a to point b + the offset depending on the distance to the target.
hey guys, i'm pretty desperate at this point.. i'm trying to parse a json string containing mesh data. but for some reason i'm getting completely nonsensical values for all the vectors (vertices, positions..) the ones for the triangles are correct that's why i'm suspecting that something is being handles wrong with the floats..
my json string looks like this:
https://pastebin.com/snRZ5bck
but my parsed objects in unity look like this:
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
what is also super strange is that everytime i run it in unity the parsed on the vectors change although my json stays the same
How do you load your json and put it into class?
yes
you'd need to fire the projectile from N different translations
eg im pointing north, east, and west
once each projectile is fired, you'll need to basically "track" it back to target
to do that, you still do movment like normal but you're turning and other stuff
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Please switch to newtonsoft first and see if that fixes your issue
I find a keyword "slerp". It's a upward curve, how do I get the left, right, and bottom slerp
i think thats just unity's wrapper for newtonsoft.json
slerp interpolates from any rotation to any other rotation,
It is not
under the hood i assume it's using JsonSerializer.Deserialize<T>(string)
its a super barebone not usable version of json
weaksauce
why even have it then? lol
we dont even use newtonsoft anymore in .net core
that makes it feel like a roll your own JToken parser lol
what "interpolates" mean
moves?
so its always curving upward?
i think its more like finding points
eg. you have a dot at 0,0 and 10,10 and are connected via a curve
using interpolation would help you find points on that curve?
JsonUtility for example does not support Properties, only fields.
oh thats super gross
there has to be a use case for it though
STJ works in the latest version, no need to use the turtle newtonsoft
Right... STJ ftw
unity is just nostalgic in keeping their own json utility in the software 😉
What STJ? And what latest version, like the stable one?
System.Text.Json
Ahhh, my bad 😄
How do I move a MonoBehaviour from one GameObject to another?
Well that makes it even easier just to use the Serializer right away, just forget about util and newton 🙂
yup, built in from the start
You want to move the component?
JsonConvert.Deserialize<T>(...)
it is not, you'd need to download the Nuget package and make the linker works for both WebGl and IL2CPP
Now that you write it, I actually used it in my latest project without even thinking 😄
that actually did the trick! thank you!
Yeah, I want all the references to it to be kept
still much much better than the turtle newtonsoft
Convert vs Serializer
i still get them mixed up
Ahh, got it, guess another dev set it up back then in the project. thanks for clarification and how to implement it 🙂
as we discuss, you can also use System.Text.JSON if you want and want to set it up, but newton does fine too for the most part.
if your .net version is 6+, you really should be using STJ
would there be any advantages?
STJ is so much faster
small memory footprint too
because of fewer allocations
optimized code and a vastly improved framework
Does it make a difference for one time calls tho?
its best to just get into the habit of using STJ
A tutorial as a shortcode here on the server would be handy or on vertx website tool 😉
Here's what it should link to
and i did have it backwards damn it lol
JsonSerializer is STJ, JsonConvert is Newtonsoft
var options = new JsonSerializerOptions { WriteIndented = true };
string jsonString = JsonSerializer.Serialize(weatherForecast, options);```
juice
oh now this is an interesting tidbit...
youd still have to convert those bytes to a string which might still be that 5-10% you're saving =/
whats the point?
Note that you can still use STJ in the older Unity versions, it's just won't take the benefit of Span<T>
Maybe using utf8 directly would benefit as you would not convert it, not sure. Someone gotta have a usage for that I guess 😄
byte[] == char[] == string
this just gives you the encoding code instead of the actual string character
i guess that would be useful for when you are doing binary reads...
Did they end up wrapping the very first version of it? Because it's total shit
i dont know... its not STJ so i dont care 😛
Pretty sure STJ is not Unity compatible unless you manually add it?
if you're running .net core, you have STJ
There is a Newtonsoft Unity package
Sir this is a Unity server
the code-behind is C#
.NET != Mono
...
System.Text.Json has linux and macOS native methods
.net core is cross platform compatible
So how is this Unity compatible again?
because of the target framework of it's underlying language?
https://learn.microsoft.com/en-us/dotnet/api/system.text.json.jsonserializer#applies-to
Unity implements .NET Standard 2.0 using Mono
From 2022 on you can use System.Text.String, so it can work
My question is how you expect a serializer that does not explicitly target .NET Standard to work in Unity
Unless, of course, I am mixing up the versions
.NET Standard is a formal specification of .NET APIs that are available on multiple .NET implementations. The motivation behind .NET Standard was to establish greater uniformity in the .NET ecosystem. .NET 5 and later versions adopt a different approach to establishing uniformity that eliminates the need for .NET Standard in most scenarios. However, if you want to share code between .NET Framework and any other .NET implementation, such as .NET Core, your library should target .NET Standard 2.0. No new versions of .NET Standard will be released, but .NET 5, .NET 6, and all future versions will continue to support .NET Standard 2.1 and earlier.
It's in .NET Standard 2.0 only for compatability with multiple target frameworks
.NET 4.6.1, .NET 4.8, .NET Core 2.1, 3.1, .NET 5/6/7/8/etc.
So how exactly would you make STJ work in Unity? Does the namespace exist in versions 2022 and later?
when your app compiles, it compiles against a target framework
.NET Standard is more of a "middleware" between versions for compatability
i reference .NET Standard libraries from my .NET 6 project and that has access to System.Text.Json
and newer versions of C#, etc.
I know you blocked me, but maybe you hit that close button 😄 It should be a thing in 2022
And this works without manually importing the dlls as plugins?
System.Text.Json has been a thing since .NET Core 3.1
You dont need additional nuget packages, correct
System.Text.Json is part of .NET inherently
That's different
just like Console.WriteLine
I know STJ is not a Nuget package
I'm talking about it being an actual part of Unity as of 2022
Just testing it right now
So forums said, it was, but it is not. You can still use the nuget xml hackaround way loading all the dlls, but its not part of Unity for now.
System.Text.JSON is NOT part of unitys builtin NET version.
^
So you either have to hackaround, use newtonsoft or never look at json again 😄
STJ isnt compiled against .net standard 2.0
that means they restrict you to only standard 2.0
...
just put the link.xml in your assets and make sure it won't get stripped when compiled
Isn't this literally what I said?
i think STJ would indeed add a dependency on having the .net 3.1 or later runtime installed
I didnt know unity locked things down like that
Welcome to Unity
im not writing things in the unity library
why do i need to stick to net standard 2.0?
im using the libraries... thats it
2.0 is sorta neutral standard, 99.999% it would work with newer versions
theres no restriction from me working in a net 6 project and referencing .net standard 2.0 libraries
Okay, I guess we just have to accept for now, the majority will use newtonsoft for now on Unity projects and from what I have seen, it works fine for everyone including me 😄
There is nothing wrong with Newtonsoft
except performance lol
People prefer STJ because it is buildin
But what they don't realise is that STJ does not actually compile for .NET Standard
As mentioned here
And Mono supports .NET Standard, not .NET 5,6, whatever
So therefore my confusion as to why STJ is being suggested 😄
I have 4 directions represented by simple vectors:
Vector2.up/right/left/down
I also have a quaternion which also represents such direction.
Question:
How do I rotate one of such directions with given quaternion?
For example if I have direction up (0,1)
and quaternion of angle (0,-90f,0)
I want to get (-1,0) result
I think you taking edge cases as an example most people would not even run into if you dont do heavy reloading of data (which would be more of a problem of data handling then json itself)
There is a Newtonsoft Unity package and it's literally the same as STJ for more people
I dont see why i wouldnt just have my project target .net 6, give me access to STJ and reference the ,net standard 2.0 libraries
you want to rotate the vector with your quaternion as offset?
I'm sure if it were that easy they would have ditched Mono by now
I guess
the only reason they have mono is because of the graphics for linux and such
you're getting it wrong.. for convenience yes... for performance? no.. newstonsoft is slow for bunch of reasons and allocates lots of memory
mono works on net 6
When I say "for most people" I mean those who don't case as much for performance and edge cases. I'm sure bubba that started the conversation does not really care if Newtonsoft is much slower than JSONUtility 😄
looks like its the other way around
I would appreciate STJ in Unity but as of right now you will have to deal with the mess that ended up because .NET was not cross platform back in the day
that jsonutility was their own homebrew
Yeah, i've been working with C# for far too long to know that it shouldnt be a limitation... I just need to look more into this unity side of things because under the hood it's still just a C# project compiled with roslyn...
Did you try to just multiply it with your quaternion? cs vector = Quaternion.Euler(0, -90, 0) * vector;
the problem isnt .net... the problem is unity
unity is still using legacy mono functionality because linux still hasn't got a standardized graphics api
thats the only reason why unity is coded to still work against framework
framework is already or almost at EoL...
Should this discussion be worth a thread to not clutter up the help channel? Just suggesting
threads have a tendency to kill conversations (which this is)
its not one person asking for support or anything like that
there's no one person in focus
Unity uses mono (still) because .NET core has no api for hosting it on top/inside of a separate runtime (unity engine). They are working on that though.
hosting it . . it being what?
The whole native code runs the .net runtime in the same process is not possible, out of the box, with .net core
what native code?
The engine
the engine is written in C# and C++... DllImport and such lets you call the C++ from C#
i dont agree with what you're saying at all...
anything you can do in framework you can do and more, better with newer versions
unity hasn't been rewritten to work with the new language specifications... it's not .net lacking or missing functionality
its unity missing and lacking
I think we got your point. I would suggest open a thread to keep on going about this thing, cause we are away from coding issues more into general unity implementation of features
you do you
Something being technically possible doesn’t mean it’s immediately useful and all relevant situations are automatically solved. A lot of work has gone into making unity work with mono, these 17 years of development and design have to be recreated for core, and many past assumptions need to be changed and this has sweeping effects on a very large codebase
i think there is some miscommunication and/or misunderstanding
i can take a C# debugger and debug a unity game...
Parts of it
The native parts
and the symbols
Which you don’t have
define "native parts" and please lets not use such ambiguous terms
lets be specific here please
The proprietary code that you have no source access to, or any debug symbols or documentation
for unity?
have you heard of dotPeek?
they dont even obfuscate it
that was part of my job at Curse... stripping assets from games like Hearthstone
the point is i can generate symbols for it and hit it with a debugger
You just want to convince everyone from you being right here, this is not leading anywhere tbh and not helping anyone with any question about general coding concepts in Unity
Sir I just wanted to inform you that STJ is currently incompatible with Unity 😢
Im not on a mission or anything... just trying to clarify... this was a stem from a base conversation that got derailed
Does anyone know if there's a way to stream chunks of a big city mesh, not terrain? Or a way to divide one big mesh into smaller pieces? One way is to divide it yourself manually and stream chunks with sectr or world streamer.
You could split it into smaller meshes manually and "stream" it with addressables.
I would suppose that any such partition would have to be manually authored to be useful in a particular project. Generic approaches exist ofc (somewhere), but overall they are usually in conflict with the way performant game worlds are constructed (compact individual ‘rooms’) where no non-compact thing/object/model stretches far outside the immediate vicinity/frustum of the camera
you could also generate LODs if thats helping you stream fewer polygons, but why do you want to split it up in general? Does the user see it one after the other, or should it be dinstance based, what is the case?
Maybe it's a trillion triangles or something 😅
And they need it to run on mobile🤔
Isnt that a thing for occlusion culling then with as you said manual separation of the meshes? We will know it eventually 😄
It should be split so it can be streamed. All the game objects in the chunks should activate/deactivate with the chunk