#archived-code-general

1 messages ยท Page 305 of 1

dreamy atlas
#

it works perfectly now

keen forge
#

Please for god's sake, help me to understand crazy phenomenon

#

Output example:
Split: buttonSouth
False
<Gamepad>/buttonSouth

Why?! If pathSplit != "buttonEast" and word False approves it, how can it type action.bindings[i].path in third row??

somber nacelle
#

make sure that your console is not set to collapse mode so you see the actual order of your logs. and also click the log entry in the console to view its stack trace. most likely that last log you are seeing is from elsewhere

#

oh wait no i see it

keen forge
#

oh, i get it. It was because of ";" in the end of "if" . I was breaking my head for hours before i asked this on this channel and now i know what the problem! Thank you, great discord server, wery helpfull!

heady iris
#

ah, that'll do it

somber nacelle
#

your IDE should be underlining that as a warning for a possibly empty if statement. it's weird that it is not unless you've gone and changed some settings

chrome trail
#

I'm very unsure how to go about the math for this, but I want a player who recognizes an attack that is less than 0.2s into its attack animation and tries to dodge it will succeed but a player who fails to do so and dodges too late will get hit by the attack tracking. What kind of tracking math would I need to make this work?

knotty sun
#

not the point, that is where your question belongs

rigid island
#

sounds like a simple timer

chrome trail
leaden ice
chrome trail
leaden ice
#

time elapsed since the attack started

#

You could also use an animation event to mark when it becomes too late to dodge

chrome trail
# leaden ice time elapsed since the attack started

Yeah, I recently decided to just do something like this but felt it would be janky. It's fine for the prototype, but is there a more versatile long-term solution I could be using?

if (time > 0.2f) { transform.eulerAngles = Vector3.up * Mathf.MoveTowardsAngle(transform.eulerAngles.y, targetAngle, 4.5f); }

heady iris
#

separate the decision from the consequences

#

decide if the player performed a valid dodge

#

then do other things based on that

#

maybe the attack can have a dodged flag that, when set, turns off tracking

#

also, this is framerate dependent, assuming this code is in Update: you should do something like Mathf.MoveTowardsAngle(..., Time.deltaTime * 180f)

#

this would rotate by 180 degrees per second

chrome trail
heady iris
#

ah, okay, then it's okay (although a bit more annoying to tune)

#

I'd still rather have a turnRate variable that's multiplied by Time.deltaTime

#

(and Time.deltaTime is set to be equal to Time.fixedDeltaTime inside FixedUpdate, so that isn't an issue)

leaden ice
#

Yep and multiplying by fixedDeltaTime also means if you change your fixed timestep it won't change the speed.

spring creek
heady iris
#

it'll still wind up producing the correct amount of motion

modest horizon
#

In general if you subscribe a method to a delegate you should also unsubscribe it, but how (or even should) you do it if you do it like this?

lean sail
naive swallow
toxic prawn
#

how do I changedensity in script?

modest horizon
#

And is there no way to just flat out clear out all subscribed functions in OnDisable for instance?

lean sail
#

If it's just a delegate then yea set it to null

modest horizon
#

Ah has to be from the same class, that was why I could not do it that way before.
It is an event, even though though it technically only is called in play mode, I think if I disable domain reload it will never clear them out if I don't handle that manually, which is somthing I'd rather avoid.
Thanks for the info :)

lean sail
solemn raven
#

hi
while switching scenes do I need to keep a copy of EventSystem in the player prefab or a copy in each scene ?

leaden ice
#

Seems weird to be part of the player

#

it just needs to exist in every scene somehow

#

assuming you are using it

modest horizon
rigid island
lean sail
modest horizon
#

It's a scriptable object, so I think that stays?

winged shadow
#

guys i am planning to add a bunch of modifers into my game and all my gameobjects have the same health script so i am adding all the conditions within the same function (shorthand, to make it concise)

#

is this ok or shall i split it up

lean sail
leaden ice
winged shadow
#

all the conditions

leaden ice
#

then in this function you can do like:

foreach (DamageModifier modifier in modifiers) {
  damage = modifier.Modify(damage, ... whatever other parameters you need ...);
}```
winged shadow
#

so check the modifiers before calling the takedamage function?

leaden ice
#

no..

modest horizon
leaden ice
#

this would be part of TakeDamage

winged shadow
#

oh

solemn raven
#

i keep getting a warning from now and then by moving it There can be only one active Event System.

rigid island
#

well yeah you're going into other scenes with event system already present

#

its up to you really, also depends how many scenes you got. You can just omit the event system from prefab, if you know the scene will contain one

solemn raven
#

if the warning that keeps poping is not a big deal (There can be only one active Event System.) then i think its easier to jusr keep it with the player

#

the warning is just awarrning it doesnt effect the experience at all

#

and only pops when the player moves from 1 scene to another ( no idea why it even pops )

#

cause there is only one event system with the player prefab

#

I guess maybe it copies the prefab in the new scene then delete the old one and close the old scene which makes 2 event system for a brief second

#

am I right ?

leaden ice
#

if the object is in the new sscene yes both will be in the scene

#

Are you using a singleton pattern for your player or something?

#

where it destroys itself

#

the right way to do this is to not put the player object in each scene. Use a bootstrap scene to bootstrap the player instance.

spring creek
solemn raven
#

@leaden ice @spring creek ok thanks , I will try remove it from the player prefab and keep it in each scene instead and see if that makes it better

#

yup , that actually fixed it
@leaden ice @spring creek @rigid island thanks โค๏ธ

winged shadow
#

@leaden ice

#

this is how i decided i wana do it

#

@spring creek public Dictionary<string, bool> battleModifiersD = new Dictionary<string, bool>();

public static bool s_ExplodingSoldiers, s_Intangibility, s_Colossus;

#

i have a dictionary of forbidden fruit

#

im planning of adding 25 of these babies

spring creek
#

Ahhhh, the static discussion from yesterday

winged shadow
#

yes lol

spring creek
#

So that is for gamewide flags, right? That should be fine

winged shadow
#

yeh

#

:)

#

so when u pick the mods before the game starts

#

it changes the functionality for all classes

#

before u instantiate any of ur units

chrome trail
# leaden ice Yep and multiplying by fixedDeltaTime also means if you change your fixed timest...

So, if I decide to use this method of having the character wait 0.2s into the attack before it starts tracking, how would I go about making sure it will track just well enough to not still hit the target if they dodged before then? I also want the tracking to be just as effective independent of distance between characters and to not use any external variables other than the target's position. Is there any way I might do that? Because I'm really not wrapping my head around the math I would need

sterile sorrel
#

How would I detect for multiple objects with certain tags and in a certain range (10 for example) and destroy them?

somber nacelle
#

use a physics query like an OverlapSphere to get the objects within that range (use a layermask to filter out unwanted ones)

merry stream
#

would dikstra's algorithm be a good choice to generate a path from the start of the level to the end? I want the path to be organic and not exactly a straight line which I know is what dikstra's algorithm is supposed to do

heady iris
#

you could generate a path with the NavMesh system, then do something to make that path more organic

#

imagine dragging a ball on a string behind you as you move along the rigid path

#

you could even physically simulate it -- make a physics scene and simulate dragging a rigidbody along the path

#

(the physics scene would make it easy to simulate a bunch of physics ticks manually)

maiden fractal
merry stream
heady iris
#

ah, is this still going to be constrained to a grid, then?

merry stream
#

yea

#

imagine a 200x200 map

#

or something like that

#

im trying to procedurally create dungeons

#

but they will be overworld so woods, deserts etc

#

are there any good a* libraries or do I just make my own

heady iris
#

you could make a more meandering path by randomizing the cost of each tile a little

#

throw some Perlin noise on it

merry stream
heady iris
#

note that if you're using A*, you will need to make sure you don't wind up breaking the heuristic

#

the actual cost to reach the goal must not be lower than the heuristic's estimated cost

#

otherwise it can find a suboptimal path

cold parrot
#

typically youโ€™d post process the optimal path to make it look more natural instead of encoding the naturalism into the graph

merry stream
#

say I want to use this for enemy pathfinding as well

#

will it be able to handle over 100 enemies?

lyric atlas
#

If I have a list of effects to be triggered by something, where each effect would have public fields to tweak it, is there a serializable way to implement it in the inspector?

Interfaces and abstract classes do exactly what I want but aren't serializable in the inspector and I'd rather not dabble in a custom inspector for them as my last attempt was rather messy (unless there's an easy clean way)

ScriptableObjects work well, but for each altered effect with different values I'd need a new object in my assets which could add up.

The current approach I'm using which works fine is to have one effect class which contains all the properties each effect type would need and only showing the necessary attributes based on an EffectType enum. This is wasting lots of memory presumably as each class instance has each variable but it's serializable and much cleaner to deal with in the inspector which I'm willing to live with I think.

Just wanted to know if there are any better suggestions or whether my assumptions on the last solution are wrong and it isn't as wasteful as I'm thinking.

cold parrot
heady iris
oblique spoke
#

Cost of pathfinding varies greatly depending on how many nodes needs to be traversed to find the path and what sort of processing you might do.

heady iris
#

(that is going to require a custom property drawer, though)

lyric atlas
heady iris
quartz folio
lyric atlas
heady iris
#

The example code shows a Fruit[] in the code, but I think the demo video is just showing a Fruit

lyric atlas
#

it worked but was awful

heady iris
#

I use lists of abstract classes all over the place for "effect"-style design

quartz folio
quartz folio
heady iris
#

crunch

quartz folio
#

I forget what I did for that as it was so long ago that I actually made this extension ๐Ÿ˜› a lot has changed with UITK lists since then

lyric atlas
heady iris
#

I was looking at Animancer's code to see if I could mangle it into something that uses UIToolkit

#

i then decided I was not going to do that

quartz folio
#

I'll see if I can look into it today anyway. There may be an easy fix

heady iris
#

alright!

lyric atlas
heady iris
#

I was planning to switch to using your library (because UIToolkit support means I can make much nicer property drawers), but lists are pretty vital to how i'm using [SerializeReference]

#

i have Animancer in my current project exclusively for the property drawer lmao

#

there are no animations

lyric atlas
lyric atlas
#

@quartz folio sorry for the ping, I presume you already know there are other libraries to do this and I've ended up using this one which works well: https://github.com/mackysoft/Unity-SerializeReferenceExtensions
Thank you very much for offering to have a look into it anyways!

GitHub

Provide popup to specify the type of the field serialized by the [SerializeReference] attribute in the inspector. - mackysoft/Unity-SerializeReferenceExtensions

shell scarab
#

so I just learnt you can make Awake() async. What other unity methods can be made async? I couldn't seem to find info online through the docs

thick terrace
#

but also, it's a bad idea to make many things async lol

shell scarab
#

well I know async tends to "grow" upwards through a project

#

but I thought you aren't usually suppose to make async methods void? And unity will just accept that it's async and run with it?

thick terrace
#

yes, it normally needs to spread because you return Task and expect callers to await it, if you don't you're just starting async operations without waiting for them to finish everywhere

shell scarab
#

I don't know anything about how Awake is actually called from unity, but if I try to call async Task SomeMethod() from Awake() the compiler complains to me it will be ran asynchronously.

thick terrace
#

unity isn't actually doing much here, it's all C# stuff

cold parrot
shell scarab
cold parrot
thick terrace
#

async Awake won't directly cause any problems on its own, it's just something to be careful with because it's easy to make a mess with

cold parrot
#

also any time you see async void its already smelly code

quartz folio
shell scarab
heady iris
#

Unity does some funny stuff with async.

quartz folio
heady iris
#

oh hey, here's you explaining it, simon :p

thick terrace
shell scarab
thick terrace
#

it's useful to be able to have an async onClick on a button for example

shell scarab
cold parrot
thick terrace
lyric atlas
shell scarab
#

sure, I'm not doing anything weird though :) So let's get back to my question, I don't really want to defend why I'm asking it when Unity itself has it in the example of how to use a part of their SDK.

So I guess since it's mostly C# doing stuff as you said @thick terrace, why does a async method called from a regular method run synchronously? What's the correct way to do that? I would assume Awake is being called from a synchronous method.

thick terrace
#

it'll run synchonously up to the first await like any async method, then you have no idea when the rest finishes

#

so you can actually treat the first part of the method like a normal Await then the rest is like you started a coroutine

#

obviously, big refactoring hazard if you move that first await lol

shell scarab
#

ah yea I get that. But I swear that I was using an async method that had an await and the compiler was warning me it would run synchonously. Something like this:

void Start() {
  DontDestroyOnLoad(this);
  Load();
}

void OnDisable() {
  Save();
}

async void Save() {
  await File.SaveAsync(); // or however you do it, i'm writing this in discord.
}

async void Load() {
  var a = await File.LoadAsync(); // or however you do it, i'm writing this in discord.
  
  // then convert a to some type of object through JSON serialization

  DoSomething(a);

  SceneManager.LoadScene("someScene"); // or really just do anything else, in this example this script is in the first scene which contains a spinning symbol representing the game is loading.
}
``` It would tell me that Load and Save would run synchronously. They shouldn't?
cold parrot
#

you need to actually run them in an async context to not be synchronous

thick terrace
#

are you maybe thinking of the warning you get if you have an async method without any awaits in it? it's worded similarly to that

shell scarab
#

maybe... so Save and Load should run asynchronously here right?

heady iris
thick terrace
#

yes

cold parrot
#

you cant start an async "thread" with a regular method call

thick terrace
cold parrot
#

there is no continuation without any context existing

shell scarab
# thick terrace yes

Then perhaps I was thinking about that warning, but I swear it was something like that. I've done it exactly like this before, but recently in a game jam I was making a save/load system and it was giving me warnings so we just scrapped it because well it was a game jam and time constraints yk how it is

thick terrace
#

you're always in a context in unity!

shell scarab
#

Ok, perhaps I was just confused. I don't use async very much after all! Thank you @thick terrace!

quartz folio
heady iris
quartz folio
#

maybe I need to repro it with something more complicated than fruit

thick terrace
shell scarab
shell scarab
native quest
#

I have a bunch of lists of Vector3s for a number of objects. I want to generate a string ID for each unique list of Vector3s

#

I have a Dictionary in my parent object that is meant to keep track of all the known list<Vector3> and their associated IDs

#

trying to getkey with the List<Vector3> isn't working

#

wondering how best to handle this

rocky basalt
#

Anyone know why I'm having trouble loading .bin files as TextAsset via Resources.Load?

Docs for TextAsset states it represents a raw text or binary file asset, however I cannot drag a bin file in the inspector, nor is loading it via script working (getting NullRefException)

I just want to get the byte[] of the file via TextAsset.bytes to deserialize it (i'm using Odin)

I'm doing Resources.Load<TextAsset>("myFile"); and I've also tried adding a ".bin" extension to that string, but no luck

https://docs.unity3d.com/ScriptReference/TextAsset.html

cold parrot
thick terrace
native quest
cosmic rain
rocky basalt
native quest
rocky basalt
#

But I don't know how else to call up a .bin file via Resources.Load

shell scarab
cosmic rain
cold parrot
rocky basalt
thick terrace
#

TextAssets are the way to load random binary data, you just need to change the extension to .bytes for unity to recognize it

cosmic rain
shell scarab
rocky basalt
cold parrot
thick terrace
native quest
#

will *essentially do it

cold parrot
native quest
#

my bitwise knowlage is poo poo lol

rocky basalt
thick terrace
cold parrot
#

and all the trickery around it

native quest
quartz folio
native quest
#

that's according to stack overflow lol

cold parrot
thick terrace
quartz folio
#

Always check the manual too;)

rocky basalt
#

To be fair the relevant info was pretty buried. But yes, next time I will search the entire manual and not just scripting docs. Either way thank you simonp for making me feel less dumb. Hah.

native quest
#

i think?

cold parrot
#

just more facts you take on authority

#

i bet there is a proof somewhere

native quest
#

well

#

I just tried it in excel lol

cold parrot
#

proof by excel โœ…

visual flare
#

what cause these - each time i delete an asset, seems like it's a post process on assets

#

there are a few post processes in my project

buoyant scroll
#

I already checked out unity.huh.how/package-manager/package-errors, and there's still package errors for my Unity project. What do I do?

visual flare
#

Panda BT v2 broke the build! bloody thing

native quest
#

but now I have a different problem

#

it seems that if I have vectors that "cancel each other out" it xors out to 0

cold parrot
#

that feels right somehow

native quest
#

yea i think it makes sense

chilly surge
cold parrot
#

you could just encrypt the list's hash codes and use that as checksum to fix the xor

chilly surge
#

Cool, just so you aware ๐Ÿ˜„

native quest
#

I just still need to be able to take an array of Vector3s and turn that into an identifier

#

that's deterministic based on contents

#

but right now an array of length 0 and ones like this edge case will end up with 0 (it's 1 in the screenshot just cause I set it to 1 initially)

cold parrot
#

add the hash of the list object itself

chilly surge
#

You can combine hash code of both the array length and each of the element.

native quest
native quest
#

I may need to figure out something else for the list elements instead of vertices in the future

cold parrot
#

in any case there is no guarantee that this method reliably differentiates array by exactly the properties you want

#

you somehat gotta work with whats possible

native quest
#

yea this will do for now I'll need to dive in deeper eventually

#

i'll backburner it

#

thanks guys

chilly surge
#

I came in the conversation late so don't have the full context of what you are using this for, but the collision point is something you do need to be aware of.

#

Things like HashSet/Dictionary use hash code as a shortbut, but they still need to perform actual equality checks because of the collision.

cold parrot
#

there are bigger issues than collisions

native quest
#

I'm looking for equivalancy checks in elements of the array

cold parrot
#

like xor of point-symmetric vectors being 0

native quest
#

so I'm open to other solutions

cold parrot
#

the best check is to check all elements against each other based on the set operations you want

native quest
#

I want to check to see if another array has already been registered or if a new array's contents are unique

chilly surge
#

There are plenty implementations of collections with value semantics online, shove them in a hash set and that's all.

cold parrot
native quest
#

oh you know what I think i understand now

#

I can make it a hashset<List<Vector3>> and look up that way?

chilly surge
#

You cannot, since List<T> does not have value semantics, but that's essentially what I'm trying to tell you: you just need to implement your own array with value semantics, where a == b compares by content, then you can just shove it in a HashSet<YourEquatableArray<T>> like you would with anything else.

#

That requires not only you to implement GetHashCode correctly, but also the actual comparison has to be by value, you cannot skip out on the latter because hash code can always collide.

native quest
#

gotcha

#

thank you

chilly surge
#

If you don't know what you need to implement/override, the easiest way is to just use something like SharpLab and look at what compiler generates with public record struct Test(string Foo, int Bar); or something.

#

That will tell you all the things you need to properly implement for value semantics, and you just need to swap out the hash code and equality implementations.

native quest
#

wow SharpLab is sweet. thanks

plush bobcat
#

I'm creating a sim for optics in unity using line renderers to represent rays of light. I'm having an issue with my system. How it currently works is every fixed update it will clear out its current line renderer and create a new one based on the light that's coming into it (I'm aware of the inefficiency of recalculating everything even though no changes have been made, I'm lazy though). I'm having an issue where some objects will have their line renderers destroyed after the new line renderers are created, probably due to script execution order. Is there a way I could "time" it so that the method to clear the lines will only be called after everything in fixed update is done? A "LateFixedUpdate" of sorts

#

This is the current behavior. The gizmo rays show that the calculation for the line is correct, and the method is being called, but the lines are being destroyed after they're created.

plush bobcat
#

Figured it out! Just had a variable track how many frames past since it was last updated. If it was 2 or more, the clear happens. Allows a frame of leeway which is enough :)

dull glade
#

does anyone know if I can temporarily disable FMOD?

spring creek
dull glade
#

I don't know where to find: FMODStudioModule.cpp

merry stream
#

anyone know why when I try to copy a tilemap prefab (premade structure) onto my main tilemap through code, only a part of it copies. It's only happening for a specific prefab, my other one works fine

#

it seems like the chunk is getting cut off?

buoyant ermine
#

hey, i'm looking for a system that will allow me to apply linear motion to gameobjects given supplied source and destination x,y coords (Built-in animation system will not cut it as it has to be something that can be paused and resumed without impacting the movement)

leaden ice
#

Linear motion is very simple

#

Just using Vector3.MoveTowards or Lerp

#

Both will give simple linear motion when used properly

merry stream
#

they are getting pasted in like this, hm

buoyant ermine
leaden ice
#

You have full control over duration

buoyant ermine
#

I also have situations where multiple of these movements are happening simultaneously at varying durations

leaden ice
#

I'm waiting to hear a problem here

#

None of this is an issue

#

You will have to write a little code

#

It's not difficult code

#

Either attach a component to each object or track all the motions in a collection

#

The linear motion is simple and the pausing is as simple as a bool

rapid stump
#

https://pastebin.com/miGipUZ0
Is there any other way I can handle 2D collision between the players ship sight/field of view (Which is a 2D image, but the image itself is a circle (transparent)) and my about 625 fog tiles?

I guess this was a temporary solution

With a small ship sight, like a scale of 15, this fog collision is fine, but when the player gets to the highest ship sight they can get the fog collision's accuracy drastically drops. Fog tiles could be almost entirely inside the players ship sight before the fog collision notices they've collided
And it's not a performance problem, even on my phone as the player moves with the biggest ship sight I get over 60FPS

dull glade
#

I don't think my logic is right:

 public AudioSource startingClip;
 public AudioSource nextTrack;

 private void Start()
 {
     startingClip.Play();    
 }

 private void Update()
 {
     if (startingClip.time >= startingClip.clip.length)
     {
         startingClip.Stop();
         nextTrack.Play();
     }
     if (nextTrack.time >= nextTrack.clip.length)
     {
         nextTrack.Stop();
         startingClip.Play();
     }
 }
buoyant ermine
solemn bridge
#

Hey guys, I'm working in the Meta All In One package and I'm using hand tracking. I'm trying to create a darts game where you just throw darts at a dart board. I have everything set up and it's working fine but I'm not able to get enough velocity while throwing the dart. I've set the weight lower, I've removed drag, etc. Does anyone have any advice on how to make the dart throw feel more realistic?

My first idea is to apply a force to it when the hand releases it but I can't find anywhere in the docs or online how to get the throw event to trigger something like that with Hand Tracking rather than a controller.

Any advice would be appreciated.

mild osprey
buoyant ermine
# mild osprey Assuming your project doesn't have a set framerate, having movement tied to fram...

I know movement based on frames sucks, but unfortunately, it's the only timing data I have for my object tracking sheet (unless I want to manually retrack everything) (if it helps visualise things, I basically have to recreate a situation where bounding boxes keep their position over an active video and the only data I have is the original sheet of xy coords, their start time in videoframe, their end time in videoframe and depending on the bounding box, their width and height)

west lotus
#

Well what frame rate was the video in ?

#

Calculating the time would be trivial

buoyant ermine
#

15fps original footage, but 60fps new footage

mild osprey
#

Yeah if you know the framerate, it's really easy to calculate time

#

But if you really need it to be tied to frames, if I understand correctly, you could set a up a coroutine that has a loop that iterates equal to the amount of frames you need it to.

int frames = 0;
int totalFrames = (whatever number you need);
while(frames < totalFrames)
{
  Vector2.lerp(xy1, xy2, frames / totalFrames)
  frames++
  yield return null;
}
rapid stump
#
using UnityEngine;

public class ShipSight : MonoBehaviour
{
    private void OnTriggerEnter2D(Collider2D other)
    {
        Debug.Log($"ShipSightScript: OnTriggerEnter2D: Collided with a tile!");
        if (other.CompareTag("FogTile"))
        {
            Debug.Log($"ShipSightScript: OnTriggerEnter2D: Tile matched 'FogTile' tag");
            other.GetComponent<FogTile>().Collided();
        }
    }
}

The first screenshot is my ShipSight, which has a 2D Box Collider with a kinematic body type, and a 2D circle collider with the correct size. The second screenshot if my fog tiles, they all have 2D Box Collider with the correct size. Each object has their corresponding script attached to them
The script I'm worried about the most the right is the ShipSight script, which I put above. Even though every collider has "Is Trigger" set to true, and each fog tile has the tag "FogTile" when they're supposed to collide, I don't receive any debug logs. At all. Nothing happens

leaden ice
rapid stump
#

Nooooo ๐Ÿ˜ฆ I can't use the Unity collision physics with UI elements

#

Shoot

leaden ice
#

It doesn't make any sense

#

UI lives in a completely different coordinate space

#

What are you trying to do here?

rapid stump
#

I'm just trying to add collision between my players ship sight (literally just a 2D image) and fog tile (more 2D images) in the Canvas.
I already have the logic, but it's not accurate, atleast when the player gets a bigger ship sight.
https://pastebin.com/miGipUZ0

leaden ice
#

What does "shipsight" and "fog area" mean?

#

Is this for fog of war or something?

#

You would need to put an object with the collider in the actual world space area corresponding to the fog area on the map.

#

If you're displaying fog in your game world it should really not be done with UI elements

rapid stump
#

Sorry lol.
In the image, the fog is circled with red. The ship sight is circled with orange.
I had a map panel in Canvas that the player can explore, as the ship sight, the field of view, I guess, touches a fog tile, the images, the fog is supposed to fade away

wheat spade
#

Am I able to invoke private methods in a private class? I can do something similar with serialized variables.

lean sail
wheat spade
#

I'm trying to call a private method in a class I don't have access to. I know how to access a private variable in a private class using SerializedProperty, but I don't know how to do that with methods.

wheat spade
#

I don't have access to the type since it's a private class.

lean sail
wheat spade
#

No, it's like this:

{
  void MyCode()
  {
    //Code to call Plugin.TheirClass.TheirCode()
  }
}

namespace Plugin
{
  sealed class TheirClass
  {
    private void TheirCode(){}
  }
}```
knotty sun
opal mesa
#

Hi there! i'm having an issue with a worldspace canvas. It visibly is behind my other UI (that are in screen space camera mode, projecting onto another camera especially for the UI; this camera being in orthographic mode.), the order in layer is inferior to but the raycasts are blocked by the worldspace UI anyway, which is weird. Then, i thought that if the plan distance was too far away, maybe it was messing with some things too bc the worldspace UI was technically in front of it in terms of coordinates, so i changed that in play mode but still nothing. any ideas?

wheat spade
wheat spade
dark fossil
#

i am casting a raycast to reveal a object if its detected by my spotlight
is there a way to handle a sort of OnExit for the raycast?

lean sail
wheat spade
#

It could have to do with unity's assembly definitions, or MyClass and TheirClass being in different files.

pastel patio
#

Guys I'm having 2 cursor-related issue here, like, seems like it's cus I'm using Linux-

The first issue is kinda resolved, and is that when locking the mouse, the mouse does visually reveal at the center after unlocking, but Input.mousePosition heavily disagrees and is higher up to the right.
I fixed that one by making a cursor manager that returns the actual screen center if it's locked.

The second issue is that Input.GetAxis did a great job at overshooting whenever dealing with locking (and unlocking?) the mouse, and uh... Honestly I ain't got no idea how to fix this one :(
I'm guessing that it didn't like the fact that the mouse basically teleported to the center of the screen.

#

And the second issue's kinda a game breaker for me cus uh, I force the player into some sorta FPS mode when drawing a bow (No alternative to this system without doing major changes to the game)

#

Might ask me why I don't turn a blind eye to this issue (Since it appears to be linux specific) or something... Well, I just don't want every linux user struggle thanks to this bug

#

Also strange thing that when I searched for it it's an old bug that was supposed to have already been patched back in Unity 2019 or so, but here I am, on Unity 2022 xD

dull glade
#

I can't get the turret to slowly rotate to target something is wrong:
transform.position = parent.position;
// Get the rotation of the car in quaternion form
Quaternion carRotation = car.transform.rotation;

// Calculate the rotation to apply to the turret based on the input
Quaternion turretRotation = Quaternion.Euler(0f, aimInput.x * rotationSpeed * 90f, 0f);

// Combine the rotation of the car with the rotation of the turret
Quaternion combinedRotation = carRotation * turretRotation;

// Apply the combined rotation to the turret
transform.rotation = combinedRotation;

// Calculate the rotation to apply to the gun based on the input
Quaternion gunRotation = Quaternion.Euler(-aimInput.y * 90f, 0f, 0f);

// Combine the rotation of the turret with the rotation of the gun
Quaternion combinedRotation2 = transform.rotation * gunRotation;

var desiredRotation = Quaternion.Lerp(transform.rotation, combinedRotation2, currentRotSpeed);

goGun.transform.rotation = desiredRotation;

thin aurora
tawny elkBOT
versed spade
#
    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        
        EditorGUILayout.PropertyField(serializedObject.FindProperty("model"));
        EditorGUILayout.PropertyField(serializedObject.FindProperty("name"));
        EditorGUILayout.PropertyField(serializedObject.FindProperty("description"));
        EditorGUILayout.PropertyField(weaponType);
        WeaponObject weapon = target as WeaponObject;

        //Based on the selected weapon type, display relevent properties
        switch(weapon.type)
        {
            case WeaponObject.weaponType.Nothing:
                EditorGUILayout.LabelField("Please Select a Weapon Type", EditorStyles.miniLabel);
                break;

            case WeaponObject.weaponType.Repeater:
                DisplayProperties(repeaterStatsProp);
                break;
            case WeaponObject.weaponType.Ballistic:
                DisplayProperties(ballisticStatsProp);
                break;
            case WeaponObject.weaponType.Cannon:
                DisplayProperties(cannonStatsProp);
                break;
        }
        serializedObject.ApplyModifiedProperties();
    }
    // Runs a iteration through the provided prop so it can generate each child (variables) of that prop in the inspector
    void DisplayProperties(SerializedProperty prop)
    {
        SerializedProperty iterator = prop.Copy();
        bool enterChildren = true;

        while (iterator.NextVisible(enterChildren))
        {
            EditorGUILayout.PropertyField(iterator, true);
            enterChildren = false;
        }
    }

I've been at this for quite a bit and need some help. I am making a Custom Editor that will change the values below "Weapon Stats" with one of the 3 classes in my switch method. It should be iterating through that class (for example, RepeaterStatsProp) to paste only those variables. However its been pasting both the variable in it and BallisticStatsProp and CannonStatsProp.

#

^Weapon object in the thread

light pond
#

as you can see it disables the box colliders but doesnt switch the tile when i jump

latent latch
#

Dont cross post please

sand vine
#

Hey guys, TMPro -> sprite's from rich text via TMP_SpriteAsset that is in TMP_Settings. When i change the default sprite asset in TMP_Settings in runtime, my sprite's refresh only after scene reload, i can bypass this by calling TMPro_EventManager.ON_TMP_SETTINGS_CHANGED(); but that works only in editor. Do you know any other way to refresh settings in build version?

winged shadow
#

Guys I am trying to figure something out and I'm not sure how to do it. I have a 2d game which is Gona be isometric(although I haven't made the sprites and background yet). I want a rain of arrows to fly in from off screen to the target. I'm thinking there's only 2 ways. Instantiate like 100 arrows make them take an arc trajectory to the target and destroy them within a range or do something like rain with the particle system which would be quite difficult

#

Instantiating all the arrows doesn't seem feasible though

latent latch
#

Pool em

winged shadow
#

I am already pooling like 50 for my archers normal attacks

latent latch
#

If it's just a radius of damage and not per instance youd only need to do a single overlap physics query over using multiple colliders

winged shadow
#

I'm not Gona do collision detection

#

I'm only using them for the effect and make the targets in that area take damage over time with some rng

thick terrace
#

you could do the rendering yourself and have a single componet that renders the same mesh 100 times, then you'd just need an array of positions/rotations

#

that's basically what particles is, but if you need more control it might be easier to roll your own

latent latch
#

Vfx graph good at this assuming the terrain isnt complicated, or by generating a sign distance field of your levels

#

Thus gpu computing everything

winged shadow
#

Haven't used it before

latent latch
#

Single physics query, 0 colliders besides raycasting the point

versed spade
#

Though a better solution would be acccessing its property shown here. Just got no idea how to call that. PropertyType and path don't seem like it

#

oh wait ๐Ÿคฆ Thats my own Debug.

winged shadow
#

@latent latch I guess I could do something like that but it's not as impressive as watching the arrows fly in from off screen

latent latch
#

You can do anything you want. Thats an example of multiple particles pooled without using colliders

#

If you want colliders, use shuriken default particle system. You still can do similar without colliders using default, but it would be cpu driven (still fine idea)

winged shadow
#

Oh so that wasn't the particle system

#

I might pool the arrows I'll see

#

At the moment in my game I am having trouble syncing the pooled arrows in multiplayer

#

For the basic attack

edgy stump
#

How to add custom shader to URP Volume Component?

trim rivet
#

Any tips on creating a connected water/swimmable collider consisting of several box colliders but treated as a single collider?

edgy stump
trim rivet
#

Meshcolliders don't work sadly

edgy stump
edgy stump
west lotus
edgy stump
full mango
#

hey everyone! are there any services that build from unity to ios for you that you know of?

dreamy atlas
#

When standing on a moving platform, the platform moves the player and objects using this script. It moves the player using the line at the bottom, and rotates the player using the stuff above.
I need to somehow get the difference between the rotation last frame and rotation this frame, and turn that into a float to replace the "_rotationSpeed" i used before. I'm just unsure what Quaternion calculations would be fitting for this
I'm replacing the _rotationSpeed thing because I won't always have a consistent or constant rotation

topaz hill
#

!code

tawny elkBOT
dreamy atlas
topaz hill
rigid island
leaden ice
somber nacelle
topaz hill
leaden ice
# dreamy atlas

FromToRotation is for DIRECTION vectors not sets of euler angles

somber nacelle
# topaz hill cam movement is smooth

9 times out of 10 the issue is due to how the camera updates. please provide details when asked about something instead of making assumptions that it works correctly

topaz hill
#

cam mov script

rigid island
#

which is prob not ideal

dreamy atlas
#

oh

steady moat
# dreamy atlas

You could convert your rotation into direction if you want, but using rotatetowards might be better at that point.

somber nacelle
# topaz hill https://gdl.space/qihiwidevo.cs

Input.GetAxisRaw("Mouse X") * sensitivity * Time.deltaTime;
well there's one source of stuttery camera controls. don't multiply mouse input by deltaTime
you're also updating the camera in Update which is potentially before the interpolation on the rigidbody has updated the object's position.
Your camera should be updated in LateUpdate to help avoid such issues

somber nacelle
#

also obligatory: use cinemachine

latent latch
#

Yeah cinamachine has some extra settings for execution ordering

somber nacelle
#

ah wait, they are using cinemachine, but rotating it manually for whatever reason

leaden ice
dreamy atlas
#

not sure if the maxdegreesdelta being zero makes any difference

topaz hill
#

but the rotations r smooth only the jumping moving around feels jittery

leaden ice
#

yes you are breaking the interpolation the way you are rotating

#

rotation needs to be done via the Rigidbody

topaz hill
#

ohk

dreamy atlas
#

for anyone searching keywords in server message history, i solved it with Mathf.DeltaAngle

topaz hill
leaden ice
#

Yes like I said use the Rigidbody to rotate

topaz hill
hexed pecan
topaz hill
#

ohk tq

somber nacelle
#

you're still multiplying your mouse input by deltaTime. mouse input is already framerate independent which is the point of the deltaTime multiplication when used with other values. by multiplying it by deltaTime you suddenly make your mouse input reliant on the framerate again causing stuttery rotation

#

although i don't see those X and Y values even being used anywhere ๐Ÿค” nvm i see it now

topaz hill
somber nacelle
#

no, do not multiply your mouse input by deltaTime

#

you will need to reduce your sensitivity variable by a factor of 100 after removing that multiplication too

topaz hill
#

and i dont then also

somber nacelle
#

Then leave it in and let your players experience the potentially stuttery movement ๐Ÿคทโ€โ™‚๏ธ

gray mural
# topaz hill and i dont then also

You don't see it, because you're testing it out with the same frame rate. If you were to test it with, say, 30 and 90 frames per second, you would notice the rotation's sensitivity being 3 times greater in the 1st case, as your X and Y values are constantly being divided by 30 and 90 in the 1st and 2nd cases respectively

gray mural
# topaz hill ohk

That's why you should remove it to avoid this kind of behavior, the same way you use Time.deltaTime when changing the position

topaz hill
#

thanks man

steep saddle
#

Anyone out there have experience using serial ports? I'm trying to understand how the baud rate works. It seems like whatever I set it to, the value is ignored. I'm trying to determine what the actual rate is

knotty sun
steep saddle
#

USB connected to a microcontroller

knotty sun
#

not even sure you can set the baud on USB, I think the devices are supposed to negotiate it

steep saddle
#

That's what I keep seeing, but I can't figure out what that negotiated rate actually is

#

the device communicating over USB is communicating with 6 other devices over Serial, and I'd like for the baud rates to match

knotty sun
#

it will depend on the implementation level of the USB devices. Do they all match?

steep saddle
#

There is just the one device connecting via USB. The others are connected to that device via hardware UART

#

Or well, a mix of hardware and software UART

delicate oak
#

I asked this a day or two ago, but it got sorta covered up.

Just wondering if anyone has experience in designing very modular plug and go character controllers. One that can add abilities on the fly and remove them too, like plugging and unplugging components essentially.

I have all my components coded up and they work fine, but when they intermingle they have certain issues. Ive overcome this temporarily by having a massive amount of spaghetti code where in every component I check for other components and disable them when I need to and then re-enable them. This is whatever, but I was wondering if anyone has sorta, like a smarter way of going about it.

Like for example, my jump component handles yVelocity, but when I add the fly component, I have to turn off the jump component when the fly component is actively flying, and then turn it back on when its not.
This sorta specific management of other components causes me to have to go back and edit a lot of code when I would much rather have it be hands off once its set up.

Any advice would be great

dusk apex
delicate oak
#

sure, I can modify it to do that. But that doesnt particularly get rid of the sorta issue I ahve to tackle of knowing which components to turn off when and where.

Like I would still have to add code to fly to unsubscribe from jump, slam, charge, etc or whatever other behaviours

dusk apex
# delicate oak sure, I can modify it to do that. But that doesnt particularly get rid of the so...

The manager would be in charge of that. For example, if something were to want to override movement completely they'd call a function from the controller manager where that function would simply remove all other functionalities and add the wanted movement. The same would be applicable with component base operations but I couldn't imagine why a person would want to do so with components unless they're implementing everything in the Update methods.

heady iris
#

I'm actually about to deal with that properly, actually. My main project has a Locomotion class that various kinds of locomotion (currently just humanoid and freecam) derive from

#

in this case, you'll only ever have one locomotion at a time

#

so that's not quite your problem

#

(the issue I'm having is figuring out how to provide input to every kind of locomotion, both from the player and from AI characters)

delicate oak
#

Right, I have a non-physics character controller. So sometimes outward forces also have to override all control

#

ill look into some manage class to atleast be able to have my hands off the code internal to the controllers

#

I dont use the update methods directly, I have an update method called via a parent controller. Cuz the order of operations matters so I have some defined operation layers and orders that ensure certain controllers fire first

lone echo
#

https://gdl.space/inohetawih.cs

Hello everyone! I'm working on a 2.5D game that's essentially a 3D game, but it's shot from a 2D-like camera perspective. In the game, a rocket launches and continuously moves right, dodging meteorites along the way. Now, I want to add enemies that appear on the right side of the rocket and move along with it, maintaining a consistent distance. The goal is for me to be able to shoot these enemies. However, I'm encountering an issue where the enemies try to position themselves to the right of the rocket but only do so for about 2 seconds before they stop moving and just stand still. Does anyone have any ideas on what could be going wrong and how I can fix it? Thanks in advance for your help!

https://gdl.space/inohetawih.cs

spring creek
lone echo
spring creek
lone echo
spring creek
lone echo
#

Yes i need real help

#

But not a policeman

soft shard
# lone echo But not a policeman

The issue with cross posting is that its confusing, say you get help here, and then 4 hours later help from a different channel but you already got a solution - its less about "policing" and more that if your question is in 1 place then it lessens confusion and keeps the topic of the question within a relevant channel

hexed pecan
#

Inb4 "quit yapping bro"

lone echo
#

Yes, well then I'd rather delete it in the beginners chat when you see that it's no longer about programming at all

spring creek
# lone echo Yes i need real help

That was going to be my next step ๐Ÿคทโ€โ™‚๏ธ but if you'd rather I butt out, I certainly will. Best of luck

lone echo
#

@spring creek Yes, well, I have now deleted it from beginners. If you would like to help me, I would be there

ocean hollow
lone echo
#

@spring creek modCheck

rigid island
lone echo
#

Unfortunately I can't manage that and I find it a bit more difficult as a beginner to program a bot

rigid island
#

want to add enemies that appear on the right side of the rocket and move along with it, maintaining a consistent distance.

#

unclear to me what this even means

#

which rocket?

ocean hollow
#

Like where you highlight text someone said

rigid island
#

some quote famous

lone echo
#

wait navarone i make a video

ocean hollow
#

like this

#

Oh cool

#

Thanks

tardy crypt
#

OK can somebody please give me a sanity check on a new project?

The idea is that there are various "facts" (floats) that can be "learned" with "imperfect knowledge." Facts are observed by sampling a random distribution having the fact as its mean. More samples gives you better knowledge.

Anyway, the facts are implemented as floats boxed into a Fact class. new-ing a Fact generates a handle and registers the fact into a main registry of facts. The purpose of using a registry is so you only have to pass handles around, and can look up facts from any place in code. It also helps clarify ownership, which C# is less good at than some other languages (as far as I understand). I figured this was better than passing references to floats or whatever around the code, or finding the owner instance of a fact and asking for its value, or whatever, which I feel could get messy. Instead, you could just search the central registry for whatever "fact" you needed.

My fear is that I am writing FizzBuzz Enterprise Edition and that I should just scrap the registry/handles and pass around some central repository that stores floats, or that there may be some simpler way to achieve this. Any thoughts?

chilly obsidian
#

would anyone happen to know why my lighting might be different when loading the scene directly and changing to that scene from another one?

lone echo
#

i cant make a video

somber nacelle
lone echo
#

In my 2.5D game, a rocket is constantly moving right through space at a speed of 10 km/h, represented by an oval object in the sketch. During the game, an enemy (represented by a circle in the sketch) appears at a fixed distance of 9 meters to the right of the rocket. The enemy is programmed to move synchronously with the missile, both horizontally and vertically, to always maintain a distance of 9 meters.

As the player steers the rocket up or down, the opponent follows this movement in real time, but always remains positioned in front of the rocket, never behind it. This allows the player to shoot at the opponent while simultaneously navigating and avoiding other game objects.

The challenge is for the opponent to precisely follow the rocket's movements while maintaining the set distance to create a dynamic and reactive gaming experience.

pine schooner
#

Hello! Has anyone here experience with litenetlib? Iโ€˜m making a board game turn based and using it. Iโ€˜d like to talk a little bit

lean sail
lean sail
opaque jolt
#

Hey there!
Trying to make a scene with a lot of cubes (up to 100k).
I would like to do some GPU instancing on them but I have two questions about that.
Is the GPU instancing the same thing as the (Hierarhical)InstancedStaticMesh from Unreal ? It seems easier in Unreal because it doesn't need any shader code..
One more question - Can we do raycasting on a cube instanced via GPU ?
Thanks for your help! ๐Ÿ™‚

tardy crypt
latent latch
#

Could do combine and mesh collider after generating and using closest point method of the raycast

#

Not sure if it's better to do individual box colliders though

heady iris
#

would you just hard-code it, like...

#
public bool MakeDecision() {
  return factRegistry.GetFact("Foo") < 1;
}
#

I guess your question is about which of these two things you're going to do

#
Debug.Log("My understanding is: " + fact.CurrentValue); // fact either contains the value or knows how to look it up
Debug.Log("My understanding is: " + registry.GetValue(fact)); // fact is just an ID
#

Is that right?

tardy crypt
#

I think that's basically the question, though I think the second example would be more like what you said above "factRegistry.GetFactByOwner(owner)" or "factRegistry.GetFactOfType(type).Where((fact)=> fact.owner == owner);" or something like that. basically i think the question is whether to pass around the facts themselves or whether to use information about the facts to retrieve them from a registry. i'm thinking this is kind of an ad hoc database. the game will have a bunch of information screens that display lists of various fact containers in the game and i think doing that with hard references to facts will be more difficult than having the central registry.

toxic prawn
#

I want to make the sound distortion effect that happens when a blue screen happens. how do I do that?

rigid island
toxic prawn
# rigid island what sound distortion effect?

the last audio thats been playing repeats again really fast making a weird crash effect. I dont know what its called but it happens hen you get a bluescreen while an audio is playin

#

i dont know what its called

swift falcon
#

Hey i upgraded the SerializableHashSet<T> https://gist.github.com/YunusYld/fe5f195f7781c649a5acbc34a97400b0
It works great until going into play mode. When i click at Play Mode, it gives me null reference of "parameter name: array" just one frame in line 50 and it works great after it. It seems Clear() method at the background tries to reach the array. But array coming null because the array of **HashSet **is not serializable.
Any ideas to solve this? Yeah Try Catch works but bet i do something wrong so i hope i get answers from your wisdom

toxic prawn
#

the distortion

swift falcon
rigid island
toxic prawn
#

yes how do I do that?

swift falcon
rigid island
#

its a common effect you can do with some dj / daws but idk what its called exactly

#

you basically set the loop repeat to be very close to each other

toxic prawn
#

but the main problem is that I dont know how to get the current audio

#

I can get the whole track but not the exact part where its playing at the moment

rigid island
heady iris
#

You'll want to repeatedly reset the playback position

#

Audio data goes into a ring buffer. If no new data is written into the ring buffer, then the audio system will keep playing the same short bit of audio over and over.

winged shadow
#

guys im losing my mind

fervent furnace
shell scarab
#

Hey guys, is there any real reason to use js for cloud code besides that you want to?

#

from an initial look it seems that using c# is just easier

chilly surge
#

Which "cloud code"?

shell scarab
chilly surge
#

I have not used Unity's, but have used other serverless functions of other platforms. Serverless functions is one of the places where C#/.NET are still somewhat playing catch up, both because of the big bundle size and long cold start time, and in general most of the backend ecosystem is made for monolith. Technologies like NativeAOT and minimal API are recent additions to .NET to improve things.

shell scarab
#

I saw the warnings about cold start times, but I couldnt find any actual timings

chilly surge
#

You can probably look at some benchmarks of AWS lambda cold start times and get a good idea.

#

NativeAOT is a giant step forward to improve cold start time, and that only happened recently.

shell scarab
#

Looking that up, 500-700 ms is not terrible for me I don't think. Would that cold start time be something like per function, or the entire module?

chilly surge
#

The entire serverless function, once it's warm subsequent requests hitting the same function will not suffer from the cold start anymore, but that depends on the infrastructure of the cloud platform. I would think UGS probably is just repackaging and reselling AWS or something with a markup.

shell scarab
#

according to unity staff on the forums it's an in-house solution built from the ground up ๐Ÿคทโ€โ™‚๏ธ

#

but I can't imagine it would be very far behind AWS's timings

chilly surge
#

Best to test it yourself then, since different cloud infrastructure can do things differently. If you are not locked into Unity's, you can always evaluate other cloud platforms.

shell scarab
#

Since it's my first time dipping my toes in these waters Unity feels safer and easier, and because it'll most likely be a game me and my friend release (after years of game jams and such, not just starting thinking I can make it big haha), I would like to stay with Unity for now.

chilly surge
#

I use Cloudflare Workers for a project and it was very nice that my code runs wherever the client is, so issues like "my function runs on a data center in US and clients from Asia gets ridiculous latency because every request has to round trip half across the world" don't exist.

shell scarab
chilly surge
#

Per request yeah, but it only counts actual CPU time. Eg if your worker does something like "query from database and return a number" that's basically 0 ms no matter how long the database query takes, because that's network time and CPU is not doing anything.

shell scarab
#

ah well that's good. Cloudfare does seem pretty good, I'll probably try it out next time depending on my experience with UGS Cloud Code. But it does sound like I might want to use js based on the longer cold start times you mentioned for c# if it's per function. Thanks for the help!

chilly surge
#

Np. If you are comfortable with C# then it's completely fine to stay there, you might have more limited options in terms of cloud platform that can run C# serverless functions, but it's not like JS in cloud is all sunshines and rainbows either. Having options is always nice.

merry stream
#

When I try to set a boxcolliders size to the rect of an image that is being affected by a content size fitter, it is always being set to 0, is this a limitation or am I doing simething wrong

shell scarab
#

I'll at least try JS. I know basic JS, by no means an expert, I'm willing to learn though and at least try it. Maybe I'll even use a combination of both, JS for easier more common stuff (where I can) and c# for more compicated stuff (where I fail with js)

soft shard
merry stream
golden wave
#

Is there a better, more error proof and more readable way to do MySQL in C#?
I'm now just manually writing the SQL as a string, which has 0 error checking.

west lotus
golden wave
#

any preference? or are both options good?

#

separate .sql file seems easier?

#

don't know what linq is ๐Ÿ˜ฆ

west lotus
#

You are doing this on the backend right? Never ever ship your sql or db connections to the client

golden wave
#

yeah ๐Ÿ˜›

golden wave
dull glade
#

Is some kind of component I can put on a gameobject to show to me as a marker just so I can see it in the editor

dull glade
#

I mean for example when you create a light it has this cool image that only shows in the editor, so i want somthng like that for my invisible objects

spring creek
#

Could the collider outline work?

dull glade
#

That is the first thing need to lose to become a dev

cosmic rain
opaque jolt
mild holly
#

Hello guys, I am using the standar third person pack for character control in unity, as it is charactercontroller based, for physics, it comes with its own script BasicRigidbodyPush which adds force to the rigidbody object like a cube or something, problem is, as it is not based on unity's own rigidbody physics, it runs slow on slower devices, and I know you would say that Time.deltaTime should fix this, so I did try that but it made it slower of faster devices and faster on slower devices

light pond
#

how can i debug stuff like tileswaps in unity

jolly rune
#

you can update time.timeScale by setting it as a variable right? Its ignoring a line where I set it from the below variable, but not when I just do = number

time.timeScale = timeVariable; //timeVariable = 2f
steel quartz
#

maybe timeVariable is not the value you want?

#

Idk but you could trouble shoot like this

float t = 2;
time.timeScale = t;
swift falcon
# swift falcon Hey i upgraded the **SerializableHashSet<T>** https://gist.github.com/YunusYld/f...

Mapper Buckets of HashSet<T> was returning null because it gets deleted when entering the play mode if your all Enter Play Mode Options's Reload Scene and Reload Domain set to true or Enter Play Mode Options itself set to false. In case if someone face this problem in future, the fix is: do not derive from a collection if you wan't full control over it and feel free to use the code ๐Ÿ™‚

jolly rune
steel quartz
jolly rune
#

I think it was something to do with me setting Time.timeScale = 2f at the start of my script, and something about me reloading the scene, and the line up the top [which shouldnt be effected cause it was in an if statement] might have somehow reset it back to 2

#

there was a specific check to make sure it wasnt redoing it again but it I probably wrote it wrong lol

strange jacinth
#

Hey, anyone could help a little. I'm having a problem with aligning dice to selected side. When function is called it rotates towards "toSide" or one opposite to that.
Getters are fine and transforms are correctly attached.
Dice has graphics component (child) that should get reoriented fromSide that it got simulated with toSide that i want to re-simulate it.

 private void Reorient(int fromSide, int toSide)
        {
            Debug.Log($"Reorienting from ({fromSide}) to ({toSide}).");
            
            Vector3 fromDirection = _diceModel.DiceSide(fromSide).localPosition.normalized;
            Vector3 toDirection = _diceModel.DiceSide(toSide).localPosition.normalized;

            offset = toDirection;
            
            Quaternion rotation = Quaternion.FromToRotation(fromDirection, toDirection);
            Transform childTransform = _activeGroupRoot.GetChild(0);
            childTransform.localRotation = rotation * childTransform.localRotation;
        }
#

Sides are put in centers of graphics dice thus creating localPosition direction vector

fervent snow
#

Hey, does anyone know what would cause the "source file could not be found" bug?

Unity is telling me that it cannot find a file, but the script is literally exactly where it says it is in the directory, and it's being used by game object prefabs

#

It just randomly started throwing this error now I'm kinda stuck

strange jacinth
#

Try Ctrl+R to refresh

#

If that not helps, right-click on script directory and reimport

#

*In Unity editor

fervent snow
#

reimport did it, tyvm!

strange jacinth
#

Next time don't let your editor instance drink and drive :)

fervent snow
#

it has a mind of its own. I need more shackles

wheat spade
#

Is it possible to get the string value itself of a FloatField in a custom inspector? I want to detect the difference between the developer deleting the content of the field and the value actually being 0.

light pond
#

is there a furom channel for my long and complicated problem

steel quartz
#

I guess you can post it here with a link to your !code using one of the following websites

tawny elkBOT
dusk apex
light pond
dusk apex
#

This is the coding channel

light pond
#

its relative tho

#

this could be a problem in the code

dusk apex
#

"Could be" or "is"?

light pond
#

i really dont know because this problem is very mysterious

dusk apex
spring flame
#

maybe instead of talking about talking about the problem, start talking about the problem :|

light pond
#

and still didnt get a solid answer

#

so i will have to make a thread now

#

Tile swapping in editor but not build

#

i asked in every single channel

#

code that is

opaque jolt
#

Hey guys!

I need to make a warehouse logistics viewer in 3D (so basically to represents pallets in racks).
There can be between 1k to 100k objects but they can only be one of two meshes (Pallet or Rack).
Nothing moving; the only interaction will be a raycast from the camera to the pallets.

I was wondering if DOTS would give me any benefits in such situation ?
I read a lot about it but most articles I found are about animating a ton of objects more than just instantiating

Thank you for any hint you can give me ๐Ÿ™‚

winged shadow
#

can someone help me there is a problem that is happening that i just cant figure out at all

#

it makes no sense

winged shadow
#

i want to call so i can show via screenshare

wide dock
#

I doubt anyone would want that

winged shadow
#

why isnt there a call chat in this server

wide dock
#

If it's something you can't describe easily, at least show us a video of it

winged shadow
#

ill show the code and explain waht is happening

wide dock
#

It's just better if you actually describe your problem or post a video so that everyone can see it and answer if they know how to fix it

winged shadow
#

tell me when u open the link

wide dock
#

Just describe the issue you're having

dusk apex
winged shadow
#

so i have the explode function and the takedamage within the health script

#

and the deal damage on another

#

in my game i have 1 gameobject attack the other, 1 on my side and the other on the other client

#

the gameobject dies, it triggers explode which calls deal damage and then calls takedamage

#

i put debug logs in each function to see how many times they are being called

#

explode triggers once, deal damage triggers once, but take damage triggeres twice

#

howver it doesnt have the (2) on the rgiht side of the log, they both come up individually (1) and again (1)

#

in this order

#

how is this possible

#

take damage is being called twice

#

it must be to do with the rpccalls or something but when call dealdamage with the normal attacks take damage happens once as it should

cloud python
gray mural
dusk apex
cloud python
frail oak
#

I have been having a weird issue relating to my movement on the player

#

when you move the camera while moving, it seems to cause things to almost stutter

#

when you don't touch the mouse, the movement seems smooth and fine

gray mural
frail oak
#

but when you move the camera in a specific way, it seems to make your acceleration weird

dusk apex
cloud python
dusk apex
dusk apex
#
var transitionObject = //Find
if(transitionObject)//Not null 
{
    transition1 = transitionObject.GetComp...
    //do other stuff with transition1
}```Understand that if anything else needs `transition1` to not be null, they'll throw an error as well.
dusk apex
cloud python
dusk apex
#

If nothing were found, you would not want to do the get component call or operate with transition1

#

Which brings up the real question and problem: why was the object missing?

cloud python
dusk apex
#

The error is suggesting that it's not in the scene.

#

If you can fix that, you'll not need the pesky guard statement (referring to the if not null, do stuff statements)

cloud python
#

then I don't know what to code in

#

I mean like then I don't know what to write in

#

because this is all I got and the fact that everything works while there's an error

grizzled lintel
#

Greetings, all. I just have a quick question - how to check if mouse is moving clockwise or counter-clockwise? Is there any function for that, or perhaps a script online?

dusk apex
#

You don't really need to write code yet (we know it's not progressive tangibly but it's necessary). Try to figure out why the wanted object isn't present in the scene you're expecting it to be in.

dusk apex
cloud python
dusk apex
dusk apex
cloud python
dusk apex
# cloud python not for the transition1 in the level select scene because it's for the playable ...

So you can't reuse those lines of code for this other scene that doesn't have the missing object. Maybe consider using the guard statement pattern as suggested above or uniquely separate some of the logic in the code you've shown. Ideally, you'd want to decouple the code from the persistent object and have it be managed in the scenes that they are present in. This would ensure they're usable in those scenes.

cloud python
lone echo
#

!code

tawny elkBOT
formal wagon
#

Is there a way to switch on/off custom pre-processor directives for editor play mode? Project's too large for a full build, but there's some stuff I'd like to toggle for performance testing

dusk apex
cloud python
dusk apex
# dusk apex What object were these lines of code on?

I'm referring to which object in the scene hierarchy were these lines of code on? They're statements in a script so they ought to be a component on an object in the scene or some scriptable object instance or pure c# object (static whatever). @cloud python

cloud python
dusk apex
brazen junco
# formal wagon Is there a way to switch on/off custom pre-processor directives for editor play ...

Depending on the Unity version, you could do some "incremental" builds. As far as I'm aware, older version of Unity required you to explicitly start a "Script only Build" (which in my experience is already much faster).
Besides that it could be worth it to implement something that reads files in the StreamingAssets directory and adjusts the initialization accordingly. This way, you can test different combinations without rebuilding the project - and this would also take effect in the editor. (It might be even better if you could toggle things at runtime, but this could become even more effort to implement.)

Regarding in-editor: "the" way to toggle pre-processor defines would be to adjust the player settings. You could do some editor scripting so you just have to press a few buttons, but in any case you'd have to deal with local changes to the project settings.

If I'm not mistaken, you can also define preprocessor-defines in the msc.rsp, but it's been ages since I used it, so I don't have a documentation link at hand. =/

dusk apex
#

Or is this a Singleton object?

cloud python
dusk apex
# cloud python yes

So if you've got multiple unique instances of this manager and nothing's really moving (persisting, don't-destroy-on-load, etc) between scenes, perhaps consider referencing the fields from the inspector?

cloud python
cloud python
cloud python
dusk apex
cloud python
dusk apex
#

After properly addressing the references, you can determine what's absolutely necessary on every game manager script and what's optional per scene.

#

You'd decouple the unique functionalities into a different script and add that as a component on whichever game manager object that needs it, relative to each scene.

#

Communicating across different scripts might seem scary at first but it isn't really all that difficult once you're able to properly reference stuff

cloud python
dusk apex
#

Either have the accessor as public or add the c# attribute [SerializeField to make it visible in the inspector (they'll be serialized)

cloud python
cloud python
dusk apex
# cloud python decouple the unique functonalities?

For instance, Transition1 isn't present in particular scenes so you ought to move transition1 and all statements directly using it to it's own script - maybe you'd be able to couple a few functionalities or all of the remaining functionalities if the scene game manager objects only differ that little.

#

Can you share the script? !code

tawny elkBOT
dusk apex
elfin tree
#

Hey! I feel like I'm missing something simple.
So I have this code that's called

#

From Enemy here

#

Yet I get this

#

There should be a rigidbody, no?

#

(here you can see it is indeed called from that gameobject Flyer (Enemy 0) )

dusk apex
#

Alright, so this is a Singleton object - semi, without ddol. @cloud python Which is fine but likely unnecessary.

elfin tree
cloud python
dusk apex
cloud python
#

oh, workstation?

dusk apex
elfin tree
dusk apex
# cloud python

It looks like other than life and the game over functionalities, everything else can be done from other objects inside the specific scenes.

misty yacht
#

Hello,

I have a system where the player controls a rig that several units are child too. Units die and get added during gameplay, and so I have a script that sorts units into a formation dynamically by moving units between 5 slots in an arrow shape.

In a little more detail, the sorting is done by changing units parent transform between empty gameobjects that represent each slot. This works perfectly fine. I just want to make it so that the sorting is animated or visualized instead of units blinking instantaneously between spots. I think I have a rough idea for how to make an object move gradually, but I'm not sure how to do it when the transform is just changing the parent object and making the object move to the parent's transform.

This is a sample of the kind of code I have for moving units between slots:

if (delta1Trooper == null && delta2Trooper != null)
{
    delta2Trooper.transform.SetParent(delta1GO.transform, false);
}

Would doing something like adding some kind of DeltaTime clause in there be good enough? If so what would that look like? I think I would be able to take it from there to make the transform also speak to the unit's animator to trigger the walking animation in the right direction so it doesnt look like they're moonwalking side to side.

Alternatively, I might just not bother and add some kind of obscuring particle effect to hide the teleporting when units join or die

knotty sun
elfin tree
#

Hi again!

I have this code here that I just to make rigidbodies follow each other (the first one in line is always a no collision enabled gameobject so it's never part of this issue). This is called in FixedUpdate

    private void AddForceMove() {
        var targetPos = _target.position;
        var currentPos = _rb.position;

        if (IsCloseToTarget(currentPos, targetPos)) {
            // Debug.Log("Is Too Close!!");
            // gameObject.GetComponent<Renderer>().material.color = Color.red;
            return;
        }

        // gameObject.GetComponent<Renderer>().material.color = Color.green;
        var direction = targetPos - currentPos;
        var desiredVelocity = direction.normalized * _maxSpeed;

        var currentVelocity = _rb.velocity;
        var desiredVelocityChange = desiredVelocity - currentVelocity;

        // The most we could change velocity given our max available thrust force.
        var bestVelocityChange = Time.fixedDeltaTime / _rb.mass * _maxThrustForce * desiredVelocityChange.normalized;

        var actualVelocityChange =
            Vector3.ClampMagnitude(bestVelocityChange,
                desiredVelocityChange.magnitude); // don't change more than needed

        // rb.gameObject.name = "aVC=" + actualVelocityChange + " | cVN =" + currentVelocity.normalized;

        _rb.AddForce(actualVelocityChange, ForceMode.VelocityChange);
    }

My issue is that will sometime just bunch up and start blocking each other, any ideas of what i could do to make them recover better in that case?

misty yacht
knotty sun
elfin tree
gray mural
#

The solution to this issue depents on what you want to do when they block each other

elfin tree
#

complicated for me anyways

elfin tree
gray mural
elfin tree
#

i'm pretty bad with physics

elfin tree
#

i can fix this real quick

#

they are mostly all vector3s

gray mural
elfin tree
gray mural
elfin tree
#

i mean that could work, the only goal is for them to recover

#

i might try that

gray mural
elfin tree
#

or maybe just increase trust force when this happens so they can push through

#

maybe a timer triggered by the first collision: if there's x collision in y amount of time trigger this response

stark flower
#

Scripted Importer help needed

gray mural
gray mural
elfin tree
gray mural
dusk apex
# cloud python but this one is really needed in the world select scene for other scenes. what's...

The other functionalities can be place in scripts on the objects themselves.
With a bit of refactoring, you could reduce the references to simply the game over object: https://gdl.space/osunuhiciy.cs
Perhaps consider making the game over object a child of the manager as it's necessary in every scene and for ease of referencing - the child object of this DDOL object will persist in every scene with it.
The others shouldn't really be managed by this object as they can simply access the manager for data and adjust themselves accordingly after the new scene loads:
Assuming Transition object isn't a persistent object, you'd simply reference the image component from the inspector and set it's size delta to the wanted value: https://gdl.space/galuxijujo.cs
With the main camera, you'd just update it's rect size https://gdl.space/xebilafomi.cs
And with the second player, camera, transition and whatnot you'd just have a script on them to destroy them if not multiplayer: https://gdl.space/emokerawas.cpp
Start would occur after the scene has loaded so these would all be completed after the scene has loaded.

elfin tree
#

the issue is mainly they stay blocked and it seems to get worst

#

so there needs to be a response (using physics)

gray mural
elfin tree
gray mural
elfin tree
#

if the person they are following slows down they will stop accelerating to hopefully avoid crashing

gray mural
#

You should perhaps clamp their speed then?

elfin tree
#

it is, maybe it's just a matter of setting those values better

gray mural
#

See, their speed shouldn't be greater than that of the one they're following

elfin tree
#

good point, maybe i make sure that's the case aswell when they're too close, maybe they break or something

gray mural
#

Yep

elfin tree
#

thanks, i'll experiment with that

gray mural
#

Alright, wish you good luck ๐Ÿ™‚

spring creek
misty yacht
# knotty sun 'so I would just put "worldpositionstays" in those parentheses' - no - go read t...

So setting worldpositionstays to true and then running delta3Trooper.transform.position = Vector3.MoveTowards(transform.position, new Vector3(0f, 0f, 0f), 0.3f);
Is just resulting in the units globbing in the center and not going to their assigned spots

I'm guessing the coords I give are referring to the highest parent and not the immediate parent, but I don't know how to chnage that

knotty sun
stark flower
knotty sun
#

also not sure where you get delta3Trooper from as it's delta2Trooper you are changing the parent of

misty yacht
#

There are 5 troopers all named like that, its interchangeable

knotty sun
#

then you should be using an array not unique names

misty yacht
#

I have an array for the parent slots and then a class to assign objects belonging to those slots to the numbered trooper names, that part is settled and working fine so unless I need to change it to make the objects follow MoveTowards its fine

#

This is my first project and I've been away a few months for school so I'm stumbling around and trying to get the reins again

knotty sun
#

it's not fine at all, you are going to end up with a shit ton of duplicate code

cloud python
dusk apex
#

The code shouldn't do anything different than what you had before

cloud python
#

I said there's no cameraDivider, Transition2, MainCamera2 and Player 2 included in the script

cloud python
dusk apex
#

You wouldn't need it, you'd place the multiplayer script on those objects.

#

They'd destroy themselves on Start rather than having the manager search for them

#

They wouldn't need a manager to manage them, they'd request the data from the manager and be able to manage themselves.

cloud python
dusk apex
#

Maybe show the errors

cloud python
dusk apex
cloud python
thin hollow
#

I'm trying to create an extension method for lists to simplify checking that they aren't empty a bit, but I get error cannot implicitly convert type 'method group' to 'bool'
What am I missing here?

//Desired function usage example
List<Vector3> someList = new();
if(someList.isEmpty)
{
  //do stuff
}


public static bool isEmpty<T>(this List<T> a) where T : class
        {
            return a.Count == 0;
        }
dusk apex
cloud python
dusk apex
cloud python
#

what?

dusk apex
#

There shouldn't be any Find or Get Component in any of the code I shared

dusk apex
dusk apex
#

It's an extension method so you ought to have the round braces () - parentheses.

thin hollow
dusk apex
#

Are you referring to properties?

cloud python
# dusk apex Assuming you read and looked at this

this is my script, and what I shown in the videos here that in the player 2 button there is no errors and everything is perfectly fine, but in player 1 button, there is an error but doesn't disturb me much. and when I say they work alright they work alright with everything, but for some reason not the transition1 image on line 102

thin hollow
dusk apex
fervent furnace
#

also note that vec3 is not class

thin hollow
dusk apex
cloud python
spring creek
cloud python
#

like this and in transition

spring creek
cloud python
spring creek
dusk apex
#

PlayerManager.instance

spring creek
#

You didn't make a reference. You cannot use the type

#

Ah, it's a singleton. Yeah. I seem to remember Dalphat saying to use .instance earlier
If you are trying to do something someone said, follow ALL the directions

cloud python
dusk apex
spring creek
#

Le gasp! For shame haha
Sorry about that then linedol. I misremembered

cloud python
dusk apex
#

Just drag the game over object as a child of the game manager in every scene

#

You'd just child the game over object to it - assuming you've got a game manager and game over object in every scene for testing purposes. They wouldn't really be necessary in every scene (but the first) when finalizing the build as the game is meant to transition in one direction - from beginning to end.

cloud python
dusk apex
#

Probably on the objects you'd normally find to execute whatever code is written in them

#

You'll probably want to drag the necessary component references for each object too - it'd be the component on them.

cloud python
dusk apex
# cloud python

They should be on the Transition1 object and main camera object, last I recall

#

More work for the level designer but fewer potential runtime errors

cloud python
dusk apex
#

I'm assuming you know where to put the multiplayer script?

#

And the necessary editing (instance)

cloud python
dusk apex
#

You'll need to configure this for each scene, if applicable - relative to objects available (for example, the second scene lacks the Transition1 so you won't need to put the script on that object)

dusk apex
#

Use that P2 if guard statement to not adjust your camera if it isn't single player

#
if(!PlayerManager.instance.P2)
{
    //do stuff
}```
#

Same would apply with transition and whatnot

orchid swallow
#

Hey everyone! I working on a small game where the player controls a mouse simulating computer. However, I am currently facing an issue with my virtual cursor where the mouse does not clamp at the game object position, causing the screen boundaries to not work and consequently drag other objects to the outside. How would one always keep the mouse position at the cursor?

dusk apex
cloud python
somber nacelle
#

rather than using the mouse's position to change the position when dragging an object, use that fake cursor's position

orchid swallow
#

I did thought about this solution which requires some work arounds and I thought there might be a better way

#

But I guess thats just what I need to

cloud python
cloud python
#

are you also wondering the extra stage button i placed over there next to the boss stage? it's more like an extra stage for the story telling of going to the next planet

spring flame
#

I have a custom editor that uses UXML and another, derived custom editor that uses the same base UXML. When add a field like [SerializeField] VisualTreeAsset inspectorXml in the base editor, then I have to set this field for each derived Editor script manually. Is there some better way to do it? I was previously just doing Resources.Load<VisualTreeAsset>("UI/some_editor") inside CreateInspectorGui but this seemed... wasteful...

gray mural
sly comet
#

I am new to unity, I have a character made that has two movement types. I have the movement states as walking and sliding. Currently for testing I swap between the two using a hotkey, but obviously I'm going to have two terrain types. I'll have snow I can walk on, and ice I will slide on. What would be the best method for differentiating between the two? Check for the material my character is in contact with?

toxic prawn
#

can I make everything louder?

graceful patio
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;

public class PlayerController : NetworkBehaviour {}```
why is this not working 
I hae all the classes right?
somber nacelle
#

no

#

make sure that your !IDE is configured so that you can use the quick actions to add the correct using directives

tawny elkBOT
somber nacelle
#

i am aware. what i said is still how you can fix it

graceful patio
#

That wont fix it

somber nacelle
#

if you configure your IDE you absolutely can use the quick actions to add the correct using directive

graceful patio
#

its not my IDE IDE has no colleration to this error
its a compiler errror

somber nacelle
#

it is also a requirement to have a configured IDE in order to get code help here anyway. but yes, configuring it and using the quick actions will fix this

graceful patio
knotty sun
lean sail
somber nacelle
graceful patio
#

the IDE doenst have a built in Unity C# compiler

#

it is not my IDE

#

i jst want to make sure i have all the improts right

#

or if im missing packages

somber nacelle
lean sail
#

Wow everyone tells you what's wrong but you refuse to believe

graceful patio
#

that wont fix it

#

can u not understand this is a compiler error not an IDE error

somber nacelle
#

at no point were you told the issue is because of your IDE. you were informed that a configured IDE can fix this for you

graceful patio
#

it is not my IDE
no IDE has a built in C# compiler

somber nacelle
graceful patio
#

yeh

#

your not helping

somber nacelle
#

and you aren't worth providing help to

#

and again, a configured IDE would allow you to fix this with the quick actions. as has been stated multiple times

graceful patio
#

i missed a package

lean sail
spring creek
graceful patio
spring creek
somber nacelle
#

that may have something to do with the fact that it is not configured

spring creek
#

That is EXACTLY what they've been telling you
If you don't want to configure it, you must find somewhere else to get help

knotty sun
lean sail
#

Oh lag, you guys already wrote that

somber nacelle
#

maybe if enough people tell them they'll eventually realize we were all right all along

graceful patio
#

and it turns out the package was depreciated

#

u just wasted 20 mins

somber nacelle
#

quit spamming

vapid lynx
#

how do i fix this?

somber nacelle
#

https://docs.unity3d.com/ScriptReference/Random.html

Because the classes share the name Random, it can be easy to get a CS0104 "ambiguous reference" compiler error if the System and UnityEngine namespaces are both brought in via using. To disambiguate, either use an alias using Random = UnityEngine.Random;, fully-qualify the typename e.g. UnityEngine.Random.InitState(123);, or eliminate the using System and fully-qualify or alias types from that namespace instead.

#

same concept, but replace System with Unity.Mathematics in that description

graceful patio
#

but im wondering
what is the more supported version of it

#

if anyone knows how multuplayer works

#

that will compile

somber nacelle
#

surely you bothered reading the docs to see that Netcode for GameObjects is unity's current networking solution

graceful patio
#

can u not

#

just stop being sarcastic and just be nice

#

this isnt stackoverflow

somber nacelle
#

and this is #archived-code-general where you are expected to be able to read some documentation and have a basic understanding of how code works. as well as have a configured IDE

spring creek
graceful patio
#

ive been using unity for 2 years

merry stream
#

so I was asking this yesterday but still haven't come to a satisfying answer. How can I sort all the item labels in the world similar to how Poe/diablo does it? using rigibodies and boxcolliders work alright, but fail when many objects are spawned. I've tried to resolve a location directly above the collision by using OnColliderEnter2D, but since all of the labels have the same function, when one moves up, the one it collided with does as well and they end up shooting up forever. any suggestions?

somber nacelle
#

using rigibodies and boxcolliders work alright
your labels do not need physics. just use a physics query to find nearby ones

merry stream
#

how would I use those physics queries to sort?

#

would I just BoxCastAll?

somber nacelle
#

the physics query doesn't do any sorting. it just gets the nearby items or whatever as an Array/List

merry stream
#

yeah?

#

i know

#

im thinking about the logic requied to sort the positions

somber nacelle
#

sort them how

#

what does it mean for them to be sorted

merry stream
#

if two boxes are overlapping, the newest one would go above the older one

#

directly above

#

so would set the y position to the sum of the colliders extents

spring creek
somber nacelle
pliant summit
spring creek
merry stream
somber nacelle
#

i mean, the physics query would be used to find all of the nearby objects that need to display their labels. that would just keep giving you an updated list of them. then you just use that info to actually draw the labels sorted in the way you'd like. i'm not really familiar with the game you've referenced and you've not shown anything about your setup so i really can't be more specific than that, sorry

merry stream
#

well the problem can be considered as a packing problem

#

in the image it sent, all of those labels are items on the ground

#

this is an image from my game, as you can see it current has the issue that I stated before where the labels go too high since they are constantly colliding with eachother as they move up

somber nacelle
#

again, your labels do not need physics. they also don't really need colliders except for the possibly using the collider to determine how much space the label takes up

merry stream
#

yes, i am just showing it since you wanted to see my current setup

#

it is a bad solution though

toxic prawn
#

how do I make a message box?

sage latch
#

or do you mean like a dialogue box?

toxic prawn
#

in game

#

or like a windows dialog

sage latch
merry stream
soft shard
# toxic prawn how do I make a message box?

I would look into "C# callbacks", one way you can do it is have a function that toggles your message box and an action that something can subscribe to, so it can respond when a "yes"/"no"/"cancel"/"ok"/etc button on the message box has been clicked

toxic prawn
soft shard
toxic prawn
#

in C# I used messagebox.show(<string>); but it doesnt work in unity

soft shard
# toxic prawn in C# I used messagebox.show(<string>); but it doesnt work in unity

Right, MessageBox is native to the System.Drawing namespace, which wont work in Unity, this is why they have a UnityEngine.UI for graphics, so you would have to create the actual visual of the message box yourself, either with a Canvas, UIToolkit or some other way of drawing UI, which also means youd have to create the callback that .Show would normally do for you

toxic prawn
#

cant I do it so unity runs the c# program?

soft shard
#

What do you mean "runs the c# program?" it can compile and execute your c# scripts, but im not sure what you mean by "program" in this context?

toxic prawn
#

the .exe file

#

cant ฤฑ open it by unity script?

soft shard
toxic prawn
#

i want the messagebox like as in windows notificatio

soft shard
# toxic prawn i want the messagebox like as in windows notificatio

Right, and thats something you cannot use the native Windows API for (at least, not easily), in Unity that is something youd haeve to create yourself or maybe find a git project that already has done this, im not sure if theres any exe you can launch to create a message box for you, and even if you could, youd still need a way to know what button was pressed on the message box and have your code wait until one has been pressed

toxic prawn
#

can I send data to unity from an exterior program?

#

that will dix it all

soft shard
#

That, im not sure of, youd probably need some kind of dll or injector or something to listen for other applications, which sounds like a more involved approach to making a message box in Unity, unless your trying to make some native application outside of Unity?