#archived-code-advanced

1 messages · Page 197 of 1

rocky mica
#

haha

#

yeah Odin makes dealing with serialized interfaces a lot easier

#

I just cant go back to normal unity without it

#

at very least NaughtAttributes has to be in the project

undone coral
#

the question is: why.

#

why have IFireRate at all

#

you can use an abstract base class inheriting from behaviour. then attach it to a gun prefab

humble loom
#

if you read the prior convesation, obviously IFireRate is very simplistic, and not necessary if you just want a float, but having compositional design of something and each component "socket" having generic behavior, and being able to compose that from the script level is what the purpose is

undone coral
#

you already have composition, it's a prefab

humble loom
#

yeah you solved it

#

interfaces serve literally no purpose in programming

undone coral
#

when using the editor for storing data, they get in the way

graceful geode
#

Anyone know a good resource for learning about Rotation matrixes (or matrices?)?
Trying to learn how to rotate 3D vectors mathematically using linear algebra

undone coral
#

interesting.

woven kettle
#

hey is it possible to make a Raycast continue if it hit a certain target ?
for example If the raycast hit a player, i want it do some impact animations on the hitpoint but also keep going, what is the best way to do that ?

fresh salmon
#

RaycastAll, order by distance, loop over the results and break if you deem that something is not traversable

sly grove
#

You could also just do a RaycastAll and do something for each hit

fresh salmon
#

I am officially invisible it seems

#

(note that a sorting is required as RaycastAll results are in an undefined order)

sly grove
#

Only if order matters for this use case 😛

woven kettle
#

Something like that ?

public Transform source;
RaycastHit hit;
if (Physics.Raycast(source.position, source.transform.up, out hit, maxRange))
{
   if(hit.transform.GetComponent<Player>())
   {
      // do some hit impact and health damage to the first player 
       RaycastHit hit2;
       if (Physics.Raycast(hit.transform.position, hit.transform.up, out hit2, 500f))
       {
          if(hit2.transform.GetComponent<Player>())
          {
              // do some hit impact and health damage to the SECOND player 
          }
       }
   }  
}
#

I'm not sure if hit.transform.up would be the right direction; not sure if it would be the same as source.transform.up

fresh salmon
#

If your limit is 2, then yeah, otherwise you might need iteration or recursion

sly grove
fresh salmon
#

lol I am indeed invisible

sly grove
#

and no it'd be the same direction vector

fresh salmon
#

Or blocked

#

Not blocked, reactions pass

#

As for the direction, I would store the original direction in a variable, and pass it for each new raycast

#

That way it can easily be adapted if you use a loop or recursive methods

woven kettle
#

ok thank you guys!! @sly grove @fresh salmon
I had the similar mind at the beginning but I was skeptical as i'm not an expert and maybe there is a better way to do it

sly grove
woven kettle
sour marlin
#

How efficient is the IPointerDownHandler & IPointerUpHandler When there's atleast 80+ objects that implement those interfaces? Is it less efficient than just getting where the mouse was clicked and mathing out if that point is on an ui element?

My scenario is that I have a grid of tiles that all need to be "clickable" but that they need to know about when the pointer is down on them or up.

sour marlin
#

More efficient than just doing the calculations of where the mouse was clicked myself?

sly grove
#

Hard to say.

#

You could do the calculations for a simple 2D grid very fast compared to the general purpose interval-tree or quad-tree they probably use. but Unity's code is also running on the native C++ side so it has that advantage.

#

The benefits of working within the event system are many though, so I'd just stick with IPointerDownHandler etc...

#

if you notice a performance issue, you can revisit it.

sour marlin
#

Right, thanks a bunch!

turbid mural
#

Does anyone here uses Ryan Hipple approach for Game Architecture using ScriptableObjects the same way?

astral python
#

Anyone ? Can't make it work correctly. I've probably made some mistakes while porting this to C# but can't figure it out

onyx gulch
#

hey guys i tried to run a unity x86 (not x86 64) build headless server on a windows 2003 server but got .exe is not a valid Win32 application (the server have .net framework installed) any tips i'm missing or just isn't compatible

formal lichen
#

that seems like a pretty extreme use case and I'm assuming there's a bunch of waaaay out of date .NET stuff that possibly can't be updated even if you include newer .NET assemblies

onyx gulch
#

yep but in player settings say .net 2.0 that is even older...

high dock
#

I'm trying to use these two packages together in my Unity project:

https://github.com/oshoham/UnityGoogleStreamingSpeechToText
https://github.com/YarnSpinnerTool/YarnSpinner-Unity

Unfortunately, both have the dll file Google.Protobuf.dll, and Unity requires that there be only one of a dll file present. I've tried renaming, however, due to the different versions between the two packages of this file, they throw a weird versioning error:
The type 'ByteString' exists in both 'Google.Protobuf, Version=3.8.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604' and 'Google.Protobuf, Version=3.15.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604'

I've also tried overriding references AND renaming the files for both assembly definitions but to no avail.

Do you know of any way I can use these two packages?

long ivy
#

decide which one you'll use, and disable the other one in the editor (made sure all platforms unchecked)

misty glade
#

Looking for the big brains.

I have a BigDecimal class for an idle game with two members, a decimal Mantissa and int Exponent. The Mantissa must be between 1 (inclusive) and 1000 (exclusive) and the Exponent must be a non-negative multiple of 3.

I've overloaded operator* (multiply) and operator^(BigDecimal left, int right) (raise to the power).

It's not fast. I have a need to do this every frame in my client. Any obvious optimizations?

https://pastebin.com/LmspDKbj

Alternatively, any strategies for profiling this? I'm not an expert in profiling.

#

The code in question that's slow:

private const double ManualTapCostStartingA = 50; // Cost to upgrade level 0 to 1
private const double ManualTapCostR = 1.5;


public static BigDecimal GetManualTapUpgradeCost(int currentLevel, double reductionPercent = 1) => (((BigDecimal)ManualTapCostR) ^ currentLevel) * ManualTapCostStartingA * reductionPercent;
#

Hm, OK, nevermind entirely, problem is elsewhere in the code. The above still runs millions of times in a second no problem

hushed flame
#

Is there a way to standardize the size of different models to make them all the same size ?
I have the player upload various 3d models and I want to make them all the same size

somber tendon
turbid tinsel
#

is there a way to uniformly generate random points inside a sphere in HLSL?

#

AKA Unity.Mathematics, due to the similarities

#

I can't use UnityEngine.Random

high dock
#

How can I get IAsyncEnumerable? One of my packages requires it and I was wondering if there was any way to get support for it without rewriting the package

novel plinth
#

that does not guarantee it would run on separate thread, if running on a thread is your intention... unless you do context switching...

if you want to await but still running on a separate thread you can do this instead

var a = await Task.Run(() => 

{
  //do your thing
});

#

you may need to ConfigureAwait(true) so it would switch back to the mainthread once done or else your game will freeze

#

if you never dealt with multi-threading, you need to learn this carefully, I agree that your use case is very suitable for that

#

second method without configureawait but requires custom thread dispatching

var a = await Task.Run(() => 

{
  //do your thing

   //Operation end, dispatching
   MyCustomDispatcher(()=>
    {

    });
});
#

due to some constraints with configureawait, it may not always work for all use cases, thus you need your own thread-dispatcher

undone coral
#

C++ has templates that accept numbers, so that's how i knew there'd be an arbitrary floating point library compatible with your choice of mantissa and exponent sizes

undone coral
#

@turbid tinsel use voronoi in 3d and reject points greater than a certain distance away

undone coral
novel plinth
#

just waiting for a webrequest UniTask is just too much imho...

#

but that's an option too, yeah

#

also UniTask has the same restrictions as ValueTask.. I'm not sure how would you consume the task if the request hasn't been completed yet and you or users want to cancel it as GetAwaiter().GetResult() would throw... at least it won't in net 6

obtuse magnet
#

can somebody please help me with random level generation?

obtuse magnet
#

well

#

its not meant to be diagnol

undone coral
#

lol

#

hmm

obtuse magnet
#

with spaces inbetween

#

and stuff

undone coral
#

well you're very close

obtuse magnet
#

i am?

#

id assume im quite far lol :|||

undone coral
#

i think the inside of the rooms looks nice

obtuse magnet
#

oh yeah

undone coral
#

i'm not sure why you would have this sort of off by one error

#

you are probably mixing up your x's and y's in a for loop

#

that goes through the grid of rooms

#

wouldn't know yet

obtuse magnet
#

i dont use a for loop :|||

undone coral
obtuse magnet
undone coral
#

what do you do then

obtuse magnet
#

yeah

undone coral
#

so that i can smack a "jank" emoji on it

obtuse magnet
#

oh

#

uh

#

i have spawner objects on each of the rooms

#

(top right bottom left.)

#

and i spawn a room

#

to make sure multiple rooms dont spawn on eachother

#

i have a trigger on each room

#

and a box collider on the spawn script (and rb2d kinematic)

#

and destroy and thing

#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class RoomSpawner : MonoBehaviour
{

    public GameObject[] rooms;
    public string destroyTag =  "RoomSpawnedHere";

    private void Start() {

        Invoke("CreateRoom", 0.1f);
        
    }

    private void CreateRoom() {

        GameObject grid = FindObjectOfType<Grid>().gameObject;

        if(grid.GetComponent<RoomList>().roomList.Count >= 20)
            return;

        int rand = Random.Range(0,rooms.Length);

        Transform newRoom = Instantiate(rooms[rand], transform.position + transform.parent.position, Quaternion.identity, grid.transform).transform;

        // Transform newRoom = Instantiate(rooms[rand], grid.transform, true).transform;

        grid.GetComponent<RoomList>().roomList.Add(newRoom.gameObject);

        Destroy(gameObject);

    }

    private void OnTriggerEnter2D(Collider2D other) {
        
        if(other.gameObject.CompareTag(destroyTag)) {

            Destroy(gameObject);

        }

    }

}
#

but ometime i get thing like thi

undone coral
#

the issue is in your instantiate line

obtuse magnet
#

oh yeah

#

i couldnt figure out how to get the pos right with the parent and spawn point pos

#

probably should've mentioned that...

#

well this is... better

#

but still have unreachable rooms

high dock
#

nvm figured it out. Didn't work

undone coral
#

so i don't know. it's available in unity

high dock
# undone coral IAsyncEnumerable is in System.Collections.Generic

This is the error I'm getting

Error: Could not load signature of Google.LongRunning.OperationsClient:ListOperationsAsync due to: Could not resolve type with token 01000037 (from typeref, class/assembly System.Collections.Generic.IAsyncEnumerable`1, Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51) assembly:Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 type:System.Collections.Generic.IAsyncEnumerable`1 member:(null) signature:<none>

undone coral
#

it looks like you're trying to use a google cloud api library

#

or is this firebase for unity?

high dock
#

This has to do with two packages in my game. They both have the same DLL file on different versions. I went into one of the packages and manually updated to be the same version as the other package, but now I get this error.

high dock
obtuse magnet
undone coral
#

late versions of unity use netstandard21

#

and do not need it

#

how did you get these nuget packages into your game?

#

don't say the nugetforunity package

high dock
#

lmao that crashed unity

high dock
#

i just downloaded the DLL files

#

from nuget

undone coral
#

you manually went through and picked out all the dependencies one by one?

high dock
#

yeah 😅

undone coral
#

it looks like you accidentally grabbed netstandard2

#

if you want to do this correctly you can

#

create a separate solution with dotnet

#

target netstandard21

#

add the package references

#

then dotnet publish and grab all the dlls from there

#

it will choose the correct ones for you

high dock
#

Yeah that's what I did

#

Originally I picked them out by hand

undone coral
#

hmm

#

i've seen this error before and i resolved it how i described

#

but i only remember vaguely

high dock
#

It's saying it can't load Microsoft.Bcl.AsyncInterfaces

undone coral
#

it shouldn't have a reference to it though

#

if it's netstandard 2.1

#

however, my code is netstandard 2.0... it just happens to not reference it

#

you can also try disabling assembly validation

#

i believe there is also some kind of workaround for having an assembly with that name

obtuse magnet
#

pangloss please hlep

undone coral
#

that doesn't declare any types

undone coral
undone coral
#

all i can do is gently reassure you, like how i do with my baby or cat sometimes

obtuse magnet
#

but idk why the heck some rooms arent reachable

undone coral
#

heck indeed

obtuse magnet
#

:/

somber tendon
#

how did you spawn the rooms anyway? nvm, just need to look higher 😄

undone coral
#

like it's so close

#

try to not use .parent anywhere

#

you don't need it

#

it's almost always a mistake

high dock
#

let me try a thing one sec

undone coral
#

you need to deal with a "base case" the flaw is somewhere in doing the 1st room

obtuse magnet
#

alright…

#

but why the first room? they are all basically the same?

undone coral
#

i also sometimes reassure the chickens

obtuse magnet
#

reassuring intensifies

undone coral
#

lol

#

there there

obtuse magnet
#

i am happy. i am a chicken, baby, and cat all at the same time

#

thats a pretty darn good feat if i donsay so myself

high dock
obtuse magnet
#

… not sure why that one didnt work

#

but do you know why this one still gens those annoying unreachable rooms?

undone coral
#

this is pretty painful

#

try editing the project file directly

#

and changing targetframework to netstandard2.1

obtuse magnet
#

I FIGURED IT OUT

#

Thank you for reassuring me lol.

unkempt nova
#

So I'm trying to encapsulate "Actions" for my autobattler, so I can Move to a position, then cast a spell or something, etc. To encapsulate them, I'm trying to use generics, and just add Actions to a list to be executed sequentially afterward. I'm having trouble adding an object to the list though. Here's the definitions:

public abstract class PawnAction<T> where T : PawnActionParameters {
    protected T _parameters;

    protected PawnAction(T parameters) { _parameters = parameters; }

    public abstract IEnumerator Execute();
}

public class PawnActionParameters { }

public class MoveAction : PawnAction<MoveActionParameters> {
    public MoveAction(MoveActionParameters parameters) : base(parameters) { }

    public override IEnumerator Execute() {
        Debug.Log($"Moving to {_parameters.Position}");
        yield return null;
    }
}

public class MoveActionParameters : PawnActionParameters {
    public Vector3 Position;
}

Usage:

private List<PawnAction<PawnActionParameters>> Actions;
...
MoveAction move = new MoveAction(new MoveActionParameters {Position = pos}); // pos is a Vector3 
Actions.Add(move); // Error

Halp?

obtuse magnet
#

im not sure how to fix your problem…

#

but fyi when writing code snippets

#

after the ‘ ‘ ‘ add cs and a line

#

it will syntax highlight it

flint sage
# unkempt nova So I'm trying to encapsulate "Actions" for my autobattler, so I can Move to a po...

Visual Basic and C# have keywords that enable you to mark the generic type parameters of interfaces and delegates as covariant or contravariant.

A covariant type parameter is marked with the out keyword (Out keyword in Visual Basic). You can use a covariant type parameter as the return value of a method that belongs to an interface, or as the return type of a delegate. You cannot use a covariant type parameter as a generic type constraint for interface methods.

Note

If a method of an interface has a parameter that is a generic delegate type, a covariant type parameter of the interface type can be used to specify a contravariant type parameter of the delegate type.

A contravariant type parameter is marked with the in keyword (In keyword in Visual Basic). You can use a contravariant type parameter as the type of a parameter of a method that belongs to an interface, or as the type of a parameter of a delegate. You can use a contravariant type parameter as a generic type constraint for an interface method.

Only interface types and delegate types can have variant type parameters. An interface or delegate type can have both covariant and contravariant type parameters.

Visual Basic and C# do not allow you to violate the rules for using covariant and contravariant type parameters, or to add covariance and contravariance annotations to the type parameters of types other than interfaces and delegates.

For information and example code, see Variance in Generic Interfaces (C#) and Variance in Generic Interfaces (Visual Basic).```
https://docs.microsoft.com/en-us/dotnet/standard/generics/covariance-and-contravariance
unkempt nova
#

Oh, been meaning to read up on these. Thanks

flint sage
#

I think the solution is to make your PawnAction and interface and define T as out T

unkempt nova
#

Thanks, will have to read up on this

hushed flame
#

is there a bound just for mesh ? i was using the collider bound but when i add a box collider, the collider doesnt fit the mesh if the mesh have alot of children

somber tendon
#

You can use mesh.bounds I guess

foggy cobalt
#

Hey Guys, does anyone have experience with an event based state machine?
I have a state machine like this:

#

The state machine updates the state, the state does its actions and checks for transitions. The transitions have a decision which contains logic and return a bool, if the result is true it switches to the next state.

My Problem with this is that the state controller has all sorts of references, for example I put the state machine on an enemy.
My first state is a patrol state, in that state i want the action to be "Patrolling", which basically means find a waypoint, go to that waypoint and find a new one if one is reached.

public class Patrol : Action
{
    public override void Act(StateController controller)
    {
        controller._Navigation.EnableNavigation();
        if (controller._Navigation.ReachedDestination())
            controller._Navigation.SetDestination(controller._Navigation.GetNewDestination());
    }
}

You can see here that the state controller needs a reference to a navigation system "_Navigation".
My question is how would i decouple this? If i want to remove or replace the navigation system i will get all sorts of errors, plus i maybe want to put the state controller on something else, like an NPC which doesn't have a navigation system....

I'm having a hard time wrapping my head around implementing an event based system for this and would really appreciate if someone can give me a push in the right direction.

flint sage
#

Dependency injection with interfaces the define the contract

#

Then if you want to change the navigation system you just create a wrapper around the new system that exposes the same contract as defined by your interface

foggy cobalt
#

So i have something like

public interface INavigationSystem
{
    void SetDestination(Vector3 pos);
    Vector3 GetNewDestination();
    bool ReachedDestination();
}
public class EnemyNavigationSystem : INavigationSystem
{
   
    public void SetDestination(Vector3 pos)
    {
     
    }

    public Vector3 GetNewDestination()
    {
       
    }

    public bool ReachedDestination()
    {
        
    }
}
#

and how would i inject this and where

mighty latch
#

If your Patrol state requires a type of Navigation system, it can be passed through the constructor when creating a new instance, or through a separate method that every State can inherit from I think

foggy cobalt
#

I don't see how that would decouple references. The states are ScriptableObjects, so they share all the same properties and functions and i can't pass anything through a constructor.
But even if i could. How would that look like?

public class StateController : MonoBehaviour
{
    void CreateState()
    {
        INavigationSystem navigationSystem = GetComponent<INavigationSystem>();
        State patrolState = new State(navigationSystem);
    }
}

Like this the state controller is still dependend on a navigation system...
If i would let the state care about it's dependecies like:

public class State : ScriptableObject
{
    public List<AI_Action> actions = new List<AI_Action>();
    public List<Transition> transitions = new List<Transition>();


    void GetReferences(StateController controller)
    {
        INavigationSystem navigationSystem = controller.GetComponent<INavigationSystem>();
    }
    
    public void UpdateState(StateController controller)
    {
        DoActions(controller);
        CheckTransitions(controller);
    }

    private void DoActions(StateController controller)
    {
       
    }
    private void CheckTransitions(StateController controller)
    {
       
    }
}

This will still produce errors when removed and it'll make the whole state machine way less modular.
Because now i have to either pass the navigation system to the actions and transitions or have a reference to the state on those...
Which than means I can't just simple swap actions in a state.

nimble imp
#

I'm spawning a big table of text items. This takes a long time.
Do you think the Job System would be able to speed this up?

As I understand it the Job System is not able to edit the Text.text anyways, so I would have to loop over it all again?
How would you speed up this spawning? (object pooling is slower)
Or how could I show the window first, and then start loading the list?

Also, deleting the window or moving the window around takes a long time, anyway I can speed that up?

foggy cobalt
#

Look into the new ui system, there are scroll lists which recycle items, so not every item is loaded at the same time and when you scroll the top items get placed at the bottom with the content replaced

nimble imp
#

What exactly should I search for? This sounds interesting.

hushed flame
nimble imp
#

thanks! 🙂

#

And for the sorting of the long list, is that achievable through the Job system? 🤔

foggy cobalt
#

sorting?

nimble imp
#

Yeah, I sort that list by Country, then City.

foggy cobalt
#

that shouldn't take very long.... how big is that list?

#

and how do you sort it

nimble imp
#

about 4k items

#

Linq

foggy cobalt
#

have you debugged just the sorting with StopWatch?

nimble imp
#

About a year ago, but I decided to postpone the perf improvements to when it made more sense to focus on that 😛

#

I should do it again, you think it won't affect that much?

foggy cobalt
#

i doubt it will take more than couple of ms

#

try it

nimble imp
#

I hope you're right 😄

#

Thanks for the help: )

spare pond
#

Hey, Who have experience with VContainer? Can't understand how to Register factory.

loud plume
#

Anyone here good with camera manipulation and bounds of objects? My game is built for portrait devices and I have the main game camera viewport rect offset to allow for space for some UI elements. I then grab the bounds of all the renderers in the game and adjust this for the viewport rect. And zoom the camera z position to show the entire scene…

        
        foreach (Renderer render in il_renderers.OfType<MeshRenderer> ()) {
            totalBounds.Encapsulate (render.bounds);
        }

        
        if (b_resetCamera) {
            Vector3 viewPos = Camera.main.WorldToViewportPoint (totalBounds.min);
            float c_yPos = Camera.main.transform.position.z;
        
            yield return new WaitForEndOfFrame();
        
            if (viewPos.x >= 0.125f) {
                while (viewPos.x >= 0.125f) {
                    Camera.main.transform.position = new Vector3 (0.0f, 0.0f, c_yPos);
                    c_yPos += 0.5f;
                    viewPos = Camera.main.WorldToViewportPoint (totalBounds.min);
                    yield return null;    
                }
            } else {
                while (viewPos.x <= 0.125f) {
                    Camera.main.transform.position = new Vector3 (0.0f, 0.0f, c_yPos);
                    c_yPos -= 0.5f;
                    viewPos = Camera.main.WorldToViewportPoint (totalBounds.min);
                    yield return null;    
                }            
            }
        
        }```

However the arbituary 0.125f used for portrait screens isn't correct for landscape - how can I ensure that all objects fit within the camera viewport and position the camera at that point?
#

As you can see as the game advances the 'cropping' gets worse!

loud plume
round star
#

Hey, I’m running into this issue that is preventing me from making a build of the game. since updating and trying to build I’ve been getting this popup prompting me to install unity 2019 etc, even though the unity version in the ProjectVersion.txt is up to date. Where is unity getting this idea from?

hardy jacinth
#

does a shader need something special (order or queue) to be able to read from depth texture?

hardy jacinth
#

because I want to read camera's depth for already rendered objects and terminate my raymarching at the depth

#

to make raymarched objects and regular geometry renderable at the same time

#

but SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, i.screenpos) seems to have no effect...

undone coral
#

can you roll back before your upgrade

terse cedar
#

did someone used sqlite4unity3d for android ?

undone coral
#

cinemachine will zoom or dolly the camera to fit all the objects

undone coral
undone coral
#

on a typical machine

#

in the worst case

undone coral
#

text rendering performance in UGUI is very poor

#

it's probalby just as bad in UITK

nimble imp
granite viper
#

@nimble imp

nimble imp
#

Basically a self made ListView?

#

I'm considering it. I feel changing my project from GUI to the Toolkit may take some time.

undone coral
nimble imp
#

UGUI

undone coral
#

You can try OSA

#

From the App Store

#

But really you need to render the text in 1 pass, which is super hard

granite viper
#

can't tmp be batched?

undone coral
#

You can also put it on a different canvas

undone coral
#

It gets composited

granite viper
#

hm

undone coral
#

Also each row is its own thing

#

I don’t know UGUI and likely UITK both suck at rendering tables

#

Of text

granite viper
#

I see what you're saying

#

makes sense

nimble imp
#

Do you have a link for that OSA, can't find it on the asset store;
But that infinite scrollview makes a lot of sense to me.

undone coral
#

Optimized Scroll View is what it’s called

#

I’m on my phone sorry

nimble imp
#

found it 🙂

#

Ah, €50 is a hefty price for something that you don't know if you will have to rewrite it yourselves anyway 😛

undone coral
#

You can always ask for a refund

#

I try not to be too bummed about assets

compact ingot
unkempt socket
#
    void OnParticleCollision(GameObject other) {
        if(other.tag == "Wind") {
            Rigidbody particle = other.GetComponent<Rigidbody>();
            rb.AddForce(particle.velocity);
        }
    }

how do I access the velocity of a particle?

#

is it even possible?

#

tells me there is no rigidbody attached to the particles...

hardy jacinth
#

ah, no sorry

#

probably using built in

turbid tinsel
#

Hey, is there a way to have a fade rendermode in URP?

compact ingot
unkempt socket
#

is it possible to access the particle systems rotation from the particle?

#

sadly cant find any documentation on what is possible with the Gameobject of the particle

compact ingot
unkempt socket
#

hmmm

compact ingot
#

a more powerful particle api is vfx graph

unkempt socket
#

yeah im using that as well, but you can extract even less information from that

compact ingot
#

That’s kinda inherent to the way it operates

unkempt socket
compact ingot
#

Maybe you should use entities

undone coral
unkempt socket
#

made that vfx wind effect and I placed a particle system inside

#

I want those particles to collide with the player and kick him aside

compact ingot
unkempt socket
#

never did that before, so I assume there is a better way? 😄

#

or you know a better way

compact ingot
unkempt socket
unkempt socket
#

even tho setting the direction of it would be annoying since the wind can have multiple directions but i guess thats fine

loud plume
#

Could you grab the direction of the wind and apply a similar force to the rigidbody during the collision detection?

compact ingot
undone coral
loud plume
#

Hmm, I have the solution working quite well, but will take a look at cinemachine too - thanks for the idea

undone coral
#

i was gonig to answer you there

#

in the future don't cross post

#

what if you did transform.forward = -linkedPort.transform.forward.

#

you have no reason to use rotations

#

you were overthinking this

#

what if you added a transform for every face

#

the snapping point

#

you sort of need a transform for each snapping point nayway

#

the key insight here is that you can set the transform's forward

#

it's not the underlying details

#

okay

#

then try what i wrote

#

alright i think i helped you as much as i could

#

the key insight here is that you can set the transform's forward

#

do you see why that's important @undone crow ?

#

i don't know why you're not trying it

#

you shoudl at least see what happens

#

it will help you put toigether a complete solution

regal olive
undone coral
#

are you saying that you want the forward of one object's child to face the forward of another object's child?

#

you're trying to connect parts

#

and have them rotate right?

#

the module is always rotated the same direction
i don't know what you mean by this. clearly if you set transform.forward on something and the forwards change, it will rotate

#

are you trying to say you don't want the module to rotate?

#

there are a lot of ways to do this. you can use constraints, you can use a dummy game object, you can interpret the port's forward relative to the parent...

#

i mean you have to think about this

#

i can of course just do it for you

#

but you're going to do transform.forward = somewhere

#

because as soon as i saw you're using an angle it meant you didn't know how rotations really worked

#

like what if you do transform.right = ... when it's the right port? etc. etc.

#

you have to think a little sure

#

you can look up "how to turn a vector into a quaternion"

#

i mean there are ways to have an object "point" in a direction

#

that's what quaternions are for

#

there are lots of ways to do this

#

you definitely know the port's transform relative toa module

#

how could you not

#

you know which objects are ports

#

what do you mean relative?

#

alright

#

it's okay i think you'll figure it out

#

sorry i think you'll figure it out

#

my bad

gray pulsar
#

Personally, I think drpangloss was extremely helpful. In fact, they did the opposite of treating you like a "day 2 coder." They treated you like a competent programmer and gave you all the tools you need to solve the problem.

I'll give you a few more breadcrumbs, though.

It is trivial to construct a rotation to rotate an object such that the child's forward direction points in the direction the parent's forward direction did before rotating. Look at Quaternion.FromToRotation.

So, you need to...

  1. Find the correct direction that you want child.transform.forward to be pointing
  2. Set parent.transform.forward to be pointing in that direction
  3. rotate parent.transform using a rotation that then aligns child.transform.forward correctly

You could also combine steps 2 and 3 into a single step pretty easily

turbid tinsel
#

is there a way to make a package dependency when exporting a unitypackage?
like, that it automatically downloads all neccessary packages
I'm trying to use package.json, but it's recognized as a text file, not as package info

high dock
high dock
# undone coral and changing targetframework to netstandard2.1

Now I'm getting Assets/UnityGoogleStreamingSpeechToText/Runtime/StreamingRecognizer.cs(329,23): error CS1705: Assembly 'Google.Api.Gax.Grpc' with identity 'Google.Api.Gax.Grpc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=3ec5ea7f18953e47' uses 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' which has a higher version than referenced assembly 'netstandard' with identity 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'

#

which is odd because when I try to switch to netstandard2 I get warning NU1701: Package 'Google.Cloud.Speech.V1 3.0.0' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project.

loud plume
#

I have ``` i_numberOfObjects = i_gridX * i_gridY;

        for (int i = 0; i < i_numberOfObjects; i++) {
            float angle = i * Mathf.PI * 2 / i_numberOfObjects;
            Vector3 myPos = new Vector3 (Mathf.Cos (angle), Mathf.Sin (angle), 0.0f) * f_radius;
            Transform myCube = PoolManager.Pools ["cubes"].Spawn (t_Cube.transform);
            myCube.GetComponent<Renderer>().enabled = false;
            myCube.position = myPos;
            myCube.GetComponent<Cuboid> ().i_myCube = i_cubes;
            i_cubes += 1;
            lgo_Objects.Add (myCube.gameObject);
            
        }``` which creates a set of objects placed around a circle of `f_radius` radius - as I add more objects in i_nuberOfObjects I would like the radius to expand so that objects do not collide - does anyone have any idea how I could possibly accomplish that?
gray pulsar
# loud plume I have ``` i_numberOfObjects = i_gridX * i_gridY; ...

the arc length of a segment of a circle w/ angle theta is radius * theta. If your angles are small, its a reasonable approximation to say the arc length and the chord for that same segment are equal (this is the same as saying your objects are small relative to your radius). And the chord is equal to the maximum size of the object you can fit in that given arc without overlap (this assumes 2d line segments. For objects with more depth in the direction of r this approximation might get bad).

So, the total arc length taken up by your objects is numObjects * widthPerObject, and the max arc length available at a given radius is 2Pi * radius. thus, the min radius required to fit the objects is: radius = numObjects * widthPerObject / 2Pi

Again, assumptions are the objects are small relative to the radius/arc length and depth is small relative to width. If they are placed with inner edges at the circle rather than centered on the circle the second assumption doesn't matter.

loud plume
#

😄 thats something for me to contemplate tonight - thanks @gray pulsar

misty glade
#

I have a player model, along with a state manager singleton that holds the single reference to "the player". This model can come in from the server, and I have various UI components that subscribe to an action I fire from the singleton when the model is changed (OnPlayerModelUpdated). However, this can happen several times per frame, so obviously it's not a good approach for anything UI related that's instantiating or laying out components. However, I do want these dialog boxes and whatnot to respond to player model changes. What's your approach to this?

I've thought of two so far but.. I'm not sure how I feel about either:

A: Break down each type of state update into several and emit those granular actions instead.. OnPlayerDistanceUpdated, OnPlayerCurrencyUpdated etc.. ad nauseum.

B: The UI component hashes and caches the part it cares about and rebuilds itself only if the hash value has changed. Ie..

private int _lastKnownHash;
private void OnPlayerUpdatedHandler() // perhaps this is a "crew" dialog box
{
  int thisHash = PlayerStateManager.PlayerModel.Crew.GetHashCode();
  if (thisHash == _lastKnownHash) return;
  ... otherwise do all the UI update stuff ...
}

I'm sort of thinking option B is looking good?

#

the problem with approach A is I'd have to write a method to compare two models - a "client" model and "server" model and sniff for differences in order to emit those actions - I don't do that now, I just send the OnPlayerModelUpdated action and let whatever UI needs to rebuild their UI based on the state

high dock
hot dock
#

Can someone please tell me how can I manually serialize an instance of a serializable class? I assume there must be an existing API for that, no?

misty glade
#

Depends on what you want to serialize it to. JSON? byte[]? XML?

hot dock
#

It is really temporary, for a "copy/paste" function

#

to a simple string should do it

loud plume
hot dock
#

I have been doing this so far:

#

But it returns me a simple string like this:
{}{}{}{}{}{}{}

#

unserializable classes return a {}?

#

Well, it cant be... which means I must be passing the wrong class... Im going to re-check

full venture
#

ok so im making a vr game but when i have my vr plugged in and i go press ctrl p it only loads in my vr not unity

compact ingot
# hot dock unserializable classes return a `{}`?

All classes are serializable as empty objects. Whether their fields are serializable depends on their type and the serializer you use. JsonUtility is known for being quite limited in what it can do.

full venture
#

mb

hot dock
#

Ok, indeed. I was not passing the serializableData, but a container with the Serialized data

undone coral
#

you are going to have a very hard time at getting this to work

#

period full stop

#

you'd have to figure out grpc core

#

it appears that you are on a macos device, is that right? @high dock

#

if it's an ARM64, you're talking to the 1 guy who's publicly documented how to get grpc.core to run on macOS

#

there's someone else who has littered the grpc github issues with misinformation / is deeply confused

high dock
#

I figured it all out lol. Turns out the solution was very obvious and I'm dumb. Just had to download the updated version of Google.protobuf to match my other package and then update the assembly reference overrides in my asmdef file.

#

I get a ton of warnings, but it works!

undone coral
#

are you on windows or mac?

#

i understand that it might import

#

but i don't know if it's going to work

#

probably a bit premature to say that

#

the protobuf assembly isn't related to those issues

#

because unless you are using the grpc build for unity

#

it is probably not going to work

high dock
high dock
#

the package i'm using has bundle files for mac

#

haven't tested on windows yet though

#

sorry, i said errors - meant warnings

#

the warnings are just letting me know that it couldn't find the target version (3.8) so it's using the version it does have (3.15)

undone coral
undone coral
#

anyway good luck out there

#

you can disable assembly version checking in player settings

high dock
undone coral
#

is it using grpc.core? then it will be intel osx standalone only

#

is it using grpc.net? then it won't support bidirectional streaming - i don't know if google's apis support grpcweb

undone coral
high dock
#

i was saying yep to the "are you sure you tested it?" bit

#

one of my QA people is testing on windows now

undone coral
#

grpc.core works on windows

#

but i don't think you have a binary for it properly

#

unless you use the unity grpc build

#

do you know if you're using grpc core or grpc net?

high dock
#

core

undone coral
#

did you grab the unity build of grpc?

#

you would have a folder called Runtimes

high dock
#

it has runtimes folder so

#

ig?

undone coral
#

gotchyu

#

so yes, this will not work natively on apple silicon, if that matters to you

#

it will only work rosetta

high dock
#

ah

#

that sucks

#

well i mean it's not too bad

undone coral
#

there are other problems with the grpc this ships with, it's pretty old

#

but it won't really matter

#

nothing significant

#

i guess i should have asked you if you were using a library in the first place

#

i saw unitygooglestreaming... and i thought you named your own library you were authoring

high dock
#

oh nono i'm not that smart 😅

undone coral
#

lol

#

it sounds cool

thorny inlet
#

Anyone knows about generic trees, cuz i need help with that plEEease UnityChanPanicWork

meager kite
#

hi, im watching this tutorial here and i have a question

#

can an object have two states active at once? (eg shooting and running)

#

ah yeah just got to that part

#

so ill make a seperate state machine for weapons

compact ingot
#

if you use multiple state machines in a non-hierarchical fashion you loose most of the benefits of a statemachine

meager kite
#

but if i want my shooting and movement states to be independent of one another, what should i use here?

#

several state machines?

#

that seems convoluted

compact ingot
#

if you primarily want to manage multiple active states, you would use a different model to manage your states (not an FSM)

meager kite
#

what model would you reccomend?

compact ingot
#

i dont know if there is a name for it

#

but you could define a set of rules for each state that need to be true for it to enable, and on each tick it would evaluate all these rules and activate the states that are valid and disable others, triggering Enter/Exit callbacks

#

i'd call that an AspectMachine, but thats just my name for it

#

you could compare it to an inference engine that solves logic questions based on facts

meager kite
#

ok ill try to find a tutorial on it

jovial totem
#

is there a way i can get a public serialized field I can drag and drop into of any monobehaviour-derived class that implements a certain interface?

thin mesa
#

pretty sure you can do that with [SerializeReference]

humble loom
#

you can, it's very limited though

#

you can't do it with monobehaviours for example, which to me is the ideal use case for drag and drop references by interface

jovial totem
#

that technically works but unity really doesnt like it hahah

thin mesa
wooden flax
#

is there a way to enable floating notification or open app info the user can do it manually because xiaomi mobile devices comes with floating notification disabled

scenic forge
#

Is setting Thread.CurrentThread.CurrentCulture enough to apply that culture everywhere? Do I have to do anything extra for Unity things like Job system etc?

loud plume
#

Not sure where to mention this but importing the mediation tarball and allowing Unity to install/upgrade play services results in : General error during semantic analysis: Unsupported class file major version 57

hot dock
#

I have a problem about deserialization, that I have no idea how to solve.

I have a list of instances of classes with a common ancestor. I would like to serialize them in a way that when they are deserialized, they can still be upcasted. How could I do that???

frozen imp
#

Since you save them as a base class, only fields it has would be saved. Objects would not have any way of knowing what it had. You can cast it later as anything, it would just not have the information

hot dock
#

Yeah, that is the issue

#

I have no idea how to do it

sly grove
#

Use a more powerful serialization framework than JSONUtility

#

Some of them can save type information alongside the data so they can be deserialized properly

hot dock
#

@sly grove I have no experience on this area. Could you please give me an example or two?

sly grove
#

Newtonsoft Json

hot dock
#

Cool, I will look into that. Thanks a lot.

frozen imp
hot dock
#

Oh! I see

#

I am using it in an package i want to distribute. So I guess I will have to add it to the dependencies list

#

What do you mean "add it by the package name"?

#

I only see 3 options to add external libraries: from git url, from disk or from tarball

frozen imp
#

com.unity.nuget.newtonsoft-json

hot dock
#

mmm.... I dont have that fourth option...

#

at least not in 2020.3

frozen imp
#

It could be 2021+ yea

hot dock
#

So I need to copy/paste it manually? 😄

frozen imp
#

use its git repository name

hot dock
#

oh, lets see

#

mmm... didnt work

#

It worked, editing directly the Manifest.json

#

oh well

frozen imp
#

Glad it worked. I think it should've been just the url without the git part

hot dock
#

Well, it worked to add it

#

now lets see how it works serializing 😄

fresh salmon
hot dock
#

Thanks, ill take a look right away

flint sage
#

That looks like the wrong repository

#

That's the normal non unity netwonsoft afaik

hot dock
#

I am using this one, in my manifest:
"com.unity.nuget.newtonsoft-json": "2.0.2",

fresh salmon
austere jewel
#

If you don't have the "add by name" option, you put the name into the git url option and it works anyway

hot dock
#

It seems to be having trouble serializing Vector3...

austere jewel
hot dock
#

JsonSerializationException: Self referencing loop detected for property 'normalized' with type 'UnityEngine.Vector2'. Path '[0].NodeRect.position.normalized'.

fresh salmon
#

Ah yeah, the "downside" is that it serializes all public properties by default, unless you ignore them with a specific attribute. And since you don't have access to the source, you can't put the attribute.
You can however define custom type serializers that you pass to SerializeObject and DeserializeObject
https://www.newtonsoft.com/json/help/html/CustomJsonConverterGeneric.htm

austere jewel
#

The package I linked thoroughly handles all that

fresh salmon
#

Yep I just clicked on it now

hot dock
#

i will check it out...

#

Im still not managing to install a package using a git url... I have tried these:

#

none of those work :/

austere jewel
#

Read the installation instructions

hot dock
#

mmm... so I have a certain DLL in my project

#

But if I am building a package for distribution, i have no way to guarantee that people using it will have that DLL, no?

austere jewel
#

If you mean a package like an editor extension, no, you would have to require people install it themselves or you provide it to them

hot dock
#

Ok, I cannot afford that... makes my package much harder to use... :/

#

I will have to find a way to do it with the normal newtonsoft package..

austere jewel
#

I'm not sure what DLL you are talking about

#

If you mean the .dll it mentions as a dependency, that is what the newtonsoft package as in it

hot dock
#

It says it in the instructions

austere jewel
#

Yes, and that dll is in this package

hot dock
#

so I need both of them, then?

#

Ok, let's see...

#

mmm... i have no idea what an UPM is 😅

austere jewel
#

Unity Package Manager

hot dock
#

ah

loud plume
#

So I switched back to UnityAds and updated the plugin to the latest version in Package Manager - now calling Ad.Load in code I receive placementId cannot be nil or empty UnityEngine.Advertisements.Advertisement:Load (string,UnityEngine.Advertisements.IUnityAdsLoadListener)

hot dock
#

can installing a asset from the asset store update the scopeRegistries in your manifest?

austere jewel
hot dock
#

nah... i want to make my asset as "frictionless" as possible

#

I guess I will have to give up on a copy/paste function :/

viral inlet
#

guys please help, I'm working on an AR game project which was handed to me, there's a section in the game in which the user is prompted to take a selfie and i need to switch from the AR camera to the selfie cam. when I do the switch everything supposedly works fine but the selfie cam renders black. If i lock/unlock the device the selfie camera will render fine until i try to switch back to the AR cam again and then i will have the same black screen problem until i lock/unlock

remote oar
#

anyone knows why the DOLookAt returns "Look rotation viewing vector is zero" and the transform.LookAt() works fine?

hot dock
#

Question:

Let's say that I have a SO called Actor, and I create a couple of entries. Now, a couple of weeks later, I realized that the classname, namespace or maybe even assembly of the class is wrong. For example, I rather call it "Character".

Now, if I were to replace Actor with Character, all my existing instances would break. Is there a way to make it, so that they automatically migrate to Character?

I tried using [MovedFrom(...)], but that didnt do the trick...

flint sage
#

I'm pretty sure that you can change the name of a type as long as the GUID and content remains the same

hot dock
#

even its namespace?

flint sage
#

IIRC yes but that's a bit more iffy

#

If you're changing the assembly then it'll break

#

Keep in mind, if yuo're renaming the file you should also rename the meta file

hot dock
#

So I guess I am screwed

#

The problem is that I already have entries saved as "Character" and entries saved as "Actor"

#

so I need to change this, without breaking neither

flint sage
#

How big is your project?

hot dock
#

It is a distributed package. I am thinking about the users who have been using it.

flint sage
#

So what you can do is write an editor script that executes after the user updates (InitializeOnLoad), that finds all objects of Type Actor and rewrites the type to be Character

hot dock
#

Wont that replace the asset, messing all the references to the old ones?

flint sage
#

That is, if you create a new asset in its place instead of changing the type

hot dock
#

Im not sure how I would change the type with a script...

flint sage
#

You can either manually change the asset file to reference the GUID of the correct class or you can iirc use SerializedProperties to change the m_Script field

hot dock
#

sounds quite advanced

flint sage
#

Well yeah 😛

hot dock
#

(what a dumb decision i made...)

#

I guess thats the price

fresh salmon
#

Don't cross-post

#

The error is self-explanatory, you're using something that is obsolete

#

It's even telling you what to replace the obsolete code with

umbral trail
#

Did you get anywhere with this?

maiden turtle
#

I want a sort of OnValueChanged event, but using the serialized property manually in the callback to that

#

Oh, there's a RegisterCallback

minor mica
#

Hi guys. Does any can help me with my problem? I'm unable to use the copied image from clipboard. I tried to use the old system.drawing.image and system.windows.form dlls but I think the functions from the system.drawing.image dlls only return null values. Tried to search answers from stackOverflow, found some users with similar issues but there are no solutions.

ivory salmon
umbral trail
#

you can't sign up with same email?

#

I can see my issue, but I can't share it

brazen galleon
#

So this might be really hard, but is there any way to change the players desktop wallpaper inside a script? kinda like that one puzzle in oneshot. Thanks

flint sage
#

You'd be writing a virus at that point

brazen galleon
flint sage
#

Not really, wallpaper engine provides a service the user wants, you're implying that you're doing something while the player is playing the game that they didn't ask for

brazen galleon
mint burrow
#

if a game changed my wallpaper i’s be furious

inland delta
#

2

pale zinc
#

I'm confused; why would all your instances break?

#

oh woops, was scrolled up nm

velvet cliff
#

anyone good at making maps in 2d wants to help go to 2d tools pls

pale zinc
undone coral
woven kettle
#

Hi,

how do you guys delay update or by a float ( factor )?

I have a Raycast that makes the player fires as long as the player presses Space


Public float fireingRate;
void Update()
{
    if (Keyboard.current[Key.Space].isPressed) { Fire(); }
}

public void Fire()
{
     Debug.Log("Player is now Fireing!");
}

the current settings would make Fire() spray bullets almost like a laser!
I want to reduce the firing rate to be more believable like a regular Ak47 or MP5

sly grove
#

you cannot delay Update itself
use variables and logic to figure out in your code whether it's appropriate to fire or not fire in the current frame.

lavish sail
#

you have to either use a timer variable or a coroutine

empty notch
#

fun!

sharp pine
#

I'll give you an example:

{
     yield new WaitForSeconds(1f/FireRate);
     isAvailableToShoot = true;
}
sly grove
#

I highly recommend not using coroutines for this.

#

Overcomplicated and will introduce timing error

sharp pine
#

I guess you could do current frame mod something?

#

I've always done it with coroutines

sly grove
#
float timer = 0;
float fireRate = 25f; // shots per second;
float shotInterval => 1 / fireRate;

void Update() {
    if (Keyboard.current[Key.Space].isPressed) {
        timer += Time.deltaTime;

        if (timer >= shotInterval) {
            timer -= shotInterval;
            Shoot();
        }
    }
}```
woven kettle
#

@sly grove @lavish sail Thank you for your replies
Yes I understand that there are multiple ways of doing that, but I don't know which way would be the best for example one of my ideas, but it seems to be the best

float delay = 0;
void Update()
{

   if(Keyboard.current[Key.Space].isPressed) 
   {
    if (delay >= 5)
       {
          delay = 0; 
          Fire(); 
       }
      else 
       {
         delay = delay +1 
       }
   }

}
sly grove
#

no that's not good because you're just counting frames instead of time. Frame durations change based on the current framerate of the game

#

so you will shoot faster with higher framerate
Also setting delay to 0 discards the inter-frame time, leading to timing inaccuracy

lavish sail
#

Add deltatime to delay instead of 1

woven kettle
sly grove
woven kettle
sharp pine
#

Big if true. Weird.

sly grove
#

Coroutines themselves are fine - but coroutines for fast repeated timers have issues related to timer accuracy that make them not suitable. They're also just way more complicated than you need for this.

heavy frost
#

I don't know if this is the right channel to ask this in but

#

I've been working on this game for a while now and I want to add proper mod support where you can just drag your mod into a folder and be able to choose which mod I want to activate

How would I go with doing something like this? I'm guessing it's quite complicated since I can't find any tutorials online for unity modding

proven phoenix
#

ok this is a longshot specific question, but does anybody know how the ".SetSpeedBased()" function works in dotween

#

i cant get it to work

#

i think the problem is my tween starts already before the option is applied

undone coral
#

is there a way

#

to ensure there's a render thread

#

in batchmode

#

is there "windowless" as opposed to batchmode?

hot dock
sudden breach
#

Hey, How would I improve my coding structure to become more advanced and efficient in unity for creating larger projects. I have been using unity for a while but after seeing after other developers I have realised their coding was more advanced and seemed like a better structure, so I'm asking how would you guys improve your structure and could you give examples, or if you know any sources about this?

pale zinc
sudden breach
pale zinc
#

(it sounds like nonsense to me, use coroutines if they fit the problem you're trying to solve)

woven kettle
# pale zinc Sorry, what does that even mean?

Well, from what I've heard, it seems to be that coroutines creates junk temp files, and sometimes they don't clean up after itself.
But I agree with you and PraetorBlue's comment, they are not ideal for fast repeated timers

pale zinc
#

They don't create files. Things like 'yield return new WaitForSeconds()' can create a tiny bit of garbage, which that can be prevented by creating the WaitForSeconds object in Awake() and storing it in a variable

undone coral
#

if a package puts something into a Resources/ folder located in its file system, will that something be shipped into the player?

pale zinc
high dock
#

@undone coral Back again 😔. I'm getting this error when trying to build my project
Copying /Users/bremea/Desktop/Overdue/Packages/com.oshoham.unity-google-cloud-streaming-speech-to-text/Plugins/Grpc.Core/runtimes/osx/x64/grpc_csharp_ext.bundle to /Users/bremea/Desktop/OverdueBuild/MacOSBuild.app/Contents/Frameworks/MonoEmbedRuntime/osx/libgrpc_csharp_ext.bundle: No such file or directory

Why is it trying to copy from /Packages/? I have all of the assemblies in my /Assets/ folder.

undone coral
#

to your unity

#

is there a line for it in manifest.json?

high dock
#

I downloaded the source into the assets folder. There is not.

undone coral
#

you can't copy and paste it into assets

#

you have to create a LocalPackages/ directory if you want to vendor in a package like that

#

ProjectRoot/LocalPackages/com.oshoham.exactpackagename@packageversioninpackage.json

topaz scroll
#

I have my states set to idle and when I debug the character is always in idle, but on start the character starts walking when i want it to be in idle animation

undone coral
# high dock <@247793168056057857> Back again 😔. I'm getting this error when trying to build...

@high dock also you will need https://github.com/grpc/grpc/issues/22485#issuecomment-933666885 if you want to build for il2cpp

GitHub

What version of gRPC and what language are you using? C# on Unity with IL2CPP, Tried with both gRPC for Unity 2.29 and 2.26. What operating system (Linux, Windows,...) and version? Windows 10 What ...

#

on all platforms

high dock
#

Alright so I got it to build but now the game crashes as soon as I boot it. Let me try to get a crash report

heavy frost
undone coral
heavy frost
#

No

undone coral
#

or is it open source on itch?

heavy frost
#

Just a fan

undone coral
#

gotchya

#

what is your objective? modding?

#

if it's open source that's the best way to mod

#

asking people to PR

#

that's what modder swill tell you

#

especially the good ones

#

at the end of the day they just want the project source files and to PR their contributions

undone coral
#

@high dock try to build for mono first

high dock
#

i'm building for mono

undone coral
#

try building devleopment mode

#

super hard to say what th eissue is

#

it could be a million things

#

it's probably an async error

#

wrong threads

high dock
#

Ah wait it's a missing script

#

at least i think

heavy frost
# undone coral what is your objective? modding?

I want to make an entirely new engine from scratch that can run mods from a folder easily without having to redownload the entire game everytime, similar to what a lot of the fanmade FNF engines do

But its probably a lot more difficult to do in unity though

high dock
#

???

#

if you want to make a new engine from scratch why are you using unity

heavy frost
#

I don't mean game engine, I mean the actual game itself like

pale zinc
#

You could also look at how VR Chat does it

heavy frost
heavy frost
pale zinc
#

yeah, if you want to make content for VR Chat, you do so through a unitypackage

#

but if you don't have the rights to Baldis Basics, I can't recommend you go through with this project

high dock
heavy frost
#

It's 100 percent legal

#

And I'm pretty sure the original dev is fine with mods

pale zinc
#

It's not a mod if you're recreating it from scratch? What license is it under

heavy frost
#

Would it not technically be a fangame then?

undone coral
#

the problem with unity modding is not having the source

#

if you give peopel the source it's easy

#

then they can e.g. build addressables and it just works

#

if they need to add code you can use Mono and load the assemblies or merge it

#

it's the best way

#

in reality nobody who authors mods

#

wants to deal with mods

#

they just want to modify the source

#

even if there were 1,000 mods the game would probably go from 90MB to 400MB... it won't matter

#

you can always auto-update

#

don't overthink this

pale zinc
#

I don't see anything on this being open source

#

Just create your own game, don't copy someone else

undone coral
#

i'm trying to say that the user @heavy frost should make his clone fangame an open source game

#

is there a way package authors add things to the project's link.xml

#

or is there another way to preserve types specified in external assemblies for il2cpp?

undone coral
#

oh my god

#

do they not test hdrp with medium or higher code stripping?

#

this is a joke

tight cypress
#

This error is popping up and I do not know how to fix it. I have been trying to fix it for the past hour. Is there any expert on C Sharp that can help me fix it

regal olive
#

im making inventory buttons and my controller's navigate only goes vertical and horizontal, but i need it to go diagonal

shadow seal
humble leaf
#

(They left)

humble loom
#

or two scripts called PlayerAttack

#

oy

regal olive
#

I have an extremely specific need (want really). I want to run Unity headless. The same way you can create dotnet console projects using the cli, I want to create a Unity project and build it for Android, all from an Android device. I should be able to instantiate everything I need from scripts without the need for an editor, I just need a way to create and build a project.

#

Any resources to get started at least?

#

Thank you.

flint geyser
#

How do I create such a mini-camera view in the right bottom corner of scene view through scripting?

#

Like, I want a specific camera to always be shown there

#

I do not need some custom inspector guide regarding it, only the action of creating the mini window with camera

flint geyser
shy glacier
#

Nvm then

flint geyser
flat matrix
#

why my message is being deleted when I post code?

#

Can there be any issue related to threading (like deadlock) with this?

orchid marsh
frozen imp
#

Also looks like the bot (or new misconfigured discord feature) right now deleting messages with repeated spaces even in code blocks.

viral inlet
#

precious internet points are guaranteed to the solver

brazen hamlet
#
    {
        childLetGo.parent = null;
        LookingAtPlayer();
        Invoke("ChargeTowardsPlayer", 2f);
    }

    void LookingAtPlayer()
    {
        Vector2 direction = player.position - transform.position;
        direction.Normalize();
        float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
        Quaternion rotation = Quaternion.AngleAxis(angle + offset, Vector3.forward);
        transform.rotation = Quaternion.Slerp(transform.rotation, rotation, rotateSpeed * Time.deltaTime);
    }

    void ChargeTowardsPlayer()
    {
        transform.position = transform.forward * 5f * Time.deltaTime;
    }```

Hi just wondering,  why doesnt this object charges forward from where it was facing? it just stays the same. did i do anything wrong? 🤔
devout hare
#

You're setting the position to a very small vector, instead of adding to it

flat matrix
#

That invoke in update with 2s delay has no sense. It is, every frame schedule invoke function with delay. Why don't you just call it normally\

minor shadow
minor shadow
#

aight gonna try

undone coral
#

the python scripting package does not work in standalone players

minor shadow
#

found this error when installing the package

minor shadow
#

use webGL perhaps?

#

man this package is so confusing, anybody here know a better way for a python script to communicate with Unity? im talking about passing data here not just keyboard input stuff

untold moth
minor shadow
undone coral
minor shadow
compact ingot
humble loom
#

i'm curious, has anyone done an implementation of using "intelligent" yielding in a coroutine for like building caches and things like that? something like: https://paste.myst.rs/yywcj9np

#

an example as simple as this i would probably just use async but i'm referring more to the principle than this specific implementation

#

say it was like a batch spawning system

#

something that has to happen on the main thread

sly grove
#

Basically you could do something like have a budget of N milliseconds after which you'd yield

humble loom
#

Oh true

humble loom
#

Does deltatime not change within update?

#

Oh I get what you're saying. Like it'll increment but it'll start as time.time - time at last frame. So it wouldn't be counting the number of milliseconds ON this frame

gray pulsar
humble loom
#

Makes sense. Yeah I'd either have to use system time or cache time.time. though I thi k the latter is less precise

wooden flax
#

hi devs, as you all know that icons appear grey in android notifications, is there any way to make them colorful or make them appear the actual image

sly grove
#

It wouldn't really work if it wasn't

humble loom
#

yeah made sense immediately after i asked. guess i never really thought about it though but yeah

#

this seems like it should work

#

stopwatch starts at the beginning of each frame, if it runs for more than half a frame, it yields and resets

humble loom
#

oh crap it's hanging. i think i have to use milis

humble loom
#

cool that's working perfectly

real kiln
#

I cant assign a function in my code to an event in animations

humble loom
#

how did you set up the animation event?

#

you should be able to drag a gameobject as a reference and you'll be able to choose any of its PUBLIC methods

real kiln
#

right but thats a private method

#

should I change it to public?

humble loom
#

if you want it to be triggered by an animation event that is required

real kiln
#

I was following a tutorial and the guy used the same code but his worked

humble loom
#

animation events are most likely classes under the hood, so they'd function like any other class that takes your script as a reference

real kiln
#

hmm i dont think i understand

humble loom
#

again i asked you how you set up the animation event

#

i have yet to see that

real kiln
#

I am trying to set an event at 25

#

and then assign the function deactivate

#

but it does not showup

humble loom
#

you need to add an event

real kiln
#

i did

humble loom
real kiln
#

but i cannot assign deactivate which is the one i need

untold moth
#

Make it public

real kiln
#

i tried but unity crashed

untold moth
#

Don't think that related...

real kiln
#

hmm

#

ok

humble loom
#

you should have an object reference though. that's weird

real kiln
#

yah i find it strange

humble loom
#

should look like this when you double click the event you created

real kiln
#

i cant double click

humble loom
#

do you have your object selected? the one you're configuring the animation for

real kiln
#

also i did try setting it public didnt work

real kiln
#

actually

#

when i click 25 to set event it clicks off from the object to sample scene

#

is this normal?

humble loom
#

off the object or off the animation event

real kiln
#

off the object

#

friends used same code as mine their's work so i dont think the issue is with my code

humble loom
#

can you record a video of yourself doing this step by step
moving the play head to a location
selecting the add event button
navigating to the inspector window

#

i can get there literally no problem

#

made a new animation, moved the play head, pressed the button

real kiln
#

can we join a call?

humble loom
#

sure. it's late though so i can't go on mic

#

actually nvm i can

real kiln
#

ok

humble loom
#

are there no vc's in this discord

#

well that was an easy fix ^_^

untold moth
#

What was the issue?

real kiln
#

assigned the wrong script to the object lol

jovial totem
#

What on earth do these errors mean.

#

Does it have to do with gizmos

humble loom
#

does it say what script it's occurring on

obsidian glade
#

Line 3 suggests you're using a constructor where you shouldn't be

swift quail
#

hi guys, is multiplayer a advanced topic?

dusky carbon
swift quail
#

ah cool, thanks

barren scroll
#

Is there a way to make some specific area can be raycasted?
I am making a tutorial system, I've created a blocker to block the raycast, and I want the "highlight" object to un-block the raycast.
Or is there better approach?

fierce wind
#

I tried every way that I know to fix but nothing work
error:
NullReferenceException: Object reference not set to an instance of an object
ShopManager.LoadShop () (at Assets/Scripts/Managers/ShopManager.cs:48)
UnityEngine.Events.InvokableCall.Invoke () (at <db7f68c084e842d98504c53b2b4dd3db>:0)
UnityEngine.Events.UnityEvent.Invoke () (at <db7f68c084e842d98504c53b2b4dd3db>:0)
UnityEngine.UI.Button.Press () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Button.cs:68)

shadow seal
#

isOwned is null or date is null

#

You'd need to Debug.Log them both to see which is, they might of course, both be null

fierce wind
#

how i do i Debug.log them?

shadow seal
hollow garden
fierce wind
#

I know to debug.log

shadow seal
#

I mean really, a NRE should never make it here either

hollow garden
#

Debug.Log(variableName);

shadow seal
#

Then do it?

fierce wind
#

but which line in code?

hollow garden
#

well obviously before where the error happens

#

so before line 48

austere jewel
hollow garden
#

right

fierce wind
#

Thx

unkempt socket
#

any idea, why this doesnt work? You can barely see the fade in/out animation

#

its like 1000th of a second

hollow garden
#

so it happens in a single frame

unkempt socket
#

so id do it like that?

#

sry i didnt quiet understand them yet ´:D

silent fox
#

hey i am going to ask here because in the other i was in said it was really hard but i am not sure if it is not pls warn me

#

can i ask?

unkempt socket
#

you mean this ine right

silent fox
#

😅 i am making a first person controller using CharacterController and i repeat NOT RIGIDBODY. so i don't want my player to sprint mid jump or stop sprinting mid jump and all that. basically i want to make that if you have momentum and you are sprinting and jump you cannot stop sprinting but if you are not sprinting you cannot sprint during your jump. How can i make this?

unkempt socket
#

brooo, not trying to be mean right now... It´s not as if I´m not doing my own research.. whatever Ill do it myself

#

if you dont want to answer, than just dont type like cmon...

worldly rose
#

that's how you get better

unkempt socket
silent fox
#

no uhh so for ex: you can sprint mid jump or you can stop sprinting mid jump i don't want that i want to be at the sprint speed if we are already sprinting and we cannot stop it. if we are not and just jump we shouldn't sprint and we should jump at the default speed.

unkempt socket
#

after this project ill never touch unity again and I asked politely for an answer. People who feel like answering can do so, people who feel like "I´m too good for this, this is beginenr stuff" can just sit back and chill

#

you did, but you couldve just leave it at that

silent fox
buoyant vine
buoyant vine
#

interface Move{ Move Move();} lets say you got that

#

then in your character

silent fox
#

yeah

buoyant vine
#

void Update(){ if( Move() != null) currentMove = ...) }

fresh salmon
silent fox
#

no i am gonna try both

#

if one doesn't work try the other one

buoyant vine
#

in your jump you just dont react to input which you would react to move

#

just statemachine

#

both will work

#

without knowing what the other is

fresh salmon
buoyant vine
#

and cross posting is shit

silent fox
#

sorry i actually didn't know

silent fox
fresh salmon
# jovial totem Yeah, but how

Looking back at the stack trace, this is an internal Unity error (line numbers are all at 0). You can safely ignore that.

jovial totem
fresh salmon
#

Restart the Editor, if that doesn't fix it report a bug and attach the Editor logs.

buoyant vine
#

in your character controller you just swap states if the return is not null

#

null == stay in same state

silent fox
#

hmm

#

thanks for helping out

obsidian glade
# jovial totem Yeah, but how

you can trigger internal errors like this with unconventional code - the error suggests you're using a constructor in a UnityEngine object, so you'll need to look at your code and see if you're doing that

buoyant vine
#

if the object is in state jump the key input shift has no meaning

undone coral
# unkempt socket

if you want to animate / tween things, use DOTween. DOFade achieves this. you should use a canvas group

undone coral
woven kettle
#

Hey,

I'm using ParentConstraint on all children objects to assign a parent for them
but when I want to delete the parent, I also want to delete all it's children.
Is there is anyway to find which gameobject has a certain Item as a ParentConstraint.source ?

undone coral
dark cypress
#

Hi, is there a package I should read up on if I want to spin up Unity in a remote VM, send it some C# code, and see if it compiles? Then run unit tests and retrieve its XML document of results?

#

I think compilation errors are outside the purview of the Tests suite, right?

#

I have a "Runtime C#" asset but that seems maybe overkill, to have Unity in Play mode to test compilation

woven kettle
#

can I add the childConstraint on the parent and keep track of all the children under ChildConstraint.source ?

undone coral
#

you just make a field

#

don't overthink this

#
[SerializeField] private ParentConstraint[] parentConstraints;
void OnDestroy() {
 foreach (var child in parentConstraints.Select(c => c.gameObject)) {
  // you should probably assert that the parent constraint
  // specifies this object's transform as its only source
  Destroy(child);
 }
}

@woven kettle

#

there's no way to do this automatically

#

ChildConstraint doesn't exist

woven kettle
#

I need the parent to somehow know all it's children Percisily , Imagine if I deleted a gun with attachements ( children ) and a mag ( child also ) ..., the gun would disappear but everything else would just hang in the air and console would have an over float of errors.

undone coral
#

well

#

you make a field

#

see my example

#

don't overthink this

undone coral
#

what do you mean send some c# code? what's your objective?

woven kettle
#

it's not that simple, its a multiplayer game and that ParentConstraint would be on the attachements and mags not on the weapon ( the source in this case would be the weapon )

where could I just make a filed that is aware of all the parentconstraints and whne the object gets destroyed, im supposed to loop through that and compare the source of each to see if it matches the ones that has been destroyed ?? ... I dont think that is the best idea

undone coral
#

i think maybe you should ask #💻┃code-beginner @woven kettle because you're getting stuck on something

woven kettle
undone coral
#

why in the world wouldn't you know what those objects are

#

surely you have them in your scene or you Instantiate them somewhere

#
var attachment = Instantiate(someAttachmentPrefab);
attachment.parentConstraint.sources[0] = someWeapon;
someWeapon.implicitChildren.Add(attachment);
#

it seems so straightforward that yes maybe i do misunderstand

#

but you're also talking about something that makes no sense

#

i didn't show any comparisons or any loops

#

and besides, even if you have 10,000 attachments, so what... computers loop all the time, it won't register in the profiler

#

so you sound stuck

#

are you working with PUN? @woven kettle

#

anyway @woven kettle the answer is no. there's no pre-existing unity api for finding all the objects that use a specific object as a source in a parent constraint component

#

that's in the docs

#

so i guess you'll have to make a list and keep track of it in a place you deem appropriate

#

or just parent the objects

woven kettle
# undone coral why in the world wouldn't you know what those objects are

I'm destroying a Gun >>> the Gun has no idea if there is an item (like: attachement or magazine ) with a parentconstraint script attached to it and has Gun as the source.

if runGetComponentsInChildren it would only get the children in the hierarchy.. ( the attachments and the mag wont show up )

so to make a script/field on the Gun itself to keep track of those, is one possible answer (YES!)
but I was thinking, what if I used ChildConstraint instead ? , if I'm not wrong, to use ChildConstraint i need to add it to the Gun instead to the attachements, where I can use get component on the Gun and look for each source on the list

undone coral
#

so to make a script/field on the Gun itself to keep track of those, is one possible answer (YES!)
this is the answer... go code! by now you would have finished

woven kettle
woven kettle
undone coral
#

i don't think i was ever confused

regal olive
#

So I have this line renderer I was wondering how I would set the end of the line to follow a specific point like a mouse. And I want the rest of the line to bend

icy aspen
#

Hello everyone I have a question

#

Is it possible to make a public function which you can input in the script properties

#

So there would be a function that you can input there

regal olive
#

That doesn't really help 😅

undone coral
#

don't

#

say

#

that doesn't help

#

say what your objective is

regal olive
#

-_-

#

Ok well I was about to go more indepth until you said that

#

Ill get help from somewhere else

#

You can see when people are typing I thought you'd figure that

regal olive
#

@undone coral
You don’t need to be so passive aggressive to everyone

fresh salmon
icy aspen
dark cypress
# undone coral what do you mean send some c# code? what's your objective?

Receive C# from an AI service, drop it in a file for the Unity Editor to compile and ensure it compiles in the current context (eg. no Editor namespace references, no inappropriate types like int32), then run unit tests. What I'm stumbling with is how to get a notification if won't compile. Like, I know [AssemblyRefresh] or whatever the hook is, but if it doesn't compile, how do I get callback?

undone coral
#

are you trying to filter out code that doesn't compile, or is the expectation that a typical code snippet generated this way will compile?

dark cypress
#

I guess filter out code that doesn't compile

undone coral
#

999/1,000 to 9,999/10,000 code snippets will not compile

#

that aren't the absolute minimum basic complexity

#

is that okay?

#

why does it have to be in the unity context?

dark cypress
#

Yeah I'm not worried about efficiency yet

undone coral
#

it's very unlikely such a generator will be aware of the unity api, there isn't enough open source unity code for it to work for that

#

have you gotten something that works with an ordinary command line c# compiler?

#

you can use stub versions of unityeditor and unityengine apis, they are available on github

dark cypress
#

Stub version, like... headless, call on command line?

undone coral
#

no

#

stub version meaning code stubs

dark cypress
#

Like, the things that get expanded in a C# code snippet? Templates, sort of?

#

or an API you implement

undone coral
#

hmm

#

i'm saying you can use a mocking library to mock the unityengine and unityplayer assemblies

#

you don't need the unity editor to see if something compiles

#

you don't need the implementations of the functions

#

you only need type signatures (types and function signatures)

dark cypress
#

I'll check it out, thanks

undone coral
#

does that make sense?

#

do you see why you don't need the editor

#

let's say you just had

dark cypress
#

It does, but I'm probably going to stick with an editor solution since I'll be running unit tests using it afterwards anyway

undone coral
#

then try to build and run the tests from the command line

#

i don't know at what level you want or need to automate this

#

what's the bigger picture app / game?