#archived-code-advanced
1 messages ยท Page 201 of 1
Ooh, interesting.
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
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.
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
Yes, this is a very non-beginner problem that's going to require some programming chops and unity chops
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
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
You don't want to use flags for values that can only be one "value" at a time
Better is to have a non-flag enum for the targets and then select off of that
Can they be only one value at a time though?
well the example you gave indicates.. yes? I dunno, you tell me ๐
If they are only one value, than a simple dictionary solves it?
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
Yeah, but why would you waste time querying? You could just cache it in a dictionary
i'm assuming you would just query when the player casts the spell or whatever
I guess it depends on what OP had in mind
That was my idea from the start
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
To query it on the selection
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
Ideally, it would be good to have properties on the unit, so then you can make a sphere selection and loop with certain conditions
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
But what if you want to find the closest enemy unit
You have to loop through all units
Or select all enemy units in react
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
It is how we did it in warcraft 3 :)
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
This looks better to me than inheritance for sure
Looks like the most viable option based on the responses
They can't be one value at a time
Every category will have a sub
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
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?
Initially I have two categories: Team and ObjectType. ObjectType can be Unit or Structure. Unit can be Hero, Minion, Boss. Structure can be Tower, Base..
I might want to change them in game
And add more categories/sub categories later
for editor scripting, what is the difference between base.OnInspectorGUI(); and DrawDefaultInspector();
I guess DrawDefaultInspector is related to Unity's default inspector (the same default inspector for every object), but by using base.OnInspectorGUI you can have inherited custom inspectors
ok, but if there is nothing to inherent then they are virtually the same?
I guess so
ok thank you for the explanation.
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?
Yes use a Raycast to get the surface normal
is there a better way to make it look normal in scene?
IK for the feet, using raycasts like Praetor mentioned
thanks
So, let's say I have an AI script, which has a certain logic with priorities. AI will attack the closest enemy. For this, I need to constantly check if enemy is nearby. Is using LINQ is still okay in this instance?
Priority order
I will need to query for each priority
Linq would be a little heavier than a regular loop with a condition inside, but it's ultimately up to you wether that performance cost is tolerable or not.
Also, what about periodic spells? The ones that select all units in range 300 and deal damage. You need to constantly check who is in range and what type they are
For me, it is difficult to judge
If players will not lag, i am fine with it
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.
Then do tests, profile. See if it lags or not.๐คทโโ๏ธ
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.
I see. I will try it using linq and see
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
Inheritance or interfaces? Maybe just a property that defines the type? Many ways to do it.
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!
Issue aside, BinaryFormatter is unsafe and shouldn't be used anymore.
Read https://docs.microsoft.com/en-us/dotnet/standard/serialization/binaryformatter-security-guide for more information
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
it says that alternatives, I should use XML or Json, but thanks for the help!!
as i know, application.persistentDataPath works on android, but even i tried to make a custom dictionary, it still gave the same error
I'm pretty sure "Saves" isn't already under that path. Maybe you want something like Application.persistentDataPath + "/" + directoryName
if you noticed, that i have 2 commented lines of code,
the uncommented saves in "User"/AppData/LocalLow/CompanyName/TankGame (name of the game)/SaveGane
meanwhile the commented one saves in
Unity/Unity projects/Tank Game(name of my game)/Saves/saveGame
So it doesnt really do much other than just changing the directory that the file saves
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
Anyways, Im not using the directroyName, since i commented it
ive commented out "if(!Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName);" didnt fix anything, same error
considering the error included CreateDirectory, I highly doubt it is the same error
I mean, this error did disappear, but it didnt fix the other errors
and my saving and loading doesnt work on android
any help?
What specifically do you need help with? What sort of progress have you made on this so far?
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!
This may be of help, i've used it to implement an isometric ("Cubed") terrain with soil variability
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
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
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
Well, pretty much. Then I can read the code and understand whats going on.
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)
What consumes battery? Answer: usage of cpu, gpu, screen etc.
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
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
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
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?
no clue, consider posting in #archived-networking though
Ok thanks
@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).
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)
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;
casting from object unboxes it and as for casting from an interface, i think that depends on whether or not its a value type (value types will be boxed and unboxed here as well afaik)
so both appear to be the same performance to me, but i'm not too knowledgable about the intricacies
Okay, that is what I was thinking but wasn't completely sure. Thanks!
no problem
it's telling you what the error is
there are a lot of reasons why you might not save in that directory
i don't think so. i think in il2cpp it will do exactly what it would do in C++. i'm not sure if they optimize sealed which would be the only way to make a cast from an object perform better
Alright thanks as well!
U guys familiar with AnimationCurve keyframes reduction (in runtime)?
my understanding is the costs are related to virtual methods
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
i think that's the limitation
Yeah, I figured. ๐ฆ
I've already "not asked to ask". Just roll up the chat:
#archived-code-advanced message
.. it seems like you said "nvm" in response to your question..?
Bottom one
This isn't really a question, but more of a statement..?
Simplifying translation and scale is "easy". Quaternion curves simplification is a mistery to me
What you said wasn't a question, it was a statement.
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
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..?
Just looking into methods to simplify 4 AnimationCurves (X,Y,Z,W) that represents Quaternion rotations
@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
Right - but you shouldn't gradually increment the values to do animations, you should s/lerp between quats
there's literally a quat method just for that.. https://docs.unity3d.com/ScriptReference/Quaternion.Slerp.html
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?
use your best judgement, probably 5-10 lines is fine, more is pastebin
Like 20 lines
This is a very lame implementation I'm working with:
https://pastebin.com/fyxAgJ8q
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Just cloning the AnimationCurve I'm working with, removing the given keyframe, and comparing it with the original
how's the animationcurve created?
this seems very weird
I'm assuming the curve is created with some library or something you've found..?
OK.. so why are you trying to remove keyframes from it after...? like, why not just create it with fewer keyframes?
Not Mecanim ones
I could do that by decreasing the sample interval, the problem is that I could miss some important keyframes in the way (that is for my runtime 3D importer)
I'm literally baking the animation in runtime
removing keyframes from a curve might do really weird things where it rotates like.. super abruptly between keyframes because of how quat slerp works..
I guess that is the problem. I know Unity does that internally, and it handles rotations as Euler Angles to do that (as far as the docs says)
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
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
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)
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.
Because of the way the original 3D models I imported were created, I need to bake the rotations to import them correctly
Thinking better now...
I can do that with the original euler data I get from the model....
euler is best er
Other 3D file formats I'm working with don't use Euler Angles at all, so a general "Quaternion-friendly" solution would be better...
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
i think 99.999% of quest developers use sidequest
are you?
ODH
?
oculus developer hub
either way the issue is that my request for userid and displayname succeeds but the result are empty strings
i mean for the purposes of sideloading an apk so you can develop easier
i use ODH for sideloading
oh
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?
you can simple points on animation curves and draw spheres or cubes to simulate one, unity have a draw bezier function but it won't be very accurate due to transfer from an animation curve to bezier curve is hard
i think animation curves can only transport you through time and space, not gameobjects
anyway don't overthink this. you can sample the animation curve in small pieces with the gizmo and call it a day
My LoadLevelAsync() is causing a kind of gnarly burp on the main thread (200ms) - is this pretty much unavoidable?
It's probably caused by scripts initializing in the scene on awake. If you want it to be truly async, you'll need to make sure that your scripts initialize async as well.
Yes, as I said everything will be in screen space within a UI Canvas. Just can't figure out how to calc all the vector stuff and convert to screen coords for icon movement :(
I typically just draw on a canvas, set it to some reference resolution that makes sense for my app, then let the app rescale it as needed for various devices - if that's the case then you only ever need to use localPosition - or if you do everything in 2d you can just center your UI in world space at the origin and then use position instead of localposition
Is it possible to display an Android View within a Unity scene?
Or rather, frame an entire Android app (packaged inside my Unity Android app) inside a 3D scene?
[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?
does anyone know how I could get this in my graph view?
Just calculate it, it's not hard
you can calculate the angle easily with Mathf.Atan2(y,x)
distance with vector2's magnitude
Make a custom mesh, there's an api for that
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
ok thanks!
alright, was just wondering if there was a dedicated function to do this stuff or not. thanks!
I don't think you understand what i'm trying to do. UI development is NOT the issue, calculating Transform Rotation & VelocityVector to Screen Coordinates is.
does anyone have experience with ML-Agents? would need a bit of help
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)
๐ฌ
I make my entire game in a subfolder because every asset on the store puts stuff in random folders! Usually I name it zGameName so it appears on bottom
_ works well for top
this isn't an advanced question - ask in #๐ปโcode-beginner or #archived-code-general - but... the error message tells you the error. You're trying to put a float into a box collider or vice-versa
It's an idea but there's a bunch of special behaviour folders that I can't/shouldn't move around - plugins, resources, etc
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
I just .. made an empty unity project, imported all his stuff into that, put it into a subdirectory, exported, and then imported that into my main project. Pain in the butt but this appears to be a unity non-feature going back at least 9 years ๐ฌ https://forum.unity.com/threads/is-there-a-way-to-import-a-package-to-a-specific-folder.173393/
Yep oof
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");```
rip..
2606 batches? tf
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..?
no this stopwatch is just a main script in the scene for timekeeping
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
I can't seem to narrow down what's causing so many batches
that is a lot of batches there.. 92,000 ๐ฌ
i only have uh... 500 in my loading scene with ... like.. hundreds of objects
what's the tooltip in the batches in the profiler
"batches count"
or triangles count maybe?
500 tris, 6 batches, 4 setpass calls
vert/tri count
i can't quite tell what your colors are since your play mode color is a little ... intense ๐
unfortunately this is a bit above my pay grade.. not sure how batches really works in unity
haha yeah that's why I posed in #archived-code-advanced
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.?
i'm assuming you've read this page https://docs.unity3d.com/Manual/DrawCallBatching.html
obvious questions - are you (not) sharing materials? what pipeline are you using? are you mirroring any transforms?
Yeah .. it's mostly an empty level with probuilder meshes with some textures, I don't even have AI or anything... I've made more complex projects with ease, Not sure what's going on here.
I'm using standard Built-In pipeline
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
quick question, I have a PropertyInfo variable, and I wanna know if it's a Get or Set type
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:
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.
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
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.
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
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();
}
}
}
When converting a Quaternion to Euler representation, there is no way to represent a full-range (180 degrees or more) rotation, right?
what is your objective
the result of that conversion quaternion to euler conversion is idiosyncratic. you can look up the source to it online or google it
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
hmm... why are you simplifying animation curves
at runtime
For my model importer
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?
It does work on every platform
yes but is that important
Yes, it is
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
Nah man. That is for my importer on Asset Store ๐
that's what i'm trying to say
It is valuable
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?
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
yeah, the general solution is running the editor as a backend service
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
yes but why
Correct, one of the many limitations of euler
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?
the thing is that for creating new physics shapes that are not just the the once that allready exist
you would need Source code access to even have a chance at that
The physics engines (2D / 3D) have only a limited set of shapes that they support
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
So I built this same custom physics shape before for Canon physics in JavaScript many years ago (https://github.com/spiderworm/rocket-riders/blob/master/physics/BoundaryCannonShape.js). I'd hoped I'd be able to do something similar with Unity. It's like a Rocket League arena shape, a big box shape with rounded corners... and all the gameplay happens on the inside of the shape, not the outside.
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
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?
you can use vhacd to build simplified, convex collider meshes
what is the gameplay for something being spawned "inside" something else
its bomberman style, press space and spawn a bomb under you that explodes after 4 seconds, everythings on a grid so i need a way for it to no collide on spawn inside of the player but recollide when you leave to overlap zone
use collision layers
why does the bomb need to be physics anyway
everthing on a grid
I'd say use the grid coordinate and dont use physics at all
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.
also, how would i use collision layers to determine when a bomb and a player are no longer colliding?
why would you need to
you could use a distance
explain
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
yeah, also it's possible for the player to be in two grid spaces at once since there's free movement
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.
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.
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
that's a good idea.
you can(or need to?) use shader for multiple texture. Then use world position y to decide which texture to show
are you procedurally generating a unity terrain?
by drawing a height map?
nope, generating a model in code
spawning a bomb shouldn't cause any significant amount of overhead
bomberman was written for super nintendos
Thanks, I'll start reading up on shader documentation
hmm... why?
why aren't you generating a heightmap?
and using pre-existing unity terrains?
is there a limit for how big terrains can be?
well...
i think you know the answer to that question
you should use Unity Terrains
there's no value to an alternative to unity terrain
in my case, unity's terrain doesnt perform well on mobile, that's why I use 3d mesh grids instead
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.
gaia pro comes with an approach to deal with floating point errors due to transforms greater than 1,000 in a dimension
you should probably start by buying that
it will introduce you to a lot of important ideas in large world terrains
My rough solution to this was to move the world instead of the player.
i agree you can reinvent gaia pro
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
I have summer off so I wanted to try my best at a large project, and procedural generation is something I was interested in.
Not really thinking of getting this done, but hoping to learn.
i see
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
did you watch this https://www.youtube.com/watch?v=wbpMiKiSKm8&list=PLFt_AvWsXl0eBW2EiBtl_sxmDtSgZBxB3?
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...
if you can't do that, you won't make a nice looking procedural one
I'd like to note that using this approach might means that you cant use static batching anymore
i don't think there's any value in ugly procedural terrains, from an educational point of view
and calculate texture can be done in shader totally if it is just base on 1 or 2 values
I have a while ago, should probably rewatch it.
learning how to generate a procedural terrain.. i mean you can certainly get the psychic experience of learning something, without learning anything at all
i think that terrain looks hideous
well yeah, but at the scale I am going for doing it by hand is impossible.
here's some cool looking stuff - https://www.world-creator.com/gallery.html - a lot of great terrain is a mix of procedural and hand-done stuff, understanding environmental art generally, like lighting, postprocessing, props, etc.
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
i am trying to say that there's no value in 1,000km x 1,000km of ugly terrain
surely you see that
you can go and make this error
My favorite game is Daggerfall
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
Oh sorry I misunderstood you I think? I am starting small trying to make a small area look nice, then I would need to learn how to extend that to a larger scale.
try to do it by hand first though
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
yeah yeah I get you
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
daggerfall is fun
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.
Really is, I absolutely love the sense of scale in it.
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
hello guys. is it possible to change unity's unit scale for an entire project ?
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
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?
Is the struct serialized? Why are you expecting it not to reset?
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
If it's not serialized why would you expect it to retain data between domain reloads?
uhhhhh
because I still forget variables not being serialized can lead to issues
the hell am I supposed to do then
I don't know, what are you trying to do?
oh ok I found someone with the issue online
I just need to serialize the types
public SerializableMethodInfo method;
...
sure-
yeah
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
render to texture
or graphic.blit
it seem so new to me, do you recomment any video to follow?
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
@fallow dune can you just raycast?
Hit normal?
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;
}
OK. So that gives you the angle relative to the player.
Then get the player facing direction. Combine them.
so with the above SignedAngle I then get my characters direction, add the 2 together ?
Yeah. But you probably need to do some geometry. I can't really picture it at the moment.
(On phone watching TV)
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.
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.
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-
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.
what is IL
It's what C# is compiled to, the code that is in C# .dlls
yeah but
yeah no I don't really understand how I would take this and convert it to a dll
@sage radish
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
It's stack based, which should translate pretty easily from node based
yeah right!
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
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:
just check its current rotation and if it overshoots, set the exact rotation and angular velocities to 0
I could do that, but it won't look smooth, right?
if you're setting the angular velocity proportional to the offset it will
So just lerping it? Kinda?
If I'm setting velocities, though, that would mean it wouldn't be affected by any collisions, no?
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
you have to use a PID controller
there is no shortcut or alternative
you can find examples by googling "unity pid controller github"
I looked at that, but got confused :')
What exactly do they do?
effectively what you're already doing by applying a correctional force proportional to the error
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?
yes
Got it, thanks a lot!
Oh this is actually huge, okay!! This definitely looks like what I need, thanks so much :0
you can start with the stuff people have done on github
it's not clear to me why this is so challenging. the hit normal in xz space corresponds to the angle
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
how can I get the screen mouse position in the unity editor?
@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
@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
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
You might actually be right
just, in the entirety of the editor
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
i'm not sure if there's anything out of th eordinary about what you're describing
Exactly the same as what metal gear solid 1 , 2 and 3 does
most games with special behavior with walls
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?
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
what do you mean
are you using animation controller?
I am yes.
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
Thanks so much for suggesting this! I managed to get it working by watching this tutorial https://www.youtube.com/watch?v=y3K6FUgrgXw
looks great
is there an alternatige to hashset that produces no garbage for iteration?
how can i draw a wiremesh in playmode?
HashSet has a struct enumerator that doesn't appear to allocate anything.
unusually in unity .GetEnumerator does, at least according to deep profiling
maybe because it's old
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?
you may have to double-check your local scale (1,1,1), anchors (0.5, 0.5) and pivot position (0.5, 0.5)
it's just default center, wdym?
are these your settings?
yes
try with these
the rect is being centered just fine,. it's just the size that's off
off by how much?
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
maybe something about the canvas scaler?
unlikely
I have set it to scale with screen size with 1080p as reference res
how do you get the pointA/B positions?
are you using https://docs.unity3d.com/ScriptReference/RectTransformUtility.ScreenPointToLocalPointInRectangle.html or something to a similar effect?
they're converted from world positions through Camera.WorldToScreenPoint or sth
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
aight, I'll try that thanks
Is there somebody here that is familiar with the TobiiXR Unity SDK, used for eye tracking? Specifically Vive pro eye
unfortunately there is no easy answer for this
didn't work out unfortunately
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
Any idea what would cause this behaviour..? Changing the build target shouldn't have any impact on this..? I'm getting syntax errors when I change to release mode
pretty weird
i think you can try changiing the release target via the editor instead
i think i've narrowed down the problem but i still don't understand it
click on the little debug symbol in the lower right corner of the editor
and switch it there
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)
listen have you been watching my one emoji play or what
i still don't understand, i have hundreds of script compilation errors
your one emoji play..?
heh
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
yeah, i suppose.. although my CI builder is building in release mode and getting other errors
the mono assemblies are always built in release mode if development is not checked, otherwise they are built in debug
or maybe it's even that they're built in debug only if you have script debugging checked on
il2cpp release versus debug is different
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
do you check your csproj files into git?
you shouldn't check them in
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
I need to for my builder, I think
I'm using the game-ci github action.. afaik i needs the csproj file?
heh
agreed
it's absolutely positively abject 100% total garbage
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
@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
funny you should mention that, that's exactly what i'm doing right now
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
well it's 2022 and you still can't like
automate a mac
you can at least rent one from amazon
also, ๐ unity advertising package just fails to import properly so i have to manually add the DLL only for the automated build
i think the underlying problem is that the developers use windows
and have the editor constantly open
funny you mention that as well - my friend gave me his mac specifically so i can generate ios builds
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
call Nvidia, get them to care about Linux, the world will align itself for the better
"yes i'd like to talk about linux... no, i don't want to buy 20,000 710 GTs..."
They wouldnโt care even then
unless you give them the key to make it proprietary
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
I guess there is just too much money to be made by having people deal with atrocities like windows development and unity Ci
"android vulkan"
unity cloud build is almost certainly run at a loss
I mean mediocre developers need jobs too
lol
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
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
/slap
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
the gameci IL2CPP build (in containers) is working for me.. although it's horribly slow, like 30 minutes
now they're stuck with Visual Studio as their compiler, which doesn't even install headlessly on a fresh copy of windows
you make me feel really glad my projects donโt need any of that and I can live with a local deploy script
I mean... "working"
it works for some games
lol
yes
exactly
like it can finish building, and you will sometimes have a corrupt data.unity3d
the hoops i have to jump through to get it to work every time are .. numerous
like literally what i'm dealing with now
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"
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
like seriously who gives a fuck
๐ Probably just manually dig up the dll and stuff it in the build? ๐คทโโ๏ธ
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
CI without alround open source seems destined to be terrible
which is, clearly, not sustainable
i'm sure it's because a part of unity ads is initialized as a side effect of opening the editor UI
haha
probably the part which downloads the platform binaries
everything for these guys is side effects
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
the editor suffers from MPD
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
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 ๐ฌ ๐ฌ ๐ฌ ๐ฌ
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.
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
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...?
I would ask on their discord if you haven't already http://game.ci/discord
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...
Why would that package be special, is it a dependency of another package or something?
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 ๐
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
you've never seen any detritus appear in git for that right?
you might want to create a new empty project
then make that change and see if anything appears in the diff
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
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.
can i check the position where 2 debug draw lines collide?
don't crosspost
You're supposed to add the dependency to the asmdef
like this
this will tell unity to also install that one
Maybe i'm asking for the impossible but is there any way to do myCamera.Render() asynchronously ?
found something
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
I'm pretty sure that's just a project local reference. I think the reference would be broken if, for example, the asmdef was from a GitHub dependency
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
What's p1 and p2?
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);
}
}```
I think the second one is not valid xml because it lacks the header
yeah but the thing is I don't want the header
Have you googled how to strip the header using xml serializer?
I am trying to get communicate to a payment processor. When I use XmlSerializer.Serialize
on my object I get
<?xml version="1.0" encoding="utf-16"?>
<txn xmlns:xsi="http://www.w3.org/
this
but I dont get it honestly
Did you try it?
Sounds like you want to pretty print the results
write to file
but yeah...
however I dont want it to be as XML
just normal text
Do you also want to deserialize the text?
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
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
class Party {
List<Character> characters;
}``` ?
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
i don't know what you mean by "im subscribing characters in instances"
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
public class unit
{
party party = new party();
public unit()
{
party.join(this);
//this method subscribes the unit using the instance
}
}
I think that's probably a bit too closely coupled to your game logic
You'll want to separate your data from your logic, that will let you cleanly manage the data
this also doesn't make sense - it implies every unit has their own party
how would you have a party with multiple units in it?
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
Can someone help me with making it so after the player completes a level they get 10 coins.
ok sorry
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. ๐คทโโ๏ธ
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)
i think your project is a little cursed because you're modifying / interacting with csproj files, which you shouldn't be doing
game-ci doesn't require those checked in
this can cause references to seemingly be broken
I'm not - I took those out of the repo specifically yesterday
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
you shouldn't have been interacting with that setting at all
i see
it was just diagnosing stuff
Yeah, I was just... confused? that the symbols were only defined in Debug mode
yeah
(I'm still confused by it but it wasn't needed for me to solve)
com.unity.ads i think is one of ht ebase modules and doesn't do anything
As far as I understand it, both the mono and il2cpp build processes don't look at the visual studio project files at all
that's correct they are ignored
this is distinct from exporting as a visual studio project
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
it's possible also that your packages lock was broken
you can try deleting it and allowing unity to recreate it
it wasn't - i rebuilt it from scratch at least a few times yesterday
yeah
"lock file was modified"
no, that's the github action
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
thx
also sorry to hijack your question - but I assume you checked out this page already? https://docs.unity3d.com/Manual/PlayerCommandLineArguments.html
yes
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
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
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?)
i know - i mean.. hang on, lemme look at the code, sec
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
nope, this is just stream redirection.. sorry, I thought it was something else. https://www.jacksondunstan.com/articles/2986
(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)
https://www.diffchecker.com/g4ALQC02 yours (left) is pretty close to mine (right)
mine omits (omitted) packages/
i'm desperate trying to find a way to render my camera by portions, anybody could give me a hint?
what do you mean "by portions"
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
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
but the part of the snapCam.Render() is still to heavy and i think its because i cannot just render just a portion
isn't that what culling is supposed to handle for you? not sure about that, haven't done anything like that before, sorry
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
you've already explored CullingGroup?
this is the full map from ttop
i understand the problem.. (cool looking game, btw).. I think you need to manually handle your culling, though
does this culling work by location?
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
okay, its a hint, thanks a lot @misty glade
btw you can find the game in appstoe
appstore
its called super citycon
do i look like i have time for playing games? ๐
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)
there are a lot of ways to do this
is your gameplay for platformer ghosts? is it specifically recreating the exact inputs?
yeah its platformer so i need exact inputs at exact time
i saw few methods to do it with transform positions, rotations or rigidbody velocitys but in my case inputs is best way to do it
do you use input system
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
Is this a good solution to creating a room with walls thats scalable and with windows? https://paste.ofcode.org/rz7jUZyeX8HSXNNQ7GXXwt
i believe u can make it more readable, its just spaghetti right now
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
But the walls relies on the floors for loop and just checks if its on a edge or not, so that way wouldnt work.. but i could have a GenerateWalls(int i, int j) in the for loop for the floor, or how do i it so its independent and dosnt use the for loop
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?
Something else that I find helps with code readability is to name the for loop variables x and z instead of i and j as that tells you what they are actually used for.
Also, yeah passing params to methods and having separate methods would help a lot.
ok thanks
@urban warren gives a good answer also u can use recusive calls for making loops
what is a recusive call?