#archived-code-advanced

1 messages ยท Page 201 of 1

regal olive
#

Hey, how can I recreate this in Unity?

misty glade
#

Ooh, interesting.

hoary pendant
#

Well the currents Entities package on DOTS is in development still, so learning it may leave you with wrong syntax in the future. Also it is a much different design paradigm which may be difficult to grasp

#

Interfaces to avoid inheritance if you want to go that way

misty glade
#

I imagine one approach is to figure out how to draw a "slice" of a voxel, then figure out how much of a voxel the plane is intersecting, then draw it programmatically. This looks like a pretty tough problem, though.

regal olive
#

I got suggested to do define equation for a plane -> sample points on the plane and store block data into a texture to be rendered

#

tbh i have no idea how to do that

misty glade
#

Yes, this is a very non-beginner problem that's going to require some programming chops and unity chops

gentle yew
#

Hmmm... I might have an idea @buoyant nacelle .. I guess it's a combination of your Dictionary idea with using System.Flags for enums

You have the following types:

[System.Flags]
enum Unit
{
  None = 0,
  Soldier = 1,
  Witch = 2,
  Paladin = 4,
  Mage = 8
  ....
}

If your unit was a Paladin and a Witch (for some reason lol), their Unit would be = 5. You could then add that unit in the dictionary under key 5. When you do your query, you instantly know the flag you're searching for. This leads to O(1) for time complexity and O(n) for space complexity

misty glade
#

I can't think of a "simple" approach, and even in my head when I break it down, there's lots of parts of the problem that aren't easy

misty glade
#

Better is to have a non-flag enum for the targets and then select off of that

gentle yew
misty glade
#

well the example you gave indicates.. yes? I dunno, you tell me ๐Ÿ™‚

gentle yew
#

If they are only one value, than a simple dictionary solves it?

misty glade
#

I assume a Soldier can't be a None

#

You don't need a dictionary, you just need a property

#
public class Dude
{
  public Unit Type;
}
``` done
gentle yew
#

Yeah, but why would you waste time querying? You could just cache it in a dictionary

misty glade
#

i'm assuming you would just query when the player casts the spell or whatever

gentle yew
#

I guess it depends on what OP had in mind

buoyant nacelle
gentle yew
#

Also, I don't think it matters if soldier can't be None or whatever. Class creation should throw an exception if invalid combination is provided

buoyant nacelle
#

To query it on the selection

misty glade
#

I mean, sure, but.. putting a flag enum on something that's not really a flag (in the sort of abstract definition of it) isn't really a great idea

#

I mean, nothing illegal about it - it'd work, but imho it'd introduce bugs later on since you'd rely on the consumer/setter of those values to remember that they should only have one

#

if you accidentally set a Dude to have two types, who knows what behaviour you'll see - maybe a shop offers witchy gear to the dude you think is a soldier, things like that

buoyant nacelle
#

Ideally, it would be good to have properties on the unit, so then you can make a sphere selection and loop with certain conditions

misty glade
#

yeah, but i'd just put the "properties" (english definition of the word) into properties (C# definition of the word) as close to what matches the mental model for your game as possible - there's lots of ways to find targets that match a set of properties

#

i personally like LINQ because it is "vertically dense" and I don't have to worry about the details or bugs

#

It's not for everyone but this ๐Ÿ‘† makes sense to me - it's less likely to have bugs, there's no looping or indexing or any trivia to handle if I just want to find a bunch of valid targets for my spell

buoyant nacelle
#

You have to loop through all units

#

Or select all enemy units in react

misty glade
#

one line of code versus the "old school" way of doing it which is like:

for (all objects in the scene)
{
  if (it's a solider)
    if (it's an NPC)
      if (it's a witch)
        if (it's in range)
          add to a list
}
foreach (item in list)
{
  get the distance
}
foreach (item in list)
{
  get the shortest distance item, add to another list
}
#

etc

buoyant nacelle
misty glade
#

again, you can "do it yourself" and cache the closest enemy unit or whatever, but I stand by my point - looping through 100 (or 10,000, or even 1,000,000) items is pretty quick as long as you aren't doing anything unity related - GetComponent Instantiate etc

buoyant nacelle
#

Looks like the most viable option based on the responses

buoyant nacelle
#

Every category will have a sub

gentle yew
#

Eh... it's overcomplicating and hitting performance.. and it's making the code ugly.. just add it to a dictionary based on some params and maintain that dictionary. Unless the type of the object changes live, you won't have any issues with that

dusky remnant
#
if (anim.GetBool("canAttack") == true) {
if (anim.GetCurrentAnimatorStateInfo(0).normalizedTime >= 1) {
    anim.SetBool("canAttack", false);
  }
}

The animation disables instantly when it gets enabled. Does someone know why that is?

buoyant nacelle
#

I might want to change them in game

#

And add more categories/sub categories later

regal olive
#

for editor scripting, what is the difference between base.OnInspectorGUI(); and DrawDefaultInspector();

inland delta
regal olive
#

ok, but if there is nothing to inherent then they are virtually the same?

inland delta
#

I guess so

regal olive
#

ok thank you for the explanation.

queen ridge
#

is raycast the best method to make the player rotate when moving on angled terrain? is there a better way to make it look normal in scene?

sly grove
#

Yes use a Raycast to get the surface normal

unkempt nova
queen ridge
#

thanks

buoyant nacelle
#

Priority order

#

I will need to query for each priority

untold moth
buoyant nacelle
buoyant nacelle
#

If players will not lag, i am fine with it

untold moth
#

Constantly or only when you want to hit them? You can make an overlapsphere to query for object with colliders within certain range and then sort them additionally if needed. That might or might not be more efficient than just looping all the objects in the scene and checking their position.

untold moth
#

In gamedev it's all about trial and error. The systems are often to complex to just tell what's more performant at glance. You need to try and see for yourself.

buoyant nacelle
#

Thanks

#

@untold moth if you don't mind me asking. I will use LINQ for sorting, but what would the best way to represent categories and sub categories? So, I can search all units or only heroes (sub type of units). So, I have class Entity, and it has Two Categories and a Sub Category for each category

untold moth
jagged holly
#

hello,Ive made the binary saving following a tutorial, but the issue is that it does save in the editor just fine, but when I build it to android, it doesnt work. Opened Android device monitor, and these are the errors that pop, but i have no idea how to fix it, I would REALLY REALLY appreciate the help!

fresh salmon
dusky carbon
#

Did you try creating a directory relative to Application.persistentDataPath? not an android developer, but I believe android will restrict app's file IO to there

jagged holly
jagged holly
dusky carbon
#

I'm pretty sure "Saves" isn't already under that path. Maybe you want something like Application.persistentDataPath + "/" + directoryName

jagged holly
dusky carbon
#

yeah I'm not talking about the saved file, I'm talking about the directory you are trying to create, specifically in the lines I highlighted in the screenshot of your code

jagged holly
#

ive commented out "if(!Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName);" didnt fix anything, same error

dusky carbon
#

considering the error included CreateDirectory, I highly doubt it is the same error

jagged holly
#

I mean, this error did disappear, but it didnt fix the other errors

#

and my saving and loading doesnt work on android

regal olive
quartz stratus
#

Or are you asking for someone to architect this from scratch for you?

#

That is a super cool effect. I hope you find help and are able to recreate in Unity!

frank peak
#

heres the terrain that i implemented with that tutorial/guide (The gif was made for another purpose but you can see the terrain and it has some tweakability)

#

Feel free to DM me if you have any questions about it

icy smelt
#

Can I convert a single Quaternion axis to a degree representation without knowing the other Quaternion components (specially W)?

#

Quaternions are such a mystery to me

#

Nvm, I guess I can't

#

Trying to implement runtime animation keyframe reduction. It gets tricky as my rotation animation curves are stored as quaternions

hallow cove
#

does anyone know how I could add a feature to stream my desktop to an ingame texture?

#

over the network?

#

like, pc to phone

#

over localhost

#

I saw unity has a Render Streaming feature

#

but I don't think that has anything to do with what I want

regal olive
misty glade
#

Googling has been unhelpful. What is likely to have the biggest impact on battery life in Unity apps on mobile devices? Draw calls? tris? Assume negligible script behaviour (I have almost no Update() calls in my entire app)

somber swift
misty glade
#

Any general process ideas on optimizing? Or is it pretty much "just do a little bit of everything better" - ie, minimize CPU in script profiling, minimize GPU in tri/batch profiling, reduce device hardware use (networking/wifi, primarily)

#

Like, if my app has crappy battery use - is there an obvious place to start looking for that? obvious low hanging fruit

somber swift
#

Start by profiling your program and see how much stuff cpu and gpu do and what are they doing. Theres no reason to optimize animations if they take 0.1% of the frame time

misty glade
#

This might be an obvious question but how do I roll up the profiler session? It looks like I can only see stats for a specific frame

scenic bear
#

Hey guys, I'm playing around with the NetCode package and am struggling with client animations being replicated on the host.
I've read through similar issues on the forums (https://forum.unity.com/threads/the-host-dont-see-animations-of-clients.1295964, https://forum.unity.com/threads/client-animations-not-displaying-on-the-host.127945) however even though I have followed the instructions given, my animations are still not propagating back to the host.

Is there anyone free to go through this with me?

dusky carbon
scenic bear
#

Ok thanks

timid coyote
#

@mossy oliveone ... Need some help with Vecotrs & Velocities, trying to replicate a HUD Velocity/Flight Path Director. That is, the Aircraft's nose is pointing one way (say nose up 10ยฐ) but the actual flight path the aircraft is moving along is -10ยฐ (i.e. when aircraft land). So, on screen we would see an icon representing where the nose is pointing (forward vector of transform) ... but the transform's (rigid bodies) velocity vector would be pointing down. How do I go about calculating where to place the icon on the screen from all the rigid body velocity vectors and transform rotations? (new to this level of coding, but not new to coding & UI management).

misty glade
#

Draw the HUD with UI elements (which can be drawn differently than things in world space) - you don't want to really be "projecting" your hud in 3d space, unless that's part of your game design (ie, perhaps other players could see your hud)

urban warren
#

Quick question, is there a performance difference between casting from an object and casting from an interface?

public interface IPerson { }
public class Teacher : IPerson { }

IPerson person = new Teacher();
object objPerson = new Teacher();

// Is there a difference between this:
Teacher teacher = (Teacher)person;
// And this:
Teacher teacher = (Teacher)objPerson;
hollow garden
#

so both appear to be the same performance to me, but i'm not too knowledgable about the intricacies

urban warren
hollow garden
#

no problem

undone coral
#

there are a lot of reasons why you might not save in that directory

undone coral
icy smelt
#

U guys familiar with AnimationCurve keyframes reduction (in runtime)?

undone coral
#

even then i'm not sure, since you don't declare any virtuals

#

it's fine

#

but technically all interfaces are virtual methods right? really hard to say

misty glade
#

Yeah, I figured. ๐Ÿ˜ฆ

icy smelt
misty glade
#

.. it seems like you said "nvm" in response to your question..?

icy smelt
#

Bottom one

misty glade
icy smelt
#

Simplifying translation and scale is "easy". Quaternion curves simplification is a mistery to me

urban warren
icy smelt
#

I mean, if I do that with Euler Angles, I know I can compare the original and reduced curve values by the delta angle "just like Unity does"

#

Not sure how to do that with Quaternions tho, and I can't use Euler for my animation curves

#

And converting the Quaternion to Euler in runtime for this kind of stuff is not reliable

misty glade
#

I'm still not sure what your question is.. Is it "can I get the euler angle between quats?" (yes) or "can I make a quat from a euler?" (yes) or "should I access individual properties of a quat?" (no)

#

What do you mean, not reliable..?

icy smelt
#

Just looking into methods to simplify 4 AnimationCurves (X,Y,Z,W) that represents Quaternion rotations

misty glade
#

In general you don't touch x,y,z,w

icy smelt
#

@misty glade

When you read the .eulerAngles property, Unity converts the Quaternion's internal representation of the rotation to Euler angles. Because, there is more than one way to represent any given rotation using Euler angles, the values you read back out may be quite different from the values you assigned. This can cause confusion if you are trying to gradually increment the values to produce animation. See bottom scripting example for more information.
#

This can cause confusion if you are trying to gradually increment the values to produce animation

#

I see @hidden edge

misty glade
#

Right - but you shouldn't gradually increment the values to do animations, you should s/lerp between quats

icy smelt
#

My animations are created using Quaternion Animation Curves. Right?

#

I'm trying to add a post-processing step where I need to decrease the Quaternion curves complexicity

#

In runtime

#

Key count

#

They are literally baked at each time-step (60fps, 30fps, etc)

#

Producing tons of keyframes

#

It is ok to paste code snippets here or do we have to use an external website?

misty glade
#

use your best judgement, probably 5-10 lines is fine, more is pastebin

icy smelt
#

Like 20 lines

misty glade
#

๐Ÿคทโ€โ™‚๏ธ

#

sure?

icy smelt
#

Just cloning the AnimationCurve I'm working with, removing the given keyframe, and comparing it with the original

misty glade
#

how's the animationcurve created?

#

this seems very weird

#

I'm assuming the curve is created with some library or something you've found..?

icy smelt
#

Nop

#

I create it with code

#

They are "legacy" curves

misty glade
#

OK.. so why are you trying to remove keyframes from it after...? like, why not just create it with fewer keyframes?

icy smelt
#

Not Mecanim ones

icy smelt
#

I'm literally baking the animation in runtime

misty glade
#

removing keyframes from a curve might do really weird things where it rotates like.. super abruptly between keyframes because of how quat slerp works..

icy smelt
misty glade
#

like you might get some sort of rotational speed of "1 degree per frame" and if you remove a keyframe then it goes wildly to 300 degrees per frame for those two frames

icy smelt
#
Set the error tolerance (as an angle in degrees) for rotation curve compression. Unity uses this to determine whether or not it can remove a key on a rotation curve.

This represents the minimum angle between the original rotation value and the reduced value:

Angle(value, reduced) < RotationError
misty glade
#

i certainly don't know how x,y,z,w are represented internally in quats - I know enough to .. know not to try to comprehend the imcomprehensible ๐Ÿ™‚

#

K, I mean, I'm still not exactly sure why you're creating the curves (runtime or otherwise) with so many keyframes.. it just seems like a better approach might be to attempt a bit more "preprocessing" and calculating an appropriate number of keyframes before creating the curve (as opposed to just creating it with a keyframe every game tick or whatever and then removing them later)

icy smelt
#

My approach was going to be: calculate the Quaternion final values per-frame by sampling the curves, get the eulerAngles property value, and compare it with a given Quaternion component curve by removing that component keyframe. But I'm not sure if that is worth the try. I'm literally working in an unknown field there.

icy smelt
#

Thinking better now...

#

I can do that with the original euler data I get from the model....

misty glade
#

euler is best er

icy smelt
#

Other 3D file formats I'm working with don't use Euler Angles at all, so a general "Quaternion-friendly" solution would be better...

humble loom
#

anyone familiar with deploying games to oculus? i'm trying to get user login information and it's...failing i think? but like it's so difficult to debug - i have to keep building development builds and watching the logs for debug output to test this crap, and i can't use breakpoints. it's miserable

undone coral
#

are you?

humble loom
#

ODH

undone coral
humble loom
#

oculus developer hub

#

either way the issue is that my request for userid and displayname succeeds but the result are empty strings

undone coral
#

i mean for the purposes of sideloading an apk so you can develop easier

humble loom
#

i use ODH for sideloading

undone coral
#

oh

rapid minnow
#

I'm aiming to use Animation Curves to transport GameObjects following a given curve. I'm attempting to visualize the curve in world space with Gizmos. Is this possible, does anyone have any experience with this?

mint kraken
undone coral
undone coral
misty glade
#

My LoadLevelAsync() is causing a kind of gnarly burp on the main thread (200ms) - is this pretty much unavoidable?

untold moth
timid coyote
misty glade
viral iron
#

Is it possible to display an Android View within a Unity scene?

viral iron
#

Or rather, frame an entire Android app (packaged inside my Unity Android app) inside a 3D scene?

kindred holly
#

[this is a 2d program] -> i have a character that is able to drop down 2 boxes. the boxes can be dropped anywhere on the (x,y) grid. once they are dropped, a line is formed between them using a line renderer to represent a hitbox. My question is how do i shift a boxCollider so that it is stretched between the 2 boxes?

#

I know i can use transform.position and .size. but i still have to deal with rotation and id rather not do it. is there any way to "Draw" a hitbox between 2 points?

#

how do i dynamically draw the hitbox represented by the pink line?
do i have to calculate the center between the 2 boxes, distance, and angle or is there an easier way?

hallow cove
#

does anyone know how I could get this in my graph view?

lavish sail
#

you can calculate the angle easily with Mathf.Atan2(y,x)

#

distance with vector2's magnitude

novel plinth
#

Or just the simplest, an Image element with draggable property

#

There's a huge thread regarding making your own custom mesh/shapes on the Forum which you can peek at

hallow cove
#

ok thanks!

kindred holly
timid coyote
split sierra
#

does anyone have experience with ML-Agents? would need a bit of help

unkempt nova
misty glade
#

What's y'alls workflow for importing unitypackages? I don't like how I can't specify where the destination is, and importing my coworkers stuff is a bit of a pain - I don't want to require him to learn my directory structure, I just want to be able to import it to a specific folder and then move the assets to where they need to go in the master project (he works in empty projects and builds cutscenes)

#

๐Ÿ˜ฌ

inland juniper
#

how do i fix these errors

stiff mulch
#

_ works well for top

misty glade
misty glade
#

TextMeshPro also installs itself at the root, and my partner uses TMPro but obviously I don't need to import it each and every time

stiff mulch
#

Yep oof

warm mica
#

any ideas why this is generating a lot of garbage collection ? ```cs
if(stopwatchActive == true)
{
currentTime += Time.deltaTime;
}

   time = TimeSpan.FromSeconds(currentTime);
    currentTimeTextUI.text = time.ToString(@"mm\:ss\:fff");```
#

2606 batches? tf

misty glade
#

Where do you see that the stopwatch call is generating that much GC though? I see it's only called once, and only allocating 68 bytes..?

#

do you have tons of these objects in your scene that have that text object on it? if so.. maybe unity's flailing on merging the meshes..?

warm mica
#

no this stopwatch is just a main script in the scene for timekeeping

misty glade
#

i might take that call to setting the text and put it inside the stopwatchActive clause - i'm pretty sure tmpro doesn't re-create the mesh if the text hasn't changed, but.. it couldn't hurt

warm mica
#

I can't seem to narrow down what's causing so many batches

misty glade
#

that is a lot of batches there.. 92,000 ๐Ÿ˜ฌ

#

i only have uh... 500 in my loading scene with ... like.. hundreds of objects

warm mica
#

where do I have 92000?

#

I see 2606

#

which is high for just a scene with probuilder

misty glade
#

what's the tooltip in the batches in the profiler

#

"batches count"

#

or triangles count maybe?

#

500 tris, 6 batches, 4 setpass calls

warm mica
#

vert/tri count

misty glade
#

i can't quite tell what your colors are since your play mode color is a little ... intense ๐Ÿ™‚

warm mica
misty glade
#

but it looks like you have 92k tris, 77k verticies?

#

106k tris seems like a lot?

warm mica
#

shouldn't make my batches 2606...

#

Ill try camera occlusion culling

misty glade
#

unfortunately this is a bit above my pay grade.. not sure how batches really works in unity

warm mica
#

with occlusion culling I was able to reduce the batches by Half, but still not good enough...

#

I've seen people have way more Tris/Verts with batches ranging to 80-100 max

#

what am I doing wrong.?

misty glade
warm mica
#

gonna try to make meshes Static, see if it helps a little..

#

yeah Static might be helping... or just placebo..

#

1205 a lot less than 2606 but still high for a pretty empty scene / gameplay

hallow cove
#

quick question, I have a PropertyInfo variable, and I wanna know if it's a Get or Set type

misty glade
#

you mean if the get and set on the property are public? put the cursor on it (in visual studio) and press F12

#

even if the code's not yours, you'll see generated metadata on the field like this:

fresh salmon
#

With reflection

#

At runtime

#

A simple docs check. CanRead and CanWrite properties.
Again, always check the documentation

#

Getting the actual underlying methods is done with GetMethod and SetMethod properties.

hallow cove
#

yeah I am instantiating some nodes that are either Set_Property or Get_Property

#

and I don't need to get the Set and Get properties tho

#

just if the version in the list I selected is a Setter or a Getter

#

and I did that by making a class that holds the PropertyInfo and a bool called "isGet"

#

but that still doesn't tell me if it's a getter or not-

#

wait no I am tired nvm

#

ok I just check if the property contains the string "Get" lmao

icy smelt
#

Guys, there is no way to get this kind of interpolation with runtime code?
I've tried creating localEulerAnglesBaked, localEulerAnglesRaw, and localEulerAngles curves, without success.
By checking the serialization code for this AnimationCurve, it is saved as an "Editor Curve", so I suppose there is no way to force this kind of interpolation in runtime.

fallow dune
#

Hey. I need to figure out how to play animations based on input given and the direction the wall is facing. I have tried quite a few things, however the main issue is, the input button in the direction of the wall needs to remain pressed to stay against the wall

#

I tried using the X and Z value from the '_playerMovement' Vector but No amount of configurations I tried gave a result I require. Also, when hugging a wall to the left or a wall that has it's surface normal in the same direction of the player the controls need to inverse as well

foggy cobalt
#

Hey Guys, I'm currently trying to write some editor scripts.
They basically should create a new class taht derives from a base class. The base class derives from scriptable object.
So after creating the new class I want to create a scriptable object asset of it.

So far I can create the new class file, but when I try to get the type it returns null. When the class was created before it returns the correct type.
So I guess I have to do some assembly recompile or something after creating the class file.

#

Code:

using System;
using UnityEditor;
using UnityEngine;
using System.Linq;
using System.IO;
using System.Text;

public class ActionWizard : EditorWindow
{
    [MenuItem("Tools/AI/StateMachine/ActionWizard")]
    static void Init()
    {
        // Get existing open window or if none, make a new one:
        ActionWizard window = (ActionWizard) EditorWindow.GetWindow(typeof(ActionWizard));
        window.Show();
    }

    private string actionName;

    void OnGUI()
    {
        actionName = GUILayout.TextField(actionName);
        if (GUILayout.Button("Create Action"))
        {
            //Get base class content
            string baseClassContent =
                File.ReadAllText($"{Application.dataPath}/Scripts/AI/StateMachine/BaseClass/SM_Action.cs");
            
            //refactor base class content to create derived class content
            string newClassContent = baseClassContent
                .Replace("SM_Action", actionName)
                .Replace("ScriptableObject", "SM_Action");
            
#
            //create derived class
            using (FileStream fs = File.Create($"{Application.dataPath}/Scripts/AI/StateMachine/Actions/Scripts/{actionName}.cs"))
            {
                byte[] info = new UTF8Encoding(true).GetBytes(newClassContent);
                fs.Write(info, 0, info.Length);
            }

            //this is true
            Debug.Log(File.Exists($"{Application.dataPath}/Scripts/AI/StateMachine/Actions/Scripts/{actionName}.cs"));
            
            //maybe refresh?!
            AssetDatabase.Refresh();
            EditorUtility.RequestScriptReload();
            
            //still true, obviously
            Debug.Log(File.Exists($"{Application.dataPath}/Scripts/AI/StateMachine/Actions/Scripts/{actionName}.cs"));
            
            
            //get type of created class
            var allTypes = AppDomain.CurrentDomain.GetAssemblies().SelectMany(assembly => assembly.GetTypes()).ToList();
            var inputType = allTypes.Find(type => typeof(SM_Action).IsAssignableFrom(type) && type.Name == actionName);
            
            //null....
            //if type was created before it works and finds the desired type
            Debug.Log(inputType);
            
            //create scriptable object instance of created type
            var so = ScriptableObject.CreateInstance(inputType);
          
            //save scriptable object asset
            AssetDatabase.CreateAsset(so,"Assets/Scripts/AI/StateMachine/Actions/"+actionName + ".asset");
            AssetDatabase.Refresh();
         
        }
    }
}
icy smelt
#

When converting a Quaternion to Euler representation, there is no way to represent a full-range (180 degrees or more) rotation, right?

undone coral
#

the result of that conversion quaternion to euler conversion is idiosyncratic. you can look up the source to it online or google it

icy smelt
#

Well. I'm working on an Animation Curves simplifier code

#

The simplification works

#

The problem is when handling rotation curves

#

Simplifying Quaternion curves wont work

#

But the only way to generate Euler curves with my codebase is by converting them back from Quaternions

#

But that would give wrong results as the axis might wrap, etc

#

When "forcing" Unity to handle Euler curves as Quaternions, it works, but this option cannot be set at runtime afaik:

#

The bottom curve is the original (baked as Quaternions), and the top one is one generated from the Quaternions "eulerAngles" values. I see it is not a reliable way to animate stuff. But I can't find a way to simplify a Quaternion set of curves based on a threshold

#

When playing the top animation, there are some artifacts (the Unity docs mention something about these "legacy" euler animations playback)

#

This is a simple 360ยบ rotation animation around the Y axis

undone coral
#

at runtime

icy smelt
#

For my model importer

undone coral
#

i suppose you should look at the blender source and see how they do it

#

does this have to import models on iOS or Android?

icy smelt
#

It does work on every platform

undone coral
icy smelt
#

Yes, it is

undone coral
#

i guess the code advanced answer is that, do you want to make something valuable? there are a lot of model importers

#

it would be most valuable to have the unity editor running on a backend, and the runtime downloads an addressable asset bundle instead

#

everything else has already been done

icy smelt
#

Nah man. That is for my importer on Asset Store ๐Ÿ™‚

undone coral
#

that's what i'm trying to say

icy smelt
#

It is valuable

undone coral
#

i would pay for general editor backend -> asset bundle

#

it's the only long term viable solution

#

everything else... it's like, i'm bothering someone like you to implement keyframe reduction correctly

#

which i get you will be able to do eventually

#

but why bother. maya does that

#

id' rather just wire up with maya

#

as a backend service

#

anyway

#

yes, look at the blender source

#

what alternative is there?

icy smelt
#

If you want a general solution that does almost everything Unity importing does + more, without needing Unity to run in background, I'm here for it

#

And runs in mobile devices as well

#

That is not something requested a lot (keyframe reduction), but I'm doing all I can to decrease runtime memory usage

undone coral
#

it wouldn't be a huge leap to do well either

#

the game-ci people have already done the hardest part, getting it to run in containers

#

even on windows

#

just think about it

#

it's still runtime model import

#

just useful ๐Ÿ™‚

#

like imagine how much more scalable it would be

#

what i am describing

#

then you could runtime import any asset

icy smelt
#

Not my goal atm

#

I mean, I follow a different path (not using backend services)

undone coral
#

yes but why

wooden cedar
kind bobcat
#

I'd like to build my own custom collider shape (I don't want to use a custom mesh physics shape). I'm new to Unity but not to coding (newish to C# tho). I'm trying to figure it out. Apparently subclassing Collider is not an option (unless someone here knows how to do it?). Perhaps I can subclass MonoBehavior and build a collision model in the Update() method?

humble onyx
#

you still can use a meshcollider / Polygon Collider 2D and fill it with the data you want

#

unless the mesh is realy big that should not be a issue

kind bobcat
#

I did try using a high poly static mesh collider for the arena back then but what I found was that performance wasn't as good as I'd like, and the results when driving on the corners was not as smooth as I'd like. Once I just built my own custom shape, everything then worked flawlessly.

#

That was with Canon, maybe I'd get better results with Unity

green ether
#

Hey everyone. About a week ago I asked if there was any way to get spawned items to no collide when spawned inside of something. I've managed to implement Physics.OverlapBoxNonAlloc and the capsule one pretty well, but I've run into a problem.

Essentially, I need now is a way to re-enable collision when there is no longer an overlap between the objects. I initially use Physics.IgnoreCollision to ignore the collision, and I know I can use it again to re-enable it. My player has a Physics.OverlapCapsuleNonAlloc on it that ignores collision, and I currently have Physics.OverlapBoxNonAlloc on the spawned item. It catches the collider of the player and anyone else inside of it when spawned, which is great, and even when they are no longer overlapping it keeps the collider inside the array too! But I don't know how to evaluate in logic when they are no longer overlapping so that I can use Physics.IgnoreCollision to re-enable collision, does anyone think they could give me a helping hand?

undone coral
undone coral
green ether
undone coral
#

why does the bomb need to be physics anyway

somber tendon
green ether
# somber tendon > everthing on a grid I'd say use the grid coordinate and dont use physics at al...

there are no physics, the bomb gameObject doesn't have a rigidbody. the player does, however, and i also need to account for other players in the future. Physics.Overlap works perfectly for ignoreing collision between any bomb spawned on top of the player no matter who spawned it, but I need to find a way to acknowledge when the player and the bomb are no longer colliding so that collision between the two can be re-enabled so that it blocks the players path.

green ether
undone coral
#

you could use a distance

green ether
undone coral
#

hmm

#

i mean there are a lot of approaches here

#

i wouldn't overthink it

somber tendon
#

it's a bit of a hack, but you can just check if player and the bomb occupy the same grid, then disable player's collider, when it's no longer the same then just enable it again
on another though, mixing two collision system might unnecessarily complicate things later in the future

green ether
#

I just want to find an answer that creates the least amount of overhead possible. I ran into a problem yesterday where spawning a bomb created way to much overhead, and now i've comepletely reduced while also simplifying the code. If I can find a way to evaluate when a collider is no longer touching the overlapbox that would be great.

left anvil
#

Does anybody know of a way to put multiple textures onto an object that is created procedually in code.

So I have some procedually generated terrain that I'm trying to texture, however I want the texture for it to be dependant on some values of the nearest vertext (for now just height), so for example if it's lower than 57 then it's gotta have a water texture, otherwise it needs to have a grass texture. Any ideas of what the best way to do this would be?

I've been working on this without progress for 2 weeks, so any help is appreciated.

somber tendon
#

What I can think of is maybe you'll need two identical colliders for the player, one for the bomb and one for anything else (using physics collision matrix).
When your overlap box detect the bomb inside the player, set player's bomb collider to trigger, then when you get oncollisionexit event set the trigger to false

green ether
#

that's a good idea.

somber tendon
undone coral
#

by drawing a height map?

left anvil
undone coral
#

bomberman was written for super nintendos

left anvil
undone coral
#

why aren't you generating a heightmap?

#

and using pre-existing unity terrains?

left anvil
#

well

#

I started this before I knew about terrains

undone coral
#

i think you should stop and use terrains

#

accept Terrain into your heart

left anvil
#

is there a limit for how big terrains can be?

undone coral
#

i think you know the answer to that question

#

you should use Unity Terrains

#

there's no value to an alternative to unity terrain

somber tendon
#

in my case, unity's terrain doesnt perform well on mobile, that's why I use 3d mesh grids instead

left anvil
#

I should say for the project I am working on big numbers are dangerous, as I am trying to create an open world (99% randomly generated) that's around the size of europe.

undone coral
#

you should probably start by buying that

#

it will introduce you to a lot of important ideas in large world terrains

left anvil
undone coral
#

i think you should buy the asset

#

it really depends what your objective is

#

there are other assets specifically for runtime procedural generation

#

gaia pro has a decent approach that is friendly for gameplay

left anvil
undone coral
#

for a good educational takeaway

#

it really depends... personally i think it's much more valuable to master how to create a nice looking terrain by hand

mint kraken
# left anvil I have summer off so I wanted to try my best at a large project, and procedural ...

Welcome to this series on procedural landmass generation. In this introduction we talk a bit about noise, and how we can layer it to achieve more natural looking terrain.

A quick summary:
'Octaves' refer to the individual layers of noise.
'Lacunarity' controls the increase in frequency of each octave.
'Persistence' controls the decrease in ampl...

โ–ถ Play video
undone coral
#

if you can't do that, you won't make a nice looking procedural one

somber tendon
undone coral
#

i don't think there's any value in ugly procedural terrains, from an educational point of view

mint kraken
#

and calculate texture can be done in shader totally if it is just base on 1 or 2 values

left anvil
undone coral
#

learning how to generate a procedural terrain.. i mean you can certainly get the psychic experience of learning something, without learning anything at all

undone coral
left anvil
undone coral
mint kraken
#

size wouldn't matter i tried unlimited size and only issue I ever faces is a default setting of lighting will be wird when goes too far

undone coral
#

surely you see that

#

you can go and make this error

left anvil
undone coral
#

anyway

#

i am saying on your journey

#

to make good looking terrain

#

try to make... 100m x 100m of good looking terrain

#

you will need to know how to do that stuff

#

in order to understand your problem

#

i see people in this chatroom who are stubborn about advice like this all the time

#

there was a guy here who wanted to jump straight into making a ML bot

#

and i'm like, just try to make a good heurstic bot first

#

because you can't make a good ML bot without making a good heuristic bot

#

and not only did his heurstic bot perform great, he learned a lot

#

and made something way more valuable

left anvil
undone coral
#

make 1 nice looking terrain by hand

#

that meets gameplay goals

#

etc. etc.

#

learn how to place props well, and to pick camera angles and make slopes that are interesting to explore

#

otherwise your terrain will just be shitty noise

#

nobody needs to waste time following sebastein lag guy's verbatim stuff

#

nobody cares about that

#

do it by hand

#

so you can learn what is important

#

and if you're like, oh man using the unity terrain tools suck

#

i mean what can i say

#

you have to figure out how to do this

left anvil
#

yeah yeah I get you

undone coral
#

cool

#

you will see from looking at gaia pro that the procedural generation is

#

like 10% of the process

#

and not at all interesting

#

that there are a lot of procgen games out there, most of them bad

#

and in the cases where you find a game designer procgenned something compelling, many times they just did so by accident

undone coral
left anvil
#

Thanks for the advise, I will keep it in mind, however I would feel bad giving up on this project halfway through so I'll continue on it, with your words at the back of my mind.

left anvil
clever pond
#

sorry for the late reply !
I just want the user's game center id, we use a custom backend for our IAP functionality alongside Unity's own IAP system so we can keep track of the player's premium currency (Gems), so we needed some sort of unique identification from the player (either the Email or the unique ID given by game center).

we use the GPGS plugin for Android devices which works perfectly but needed the same for IOS devices.

p.s. thank you I'll check out the plugin your mentioned

rugged radish
#

hello guys. is it possible to change unity's unit scale for an entire project ?

regal flax
#

I'm making an interaction UI to come up but I want it to come up according to the input device you're using so xbox playstation or computer how can I do that

hallow cove
#

ok so I have no idea why this happens

#

but essentially, I have a Node object that holds a struct

#

and whenever I reopen the project or recompile scripts

#

the struct just resets?

sly grove
hallow cove
#

well

#

when the scripts recompile

#

the data in the structs gets reset

#

and then I can't display anything properly

#

it's all "corrupted" then I suppose

#

no it's not serialized

#

and half the things inside of it aren't serializable

#

here's the struct:

#
{
    public Type type;
    public MethodInfo methodInfo;
    public FieldInfo fieldInfo;
    public PropertyInfo propertyInfo;
    public bool isExposed;
}```
#

only the isExposed bool is serializable

#

the rest aren't

sly grove
hallow cove
#

uhhhhh

#

because I still forget variables not being serialized can lead to issues

#

the hell am I supposed to do then

sly grove
#

I don't know, what are you trying to do?

hallow cove
#

oh ok I found someone with the issue online

#

I just need to serialize the types

#

public SerializableMethodInfo method;

#

...

#

sure-

sly grove
#

Save the data in a serializable way that's all

#

Fully qualified type name, etc...

hallow cove
#

yeah

spring gorge
#

https://www.youtube.com/watch?v=EAMUBMX5qvI&ab_channel=UnityTutorialWorld
the trouble of this way is it spawn so much obj and is a big trouble for performance
the idea limit the obj can be spawned seem not good
there is any other idea?

Do not Click here=https://bit.ly/2JHk1cp
Fallow me on Facebook=https://web.facebook.com/UnityTutorial-World-112558163614944
In this video i will show you how to Instantiate Mask in unity with mouse or finger drag in unity

โ–ถ Play video
somber tendon
#

or graphic.blit

spring gorge
fallow dune
#

How can I get the surface normal angle in a 360 degree radium based on where the character stands and the raycast hits?

#

If I run into the wall infront of me, It should say 180

#

and if I run into the wall on the right, It should say 90

#

This should be calculated for any GameOBject I run into

obtuse remnant
#

@fallow dune can you just raycast?

fallow dune
#

I am Raycasting

#

but I need the angles

obtuse remnant
#

Hit normal?

fallow dune
#
 private void InCoverMovement()
    {
        
        if (_isAgainstWall)
        {
            _playerSpeed = 2.0f;
            
            float angle = Vector3.SignedAngle(_coverSystem.CalculateSurfaceNormalDirection(), _characterController.transform.position, Vector3.up); //Returns the angle between -180 and 180.
            
                if(angle < 0)
                {
                    angle = 360 - angle * -1;
                    Debug.Log(angle);

                }
        }else
        {
            _playerSpeed = 8.0f;
        }
    }
#

I want to return the wall angle and then do some logic based on that angle of the wall

#

ignore the nested if

#
 public RaycastHit RaycastHitCalculator()
    {
        RaycastHit hit;
        // Does the ray intersect any objects excluding the player layer
        if (Physics.Raycast(raycastPoint.transform.position, transform.TransformDirection(Vector3.forward), out hit, _raycastDistance, _layerMask))
        {
            // Debug.Log("Did Hit");
            // Debug.Log("distance from cover:" +hit.distance);
        }
        return hit;
    }
obtuse remnant
#

OK. So that gives you the angle relative to the player.
Then get the player facing direction. Combine them.

fallow dune
#

so with the above SignedAngle I then get my characters direction, add the 2 together ?

obtuse remnant
#

Yeah. But you probably need to do some geometry. I can't really picture it at the moment.

#

(On phone watching TV)

fallow dune
#

I get it. Ya I have tried a few things already. I have tried Vector3.Angle The Vector3.SignedAngle etc so I am kinda at my wits end.

obtuse remnant
#

You might have to do the maths yourself. I don't think there's a method that gives the answer.

#

Soh coh toa right angled triangles, if you remember those from high school.

fallow dune
#

ya, Cool. Let me give this a try

#

Thanks for the help

hallow cove
#

alright so, I have a big issue

#

so I finished my visual scripting editor

#

and now I need to somehow compile it

#

my first thought was to convert it to a C# script, but uhhhh

#

how do I turn this into code-

#

I know this is just transform.position = transform.position

#

it's not practical but that's besides the point

#

I see VRChat's UDON compiles to assembly directly, but I don't know how I would even do that-

sage radish
#

You can convert it to IL code directly. If you want to write it to a .dll, you need to use the Mono Cecil library. You can also emit IL at runtime with Reflection, but that only works on Mono, not IL2CPP.

hallow cove
#

what is IL

sage radish
#

It's what C# is compiled to, the code that is in C# .dlls

hallow cove
#

yeah but

hallow cove
#

@sage radish

sage radish
# hallow cove yeah no I don't really understand how I would take this and convert it to a dll

Mono Cecil can create a .dll if given IL code. In your case, the IL code would look something like

IL_0000: ldarg.0
IL_0001: call instance class Transform MonoBehaviour::get_transform()
IL_0006: ldarg.0
IL_0007: call instance class Transform MonoBehaviour::get_transform()
IL_000c: callvirt instance valuetype Vector3 Transform::get_position()
IL_0011: callvirt instance void Transform::set_position(valuetype Vector3)
IL_0016: ret
hallow cove
#

ohhhhhhhh

#

I see

sage radish
#

It's stack based, which should translate pretty easily from node based

hallow cove
#

yeah right!

sage radish
#

In order to call a method, you need to load its arguments to the stack first. That's what ldarg.0 is doing for example, loading this to call an instance method

valid estuary
#

So I'm trying to make a 2D submarine game where the submarine is able to correct its rotation when it hits something at an angle, returning itself to where it wants to be without overshooting and having a max turn speed.
I have tried this in FixedUpdate:

float rot = transform.eulerAngles.z;
if (rot > 180) rot = -360 % rot;

if (rot != 0)
{
    rigidbody.AddTorque(rotationForce * -Mathf.Sign(rot) * (Math.Abs(rot) / 180f));
}

But it overshoots slightly. I've looked into how I can use counterforces and found this on the Unity forums, trying to get it to use torque instead of velocity:
https://answers.unity.com/questions/195698/stopping-a-rigidbody-at-target.html
This hasn't been successful either. :<
So where should I start with this? I'm open to learning some extra maths for this, if anyone is willing!
Here's a video of where it's at right now, with its overshooting and wobbling:

obsidian glade
valid estuary
#

I could do that, but it won't look smooth, right?

obsidian glade
#

if you're setting the angular velocity proportional to the offset it will

valid estuary
#

So just lerping it? Kinda?

#

If I'm setting velocities, though, that would mean it wouldn't be affected by any collisions, no?

obsidian glade
#

no, lerp is linear

#

you don't need to set the velocity directly, you could apply force and then clamp the restorative velocity if it's too high

undone coral
#

there is no shortcut or alternative

#

you can find examples by googling "unity pid controller github"

valid estuary
obsidian glade
#

effectively what you're already doing by applying a correctional force proportional to the error

valid estuary
#

Right okay, I'll look into those

#

A lot of the theory and tutorials on it seem to be for 3D though, would the basics still apply for 2D?

obsidian glade
#

yes

valid estuary
#

Got it, thanks a lot!

#

Oh this is actually huge, okay!! This definitely looks like what I need, thanks so much :0

undone coral
#

you can start with the stuff people have done on github

undone coral
#

Mathf.Rad2Deg*(Mathf.Atan2(hit.z, hit.x) + Mathf.PI/4) should be it

#

but what is confusing to me is why you need these idiosyncratic values

#

just use the vector

#

and blend it

#

don't work in degrees

#

this is for an animation right?

#

you can use a 2d blend shape in the animation controller

#

and work with the hit vector directly

hallow cove
#

how can I get the screen mouse position in the unity editor?

undone coral
#

@fallow dune i think this isn't working because it's a bad idea

#

the way you are thinking about these angles doesn't make sense

fallow dune
#

@undone coral that was my first attempt. Have a float i.e player speed and then if the user is against a wall right in front of you, use the X axis to set the float from positive to negative and that will set the animations left or right

undone coral
#

maybe a simpler approach would be to put triggers on every wall, and label it "north" "south" "east" "west"

#

because that's really what it is

fallow dune
hallow cove
fallow dune
#

The whole issue I have is to have the player just hold the direction toward the wall and use the other axis to move the player along the wall.

#

if I hold A toward a wall on my left, use W or S to move up and down along the wall

#

If I hold W , use A and D to move left or right along the wall

undone coral
fallow dune
#

Exactly the same as what metal gear solid 1 , 2 and 3 does

undone coral
#

place a trigger on the wall

#

@fallow dune for example, here's the view from portal 2 in hammer editor:

#

observe they yellow regions. these are triggers

#

i am trying to find a screenshot from titanfall

#

but all the walls for wall running have triggers on them in titanfall

#

they design it in

#

they don't "raycast" and then "measure the normal" or whatever

#

they design the feature

#

does that make sense?

fallow dune
#

Ya, 100% . The thing that is troubling me is I am trying to recreate ps1 Metal Gear solid wall mechanic and although without animations it works perfectly, the issue comes in where I try play animations and that is where the wheels fall off. I have been stuck for about 3 days now so I think I will just have to redesign the system or go the trigger route like you mentioned

undone coral
#

are you using animation controller?

fallow dune
#

I am yes.

undone coral
#

the animation is symmetric... instead of thinking in xyz, think in "uv" where u is along the wall, v is the normal of the wall

#

those are your parameters

#

okay i gotta go

fallow dune
#

Other than the anims, the system works.

valid estuary
undone coral
#

is there an alternatige to hashset that produces no garbage for iteration?

random shell
#

how can i draw a wiremesh in playmode?

sage radish
undone coral
#

maybe because it's old

raw path
#

Hi there, can anyone help me out?
I have this situation:
I have 2 points in screen space and try to set a RectTransform as the "bounding box" across these 2 points, so that the line between the points becomes the rects diagonal
so I center the rect to the center of the line , then I get the X & Y distance from both points and use those distances for the size delta
but my result doesn't have the proper size
why would that happen?

compact ingot
compact ingot
raw path
compact ingot
#

try with these

raw path
#

the rect is being centered just fine,. it's just the size that's off

compact ingot
#

off by how much?

raw path
#

I try to set it through sizeDelta and it's off by like 1/4

#
Vector2 pointA = ...;
Vector2 pointB = ...;
float dstX = Mathf.Abs(pointA.x - pointB.x);
float dstY = Mathf.Abs(pointA.y - pointB.y);
rect.sizeDelta = nee Vector2(dstX, dstY);

something lile that

compact ingot
#

yes, that is obviously correct

#

the error is somewhere else

raw path
#

maybe something about the canvas scaler?

compact ingot
#

unlikely

raw path
#

I have set it to scale with screen size with 1080p as reference res

compact ingot
#

how do you get the pointA/B positions?

raw path
#

they're converted from world positions through Camera.WorldToScreenPoint or sth

compact ingot
#

well, if you are using a canvas scaler then world space will not map directly to screen space in an overlay UI

#

you could use RectTransformUtility.ScreenPointToLocalPointInRectangle on the rect transform of the canvas to get your screen-point to UI conversion

bold dome
#

Is there somebody here that is familiar with the TobiiXR Unity SDK, used for eye tracking? Specifically Vive pro eye

undone coral
undone coral
#

it is seemingly very simple

#

are you using a screen space overlay canvas? @raw path

undone coral
# raw path yes

get the world positions of the screen positions. inverse transform those world positions into the local space of the rect transform's parents. set the size delta to the difference of those local positions

misty glade
undone coral
#

i think you can try changiing the release target via the editor instead

misty glade
#

i think i've narrowed down the problem but i still don't understand it

undone coral
#

click on the little debug symbol in the lower right corner of the editor

#

and switch it there

misty glade
#

the pragma for UNITY_2017_3_OR_NEWER isn't defined in release mode for some reason

#

(i have to reopen/close the file because my intellisense takes forever when i have a lot running.. which i do)

undone coral
#

listen have you been watching my one emoji play or what

misty glade
#

i still don't understand, i have hundreds of script compilation errors

#

your one emoji play..?

undone coral
#

nevermind

#

it is pretty bizarre yeah

misty glade
#

heh

undone coral
#

i think don't mess with the mode

#

in vs

#

do it from the editor

#

nothing happened when you tried it from the editor?

#

also try regenerating the project files

misty glade
#

yeah, i suppose.. although my CI builder is building in release mode and getting other errors

undone coral
#

or maybe it's even that they're built in debug only if you have script debugging checked on

misty glade
undone coral
#

il2cpp release versus debug is different

misty glade
#

Yeah - I mean, that's what I was assuming, so I was thinking that I needed to try building locally in release mode, so.. I set that, and kaboom

undone coral
#

do you check your csproj files into git?

misty glade
#

yeah

#

er, lemme check.. as far as I know I'm not ignoring them

#

yeah, they're there

undone coral
#

you shouldn't check them in

misty glade
#

I did try regenerating the project files.. I even tried doing the "generate project files for packages" but that is.. I dunno, I don't think I want to go this route

undone coral
#

you want to nuke them all

#

including .sln

misty glade
#

I need to for my builder, I think

undone coral
#

and then regenerate it

#

hmmmmmmm

misty glade
#

I'm using the game-ci github action.. afaik i needs the csproj file?

undone coral
#

no

#

i don't know

misty glade
#

heh

undone coral
#

we wrote our own thing

#

but honestly unity CI is horrible

misty glade
#

agreed

undone coral
#

it's absolutely positively abject 100% total garbage

misty glade
#

i am so sick of fiddling with CI stuff, btw

#

we completed our raise (hooray, money) and I'm seriously debating my first engineering hire being a CI guy

#

CI/devops/azure/whatever

undone coral
#

@carmine light i don't think there's anything worse in the Unity Editor featureset than the experience of trying to build unity projects from the command line.

#

someone will have to hack or DDoS the unity cloud build service infrastructure in order to force them to start caring

#

although that's my speculation

#

i don't know what it would take to get them to care

#

i can't believe i'm saying this, but it's worse than xcode

#

it's worse than building for the app store via CI

#

that would put it on the lowest tier of horrible

#

like making people just dread it

misty glade
#

I had to make my own document with maybe ... 100 steps because even the automated CI deployment process is so fucking involved

#

"delete this dll file then readd it but only in the unity packages folder"

#

etc

undone coral
#

well it's 2022 and you still can't like

#

automate a mac

#

you can at least rent one from amazon

misty glade
# misty glade

also, ๐Ÿ‘† unity advertising package just fails to import properly so i have to manually add the DLL only for the automated build

undone coral
#

i think the underlying problem is that the developers use windows

#

and have the editor constantly open

misty glade
#

funny you mention that as well - my friend gave me his mac specifically so i can generate ios builds

undone coral
#

and are always polluting their thing with the side effects of opening the project with the editor

#

unity generates so much trash as a side effect of opening something

#

it is critical to how it works

#

and like, windows users don't command line

#

have you seen powershell? cursed is an understatement

#

and why would they? there's no deadline for builds

#

when builds take long bigco developers can eat another refrigerator sushi, at least for now

#

it's madness

compact ingot
#

call Nvidia, get them to care about Linux, the world will align itself for the better

undone coral
compact ingot
#

They wouldnโ€™t care even then

#

unless you give them the key to make it proprietary

undone coral
#

nvidia would support 1 superhuman developer to fix their linux thing, with 20 additional interns

#

and as long as they're all in china

#

i don't know it's tough

#

i don't know anyone in gaming who cares about vulkan

#

linux doesn't even have a modern compositor that's still maintained

#

HDRP vulkan on windows performs 50-100% worse than DX11/12

#

at least in my experience

#

nobody cares about android either

compact ingot
#

I guess there is just too much money to be made by having people deal with atrocities like windows development and unity Ci

undone coral
#

"android vulkan"

undone coral
compact ingot
#

I mean mediocre developers need jobs too

undone coral
#

lol

compact ingot
#

managers even

#

computing as a whole is stuck with so much tech debt, sunk cost and that whole platform lock-in perpetrated by everyone that things can never get better

undone coral
#

it's crazy how much the bad CI pisses us off

#

it is clearly one of the lowest hanging fruit in terms of developer productivity

#

this is coming from someone who runs a CI for unity as a service

#

we still haven't be able to figure out il2cpp in containers

compact ingot
#

/slap

undone coral
#

it's so fucking glitched

#

il2cpp builds are truly completely and utterly cursed

#

it doesn't even need to be this complicated. they should have emitted a cmake project from the get go.

#

but no.

#

they wanted to emit a platform specific thing themselves

misty glade
#

the gameci IL2CPP build (in containers) is working for me.. although it's horribly slow, like 30 minutes

undone coral
#

now they're stuck with Visual Studio as their compiler, which doesn't even install headlessly on a fresh copy of windows

compact ingot
#

you make me feel really glad my projects donโ€™t need any of that and I can live with a local deploy script

misty glade
#

I mean... "working"

undone coral
#

lol

#

yes

#

exactly

#

like it can finish building, and you will sometimes have a corrupt data.unity3d

misty glade
#

the hoops i have to jump through to get it to work every time are .. numerous

#

like literally what i'm dealing with now

undone coral
#

gameci means well

#

they are good at this stuff

#

but they are stuck at things like

#

"well we can't distribute the visual studio inside compiler tool inside the container because this piece of text says so"

misty glade
#

since the unity Ads thing is handled.. separately? then normal packages, the game-ci thing breaks so .. i have to figure out what my hack for this is going to be

undone coral
#

like seriously who gives a fuck

misty glade
# misty glade

๐Ÿ‘† Probably just manually dig up the dll and stuff it in the build? ๐Ÿคทโ€โ™‚๏ธ

undone coral
#

so there's no working standalone windows container image

#

the reason it works is because they are idiosyncratically bind mounting directories from the windows runners in github

compact ingot
#

CI without alround open source seems destined to be terrible

undone coral
#

which is, clearly, not sustainable

undone coral
misty glade
#

haha

undone coral
#

probably the part which downloads the platform binaries

#

everything for these guys is side effects

misty glade
#

there's like... 2 workflows for installing ads, neither of which works with each other

#

if you go to the package manager and try it, you get an old version

#

you have to magically use the special interface for it here

#

or here

#

but NOT here

undone coral
#

there's a nonzero chance

#

that when you use unity cloud build

#

there's straight up a guy in the philipines who opens your editor project

#

on one of their build machines

#

like RDPs in

#

because it is inconceivable to me how they make it work otherwise

#

it probably just does not a lot of the time

misty glade
#

re: the builds failing for setting release mode, btw - duh, didn't even think to look in the proj file for the symbol definitions:

#

OBVIOUSLY unity doesn't include the symbols in the release builds ๐Ÿ˜ฌ ๐Ÿ˜ฌ ๐Ÿ˜ฌ ๐Ÿ˜ฌ

timber depot
#

Hello, I'm back, regarding adding the colors. So i created the static class with all of my colors.

public class MyColor
{
public static Color Alice_Blue{get {return new Color(0.94f,0.97f,1f,1);}}
public static Color Antique_White{get {return new Color(0.98f,0.92f,0.84f,1);}}
public static Color Aqua{get {return new Color(0f,1f,1f,1);}}
...etc...etc
}
now i want to make it where you choose them as a drop down in the inspector. but i have not figured that part out.

misty glade
#
public enum MyColorEnum
{
  Alice_Blue,
  Antique_White,
  Aqua,
}

public Color GetColor(MyColorEnum type) => type switch
{
  Alice_Blue => new Color(0.94f, 0.97f, 1f),
  Antique_White => new Color(0.98f, 0.92f, 0.84f),
  Aqua => new Color(0f, 1f, 1f),
  _ => new Color(1f, 1f, 1f),
};

public class SomethingWithColor : MonoBehaviour
{
  public MyColorEnum TheColorOfThisThing; // dropdown in inspector
  public void Awake()
  {
      Color c = GetColor(TheColorOfThisThing);
      // use c wherever
  }
}
#

@timber depot

misty glade
#

I'm still having trouble building to Android using the GameCI github action. It appears as if the builder is rebuilding the library from scratch, but failing to see a dependency on com.unity.ads, so the package isn't drawn into the build:

And as a result, the build fails:

#

I've tried including the manifest.json and packages-lock.json in the repo, but that didn't help. Anyone know how to force unity to draw in a dependency?

I suppose I could just try manually including the DLL...?

austere jewel
misty glade
#

Yeah, I did.. a couple times over the last 8 hours, no dice. ๐Ÿ˜ฆ

#

I'm tacking it from the Unity side now.. trying to ... force the library rebuild to include the package

#

If I just stick the DLL in the plugins dir in source control, it should work, but then local builds fail/complain because of the "multiple references" thing

#

I also note that the ... plugins directory is gitignored, and there's a "special" android folder there that comes with a manifest.. I don't know a lot about building android apps, but maybe I should research that? something about generating the xml manifest...

austere jewel
#

Why would that package be special, is it a dependency of another package or something?

misty glade
#

I'm not sure, but .. the package isn't handled the traditional way in the editor.. See the conversation I had about with DrP - you don't add this particular package through the package registry, you add it through a one-off menu for unity services

#

I'm not sure if ... there's a bug in there? that's causing the command line library rebuild process to not see that dependency

#

As far as I can tell, I'm including the aab file properly:

#

no worries - thanks for reading my problem ๐Ÿ™‚

misty glade
#

Looks like that worked (manually including the DLL in the plugins dir and removing the package from the project). Super annoying because there's configuration (somewhere??) related to ads - game IDs that have to be defined in the web interface on the unity dashboard. I'll have to figure out where that nugget of configuration is stored

undone coral
#

you might want to create a new empty project

#

then make that change and see if anything appears in the diff

misty glade
#

No, I think I've .. narrowed down the problem. I couldn't put the DLL in the plugins folder because ... Unity apparently has some safeguards in place against calling certain unity namespace methods from "user code" (even if said user code is UnityEngine.Advertisements.DLL)

#

I just think the package manager can't find Unity ads 4.2.1, it thinks the latest is 3.7.5 so... I just am using that version, installed "normally" through the package manager .. doing a build now, we'll see what happens

kindred tusk
#

Does anyone have any advice for bundling another dependent UPM module within your own? My understanding is that UPM doesn't properly resolve dependencies.

#

I feel like the "most correct" approach would be to pull it into my repo and then perform a namespace transformation on it.

#

And ideally convert anything that was public to internal

#

But that's pretty annoying.

#

Another option would be to have the package as a peerDependency kind of thing, and force consumers to install both packages.

robust tusk
#

can i check the position where 2 debug draw lines collide?

thin mesa
jovial totem
#

like this

#

this will tell unity to also install that one

stuck onyx
#

Maybe i'm asking for the impossible but is there any way to do myCamera.Render() asynchronously ?

#

found something

unkempt moat
#

Hello !
So I'm a newbie in everything related to a server, but I'm trying to do a coop game.
However, I can't figure out how the server can know what I sent him was the name of a client, and how to attribuate it to a struct which contains every informations ?

Someone would have any hints about that please ?

Thank you !

#

I did code a server using TCP, which run in a terminal

kindred tusk
wintry magnet
#

I have a question in regards to serialization... I want to know how can I remove the tags I don't want so from p1 to p2; I will also paste my code

kindred tusk
#

What's p1 and p2?

wintry magnet
#

as in picture 1 to picture 2 :d

#
    {
        XmlSerializer serializer = new XmlSerializer(typeof(AnimatedImage));

        using (var stream = new StreamWriter("C:\\Avas\\etc\\aaaaaaaaaaa.xml", false, Encoding.GetEncoding("UTF-8")))
        {
            serializer.Serialize(stream, bla);
        }
    }```
kindred tusk
#

I think the second one is not valid xml because it lacks the header

wintry magnet
#

yeah but the thing is I don't want the header

kindred tusk
#

Have you googled how to strip the header using xml serializer?

wintry magnet
#

this

#

but I dont get it honestly

kindred tusk
#

Did you try it?

wintry magnet
#

yes

#

kinda works

#

but there are no

#

spaces or \n

#

it's all in one line

#

๐Ÿ˜ฆ

errant plinth
#

Sounds like you want to pretty print the results

wintry magnet
#

write to file

#

but yeah...

#

however I dont want it to be as XML

#

just normal text

errant plinth
#

Do you also want to deserialize the text?

wintry magnet
#

nah

#

dont care about that

errant plinth
#

You can create an XDocument and fill out the structure as you want.
Create an XmlWriter with some XmlWriterSettings where you have set OmitXmlDeclaration to true

#

Perhaps that's good enough in your case

wintry magnet
#

Yaaaaaay

#

I love you

#

it works

#

thankyou!

urban hull
#

hello everybody

#

i am working on a turn based battle system

#

i want this system to support multiple parties, but i have no idea of how i can approach creating a party of character maintaining this data persistent

sly grove
#
class Party {
  List<Character> characters;
}``` ?
urban hull
#

i did it but when i pass this data trough classes i get a null exception because im subscribing characters in instances

#

the problem is how i keep this data persistent through classes

#

creating separated classes for each party hard codes the amount of parties and make the singleton approach unnavailable

sly grove
#

but basically you just need to make a data model for it and stick with it

#

"how i keep this data persistent through classes" the answer to this is to serialize the data to a save file

urban hull
#
public class unit 
{
  party party = new party();

  public unit()
  {
    party.join(this); 
    //this method subscribes the unit using the instance 
  }
}
sly grove
#

You'll want to separate your data from your logic, that will let you cleanly manage the data

sly grove
#

how would you have a party with multiple units in it?

urban hull
#

thats what i want to know

#

i showed the code as an example of what i tried

#

what i want to understand i how do i keep a single instance of the party class with all units that subscribed to it

#

i also tried making it a singleton but since the party class is an abstract base class i cant make any derived class static

warm condor
#

Can someone help me with making it so after the player completes a level they get 10 coins.

warm condor
#

ok sorry

misty glade
#

8 hours of banging my head on a build yesterday and ... I've solved it but I'm not closer to understanding why. The package manager in unity isn't properly finding dependencies - I'm not sure if this requires the packages to be defined in the manifest or how else it gets them.. but it just doesn't work for com.unity.ads, so adding the package manually to the manifest and putting the manifest into the repo worked. ๐Ÿคทโ€โ™‚๏ธ

undone coral
#

is there a way to start a unity binary from the command line with "job control" on windows? this means the process is attached to the console, and signals like CTRL_C reach the console handler unity defines and closes the game. this works correctly on macos. in contrast, starting a typical unity binary in windows from cmd.exe or powershell backgrounds it; in busybox64.exe bash, it is attached but ctrl+c backgrounds it (it is ignored)

undone coral
#

game-ci doesn't require those checked in

#

this can cause references to seemingly be broken

misty glade
undone coral
#

did you abandon that release versus debug thing?

#

it didn't make sense

misty glade
#

I wasn't actually interacting with them - I was just trying to get this problem working, and I noted that the build was in debug mode and thought it should be in release mode

undone coral
#

you shouldn't have been interacting with that setting at all

#

i see

#

it was just diagnosing stuff

misty glade
#

Yeah, I was just... confused? that the symbols were only defined in Debug mode

undone coral
#

yeah

misty glade
#

(I'm still confused by it but it wasn't needed for me to solve)

undone coral
#

com.unity.ads i think is one of ht ebase modules and doesn't do anything

misty glade
#

As far as I understand it, both the mono and il2cpp build processes don't look at the visual studio project files at all

undone coral
#

that's correct they are ignored

#

this is distinct from exporting as a visual studio project

misty glade
#

Yeah so it's just a ... unity "bug" that the symbols aren't defined for release mode, but I suppose it doesn't matter because no one builds in VS for "release" .. they just use it for debugging

#

ie - putting your VS build into release mode doesn't really... make sense

undone coral
#

you can try deleting it and allowing unity to recreate it

misty glade
#

it wasn't - i rebuilt it from scratch at least a few times yesterday

undone coral
#

yeah

misty glade
#

etc

undone coral
#

i don't think you're doing anything wrong

#

it's just very haunted

misty glade
#

"lock file was modified"

undone coral
#

that's from your local build

#

?

#

you should check that file in

misty glade
#

no, that's the github action

undone coral
#

hmm

#

here let me share a .gitignore with you

misty glade
#

right - i mean, my debugging/learning for this was to remove the packages manifest and lock file, let the action rebuild the deps from scratch, and that's where i realized when it was doing this it was NOT finding the unity ads dep

#

i have a gitignore from some... public repo, I don't recall where i got it originally but mine has quite a bit of modifications in it now

#

I'm just .. confused that adding com.unity.ads (to the package manifest) is A) required and B) not done when adding the Advertisements package in the package manager in unity.. that feels like a bug

undone coral
misty glade
#

thx

undone coral
#

yes

misty glade
#

there might be clues on unity command line behaviour.. at least for linux .. in the gameci build action repo

#

i don't know if you want to go source diving down that route

undone coral
#

i'm trying to start a unity standalone player build from the command line

#

as opposed to the editor which behaves correctly

#

it seems to not attach to the console

#

no matter what

misty glade
#

hm... i manually attach unity console to unity logging, i wonder if there's some vice-versa ability in here

#

i think it's just for rerouting streams though, not SIGnals

#

(which is what you want, yeah?)

undone coral
#

no i mean

#

to a terminal window

#

on windows

misty glade
#

i know - i mean.. hang on, lemme look at the code, sec

undone coral
#

yeah

#

i mean it must be some invocation

#

i think i have almost everything i need to do it

#

with win32

#

it's just tedious to test

misty glade
#

(fwiw I do start my app locally using a batch file but.. the console window just closes after - ie, the call to player returns immediately and starts the gui)

#

mine omits (omitted) packages/

stuck onyx
#

i'm desperate trying to find a way to render my camera by portions, anybody could give me a hint?

misty glade
stuck onyx
#

im using:

#
  var matrix =  Matrix4x4.Ortho(left, right, bottom, top, near, far);  
                snapCam.projectionMatrix = matrix;
                snapCam.Render();
#

so i can get a texture from a little part of the screen

#

like... i want to create a 'satellite view' of all my map

#

but its too big

#

so i have a camera on top (orthographic)

#

and i enable it and i take 16 different snaps (portions of the map)

#

4x4

#

but the snapCam.Render() is still too heavy, and i think its because its rendering the whole map every timme

#

the result of the code above its a portion of the map, but its as much as heavy as if i render the whole map

#

so im guessing internally unity renders all, and then takes a portion (the matrix) out

#

what i do with that is take snapshots of all the sections 4x4.. and then i put the textures in a plane... so is sort like a google mmaps

misty glade
#

perhaps - I would imagine you have to be more "intentional" about what is enabled/disabled

#

perhaps a more performant approach (although probably quite a bit more work/difficult) is to make a separate area that renders only the important stuff of the "real" world and have a camera pointing at that

stuck onyx
#

but the part of the snapCam.Render() is still to heavy and i think its because i cannot just render just a portion

misty glade
#

isn't that what culling is supposed to handle for you? not sure about that, haven't done anything like that before, sorry

stuck onyx
#

its a city builder, i update areas depending on where the player builds or destroys

#

culling is by layers

#

and i use it, just render certain objects

#

but what i want to do is just render an area ... like a Rect

#

that way would be faster because right now when these areas have lots of buildings the Render() operation is too heavy

#

but as I said, i think its because unity is not rendering just a portion, its rendering all

#

if i could tell somehow just render this part of the map somehow

#

look

misty glade
#

you've already explored CullingGroup?

stuck onyx
#

this is the full map from ttop

misty glade
#

i understand the problem.. (cool looking game, btw).. I think you need to manually handle your culling, though

stuck onyx
misty glade
#

like setup a bounding rect/sphere, add it to the culling group, and put a camera on that group

#

you probably ought to read up on it ๐Ÿ™‚ i'm not an expert in it.. i just know vaguely that culling and culling groups exist and are probably what you need

stuck onyx
#

okay, its a hint, thanks a lot @misty glade

#

btw you can find the game in appstoe

#

appstore

#

its called super citycon

misty glade
#

do i look like i have time for playing games? ๐Ÿ˜‰

stuck onyx
#

heheh no, neither do I

#

๐Ÿ˜„

pine topaz
#

What is the best way to record some data based Timestamp and play that ?, forexample starting to record player mouse inputs on level start and replay it on ghost player prefab with the same timestamps (like player clicks on 5th seconds so ghost player clicks on 5th second)

undone coral
#

is your gameplay for platformer ghosts? is it specifically recreating the exact inputs?

pine topaz
#

yeah its platformer so i need exact inputs at exact time

pine topaz
undone coral
pine topaz
#

idk im using an external input controller and its probably using the native one

#

its not important actually casue i can get every input with the events so i can get the same inputs for listening same events on recording phaze

regal olive
pine topaz
pine topaz
# regal olive Less spaghetti? https://paste.ofcode.org/Stw33iV8Km4VBwvaxhC6SV

Yeah a bit less :D, but u can seperate logics into functions like

public void GenerateRoom()
{
  GenerateFloor();
  GenerateWalls();
  GenerateWindows();
}

With this way ur code will be more readable and easy to undestand, also there is a huge bonus for debugging like if something wrong with the windows u dont have to check all 140 line, if we came up to ur answer yeah we can say this is a good solution but always can be improved for further features or different projects

regal olive
compact yarrow
#

Hi there, got an issue when using Animator.Rebind().
I iterate over all layers to get the current AnimatorStateInfo and store the current fullPathHash. After calling Rebind I iterate again over all layers and call Animator.Play(fullPathHash[i],...) but this seems to have no effect. The character in question is still in the entry animation of each layer.
Got it from here: https://answers.unity.com/questions/1104298/anyway-to-keep-the-animation-state-after-calling-r.html
Any ideas, how to restore the animation states after calling Rebind?

urban warren
pine topaz