#archived-code-general
1 messages · Page 262 of 1
Correct me if Im wrong but the amount of subscribes does matter and its not cheaper or identical to lets say a method call
events flew over my head when thinking this, i could try, thanks
Why are you worrying about optimizing 22 walls ?
how the array element looks like doent affect the length of the array
i have a large number 12345678987654321 store in a long long[], it is still one element
you are not taking into account the processing time of the array/list/dictionary
I dont have the time to test it right now but Im willing to bet iterating a array of 1000 elements is significantly faster than invoking a event with 1000 subscribers
those 22 walls have almost 4k cubes in total
Well you still have to worry about just 22 objects
that is very bad design
Each wall can hold its cubes as children
Maybe he wants to destroy his walls in some way we dont know
each wall should have 1 cube unless there is a damn good reason for it not to have
Yeah, so that number of cubes won't be much of an issue. But you can do this pretty efficiently by simply grouping the walls into hierarchies where either each wall segment has the same parent object or each cardinal direction is stored into a common hierarchy. Disable the parent object and all children will be skipped.
i wanted explosions to affect walls, but having one cube per wall and 2 meshes, a full one and a broken one is also a possibility
You can replace the wall segment being exploded into cubes when it's being exploded.
And dont forget to object pool 🤣
absolutely
I think I have optimized more things with object pooling than anything else in my career
4k cubes all things considered is still not a lot.
i will try and test both approaches, grouping in object hierarchy then disable the parent and one big cube per wall exploded into cubes
For mobile I would consider it a lot
thank you guys
honestly the biggest optimization is just using event delegates to avoid calling a function an unnecessary number of times
Turns out there is less work to do when you just… don’t do as much work.
But that’s more of an architecture thing.
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
the cubes on the borders are filled, the inner cubes are quads
applies to both floors and walls
Would anyone be able to help with fiddling with this tutorial : https://github.com/zigurous/unity-pacman-tutorial
In the tutorial the guy decides to just rotate pacman around instead of changing the actual sprite animations and I'm just not sure what the best way to do that would be based on what he's got going on. I need different animations because my team is making a sort of 2.5D pacman and would need 1 animation for each direction.
is it possible to slerp/lerp in ECS?
sure. those are just math functions
this will be Burst-compatible
slerp is also available
Hello Im looking for someone who knows unity who can eventually help me in a vc since I have some problems
just ask your question here. nobody is going to join you in voice chat to help you with an unknown issue
https://dontasktoask.com
also don't crosspost
new problem: When I start the game the zombies now fall into my turret and do not follow the waypoints anymore. I also would like to know how I can make the turret automatically aim at the zombies. this is the code right now
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Tower : MonoBehaviour
{
public float range = 10f;
public float fireRate = 1f;
public GameObject projectilePrefab;
private Transform target;
private float fireCooldown = 0f;
void Update()
{
if (fireCooldown > 0)
{
fireCooldown -= Time.deltaTime;
}
if (target == null || Vector3.Distance(transform.position, target.position) > range)
{
// No target in range, find a new target
FindNewTarget();
}
if (target != null && fireCooldown <= 0)
{
// Rotate turret to face the target
RotateTurret();
// Shoot at the target
Shoot();
}
}
void RotateTurret()
{
Vector3 targetDirection = (target.position - transform.position).normalized;
float angle = Mathf.Atan2(targetDirection.y, targetDirection.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
}
void FindNewTarget()
{
Collider2D[] colliders = Physics2D.OverlapCircleAll(transform.position, range);
float minDistance = float.MaxValue;
Debug.Log(colliders.Length);
foreach (Collider2D collider in colliders)
{
if (collider.CompareTag("Zombie"))
{
Debug.Log("New Zombie Detected");
float distance = Vector3.Distance(transform.position, collider.transform.position);
if (distance < minDistance)
{
minDistance = distance;
target = collider.transform;
}
}
}
}
void Shoot()
{
fireCooldown = 1f / fireRate;
// Instantiate the projectile and set its direction
GameObject projectile = Instantiate(projectilePrefab, transform.position, transform.rotation);
// Calculate direction to the target
Vector3 direction = (target.position - transform.position).normalized;
// Move the projectile towards the target
Rigidbody projectileRb = projectile.GetComponent<Rigidbody>();
projectileRb.AddForce(direction * 10f, ForceMode.Impulse);
}
}
its a turret for a Tower Defence game
Stop crossposting. Posting in multiple channels like this is spam.
(note that the code channels are the appropriate place to ask about this, so it's fine to post here. just don't post in other channels as well)
Hey there. I'm making a 2D platformer game which needs to be quite precise in collision detection. Therefore I have made my own collision detection system using raycasts. In the picture below I added some more visualisation to make my problem/question more clear. So my character has a square hitbox (green box) with which I use the bounds to calculate the ray origin points (red dots). These are inset by a small amount to prevent bugs etc, so they don't start exactly on the edge of the box.
The character has rays going both left and right at all times to detect collisions on the left and right, as seen on the left side of the picture. When my character runs to the right, I adjust the length of the right rays to match with his velocity. I do this so if a wall is detected I can us the RacyashtHit2D.distance to align the character perfectly with that wall. This works fine, but I'm not sure what to do with the left rays while running right. Do these have to be turned to the right and adjusted to the velocity too? What would be best?
float rayLength = Mathf.Abs(moveAmount.x) + skinWidth;
for (int i = 0; i < 3; i++)
{
Vector2 rayOrigin = new();
if(i == 0) rayOrigin = raycastOrigins.rightTop + Vector2.up * moveAmount.y;
if(i == 1) rayOrigin = raycastOrigins.rightBottom + Vector2.up * moveAmount.y;
if(i == 2) rayOrigin = raycastOrigins.rightCenter + Vector2.up * moveAmount.y;
RaycastHit2D[] hitsRight = Physics2D.RaycastAll(rayOrigin, Vector2.right, rayLength, collisionMask);
Debug.DrawRay(rayOrigin, Vector2.right * rayLength, Color.green);
}
Here is my code for the right rays, where the skinWidth is the small inset I was talking about
Hey guys, is there a channel to ask questions about cinemachine?
Thanks! Kinda new on discord! Thanks!
Anyone having any issues starting unity (license errors)? I can't google up any errors/outages with the license servers but my client isn't getting a response and so I can't start unity
(license is definitely still valid)
I suppose I'll try that?
this is a code channel
I have a level editor, a menu, and a scene that contains a list of all user-created level files to load from. I am getting the following errors
1- I get an error when I try to load into a level (it still opens the level editor)
2- I get an error when I try to place objects (this did not happen before I changed the system to use the save and load feature)
3- I get an error when I try to save a file from the editor
PersistenceManager.cs code snippet
private void SetupFloorplan()
{
this.sceneData = dataHandler.UnpackSceneToLoad();
// if no data can be loaded, initialize to a new game
if (this.sceneData == null)
{
Debug.Log("No data was found.");
} else {
// set sceneData.fileData
string theDate = System.DateTime.Now.ToString("MM/dd/yyyy") + "_" + System.DateTime.Now.ToString("hh:mm:ss");
// PROBLEM ON LOAD AND CREATE NullReferenceException: Object reference not set to an instance of an object
FileData newFileData = new FileData(sceneData.fileData._name, theDate, sceneData.fileData._size);
sceneData.SetFileData(newFileData);
GameObject.Find("PlacementSystem").GetComponent<PlacementSystem>().LoadFromSceneData(sceneData);
}
}
ObjectPlacer.cs code snippet
public int PlaceObject(GameObject prefab, Vector3 pos, bool rotate, Vector2Int scale)
{
PlacerObject newPlacerObject = new PlacerObject(prefab, pos, rotate, scale);
GameObject newObject = Instantiate(prefab);
newObject.transform.position = pos;
if (rotate) { newObject.transform.Rotate(0, 90, 0); }
Vector3 newScale = newObject.transform.localScale;
newScale.x = scale.x > 1 ? scale.x : newScale.x;
newScale.z = scale.y > 1 ? scale.y : newScale.z;
newObject.transform.localScale = newScale;
placedObjects.Add(newObject);
// PROBLEM ON PLACE NullReferenceException: Object reference not set to an instance of an object
placerObjects.Add(newPlacerObject);
return placedObjects.Count - 1;
}
FileDataHandler.cs code snippet
public void Save(SceneData sceneData)
{
// PROBLEM ON SAVE second argument cannot be null
string fullPath = Path.Combine(pathBuilds, sceneData.fileData._name);
try
{
Directory.CreateDirectory(Path.GetDirectoryName(fullPath));
string dataToStore = JsonUtility.ToJson(sceneData, true);
using (FileStream stream = new FileStream(fullPath, FileMode.Create))
{
using (StreamWriter writer = new StreamWriter(stream))
{
writer.Write(dataToStore);
}
}
}
catch (Exception e)
{
Debug.LogError("Error occured when trying to save data to file: " + fullPath + "\n" + e);
}
}
anyone know where I'm going wrong?
How can I add 90 degrees to hips.AddForce(hips.transform.forward * strafeSpeed); because my hips.transform.right is not my left and right. It's up and down
Null reference errors are always the same in terms of debugging steps. First find out exactly what is null, then find out why it is null. Maybe race condition, unassigned variable, could be any reason.
Im surprised you wrote all that code tbh before being able to solve those errors, did you write this yourself? Is it AI code
Then your model is likely not oriented correctly. You can rotate a vector using Quaternion * Vector3 but I would suggest finding out why right isnt right first
Yes its about the model
They are just snippets. It's a rather big project that I am adding Save & Load functionality to so you can do level building through the program instead of only in unity editor
if there is a way to change transform but not changing the model that can solve the problem
Ok so my camera jitters when following my character controller player but only in the build. Works perfectly fine in editor. It's not the update method, I tried that.
It probably couldn't be that anyway given it's smooth in the editor. Does my build need vsync or something? I don't know what to look at
Make the model a child object and rotate it to fit the direction. Realistically you want to fix this in the program it was created in though
I took the model from the asset store
I'll try thanks
So you didnt write the code? Im confused what you mean it's a big project you are adding functionality to. Either way what I said still applies. Your comments said it was null error, the debugging steps are always the same
Right, I was just answering the question. I did write the project, but I'm adding new functionality into the existing project I previously made. It's around 30 cs files, so I was just trying to only give the problematic lines.
The third error isn't null error though, so I think I'll still be stuck on that one
ArgumentNullException: Value cannot be null.
Parameter name: path2
System.IO.Path.Combine (System.String path1, System.String path2) (at <b5ac4fa8faf34bc9be9b9c54f8ce8a43>:0)
It does literally say "Value cannot be null"
We have a project in Unity 2021.3 and we want to update to 2022.3. My plan was to clone our repo into an entirely new directory that uses the new version so that hotfixes in 2021 can still be made without needing to rebuild the library twice (once to boot into 2021, once to boot back into 2022).
I made cloned the repo into a new directory, branched git, upgraded unity in that branch and fixed all the configuration stuff, and patted myself on the back.
Then I wanted to work on some 2021 work so I closed unity 2022 and opened 2021 (pointing at the "old" repo directory which was always 2021). I was surprised when a library rebuild was triggered:
[ScriptCompilation] Requested script compilation because: Assembly Definition File(s) changed
[ScriptCompilation] Requested script compilation because: Assetdatabase observed changes in script compilation related files
Clearing Bee directory 'Library/Bee', since bee backend hash ('Library/Bee/bee_backend.info') is different, previous hash was 241a572c16cb9bf3430ef298ed253734c257e34eb5cd139b490776a0a556aef1 (Unity version: 2022.3.18f1), current hash is 68e8537ffe8d9d5548d00a71da3d23d769decaf2e00f40c6ce196e1701b63cac (Unity version: 2021.3.10f1).
Starting: D:\Program Files\Unity\Unity 2021.3.10f1\Editor\Data\bee_backend.exe --profile="Library/Bee/backend_profiler0.traceevents" --stdin-canary --dagfile="Library/Bee/1900b0aEDbg.dag" --continue-on-failure ScriptAssemblies
WorkingDir: D:/projects/unity/sapling-client
Did I F something up or am I somehow not aware of some common area these hashes are stored (between instances of unity)?
yeah, I guess it is still a null error variation.
I think my issue is with trying to convert my SceneData object to and from files using the JsonUtility, but I am still not sure what it is that I am doing wrong
save method
public void Save(SceneData sceneData)
{
string fullPath = Path.Combine(pathBuilds, sceneData.fileData._name);
try
{
Directory.CreateDirectory(Path.GetDirectoryName(fullPath));
string dataToStore = JsonUtility.ToJson(sceneData, true);
using (FileStream stream = new FileStream(fullPath, FileMode.Create))
{
using (StreamWriter writer = new StreamWriter(stream))
{
writer.Write(dataToStore);
}
}
}
catch (Exception e)
{
Debug.LogError("Error occured when trying to save data to file: " + fullPath + "\n" + e);
}
}
load method
public SceneData Load(string filename)
{
string fullpath = Path.Combine(pathBuilds, filename);
SceneData loadedData = null;
if (File.Exists(fullpath))
{
try
{
string dataToLoad = "";
using (FileStream stream = new FileStream(fullpath, FileMode.Open))
{
using (StreamReader reader = new StreamReader(stream))
{
dataToLoad = reader.ReadToEnd();
}
}
loadedData = JsonUtility.FromJson<SceneData>(dataToLoad);
File.WriteAllText(pathSceneToLoad, "");
}
catch (Exception e)
{
File.WriteAllText(pathSceneToLoad, "");
Debug.LogError("Error occured when trying to load data from file: " + fullpath + "\n" + e);
}
}
return loadedData;
SceneManager.LoadScene("Floorplan_Editor");
}
Your code does not compile. void Load() contains a return loadedData; which is not possible
Do not alter the code when posting it.
Not sure what's confusing..? I also agree with @lean sail that it seems like you didn't write this and generated it instead for a couple reasons - it looks generated, but is also more challenging to write then a someone who can't find a NRE issue (your issue is on the first line of Save(), btw - sceneData or sceneData.fileData is null).
No worries with the AI thing (I use copilot myself) but if you don't know how to debug something, you should probably ask that first. Put a breakpoint on that line, find out if sceneData or sceneData.fileData is null, and why. fileData doesn't appear to be properly named (another pointer towards generated/AI code), nor is it a field in Unity.Entities.SceneData: https://docs.unity3d.com/Packages/com.unity.entities@0.0/api/Unity.Entities.SceneData.html
It's AI code and it's just... mangled.
Like... your catch clause of your Load() function has a file.writealltext? that makes no sense whatsoever..?
Yea I dont really know how to respond because this error is one of the first things you should learn. I don't know how you write all this code without knowing the basics
This is why AI won't take the jobs of programmers.. because it "looks" right but is actually mostly nonsense.. and complicated nonsense at that
Real beginners (who don't yet know how to figure out NRE issues) don't use try/catch with nested using statements ...
My b, I combined 2 functions to make it easier to read because the excess I cut out doesn't functionally have an impact on what I'm asking about. Forgot to change the void to SceneData
Do not alter the code when posting it.
Ever.
We need to see exactly what you are seeing
But like under that same concept, I may as well post all 30 files of code
that's why I always ask people to share full scripts
i might ask for more if I need to see it, yes
but obviously I do not need to see literally every .cs file in your project
code in a single script tends to go together
If you feel that all 30 files are related, your code is so coupled they are basically holding hands
Like a kindergarten class
string fullPath = Path.Combine(pathBuilds, sceneData.fileData._name);
Tell us about that line - because that's what's broken (and shouldn't/won't even compile..?)
sceneData doesn't have a field named fileData
It's usually very precise requests at first, and if the issue is more global we ask to post more code.
Start with the error. It contains a stack trace, pointing to the exact line of code the exception occurred on. Post that entire file. If needed you will be asked to post other files.
Are you sure that you opened the right directory? You'd need to add a new project to the Unity Hub (using the new directory)
99% sure..
go check your last-modified dates on the files to be sure..
otherwise, I would not expect to see this
worked on the 2022 version all morning, then closed it, opened the 2021 version and was very surprised for it to rebuild
Maybe you committed the entire Library folder to the remote (bad or misplaced gitignore file?)
(didn't change the editor version in the dropdown there)
Nope, did no commits, actually, even..
Hub can show same project name , check favorite icon in the list ( other path but same project/copy)
Basically my process (yesterday) was:
- Create an empty directory, sapling-client-2022.
- Clone the repo into that directory.
- Branch from main into something like
feature/upgrade-unity-2022 - Install unity 2022.3.18f1
- Open that new directory with unity 2022 - get a library rebuild (as expected).
- Work on that branch in 2022. Stash changes.
- Close 2022, open 2021 (pointing at old directory)
- Library rebuild!?
(and definitely haven't committed the /library directory - I think for this project that directory is like 4gb+)
The reason I thought it was broken was SceneData has FileData and PlacerObject attributes which weren't [System.Serializable]. I knew SceneData needed to be Serializable, but didn't realize any attributes inside also needed to be Serializable. After I made them all Serializable, it still does not work though. I think I must be doing something wrong with JsonUtility
At step 7, did you get a warning about opening a project with a different editor version?
sort to find dupplicates, in diffrent folder, at same name than check one with star favorite and hit ... open folder
nope .. i have the full editor logfile FWIW.. i'm looking through it but literally don't see anything suspicious aside from the lines in the OP
snipped out some personal info but ... startup logs look fine? boots into 2021.3, pointed at the correct directory, etc
I might even be able to dig up the editor log from the last boot into 2022.3 just to verify that i opened it while pointed at the correct dir
oh, nevermind.. unity puts all editor log files into a common directory 😦
editor-prev?
overwritten already - had some other issue
ah, okay
(license server down or something)
hm, I can't think of any other reason for that to happen. You could try and reproduce it with a new project
Yeah, it's.. a stumper.. I think maybe I goofed something.. I'm only hesitant to try to repro because the library build for this project takes forever (like 35 minutes)
the Hub is not infallible, for sure (it could completely obliterate new projects if you logged in via the editor for quite a while)
create new project -> sign in through the editor -> close editor -> open editor -> project is overwritten with the original template
oops
yeah I have some.. back and forth in a unity forum thread about the hub going on..
the whole administrator access required UI/UX (for the hub) is .. a little bumpy
man i really need some help, i've been trying to find and fix this for 8 hours, can anybody help me doing a melee attack in an rpg?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class ReturnToMainMenu : MonoBehaviour
{
// Start is called before the first frame update
public void mainMenu()
{
SceneManager.LoadSceneAsync(0);
}
}
Any clue why this won't take me back tomy main menu and just restarts my level? Script is attached to main menu, button is attached to UI Canvas-> Canvas
hey, anyone can help me with the JsonHelper? its a json serialization helper and its just giving me empty json strings
this loads whatever scene is at index 0 in the build settings
perhaps that's the wrong scene
explain your problem.
It is not 😔
I have no idea what that is, so you'll need to show us.
Check that mainMenu is actually being called by logging something in that method
Perhaps your button is targeting the wrong thing
public static class JsonHelper
{
public static T[] FromJson<T>(string json)
{
Wrapper<T> wrapper = JsonUtility.FromJson<Wrapper<T>>(json);
return wrapper.Items;
}
public static string ToJson<T>(T[] array)
{
Wrapper<T> wrapper = new Wrapper<T>();
wrapper.Items = array;
return JsonUtility.ToJson(wrapper);
}
public static string ToJson<T>(T[] array, bool prettyPrint)
{
Wrapper<T> wrapper = new Wrapper<T>();
wrapper.Items = array;
return JsonUtility.ToJson(wrapper, prettyPrint);
}
[Serializable]
private class Wrapper<T>
{
public T[] Items;
}
}
heard.
I'd suggest just using Json.NET if you're doing anything non-trivial with serialization
JsonUtility is extremely limited
as you can see, it requires lots of weird workarounds -- wrappers and whatnot
You can install it via the package manager https://docs.unity3d.com/Packages/com.unity.nuget.newtonsoft-json@3.2/manual/index.html
(install the package by name; it's named com.unity.nuget.newtonsoft-json)
yea this script aims to fix some of the limitatins by wrapping everything into "items" so your entries wont be on top level. this allows for basic read and write to an already existing json
Yeah seems to be right, doesn't trigger my debug log. Huh.
im just doing extremly light work and this script seems to work for everyone i saw online. im just having a very strange problem as it seems
Check the On Click event on the button.
make sure you don't just have info messages filtered
this is how it'd look when filtered
If there is indeed no log entry, then perhaps you have multiple buttons overlapping there
you could check by deactivating the button here
I don't have any other buttons, it's the only interactable button
Rest is text or images.
pretty sure you have all log entries filtered there. the numbers will still go up when messages are logged either way
(maybe your color scheme is just different tho)
I just realised that's probably useless because of my having named everyting lol
Made sure all my stuff wasn't filtered and still nothin... Hmm. Must be something somewhere else. I don't know why it would restart the game if it did nothing at all.
Probably cause of the way I set up the end screen to test it, there's some code after the canvas pops up that could just be continuing or something. Thanks for trying to help either way
So you confirmed you are not getting anything in the console, correct?
Yeah.
You should now search your project for everywhere that you interact with the SceneManager class
click it and hit shift-F12 to get a nice list
barring any truly heinous creativity, this should be every place that actually loads a scene
that'll give you something to start with
How do I search the whole project? Was unaware I could do something like that lol
This is in your code editor.
It's not related to Unity at all -- you're just asking your IDE to find all uses of something
Ah okay
e.g.
I am newish to Visual Studio, didn't use it before starting with unity
shift-F12 is great for quickly understanding who uses something
and F12 takes you to the definition of something
ok imported the package and now a least it saved into the json but it always overrides itself. do you know how to fix that?
well, yeah, if you write to file X, and file X already exists, you're overwriting file X
FIleMode.Append maybe better idea?
that would mash two JSON objects together into one file
which would be invalid JSON
what are you actually trying to accomplish here?
ye hehe
storing data into a json file
well, your code does exactly that
so be more specific
are you trying to add to existing data?
example: i input name into input field, i t appends the name into json
if so, deserialize the object, modify the object, and serialize the object
JSON keys should be unique. This would be nonsense.
What are you trying to make your game do?
store this data into a json. name will be unique so there is the unique key
okay, so you need to serialize a Dictionary<string, TeleportJson>
if you want to add another TeleportJson to the saved data, you must read the data, modify the dictionary, and save it back to the file
You could also just serialize a List<TeleportJson> and then make a dictionary out of it after deserializing it
Okay sorry I am so unfamiliar I couldn't even figure out how to get it to recognise all the files together but literally the only other place is the main menu scripts (idk why there's 2 but they're identical)
you probably renamed MainMenuScript to MainMenu, but then saved the original file again
Yeah I must've lol
figure out which one you're actually using and delete the other one
then add a log statement before that LoadSceneAsync
mmm Okay, now the return to menu button is working but is showing up when it's not supposed to. oh the joy of game making. I gotta run but I really appreciate your help so far!
How could I set the bounding shape of a cinemachine to be the composite of PolygonColliders in a list?
private static List<PolygonCollider2D> colliders = new();
public void Foo() =>
CinemachineConfiner2D.m_BoundingShape2D = (CompositeCollider2D)colliders;
Something like the above
so i have a code thats adding points to an list based on the objects position, my issue is it is also making the y do weird things this was me holding my hand out and just walking straight
"this code"?🤔
its litterally just this T-T
Then it must be the position going crazy at certain frames.🤷♂️
i figured it outtt
it was my own code
or atleast a different code i put on the side saying id finish it after this one
jokes on me
Is there a way to enable/disable a button (image and text) in code?
like visibly or not allowing you to click the button
would somethiing like this help?
Maybe, let me try. I kept seeing different syntax everywhere and none of it seemed to work.
Yeah this is the error I get when trying to do it like that.
That was before I had got to that point, it didn't show up in the inspector yet, I think I had a typo somewhere else. I gotta figure out how to get VS to suggest that my sausage fingers fuck up some day.
C# is case sensitive, btw not code general
Yeah, I've been learning C# through unity only, and Unity Pathway Tutorials at that.
It's a tough shtick lol
Yes I can, I was just about to test it
oki
ope
That formatted wrong
I am not the programmer on this project really, I'm just in charge of getting UI working and we are working off of a youtube tutorial (class project)
can you show me the inspector for the script
i just tried the script and it should work
Sure, one sec.
I think it might be something about how the UI is layered, if I click anywhere on the screen after the end game popup the game also just restarts so somethin is fucky
Oh, you're on the team with the Fructose guy?
Tell your team to be more careful with tutorials next time...😅
Button inspector, I've been fiddling with turning the actual who button off in the inspector vs in the code
Yeah I was trying to help and that tut was just awful 🤢
everything should be enabled but the button itself
It's a very fast turn around project considering full time students so we were just rushing to get it done
I pressed paste and it didnt im sorry
and this didnt work?
Nope, I can show you (I am using place holder art and it's awful)
...... hmm
I just lost the game and went to take a screenshot
and now the button is there
i did all the same workings and it worked for me
maybe the issue is when that part of the script is being run
maybe add a Debug.Log("something"); there so you can see when its being ran
but dont forget to remove it
i keep forgetting T-T
Yeah, I'm gonna have to make some, I've been going and removing them lol
But this is what it looks like, I don't know how pressing printscreen made the button show up lol
Or just use the debugger.
or that, i dont know how to use that so i dont
Okay I see, now that the button is not being disabled again when the round restarts (again idk what that happens on mouse click but its kinda not my problem), the button stays
but its like under the stupid image or something lol
I don't know if that's related to the issue, but you typically don't want any offset on the z axis on your ui.
It's -10 on this screenshot
Oh right, because I was trying it at different values lol
I tried making it super negative and super high to see if that would cause it to render before the image or something.
the way you have them layered does matter with UI
If I move the button down from the image it exists, so i guess I'll just have to take that.
The rendering/events response of ui depends on the position in the hierarchy, not their physical position.
Yeah I did make sure the button is higher than the image, doesn't seem to care.
It's alright, I can deal with just putting it way below even if I think it's ugly, as long as it works.
If you want the button to react, it needs to be lower.
I had it both lower and higher, like I said at this point I'm basically just fucking with it in every way possible lol
It's probably a combination of factors. You're probably fixing one issue but breaking it with a different thing
That's why you don't just "try everything unintelligibly"
everytime i press a button it presses the next time once more than before
ah nvm
ik why
Then you are subscribing each time it's pressed
Children draw in front of parents. Later siblings draw in front of earlier siblings.
Those are the only rules.
now, if you've shoved a SpriteRenderer into your UI, all bets are off
I find it strange you don't have that sorting group control with UI compared to sprite renderers
beyond canvas groups
I'll do my best to remember that, thanks.
So if you want to show a window with some buttons, parent the buttons to the window
The drawing order matches how you should arrange things to get good automatic layout
So I'm trying to set a rigidbody's velocity based on an animation event and it doesn't seem to be responding. Is there any reason this might be the case?
Is it possible to swap a CapsuleCollider2D between horizontal and vertical with a script?
Wdym by it not responding?
Show code etc
And show what debugging steps you took
The code is literally just a velocity change
What debugging steps did you take?
Step 1 did you make sure the code was actually running e.g. with a log statement?
I tried hitting the thing with an attack and it's not responding to the knockback it's supposed to be receiving
Yes, the code is running
It's just this one line that isn't doing what it's supposed to
Ok then either you're setting the velocity of the wrong object object or you simply have other code overwriting the velocity
For example maybe your other code is setting the velocity every frame
I figured it out. The animator is screwing with it somehow
My understanding is that each animator layer will write to all properties that any of its animation states write to
Probably have write defaults on
so even if you have a state that does nothing, the presence of another state that modifies your position will cause your position to be constantly set
nah, Write Defaults just changes what the animation writes when a state is active but not writing a specific property.
Write Defaults will write a fixed default value. If it's disabled, the animator just writes the last value it had.
Either way, the animator will constantly write to the property.
the animator is currently in a state that does literally nothing, and Write Defaults is off; the cube is impossible to move
New Animation makes it move from one place to another
If I turn Write Defaults on, the cube snaps back to its original position when I exit the "New Animation" state
Otherwise it just parks itself in place
I feel like the documentation could be more clear about this..
quick question regarding burst
is there any difference in performance between for and foreach loops?
this is in the context of a job that runs tens of thousands of times per frame
in my case when using the foreach im creating an iterator int before it and incrementing it every loop aswell
just trying to squeeze as much performance out of this job as i can get
A job as in, specifically a Unity Job system job, or are you just using it as a generic term for some amount of work?
the unity job system one
Are you using Burst compiler?
looping through a nativearray of float3's and doing stuff with them
yes
Then I highly doubt it makes any difference.
thanks 
hey, a somewhat fun problem. I have box with dimensions D. I have a player at a position P (all in 2 dimensions).
the player throws a laser that bounces off of every wall until it reaches some max distance. Is there any way to check if the laser ever goes back to the player position? Somewhat of a math problem, I know.
Do you mean you schedule 10s of thousands of jobs per frame? Or that your 1 job iterates over tens of thousands of elements?
the latter
job performs gravitational calculations for 10s of thousands of particles, each applying gravity for tens of thousands of particles
Have you already coded that whole laser bouncing mechanic? This would all be pretty simple with raycasts
i agree but i think they're talking abou6 more of a methematical formula to solve the problem rather than simulating it in-game
id think it's possible but i wouldnt know how to get there
There is no mathematical formula, it bounces so they must use something that detects objects
Thats good. Anyway I personally do not use foreach in jobs especially with Bust since I dont trust it. Actually I dont use foreach at all.
But Sarah shouldn’t you be doing your particle sim with compute shaders. Even for burst and the job system I think a cpu sim of that magnitude would be taxing.
with my current setup i get around 20fps with around 11k particles (when nothing is colliding) and im currently in the process of optimizing at as much as i can
problem being i have yet to learn how compute shaders work 😅
and im not sure if they would work for all the use cases i plan to use the sim for when i build it into more of a game kinda thing
i could be wrong though
would i be able to do stuff like gravitational calculations on the gpu while still being able to interact with the entities normally otherwise?
for example
Define interact normally
i plan to let the player select individual particles (or groups) and change things about them in real time, like their mass, size, color, etc
through a ui
Selecting individual particles seems like the hardest haha
Especially if they are being moved on the GPU
using dots to do this like i am would be as simple as changing property(ies) of the given entity(ies) through a monobehaviour (or i could make a system for it but you get what im saying)
Oh your using ECS
We do have a #1062393052863414313 forum btw
im aware, just this discussion stemmed from something a little less related
if you want us to move it there lmk
i also plan on adding optional ranges to gravitational fields to reduce negligent calculations
also that meant to say 20 fps not 120 😅
120 i wish
20 fps makes a bit more sense
So each particle has its own gravity it applies to other particles ?
yep
Your gonna need some sort of acceleration structure
the system caches a list of all particle positions (and masses) with a grav field, then iterates over every particle that has a grav reciever component and modifies the velocity by iterating over the aforementioned list of particles and applying gravity for each
not quite sure what that is
Its something that will help you get only the closest particles to a given particle. Im thinking of what structure exactly would fit your case best
It wont sacrifice any accuracy it will simply help you skip calculations for far away particles without having to iterate over all of them
...what if i want the calculations for those far away particles though
like, a large cloud of particles should have a grav influence on a particle a few km out from it
Google n body simulation
Then read the paper on how people accelerate it by spacing partitioning
So how are you doing grav calc now. For every particle get a particle calc distance calc grav ?
Thats what we are talking about right now
for every particle, get a reference to a list of all other particles, iterate over each one and calulate distance and direction and apply gravity by modifying the og particle's velocity
is it acceptable to post a code snippet here or do i gotta pastebin it
The Barnes–Hut simulation (named after Josh Barnes and Piet Hut) is an approximation algorithm for performing an n-body simulation. It is notable for having order O(n log n) compared to a direct-sum algorithm which would be O(n2).The simulation volume is usually divided up into cubic cells via an octree (in a three-dimensional space), so that on...
Yes so thats what is called the naive approach. You are effectively O^2
im aware of that haha im learning as i go here
Depends on the lenght
when i read about these acceleration structeres i see the word approximation everywhere
do these "approximations" effectively change the deterministic result of a simulation?
bout 30 lines
Well in a physics sense yes. Since real gravity does bot have a effective cutoff point
thats the part im hung up on
maybe ill have multiple modes
performance and accuracy
It must affect the accuracy but the result is always deterministic if your algorithm is deterministic
If you aim for accuracy then the only choice is n^2 algorithm
so the one i use right now?
i think what i might end up doing is having two seperate components and two seperate systems for accurate gravity and performant gravity
so the player could use a mix of the two if they wanted to
Are you making a game or a scientific simulation where the accuracy of results actually matters
its a hobby project but you could say both
i just personally really like the idea of a perfectly accuarate simulation
if i can implement both its a win win
i'll just optimize it to whatever extent im able to
its not like 11k particles is anything to sneeze at
imo
For a cpu nbody thats pretty decent
I mean you could get better results if you start sacrificing somethings. Like each particle being an entity is bound to have overhead
Simulation actually introduce inaccuracy since it is not solving the equations directly but iterate until the system is stable
(On a side note, a perfect simulation is simply impossible, game dev or not; see chaos theory and 3 body problem)
Btw it is completely up to you to have which algorithm, slightly inaccurate result but faster or accurate but slower
note that they are both deterministic
yeah thats kinda what i want to do
i know its not technically perfect
i just like the idea of having everything influencing everything else
Game is more focusing on real time interaction, so why performance matter and you can have inaccuracy results
game will be mostly about setting up a simulation and watching it play out
so i like the idea of having both options
think universe sandbox
if you've ever seen that
setting up spawners, pausing mid sim to add/change stuff, etc
i put a small demo in #⚛️┃physics
obv this isnt implemented yet
I think you can allow the change of algorithm at the very beginning (i am not sure if you should allow the change while playing since the result can be non deterministic)
doesnt matter to me if it changes while playing thats up to the user
my idea is to have the algorithm used be set on a per-particle basis if possible
sorry for asking it here but in other group no one responding
i have been trying to make a playble ads, and i thought that i will do it with the help of WebGL build. but it is giving a lot of file and i need a single html file. now after spending a lot of time, i am thinking is it even possible to make a playble ad directly from unity/ webgl.
hello, im quite new here
is there a more efficient way to keep a database of characters with their own specialty other than making a list of the parent character
like assuming a moba game, im keeping the characters alongside with their abilities
so I made a procedural 2D TileMap, how can I add colliders to certain types of tiles?
I would assume people use scriptable objects for that tho I'm not sure.. try looking into it and see if that's what you're looking for?
Although it's completely data structure related issue
scriptable objects for the database right, pretty sure i cant just use polymorphism on a scriptable object that just collects data
was just having the problem to keep the abilites
You can manually give physics shape to the tile in spritesheet and use simple tilemap collider on the tilemap
how do I give a physics shape? also what about having two seperate tile maps one for colliders and one for ground? would that be better
what id probably do is seperate what needs collider and what doesnt (also seperate by layers if u got like waters and such)
Having trouble between choosing unity or unreal as an engine. Personally Id choose unity over unreal however most of the AAA industries hire developers experienced in C++ which makes me want to go for unreal, any suggestions on which one I should choose?
hm just prefabs sounds fine here, do you need something different?
Yeah I guess that's what we normally do? Seperate tilemaps for separate layers in scene
Also click on the sprite sheet that you're using, sprite editor, then there would be an option called "custom physics shape" in dropdown
Use that, and give whatever shape you want/don't want
that sounds like a disaster to organize, was hoping i could find a more efficient way
Removing physics shape for certain tile would make it so no collider for that tile
in what sense? a SO is gonna exist in the same way that a prefab does. What could be more efficient and whats the use case
in database, yea tbf prefabs are the same as SO, but SOs are way better right..
Tbf i dont even know if there is a more efficient way, and the whole point is just to make it more efficient / save more space thats all
it works tho, totally just afraid of the impact for future progresses, cause im still new
With SO you can have all the relevant data for a character in one place, but with prefab it will be nightmare to deal with..
Imagine having 100 prefabs for a character introduction scene, each containing model and canvas for skill explanations
what, how would this be any nicer to do with SO?
but SOs are way better right..
Not exactly
in organizing things :/
For 100 characters, you just store character model and sprites, and just replace them. For prefabs you'll have to make different prefab for each scenario
owh alright then, id suppose that there is no other way to resolve this so yea imma just continue, thanks tho for the help
thought i'd learn some things i dont know
and how do you suggest making an SO, without making the SO for each one?
this is just silly
I'd rather use real database like sql for that, and load images at runtime
Fair, I haven't used SQL..still have to learn it
this is why i ask the use case, we are speculating at what they actually want to do
Again, it's not about 100 prefabs vs 100 SO
I was saying with SO you can have all the relevant data about character in one place and just replace details at runtime.
With prefab you'll have to make dozens of 100 prefab group for each scenario
"dozens of 100 prefab"?
Character details, in game screen, etc etc
wat
iirc, master/server need to broadcast the input from one client's input to other clients so other client can see the input
wait, that can't be right 🤔
it should be automatically synced
Which function is used for that?
I used FixedUpdateNetwork() that inherits from network behaviour
Master can see client's input but client can't see other clients input
Whats a good way to set EventSystem.firstSelectedGameObject to an object you want to be selected by default when you switch UI?
Do you add a class to all UI elements with "OnEnabled" that will set this value or do you use UI Manager to set this up for everyone when the UI changes?(Tho some data is added at runtime which still requires you to get that gameObject from other UI elements.)
its been a while since I touched fusion, but iirc, you dont actually broadcast input, but use networktransform so they get synced
there should be a photon forum, or maybe ask in #archived-networking. i havent used photon specifically but it sounds weird that anything is even synced by default. This should've been done through some code at least
I applied rotate and movement logic in it, yes both of them are synced automatically but in rotate I'm trying to rotate the "head" up and down as well
Master can see when other people are rotating head up and down and sideways and it's syncing , but on clients head are only turning sideways
In my logic
For sideways rotation entire body is turning sideways,
For up and down rotation only head is turning up and down
Thanks, I'll try looking into it!
Seems like EventSystem.current.firstSelectedGameObject is not the same as EventSystem.current.SetSelectedGameObject(GameObject gm);
First one actually sets the variable, but the second one does something behind the scenes.
Both works tho, but if I want to get currently selected game object I can only use 1st option?
there is currentSelectedGameObject
so I guess firstSelectedGameObject is only meant to be used once?
Any idea whats better to use for simple readonly data container?
record
or
readonly struct?
I usually just use class because struct initializers are poopy
i dont think record is supported
depending on the use case scriptable objects might be good. SO is pretty much just supposed to be a immutable data container.
Yeah, I mean cases like passing some more data as parameters, but to reduce amount of parameters its good to just group up the data
you can still pass SO as a parameter, but yea just depends on the use case
like if you want this to be data made during editor time
is there a way to detect if you came in contact with the top of a surface instead of say the side or the bottom?
yes, check the normal of what you're in contact with
compare it to Vector3.up to see how close it is to up
Hey there! I'm having some troubles with json deserialization (who doesn't lol)
I have this json:
{
"uuid": "4fe0f2eb-9b83-4d77-ae9a-2ad45337b20c",
"name": "Small Chest",
"sprite": "chest_0",
"sizing": {
"x": 1,
"y": 1
},
"scripts": [
{
"name": "Storage",
"props": {
"space": 15
}
}
]
}
and my classes are:
[Serializable]
public class Sizing
{
public int x;
public int y;
}
[Serializable]
public class Scripts
{
public string name;
public Dictionary<string, object> props;
}
[Serializable]
public class ItemDefinition
{
public string uuid;
public string name;
public string sprite;
public Sizing sizing;
public Scripts[] scripts;
}
Yet, the props always comes as null
I do need the props attribute to be some kind of generic though as it'll be handled by the scripts themselves
What do you use to deserialize it?
JsonUtility.FromJson<ItemDefinition>
JsonUtility doesn't support dictionaries
Is there any other tool that does? Or any alternative? I tried making it a simple object but won't work
Well practically all other JSON libraries do. Newtonsoft or System.Text.Json for example
Any you'd recommend? (I'm not a c# guy so happy with tips!)
private void CheckGroundSlope()
{
Ray ray = new Ray(transform.position, -transform.up);
RaycastHit hit;
if (Physics.Raycast(ray, out hit, groundCheckDistance, groundLayer))
{
Quaternion targetRotation = Quaternion.FromToRotation(Vector3.up, hit.normal);
targetRotation *= Quaternion.Euler(0, transform.rotation.eulerAngles.y, 0);
playerVerticalRotation = targetRotation.eulerAngles;
}
}
private void RotatePlayer()
{
Vector3 movementDirection = PlayerInputManager.Instance.UpdateMovementInput().normalized;
if (movementDirection != Vector3.zero)
{
Quaternion targetRotation = Quaternion.LookRotation(new Vector3(movementDirection.x, 0, movementDirection.y), Vector3.up);
transform.localRotation = Quaternion.Slerp(transform.localRotation, targetRotation, playerRotationSpeed * Time.deltaTime);
}
Quaternion targetVerticalRotation = Quaternion.Euler(new Vector3(playerVerticalRotation.x, transform.rotation.eulerAngles.y, playerVerticalRotation.z));
transform.rotation = Quaternion.Slerp(transform.rotation, targetVerticalRotation, playerRotationSpeed * Time.deltaTime);
}
So im running into a slight issue and im trying to figure out why my player only rotates about half way while moving but when i stop then it completely matches the angle of the object im on. I can get a video of it if need be.
also is that block to bug
big
System.Text.Json is the C# built-in one, that's what I use
Sweet, I'll use that then
Thanks!
Hmm, but how do I integrate System.Text.Json in unity? It doesn't seem to exist
You need to download it from Nuget. https://forum.unity.com/threads/please-add-system-text-json-support.1000369/#post-7092082
this is not how you slerp/lerp properly
playerRotationSpeed * Time.deltaTime - ❌
Is that all you have to add, doesn't really help the situation by scolding the code and not offer a solution, or advice to the problem, at that point really no reason in saying anything.
the solution is to lerp properly
last lerp/slerp parameter is the interpolation point between start and end point
from 0 to 1
where 0.5 is in the middle between start and end
0 is start, 1 is end point
So RectTransformUtility.ScreenPointToLocalPointInRectangle() returns true 'if the plane of the RectTransform is hit, regardless of whether the point is inside the rectangle'. What constitutes hitting versus missing? Because sometimes this function will just randomly return false, even though it's running repeatedly with the exact same input values.
If the transform is at a 90deg to the provided camera ray
Ie. it's visible as a line, and the ray doesn't intersect the plane
The rectttransform is attached to an overlay canvas, so I set the camera value to null as specified in the documentation
"The cam parameter should be the camera associated with the screen point. For a RectTransform in a Canvas set to Screen Space - Overlay mode, the cam parameter should be null."
Yes, that's what you should be doing
I cannot tell you why it would return false unless your transform is rotated
The code is not private, you can see how it works
oh shit
the overlay canvas is a child of the player character, that rotates around because it's an FPS
it probably should not be set up like that
Did you do that or is that an asset
if thats an asset thats worth reporting to the creator
nope did it myself, that's probably the cause
I'll write it down and sort it out some other time
then report it to yourself ^^
reading the code, that would seem to be the case
because I'm real tired
I tried just changing the screen space to camera and it caused some other issues
thanks @quartz folio @hybrid relic
(FYI you indeed can use records in Unity, but not record structs)
I didnt actually do anything but 
So I just updated VS to the latest version, I put this code in and comes up with this error. How can I update this so that the code works fine?
the c# version is typically dependent on your unity version. what version of unity are you using
which Unity version are you using?
im not using unity atm, Im only using vs, im doing a text based game
this is a unity server, mate
should hopefully be the easiest thing to start off with, right?
well, isn't vs part of making games?
you can ask your non-unity related c# questions in the !cs discord
Join the C# Discord server, a programming server aimed at coders discussing everything related to C# (CSharp) and .NET. https://discord.com/invite/csharp
this is a unity server. as i already pointed out. as is pointed out in channel description. you are asking about something that you don't even do in unity and aren't even using unity
just to make your life easier, you can set the c# version in your VS .csproj file
this was the closest I can find to some help, I had no idea about the C# ds, It wasn't that bad to at least ask, right? Even if this isn't the right server...
you could have also just as easily (if not more easily) googled it. which should be the first step before asking here anyway
The C# server has commands like $helloworld, if you are new to C# in general it's definitely a good place to start.
wow 😒 getting quite the ||hate|| vibe here...
"i intentionally ignored the off topic rules and the context of where i asked a question and got pissy when i was told to ask it in the right place or actually put effort into finding the answer myself with a 2 second google search, but everyone else sucks"
Fine I guess I wans't able to get the help I thought I could. I guess I'll just leave the server then.
bye
To explain why people are directing you to the C# server rather than here, the reason is that your question is about project setup, and Unity project setup is very different from a regular C# project setup.
Man, I have told you what you need to do and provided a link on how to do it. What more do you want?
they already left lmao
over-entitled little children
@everyone
guys how do I comunicate from isystem to monobehaviour unity
in unity dots
@everyone
that is obviously not going to work. and what did you expect, to ping 80000 people just to get help?
also #1062393052863414313 for dots related questions
@here
<@&502884371011731486>
why are you literally trying to spam and annoy people? are you 9?
Ask your question in #1062393052863414313 without trying to ping 100,000 odd people and spamming separate messages
I did ask in the dots channel
Then don't cross-post.
why are you triggerd this much boxy
where did I cross-post
bro I can't type a single damn question in this server
!warn 812745620308885504 don't spam, cross-post, or be an antagonistic git
m7md399 has been warned.
male karen
!mute 812745620308885504 1d when you return, clean up your shitty behaviour or you will be removed completely
m7md399 was muted.
You are v kind not to instaban 😄
One of my many regrets
There's still time!
Imagine being so arrogant to think everyone would want to assist you with your issue.
!ban save 812745620308885504 on second thought, your attitude and behaviour is intolerable. Bye.
m7md399 was banned.
🫡
Thanks for the second opinions
Hmm, Community Moderators posting off-topic, whatever will we see next?
Man comes in asking a question. Attempts to spam ping everyone. Resorts to insults when told not to try to ping everyone.
Advanced
Hello, I am encountering a problem which seems to be with float's precision when the number is too small when multiplied with Time.deltaTime causing the error to accumulate throughout the frame, making the healthBar changing too fast (i.e. I set it to take about 3 seconds to make the slider slowly change its value but it's taking much less time). I am thinking of using double but Mathf.Lerp dont seem to support double.
Anyone have an idea of what's else is wrong with the function? Thanks
https://paste.ofcode.org/dh65Afs7742KmaJvSbHtki
Hey guys, how do I debug this?
that's an editor bug likely due to having the Animator or Shader Graph window open. you can typically ignore it or just restart the editor if it persists
if it bothers you that much just close whatever window uses the graph editor and it will stop
if you are not writing any code that uses jobs then this is also just an editor bug
zero Job
no idea where in your code are wrong
btw
eg if i have a progress bar for 10^9 s (just a huge number) then for each dt it should only grow around 0.016/10^9 = some value around 10^-11 (you may notice that 0.1+10^-11 returns you a same number), to prevent this, you can let the progress bar grows 0.01 for each 10^9 * 0.01 = 10^7 seconds are passed
after 100 10^7 seconds were pass my progess bar reach 1
okay thanks I will try that
@simple lynx if you need help with something then ask it here. do not send unsolicited DMs or friend requests
I can't send you a friend request?
Your so arrogant
Unsolicited DMs lmao
it's clear you are trying to get help with something via DM since you previously told someone else to check their DMs before you sent an unsolicited friend request to me. it is against server rules to send unsolicited DMs #📖┃code-of-conduct
alright, i won't be helping you then 🤷♂️
Yeah
btw how does lerp differs from normal IEnumerator method or I am getting it wrong
those are completely different concepts. lerp is just math
Lerp is just a math function it has nothing to do with coroutines.
oh I thought it slowly interpolate
you would typically be lerping over time, but that doesn't mean it has anything to do with coroutines. you can lerp in a coroutine or in update or really anywhere
It computes a value betwen A and B
That's it
Hey, is here anyone who has experience with Wheelcolliders? And can tell me why I cant accelerate my object (bike) past about 2m/s despite cranking torque?
don't crosspost
a physics problem you say... I look into it thanks already
!warn 441242287960227842 Don't send unsolicited DMs or friend requests, don't spam the channel or insult members. Last warning on that account.
pixiejohn has been warned.
Who know how to solve the problems \
always start with the top error in the console
The later errors are just Unity complaining that there were errors, yeah.
so how do I do
start by looking at the first error in the console rather than the last one . . .
it also doesn't even look like a code issue
It tells you what line the exception is on
well it's still not a code issue. it's probably related to special characters in the path, but that's a guess 🤷♂️
possibly due to the chinese characters in the file path
are you perhaps building with VS22? i had the same issue, switching to VS19 fixed it (for some unity versions its bugged)
Also mentions backend exited with error code 2. Did you look up what that means?
But it con work on Mac computer paltform
Your Jobs are not ended properly, or some asset you use is doing this.
This as it says will impact performance and may create a cpu/mem leak where your game increasingly eats more cpu/ram till it crashes, i dont advise ignoring this
Could be, i would definitely recommend looking if its still there after a restart, then its either code by them, they copied or code in a asset they use.
or it's just an editor bug that will randomly happen. this happens pretty often in many of my projects, especially if i've not restarted the editor in a long while
so close other app can solve this problem ?
that wasn't even a reply to you, mate
Your hanzi / kanji (idk if its chinese or japanese) characters are very likely the problem
I change file name but it didn’t work
I've certainly had problems with IL2CPP builds on my macbook
but it wasn't this problem
it was an error with code signing
ah, and this is an iOS build, not a macOS build
so I don't have any experience there, unfortunately
Do the vscode file name and project name have to be the same?
It can run at macOS but When Compiling at iOS It show me Error
which error
this
yeah your project path , maybe IL2CPP doesn't like that
What you mean ?
Those characters in the Project name . It doesn't like that probably
I would also avoid spaces in any file names you ever make
lots of software hates dealing with filenames that contains a space key because space usually gets parsed as separating different commands or inputs.
Underscores or hyphens are the normal workarounds
I’m honestly surprised modern operating systems don’t automatically stop you from entering spacebar into filenames
I need to know if mouse is over any UI elements to stop some calculations happening based on mouse collision. Any efficient ways to do that, since i'm doing it in Update
The IPointer interfaces should give you that
do they?
As a game developer who has released titles before, I've discovered a way to detect piracy using most Steam Emulators. However, any piracy DRM can be bypassed, especially since Unity is so open to decompilation techniques.
I found that most SteamEmulators, will fake a Steam User, and the "persona" name. By using this, you can detect piracy by having a check for the players name on the SteamManager initializing. Using Steamworks.NET, the most common plugin, you can just check if lets say, the username text box did not change, and the manager did not initalize. This is a simple attempt to catch pirates on lets say first week of a successful release.
In my case, I am just making an image appear over the title screen if detected.
If anyone who wants a very simple easy way to detect piracy, this is one way!
It is very easily bypassable, and will be, but if people are lazy with their pirating, its a good way to catch someone on an illegal copy of your game. I used this in a past title of mine, which changed the characters material. I caught a lot of people pirating my game this way, and well theres not much you can do after that, but you can leave a nice comment on their lets play xD
void Start()
{
if(SteamManager.Initialized)
username.text = SteamFriends.GetPersonaName();
StartCoroutine(CheckForPiracy());
}
IEnumerator CheckForPiracy()
{
yield return new WaitForSeconds(0.5f);
if (SteamManager.Initialized)
username.text = SteamFriends.GetPersonaName();
yield return new WaitForSeconds(0.1f);
if (username.text == "PIRATE")
{
piracy.SetActive(true);
}
}```
Simple, works. Its by no means secure, but, best piracy avoidance is if someone can easily pirate your game, there's no reason to "crack" your game. This may be common knowledge but I did want to share it.
You mean just watch for enter/exit events and see if they are UI layer and then track that?
thats not even for global, it's just for the game object
what
just implement the IPointerEnterHandler etc interface on a monobehaviour on the object in the UI, and it will invoke the relevant method when the pointer enters it
legit copy compared to a pirated copy
I dont need that. I need to know if mouse is over any UI objects, which i could have dozens of in the scene.
attaching a script to all of them seems very inefficient for such a simple thing
oh okay then. that changes everything
things like that are bypassed by every bigger piracy studio
ok so here is what you do.
make a monobehaviour, have it implement IPointerEnterHandler, and make the function you want to call tied to the relevant interface function
no, the PointerEvenData has a hovered property which is a List of GameObjects. So you only need one instance of the interface
Yeah like I said, it is. However big names in the space, like IGG games, DID NOT bypass it. If the game can be played by a steam emulator, most of the time they do not go to the lengths to bypass something like the Steam Persona name not being set
A way I personally went about detecting piracy of my game(s), just wanted to share.
nahh, im not doing that. My ui lets me to just cut away 10-15% of the screen and that's it. I can just tie it to a boolean that knows if cursor can be used for gameplay or not.
Im sure it's not huge, but checking a list of gameobjects every frame just to know if i can use the mouse or not is kinda inefficient. If I needed to know this outside of Update, then sure
Ok, so you are telling me you want to invoke a function whenever a pointer enters a given object, but do not want to use the feature to invoke a function when a pointer enters an object?
sorry, i dont get what you mean 😄 I need to know if my mouse is over a certain part of the screen (or over any ui objects) every single frame. I dont want to attach scripts to every object or check the list of gameobjects the mouse is over every single frame
set a bool to true in pointer enter
and to false on pointer exit
you dont need to check if every single frame
that won’t work
it will
it’s too easy

also, if you do any specific OnPointerEnter activity with something that needs to know if the pointer entered it, then unity still needs to sift through everything on that frame anyway
now you can do this only when the pointer actually enters something relevant, or you can do it on every frame, but either way, you will have to do it.
the computer isn’t magic. it just does what you tell it to
OnPointEnter doesnt even get called when pointer interacts with any object that doesnt implement the interface
obviously
that’s the point, isn’t it?
there are way more efficient solutions just doing some simple math instead of having these interfaces implemented
then do your maths
then do it
Im refering to this
thats why im asking if there is just a simple global variable somewhere that holds stuff like this
already
EventSystem.IsPointerOverGameObject
event handler has that stuff i think on gameplay
// Check if the mouse is over a UI element
if (EventSystem.current.IsPointerOverGameObject())
{
Debug.Log("mouse over UI");
}
Thank you
2018 docs 🫠 (though i dont think it has changed)
1 minute of googling
literally first link
that's what i did
this link in the OP post lol
literally what i gave you
googling is a skill you need to learn ig
Searching the internet is a devs #1 skill
I always thought that was 'Actually reading error messages'
lots of messages give instructions on what to do
read first, google second
think first, read second, google third
think? nah asking waaay too much
or there is a alternative - ask in discord, provide 0 context "hi my player doesnt move please help"
way easier
Lmao
caveman style
As a game developer who has released
Might be overthinking this, but I want to make this Timeline feature in my game's level editor work a bit like the Unity Animation Pane.
There's two parts to this of course, the line that goes across the timeline so that it catches keyframes and does the shit that the keyframe has info far, and the actual length of the lines themselves.
I'm unfortunately very new to level editors and how they work, so I'm not actually sure what to type into Google to get a good result, nor what to do with my math skills, especially considering I'm using recttransform like a nerd for my UI instead of sprites
in other words, "don't work, how fix?"
custom classes + command pattern 🤷♂️
Can someone briefly explain to me or give me resources that explain how the convert to entity script works for gameobjects and how to impliment it properly
At least you used punctuation, so a good start.
In the word of the proverbial Yorkshireman, 'I wouldn't start from here'
what I mean by this is it screams out for UIToolkit, gonna make your life so much easier
Have you read through this section of the manual?
https://docs.unity3d.com/Packages/com.unity.entities@1.2/manual/conversion-intro.html
perfect thank you
Thanks Steve I'm going to
wow i can't even say uh 😭
How do you guys organize your scenes? Do you use any tools to make your hierarchy neat?
in a word, no. Why would I want to clutter up my build with a bunch of extraneous gameobjects taking up valuable resources?
What is your opinion about this class? Can you suggest any improvements or automation?
using CodeBase.GameLoading.States;
using CodeBase.Infrastructure.States;
using CodeBase.Services.LogService;
using UnityEngine;
using Zenject;
namespace CodeBase.GameLoading
{
public class GameLoadingSceneBootstraper : IInitializable
{
private readonly SceneStateMachine sceneStateMachine;
private readonly StatesFactory statesFactory;
private readonly ILogService log;
public GameLoadingSceneBootstraper(SceneStateMachine sceneStateMachine, StatesFactory statesFactory, ILogService log)
{
this.sceneStateMachine = sceneStateMachine;
this.statesFactory = statesFactory;
this.log = log;
}
public void Initialize()
{
log.Log("Start loading scene bootstraping");
sceneStateMachine.RegisterState(statesFactory.Create<ServerConnectState>());
sceneStateMachine.RegisterState(statesFactory.Create<LoadPlayerProgressState>());
sceneStateMachine.RegisterState(statesFactory.Create<PrivatePolicyState>());
sceneStateMachine.RegisterState(statesFactory.Create<GDPRState>());
sceneStateMachine.RegisterState(statesFactory.Create<FinishGameLoadingState>());
log.Log("Finish loading scene bootstraping");
// go to the first scene state
sceneStateMachine.Enter<ServerConnectState>();
}
}
}
Empty game objects would take up valuable resources?
of course
I've never noticed a performance difference with empty game objects just sorting an hierarchy
I mean Im sure maybe if I instantiated 10000 of them, then def.
Just slap the EditorOnly tag onto them and they'll be removed from the build version as far as I know
you mean apart from the fact that you do absolutely no error checking?
Checkout my new Kickstarter campaign.
this is not the channel for this
What is
this is just a polygon space pack too
It is guaranteed that it will not be null, but thx
for generic code, which is what this looks like, guarantees and $1 will get you a cup of coffee
Alright, I understand. Well, in that case, is there anything else you can add, now that you've started?
tbh, not enough information
too much happening of which 'I know nothing'
I would worry about the use of CodeBase as a namespace though
I am creating a template to use; it's not a concrete project
even more reason to make it something less generic
Interesting, why do you think that, even though I know partially why?
So the future you does not hit namespace conflicts
also
statesFactory.Create<>().
I would use or at least make an override
statesFactory.Create(Type type);
then the types become soft rather than hard as you now have, a bit of future proofing
Also CodeBase in no way explains what is going on
I made a little mistake, but an interesting one :))
public void InstallStates<TBaseState>(StateMachine<TBaseStates> machine) where TBaseState : IExitableState
{
var derivedStateTypes = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(assembly => assembly.GetTypes())
.Where(type => typeof(TBaseState).IsAssignableFrom(type) && type.IsInterface && type.IsAbstract)
.ToArray();
foreach (var stateType in derivedStateTypes)
{
var state = instantiator.Instantiate(stateType);
var castedState = state as ExitableState;
machine.RegisterState(castedState);
}
}
hey guys, I am using Unity 2022.2.0f and I have a class which I create a list from, however, when I change window or press play and stop some of the elements just make it's content "disappear", I'll send the class and also pictures of what's wrong
show the !code where you're actually using this class
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
it changes from this
to this
here's the full code
https://paste.ofcode.org/gtT6XUmrZGKeJzr5tsBcmu
okay and keep in mind that changes made during play mode do not persist when exiting play mode
yeah ik
well there's nothing in there that would cause it to just randomly remove items from the list(s) except for your UpdateCosmeticsInside method. however it is also public so anything with a reference to the Chests component can change it
no, look closely to the picture, it's not removing items, it does not render it's content
that would probably be more obvious if you didn't crop the screenshots so much. all i see is the Cosmetic Index list in the second one and it just has fewer elements than the first screenshot
the first picture it shows Cosmetic Index -> Element 0 - > Cosmetic Index -> Element 0 = 2
and in second it's just Cosmetic Index -> Element 0 = 2
I'll post it again less cropped
literally how could i have possibly known that is what you were referring to? both lists have the same name. the second screenshot just looks more cropped than the first one
sorry didn't noticed, I am a bit dumb :d
so what do you think?
no idea, seems like an issue with the editor not your code 🤷♂️
if you have a custom inspector or something that would potentially break it, but you'd ask for help with custom inspector stuff in #↕️┃editor-extensions
no custom inspector
broo, I don't want to go to higher Unity version
do you think there is any other way I could make this without using the class?
maybe I can assign it's values in the code
it's not much effective but it could work
is there a reason it is fine making a 100x100 and a 200x200 but can't make a 300x300, its probably very simple but I can't find it
By default the max amount of vertices per mesh is 65536 (16-bit integer maximum value). You can change its .indexFormat to up that limit to 2 billion (32-bit integer maximum value)
oh is that a project setting or do I just put it in the code for the mesh
On the Mesh you create in code yes
so i want my character to walk down a slope without constantly falling as it goes down with this code. Is there a good way to do so? (_direction variable takes the player input on keyboard or controller and makes a vector based on x and z leaving y usually at 0)
void Move()
{
if (_direction.magnitude >= 0.1f && _canMove)
{
_anim.SetBool("isMoving",true);// Transition to move state
// Determine angle to be facing based on camera direction and input direction
_targetAngle = Mathf.Atan2(_direction.x,_direction.z) * Mathf.Rad2Deg + _camera.eulerAngles.y;
_angle = Mathf.SmoothDampAngle(transform.eulerAngles.y,_targetAngle,ref _turnSmoothVelocity, turnSmoothTime);
// Generate move direction using character's current forward
_moveDirection = Quaternion.Euler(0f,_targetAngle,0f) * Vector3.forward;
// Move based on rigid body and movement speed and rotate them accordingly
_rigid.MovePosition(transform.position + (_moveDirection.normalized * Time.deltaTime * _baseMoveSpeed));
transform.rotation = Quaternion.Euler(0f,_angle,0f);
}
else
{
// Transition out of movement if movement input is less than 0.1 or if the player can't move
_anim.SetBool("isMoving",false);
}
}
is it a dynamic RB or kinematic RB?
2D or 3D?
ah apologies. Dynamic and 3D
that is going to be rough. Have you considered KCC?
KCC?
kinematic character controller is a free asset, with a physics solver, that let you move a kinematic rigidbody around while respecting slopes, stairs, walls, etc
Showcase for the Kinematic Character Controller system
Available now on the Unity Asset Store: https://www.assetstore.unity3d.com/#!/content/99131
Forum thread: https://forum.unity.com/threads/released-kinematic-character-controller.497979/
Browser demo: https://phil-sa.itch.io/kinematiccharactercontroller?secret=rjRvT8GfZCAXEkevCF92TV07UQ
Musi...
guess i'll give a try
look closely at what it does first. It takes effort to implement
it’s more like a separate API from rigidbody
What do you mean constantly falling down? Also movePosition is supposed to be used with kinematic rbs
when you say "walk down a slope without constantly falling as it goes down with this code"
do you perhaps mean that it moves horizontally in the direction of input so it moves off of the slope then it drops back down onto it? because if that's the entire issue then just project the move direction on a plane represented with the normal of the surface it is moving on
KCC solves the basics of simple motion in 3D with slopes and stairs. i recommend you check it closely before deciding what you want
dynamic RBs always have to fight forces and the physics system. They inherently do NOT follow simple commands, like move along a slope.
KCC is a bit bulky tbf. It would take them quite some time to go through it to even decide if its fit for them
hey guys, im using a premade package called kinematic charachter controller to set up my player controller and im facing some issues.
as you can see the Y rotation of the player is not acting like how it should.
any ideas where the issue is? im guessing it has something to do with the ProjectOnPlane things in the code snippet down below but i cant figure it out.
code snippet related to setting the player rotation:
//Calculate camera direction and rotation on the character plane
Vector3 cameraPlanarDirection = Vector3.ProjectOnPlane(targetCamRot * Vector3.forward, Motor.CharacterUp).normalized;
if (cameraPlanarDirection.sqrMagnitude == 0f)
{
cameraPlanarDirection = Vector3.ProjectOnPlane(targetCamRot * Vector3.up, Motor.CharacterUp).normalized;
}
Quaternion cameraPlanarRotation = Quaternion.LookRotation(cameraPlanarDirection, Motor.CharacterUp);
if (cameraPlanarDirection.sqrMagnitude == 0f)
{
cameraPlanarDirection = Vector3.ProjectOnPlane(targetCamRot * Vector3.up, Motor.CharacterUp).normalized;
}
_moveInputVector.x = (cameraPlanarRotation * moveInput).x;
_moveInputVector.z = (cameraPlanarRotation * moveInput).y;
_lookInputVector = cameraPlanarDirection;
this is where i set the targetCamRot used in the first code snippet
// NOTE : Do NOT Use time.Deltatime, beacuse the mouse input that is coming from the new input system is already a delta. more info :
https://unity.huh.how/programming/input/built-in-input/mouse-delta-time
// Rotate the camera based on mouse input
float mouseX = lookInput.x * sensitivity;
float mouseY = lookInput.y * sensitivity;
//we use the lookInput values to rotate the camera horizontally and vertically using the transform.Rotate() and Quaternion.Euler() functions
//respectively.
rotation.x -= mouseY;
rotation.x = Mathf.Clamp(rotation.x, -90f, 90f);
rotation.y += mouseX;
camHolder.transform.localRotation = Quaternion.Euler(rotation.x, 0f, 0f);
Character.targetCamRot = rotation.y;
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
well i mean im not sharing an entire script and only short code snippets so i dont see why that would be necessary
https://hastebin.skyra.pw/wuxeheboyi.csharp
input code is on line 230
the _lookInputVector is the exact code from kcc, but it dosnt work in this situation
yeah that's what i'm doing but i still seem to be going off the slope when going down
i guess i should probably modify it somewhere there in the move script
cause right now i just have it where it replaces the original move vector from the player input with that
why does gravity not work when my player animation is playing
that said yeah it is dynamic, should i change it to kinematic then?
at least when grounded?
kinematic bodies are not affected by forces like gravity so you'd have to add your own if you make it kinematic
correct
so for the project on plane thing like you suggested
would it still work if it's dynamic
or does it need to be kinematic?
yes because it has nothing to do with the rigidbody
ok so for the projectedonplane where should i slot that?
like in the code block i showed above
the _direction gets replaced with that vector
if i'm on a slope ( i have a slope check using raycast and angle difference checking)
get the normal of the surface. then pass your move direction through Vector3.ProjectOnPlane with the surface normal. that is now the direction of your movement
because big blocks of code clutter the discord. i literally had to scroll for 3 screens on mobile just to get to the previous comment. Not using a pastebin is rude.
your code blocks are just on the borderline where I'd want to use a paste site
The lines are very loooong
which makes it worse on mobile
if I need to scroll through 2 screens on mobile, it’s too long
this is a discord, not a github
and it is literally on #854851968446365696
ye that's how i did it, let me show the parts
private void SettingMoveVec(InputAction.CallbackContext ctx)
{
Debug.Log("Setting movement");
Vector2 input = ctx.ReadValue<Vector2>();
_direction = new Vector3(input.x,0f,input.y);
if (_playerForces._isOnSlope)
{
_direction = _playerForces.GetSlopeMoveDirection(_direction);
}
}
public Vector3 GetSlopeMoveDirection(Vector3 direction)
{
return Vector3.ProjectOnPlane(direction,hit.normal).normalized;
}
you have now shown multiple disjointed methods, most of which i have no context for the order they are called in.
however i can say that if you are only projecting it there, then you aren't doing it at the right time because you only do it when the input changes. not when the the ground normal changes
oh ok
You want to project your movement onto the floor. For input you only need to change it so that it is relative to where the camera is looking
so for the GetSlopeMoveDirection function should i call it on fixed update then?
call it when you need to get the direction to apply your movement
so would that be when the script receives movement input?
you see here where you calculate the move direction. you need to project the move direction on the surface plane
ohhhh ok let me do that then
so not pre-emptively like i did earlier
pre-emptively meaning doing it directly from the input before any calculations like angle to move at
correct because as your object moves the surface it moves along may change. you can't just precalculate the surface normal and keep reusing it, you need to get the current normal or you run into the issue you are having
eye sea
it works
mostly (it's gonna be additional issues i'll need to tackle)
basically just being when i hit the end of a slop where it goes back to being flat (so normal facing upward), my character briefly for a moment enters the falling state before going back to ground
but i think it just has to do with some of my other code earlier for fall checking
still tysm @somber nacelle
Hello peeps. I have this conveyor belt prefab and I want to put a shader on the part that moves. Is there a way to do this without having two separate objects and only have 1 mesh or not
hey guys
Had anyone watched and followed this video ?
In this video We continue creating our Enemies and give them the ability to Attack our Player!
Come Join us on the Discord!
🎮 https://discord.gg/xgKpxhEyzZ
Link to the Weapon Model
🔫 https://www.mediafire.com/file/gth5615w2gccj48/AssaultRifle.fbx/file
The Shoot() function
Idk why it was only called once @@
thank you
Sorry another question. I need lots of objects to be animated. Should I be using hybrid rendering for this where I have a game object that recieves rendering info from ECS?
How do I tell if a gameObject collided with a child of another gameObject?
I'm trying to have the parent gameObject be told when another object collides with its child
without adding another script on that child that tells the parent when something collides with it
put the script on the child and send info to parent
i was hoping I didn't have to do that, feels a bit messy...
I can not for the life of me figure out how to get a touch release working with Unity's Input System and input actions assets. Could anyone familiar with this system help me out?
This is what I have tried.
But, the event is triggered for the press and release of touch.
If the child only has a collider and the parent has an rb, collision messages, would be forwarded to it.
i have a VideoPlayer component, but its instantiated from a prefab.
once instantiated, it cant find the main camera, its videoplayer.camera property just appears blank.
the property is read only, so i cant assign it through code.
the only way i can find to assign it is through the inspector, but i cant because its instantiated from a prefab.
the whole of google is giving me nothing so this is my last resort right now
as far as i can tell, unity just never considered this situation so its impossible
Are you sure it's read-only?
The docs don't mention anything about it being read-only.
the errors say it is
Why we use Time.deltaTime? i'm new
Property or indexer 'Component.camera' cannot be assigned to -- it is read only
if you dont use it then when your games fps drops then it would also slow down time
How can I efficienlty switch the turret stats with cases? I just want it to be more clearer without having to have alot of code visible/make a bunch of functions. ```cs
void ManageTurretType() {
switch (currentType) {
case 0: // Change turret stats to Light Turret stats
break;
case 1:// Change turret stats to Heavy Turret stats
break;
default: // Change turret stats to Default Turret stats
break;
}
}```
I understand I can just say: turretHp = LightTurret.hp, turretDMG = lightTurret.DMG etc
That's not the correct property.
camera is a legacy property referring to the camera on the same GameObject.
You want to use this:
https://docs.unity3d.com/ScriptReference/Video.VideoPlayer-targetCamera.html
I recommend checking the docs every time you have issues with the API.
I have a 2D game i’m working on and an entity in the game needs to get to an object but there are obstacles in the way that they need to avoid. So far i’ve just had them moving directly towards the transform but now I need to get around these obstacles. Does anyone have an idea on what i could use to do this?
stats = statsArray [(int)currentType]
What is stats in that situation?
I'd probably just make a struct containing that kind of data, make static readonly presets for all kind of turrets and just use these presets in the switch statement / use an array and enum
A class/struct encapsulating your stats.
Then what is statsArray?
basically what dlich also just said
An array of these classes/structs.
I'd use SOs for them.
Not sure what that emoji is supposed to represent. If you don't k ow what SOs are, they're ScriptableObjects
I am very much lost. I don't understand what you are telling me about the stats
Some kind of pathfinding🤔
Or custom avoidance logic.
What do you mean? What part do you not understand?
stats = statsArray [(int)currentType]. How do I get stats and statsArray? Are they variables where? Where would these be*
Both would be class fields.
So stats will have its own public class and statsArray as well?
The array you could initialize from the inspector.
No. Stats would just have whatever stats you want.
So not this? ```cs
static public class TurretStats {
}
public class TurretStatsArray {
}```
🤔 do you know what an array is
Yes
TurretStats, yes, but without static.
statsArray is just TurretStats[]
Ideally,
public class TurretStats : ScriptableObject
{}
But a serializable plain class is fine too I guess.
Wait, how is statsArray TurretStats[]? I can't find how you can make a class an array. Is it a int inside that class?
Its an array of a type. Same as you can have an array of any other class...
Did you never have a SomeClass[] field in your code?
I don't think so
How about int[]?
Yes
Well, it's basically the same.
The only difference being int is a value type and class is a reference type.
I believe going through a C# course first would be preferable here
i understand some kind of path finding but like what path finding would i use
Google it, there are tons of examples online
A* pathfinding is probably the most well known one
Is there a way to just make a float function that takes in a class? Then just change that class to Light, Dark, or Heavy?
Wat? What do you mean by a float function?
A function that returns float?
Sure, but it's arguably worse than what I suggested.
Since you're gonna have a class of stats anyway.
It's kind a doing more work for nothing.
okay thank you
Can you give a simple example of how to do it? Also why is it a bad idea?
At this point I feel like it's becoming a topic for #💻┃code-beginner
As for the way you want to do it, I'm not entirely sure what you have in mind and why. Try writing some code and if doesn't work, ask about it.
Also, if I feel like you're clearly missing the basics of C#, I might not be able to help until you go through the basics.
Okay, thank you for all the help. I'll look up the basics on classes when I get the opportunity. 💯
Not "basics on classes". Classes are one of the basic concepts of C# and OOP languages in general, so you should go over "C# programming basics".
anyone knows how to make a group of serializablefield in the inspector colllapsible without having to making another public class and making it [System.Serializable]
I did check the docs and I didn't find that
Didn't find what? targetCamera in the properties list.
Yea
That's my fault for being blind tho
Just I did check the docs I'm not stoopid
got it thanks
I made an abstract class called "Attack", and in another abstract class created an array of Attack scripts. But in the editor, I'm completely unable to add any Attack script objects to this array
so everything is abstract classes, you need to have a regular concret class extending a abstract class to use it for anything but referencing
I do, though. There is a concrete WeaponSwitch script attached to the player object, which properly holds Gun objects, and a Gun object which is unable to hold Attack objects.
https://hastebin.com/share/etusefuxag.csharp
https://hastebin.com/share/koyevigihu.csharp
https://hastebin.com/share/zohajocoho.csharp
Yes, this is EXTREMELY confusing lmao
then it should work
should be able to reference PumpShoot in the Attack[]
PumpShoot will just need to be added as a component to a gameobject
Ohhhh
That was the issue
Ty
hey there, I'm building a 3D tower defense and I've hit a wall with how I would store wave spawn data. I have a LevelManager that holds references to SpawnPoint prefabs that act as factories that LevelManager passes spawn info into. the issue I'm having is figuring out how to hold the data in a scriptableObject in a way that LevelManager would know what enemies are being spawned, at which SpawnPoint they are being spawned at, and the enemy ID for the SpawnPoint to pull a reference to the enemy prefab
I make a waves data type that holds a bunch of enemies along with extra parameters like frequency and stuff, which I then feed into my wavespawn manager that iterates over these waves
So, my LevelSOs contain multiple WaveSOs
I see, i have it setup kinda like that atm and wanted to consolidate. I like the idea of being able to set the frequency, but how are you doing that? does each enemy in the WaveSO also have a delay before it is spawned?
Actually what I do is weighted spawns, so I give me WaveSOs enemy types and a weight modifier, so when it spawns an enemy it first picks from the random pool of assigned enemies (20% chance to spawn a skeleton, 80% for bats for that specific wave). For frequency it's normalized from the max time of the wave and distributed evenly, but I do have some slight deviations I can enable.
ohh i see
I still need to improve on it, but that's my base idea of it all
so you have one overarching timer over the course of the entire wave and enemies are just spawned in at set intervals on that timer based on their type?
Yeah, but it's not always just single enemies at a time, I have settings for making waves into formations that spawn a number of enemies at once
so like 20 formations in a span of 60 seconds, with respect to the max enemies that can be alive
gotcha
If I didn't want to use a weighted pool, I've also made the option to separate the groups of enemies with their own count, which then both will run its course over the time limit
Does anyone know how to mirror armature based on the direction are on
this is my issue
I got sonic here with a perfectly normal animation facing the right direction
now here goes the issue. If you turn left he has his back turned
wait shit this is not animations my b
cant you just set one of the axis scale to -1?
Here's an example
Left with scale = (1, 1, 1), right with scale (1, 1, -1)