#archived-code-advanced

1 messages ยท Page 3 of 1

misty glade
#

at least use a monospaced font

jade citrus
#

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.

flint sage
jade citrus
#

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.

tiny ocean
#

its not stupidly large

#

its totally normal

#

1920*1080*4 (assuming 1 byte per channel) = 8294400โ€ฌ bytes / ca. 8.3 mb

misty glade
#

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

tiny ocean
#

oh yes, vector graphics are wonderfully compact

#

especially because they're basically just text

misty glade
#

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)

undone coral
#

but it doesn't work for me in CD/CI

#

so that's how ti goes

versed crystal
#

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

high kite
#

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)

versed crystal
#

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!

high kite
#

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.

undone coral
#

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

scenic helm
#

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.

runic bridge
#

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?

novel plinth
#

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

runic bridge
#

yeah, I missed the part in that link that shows the new way of requesting server side access

#

Thanks Slim

undone coral
#

like i know the profiler reports so and so amount of garbage

scenic helm
#

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

dapper nest
#

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

austere jewel
dapper nest
#

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

novel plinth
#

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();
silent acorn
#

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 ?

digital gazelle
#

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?

twilit sage
#

i have no idea if this is advanced but it's incrediby cool
queuing and dequing function calls

pale zinc
novel plinth
#

I even more confused, as I didn't see any Reflections used at all, only the namespace.. proly I'm just blind I guess

pale zinc
#

the link they posted used reflection to find and instantiate a type from an assetbundle

#

in the Unity.. 5... docs lol

silent acorn
#

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

hallow cove
#

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

compact ingot
#

you are welcome to delete messages that do not arrive at a question someone can answer

unique ermine
#

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?

fresh salmon
#

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)

unique ermine
#

Oh what something like this works? O.O

fresh salmon
#

Yep, that's called a "closed generic" if you provide a real type in the <>

unique ermine
#

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>;
fresh salmon
#

Pass T directly, you have it

newItems as M_Item<T>
unique ermine
#

the type I pass for the methode is S_C_BasicItem

#

but the interface needs the type C_BasicItem

fresh salmon
#

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>
unique ermine
#

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

fresh salmon
#

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

thick cairn
#

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.

  1. 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.

  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.

  2. 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.

unique ermine
novel plinth
#

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

supple ether
compact ingot
# thick cairn Hello everyone. I was reading some arguments against the singleton pattern and i...

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.

errant plinth
#

How would you implement logging?

compact ingot
errant plinth
#

Isn't that a global access pattern?

#

I guess if you had special logging needs it might be nice to carry some around

compact ingot
#

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

high kite
# errant plinth Isn't that a global access pattern?

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.

compact ingot
#

those can be singletons (if they are unique) or passed around to "everything" like Debug.Log

undone coral
#

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

unique ermine
undone coral
#

this way of modeling things was a mistake

#

you should fix it now. otherwise it will cause you way more grief later

unique ermine
undone coral
unique ermine
#

Why?
I have different scriptableobjects for each item type

undone coral
#

big mistake

unique ermine
#

as each itemtype requires different data

undone coral
#

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

unique ermine
#

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

novel plinth
unique ermine
undone coral
#

it's up to you to take my advice

unique ermine
#

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.

undone coral
#

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

unique ermine
undone coral
#

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

unique ermine
#

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

undone coral
unique ermine
#

maybe we are talking about different things

undone coral
unique ermine
#

cuz u didnt saw my whole code

undone coral
#

i'm glad you spent that much time thinking about it

#

you will have to think about it at least... 100x more

unique ermine
#

?

#

anyways.

undone coral
#

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

serene girder
#

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

unique ermine
# undone coral anyway i don't think you're going to change anything <@321649314382348288> BUT y...

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?

serene girder
#

and then work with virtual methods for loading the scriptable objects?

unique ermine
#

I only have 1 interface

#

To handle my generic Methode

#

this is my base item class

serene girder
#

Maybe instead of an interface you can just implement the method in the base class for your items as a virtual method

compact ingot
unique ermine
#

and my clothing class inherits from it

hollow garden
unique ermine
#

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

compact ingot
#

when i see a type prefixed with S_C_ or something like that i immediately loose all motivation to continue looking at it

serene girder
#

genuinely trying to understand

compact ingot
serene girder
#

Diamond problem, gotta have to read about it

unique ermine
#

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."

compact ingot
#

its the most succinct problem to illustrate whats wrong with type hierarchies

serene girder
#

@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

compact ingot
#

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

serene girder
#

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

compact ingot
#

then why do you have an interface in the first place?

serene girder
#

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?"

unique ermine
#

the purpose for the interface is that I need it in order to make my generic methode work

serene girder
#

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

unique ermine
compact ingot
#

it looks complicated and unnecessary and this channel likes simple things A LOT

unique ermine
#

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

serene girder
#

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

unique ermine
#

I'm only inheriting from one base class

unique ermine
#

it's a flaw in my code I knew but didn't bother removing yet.

#

So thanks a lot for this feedback.

serene girder
#

Yeah no problem, I have also learned something new today, never thought about the diamond problem

unique ermine
undone coral
#

that approach will support the most gameplay with the least amount of fuss

compact ingot
#

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

flint sage
#

Even if they did, most games are so inter connected that makes testing very hard

#

For sure, it's just even harder in games

compact ingot
#

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

stuck onyx
#

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

compact ingot
#

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

stuck onyx
#

testing also requires a BIG amount of time, preparing it and updating it

rugged radish
modern cedar
#

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.

stuck onyx
#

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

rugged radish
#

I'd consider writing tests for billing and account systems for sure tho

stuck onyx
#

im talking about games obviously

rugged radish
#

me too

modern cedar
#

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

stuck onyx
#

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

modern cedar
#

yeah, since there's a lot more variables to account for

#

you can't realistically keep every possibility in mind when writing tests

stuck onyx
#

variables, movements, interruptions in certain moments ... some things you simply cant

split sierra
#

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?

modern cedar
#

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

stuck onyx
#

or you can release it and let the customer debug... like bethesda or project red

modern cedar
#

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

rugged radish
#

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

modern cedar
#

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

compact ingot
#

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

undone coral
#

i don't think it is

compact ingot
#

This is just arrogant

#

People here are not stupid

undone coral
#

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

compact ingot
#

And many of us have tried all the things you suggest but tempered their excitement with experience

undone coral
#

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 ๐Ÿ™‚

mossy token
#

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?

undone coral
mossy token
undone coral
#

(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?

mossy token
#

(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).

undone coral
#

okay

#

so i have a few comments

mossy token
#

(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.

undone coral
#

so if you can emotionally accept that, you will thrive

#

i know that it seems possible in theory

supple kernel
#

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 ?

undone coral
mossy token
#

I spent about a week getting the build process to work and I got really far! I'd be okay to resign this attempt...

undone coral
#

no

#

stop now

#

before you waste any more time on this

mossy token
#

What?

undone coral
#

i run a unity build process

#

it will take you almost a year

mossy token
#

XD

undone coral
#

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

mossy token
#

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.

undone coral
#

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

mossy token
#

I'll take your word for it then ๐Ÿ˜„

undone coral
#

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

#
  1. use unity cloud build. instantly, immediately cease wasting your time on this
#
  1. the $10/mo or whatever absolute bullshit it costs is worth it
#

are you making a mobile game?

mossy token
#

VR

undone coral
#

Quest?

mossy token
#

Yes, quest 2

undone coral
#

okay

mossy token
#

Things are coming along quite well TBH

undone coral
#

i know it looks that way

#

but listen, i knew exactly how to fix the build right?

mossy token
#

Even mumble server is working :]

undone coral
#

how did i do that?

#

oh you mean with the game

mossy token
#

Cloud

undone coral
#

that's good ๐Ÿ™‚

mossy token
#

$10/mth is totally fine

undone coral
#

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

mossy token
#

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?

undone coral
#

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?

mossy token
#

adb bridge to upload it (or directly from Unity's Build)

undone coral
#

or via UCB

#

okay

#

then i think it will probably be fine

#

unity cloud build

mossy token
#

alright i'll look into it

undone coral
#

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

supple kernel
undone coral
#

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"

supple kernel
#

no I am already googling it ๐Ÿ˜„

undone coral
#

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

supple kernel
#

thank you soo much I will look at it

inner juniper
#

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.

stark sedge
#

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;
sly grove
jade citrus
undone coral
#

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

undone coral
jade citrus
jade citrus
undone coral
#

lol

jade citrus
#

from the code it seems like it is, and you're calling AddTorque after you set the collider to convex... Hmmm

stark sedge
undone coral
#

oh yeah id idn't even look at the code

jade citrus
#

Interesting solution! Will keep that in mind, thanks for sharing @sly grove

undone coral
#

i don't know, it's glitchy

#

don't use concave colliders

#

even if you check the box

jade citrus
#

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

stark sedge
#

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.

sly grove
#

if you liked how it was behaving without the collider

supple kernel
mossy token
#

@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).

undone coral
#

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

mossy token
#

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

undone coral
#

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

undone coral
mossy token
#

This makes me want to go back to pushing forward in GCP

undone coral
#

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

mossy token
#

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.

undone coral
#

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

mossy token
#

Oh interesting. Seems a bit annoying that the CLI can't do the same thing as the Editor UI

#

Oh well ๐Ÿคท

undone coral
#

and like who the fuck is going to file those bugs

mossy token
#

;

#

100%

#

I feel like you had an opportunity to vent there quite a bit. Are you actively working on a project too?

undone coral
#

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

mossy token
#

Thanks, good to know!

undone coral
#

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

mossy token
#

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?

untold moth
#

And IL2CPP seems to be the default one I guess.

#

Actually I can't find that option in the docs๐Ÿค”

mossy token
untold moth
#

Does it actually affect the scripting backend though? It could be some deprecated enum value not used anywhere.๐Ÿค”

mossy token
placid shell
#

doing some dll stuff, and im trying to recreate ```c++
typedef unsigned int NvFlowUint;

mossy token
#

I still don't understand why I shouldn't use defines with BuildPlayer:

  1. The context in which BuildPlayer runs has the UNITY_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.
  2. 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.

placid shell
mossy token
placid shell
quasi fog
quasi fog
foggy elk
#

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?

novel plinth
#

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

foggy elk
#

can a class field marked as an Enum field contain any other thing than an enum?

novel plinth
#

you're making your game with fancy tech, but your questions are somewhat basic ๐Ÿ˜ตโ€๐Ÿ’ซ .. I'm confused ๐Ÿคฃ

foggy elk
#

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

flint sage
foggy elk
#

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?

azure delta
#

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?

devout hare
#

That's not a coding issue so stop posting it to coding channels

obtuse remnant
ocean mica
#

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.
sly grove
#

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

stuck onyx
#

same here bro

ocean mica
# sly grove Opengl no good

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.

ocean mica
undone coral
undone coral
unique ermine
#

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

undone coral
unique ermine
sly grove
unique ermine
#

wtf is any omg.

sly grove
#

Find actually returns the thing

unique ermine
#

didnt know that

sly grove
#

Any tells you if it exists

unique ermine
#

ah I actually need the item in the list to return
so any wouldnt work then

ocean mica
sly grove
undone coral
sly grove
#

e.g.

var flag = allDefaultFlags.Find(...);
if (flag != null) {
}```
undone coral
#

like a typical title in the Switch store built with Unity is... probably closer to 30-50GB of RAM to build

#

probably more

novel plinth
#

List.Exists

undone coral
#

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

unique ermine
sly grove
unique ermine
undone coral
sly grove
#

show what you tried and the actual error

undone coral
#

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

unique ermine
#

ah my bad.

#

Still had the any instead of find

#

works now, ty.

undone coral
undone coral
regal olive
#

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?
regal olive
#

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?

sly grove
#

I'd think you'd want a vector at 90 degrees from the first

regal olive
#

Yeah either works I guess, Ill try AngleAxis

sly grove
#

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;```
regal olive
#

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

upper phoenix
#

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

undone coral
#

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

upper phoenix
bleak marsh
#

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

bleak marsh
#

Okay, that kinda makes the whole system basically useless...

cyan nacelle
#

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?

neat cloud
#

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

misty glade
#
motor.rpm = 9001;
motor.torque = 700;
glass mica
#

How can i detect area of collission? Like how much is the size of the collider is at current collission

novel drift
#

Letter tracing

undone coral
tough knoll
#

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

sly grove
#

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

tough knoll
#

Oh damn

#

that's easy

sly grove
tough knoll
#

thanks man

unkempt nova
#

I need to do this, but at runtime. Or is there an easy way to cache these from the editor, for use at runtime?

austere jewel
unkempt nova
#

Yeah that should work, thanks

mossy token
#

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?

austere jewel
#

That's not normal. Presumably a script somewhere in your project is doing it.
Otherwise, search for known bugs on your Unity version

upper phoenix
ocean mica
crimson urchin
long ivy
#

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

royal timber
#

how do I rotate a matrix?

#

I have the view matrix used for direction light shadows

#

I would like to rotate it

granite axle
#

If itโ€™s a unity matrix you can use one of the static helper methods under Matrix4x4

mighty latch
#

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

flint sage
#

That sounds sketchy af

novel plinth
#

The platform the game it's on, wont allow that...

#

Windows or mac especially, or it will break their tos

sly grove
mighty latch
calm ocean
#

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?

calm ocean
#

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.

untold moth
#

Finally done with the damn terrain edge detection algorithm. It's slow, but otherwise perfect!

hollow garden
#

nice

calm ocean
#

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?

undone coral
calm ocean
#

No, the ground tile has a tile piece.

calm ocean
undone coral
#

like how much research have you done

#

into implementing this game

calm ocean
#

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.

calm ocean
calm ocean
undone coral
#

is what you are doing improving gameplay?

calm ocean
#

Not directly. We could get away with casting. Though, I would imagine that the more features we add, the slower development will be.

untold moth
#

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.

undone coral
#

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"

calm ocean
#

ITilePiece is the interface in my case

#

Wait

undone coral
#

"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

calm ocean
#

From my minute of research into one of, it looks like an enum

undone coral
#

in your own game codebase, you know what all the types are going to be ahead of time

undone coral
calm ocean
#

Well, a slightly more powerful enum

undone coral
#

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

calm ocean
#

lmao ok

undone coral
#

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

misty glade
#

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.

undone coral
misty glade
#

(I mean, you might want interfaces but I don't feel like this is .. the correct time for it)

undone coral
#

because Unity components are already the idea that interfaces seem helpful for

misty glade
#

(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

calm ocean
misty glade
#

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

misty glade
#

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

calm ocean
#

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?

calm ocean
#

Also, this restrains things on a tile to just NPCs. What happens if I want items and environmental objects?

misty glade
#

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

undone coral
#

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

undone coral
#

and your UI elements - like clicking on tiles - queries that

calm ocean
#

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

undone coral
#
public GameAction[] GetAllAvailableActions(...)
calm ocean
#

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.

undone coral
#

The โ€œCreating a LISPโ€ stage

#

Like why not write the piece of code that does โ€œANDโ€

#

Maybe make the method I described

undone coral
#

When youโ€™re learning

wintry wind
#

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?

rugged radish
#

sounds like signed projection to me

wintry wind
#

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 ๐Ÿ˜†

undone coral
wary swift
#

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.
wintry wind
#

Thanks!

undone coral
calm ocean
#

Like renaming AndMapTilePredicate to TrueForAllTilePredicate?

calm ocean
silver schooner
#

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.

mossy token
#

I read that IL2CPP is a unity-developed tool. How come microsoft doesn't have such a tool?

novel plinth
#

it's a transpiler, and why would Microsoft develop game-engine related transpiler in the first place ๐Ÿง

mossy token
#

by the name of it, it converts IL into CPP

novel plinth
#

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

novel plinth
mossy token
hallow cove
#

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))```
flint sage
#

Idk how many entries you have but you can use linq's GroupBy

hallow cove
#

well uhh

#

thousands

#

however I can try and cache them, since they don't really change

flint sage
#

Then you might need another solution but you can try it to see if it's fast enough

mint sleet
#

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

upbeat path
viral pilot
novel plinth
# mint sleet Hello

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));
mint sleet
#

thanks

round blade
#

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

timber flame
#

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)

round blade
#

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! โญ

novel plinth
#

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

regal olive
#

Is there a way to create an event handler for everytime a value on my dictionary is changed?

novel plinth
#

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

undone coral
undone coral
#
// 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);
 }
}

https://github.com/magefree/mage/blob/cbbfe5906a5d4ae67692dfdcf247ce541ff4771f/Mage.Sets/src/mage/cards/p/PainfulMemories.java#L23

GitHub

Magic Another Game Engine. Contribute to magefree/mage development by creating an account on GitHub.

undone coral
undone coral
neat cloud
#

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?

hallow cove
#

everything is here, so why doesn't this work

round blade
hallow cove
#

why doesn't it allow me to open the Search Window, if every variable is there

undone coral
#

are you recording the screen for gameplay purposes?

round blade
#

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

undone coral
#

is it for you in order to create demos?

#

is it for the end user in order to...

round blade
#

For the end user to capture content

undone coral
#

content that is used by you

#

or...

#

well i think you should just turn off or crop away the UI

round blade
#

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)

undone coral
#

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

round blade
#

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

undone coral
#

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

round blade
#

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

undone coral
#

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?

round blade
#

Yeah

undone coral
#

okay, then it should be within your scope to achieve that

round blade
#

I get you, but the UX requirements I have are in it's crudest form to 'replicate instagram' in the app

round blade
#

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

undone coral
#
// Commit video frames
Texture2D[] frames = ...;

^already a dead end

undone coral
#

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

round blade
#

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

undone coral
#

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

round blade
#

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);
}
}

undone coral
#

yeah, that puts the buffer on a CPU thread

#

and therefore, will not work performantly

#

it's also a little wrong

round blade
#

I am running an AsyncGPURequest? That was definitely more performant

undone coral
#

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

round blade
#

Okay, thank you for your feedback

undone coral
#

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

round blade
#

Yeah that's what I was using before

undone coral
#

yeah

round blade
#

I guess I can add a timer to the recording so people have a chance to capture without the UI

undone coral
#

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

undone coral
#

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

round blade
#

Okay, sure I will try that, thank you for your guidance on this

undone coral
#

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

round blade
#

Appreciate it ๐Ÿ‘

undone coral
subtle river
#

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);
}
undone coral
#

you fell for the agora sdk trap

round blade
#

Gonna be honest, I did before and I share your opinion on how difficult it is

subtle river
#

been in agora hell for years now

undone coral
#

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

round blade
#

We got agora working and it wasn't too performant but we got AR streams working

undone coral
#

about you, or your application, or its unity sdk, or how well it works

round blade
#

Yup

#

It sux

undone coral
#

i think if you want to send headsets and phones out to people and stream their trainign sessions or whatever

subtle river
#

ikr. i keep being blown away by how incompetent their company and product is

undone coral
#

to a website with an instructor to watch their thing

#

TOUGH COOKIE

#

it's not possible with agora

undone coral
#

this will also not work

subtle river
#

how's that?

undone coral
#

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

subtle river
#

it is! haha, but agora is in charge of invoking the callback not sure how much control i have over that.

undone coral
#

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

subtle river
#

i hear ya. out of my hands unfortunately. it is a Businessโ„ข thing

undone coral
#

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

subtle river
#

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

undone coral
#

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

subtle river
#

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

undone coral
#

even on a PC, there are limits

undone coral
#

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

subtle river
#

everyone is painfully aware, we're just making a product with weird requirements and

  1. haven't found another solution that fits our needs
  2. 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

undone coral
#

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

undone coral
#

does it have to do with instructors and training

#

there is nothing sensitive

#

about what the app does

subtle river
#

remote collaboration/communication thing

undone coral
#

but no instructors?

#

there's no training?

#

there's no instructor doing a remote training?

subtle river
#

nothing to do with training

undone coral
#

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

subtle river
#

its a shared space with rooms/videos like figma but you actually exist in the space

undone coral
#

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

subtle river
#

yup! figma is pretty good lol ๐Ÿ˜…

#

they got some smart people over there. pretty crazy it runs in the browser

undone coral
#

personally

#

i hate figma, passionately, it's like a quintessential negative ROI tool

subtle river
#

lolol. i haven't used it enough to hate it yet

undone coral
#

people like figma

#

but usually, they are doing something very negative ROI with it

subtle river
#

fair. from a tech perspective i think its impressive tho

undone coral
#

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

undone coral
#

especially software

timber flame
calm ocean
regal olive
#

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++;
    }
regal olive
sly grove
#

what are these 100s of items?

#

and what are you waiting to happen before doing your thing

upbeat path
sly grove
#

Like would it be acceptable to wait one frame?

#

Or does it still need to be first frame, just after all Starts

regal olive
# sly grove and what are you waiting to happen before doing your thing

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.

sly grove
#

(is this at the begining of a scene?)

sly grove
#

You could just do:

IEnumerator Start() {
  yield return null; // wait one frame
  DoTheThing();
}```