#archived-code-advanced
1 messages · Page 51 of 1
For aesthetic purpose
so you can load a limited amount of it at once..?
split terrain generation over multiple frames so areas over 100 by 100 can load better
I at least, that it is what I concluded
aesthetics is one thing, load "denormalization" is another
you should fully load the terrain using a lightweight object of some sort as one thing (and be concerned with aesthetics there) and load the heavy objects separately (and be concerned with performance there)
those things are two different problems, you're .. maybe mashing them into one
both are the same, aren't they, i don't get the difference, eh I'll deal with that later, spiral first
To come back with the previous topic, you use 1 as base case. The rest is like resolving a series.
private Dictionary<(int, int), TerrainTypeEnumOrSimpleClass> _data; // <-- populating this is instant for pretty much anything up to zillions
private Dictionary<(int, int), GameObject> _unityData; // <-- populating this is very slow
public class TerrainTypeEnumOrSimpleClass // <-- not a monobehaviour
{
public TerrainTypeEnum TerrainType;
public float Height;
public int Weight;
}
ok, i think i understand? so (frames - 1)**2 + 1, and if that is equal to something, then turn, and then I don't know....
Not really sure why we have frames there.
oh, i use NativeHashMaps, much faster than dictionaries as far as i know
no
sure, fine, whatever 😛
really?
how else would i get the previous square?
What you are expecting in performance ?
just saying, figure out your terrain first using POCOs, render/load it separately depending on .. whatever. What the user is facing, how far they can see, how much memory/cpu your game objects take to interact, etc.
Plain Old C# Object, if you did not know
i don't use many gameobjects, and also my game is 2d top down, so the user can see the same amount in every direction
maybe you should show some code..
my code is so terrifying that even I barely understand it lol
maybe that's the problem then 😛
ok fascinating, i think i get this, let me test it in excel quickly
10k GOs is no big deal
Start at:
Previous Sqr: 0
Next Sqr: 1
Previous Sqr + 1 Turn
Previous Sqr + (Next Sqr - Previous Sqr)/2 Turn
Increment Next and Previous Sqr
I mean, it's a lot, but .. it sounds like what's much more likely to be the culprit is something else in the spooky code
i use entities instead, cause you can have even more entities than game objects (I probably should have mentioned that I'm using ecs and dots for most things, sorry....)
still fine
You really made me do it. I won't do anything else though. You figure out how to translate in position.
ok, I think i get this then, let me try it in excel thanks!
If you're having performance with 10k objects you're really likely doing something else that isn't obvious to you that's killing your performance.. rendering your gameobjects in a spiral or in a limited fashion is A) going to be hard for you and B) probably not the problem
It is the loading. Pretty sure he wont use that for render
i get 100 fps while not generating anything, and 10 fps when generating 50 by 50 areas every frame, nothing to do with rendering, i keep everything rendering at all times cause entity graphics is fast enough
It could look cool. See everything just come from the sky and form the world in a spiral.
Sure, it could be that as well, but designing some convoluted system to load "when the player isn't moving" is surely a recipe for spaghetti.
Yeah, you would need a second system for whenever the world is actually loaded.
To reiterate: this is probably the issue. I'd bet a dollarydoo on it.
i delete all my code and rewrite it based on the old code but in a way that makes sense, every couple months, so it should be fine lol
ok so some pseudo code in excel, something like this then?
and what would i do with these step1 and step2 then?
I ain't clever lol
guessing there is some pattern between step1, step2, and the position then? Curse me for being so bad at finding patterns....
https://oeis.org/A174344 managed to find this which looks like it might help!
also sorry, but i can't see any pattern....
This seemed pretty fun to try out. There’s a rule of math that a square root of any integer will never be perfectly between its upper and lower square.
So take the number 13 and square root it. Ceil and Floor it. Now figure out if it’s closer to its ceil or it’s floor. If the closest square is ceil and even number go left. If it’s closest square is ceil and odd, go to the right. Likewise, if it’s closest square is floor and odd go up, and if it’s closest square is floor and even, go down. You’ll have to save your previous position but this should tell you whether to add/sub the x or y.
13 square rooted for example is 3.78. The ceil and floor is 3 and 4. It’s closer to 4 and 4 is even. therefore go left (minus 1 on x).
oooh i get that i reckon, thanks a ton!
in that site i found a way that seems even easier:
public static int2 GetNextSpiralPos(int2 PreviousPos, int SpiralIndex)
{
return new int2((int)(PreviousPos.x + math.sin(math.floor(math.sqrt(4 * SpiralIndex - 7)) * math.PI / 2)), (int)(PreviousPos.y + math.cos(math.floor(math.sqrt(4 * SpiralIndex - 7)) * math.PI / 2)));
}
somewhat visualized
cool! Don't know why you have highlighted those numbers on the diagonal though lol
those are the squared numbers, i just boxed them to help me think 😅
oh ok cool
#1062393052863414313 is the place for Entities questions!
there she is
(the first pinned forum post)
Is there any code that allows me to check if my player has this option enabled
If I were to guess, it would be in the registry.
Thanks!
That being said, you might want to look into this if there is a better way to access the information than directly from the registry.
https://learn.microsoft.com/en-us/archive/msdn-magazine/2014/december/voice-recognition-speech-recognition-with-net-desktop-applications
https://learn.microsoft.com/en-us/dotnet/api/system.speech.synthesis?view=netframework-4.8.1
hello all, im currently experianceing 3 errors saying that the XRSocketInteractor dose not contain a definison for GetCurrentSocket ,isSelected, andGetAttachedObject when useing the XR Interaction toolkit package in unity3d, did they change the names of these? or are they not a thing to begin with? and if thats the case how would i go about makeing them? code here:https://codeshare.io/oQZmlB
opps my bad sry
Thanks again
if I have an object implementing two interfaces, class myClass : interfaceA, interfaceB, in a function in interfaceB would (this is interfaceA) evaluate to true when run? could I then do (myclass)this in interfaceB?
sorry if this isnt advanced, still learning how to properly use interfaces
Not clear. Can you elaborate ? in a function in interfaceB would (this is interfaceA) evaluate to true when run?
From what I understand, you are not using interface in the correct way...
Generally you don't provide implementations to functions inside the interface itself so it's unclear what you mean
unless it's a default implementation?
It would work, in theory though.
It seems like a bit of a code smell to me TBH
In practice, you would want to redo your code pretty fast.
what's the goal of this
hold on, ill go write it out and provide a more detailed explaination
Try to stick to concrete example.
will do
im trying to make an interactable interface that the player can call the oninteract method when pressing a button. The default implementation should be to check if the class implementing oninteract is an inventory, and if so run a function on the player to show ui
im wondering if in the default implementation of oninteract in the interactable interface i can do if (this is inventory) and then use player.showInventoryUI( (inventory)this );
is that an okay approach to this?
The inventory is interactable ?
yes all inventories are assumed to be interactable
Why are you just not overriding the function ?
inventory is also an interface
i was thinking it would be easier to assume the norm for interactable is an inventory and do default method there, and for buttons and things like that override it
Do a graph.
I'm not following the dependencies
I think that, there is something that is not working here
on it
many things are interactable, but im assuming most will be inventories, so the default should be inventory
Makes an abstract class for Inventory instead of an interface.
In the class, implement the onInteract.
better graph:
it has to be an interface
Why ?
the modloader im using has to package it to be an interface to properly compile
all interfaces are part of a custom assembly shared to modders
Use composition over hierachy then.
I am
most inventories are also destroyableObjects
this is just a basic graph of interactable heirarchy only
I was thinking it would be easier to have interfaces more specific than interactible so I wouldnt have to re-setup inventory every time
I guess it would be better to put a default implementation of oninteract in inventory rather than interactable, as well as the other interactable interfaces
How would you provide a default implementation in an interface ?
Inventory must be a class to implement something.
Hence an Abstract class.
What I am talking about composition over heritance is:
Instead of implementation the "OpenInventory" in each class (Chest, Body, etc.), you implement it in an "Action" that you reuse it.
This way, you do not need to re implement everything in each class.
If you push this all the way. You have only 1 concrete class (Interactable) that have multiple action and behaviour implemented as action/effect.
don't overthink this. do this instead
interface IInteractable {
bool opened { get; set; }
void Use();
}
// an example where both opened and use make sense
class Door : MonoBehaviour, IInteractable {
public bool m_Opened = false;
bool opened {
// put the door opening animation here
get => m_Opened;
set => m_Opened = value;
}
void Use() {
opened = !opened;
}
}
// an example where only Use makes sense, to mean
// "start a conversation with"
class Guard : Npc, IInteractable {
// not used for anything, but implemented
bool opened { get; set;}
void Use() {
StartConversation();
}
}
// an example where only opened makes sense
...
class InventoryItem : MonoBehaviour, IInteractable { ...}
class Chest : InventoryItem {
bool opened { ... }
// left empty
void Use() {}
}
does this make sense? you don't need a hierarchy of interfaces
it does nothing for you
every kind of interaction you suppose should go into IInteractable
this this is for a mod, i understand that you must use interfaces
You can always mix and match interfaces too; don't necessarily need to derive from them.
this makes sense, they are for things where you can not modify the code
don't mix and match interfaces
declare 1 interface
put all the methods you "need" in the interface
it's an interface, it's not a hierarchy. it's an adapter. it's a way to translate from one thing to another
does this make sense?
you guys are right ive been thinking about this wrong
look at my snippet
i believe you must use an interface because that's what the mod system requires, for good reason
My code base is fine with mixing interfaces. Say you have an interact interface, but I don't want to interact with my NPCs. So, by mixing them I can interact with some npcs or not.
i know it's fine, but it's pointless
If it's pointless then c# wouldnt let you inherit multiple interfaces
and stuck to 1 class 1 interface rule
Not fan of such architecture. It really complicates the maintainability of the project.
so we've eliminated IButton, INpc, IInventory
I want to implement a bunch of objects that are both InventoryItem and IInteractable, so it seemed a waste to rewrite it every time
but I think i know what to do
try to merge the methods declare in those all into IInteractable, and then, when things sound like they have overlapping meaning (like Use and StartAConversation could both be just Use)
combine them
IInteractable is an adapter for the mod loader
which i assume needs to know some kind of methods for turning a pointer click into a method call on a script
that's all it should do
I guess I was looking for a way to have a class implement something that just set up a predesigned implementation of both interactable and inventoryitem
this is a little more confusing. InventoryItem is always an IInteractable so you might as well implement it there
you're focusing on the wrong part of the snippet i guess lol
i modified it
i think people shove things into the right side of the : all the time
it's not super clear yet what your goals are
what it sounds like is there is a pre-existing IInteractable declared by the game
and you want to use it somehow?
yes?
what does it actually look like
you create a DoorInteractable : MonoBehaviour, IInteractable, and it has a reference to a Door, and you're done
you build prefabs
it's hard to say
well the idea was basically have an class Inventory : IInteractable then class smallChest : Inventory, class largeChest : Inventory, but im forced to use interfaces by modloader
there's a lot of context missing to give good advice
thats why I had interface implementing interface
a largeChest is an IInteractable
it sounds like you didn't know that
in the declarations you just made
I did, but I wanted to share the inventory class with modders, which has predefined implementation of the OnUse function
also share NPC class and Button class with predefiend OnUse
but must use interfaces...
I need to restructure
if the modloader needs you to have an interface declared for every class
so it goes
you can't make it any easier for people, other than maybe writing your own mod loader
it has nothing to do with your structure
if people can't handle doing that, they're not going to be able to use your toolkit
@sage bolt put another way, you can't take this from "1" coding knowledge required to "0". you're only taking it from "103" to "102", which isn't so meaningful
i wouldn't sweat it
when you say share with modders
i mean this is all very confused...
i am starting to understand what you are trying to do
sorry about that
thats a good point actually
ive been trying to make it as simple on modders as possible
so here's what you're trying to do
you're trying to make a toolkit for modders
their mod would have a dependency on yours
you want to share things like an inventory item implementation
but unfortunately the mod loader only allows sharing interfaces between dependencies
great
i have a lovely solution for you
not entirely
I usually roll with an architecture like that. This is what I am talking with Composition over Inheritance.
I was sharing dlls directly to modders
sure same thing
oh ok
and it sounds like they can't access the classes
is that the issue?
they can't just inherit from your Inventory class
because of limitations in the mod loader or something?
or can they? in which case this is a moot point
yes, the modloader is limited, cannot share classes only interfaces
they can access and call functions on classes from other mods, but not inherit them
this affects how verbose this is
inheritance I need to do interfaces
great
i'm not quite sure why it can't be inherited, i'm sure there's a good reason
but then this can be done with
interactable has an IOnInteractAction, which can be set to other functions?
// your prebuilt behavior (example)
sealed class DefaultInteractable : MonoBehaviour {
public IInteractable target { get; set; }
void OnClickHandler() {
...
target.Use();
}
}
// a modder's code
class Button : MonoBehaviour, IInteractable {
public void Start() {
var defaultImplementation = gameObject.AddComponent<DefaultInteractable>();
defaultImplementation.target = this;
}
void Use() { ... }
}
interface IInteractable {
void Use();
}
@sage bolt do you see?
ohhh i think i understand now
so a modder has a custom implementation of IInteractable, and this script has that as its target
or I can use my predefined ones
you can turn
var defaultImplementation = gameObject.AddComponent<DefaultInteractable>();
defaultImplementation.target = this;
into
void Start() {
AddInteractableBehaviour(this);
}
...
interface IInteractable {
void Use();
Component self { get; }
}
public static DefaultInteractable AddInteractableBehaviour(IInteractable target) {
var impl = target.self.gameObject.AddComponent<DefaultInteractable>();
impl.target = target;
return impl;
}
yes
your problem is basically "all classes in other libraries are sealed"
that's the most accurate way to describe the underlying issue
you can work around that though
right that makes sense
I wasnt thinking about it like that
I could even have some of the interfaces just be components now that I think of it
Thanks for all the help!
@sage bolt yes, and since you have static methods, which are easy to use
for normals
you can build around that
see the updated snippet
you can use the interface to force the end user (the modder) to conform to what a button needs to do
you can do this a lot of ways
very reasonable use of an interface
you're one of the only people using interfaces for what they are actually meant for btw @sage bolt
99.999999% of people having issues with them in this chat use them in ways that don't make sense
it is a Bad Idea to declare function properties (like UnityEvent) on your sealed class ... : MonoBehaviour and have users assign those instead
assigning functions is reinventing interfaces
thats good to know!
most people probably aren't programmers and just want to "make a game", which, fair, but it does mean we see a lot of it here in code-whatever
i mean dont' try to replace interfaces with UnityEvent in response to this comment you made
or something similar
I was thinking of making inventory a component but the more I think about it the worse it is. your solution is great for allowing modders freedom.
you can make an sealed class InventoryUIActions : UIBehaviour and it takes a IHandlesInventoryUI interface in a property
and the modder implements "just" the methods in IHandlesInventoryUI
this is how UGUI works isn't it? you've seen these patterns before
the reason interfaces crop up in all these places is because interfaces are meant to answer the question:
"what if you can't possibly know what all the code is going to be ahead of time?"
they aren't meant for "organizing a programming project" or "adding structure"
thats exactly why im using them, I do not want to have to know everything a modder could add
you will also maybe see that things that take an IInteractable as a target might themselves be something like
interface IHasInteractable {
IInteractable target { get; set; }
}
thats perfect
and maybe you want to make that generic...
interface IHas<T> {
T target { get; }
}
interface ICanAssign<T> : IHas<T> {
T target { get; set;}
}
what does this look like?
interface IProvider<T> {
T instance { get; }
}
interface IHost<T> : IProvider<T> {
// really TrySetInstance
void Inject(T instance);
}
here's another way to look at it
this same stuff by a different name
there are also dozens of people who post about dependency injection here
and it makes no sense
but when you're authoring mods and plugins it does!
that is what it is meant for. when you can't possibly know what all the code is going to be ahead of time
whereas, in your own game and your own codebase, you can always know all the code ahead of time
so it's pointless
you can modify anything, and change the access level of anything. if something is sealed, you can go and remove that keyword. so it's pointless. @regal lava
that makes sense
in my opinion, you probably do not want to create a dependency injection framework
keep it as simple as possible. don't use the generic interfaces
and stuff like that
it will intimidate people
carefully choose static methods
with clear names and simple arguments
and encourage people to use that as the API
unity is already a dependency injection framework, Inject is AddComponent and GameObject is an IHost
and IProvider is GetComponent
that's why you don't really need to author a whole dependency injection framework
you can use interfaces here to reduce the amount of bugs
It's hard to avoid the dependency injection stuff since monos are done using Unity's constructor. I've ran into this issue multiples times and still scratching my head about keeping some data completely private from other modules.
completely private from whom though?
unless you are authoring a plugin or library, private is documentation. the access modifiers have this weird thing with the inspector by idiosyncrasy, but they are really documentation in your own code base
May got to get back to you on that, I was developing some tool on the gui and couldn't wrap my head about some accessor privilege's when trying to nest multiple classes.
yeah it's pretty arcane
i'm not saying declare everything public and use class instead of struct
they have functional impacts, sure
but using them as access modification alone is documentation. you can always change the access modifiers
I arrived at a solution in line with this idea
Interactable class and interface for has interactable```cs
public sealed class IInteractable : MonoBehaviour
{
public Func<InteractInData, InteractOutData> InteractionAction;
}
public interface HasInteractable
{
public IInteractable interactableTarget { get; set; }
}
then an inv interface
public interface Inv
{
public List<Item> items { get; set; }
//can be overridden if a modder wants their inventory to be set up different by default
public void SetupDefaultInteractable(IInteractable interactable)
{
interactable.InteractionAction = data =>
{
//default show inventory stuff goes here
return new InteractOutData(true);
};
}
}
don't use a function
it's redundant
oh yeah
this si going to work poorly
silly of me
you did exactly what i said not to do lol
very very bad
lol
just stick to the snippet i shared
trust me it's the best approach
I was thinking raycast can just look for interactable and call it
no
ok will redo it
also you declared a default implementation in an interface
in line with snippet
which is not allowed
i mean this thing you shared won't compile
okay, before you do anything more
carefully reread everything i wrote lol
and if you have any questions please ask them
you sort of have to understand 90% of what i wrote before you embark on the rest of this journey
sorry yeah ill reread it
weird unity threw no errors
i am not sure what is going on, but afaik, unity does not support default interface method implementations, which you authored in the snippet you shared
it might support them in unity 2023.1.0a but i don't think you are using that
so either you're not using the code you posted, you are misreading the messaging from unity and haven't yet discovered it doesn't work, or i am wrong
I misread, ill redo it one sec
ok used the snippet i think
use these two for handling interaction calls
public sealed class InteractableHandler : MonoBehaviour
{
public IInteractable target { get; set; }
public void OnClickHandler(InteractInData data)
{
target.Use(data);
}
}
public interface IInteractable
{
public void Use(InteractInData data);
}
I can just look for InteractableHandler when raycast or something like that
inventory and data is this
public struct InteractInData
{
public GameObject caller;
public InteractInData(GameObject caller)
{
this.caller = caller;
}
}
public interface inventory
{
List<Item> items { get; set; }
}
I did one thing different though that im wondering if is okay or terrible
//modder made class
public class smallChest : MonoBehaviour, IInteractable, inventory
{
public List<Item> items { get; set; }
public void Awake()
{
var handler = gameObject.AddComponent<InteractableHandler>();
handler.target = this;
}
public void Use(InteractInData data)
{
//GenericFunctions.ActionDict["default inventory"](data);
Debug.Log("default inventory function not implemented")
}
}
/* unused
public sealed static class GenericFunctions
{
public static Dictionary<string, Action<InteractInData>> ActionDict { get; private set; } = new Dictionary<string, Action<InteractInData>>()
{
{"default inventory", data => Debug.Log("default inventory function not implemented") },
{"default buttom", data => Debug.Log("default button function not implemented") }
};
public static bool AddEntry(string name, Action<InteractInData> action)
{
if (ActionDict.ContainsKey(name))
return false;
ActionDict.Add(name, action);
return true;
}
}*/
to allow modders a default function to pull from instead of writing their own
have a static dictionary of predefined functions
also if a modder wants to add a bunch of interactables that all behave the same, instead of rewriting it they can add it to the dictionary and reuse it
okay
i think you're still pretty confused
addcomponent doesn't appear anywhere here
you're still declaring functions and assigning them to variables
you're too preoccupied with making the api "and then your thing : IInteractable" and that's it. it's impossible to just do that alone
next snippet you share, write in a comment which code is yours and which code would be the modder's
and declare everything that is sealed sealed
so that you can wrap your mind around this better
is this not the same as snippet with one change?
smallChest implements the Interact function from the IInteractable interface
but instead of defining it there it pulls from preset functions
i changed without dictionary active, is that still different from snippet? I add the interactableHandler in awake of smallchest and set target, and implement the IInteractable.Interact void
I'm sorry if im missing something
i think this is entirely in line with your snippet now
okay lol
Debug.Log("default inventory function not implemented")
this is a little concerning. if you want a default implementation,AddComponent<DefaultUseImplementation>()
InteractableHandler is mean tot be all the "Defaults"
like nobody wants to write their own click handling codew
you are saying "defaults" and reall yhtat's just, i don't know, the meat of your plugin
Hi all, i got a problem with the unity event system to find a game object, if i do "itemToDrop = EventSystem.current.currentSelectedGameObject.GetComponent< ...>" then he find the GameObject, but if i do "GameObject.Find(EventSystem.current.currentSelectedGameObject.ToString())" then he does not.. anyone got an explanation please ?
everyone is going to have a different Use implementation, nothing "Default" should appear in there
does that make sense? @sage bolt
so Use is strictly the stuff that is special about the end user's inventory item
you can add useful utilities (like static functions) that people can call from Use
the not implemented is just filler, I will fix it
im reading and responding to all give 1 sec
an empty Use ought to be valid
no problem
like Use that is empty would be an item that when clicked in the inventory, does nothing
and gets spent
does that make sense?
it would be "Potion: Does nothing."
ohhh
InteractableHandler would contain everything you are calling "default"
you say default
you're still thinking in radioactive class hierarchy terms, where that word isn't used anywhere anyway
right
default is a made up chembot idea
so all default interactable general stuff goes there
purge your mind of this word default
ok so no default at all
lol
what im thinking is this
i know
yes
i understand what you are saying
you can say "Basic" instead of "default"
a basic implementatino of an inventory item, you click on it, it spends 1 quantity, it casts a spell
public void Use(InteractInData data)
{
GenericFunctions.ActionDict["basic show inventory function"](data);
//special specific to this class modder function
}
the spell is implemented in Use
nooooooo
stop with the actiondict!!!
look at what you have
should modders not have access to a generic show inventory function without having to code it?
look at OnclickHandler
why would they call that?
you would put that in OnClickHAndler, and also, why is it an action dict? why isn't it just a static function?
anyway
i gotta go
you have used up all your doctorpangloss points lol i'm sorry
sorry about that
it's okay
specific to inventories not all interactables
i think as you improve in C# a lot of this will be obvious to you
ill try
I assumed that all inventories modded or not would call a similar base show inventory ui function then add custom stuff from there hence the dictionary
sorry for wasting so much of your time on this
it is incomprehensible to me why you are doing GenericFunctions.ActionDict["basic show inventory function"](data); instead of InventoryItems.ShowInventory(data);, where ShowInventory is a static method
but nevermind that you don't need that at all, in this psecific case
Use wouldn't have ShowInventory, i mean
i don't know
okay
yeah sorry
ill do some research and testing on my own. thanks for all the help and snippets
Uping my message
gameObject.toString != gameObject.name
but the ToString give me the exact name
i used a Debug.Log and it shows me what i want
Debug.Log(teste);==Debug.Log(teste.ToString());
Debug.Log(teste.name); is what you want
oh... hold one a second
oh yeahhhhhhhhhhhhhhhhhhhhhhhhhh
got it thanks !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
np 👍
I've got an object pooling system that uses classes that implement an interface I made that has a Reset function, so I can have different objects reset different fields when they get disabled by the pool. If I use extension methods to add a Reset function to, for example, Transform, is there a way I can make it "implement" the interface and be a valid sub-type for the pool? I don't want to just use SendMessage or reflection, if it comes to that I'll just check the type before calling the function on it and drop the type requirement on the generic
You wouldn't really be able to make a type implement an interface without being able to modify the actual type so that wouldn't really work. You could instead go the route that unity's built in ObjectPool went and just accept delegates in the ctor for the actions to take when getting/returning to pool. Then you wouldn't need any constraints on the type and your pool would work for any type
I could, but I liked the idea of the interface instead of the delegates just for the sake of my own OOP-poisoned brain grokking it better. If I have to use delegates I'd probably just switch back to Unity's built in
The whole point was to make one I didn't need a bunch of delegates for
Guess I just discovered why it used em in the first place then, might as well switch instead of repeating mistakes of the past
what are you trying to do?
based on this snippet you should probably start with some more unity tutorials #💻┃code-beginner
hmm, so my game has a pause menu with a host and a client button, when i press the host button (obviously starts hosting, im using netcode btw), and then close my menu too fast, it crashes the built version but NOT the editor version. looking at the player log shows that it crashed ofc, and then it says that it fails to get the stacktraced debug symbols. this is the actual log (minus the massive loaded binaries list and other stuff at the top)
ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FFA64DC6A7D)
0x00007FFA64DC6A7D (UnityPlayer) (function-name not available)
0x00007FFA65AD07BF (UnityPlayer) UnityMain
0x00007FFA65ADA53D (UnityPlayer) UnityMain
0x00007FFA65ADA635 (UnityPlayer) UnityMain
ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FFA64D1889A)
0x00007FFA64D1889A (UnityPlayer) (function-name not available)
0x00007FFBABBA26BD (KERNEL32) BaseThreadInitThunk
0x00007FFBAC60A9F8 (ntdll) RtlUserThreadStart
any ideas how I can debug what's happening if my stacktrace isnt even working?
and yes i selected development build
also the stacktrace changes for some crashes apparently
Do you have a crash dump ? Do you have the symbols associated ?
crash dump yes
symbols no clue
i assume no because it cant read them
no clue how to check tho]
They should located with the build you did or in the StagingArea after a build.
stagingarea?
In temp folder, after a build.
appdata temp or windows temp
Unity temp
never heard of that, is that in my project folder or some folder i dont know about?
this folder is empty
windows 11 64 bit
you need specs or
i imagine not for binary debugging like this
stagingarea has data folder
lib_burst_generated.pdb
i imagine thats what i want
In PC you usually have BackUpThisFolder_ButDontShipItWithYourGame
yes i have that too
and the symbols are there
_BurstDebugInformation_DoNotShip
thats what i have
in the game folder
lib_burst_generated.pdb is what i want i imagine
Do you use Mono or IL2CPP ?
mono
I use IL2CPP. Not sure where the symbols are with Mono.
how do i use the symbols tho
Not really something I am an expert in.
its a pdb file right
Yes
You open your crash dump with Visual Studio
whats the difference?
Il2CPP is faster runtime
by how much
I mean, everything that is faster is better.
Can you screen shot the whole
the whole?
Is that the whole screen ?
what else do you want
I usally have an action like that
Maybe just try to launch debug from the menu
Then something like that
i dont see an "Actions" menu
And, I've look and you need to have "Copy PDB files" checked
Just start the debug as you would do normally
oh okok
idk what normally is
i dont have a lot of experience debugging in VS
What is the file you are opening ?
crash.dmp
I just have Switch crash dump on hand
Do not really know how to help there.
Normally you have those action
🤦
nah i already ran debug
but i reopened my file just now
so when i was talking earlier there was no actions
Ok, so you did click on debug
yeah but i just randomly picked one of the 3
im gonna run mixed i think?
hold on
what the
i added the unity pdbs selection on that unity debugging article you linkedf
idk if thats what i need
but now i need this extendedatomcops header
What your callstack looks like now ?
or in an object file that needs that header
i can scroll more if you want
interesting
You have everything you need
I usually do not go further
stack frames are so fun to look at lol
i disagree.
IMO debugging stuff is so much fun, i didnt realize VS supported debugging this well
Say that in a couple of hour.
I'm sure you gonna have a lot of fun with this bug.
trust me ive had my fair share of debugging stack traces
idk that im GOOD at it
but its fun
.
Anyway good luck
what am i supposed to do, just send it in to unity
or do i go apply for a job at unity 👍
debug it there with access to the entire source
You minimize your code/scene till you do not have the issue
If you look a bit higher. You might be able to have more information. I've to do this for Partcuticle Effect and Cloth at some point.
You remove every particule effect
till you find the one
what if i already have an idea that its two or three specific scripts
Work from there
hi guys, im not looking for a detailed solution or answer here but more just general advice... i have a turn based 3d grid based multi level game with A* pathfinding. I also have an 'enemy intent' system (similar to slay the spire) where it shows the player where each enemy is going to move next turn or do x action on what unit etc.
im having performance problems with pathfinding as i update each enemies intent (next action they will do) after the player does an action or ends their turn, as the enemy intent system checks every possible spot the enemy can move to and evaluates how close it is to its target player
i did make some performance improvements by switching from classes to structs for my pathfinding implementation but its still quite slow, im hesitant to take the dive into using jobs as it requires a large refactoring and im not 100% sure if it will solve the problem
code for move action, every valid gridposition is fed into this method everytime the player takes an action
public override EnemyAIAction GetEnemyAIAction(GridPosition gridPosition)
{
Unit targetUnit = unit.GetEnemyAIUnitTarget();
GridPosition targetGridPosition = targetUnit.GetGridPosition();
int pathLength = Pathfinding.Instance.GetPathLength(gridPosition, targetGridPosition);
int pathLengthValue = 100 - pathLength; // invert pathlength so we get the lowest value, which is the best path
return new EnemyAIAction
{
gridPosition = gridPosition,
actionValue = pathLengthValue,
};
}
is anyone able to give me some advice on how to start thinking about and solving the performance problems? (performance problem = the game 'lags' for ~1s when youend your turn or complete an action)
Hey guys, I'm trying to make a minimap rendertexture, I had it working earlier but now I want to use a shader to render my texture and its showing up as dark red in the game view, however when I look at my scene view everything is fine.
Even during play the scene view is totally fine
the same texture in game view
btw im using shader graph to write the shader
I'm trying to make a minimap rendertexture
just create it in UGUI
this is such a simple minimap you don't need to do anything sophisticated
Yeah earlier I was using a rawImage
but I wanted more flexibility on how to render it
What renderer are you using to render it now?
But I agree with roctorpangloss that it should probably be a ui object. You can use a custom ui shader. Although I'm not sure if you can create one with the shader graph at the moment.
@dusty wigeon so apparently if i remove all my trees it stops crashing
BUT
i dont know if thats a race condition or something
it might not be related to trees
but i have 10000 trees
and its always crashing on a draw call afaict
can't u have a few less trees? 😄
do you ever see 10000 trees in the camera, tho?
no
then yes
i am NOT writing a script to move the 10000 trees around
is it more problematic than a game that crashes? xD
anyways it shouldnt CRASH from having too many trees
they have LOD
so it shouldnt be a problem
and its only if i close my menu fast after starting a netcode host
its a weird bug
pretttttttty sure i dont want to just delete some trees and let it marinade in my game code
do you happen to completely sync 10000 trees? 😛
no
phew 😄
they dont have network objects or anyhting
and again
its only when i close my menu quickly
if i close it after a few seconds, it works completely fine
that's so weird
my best guess atm is some really weird race condition where the frames my netcode starts running, the code has to handle input
still you shouldn't have 10000 anything in your scene at the same time 😛
the standard is either the UnityEngine.Terrain Component, Chunks, or custom GPU stuff
?
anyways my guess is something in my input handler does not like something in my netcode
well its not my netcode
it IS my input handler
but i dont know how to tell if thats true
whoops
how do i print what thread im running on so i can compare in my debug crash dump?
Thread.CurrentThread?🤔
yes
How can I pass a texture that I created during runtime to shadergraph for sampling
I've created a minimap texture during runtime, but I want to do some post processing on this texture using a shader
guys have i mentioned how simple race conditions are to debug
i added debug.log()s
and now it wont crash
yep
this is brilliant
same way you'd pass a texture that resides in the project files, material.SetTexture(fieldName, myTexture);
what node would this be
shadergraph is just a shader creator, you don't actually mess with shaders in runtime (not in normal use cases)
its not a static asset, I create this Texture2D during runtime and I also update it
instead u should feed data to the material that uses that shader
I see
I have a list of vector3's on a game object, would it be possible to pass these to the shader during runtime? And if so what node would that be
It doesn't matter when you create it, you pass it into the material/shader the same way as Lyrcaxis mentioned a few messages ago.
ok well how would I get a reference to this texture
I can expose it as static on the game object
? by passing it from where you created it
Same as with the texture. Material.SetVector(iirc). And nodes are irrelevant. It's a shader property.
Well, get a reference to the object that generates it and expose it as a property or something. That is really not an advanced question...😅
ok so how do i debug a race condition
or figure out if it is 100% a race condition
check the crash logs?
what logs
they just say "Crash !!!"
and then a bunch of binary names
and then a list of errors where it failed to read the stack trace
They should give a reason of a crash.
Some kind of error or error code
And probably a stack trace.
Probably also worth looking at the player log.
oh the player log is the only one i am looking at, where is the crash log?
im in the crash_ folder
but the only log in it is the player.log
and then a memory dump
Is that from a build?
I guess there isn't a crash log then...🤔
I think you are misunderstanding my question
In my MinimapRendere.cs file in the Start method I create a new Texture2D
public Texture2D minimapTexture;
void Start() {
minimapTexture = new Texture2D(width, height);
}
I don't understand how to pass this texture to my shader (using shadergraph) as it is only created in runtime
we understand it perfectly fine
we already told you
You can pass it right there in the Start after creating it.
But then I need a reference to my shader?
no to the material
and anyways, thats not hard
it always crashes with a stack roughhhly like this
Not 100% sure, but are you calling some unity API from a thread perhaps?
what counts as a thread?
i mean like
i would tell you
but my debug.log() stops the crash
Anything but the main thread.
Because it stops the thread before it gets to the crash I'd assume.
im not explicitly using another thread, but there is netcode and the input system
that might use another thread
Netcode as in unity's netcode for gameObjects?
not entirely sure on the thread architechture of unity, i probably should be if im gonna keep dealing with race conditions
yes
What callback is it?
Like where is it called from?
Yes
uh, so im calling NetworkManager.Start_Host() from a button press, and im calling some code to close my menu in a key press
ship it with debug.log when exiting the menu quickly lmao
i love marinading race conditions in my code :tf:
i wish i had nitro for that emote but i assume most people know it
?
Honestly, I don't think it's a race condition
trollface lol
that is why i was asking
👍
👍
what details are you looking for, or what details should i find
what log tho
the crash one?
Yes
because again it doesnt crash in the editor
also
i think the stuff you said earlier is in my crash dump
What platform are you building for btw?
windows 64bit
Okay.
this is the error code
from VS
reading my crash dump
and its in some graphics callback
well
idk about callback whatever
doesnt matter its a function
and thats where it is in the stack trace, in every single crash
It sounds like unity's thread safety system. But we don't know what the cause is.
This is not the log though. What do you see in the log?
i dont know how im supposed to get to the log
also after i checked "Copy PDB files" in build settings my player.log actually does have a stack trace but its just like in the call stack in my crash dump
========== OUTPUTTING STACK TRACE ==================
0x00007FFA694C649D (UnityPlayer) BufferD3D11::EndWrite
0x00007FFA694BAFA3 (UnityPlayer) GfxDeviceD3D11Base::EndBufferWrite
0x00007FFA692C6A7D (UnityPlayer) GeometryJobTasks::EndGeometryJobFrame
0x00007FFA69FD07BF (UnityPlayer) GfxDeviceWorker::RunCommand
0x00007FFA69FDA53D (UnityPlayer) GfxDeviceWorker::RunExt
0x00007FFA69FDA635 (UnityPlayer) GfxDeviceWorker::RunGfxDeviceWorker
0x00007FFA6921889A (UnityPlayer) Thread::RunThreadWrapper
0x00007FFBABBA26BD (KERNEL32) BaseThreadInitThunk
0x00007FFBAC60A9F8 (ntdll) RtlUserThreadStart
========== END OF STACKTRACE ===========
if you want it
From the stack trace it looks like it's trying to write to a buffer. If that's where it crashes, perhaps the buffer is not available on the thread... I'm not sure why that would happen though.
@craggy sierra, you still like debugging ?
hell yeah
i just am not good at it
What's coming before that?
What happens if you reduce or increase the amount of tree ?
And before that?
good question
Does the error goes away ? Does it amplify ?
Crash!!!
SymInit: Symbol-SearchPath: '.;C:\Users\a\Documents\Debug Hunted;C:\Users\a\Documents\Debug Hunted;C:\WINDOWS;C:\WINDOWS\system32;', symOptions: 534, UserName: 'a'
OS-Version: 10.0.0
Which line cause the crash ? Is it when you open the menu ?
i dont know because i cant get a trace from in the code
Do you instantiate your menu ? Or you keep it alive ?
Do not need a that to know which line cause an issue.
Delete everything till it works
its when i close the menu quickly after starting the NGO hsot
deleting the trees worked
Then readd everything till it does not work
but i need trees
What shader are you using ? What batching technic are you using ? What tech are you using ?
Did you try to swap your tree for something else ?
i would like to
not sure about batching technique
Is it only this particular object ? Is it the material ?
not sure what you mean by tech
What rendering path are you using ?
forward
URP ?
the shader is a shader that ships with the trees but i had to edit it a bit to actually work
urp
yes
Did you try to remove the SRP
for some reason the shader still had "lightweight" instead of "universal"
it will probably just pink and throw errors at me
and i dont think it will build
which i need to repro the crash
It should not and if it does, it will still build
Is it one kind that is problematic ?
idk i can test that before throwing out URP
but i dont even know if trees are the problem for sure, just the problem stops i remove them
There is a lot of tree, maybe it is link to the number of objects rendered.
Which is why I'm thinking about the SRP.
And batching.
i tried adding 10000 cubes and it did not crash
but why would that crash
number of objects i mean
and i dont want it to
Maybe there is race condition in the SRP.
if i have high object count it should just run at 1 fps
maybe
but
it could also be anywhere else
why does it hapenn
SPECIFICALLY when i close my menu quickly after opening a host for NGO
idk it could be either way
SRP or my own code
Because you are changing the graphics load.
ok one type of tree crash
Are you instancing your menu ?
now to test the others
what no
i dont think that makes sense does it
Do you keep it alive ?
yep
Or your Destroy it
it stays alive
Did you try to destroy it and instancing it back. You shouldnt do that, but for test purpose.
no it has a lot of weird references
i have to refactor a bit so it can be added as a prefab for any level
!Unclean Code Detected!
very true
Did you try to show up other piece of UI instead of your menu ?
ok tree type 2 crashed
Try something else than a tree after.
hmmm, like what
how do i mass place cubes tho
Like you do with your tree...
maybe it wasnt working because i was trying other meshes
idk i tried other stuff earlier
I'm unsure whether this is really an #archived-code-advanced topic, but it's going on long enough that you should make a thread for it anyway!
There should probably be triangle index in the hit info. You could probably calculate the vertices indices from it and get their positions from the mesh
Or whatever stores the vertices in this case?🤔
Physics2D.raycast doesnt have any overloads that output hitinfo it seems
Bloop bloop, realized you were talking 2D 😄
Raycast returns a RaycastHit2D, it doesn't provide that info and you would have to calculate it yourself afaik
that kind of sucks, is there a way you'd suggest for me to calculate those points?
Iterate over the border edges and check if the point lies between the line's points using any of the algorithms you can find online for such a thing
that sounds like extremely large overhead for what i'm trying to achieve
I need these vertexes so i can allow my player to move in a path traced along a composite collider, iterating through the edges to find the correct one would be a ton of overhead to run every frame for my player's movement logic
Maybe you could do that at editing time(find all the outside edge points) and cache the results. Then just use them as a waypoints at runtime..?
Composite colliders and edge colliders already store their edges in an array, the issue would be obtaining the correct edge index based on position; any solution I’ve come across there just involves iterating through every edge, but the composite collider in question is my level geometry, it would be a lot of overhead
Maybe use a quad tree?
when i throw my rope using line randerder in my first throw my my rope comes from the (starting point (the point where my line randerder is on the ground ) )or may be from another side .
after retracting back and using again makes it fixed..
anyone got an idea what's going on.
after retracting and using again making it fix.. (Perfectly)
i've tried caling retracting in start in case it fix but not working
i have
Starting Point
End Point
in First throw it comes my rope goes create from the my hand but a line actually moving from ground to my end point
Need help with my "grid" object placement system.
I have "top walls" & "bottom" walls. When placing in some directions, they randomly change to "top wall"
I use "OverlapBoxAll" to detect objects closes, change to other sprite depending on if it has an object below or above.
I've tried messing with directions for a while now.
(Putting code in thread)
!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 what the code posting instructions say, try again
Mobile users cannot see the code without downloading it
hmm :_) ohh
soo how can i add
You read the instructions of the bot above
I see nothing unusual. You should try #💻┃code-beginner to have someone guide through debugging steps. (Logs, Breakpoint, Scene Setup, etc.)
Also, if you could rewrite your original message, it is hard to understand what you trying to say.
well actually when it throw the rope at the first time rope coming from my hand but the end point is the ground and its like the end point is going from ground to my grapping point
but after retracring and throwing again making it perfect i have no clue why it's happening
#💻┃code-beginner or #archived-code-general. Advanced channel is for advanced subject, not day-to-day debugging steps.
Anyone here good at networking stuff?
I'm building an app on iOS that needs to communicate with the Unity Editor (a custom editorwindow). I need to be able to send files from the editor to the app and vice versa. I also want to do some RPCs from the editor to the app.
What's the best way to go here? I came across the Telepathy library which makes it easy to set up a connection and send arbitrary byte arrays over tcp, but I'm not quite sure how I would figure out what file I'm sending/receiving (a header, probably?).
Or is it a good idea to run a small http server on the app and use UnityWebRequest for sending files?
man I am sorta regreting this decision to implement my own input field class
totally didn't consider the selection caret lol
and my brain is not working this morning
why are you doing this
lol
Im building a code editor in-game and the input field was acting like a scroll rect when I was trying to use a parent scroll view
either way the solution felt janky so it was a choice between jank and jank
cuz I want the line numbering and input field bound to the same scroll rect, so I just sort of made my own input field class to handle input
i think we have a code editor
really?
with line numbering
F
i don't remember it being this complicated
what is your goal?
why do you need an in game code editor
I was building a digital circuit simulator, its more a passion project then anything honestly, its not a big deal really heh 😅
and wanted to make a code editor to complement things I guess?
tho honestly maybe a selection caret is the real test here. If i want to tackle stuff like code completion at some point, maybe I need to do this hurdle heh
you will learn something more useful in the long run if you embed a web browser in a ugui rect, and host the code editor inside there
UGUI and UIToolkit aren't really suitable for building text editors
Mmm I see
and by more useful, i dont' mean 20% more useful
i mean more like 10,000% more useful
right now you're clicking on the corpse, and you have two items to loot and only one space in your backpack:
- the parts for building your own code editor in ugui
- an embedded browser
and the game is rendering embedded browser with rainbows and holograms and animated particle effects and shit, and its legendary rarity hue is such a deep purple that it created a void in your screen. whereas the parts of building a code editor have like, a little fly circling around like it was a pile of poo
@frank peak does that make more sense?
lmao fair ye
If you go with embedded browser approach, you could just use VS Code for the web and you get all VS Code features for free without you needing to write a single line of code; alternatively you can use one level under which is Monaco editor (which powers VS Code under the hood) and at least get things like syntax highlighting line numbers autocomplete for free.
Or you can just expose the file directly and let user choose whatever code editor they want to use.
you can open up your mind to ways to build a circuit simulator more dearly
expose a text file? heresy
i only use an in game code editor for literally receiving copied and pasted text
there's a lot of value in going from 1 code to 0 code, but not much value in going from 102 code to 101 code
I mean if the game is centered around letting players to code, I’d like to let players use whatever code editor they prefer than forcing something on them.
I’d much rather opening it in VS Code and have all my extensions and keybinds to work comfortably, than whatever in game code editor you force onto me that probably works very wonky and unpleasant to use.
hmm good points but I also am leaning towards forcing the players hand into this jank
It's always a trade off, players tabbing out of the game to edit code breaks game immersion, but so does player getting frustrated at the code editing rather than enjoying the problem solving.
i wasn't sure if this was a game or an immersive application
surely if it's a game, you should be using blockly (there is a UGUI based asset and also official blockly embedded in a browser) or a limited-syntax coding tool (like a node based graph, although i personally really dislike those)
👀
With limited information, I would do:
- Design the language in a way that it can be coded comfortably without the assist of an IDE. Obviously it shouldn't be whitespace sensitive like Python; reduce the need for punctuations especially bracket pairs like
(); linear code top to bottom flow, so no need for player to "jump to symbol" around; short keywords egfn/funcinstead offunction. - Offer a super basic in game editor, could be as basic as literally just a multiline input field.
- Also offer editing outside using your own editor. It can be done as simply as "when player tab out, write the code from memory to file; when player tab back in, read from the file to memory" that's trivial amount of code with decent enough UX.
but that's just my opinion
recreating fusion360 and eagle, and then also turning it into a game, is hard
yeah thats fair. its fairly silly to try this but eh its not a serious project but just something to experiment with more or less, to learn and stuff. Thank you for the suggestions Burrito, Ill keep that/them in mind.
Hi there, I am implementing object pooling and I am trying unsuccessfully to Release all objects in my pool using thePool.Clear() et .Dispose(). Have I missed something ?or misunderstood how it works ?
not really an advanced issue. but you need to be more specific about what exactly isn't working.
Sorry, a bit hard to judge of the difficulty *:S Pasting the code rn
hello there, does anyone know how to get sqrMagnitude of a float3? "mathemathics package"\
math.lengthsq
Just found it through the api, thanks!
How do you use Unity API from another thread which isnt the main thread? I have found https://stackoverflow.com/questions/41330771/use-unity-api-from-another-thread-or-call-a-function-in-the-main-thread and it seems that the first answer works for people but I want to know if there is any simpler method
you'd need to make your own thread dipatcher
just use jobs instead of rolling your own tbh
Use unitask, which das a dispatcher that allows you to easily switch between threadpool and main thread anywhere inside an async call stack
Awaitable also has this if you are on 2023 https://docs.unity3d.com/2023.1/Documentation/ScriptReference/Awaitable.html
I have a problem:
I have a gameobject hand that has a rigibody, I want it's children (fingers) to trigger but if I had rigidbody on fingers the hand lose it's behaviour
fingers colliders are not trigger, and I want that triggers with in scene trigger collider without rigidbody
Trigger happens only if one of the 2 colliding colliders has a rigidbody, right?
the fingers rigidbody prevents the hand rigidbody to work properly (using the fingers collider as combined collider)
Rigidbody takes events from colliders on the same object and children
I'm thinking about possible solutions:
- fingers without rb. add rb to scene gameobject that have to interact with trigger.
- dupplicate the fingers so I can have one with rigidbody that makes the trigger happen and the other without rigidbody to gives hand's rb to work correctly.
- fingers with rb. somehow makes the child rigidbody stop prevents the hand (it's parent) rigidbody to work.
- fingers without rb. somehow know from with finger collider the trigger happen.
- fingers without rb. somehow trigger enter only when the hand enter and not for each finger
the problems come from that if I have only the rb on hand it fires the trigger for each finger
Hello. I'm currently trying to modernize a screenshot tool that's part of the build process to be automatic. This is going alright, but the screenshots I'm getting from it are significantly darker than what I actually see in playmode/the old screenshot system. Any advice? The settings on the cameras used are exactly the same. My current suspect is that the color mode on the render texture's inaccurate, but I don't know what it should be for a usecase like this
the dark one's the current output, and the lighter ones are examples of how it shows up in the old system/in the editor
The OnTriggerEnter(Collider other) method gives the "other" collider (the scene gameobject which i'm interacting with) so there is no way the finger will know it
Yeah, true
the other behaviour is that the vr hand collides with object pushing it on the wall without cross it when the player moves the vr controller in his real space
to have a good precision with the hand I need to place colliders into fingers
but with triggering gameobject in scene i gets triggerenter and triggerexit for every finger, instead i want only one
Can you just keep track of how many finger have enter and just fire the event if there is none ?
Beware of when objects are being destroy/disable, if I remember correctly they do not fire OnTriggerExit.
can you show me your inspector for your volume (URP or HDRP)?
you are probably using automatic exposure
i'm not sure if that exists for URP if this is a URP pipeline game
Already figured it out lmao, wasn't setting linear to true when making the texture I was getting the jpg from, and I didn't have the render texture on the right color format
okay that was my other guess lol
the api should really give you the texture format that is appropriate for the color space, rather than making you choose between sRGB and UNORM
any suggestions for runtime texture manipulation libraries? my goal is to easily crop and resize textures performantly. for example, i'd like to zoom-to-fit an AOV to a specific size.
Do you really need to change the texture or do you just want to show it cropped?
i need to crop it for an external system. this is part of my art generator workflow i hope to share soon
it looks likely i will put this all into a custom pass, but i'm wondering if there are already utilities for simulating the various camera croppings. for example, if the player's viewport is 300x500, and i need a 400x400 square image, i'd want a letterboxed/pillarboxed source from the center of the 300x500 viewport (a 300x300 source) copied to the 400x400 frame. i understand i can achieve this at the finest level using the graphics pipeline commands, but i'm wondering if there's already an expressive way to do "blit letterboxed/pillarboxed"
how to code a* stairs/slopes pathfinding?
Depends on the way your world is. Is it continous or discret ? Does it include vertical pathfinding ?
i'd say discret and it does include vertical pathfinding
i want to have units that can fly later, but i'm trying to start with simple things
so yes the character is grounded
i dont want to do it by hand, what algorithm should i use?
Use the navmesh of unity ?
it turns out the unity perception package has solved a lot of these problems already
i cant use unity's thing because i have my own movement script
You still can use Unity's.
okay i 'll learn about nav meshes and come back
this might be code-general / code-beginner
You can directly use: https://docs.unity3d.com/ScriptReference/AI.NavMesh.CalculatePath.html
oh cool and thanks for letting me know! 🙂
Hey guys, I'm trying to add multiplayer to my game. I have a gameobject with a rigibody, network object, network transform, and a network rigidbody. I'm currently sending the player inputs over a ServerRpc, but I'm running into this weird issue where My movment works as expected when I run my server in the editor, however once I try to run my server as a dedicated server my movement seems very slow and jittery.
any ideas as to why this could be happening?
I'm using multiplayer tools to run the server from unity editor, and I'm compiling for a standalone dedicated server to run it outside of unity.
Im trying to make a inventory system, I have a inventory array that holds all the item data and the imaginary slots, but idk how I can pair the lets say 3rd inventory slot UI with the 2 index in the array. (Also the amount of inventory slots determined till the game is ran)
what is your goal?
big picture
Im creating a racing game with server authoritative physics
My “racer” is a cube that I apply a force to using a UI joystick.
Ive been noticing some really weird discrepancies between running my server and client in the editor and running a separate dedicated server (compilation target) and a standalone client.
okay it looks like you are an experienced developer generally
does your journey end with a graphically polished multiplayer game?
there are a lot of things that could be going on, including some configuration here and there, differences between reality and expectations, etc.
yes this is for a startup I am working on, I have about 1-2months of experience with unity, but overall 5 years of professional dev experience
gotchyu. so you guys have a budget?
is the primary purpose to have a game, or something else?
both kinda
i am trying to figure out what mutliplayer thing to suggest
the game is just a aspect of the platform
and i totally understand the magnitude of jeopardy you might be in lol
okay
and i also totally understand the lack of focus
the overarching platform is a competitive crypto gaming platform
yeah
lol to your emoji
ive looked at PUN