#archived-code-advanced
1 messages ยท Page 3 of 1
Hello everybody, I'm having some weird inconsistent behaviour with collisions: I have a dynamic rigidbody (knife) that collides with a kinematic rigidbody (player), and on the knifei have my collision handling, which basically just freezes the knife in place and reparents it (to make it look stuck to the player).
Only the first knife to hit the player actually gets stuck. All subsequent knifes bounce off of the player, and then get stuck to whatever object is hit next.
Nowhere in this path of code do I have a collision counter. Objects are in the correct layers, etc. Only the first knife (that hits the player) handles the collision properly. In other words, I could spawn a whole bunch of knifes that miss, but whichever is the first to hit, it will collide. All subsequent knives "miss". Super. Weird. Any ideas?
Thanks in advance. I'm gonna take a break, this bug is melting my head.
Going to guess that the collider of the first knife is causing interference somehow
I guessed too, but in fact, something funny happens.
Upon contact, I make the knife kinematic + set rb.detectCollisions = false, so the knife doesn't keep doing damage and interfere with other stuff.
However, I have to do this with some delay to avoid preventing the damage from the initial hit to register, so there's a small fraction of time where the collider is detecting collisions and is active. If another knife collides then, it gets stuck to the other knife. So it only "works" if there's interference. But when there's a direct hit to the player collider (by turning the player's back to the danger), it bounces as usual.
its not stupidly large
its totally normal
1920*1080*4 (assuming 1 byte per channel) = 8294400โฌ bytes / ca. 8.3 mb
yeah - I suppose I'm still thinking in a web sort of frame of mind, where vector images can be pretty tiny
compared to jpgs or bitmaps or whatever
oh yes, vector graphics are wonderfully compact
especially because they're basically just text
yeah.. it's just funny because the svgs that my designer creates are a few KB and then the images we use in game are several hundred times larger
i also don't really need to go with 1024x2048 for these images.. most places in the game they're like 100x200 px
i had wanted to use some large images in places (cutscenes/story stuff) but.. i can make one-off larger images of those instead of the "main" character images (9 poses, 60+ characters)
the svg importer works
but it doesn't work for me in CD/CI
so that's how ti goes
Dumb question, if you can is there a way to connect your game to discord if as a multiplayer game to apply a role if you use get lets say verify your discord from in your game through commands and what not so now your discord is paired with your game, lets say in the game you get banned. Is there a way get a automated role if you achieved said role in game?. Worded that poorly haha
if so, how haha
There's a Discord SDK that you can use, although Discord has more or less deprecated it since they gave up on their game store. Without the SDK, you can set up a website that requires people to sign in to both Discord and the platform you're using for your game's authentication (e.g. Steam).
One shortcut you can take on the linking part is to get the connected platforms from the Discord user. Note that you still need a site for this because bots don't have access to a user's connected profiles. (This would also require people to have their Steam account connected to their Discord account)
Much appreciated! guess some note, i am referring to the quest 1 and 2. Probs in the same ball park of what to do. Site part seems interesting, just wanted to see if it was possible in general. Much appreciated!
Definitely possible. If people aren't running Discord on the same device as the game, then the SDK route won't work and you'll need the website where you have them sign in to both platforms using OAuth and link them in your own back-end.
At that point the consideration is more about user friction. I wouldn't make it a requirement at least ๐
One thing I do for our game is the Discord linked accounts route for people that have purchased a DLC. It has a Discord OAuth set up that requests perms to the connected accounts, checks the Steam ID that's connected, uses the Steam API to check if that account has the DLC - if so then tell a Discord bot to give the user the related role.
That way for people that already have Steam connected and are signed into Discord, the role activation is just opening the site and clicking authorize & done.
you can make a backend API.
- in the unity client, retrieve the user's public oculus profile token
- ask the user to login with discord and authorize your backend app. i don't think anyone will ever do this on the quest, because it's clunky, but go ahead, try.
- post the two tokens to your backend api
- use them to do your role business with the right profile information
if you have no experience with soemthing something a server, try the serverless framework and deploy to AWS.
as long as you can write javascript or python you will be fine
That is pretty much what I have implemented already - it works fine, and the last piece of the puzzle is having to stringify things to pass to certain engine features or other libraries etc. But it more a "it would be nice if there was a way to do this, even if its a dirty hack" rather than "i need this or ill die".
The biggest offender is Addressable Assets - ultimately you need a string to load / instantiate an asset. For each asset in the game there are often multiple versions - for different quality levels, localization, patches etc.
We have a library that takes an assets path, and then determines the best version of that asset to load. I preprocess and cache all the assets during init, and the api exclusively works with spans and a struct that uses an arena allocator to avoid memory fragmentation.
I could instead cache the original IResourceLocation but this also contains a bunch of heap objects - though unity might always have a copy of this so just storing a reference may be the answer. I also need to look into IKeyEvaluator and see if I can do something cheeky here by implementing the interface on the aforementioned struct.
I also found that certain string operations unexpectedly produce garbage (IndexOf for example), and while we don't typically use them while the game is running, we have to preprocess a lot of data up front, like addressables mentioned above, and scenario scripts for cutscenes and stuff.
I'm kinda rambling here though, and its quite domain specific so most devs here probably don't have to worry about these sorts of problems. Just fishing for ideas really - and so thanks for your input! Much appreciated.
Hey, with unity Authentication, I store the user account data in my own database, sending over a player id using Unity Authentication seems unsafe as anyone can just brute force my API server to retrieve user accounts based on a PlayerID.
Previously I was authenticating on the backend via the PlayGamesClientConfiguration Builder (requesting id token and server auth code) but it seems the new Authentication service unity provides uses a version of Google play games that don't have this feature anymore.
My flow is, Auth on mobile device, send auth data to server, auth on the server then send user data back to the client with my own JWT auth code for future requests.
Is there a different way we can authenticate a user on the server or am I missing something in the authentication flow?
GooglePlay services alike ain't maintained by Unity
or any other 3rd party cloud services
but they do provide bridging to those extenal apis if I remember correctly, proly this is your case, who knows
yeah, I missed the part in that link that shows the new way of requesting server side access
Thanks Slim
it's just hard to imagine a circumstance where this is going to cause meaningful performance impacts
like i know the profiler reports so and so amount of garbage
dynamically allocated memory (on the c# side) is never released on playstation platforms, so it gradually builds up over time, especially as fragmentation gets worse.
the c# runtime (or rather the cpp version of it) will "release" said memory internally, but on the native side of things that memory is gone for ever
If you consider the following design of implementing item effects:
public class Item : ScriptableObject
{
public ItemEffect effect;
}
public class ItemEffect
{
public virtual void Use(Unit unit)
{
}
}
public class ModifyStat : ItemEffect
{
public enum Stat
{
Health,
Attack
}
public Stat m_statToModify;
public int m_amount;
public override void Use(Unit unit)
{
if (m_statToModify == Stat.Health)
unit.Health += m_amount;
else if (m_statToModify == Stat.Attack)
unit.Attack += m_amount;
}
}
How would I go about adding the option to chose my desired effect in the inspector when having created a new Item scriptableobject, along with setting the specific variables tied to the effect? Right now it's not showing anything at all
Mark your classes as [Serializable]
well that works if I specify in the scriptable object that I want the "ModifyStat" effect like this
public class Item : ScriptableObject
{
public ModifyStat effect;
}
My idea is that if there are multiple classes inheriting from ItemEffect, how am I supposed to be able to chose which one I want on the item
To modify the example more
public class Item : ScriptableObject
{
public ItemEffect effect;
}
[System.Serializable]
public abstract class ItemEffect
{
public virtual void Use(Unit unit)
{
}
}
[System.Serializable]
public class ModifyStat : ItemEffect
{
public enum Stat
{
Health,
Attack
}
public Stat m_statToModify;
public int m_amount;
public override void Use(Unit unit)
{
if (m_statToModify == Stat.Health)
unit.Health += m_amount;
else if (m_statToModify == Stat.Attack)
unit.Attack += m_amount;
}
}
[System.Serializable]
public class RecallUnit : ItemEffect
{
public override void Use(Unit unit)
{
unit.Recall();
}
}
As it stands right now, there is no way to chose which one I want in the item scriptable object
you can implement abstracts for such use cases, or even interfaces if you prefer to, and use [SerializedReference] on your scriptableobject
public interface ISome
{ //some things}
public ItemEffect : ISome
{}
then later on, on your scriptableobject class
[SerializedReference] public List<ISome> referToIsomeInterface;
I'd implement second generic interface, so you don't need to implicitly casting to the correct type later on
but it's up to you
was misplaced, now fixed.. lol
very handy
you said ..there are multiple classes inheriting from ItemEffect, how am I supposed to be able to chose which one I want on the item
with the above approach you can do :
without generics
(ISome as RecallUnit).Use();
Hi,
I'm working on a project using addressables.
I need to include additional code inside some asset bundles, that is not compiled in the original build.
To do so, I use this kind of technique : https://docs.unity3d.com/550/Documentation/Manual/scriptsinassetbundles.html
Almost everything is working fine, except for one point : if I need my "external" code loaded from the asset bundle to interact with the original built-in code, I am facing some issues.
For example, I would like to add a button on the scene in my asset bundle which sends an order to my addressables manager singleton to load a new scene.
Here is a simplified version of my AddressablesManager class:
using System;
using System.Reflection;
using System.Threading.Tasks;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.AddressableAssets;
using UnityEngine.AddressableAssets.ResourceLocators;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.ResourceManagement.ResourceProviders;
using Utilities;
namespace Tools
{
public class AddressablesManager : MonoBehaviour
{
public static Action<string> DoLoadScene;
private void OnEnable()
{
DoLoadScene += LoadScene;
}
public void LoadScene(string addressableKey)
{
// loading scene from here
}
}
}
I have created a small Monobehavior class that I can reference in the onclick event on my button to load the scene:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Tools
{
public class AddressablesEvents : MonoBehaviour
{
public void LoadScene(string sceneName)
{
AddressablesManager.DoLoadScene(sceneName);
}
}
}
The problem : referencing the AddressablesManager class like this implies a cascading hell of dependencies (all the imported classes at the begininng of AddressablesManager ) to add in my secondary project to build the dll file.
How could I work around this issue to keep the minimal amount of scripts to be included in this secondary project and be able to have both sides of the code talking to each other ?
Hey all. Hopefully someone can help me with the following issue. I'm bending a mesh by moving it's vertices, which works fine. When I bend the X-axis as well as the Y-axis, the Z-axis bends automatically as well (it has to). Does anyone know the formula to calculate the Z-axis bend based on the X and Y bends?
i have no idea if this is advanced but it's incrediby cool
queuing and dequing function calls
I'm confused. If you're loading the types from the assetbundle using reflection (as per the example), how are you referencing AddressablesManager directly?
I even more confused, as I didn't see any Reflections used at all, only the namespace.. proly I'm just blind I guess
the link they posted used reflection to find and instantiate a type from an assetbundle
in the Unity.. 5... docs lol
Hi !
I've just found a solution ๐
I've created two classes with actions and events and I use them as a bridge
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
namespace Common
{
public class EventsManager : MonoBehaviour
{
public static Action<string> LoadScene;
public UnityEvent<string> OnLoadScene;
private void OnEnable()
{
LoadScene += _LoadScene;
}
private void OnDisable()
{
LoadScene -= _LoadScene;
}
void _LoadScene(string sceneName)
{
OnLoadScene?.Invoke(sceneName);
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Common
{
public class EventsDispatcher : MonoBehaviour
{
public void LoadScene(string sceneName)
{
EventsManager.LoadScene(sceneName);
}
}
}
So here I assign EventsDispatcher to my button, and call its LoadScene function from the OnClick event
and then EventsManager executes this action which call the other event... where I can have anything else assigned
So I just have these 2 classes in common in the two projects
After a second thought, maybe the action could be removed
anyway, it's working now
hello, so
I have a MethodInfo variable and I want to check if it's one of these functions:
they derive from the Object class
but I don't know how to check if they are specifically in that script
well I did it
{
OtherMethods.Add(savedMethods[methodName]);
}```
I can change it to typeof(object) instead
nevermind, that doesn't work
string it is
it kinda works
you are welcome to delete messages that do not arrive at a question someone can answer
Ah, I cannot find my answer online so might as well try it here.
I Have an interface that has a returnList methode.
problem is that I actually don't want to declare the return type when calling the methode. It should do it in the methode itself as it's unique for every class that uses the interface.
so I would like to have it work like this :
Is that somehow possible?
Sure, you can make the interface generic
interface IItemProvider<T>
{
List<T> GetList();
}
public class BasicItem : IItemProvider<CBasicItem>
{
// impl.
public List<CBasicItem> GetList() { /* ... */ }
}
(naming conventions fixed in the process)
Oh what something like this works? O.O
Yep, that's called a "closed generic" if you provide a real type in the <>
That's cool.
Give me a couple of minutes, I'll let you know if I get it working
okey I need 1 more thing to make it all work I believe.
I have one methode
private T CreateBasicItemObjectFromFilesAndMods<T>()
And inside of it I'm doing stuff with the above interface.
is it possible to have a Type as a parameter that I could pass into T via an argument?
M_Item<T> newItemsInterface = newItems as M_Item<T>;
Sadly this doesnt work :
private T CreateBasicItemObjectFromFilesAndMods<T>(Type classType)
M_Item<classType> newItemsInterface = newItems as M_Item<classType>;
Pass T directly, you have it
newItems as M_Item<T>
That's the thing, I don't.
the T that I pass with that methode is a different type as I need for the interface
the type I pass for the methode is S_C_BasicItem
but the interface needs the type C_BasicItem
Ah I think I see, would it be possible to add a type constraint on that method so it only accepts type implementing your interface?
private T CreateBasicItemObjectFromFilesAndMods<TClass, TItem>() where TClass : M_Item<TItem>
I doubt it as I would like to use the methode for other classes.
Let me give you an example quickly
This is how I would like to use the methode.
But I somehow need to pass 2 types, the S_C_Class and the C_Class
Unless you made a typo in the example you don't, the type you pass is the returned type
I have to go, someone else will take the lead
Thanks anyways!
Hello everyone. I was reading some arguments against the singleton pattern and i have some questions related to that. They say it is bad because of two reasons.
- It is globally accessible, so it is hard to find where the problem is being created when debugging.
2.ย Global states should be avoided because of the same reason.
Now here is the thing, a simple gameobject that is not a singleton (Say the player), will suffer from the same problems.
-
The reference may be passed around in different scripts and again any of them can create problems. Whether the reference is being passed, or the object is globally accessible. We can just do a "find all references" in both cases.
-
The player is not global but it has a state as well which may be changed here are there by other scripts.
So if the object is being accessed by a lot of different outside scripts. What is the harm in making it global?
For example, if i add a script "player references" on a player and make it a singleton (we can only have one player and for cases where we need some kind of clones, we can just not add "player references" script on them). Now the script player references will have references to all components on the player. That way anyone that wants the reference to player can use that with easy global access.
I believe this can be the example of "overuse of singletons".
But i fail to understand why this is bad practice.
Holy crap I fixed it.
Thank you so much!
All I had to do now was add a second generic argument that way I have 2 types I could pass and everything worked :))
1. The reference may be passed around in different scripts and again any of them can create problems. Whether the reference is being passed, or the object is globally accessible. We can just do a "find all references" in both cases.
you got this in reverse, when you're passing it as a parameter, the origin of it is clear and easy to track down. You can't say the same for singletons as they break those rules
Also, Singletons carry state around for the lifetime of the application which c# folks who doesn't do gamedev think that this is an evil thing... which I sorta agree
There's a talk by Ryan Hipple, Unite 2017 which elaborates on your points. Highly recommend giving it a watch.
Scriptable Objects are an immensely powerful yet often underutilized feature of Unity. Learn how to get the most out of this versatile data structure and build more extensible systems and data patterns. In this talk, Schell Games shares specific examples of how they have used the Scriptable Object for everything from a hierarchical state machine...
the "global access" pattern is bad no matter which way you implement it, a lot of things accessing one resource (through a singleton or otherwise) without indirecting/abstracting that access creates problems. The singleton pattern in particular is abused by many to create a simple way to access an instance from anywhere without thinking about how this user-object get its reference to it. This is NOT what a singleton is about, the Singleton pattern exists to capture the notion of uniqueness of a resource.
How would you implement logging?
Debug.Log()
Isn't that a global access pattern?
I guess if you had special logging needs it might be nice to carry some around
yes it is, and it also captures the notion of "there can(should) only be one logger"
same as networking and IO, you make assumptions in any program what will be unique and which will get woven into every bit of code you write, you need to be careful about choosing those
as changing them later is almost impossible
Singletons are not 100% bad. The point is that they're abused, so the easiest thing to tell a beginner is to not use them - because it's an easy way to do something in the wrong way and you shouldn't fall back on it.
those can be singletons (if they are unique) or passed around to "everything" like Debug.Log
you shouldn't have polymorphic data objects
so you're going to be repeating yourself over and over and over again, checking for the types of stuff
because you modeled it wrong
whatever you're writing to disk, it should look like
a single type
how am I repeating myself over n over?
It seems fine the way I did it now.
you made polymorphic data container. now you pay the price.
this way of modeling things was a mistake
you should fix it now. otherwise it will cause you way more grief later
I'm still not sure what you mean is problematic.
I wouldnt know how to solve it differently for my use-case.
this snippet looks really bad
Why?
I have different scriptableobjects for each item type
big mistake
as each itemtype requires different data
does it though.
like how different of data
like... one field
"well food has calories, and clothing has durability"
what if you made a field int value, and interpreted it differently depending on what kind of item it is
now when you write your code
you can do DoublePotencySpell, and it will find the "value" WHATEVER IT IS and double it
it doesn't need to know the difference between a piece of clothing and food
getting rid of polymorphism, and trying to solve your problem with a single data type, makes everything everywhere simpler, better and more interesting
anyway just think about it
it's your code
make generics
I don't think so.
It's way less readable and writeable from a modder standpoint.
Also how is it scaleable then? It's not.
What if I want to add in a new item type and my fields are not enough? I would need to alter that one item type to make up for the new item type.
And with my system I can simply add new item types without annoying the other ones
it's not as bad as you think I believe
Just necroing, not really important, BUT Unity has [SetializeReference], you can just serialize the interface in 1 scrtiptableobject if you wanted to
I know, I'm using that to have all scriptableobjects in a list to access from.
It's way less readable and writeable from a modder standpoint.
well the reason i know this stuff is because i made a game where the players developed all the content ๐
it's up to you to take my advice
I mean I understand the simplicity behind it.
But it would look like a mess in my case.
Some itemtypes like the weapons have way more fields than a simple food item.
And we're not talking about 2-3 more fields, more like 10-15 fields
And modders/players will not even see this kind of backend stuff.
They can create items via user interface
they don't have to write in the json file themself.
it's your prerogative.
you're trying to store something polymoprhic in json
it will be the single greatest source of pain in doing the seemingly simplest stuff
for you, for your users, everyone
is that smth uncommon? I really don't know it
just focus on the insight that you can have a field int value and interpret it different ways
i don't think anything else matters
you should focus on int value and keep thinking about it until you realize how powerful it is
well I need way more stuff than just an int value.
and it just seems odd for me to have the simple items with probably 70% empty fields because these item simply don't use it
it's common among people who don't know any better
maybe we are talking about different things
i would say you're getting to the first level of the expanding brain meme here
cuz u didnt saw my whole code
i'm glad you spent that much time thinking about it
you will have to think about it at least... 100x more
i am saying this is the first step on a... maybe 7 step journey to understanding why you should model your game the way i am suggesting
i have a few opinions
- what, truly, is the downside of empty fields, which cost nothing and confuse no one?
- but if you model everything like this... you will wind up with way fewer fields anyway
- and weapons and food items... it all comes down to thinking about how you can model different things with fewer data
which is valuable
you can always have more fields. in JSON, you don't need to declare unused fields, so it's sort of a moot point
which is to say that you're not sure yet how to do polymorphism, really
for example, you could have
class Item {
string name;
int value;
int cost;
...
WeaponAspect weaponSpecific;
FoodAspect foodSpecific;
}
that's still polymorphism, this is still a step on the journey
it's not the destination
anyway i don't think you're going to change anything @unique ermine BUT you should at least consider using an asset store asset for RPGs
since those are already purpose built for modding, in a sense
I might be talking bullshit since I am not an "advanced" programmer, but @unique ermine instead of using a lot of interfaces with so many variable types, can't you just create a basic item class, not interface, and expand from that on every other item in the game? For example Item -> EquipmentItem, RawMaterialItem, ProductItem -> more types expanded from each
Nah I appreciate the feedback & suggestion. In the end we cannot know everything correct from the start.
I do understand your standpoint and it does make sense, I even looked at an example that handles everything like you mentioned. But I thought itโs a bad habit and bade structure.
So do you also suggest having 1 ScriptableObject for all items? Or just have 1 data structure for all items in json?
and then work with virtual methods for loading the scriptable objects?
Thatโs actually what Iโm doing
I only have 1 interface
To handle my generic Methode
this is my base item class
Maybe instead of an interface you can just implement the method in the base class for your items as a virtual method
that type hierarchy approach breaks down really fast, using composition is the only sustainable way
and my clothing class inherits from it
they are down there
I need to explain some stuff in order for you guys to understand
or maybe you can already answer it yourself lol
when i see a type prefixed with S_C_ or something like that i immediately loose all motivation to continue looking at it
hmm, why is that so, is it because you can only add new "types" via code?
genuinely trying to understand
because of the diamond problem
Diamond problem, gotta have to read about it
I'm not encountering the diamond problem
"The "diamond problem" (sometimes referred to as the "Deadly Diamond of Death") is an ambiguity that arises when two classes B and C inherit from A, and class D inherits from both B and C."
its the most succinct problem to illustrate whats wrong with type hierarchies
@compact ingot I see, but still, the solution i proposed is not one which can face this problem, because I proposed swapping the interface for a virtual method, therefore the inheritence would look like a tree and C# doesnt allow a class to inherit from multiple classes
usually it appears only after you have made your initial design, and it is what causes you to create a mess for yourself and your project when you try to work around it later, when you've invested too much into the hierarchy to rewrite it
hence, hell
And for this specific scenario, a game item will not need to inherit additional interfaces from what maybe the original initial base class would have
then why do you have an interface in the first place?
Exactly, I proposed dropping the interface with the method returnlist in favor for a virtual method in the base class which will be overridden in all the classes that inherit the base item class
Again, It was a proposal, I am not confident in my answer and its more like "Would that maybe work?"
that's the thing.
While you guys are arguing you havent seen my whole code and you most likely don't even know why Im using that interface.
the purpose for the interface is that I need it in order to make my generic methode work
That is also correct, but I wouldn't say we are arguing, I am mostly discussing and I want to see his point of view
sry then, my english isnt perfect so I sometimes mix words
the whole discussion started because your code snippet looks like it came from a codebase that is modelled in an annoying way
it looks complicated and unnecessary and this channel likes simple things A LOT
I see haha.
Okey let me explain a bit so it makes sense.
I have different items that require different data.
I'm saving those items in seperate files in json.
as my game features modding, I need to read from specific directories and collect all items saved in the json. Basic modding stuff.
And for that I had 1 methode for every itemtype to load those items from the correct json.
But this has changed now as I changed the methode to be generic so I can use it multiple times without writing additional code.
I simply pass my needed classes ( which I think I can get rid of one after looking at it, as one class is just a List<> of the other class )
and I made an interface that I can then use in my generic methode to get the correct data and types
and it works exactly the way i want
But Like I said above, I think I can get rid of all my S_C classes.
This would simplify a lot of things and this might actually give me the ability to get rid of the interface
What I assume is that the whole S_C_BasicItem class is confusing, it did confuse me a lot
yeah
and then the interface works as intended, attached only to the base class of all the items
since it is a shared functionality
It also should not encounter the diamond problem since the classes that inherit from C_BasicItem will not have additional interfaces
Correct
I'm only inheriting from one base class
That's probably true
it's a flaw in my code I knew but didn't bother removing yet.
So thanks a lot for this feedback.
Yeah no problem, I have also learned something new today, never thought about the diamond problem
same!
I learned that you can have generic interfaces as well
you should have one, easily copied, optionally immutable data structure to represent all the "entities" in your game. this is essentially DOTS, but on easy mode
that approach will support the most gameplay with the least amount of fuss
You sound a little bit like someone trying to sell a book or something similar ๐
Thatโs what people sometimes say to end a conversation
Itโs probably just because nobody had demonstrated positive ROI for automated tests in games . The VG industry is probably testing more than any other industry, just not in a fully automated way
Mistake
Even if they did, most games are so inter connected that makes testing very hard
For sure, it's just even harder in games
you canโt automate things that are supposed to be consumed by humans. Not all things can be quantified and therefore tested. If you design for purely automated testing, you loose touch with your audience
Is there some way I can guarantee my app will always have lets say 50MB available in Application.PersistentDatapath ?
or if the user has the memory full i wont be able to use it whatever i do?
I was thinking if its possible to include in the build some sort of dummy files... but if i include them in the build im guessing they wont be in PersistentDataPath
is there anyway to include those files on install inside persistentDataPath? this way i would remove the dummy files on gameStart
and i would have that space
i've come across this:
but theres 0 info about how much is it available and how to use it
Simply put, you canโt Automate testing for if something is fun or makes a user more effective without introducing a metric that can overtime (or a priori) deviate from what it was supposed to measure
testing also requires a BIG amount of time, preparing it and updating it
not always, they can often save time
but TDD for gamedev sounds like a waste of time tbh
games are also a lot more fluid than for example a web API, games tend to change over the course of development, forcing you to continuously keep all relevant tests up to date.
Maybe you tweaked some balancing, maybe you extended an existing system, added a new system that needs to integrate with existing ones somehow - if you had a test for something affected by this change then now you also need to update all of those tests.
I'm no test expert but i find highly unlikely to create a test environment in which 'most' of the exceptions i get from my players can be detected
I'd consider writing tests for billing and account systems for sure tho
im talking about games obviously
me too
sure, some things can be tested even in videogames but there's a lot of things that would really not be worth the time spent keeping the tests up to date
ah, billing and account sytesms inside the game, yeah true
but to be honest the most problematic bugs i needed to debug... were all because the player was doing something unpredictable and i dont see ways to test those things
but as i said... im no test expert
yeah, since there's a lot more variables to account for
you can't realistically keep every possibility in mind when writing tests
variables, movements, interruptions in certain moments ... some things you simply cant
Hey i have some lists of different custom classes and i now want to make a function which takes any of this so i need to be able to pass a list of any type.
public class enemy
{
public string name;
public string art;
public string armour;
public string power;
}
public List<enemy> enemyList;
Can someone tell me how this would look like?
depends on the game / developer i'd say. sometimes you don't have a 100% implementation in mind from the get go, obviously with more strict planning that would be less of an issue
yes, but you can't catch every bug using just unit tests, there's always going to be a need for manual testing
or you can release it and let the customer debug... like bethesda or project red
things that are self-contained would definitely be good candidates for TDD, but a lot of things IMO wouldn't make much sense
on the opposite side, the more things something interacts with, the more effort it is to set up the test and then make sure it's also up to date on any additional changes
i'd say that depends highly on the game in question
some games have very "straightforward" mechanics, like for example some sort of a economy simulator type of thing,
whereas if it's a platformer then there's not necessarily much you can test imo, you can make a test that the jump button works but maybe not that the jump is high enough or that there's no bugs with how the jump interacts with various terrain types and/or the jump height
if you want to test some of these things you also need to go out of your way to code it in a way that's test friendly
which might take extra time to make sure the code architecture supports it correctly
most meaningful tests for a game have to be end-to-end tests
only so much you can test with unit tests, unlike things like web back-end
end-to-end tests will take a huge amount of work to properly setup
whereas you could just make a scene with every terrain type, hit play mode, and try jumping
yeah
that could work
but you don't necessarily change platforming mechanics every day
basically the point i'm trying to make is that there's a lot of things in videogames that can take more effort to have automated tests for than they are worth
as someone said earlier, you can't test "game feel", which is arguably the most important thing for most games
and balancing of values, like damage formulas or buff durations or things like that
you still need to manually play through the game and tweak those, now if you had unit tests relating to any of that you have twice the effort maintaining all of those tests
Also the whole TDD business was invented by/for projects where qualitative concerns are largely irrelevant (enterprise, PLM, PLC stuff and really any line of business applications)
and a bunch of other things that turned out nice in theory but useless in most practical situations
No sane person was ever quoted as a prophet
StreamingAssets will ship files without compressing / importing them / putting them into the asset database. i'm not sure if on mobile devices the practice is to copy from streaming assets into persistentDataPath
i don't think it is
last time i had a truly weird data structure - the in-memory representation of a trie for a word game - i think i put it in resources and loaded it as bytes
it wasn't read only, but i read the appended parts of the trie out of... probably persistentDataPath
And many of us have tried all the things you suggest but tempered their excitement with experience
no i think this is the situation you can gracefully fail in
because i don't think it's lethal to your game if that's the situation the user is in
if 100% of the time it reports less than 50MB available - like as a side effect of the user or platform denying permissions, or a flaw in unity - that becomes a programming error that, unfortunately, you can only discover by on device playtesting
i don't know if e.g. ios simulator replicates those situations
i think it does for networking stuff, which is the most painful
i don't think you will have to worry too much though. Application.persistentDataPath should work most of the time
so basically what ou should do @stuck onyx is have an alternative way of generating an image that doesn't require the filesystem, which is easy - just store it in memory. and if it poops out there, show a smaller image ๐
When I build in Linux for Linux and run the build, it immediately returns with a segmentation fault. When I build in Windows for Linux and copy the build to Linux, everything works fine.
I'm running with the same static build function ~/Unity/Editor/Unity -quit -batchmode -nographics -logFile stdout.log -projectPath Game -executeMethod Game.Builder.BuildHostLinux
Any idea what can be causing this discrepancy?
the standalone player segfaults?
Yes
(1) try deleting the Library/ folder and building to a clean directory
(2) if that doesn't work, try copying the Resources files (or whatever it's called) from the windows built player into the linux player, specifically data.unity3d or whatever it's called
(2) is saying copy the non-code assets
also, are you trying to do il2cpp?
also, does the standalone player work when you build from the Editor UI on linux?
or are you comparing a windows editor UI built player to a CLI build player?
@mossy token so many questions.
did you consider using unity cloud build?
(1) I tried that. Cleaned entire repo with git clean -fdX (annoying, because the build then takes 2 hrs to complete)
(2) Okay tried copying the game_data folder from the good version (i.e. the one built by Windows) to the not working and that makes it work.
(3) here's the binpaste for the builder. It shoudl be using IL2CPP, but whenever I run the build it changes the PlayerSettings Standalone: 0 to Standalone: 1 which I understand to be Mono.
(4) I don't have UI Editor in Linux. I only installed the Editor binary
(5) The Windows built one is also built with the same command (So not built using the Unity Editor UI application).
(6) I'm going a bit lean at the moment so I'm avoiding paid services like cloud build.
(7) In case it matters, I'm running in GCP and would like to be able to build there too.
first, it's a waste of time to try to build any complex unity game* on linux
so if you can emotionally accept that, you will thrive
i know that it seems possible in theory
hi I have an issue, I am trying to move videoclip.frame by 1 frame forward, but it only works if I enable Skip on drop in videoplayer inspector and even if skip on drop is enabled, it works maybe 5 times or less, after that it dont work again... any suggestions ?
you're not going to succeed in getting this to work on GCP
I spent about a week getting the build process to work and I got really far! I'd be okay to resign this attempt...
What?
XD
because, for starters, it will never build correctly on linux
something complex will never build correctly on linux. scriptable render pipeline games can only essentially be built on windows
So, in the same unity project I have two separate biulds. One for the host and one for the lobby - yes it's a multiplayer ๐ฆ - and the lobby build works fine.
you can try to use windows builders, but this is a waste of time. you will be way out of your league in terms of administering that yourself
you aren't saving any money
you are in fact lighting it on fire
huge, huge amounts of it
I'll take your word for it then ๐
It shoudl be using IL2CPP, but whenever I run the build it changes the PlayerSettings Standalone: 0 to Standalone: 1 which I understand to be Mono.
this is indicating to me that you are still on a very early part of this journey
so here's my suggestion
- use unity cloud build. instantly, immediately cease wasting your time on this
- the $10/mo or whatever absolute bullshit it costs is worth it
are you making a mobile game?
VR
Quest?
Yes, quest 2
okay
Things are coming along quite well TBH
Even mumble server is working :]
Cloud
that's good ๐
$10/mth is totally fine
yes i think if your game is good
like if you're happy
please don't waste your time on the build stuff
that said, i don't think anything can do automated builds of Quest 2 games
wdym?
I've been able to make builds that run on the quest2 correctly (not just streaming from windows Unity editor). Why wouldn't that be automatable?
like is the idea to automate an... apk you sideload?
or automate publishing to the Quest store?
or whatever they call it now
if it's for testing purposes, you mean a sideloaded apk?
adb bridge to upload it (or directly from Unity's Build)
alright i'll look into it
you can't really seek any random video you pull off the internet
what is your objective?
(2) Okay tried copying the game_data folder from the good version (i.e. the one built by Windows) to the not working and that makes it work.
also, i observe when doing il2cpp builds, for some reason, even on windows cli, i get corrupted game data
this is to say that literally no one at unity does this
they don't have any complex games to test
hearthstone is probably stuck on... unity 2018 or whatever
or older
still
and it's only il2cpp on windows
it's mono on everything else
I can seek video by 5 frames forward or backward no problem, just moving frame by 1 is problematic and I cant figure why... I have my own videos, locally
you can't really seek most typical videos 1 frame
not with the way unity implements video players
you can try compressing the video with no B frames first and see if that improves things
and then try compressing it with neither I nor B frames
or you can ignore what i'm saying because it "sounds complicated" so it "couldn't possibly be right"
no I am already googling it ๐
okay phew
it's hard
you can use ffmpeg -i your_video.mp4 -profile:v baseline baseline_your_video.mp4 to try with no B frames
then you can try ffmpeg -i your_video.mp4 -c:v mjpeg -q:v 3 your_video_all_keyframes.mov
i don't know if unity can read quicktime container on all platforms
brew install ffmpeg if you're on a mac
thank you soo much I will look at it
I'm using Parrelsync with a multiplayer game I'm building with Mirror, and I noticed a bug where, if I move some players to another scene additively, other observing clients have gameobjects activated when that isn't supposed to happen. My question is, is there a way to find out what line of code is being called at a given time/frame? I have tons of code and debug.log isn't an optimal solution at this point.
Physics scripting question... In a script I'm loading a spaceship mesh+materials and adding rigidbody and mesh collider components. I'm moving using rigidbody.AddForce() and rigidbody.AddTorque(). Without the collider, the ship moves as expected, mass, rotation and acceleration, drag, all seems to work right. As soon as I add the collider, AddTorque stops working at all, but AddForce continues to work as expected. Is this something obvious I'm missing?
var rigidBody = gameObject.AddComponent<Rigidbody>();
rigidBody.mass = ship.Mass;
rigidBody.angularDrag = 0.25f;
rigidBody.drag = 0.015f;
var collider = gameObject.AddComponent<MeshCollider>();
collider.convex = true;
Rigidbodies calculate their moment of inertia / inertia tensor from the shape of their colliders
you can always override it if you want: https://docs.unity3d.com/ScriptReference/Rigidbody-inertiaTensor.html
Follow up on this: Restarted unity and suddenly things worked again. Love it! Not frustrated at all ๐
there must be some way you can ask it to recalculate its moment of inertia
i think the physics baking settings might have osmething to do with this but i doubt it
is it a convex mesh collider?
I have a guess: Is your mesh collider convex?
๐ง
lol
from the code it seems like it is, and you're calling AddTorque after you set the collider to convex... Hmmm
Ahh, that's exactly what I had missed. Thanks a ton!
oh yeah id idn't even look at the code
Interesting solution! Will keep that in mind, thanks for sharing @sly grove
are you saying, like, in general? Because for non-moving objects, concave colliders provide much precise collision when it comes to like, grounds and stuff.
I was only able to achieve a more realistic walking situation when i used concave colliders for my floating island object.
Otherwise a single vertex that was above the average ground level would create an invisible slope that looks like the character is floating
FWIW, trying to add the MeshCollider without setting it as convex gives an error in the console... Non-convex MeshCollider with non-kinematic Rigidbody is no longer supported since Unity 5. Setting that InertiaTensor to non-zero fixed my issue, now I just need to find some sane values there.
one thing you could do is record the inertia Tensor from before adding the collider and just reuse that
if you liked how it was behaving without the collider
this made it to work properly, man u are a true genius
@undone coral I'm setting up Cloud Build as you recommended, but I don't see headless (i.e. server) for Linux as an option. And when I choose Linux desktop it doesn't let me build from Windows (says it must be OSX).
hmm i didn't realize you were trying to build headless
headless isn't a thing really
you don't need or want headless
start your game with -batchmode -nographics and do a regular build
i think it will work from osx, but are you sure that's not because it's il2cpp?
try setting it up as mono
i mean i understand the appeal of headless, to save so and so disk space
What do you mean headless isn't a thing? What does the "Server" option do in Unity Editor? Also, I can build just fine in Windows for Linux target. Why is this not a thing in Cloud Build? Also, why can't I just run my own custom build script in cloud?
osx is 5x more $$$ as Windows. Understandably why, but seems a bit weird that I can't do somethign as simple as a build that I can do on my windows machien
i think you can try to make your build work, which isn't going to happen for a year
i don't know anything about the pricing really
What does the "Server" option do in Unity Editor
i'm not 100% sure - it builds the player with graphics assets turned off or zeroed. i'm not 100% sure how that would work robustly, because, for example, a mesh can be used as a collision mesh, which isn't graphical and definitely essential for many purposes you'll be using a running unity server process for
i guess you can message them and they'll tell you
This makes me want to go back to pushing forward in GCP
i guess go ahead and do that
i think you will succeed for a build, on a particular commit
eventually
i don't think working on CI/CD if it's not your core product is healthy
you wind up procrastinating with it and generating negative ROI
your colleagues will know this too and it will look bad on you
i mean maybe there are zero colleagues
it's just tough
you're asking for something - automated unity builds on linux - which doesn't exist for complex projects
it just doesn't
it will never build correctly on linux, and that's that
it will not give you any insights into why it is producing a corrupted data.unity3d file
which, you have to credit me, i knew right away was the issue, because i've done this before
so yes, ia gree, that advice is valuable
it's "5x more than the price of windows" or whatever
i mean you can look at game-ci, and they will claim it works, and i've tried game-ci, and i know its limitations
complex projects don't compile with their linux images
nobody does il2cpp
it's just tough
i mean, it's just a bunch of people doing this stuff for free, game-ci... i'm not giving them a hard time
I totally feel you on this whole thing.
Yes, dev ops and setting up ci isn't my thing but I've been powering through for a bit now and it really feels like the light is right there. at worst this will be a good first hand learning experience for me. Also worst case scenario, I'll lose some time and fall back on building on my windows machine and automate a bit of the file transfer and shuffling.
that feels very tractable
and - holy ๐ฉ are the logs and error messages weak.
like i said you will simply not be able to build it
there is nothing you can learn
from trying to get this to work on GCP
on your own windows machine
i am saying that a CLI build on windows might also produce corrupted output
the thing that Unity Cloud Build does differently than you is that they operate their builders - if necessary - with the Editor UI
they don't start the editor in batchmode, necessarily
in a remote desktop session
so it goes
Oh interesting. Seems a bit annoying that the CLI can't do the same thing as the Editor UI
Oh well ๐คท
the unity editor is just flawed. opening the editor, and packages that expect the editor to be opened, make a lot of side effects CLI builds do not.
and like who the fuck is going to file those bugs
;
100%
I feel like you had an opportunity to vent there quite a bit. Are you actively working on a project too?
lol i don't have to
not healthy for me
we have CI/CD as a central part of our unity streaming product so i've learned a lot about it
i have had similar conversations* and it is still hard for people to do
Thanks, good to know!
Is there any point in setting PlayerSettings if I'm using BuildPipeline.BuildPlayer(buildPlayerOptions); like this? https://paste-bin.xyz/71794
the player settings are indeed used in the build
is that what you are asking?
there is some jeopardy you are causing by setting extra scripting defines the way you are
you should not use scripting defines
or, you should have them set before you start the editor
do you see why?
unity can't unload the assembly with BuildHostLinux in order to recompile the player
with your new scripting define
so transitively it doesn't unload all sorts of stuff
i guess i'll hear from you two weeks from now lol
you can try github actions and a windows runner
with them
I don't get something:: When running BuildPipeline.BuildPlayer, you pass it BuildPlayerOptions. Part of BuildPlayerOptions is BuildOptions. In the metadata there's an option for BuildOptions.None and BuildOptions.IL2CPP (which are both 0). How come you can set IL2CPP here and also in PlayerSettings? Wouldn't the BuildPlayer override the PlayerSettings?
Apparently so. Imagine if you wanted to iterate on different backend types quickly from your custom build tool.๐คทโโ๏ธ
And IL2CPP seems to be the default one I guess.
Actually I can't find that option in the docs๐ค
Yeah, I think the doc generator doesn't pick up because it overlaps with other flags:
https://imgur.com/a/f6j5jPP
Does it actually affect the scripting backend though? It could be some deprecated enum value not used anywhere.๐ค
Yeah I haven't tested the behaviour. There's no mention of Mono so I don't even know what it means
doing some dll stuff, and im trying to recreate ```c++
typedef unsigned int NvFlowUint;
I still don't understand why I shouldn't use defines with BuildPlayer:
- The context in which
BuildPlayerruns has theUNITY_EDITOR#defined (it has to in order to be built in CLI), but in the build process that define is not set. So it clearly it does use the right compile directives. - It's literally an option given to us to use. Or is it intended to be used differently?
Separate question:
Usually when I close Unity Editor the list preloadedAssets in ProjectSettings.asset keeps growing typically with - {fileID: 0} even though no changes were made in the editor. I now have around ~50 such lines there and it keeps polluting my commits.
from doing some research, it appears this can be achieved with "using" although i am still uncertain whether the dll will accept this as being the same
There's no good equivalent to typedef in C#. My solution is to just create a struct. Most of the time there's an appropriate way to make it work. Maybe if you share the context for what you're trying to typedef we can find something?
oh ok, so basically im trying to get an nvidia flow dll to work in unity, unfortunately it has a bunch of custom type defs for things like NvFlowUint, and basically i need to pass those to functions to make them do stuff, so i need to remake it exactly the same in c# in order for the dll to not complain
Can I ask about help on #๐ฅฝโvirtual-reality? || I'm now out of hope and ideas ||
Don't ask to ask.
I wrote question on #๐ฅฝโvirtual-reality and I asked if someone want to go there and see if will see the error
Good morning community!
Have a question about Enums and database storing (using MongoDB)
- MongoDB dosent take Enum, and such I will have to serialize them into strings for storing it in the DB.
- When I retrieve the data, what happens to the data that are supposed to be an Enum?
Example:
Enum Colors {Red, Blue, Green}
Class Painting
string name;
Colors colors;
Serialized into the database, the enum will turn into "Red" instead of being Colors.Red
What happens when I load the data back in.
Will the Colors field be a string where it should be an Enum value, will the deserializer just skip it.. or something else?
it won't magically convert the colors for you ๐ง ... enum is just... enum ๐ ...
One can always do a dirty hack to serialize anything via json serializer, for this specific case you must use StringEnumConverter
public class SomeCustomClass
{
[JsonConverter(typeof(StringEnumConverter))]
//Your custom converter of your MongoDb or whatever here!///
public Something someThang { get; set; }
}
This can be done to any DBs... quite a handy trick
here for StringEnumConverter of Newtonsoft json https://www.newtonsoft.com/json/help/html/T_Newtonsoft_Json_Converters_StringEnumConverter.htm
๐ No of course not. Was hoping that there was some functionality into the mapping that would reckognize when something was stored as string, and would convert it back aswell.. but alas.
I think my real question here are, what will be in the class field after I load the data.
Will the Paintin.colors field be
-null?
-"red" (as string)
- something other funny stuff?
can a class field marked as an Enum field contain any other thing than an enum?
you're making your game with fancy tech, but your questions are somewhat basic ๐ตโ๐ซ .. I'm confused ๐คฃ
happens when you learn by doing from scractch xD
ive converted local storage in json with database storage, and the classes containing enums dosent seem to properly work anymore. So I take it after I load the data from the database into a class, the code dosent reckognize the enum when checking for it
That depends on the implementation, we can't really know
perhaps im thinking of this the wrong way. Currently Im "filling" classes with data loaded from the database, so all the data are stored locally. But perhaps it would be better to just refactor the code to query the db directly istead of the local class?
Hi guys, i want to create a game (just for a hobby). I want to make an RPG, and i found a cool asset, RPG Builder, but that cost way too much, because i don't know i'll finish a game ever, and as i said, its just a hobby. RPG Builder have a tons of features, like talen system, npc editor with interface, pets, shapeshifting, dialogues, crafting, gathering system etc. Is there any good alternative, which cost less, or free?
That's not a coding issue so stop posting it to coding channels
Yeah, YouTube tutorials, time and effort. Learn enough and you can build your game yourself.
Of course, if you value your time, paying for the assets will be cheaper, but if you want it free you'll have to put in the work yourself.
Hello everyone,
There is a question that I want to ask about building project with HDRP on CI server:
Do server/pc must have a graphics card to build projects that are using HDRP?
Resources:
- NAS Synology DS1821+: AMD Ryzen V1500B (with virtualisation support), 20GB of RAM
- Docker with next images: "
gitlab-runner" - Gitlab CI configuration is using GameCI docker images: "
unityci/editor:2022.1.0f1-base-1"
As soon as I try to build my project, build is failed with next messages:
- If automatic resolution of graphic API is set:
BuildFailedException: Platform StandaloneLinux64 with graphics API Null is not supported with HDRP. - If graphic API is set to manual mode:
BuildFailedException: Platform StandaloneLinux64 with graphics API OpenGLCore is not supported with HDRP.
https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@15.0/manual/System-Requirements.html looks like only Vulkan is supported on Linux
Opengl no good
I don't think the build server needs a GPU, you just picked an incompatible graphics API
Also:
HDRP doesn't support OpenGL or OpenGL ES devices. On Linux, Vulkan might not be installed by default. In that case you need to install it manually to run HDRP.
Regardless they chose opengl as the graphics API in the build
Which is not supported for hdrp
They need to choose Vulkan
same here bro
Thanks for the link, looks like I need some sort of GPU on server with docker or downgrade from HDRP to URP, or maybe try to install docker inside VM so docker could use vmvga adapter.
Too bad, I'd rather buy more virtual servers without GPU (for increasing amount of parallel builds) than one with a graphics card to build my pet gamedev projects.
I've tried changing orders of vulkan and opengl API in settings, but got same error about opengl driver is not supported, looks like if GPU doesn't support Vulkan then it fallback to OpenGL
Do server/pc must have a graphics card to build projects that are using HDRP?
no
unityci/editor:2022.1.0f1-base-1
use the windows runner on github if you want to do CI with game-ci, it's the only practical way to achieve this with containers. but you should really use unity cloud build
I have a List called allDefaultFlags containing strings with file paths.
is it not possible to do something like this?
as I want to compare only the file names
don't use find
NAS Synology DS1821+: AMD Ryzen V1500B (with virtualisation support), 20GB of RAM
most HDRP projects need 16-24GB of RAM to build
What else?
use Any if you want just a bool of whether such a thing exists
wtf is any omg.
Find actually returns the thing
didnt know that
Any tells you if it exists
ah I actually need the item in the list to return
so any wouldnt work then
Ok, I definitely need to switch to URP
so use find but then you can't directly use the item in an if statement. You'd have to do some comparison on it
hmm what i meant was you need 16-24GB of RAM to build a typical game, at least, in Unity
e.g.
var flag = allDefaultFlags.Find(...);
if (flag != null) {
}```
like a typical title in the Switch store built with Unity is... probably closer to 30-50GB of RAM to build
probably more
List.Exists
if you build windows with PGO (i.e. MASTER build) you will need (1) windows anyway and (2) like 60-100GB of RAM
it's not tractable to build on the Synology. they're too slow
I somehow need to use Path.GetFileName() as I only want to compare the actual fileNames
how would I use Path.GetFileName in Find( . . . )
WHo said you can't use Path.GetFileName ?
How tho syntax wise? I keep getting errors when trying to make it work with Find()
what error
Docker with next images: "gitlab-runner
i think don't try to do this with docker, it's too hard.
show what you tried and the actual error
you can try installing this stuff onto the synology if you have ssh access, and try building the project once
gitlab itself takes so much RAM, it will not wind up working
MongoDB
don't overthink this. you will have like 1-3 types of documents. don't model it. read and write BSON directly. it's a prototype. you can't interact with Mongo directly int he long term anyway
i think you should look at nvidia reflex to see how they made a unity plugin for their libraries
Ive just realized that this bezier curve calculator I made a long while ago has a bug
It works by taking 2 points, p0 & p3, and making a bezier curve between them
To do this it needs to find the points p1 and p2
The problem is that the further away from the origin the points are, the more exaggerated points p1 and p2 are, aka they get further away from the main points
By only going about 10-20 units right the curves are already going off screen
Does anyone know why this might be happening?
float elapsed = 0;
Vector2 p0 = transform.position;
Vector2 p3 = Player.Instance.transform.position;
while (elapsed < _collectTime)
{
// Possibly the problem?
Vector2 p2 = (2f * p3 / 3f) - (2f * p0 / 9f);
Vector2 p1 = (p0 / 0.75f) - (p2 / 3f);
float curved = A_Extensions.CosCurve(elapsed / _collectTime);
transform.position = A_Extensions.BezierCube(p0, p1, p2, p3, curved);
elapsed += Time.deltaTime;
yield return null;
}
public static Vector2 BezierCube(Vector2 p0, Vector2 p1, Vector2 p2, Vector2 p3, float t)
{
float r = 1f - t;
float f0 = r * r * r;
float f1 = r * r * t * 3;
float f2 = r * t * t * 3;
float f3 = t * t * t;
return new Vector2(
f0 * p0.x + f1 * p1.x + f2 * p2.x + f3 * p3.x,
f0 * p0.y + f1 * p1.y + f2 * p2.y + f3 * p3.y
);
}```
Unfortunately I dont remember how any of this math works, I copied it a long time ago
But what are the things that cause points to become exaggerated when they are further from the origin?
Through testing Ive realised that p2 ALWAYS point left towards the origin
And p1 always seems to point away from p3
Heres a diagram of whats happening
In the top right you can see what I want it to look like
Forget the code I already have, just look at the diagram
I have point 0 and point 3
How do I get point 1 and point 2 (with a distance variable to choose how far away they are)
Like the box
Im just gonna start thinking out loud
So if I get the slope of |03| and invert it to get the slope of |01|
Then I know theres a formula to go X distance on a line from a point on that line
Then I can do the same thing on the right side to get point 2
Am I overcomplicating it?
|
How do I get the inverse slope in code?
are you sure inverse slope is what you want
I'd think you'd want a vector at 90 degrees from the first
Yeah either works I guess, Ill try AngleAxis
probably want this:
Vector3 p0 = ...
Vector3 p3 = ...
Vector3 dir = p3 - p0;
Vector3 rotated = Quaternion.Euler(0, 0, -90) * dir;
Vector3 p1 = p0 + rotated;
Vector3 p2 = p3 + rotated;```
Oh I didnt realise you could do that with Euler, Ive been using AngleAxis way too much then
Alright nice I finally got it, cant believe Ive been using this scuffed version this whole time and didnt even realise
I'm using nReal glasses with remote profiling and I'm getting CPU/GPU spikes.Is an Android app. I'm using URP.
Any help? I dont know much suff about profiling. The UI from the apk is lagging after every second
there isn't much information here. it looks like you are incorrectly using an async method recursively, and incorrectly using the out of the box async instead of unitask. doesn't seem to have anything to do with nreal
I've found it. But I dont use the scrip in my scene.
I also looked at the UI but I don't see any information there. Although I have a UI menu
Hey, I'm looking into Physics Raycaster 2D and cannot figure out the order at which the colliders are detected, is there an order?
At first I assume Z position, but that doesn't seem to always work
probably not
Okay, that kinda makes the whole system basically useless...
I apologize if this isn't the right place. But we are having some terrible difficulty figuring out what is causing this Prefab missing error when upgrading from 2018 -> 2019/2020/2021 (all same error).
Basically the metadata files after the upgrade seem to replace fileIDToRecycleName with internalIDToNameTable and in our case its empty, and im pretty sure thats what's causing our issue. The GUID's between both old and new meta data's are the same.
I can't find any docs really on either of these fields, does anyone have any idea where I can start looking?
hello i'm making a motor game i don't know how to calculate the torque and rpm of the motor can you help me
motor.rpm = 9001;
motor.torque = 700;
How can i detect area of collission? Like how much is the size of the collider is at current collission
Letter tracing
who authored an async Update method?
Sup guise
so I wrote a c++ utility to combine .exr files that uses OpenEXR
I only use it in the editor, it's completely not required for the game to run, but because I have the DLLs in the assets folder, it's packaging it into the build
Is there a way to tell Unity to explicitly not include them? I'm not referencing them anywhere outside of the editor assemblies. I know I could just put the program and OpenEXR outside the project's architecture but it's just more convenient to keep things consistent when the project is cloned from git by someone else
yeah it's documented here: https://docs.unity3d.com/Manual/PluginInspector.html
but basically - just put it in an Editor folder
you can also just click on the plugin and set it to editor only from there
thanks man
Is there a runtime version of https://docs.unity3d.com/ScriptReference/AnimationUtility.GetAnimationEvents.html ?
I need to do this, but at runtime. Or is there an easy way to cache these from the editor, for use at runtime?
Yeah that should work, thanks
Usually when I close Unity Editor the list preloadedAssets in ProjectSettings.asset keeps growing typically with this line being added - {fileID: 0} even though no changes were made in the editor. I now have around ~50 such lines there and it keeps polluting my commits. What can I do about this?
That's not normal. Presumably a script somewhere in your project is doing it.
Otherwise, search for known bugs on your Unity version
ooh fascinating, thanks!
What?
After switching to URP instead of HDRP, builds are succeeding.
I've tried to use Windows VM with Jenkins, but OS got completely stuck on shader compilation, not sure why, maybe because previously my NAS was short on RAM.
Thanks to everyone who helped me. ๐
you added Chunk as a component to a GO, but then turned it into a regular class. Now Unity's complaining about it
turn it back into a MonoBehaviour and delete its constructor, or remove it from (I assume) Cube which probably calls it a missing script
lol
how do I rotate a matrix?
I have the view matrix used for direction light shadows
I would like to rotate it
Rotate across what axis
If itโs a unity matrix you can use one of the static helper methods under Matrix4x4
https://docs.unity3d.com/ScriptReference/Matrix4x4.Rotate.html
Here is one of them
This may be more of a C#-focused question but, is there a way to intercept a user key press to stop other apps from consuming it? Like let's say a program that intercepts an W press and "cancels" it so that the FPS game running right next to it can't see the W key has been pressed
That sounds sketchy af
The platform the game it's on, wont allow that...
Windows or mac especially, or it will break their tos
you would need elevated permissions from the operating system for that kind of thing
Let's assume I have them, is there any library that could help me do that?
I could use some advice on some design decisions. I am currently making a turn-based tactic. Let's say it's the player's turn and they can attack. There are some red tiles to indicate the tiles that are within the player's attack range, but they can only move to the attack state if they click on a tile that has a live enemy on it. In the "OnSubmit" method of my state, there is an if statement to check if the tile meets the predicate, which in this case would be if the tile has a live enemy on it. However, doing this would mean that I expose implementation details of the tile. And I probably have to do some casting because the if statement has given certain guarantees of what's on the tile. I have considered using dynamic dispatch, but then the changing of the state would then be inside the tile, and outside of the state manager. Is there a way to not expose implementation details and use casting and still keep the changing of state inside the turn manager?
Maybe a callback?
Something like this? https://docs.microsoft.com/en-us/archive/blogs/toub/low-level-keyboard-hook-in-c
Currently, tile stuff isn't being done in the player code. Well, in my case, a tile has an ITilePiece, and an ITilePiece could be one of unit, environmental object or an item (and more to come as the game expands). Thus, when I do the query to check if the tile has a live enemy, in the if statement, I am guaranteed that the tile piece is indeed a unit, and I can call unit methods. Thus, I need to cast the tile piece into a unit. So it seems like to me the query comes hand in hand with the casting code smell.
Finally done with the damn terrain edge detection algorithm. It's slow, but otherwise perfect!
nice
So like, a getter?
That's basically what I have right now, except that it's a method that returns an enemy specifically instead of an ITilePiece which I have to cast into an enemy. Isn't this method simply casting in disguise? And also, wouldn't the getter expose implementation details of the interface?
you're on the start of a very long journey
No, the ground tile has a tile piece.
A journey that will never end
no
have you looked at an asset for tactical turn based RPGs?
like how much research have you done
into implementing this game
The reason for casting the tile piece into an enemy is because, say, for example, I want to choose a tile to attack. I can only do so if the tile contains a live enemy. So, if the condition for the if statement is true, that means that the tile piece is guaranteed to be an enemy, and I can treat it as such.
Making an API of the tile piece that contain everything I would want to do to an enemy would simply be empty code for all classes that implements the ITilePiece interface except for the enemy.... which I am not going to lie, is basically what I have right now. I was hoping for a more elegant solution.
This is a school project which I joined midway. Too much stuff has been done for it. Dropping everything and using an asset would throw away a year of development. Besides, there are a few programmers aside from myself, I think we could pull it off.
We have a working a game right now, I am just trying to make things more elegant and scalable.
We have a working a game right now
that's good
is what you are doing improving gameplay?
Not directly. We could get away with casting. Though, I would imagine that the more features we add, the slower development will be.
Basically, I have a grid of points that define the terrain type at that position. Each point can blend several types of terrain.
The idea is that some terrain transitions (for example from a rocky mountain to grassy plains) would have specific "transition" texture. It's gonna be a spline mesh going along the "terrain transition edges". Therefore I needed some algorithm to find these "edges". Tried many things but every time there was some kind of obstacle. In the end, there were 2 key elements to the correct solution: finding these "edge" points correctly and sorting and ordering into "paths".
Finding the edges was not that difficult. I simply iterate all the points and their neighbors and check if there's a change in the "main terrain type". If there is, we've got an edge.
The problem was coming next: the result of the first step is edge points in arbitrary order, making a mishmash instead of correct paths. The solution to that was introducing additional data: a normal of the edge - basically in what direction it's facing and it's tangent(I think that's the correct term) - direction orthogonal to the normal. With this new data, I could iterate the edge nodes and link them in the right order(setting previous and next nodes), as well as merge some "irregular" and overlapping nodes on the way. Then it's just a bit of logic of sorting them into separate lists and done.
hmm
well only you've seen the code, you know best
one of unit, environmental object or an item
@calm ocean this was the hint that you know what you want
but an interface isn't it
there's a thing called a "one of"
"one of" comes up a lot
you don't want interfaces
it's tricky
you can't rewrite what you have
interfaces are for when you don't know the types
that you can't possibly know ahead of time
From my minute of research into one of, it looks like an enum
in your own game codebase, you know what all the types are going to be ahead of time
that makes sense
Well, a slightly more powerful enum
it depends what your goals are @calm ocean
if you went to your prof and said "i removed all the interfaces because interfaces are for when you can't possibly know the types ahead of time, which isn't the case in my own codebase"
well i don't know what grade you'd get
lmao ok
but that would be one of the best ways to grow as an engineer
if you do a lot of if (tile is Unit unit) you can overload a method
Just skimmed the above conversation @calm ocean - I don't think you want an enum or an interface for this. I think you want "objects" (like monster, player, item) that can reside on a tile. Let the tiles hold stuff like location, type (ground/water/mountain/etc) and then hold references to whatever is on that tile.
If your player is trying to interact with some aspect of the tile, you query all the tiles in range for items that are of the relevant type.
yeah, this is a good and simple approach
(I mean, you might want interfaces but I don't feel like this is .. the correct time for it)
because Unity components are already the idea that interfaces seem helpful for
(this is also just opinion, if it works for you, it works)
I more think of interfaces as... generic functionality you want to staple to an object, not as the core design of an object
As I stare at my monitor I can actually think of several counter examples to that but... you know, it works for broad generalizations. ๐
in your case ITilePiece isn't an interface, it's an abstract parent class
If your player is trying to interact with some aspect of the tile, you query all the tiles in range for items that are of the relevant type.
So if I click on a tile that I want to attack, I search for all the tiles in range that can be attacked?
I always go back to IPointerDownHandler - it's an interface that handles a pointer down, but it doesn't make any logical sense to say that an object is a pointer down handler
If it makes sense to attack a tile without an enemy on it, yes
lemme dash up some pseudocode, standby:
public class Tile
{
public GridPoint Position; // GridPoint { int x; int y }
public NPC Enemy = null;
public float DistanceFrom(GridPoint pos) ..
}
...
List<NPC> targets = AllTiles // in a list of all the tiles in the game ...
.Where( // ... get tiles where ...
x => x.DistanceFrom(myPosition) < 5 // .. the distance to "myPosition" is less than 5 ...
&& x.Enemy != null) // ... and the tile contains an enemy ..
.Select(x => x.Enemy); // ... then select only the enemies onto a new list
that might not work syntaxwise - i always forget when you have to ToList() linq results, but you should get the idea
I could see how that could be useful for like AOE damage, but if I am trying to click on a tile and damage that particular enemy, would I just get the enemy from tile.Enemy?
yup
Also, this restrains things on a tile to just NPCs. What happens if I want items and environmental objects?
then you do the same thing for those objects - tiles would contain members for environmental objects or items
bonus - now your tiles can simultanously contain an environmental object and an enemy, which seems to make sense to me
it soundsl ike the way your game is now, if a tile contains an enemy it simply "becomes" an enemy (and "loses" the river/mountain/ground/whatever state of a tile)
i'm thinking of Through The Breach (if you've played that) - there's some things in the game that can change a tile from ground to water, and if there's an enemy on it that can't swim... it dies
the UGUI people couldn't possibly know what types will be handling pointer clicks ahead of time
an interface and an event handler are duals - i'm not sure they were thinking about things like that
but they solve the same problem
into the breach is so good
the right way to have done this, a while ago, a thing you cannot change, was to have a way to create a list of all the valid things a user can do
and your UI elements - like clicking on tiles - queries that
I do have something like that
Each action has a predicate to determine its valditity
A possible predicate is a list of predicates, and its test is just to andmap/TrueForAll across the list of predicates
so you have a method that looks like
public GameAction[] GetAllAvailableActions(...)
Not like that.
[CreateAssetMenu]
public class AndMapTilePredicate : ATilePredicate
{
[SerializeField] private List<ATilePredicate> _tilePredicates;
public override bool TestTile(TileSpace tile)
{
return _tilePredicates.TrueForAll(pred => pred.TestTile(tile));
}
}
Where ATilePredicate is a scriptable object.
And in the on submit of the choose tile to attack state
public override IEnumerator OnSubmit()
{
TurnController.clickedSubmit = false;
if (!_tilePredicate.TestTile(selectedTile)) yield break;
// DO ATTACK STUFF
TurnController.SetState(new MiscSelection(TurnController));
}
So you would drag and drop conditions into the tile predicate. Then drag and drop the tile predicate into the state
But it is without its flaws. I now understand that doing a predicate on an an interface ruins the point of the interface, so I have to consider what you all said and amend the design.
nice
This is a step on the journey of making these kinds of games
The โCreating a LISPโ stage
Like why not write the piece of code that does โANDโ
Maybe make the method I described
Anyway your goal is to learn right? Itโs okay to rewrite a ton of stuff
When youโre learning
Hi! I'm looking for an operation that gives me the amplitude of Vector X in direction Y. For example, if I want to know the Amplitude of Vector (0,1,1) in direction (0,1,0) it would be 1. If I want to know the Amplitude of Vector (0,1,1) in direction (0,-1,0) it would be 0 (as the current vector is opposite to the direction). Does this operation have a name?
sounds like signed projection to me
I would expect it to be (0,1,0) in this case instead of (0.5,0.5,0)
Oh wait, seems if I switch the two parameters it might work ๐
i think you want Vector3.Dot(vector, normal.normalized), clamped to 0-1
afaik you don't have to clamp it, if you don't then you get the magnitude of vector in the direction normal.. if that makes sense
let me explain
var vector = new Vector3(10, 5, 0);
var normal = new Vector3(1, 0, 0);
var mag = Vector3.Dot(vector, normal.normalized);
// mag should be 10```
Something to keep in mind though, is that if `vector.x = -10`, you'd get a magnitude back of -10.
Thanks!
yeah @wintry wind wants a dot product without anything special to it, but based on
if I want to know the Amplitude of Vector (0,1,1) in direction (0,-1,0) it would be 0 (as the current vector is opposite to the direction).
he'd need to clamp
Wdym
Like renaming AndMapTilePredicate to TrueForAllTilePredicate?
For the GetAllAvailableActions, for example, if there is an enemy to attack in range, then one of the GameAction would be the attack? '
Does anyone know how to perform the same operation as InverseLerp, but with SmoothStep?
All my searches for an inverse of smoothstep just return functions which move fast at the start and end and slow in the middle, when what I'm trying to do is figure out where along the smoothstep I am given three input values.
The reason I'm trying to do this is because I'd like the player to be able to toggle between an object being smoothstepped and being lerped without having the object snap to a new location as soon as they make the change. 25% of the way along a smoothstep will place it at a different location than 25% of the way along a lerp.
I read that IL2CPP is a unity-developed tool. How come microsoft doesn't have such a tool?
it's a transpiler, and why would Microsoft develop game-engine related transpiler in the first place ๐ง
by the name of it, it converts IL into CPP
if you're going for crossplatform-ness but NOT game-engine out of the box, you can do so with netCore or with the new poster-boy .Net Maui..
At least with Maui, you can make 2d games with no problem as it built on top of SkiaSharp
are you asking this just for fun or profits? ๐
I'm asking because the fact that I don't know the answer means I don't understand something fundamental about it.
I don't know why I can't figure this out, but I am trying to write a wrapper for Unity's Search Window
because I don't like the way they make you define the elements inside them
so with my method, I'm trying to define an entry like this:
searchTreeEntries.Add("Group/Folder Name", new SearchTreeEntry());
and I don't know how to get all the elements that correspond to the same group
basically I wanna convert this:
("Entry1", object2),
("Entry1", object3),```
to this:
```("Entry1", List(object1, object2, object3))```
Idk how many entries you have but you can use linq's GroupBy
well uhh
thousands
however I can try and cache them, since they don't really change
Then you might need another solution but you can try it to see if it's fast enough
Hello
var query = mvAdminList.Where(x=>mvRoleList.Any(y=>x.Id==y.Id)).ToList();```
I want to find the diffences between two lists but it does not retrieve
where am I mssing
Use Dictionary<string, List<SearchTreeEntry>>
Maybe this could help ?
https://dotnettutorials.net/lesson/linq-except-method/
I see you already used linq there,
IEnumerable<T> listAdiff = listA.Except(listB);
just reverse it if you're looking the diffs from listB
via Where-Any or if you're looking for specific things
IEnumerable<T> listAdiff = listA.Where(x=> !listB.Any(y => x== y));
thanks
Hey guys, wondering if anyone has had experience with video capture of the scene by taking frames from the camera, encoding it into a video and saving to camera roll on iOS?
Any pointers appreciated
To update the elements of a list (change field values) in one place as time elapses, do you think which one is more efficient?
One monobehaviour class (Update)
Standard Task (async/await) // --> change sync context is slow
Task.Run + JobQueue
UniTask
The routine is simple (addition/subtraction)
Yeah exactly my issue, it's not at runtime with saving to iOS camera roll unfortunately
would be GREAT if it did that
Thank you for the suggestion regardless! โญ
you can capture it every frame, https://docs.unity3d.com/ScriptReference/ScreenCapture.CaptureScreenshot.html
but there's no way you can do compression with it
look up for ffmpeg for .net on github and pray to god that it will run on unity
especially ios.. like uh
Is there a way to create an event handler for everytime a value on my dictionary is changed?
not the behavior as you mentioned, but i believe is that you wan't to be notified if something is changed in the dictionary
not sure if that exists in the regular framework, tho.. do your research
scratch that.. https://docs.microsoft.com/en-us/dotnet/api/system.collections.objectmodel.observablecollection-1?view=net-6.0
yes. and for example, to move, you would have an action for each possible move.
class WaterUnit : BaseUnit {
override bool CanMoveHere(Context context, Tile destination) {
if (destination.TerrainType != TerrainTypes.WATER) {
return false;
}
return base.CanMoveHere(context, destination);
}
}
// at the start of the turn, the destroyer
// gets to shoot one target
class Destroyer : BaseUnit {
protected Destroyer() : base() {
attack = 3;
hp = 4;
moves = 5;
AddTarget(new TargetEnemy());
AddEffect(new DestroyerEffect());
}
override bool CanMoveHere(Context context, Tile destination) {
if (destination.TerrainType != TerrainTypes.WATER) {
return false;
}
return base.CanMoveHere(context, destination);
}
}
use the official API on iOS:
https://docs.unity3d.com/ScriptReference/Apple.ReplayKit.ReplayKit.html
yes, il2cpp will take your game's .net assemblies, convert them to C++ code via heuristics, and then compile the c++ on your target platform's toolchain to create new assemblies
you can use unitask or a coroutine to achieve this
hello i want to make a motor game and now i am trying to make a gear system but i can't calculate the rpm and torque exactly i can't make the torque decrease as the gear increases can someone help?
everything is here, so why doesn't this work
Thank you for this! Do you know if you can target a specific camera to get around showing UI elements on screen?
why doesn't it allow me to open the Search Window, if every variable is there
no, it can't do that
are you recording the screen for gameplay purposes?
I am wanting to capture AR content from within the app with UI and save the video without the UI to camera roll
Essentially adding a 'Capture and save' functionality to the app
yes but for what purpose?
is it for you in order to create demos?
is it for the end user in order to...
For the end user to capture content
content that is used by you
or...
well i think you should just turn off or crop away the UI
as a user I would like to capture videos and save them to my camera roll so I can use the content for later (socials, after effects etc)
it isn't within your scope to record video
from a unity camera
you can hide, reduce or crop away the UI
it's up to you
i know it sounds simple but it's not
I'm not quite clear what you're saying
It is within the scope of the requested feature to record video
I can hide the UI but what about when the user wants to pause or stop recording functionality, there will need to be UI there to control that
i know what you're asking for
there's no unity asset or plugin that achieves this performantly, sorry
you can use replaykit and record with the UI
I'm exploring two options : a all in one that can capture and save video from unity
OR
A way of creating a video from frames read from the GPU buffer
if you try to engineer this yourself
you will end up making something that takes 5-10x the time of the AR thing you are making
on iOS replaykit is viable
you can make a gesture to hide and show the UI
like tap the screen with three fingers or whatever
are you using input system & event system?
Yeah
okay, then it should be within your scope to achieve that
I get you, but the UX requirements I have are in it's crudest form to 'replicate instagram' in the app
too bad
I'm one dev, 5 days to do this, I am going grey as we speak
๐
I found something like NatCorder
seems to be promising
Just btw I really appreciate your input and guidance but I simply can't record the UI and the interaction needs to be intuitive
it will not be performant
// Commit video frames
Texture2D[] frames = ...;
^already a dead end
you can waste your time trying to find free or even paid things to do this
and then you'll have 3 days left instead of 5
it's your prerogative
you'd need a library that correctly uses hardware encoding & correctly uses a render texture or custom pass buffers only in hardware without copying and in plugin (i.e. render thread, not main thread) code
and even if you manage to achieve this, your game (or wahtever this is) will overheat and lag out in 2.5m instead of 4m like it does now
@round blade so i would tell these people now, or whomever or whatever this is, that it's going to have the UI and tough cookie
i think you should make a gesture to hide the UI
that's the best approach
and use replaykit
and if it doesn't work well with replaykit, which is as optimized as it could possibly be, it won't work well with any plugin, even a correctly written one
Okay, noted, currently there is a functionality to hide the UI, it will just be on the start and end of the video I guess as they hide and show the UI to control the video playback
i guess they'll have that yes
i don't know what the plan is here though... it'll record at the rendering framerate, which will dip to 10 fps after 2-5 minutes
I managed to stream using another camera which hid the UI which was firing frames at a streaming service
so was using
private void RenderPipelineManager_EndCameraRendering(ScriptableRenderContext context, Camera camera)
{
if (camera == renderTextureCamera)
{
if(runAsyncGPURequest)
CopyCameraToTexture(camera);
}
}
yeah, that puts the buffer on a CPU thread
and therefore, will not work performantly
it's also a little wrong
I am running an AsyncGPURequest? That was definitely more performant
what would be the most helpful thing for me to tell you
you can be one of those people who's like
"no this must already exist"
you can look at natcorder, and you can think "oh i just have to get this with async gpu readback"
i spelled out exactly what it has to do to be even close to as optimized as replaykit
i didn't say async gpu readback
so it's your prerogative.
if it doesn't work well with replaykit, it won't work well with anything
it's not really going to
you should not have promised an AR thing recorder on a phone
it overheats too quickly and the framerate will drop very noticeably
and your people will ask you why it does that
Okay, thank you for your feedback
i'm just trying to illustrate that i know a lot more about this than you, and you don't seem convinced
if you so much as sneeze on the wifi during the 5-10m you have now, it's going to go down to 1-2m
you're going to try to upload "using s3"
in "the background"
and your device, a $1,400 iphone, it's going to overheat
it does overheat, and it's why these experiences don't exist for the most part
you're going to "save to Photos"
and it's going to overheat!
or it's going to show this absurdist loading bar... on iOS you have to copy into photos
you can't just move from the application container to the photos container. it's always a copy
"agora SDK" i mean seriously, good luck with that
Yeah that's what I was using before
yeah
I guess I can add a timer to the recording so people have a chance to capture without the UI
so this thing where you record someone's training session in AR
or whatever
i think you have the UI
or instagram?
i mean who are these people lol
i don't want you to be in any more jeopardy
that's a good idea
i would at least test replaykit
like i said it's as optimized as it can be
because truly, you need graphics driver cooperation to do full screen recording efficiently.
it's just how it goes
that's why replaykit works
Okay, sure I will try that, thank you for your guidance on this
okay my dude
don't die out there
if these people give you a hard time about doing something impossible you have to tell them off
Appreciate it ๐
hmm, well you've been trying this since at least last november
I'm working with a video streaming plugin that provides a byte array representing rgba32 colors. I can load it into a texture just fine, but I need to display the video in worldspace and would like to generate mips.
The trouble is, when I ask unity to generate mips the texture is grey.
I've seen some examples of using two textures for this, but that can't be the only way right? I need to make this as performant as possible since in this case texture data is being loaded constantly and there's many video streams
private void OnVideoFrameDataReceived(VideoFrameData videoFrameData)
{
if (_texture == null)
{
_texture = new Texture2D
(
width: videoFrameData.width,
height: videoFrameData.height,
textureFormat: TextureFormat.RGBA32,
mipChain: true
);
videoImage.texture = _texture;
}
else if (_texture.width != videoFrameData.width || _texture.height != videoFrameData.height)
_texture.Reinitialize(videoFrameData.width, videoFrameData.height);
_texture.LoadRawTextureData(videoFrameData.data);
// I also tried this for loading raw data, but no difference!
// var nativeData = _texture.GetRawTextureData<byte>();
// nativeData.CopyFrom(videoFrameData.data);
_texture.Apply(updateMipmaps: true);
}
so i think you know how hard it is to do the hardware recording the way you want
you fell for the agora sdk trap
Gonna be honest, I did before and I share your opinion on how difficult it is
been in agora hell for years now
you felt like, oh well if i can only figure out how to give agora the frames efficiently
and like, agora doesn't give a fuck
We got agora working and it wasn't too performant but we got AR streams working
about you, or your application, or its unity sdk, or how well it works
i think if you want to send headsets and phones out to people and stream their trainign sessions or whatever
ikr. i keep being blown away by how incompetent their company and product is
to a website with an instructor to watch their thing
TOUGH COOKIE
it's not possible with agora
video streaming plugin that provides a byte array representing rgba32 colors
oh no...
this will also not work
how's that?
a desktop computer and a simple enough scene, this can work most of the time
you can't receive the video data on a unity thread. it will be too slow
you can try com.unity.webrtc or keijiro's mediatek ndi plugin
but even then, there are limitations
it is! haha, but agora is in charge of invoking the callback not sure how much control i have over that.
nooo
guys you can't use agora
agora is a fake thing
it just doesn't work, as you can see
there's no ifs and buts about it
i hear ya. out of my hands unfortunately. it is a Businessโข thing
and using com.unity.webrtc correctly requires a degree in webrtcology
which is valuable, and it will eventually work as well as it can
but even com.unity.webrtc is flawed
fwiw i think agora's callbacks are off the main thread now. of course they don't say this anywhere, but I get a threading exception when trying to create the texture from the callback
SupportsTextureFormatNative can only be called from the main thread
and unity crashes of course
If you canโt pass a native texture pointer to agora, you will always touch a CPU thread for a copy
And besides, itโs not like a mobile device has real parallelism
The 1 watt CPU performs as well as the marketing department says it does
luckily we're not currently targeting mobile ๐
agora is going out the window as soon as we can find/make something that fits our weird requirements
even on a PC, there are limits
i think the sooner you tell the truth to these people the better
i don't really know. there are infinite hours to bill
around making impossible video streaming
normal people, like the kind who sell and design these websites, cannot conceptualize that it's impossible
everyone is painfully aware, we're just making a product with weird requirements and
- haven't found another solution that fits our needs
- don't currently have the bandwidth to do our own thing
until that changes, agora is our unfortunate stopgap
tencent recently released a streaming solution that could be promising https://intl.cloud.tencent.com/products/trtc
one thing to consider
there are maybe 10 people on earth who can engineer this stuff
and none of them work at tencent
or agora
is it a training app
does it have to do with instructors and training
there is nothing sensitive
about what the app does
remote collaboration/communication thing
but no instructors?
there's no training?
there's no instructor doing a remote training?
nothing to do with training
okay phew lol
is it a recroom / that thing i saw on the billboard where it's a chatroom and all the little portraits of the product managers were yelling?
and it had a million dollar domain name
its a shared space with rooms/videos like figma but you actually exist in the space
i see
what if it's just better figma lol
better google slides really
what if that's all you did
this is already so hard
yup! figma is pretty good lol ๐
they got some smart people over there. pretty crazy it runs in the browser
personally
i hate figma, passionately, it's like a quintessential negative ROI tool
lolol. i haven't used it enough to hate it yet
fair. from a tech perspective i think its impressive tho
like at least with excel, it's positive ROI
writing emails and google docs memos, okay, maybe net neutral ROI
google slides can be positive ROI
figma? i don't know. as soon as you're "designing a UI" you've already lost
you're already negative ROI
do we need more clones of popular apps? no.
did you need to make a UI to pass off to a contractor? no, you could have just asked them to copy something, without all the song and dance. but if that means that they will "be lazy" well they weren't going to do a good job for the price they said anyway... and besides, the figma user, is still redundant
solving problems with graphic design? that's already a massive white flag
"oh we'll take our crappy thing and, if we figma enough UI on top of it and make it kidsSAFE, it will be good" no dude
you can't solve problems with graphic design
you can entertain people with good demos, so i understand there is some positive ROI stuff you can do, but then learn after effects
and cloning UIs by committee.. that sounds extra negative ROI
now you're just roping in 5 graphics designers who are redundant instead of merely 1
i understand the venture capital community, which also thought Superhuman was useful, doesn't see things this way, and that this is a minority opinion, but those people barely use software and have a very broad sense of ROI that discovers "value" in anything
or another simpler perspective is, usually stuff that is made by teams, a bunch of people are redundant anyway
especially software
Yes but suppose there are many elements (millions)
UniTask is your first suggestion?
I see, that's an interesting approach. So I would be moving the predicate to the responsibility of a unit. Having a base unit would abstract out common code between all the different units. This is something to consider.
Is this an acceptable way of delaying something until after start? I could use events but it would require me to get and subcribe to events of 100+ GameObjects that would only exist for the duration of the start method. This (below) will always work due to the script execution order, but the if statement will be checked constantly, although I'm sure that's trivial.
int count;
void Update()
{
if (count > 0) return;
DoThingAfterStart();
count++;
}
that delays nothing
what exactly is the use case here?
what are these 100s of items?
and what are you waiting to happen before doing your thing
I think I misunderstood, you mean you want to delay something until after all Start()'s have executed?
Like would it be acceptable to wait one frame?
Or does it still need to be first frame, just after all Starts
Randomly generated Tiles. The initial gameobjects are of type RandomTile, which all generate a random tile in their Start method. Once all tiles have been generated, I am getting all tiles currently in the scene and the number of tiles. I am doing this so i can subscribe to a custom OnTileDestroyed event generated by them so i can decrement the count of numOfTiles. When it is 0, next level.
I'm using events because I don't want to calculate the number of tiles each Update.
(is this at the begining of a scene?)
yes, my bad for misexplaining.
Sounds like it could probably wait till next frame, right?
You could just do:
IEnumerator Start() {
yield return null; // wait one frame
DoTheThing();
}```
