#archived-code-general

1 messages · Page 122 of 1

weary quiver
#

I swear it was the worst idea to make such a school project in a week time ._.

hidden parrot
#

So your script opens the port, right?

#

And it closes it on destroy, right?

weary quiver
#

Yes

hidden parrot
#

But what if you end the game early, and the script is never destroyed?

#

I reckon the port never closes

weary quiver
#

Hmmm

hidden parrot
#

Try closing the port with a context menu function or something, might work

weary quiver
#

How do I do that

hidden parrot
#

If not, try Portmon and see what app is using it, because that's the only explanation in my opinion.

hidden parrot
#

Then put the [ContextMenu("name")] attribute above the function

#

And then you can right click the monobehaviour

#

and there'll be an option to run the function

#

and close the port

weary quiver
#
{
    if (dataStream != null && dataStream.IsOpen)
    {
        dataStream.Close();
        Debug.Log("Serial port closed.");
    }
}

[ContextMenu("Close Serial Port")]
private void CloseSerialPort()
{
     
}
``` Something like this? Or have I got it wrong?
hidden parrot
#

Nah, that's good, then just put dataStream.Close(); in the function

weary quiver
#
{
    if (dataStream != null && dataStream.IsOpen)
    {
       
        Debug.Log("Serial port closed.");
    }
}

[ContextMenu("Close Serial Port")]
private void CloseSerialPort()
{

 dataStream.Close();
     
}```
#

So like this?

hidden parrot
#

Yep, you should be able to right click the monobehaviour in inspector and click "Close Serial Port"

weary quiver
#
``` Now I get this
hidden parrot
#

yeah

#

you have two functions

weary quiver
#

oh

hidden parrot
#

with the same name

thin aurora
#

If you want to overload a method, you need to make the new one unique by itself

weary quiver
#

now I saw xD, should I simply rename the second one CloseSerialPort1?

thin aurora
#

Otherwise you need to give it a different name

hidden parrot
#

Yeah, something like that

#

Doesn't really matter, it's just for testing

thin aurora
hidden parrot
#

You're getting rid of it later

#

if this works

weary quiver
#
    {
        if (dataStream != null && dataStream.IsOpen)
        {

            Debug.Log("Serial port closed.");
        }
    }

    [ContextMenu("Close Serial Port")]
    private void ContextCloseSerialPort()
    {
        dataStream.Close();
    }``` So like this
hidden parrot
#

Yeah

#

try it out, let us know if it works

weary quiver
#

So now when I start the project, I should right click and close/?

#

Or I got it wrong

hidden parrot
#

Close the port now

#

then start the game up

weary quiver
hidden parrot
#

Right click the monobehaviour in the inspector

#

And click Close Serial port

#

and that runs the function you wrote

weary quiver
#

Now the port functions, I do not get that error anymore.

hidden parrot
#

Great! Now you need to make that function run every time you stop running the game

weary quiver
#

Put now I have like 300 of the same error: ```FormatException: Input string was not in a correct format.
System.Number.ThrowOverflowOrFormatException (System.Boolean overflow, System.String overflowResourceKey) (at <88e4733ac7bc4ae1b496735e6b83bbd3>:0)
System.Number.ParseSingle (System.ReadOnlySpan`1[T] value, System.Globalization.NumberStyles styles, System.Globalization.NumberFormatInfo info) (at <88e4733ac7bc4ae1b496735e6b83bbd3>:0)
System.Single.Parse (System.String s) (at <88e4733ac7bc4ae1b496735e6b83bbd3>:0)
Hand.Update () (at Assets/Script/Hand.cs:28)

hidden parrot
#

Yeah, that's just your string splitting stuff not functioning

#

Let's fix your port stuff first

#

And then your string stuff

weary quiver
hidden parrot
#

Alright, before you change the script just run that datastream close a couple times

#

so we're sure its closed

#

and we can make it run automatically

weary quiver
#

So basically close the serial port, right?

hidden parrot
#

Yeah, close the serial port when the game quits

#

There's a function for that, OnApplicationQuit() :D

#

Get rid of the contextmenu attribute and change the function name to OnApplicationQuit()

#

That should close the port every time your game stops running, in editor or in build.

weary quiver
#
    {
        if (dataStream != null && dataStream.IsOpen)
        {

            Debug.Log("Serial port closed.");
        }
    }

    //[ContextMenu("Close Serial Port")]
    private void OnApplicationQuit()
    {
        dataStream.Close();
    }``` Something like this?
hidden parrot
#

Yeah, commenting it out will work too.

#

Now then, that's port stuff fixed

#

String stuff now

#

Go ahead and just debug log everything you're recieving from the port

#

so we can see what's going on

weary quiver
#

Lemme send the code again, maybe it helps you know exactly what the problemo might be : ```using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO.Ports;

public class Hand : MonoBehaviour
{
public string portName = "COM3";
public int baudRate = 9600;
public Animator handAnimator;

private SerialPort dataStream;

void Start()
{
    dataStream = new SerialPort(portName, baudRate);
    dataStream.Open();
}

void Update()
{
    if (dataStream != null && dataStream.IsOpen)
    {
        string[] fingerData = dataStream.ReadLine().Split(',');

        if (fingerData.Length == 5)
        {
            float indexValue = float.Parse(fingerData[0]);
            float middleValue = float.Parse(fingerData[1]);
            float pinkyValue = float.Parse(fingerData[2]);
            float ringValue = float.Parse(fingerData[3]);
            float thumbValue = float.Parse(fingerData[4]);


            handAnimator.SetFloat("Index", indexValue);
            handAnimator.SetFloat("Middle", middleValue);
            handAnimator.SetFloat("Pinky", pinkyValue);
            handAnimator.SetFloat("Ring", ringValue);
            handAnimator.SetFloat("Thumb", thumbValue);
        }
    }
}

void OnDestroy()
{
    if (dataStream != null && dataStream.IsOpen)
    {
        dataStream.Close();
    }
}

private void CloseSerialPort()
{
    if (dataStream != null && dataStream.IsOpen)
    {

        Debug.Log("Serial port closed.");
    }
}

//[ContextMenu("Close Serial Port")]
private void OnApplicationQuit()
{
    dataStream.Close();
}

}```

hidden parrot
#

Nah, each implementation is different, easiest way is to debug log it out

#

DebugLog the fingerData array

#

where you had the animation set float stuff

weary quiver
#
            {
           
                 Debug.Log(fingerData[0]));
                 Debug.Log(fingerData[1]));
                 Debug.Log(fingerData[2]));
                 Debug.Log(fingerData[3]));
                 Debug.Log(fingerData[4]));
            }``` Something like this?
hidden parrot
#

Yeah, go for it

#

Let me know what it prints

weary quiver
#

Welp, seems like the Index finger hardware isn't connected right, but that's a problem for later.

hidden parrot
#

oh thats why then

#

You're printing the name of the finger too

#

not just the raw number

#

so it cant parse it

weary quiver
#

Oh

#

I should remove from the arduiin code the finger names right?

hidden parrot
#

Yeah

normal dust
#

hey guys can anyone familiar with firebase help? i want to make a semi idle game where every second i gain some currency, what would be the best approach to save that currency? im mainly wondering if using OnApplicationQuit is a viable option for saving the game

hidden parrot
#

If you're literally just saving the currency, go for PlayerPrefs

#

If you're doing something more complex have a look at binary encryption

normal dust
#

im using firebases database

weary quiver
hidden parrot
#

Ah

hidden parrot
#

try it out with your original code

weary quiver
#

Alright

normal dust
#

also doesnt playerprefs get deleted when i delete the game?

hidden parrot
#

What, delete the game or quit the game?

#

Delete the game everything gets deleted, binary encryption or not

#

Unless you save the savefiles in some obscure folder

#

that doesnt get deleted with the game

#

(shady, imo)

normal dust
#

yea so firebase it is

hidden parrot
#

Can I ask, why are you using firebase for this?

#

What's the reason behind needing it to persist between game deletes?

normal dust
#

i just want to experiment with this trying to release an android game

weary quiver
#

I don't know If I am doing something wrong, but now whenever I hit play I get this: All compiler errors have to be fixed before you can enter playmode! UnityEditor.SceneView:ShowCompileErrorNotification ()

hidden parrot
hidden parrot
#

Have a look at the docs if you haven't already

#

And show me what you've got currently

weary quiver
hidden parrot
#

That error shows up because you have other errors

normal dust
#

currently i got nothing exciting im trying to think how to architect the project and it depends if OnApplicationQuit data saving is a viable option, I already managed to save and retrieve values from the database

hidden parrot
#

For an android game, OnApplicationQuit is a decent idea

#

I mean, I can't think of anything better

weary quiver
#

That's what I get

normal dust
#

if i just leave the game and keep it running in the background would that be counted as applicationquit?

hidden parrot
#

with hatebin

#

preferably

#

this time

weary quiver
#

Here

hidden parrot
#

Thanks, one sec

#

using

#

I think that might actually be your only error, at least console based

weary quiver
#

Damn.. let me try again haha

#

Now when I start the project I get this: ```UnassignedReferenceException: The variable handAnimator of Hand has not been assigned.
You probably need to assign the handAnimator variable of the Hand script in the inspector.
UnityEngine.Animator.SetFloat (System.String name, System.Single value) (at <d4133d02309b4839805ff06ac3f8d211>:0)
Hand.Update () (at Assets/Script/Hand.cs:35)

normal dust
thin aurora
#

@weary quiver Do you mind sharing a screenshot of your editor? I believe you haven't configured it.

hidden parrot
hidden parrot
weary quiver
#

I should drag that one there?

#

Or I got it wrong?

hidden parrot
#

Into the inspector

#

where the slot is

#

for the animator

thin aurora
hidden parrot
#

Like that

#

but not a physic material

thin aurora
hidden parrot
#

lawd light modfe

weary quiver
#

xD

hidden parrot
#

Okay so you don't have intellisense

thin aurora
# weary quiver

Please configure your !ide before continuing with the issue. It is not configured.

tawny elkBOT
#
💡 IDE Configuration

If your IDE is not autocompleting code
or underlining errors, please configure it:

Visual Studio (Installed via Unity Hub)
Visual Studio (Installed manually)

VS Code*
JetBrains Rider
Other/None

*VS Code's debugger plugin is unsupported.
We recommend using VS or Rider instead.

thin aurora
#

I hoped others would notice but I guess not

normal dust
hidden parrot
thin aurora
hidden parrot
#

though

weary quiver
thin aurora
thin aurora
thin aurora
# tawny elk

If you press • Visual Studio (Installed manually) it will be explained in detail

thin aurora
#

It's only three steps. I see you already set up VS as your external editor, and now you regenerated project files, so you only really need the Unity workload

weary quiver
#

I've hit regenerate project files

#

Where do I get this Unity workload?

thin aurora
#

It is also explained in that url

weary quiver
#

Yes thanks for the help!

obtuse silo
#

Hey there, I need to change those exact settings on 550 animation clips.
How would those be accessed and changed by code in the editor (changing the files themselves, not at runtime) ?

#

They come from .fbx animation files, and import preset won't work for those settings

static matrix
#

Can I dynamically edit terrain at runtime?

static matrix
glossy mica
#

I am currently using the "profile.beginsample" to sample the Update() function in A* and bidirectional A* algorithm. Will that suffice to compare the performance time of both algorithms? Because if so, why is bidirectional A* taking longer than A* when looking at the timeline in the profiling window? Am I interpreting wrongly?

dusk apex
static matrix
#

How do I dynamically edit terrain tho
is there a function i can use

#

ugh why is the terrains origin on the corner
rotating it is annoying

loud wharf
#

Ok, this is progress.

#

A bit big for some reason, idk why. UnityChanThink

#

I'll add in the other elements first tho.

hexed pecan
static matrix
#

no, but I needed to rotate its parent

#

which greatly shifted it

#

I fixed it, just put it under an object that doesn't need to rotate

static matrix
#

thx

swift falcon
#

hi everyone , it would be appreciated if someone can help me in my question in the ai channel... thank you*

static matrix
#

how can I convert, say, a collision position into a point on the terrain

maiden fractal
swift falcon
#

noted

hexed pecan
#

The terrain system has been around for ages and these questions have been answered

static matrix
#

okay thanks

waxen kayak
#

I'm trying to make rcs thrusters for spaceships

#

I can do the manual way of setting each thruster when to fire

#

but is there a way to tell when thy should fire if I want to change the angular rotation for example

#

like some kind of all in one equation that would tell me that

#

where I could place the thrusters anywhere on the ship and they would work, kind of like how ksp did it

#

and also make them balance eachother out

#

I've been trying to make them balance eacother out but I haven't tested it yet

river kelp
#

I know the ideal amount of GC allocation to do per frame is 0, but it seems difficult to actually accomplish. I'm doing 200-300 bytes right now per frame, with a spike up to 10kb when a large task like pathfinding over a complicated structure is done. I have no reference for what a large amount is, and what amount is considered acceptable. Is there anyone here with experience regarding this? I'd love to at least have some reference for what is "a lot"

west lotus
#

Also it’s probably entirely possible to not generate garbage at all

fervent furnace
#

My pathfind use unsafe at all

river kelp
west lotus
#

Sure

river kelp
#

Still, I don't know if 1kb is a lot or nothing at all

west lotus
#

Like I said it depends on your game and target device

ashen yoke
#

its pointless to stick to zero alloc, its enough not to generate high enough amount for a significant spike that is more ms than a frame

west lotus
#

If you see lag spikes related to the gc then reduce the amount of garbage

#

Its all a balancing game

#

1kb can be much it could be nothing

ashen yoke
#

also gc in editor should be ignored

river kelp
#

I guess it would be easier to just program the way I feel is readable for now

fervent furnace
#

The possible allocations of my pathfind are calling task, realloc of stack and minheap, but only the first one is handing by gc i guess

river kelp
#

and then go check when I have problems

#

My pathfinding is creating a whole lot of nodes for the paths that don't work out, and they are then discarded

ashen yoke
#

task generates about 0.5kb

river kelp
#

Could maintain a pool of these objects but that's why I'm not sure if it's worth it

ashen yoke
#

use pools

#

for all collections

fervent furnace
#

And i can prevent realloc of stack by malloc the whole buffer at the very beginning but i dont what to fo this….

static matrix
#

I would basically like for terrain to rise where an object hits it
nothing is seeming to work

ashen yoke
#

you are painting pixels essentially

fervent furnace
#

you have to reuse the visited array by allocate aa additional stack that keep track the nodes explored and clear it after finish pathfind

static matrix
#

hmm
where can I find it

ashen yoke
#

"unity terrain api" first link

fervent furnace
#

and this stack can also be reused

static matrix
#

ohh I have to "Flush" it

#

ill send my code
it doesn't seem to be working

#
  public Terrain Water;
    //public AudioSource Splash;
    public List<Vector3> PushPoint;
    
    // Start is called before the first frame update
    void Start()
    {
        Water = GetComponent<Terrain>();
    }

    // Update is called once per frame
    void Update()
    {
        
    }
    private void OnCollisionEnter(Collision col)
    {
        Vector3 Pos = ConvertWordCor2TerrCor(col.transform.position);
        PushPoint.Add(Pos);

        Water.terrainData.SetHeights((int)Pos.x, (int)(Pos.y), new float[1, 200]);
        Water.Flush();
    }
    //Stolen this bit below
    private Vector3 ConvertWordCor2TerrCor(Vector3 wordCor)
    {
        Vector3 vecRet = new Vector3();
        Terrain ter = Water;
        Vector3 terPosition = ter.transform.position;
        vecRet.x = ((wordCor.x - terPosition.x) / ter.terrainData.size.x) * ter.terrainData.alphamapWidth;
        vecRet.z = ((wordCor.z - terPosition.z) / ter.terrainData.size.z) * ter.terrainData.alphamapHeight;
        return vecRet;
    }
fervent furnace
#

i allocate a pool of all (persistent and unsafe) data structure in awake() i need and i reuse them to prevent meaningless allocation in game main loop @river kelp

ashen yoke
#

you can do that without unsafe

river kelp
#

Sure, but what kind of value are you getting from that

fervent furnace
#

those i still cannot prevent the allocation due to task....perhaps i have to use job system

ashen yoke
#

you can use UniTask

#

its non alloc

river kelp
#

I do that for gameobjects because instantiating them is slow

#

but I'm not sure if it's valuable to me here

ashen yoke
#

btw async is not multithreaded

static matrix
#

sorry im being a pest

ashen yoke
#

@static matrix what happens there? nothing?

static matrix
#

nothing happens

#

I think its doing the collsion, let me check

#

throw in a debug.log

#

yeah its detecting it
the object hits and the height doesn't seem to change anywhere

ashen yoke
#

The samples are represented as float values ranging from 0 to 1

#

took that into account?

river kelp
#

like, once it reaches the "Await" it yields until the next frame?

ashen yoke
fervent furnace
#

await wait until the task is finish

ashen yoke
#

if its await for a frame it will wait a frame

static matrix
#

I think await means it doesn't run the next thing in the function until the one before it finishes

#

but im probably not qualified here
Im a questioneer not an answerer

ashen yoke
#

at least in case of UniTask, i didnt work much with raw async

static matrix
#

let me try just setting the height to like 200 in a specific point
instead of where the collision happens

ashen yoke
#

you can yield a method that executes right there on the spot, then it wont suspend

static matrix
#

yeah the height doesn't change anywhere

ashen yoke
#

async and enumerators are state machines, same mechanics, but raw async is handled by .net, and coroutines/unitask are handled by unity

#

actually in unity async can also be handled by unity internally

#

even tho it allocates default task

hexed pecan
static matrix
#

its supposed to change the height right?

#

I think I dont understand setheights

hexed pecan
#

You are assigning an empty heightmap to it

static matrix
#

should I use something else

#

ahhh

hexed pecan
static matrix
#

ahhh

#

how do I just change the height in one place

hexed pecan
#

Get/store the heights in an array

ashen yoke
#

yeah keep the buffer separate

#

accumulate changes, then dump them to terrain once

hexed pecan
#

Modify that array at the coordinates that you get from your ConvertWordCor2TerrCor method - assuming it is correct

static matrix
#

its a two dimensional array isnt it

hexed pecan
#

Yeah, the 1, 200 doesn't seem to make sense really :P

static matrix
#

thats the position

hexed pecan
#

Also note that it is y, x not x, y

#

😵‍💫

static matrix
#

WHO DOES THAT

#

ill check some of the props

hexed pecan
static matrix
#

ohh
so how do I access the heightmap I dont see a clear var

hexed pecan
#

Either make your own array and store it somewhere or get it with GetHeights

static matrix
#

GetHeights

#

why does it Have GetHeight and GetHeights but not SetHeight and only SetHeights

#

ugh

#

okay Ill take a look

hexed pecan
static matrix
#

ahh

#

okay

#

hmm

hexed pecan
#

I really suggest reading the SetHeights doc

static matrix
#

yeah
I have it open

hexed pecan
#

The description too

static matrix
#

I dont fully understand it

ashen yoke
static matrix
#

ohhz

hexed pecan
#

In chrome

#

Gotta save them eyes

static matrix
#

I think I slightly get it now?
Like
heights is the area that is being edited?

ashen yoke
#

i can probably use greasemonkey for that

static matrix
#

hmmmm

#

okay

#

sorry im so dumb lol

ashen yoke
#

keep a large buffer for the whole map, keep a small buffer for "stamping" changes from-to

hexed pecan
#

Yeah lets say your heightmap is 100x100
If you want to change it all you would do SetHeights(0, 0, myArray) where myArray has dimensions 100, 100

static matrix
#

and the dimensions are the dimensions of the terrain?

hexed pecan
#

Or if you want to update a 10x10 chunk of that heightmap, at position 5, 5 you would do SetHeights(5, 5, myArray) where myArray has dimensions 10, 10

#

Does that make sense?

hexed pecan
static matrix
#

yes

#

no the terrain dimensions

#

in terrain units

hexed pecan
#

Because the heightmap doesn't necessarily have 1 height per unit (meter)

ashen yoke
#

just think of it as pixels

static matrix
#

ah

hexed pecan
#

Yeah, it's really just a texture

static matrix
#

ahh

stuck wigeon
#

hey can i get some help plz, a bunch of stuff in my mouseLook script like sensitivity is increasing and my recoil is completely different from the editor and the game when it has been built.

    void LateUpdate()
    {
        mouseLook = controls.Player.MouseLook.ReadValue<Vector2>(); //Get Mouses Values

        //Calculate random recoil
        if (Mathf.Abs(upRecoil) > gunDataScript.minRecoilThreshold)
        {
            upRecoil += gunDataScript.snapiness * Time.deltaTime * ((upRecoil > 0) ? -1 : 1);
        }
        else upRecoil = 0;

        if (Mathf.Abs(sideRecoil) > gunDataScript.minRecoilThreshold)
        {
            sideRecoil += gunDataScript.snapiness * Time.deltaTime * ((sideRecoil > 0) ? -1 : 1);
        }
        else sideRecoil = 0;

        test.SetText(xRecoil + "/" + sideRecoil);

        mouseLook.x += xRecoil;
        mouseLook.y += yRecoil;

        //Adds sensitivity & adds recoil to the camera
        float mouseX = upRecoil + mouseLook.x * mouseSensitivity * Time.deltaTime;
        float mouseY = sideRecoil + mouseLook.y * mouseSensitivity * Time.deltaTime;

        //Calculats t


        xRotation -= mouseY; 
        xRotation = Mathf.Clamp(xRotation, -90, 90); //Clamps the Y axis value that way player dont look past head/feet

        transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f).normalized; //Rotates the Camera 

        playerBody.Rotate(Vector3.up * mouseX); //Rotates the Player on the X axis
    }

    public void RecoilFire(float up, float side)
    {
        upRecoil += Random.Range(-up, up);
        sideRecoil += Random.Range(-side, side);
    }
}
static matrix
#

so
then how do I tell it how much to change it by?

ashen yoke
#

even the grass you pain is also literally a texture

static matrix
#

because this looks like it tells me where to edit it

#

but not by how much

ashen yoke
#

value 0-1

#

its between 0 and terrain max height

static matrix
#

where in the function is that

hexed pecan
#

You put that 0-1 value in the array

static matrix
#

oh

#

OHHHH

#
       var MyArray = new float[30, 30];
        MyArray[0, 0] = 1;
        Water.terrainData.SetHeights((int)Pos.x, (int)(Pos.y), MyArray);

Like this?

hexed pecan
#

That would change only one position to the max value

static matrix
#

yes
but it would change it

hexed pecan
#

The rest of the positions in that 30x30 array are default float value which is 0

static matrix
#

yep

hexed pecan
#

So probably not what you want

static matrix
#

its closer

#

how do I edit a lot of the values
ig I can use a for loop but that seems wrong

opal cargo
#

Hey guys, trying to climb up a rope - works OK with Raycast but when looking away, RC fails and I fall.
At the moment I'm climbing up by projecting my move vector onto the vertical lane of the Rope (Raycast Hit)

 Vector3 movement = new Vector3(0, ctx.inputs.moveInput.y, 0);
 movement = Vector3.ProjectOnPlane(movement,ctx.RopeRC.normal);

Want to change Raycast for OverlapSphere, but this is giving me a collider.
Is it somehow possible to move alongside a collider?

somber kite
#

Does defining a Start() method on a class that inherits from another class that inherits from MonoBehaviour that has a Start() method defined override the inherited class's definition or do both their Start()s execute?

hexed pecan
#

@static matrix Start with having a float[,] heights in your script.
Use heights = terrainData.GetHeights(0, 0, terrainHeightRes, terrainHeightRes) or something like that to populate it

#

Then modify it

static matrix
#

ahhhh

#

ok

fervent furnace
#

override, or hide the base class's start

#

you will see a warning

ashen yoke
#

if terrain height is set to 300 and you want 67 units you set the value to Mathf.InverseLerp( 0f, terrainData.heightmapScale.y, 67)

hexed pecan
# static matrix ok

It's maybe not as performant as modifying a certain slice of the terrain but this will get you started

static matrix
#

ok tysm

vapid sparrow
#

How would I go about drawing a 3d line between 2 points but have the line use 45 degree angles to get to the points, kind of looking like a circuit diagram?

hexed pecan
heady iris
#

Sounds like you should pick the minimum of your x/y/z distances and go that far

#

Then repeat twice

gray mural
#

does anyone know why 2d game is with min scale 1.3x already?

hexed pecan
#

Is this a pixel perfect camera thing?

static matrix
#

last question is it possible to make a terrain collider a trigger?

gray mural
hexed pecan
static matrix
#

well because water

hexed pecan
potent sleet
static matrix
#

yeah I can just use a box actually if its just a trigger

#

im stoopid

potent sleet
hexed pecan
#

@static matrix Why are you using terrain for water though?

static matrix
#

because I want dynamic water
like a thing falls into it and theres a splash

potent sleet
#

but yeah just use a box

hexed pecan
static matrix
#

well thats why im trying to do it with heightmap edits

#

rather than having 2000 rigidbodies which was my previous solution in 2d

#

which was very laggy

hexed pecan
#

HDRP has a new water system I think, if you wanna try that

#

Using terrain for water splashes/waves sounds very inefficient but you can try it

static matrix
#

I'm in too deep to migrate to HDRP I think

hexed pecan
#

If it only happens at a certain position then it might be ok

static matrix
#

ive tried to do it a couple of times and it never works out

#

but yeah
maybe ill mess around in a new project just to see how the water works

#

does unity have cloth physics actually?

hexed pecan
#

It does but I don't guarantee it to be a great solution for this either :P

static matrix
#

yeah....

#

this is a bad idea

hexed pecan
#

Does the collider have to match the visuals exactly?

static matrix
#

no

#

not at all in fact

#

the collider can be static

hexed pecan
#

Then you probably want to use a box collider anyway for the collisions

static matrix
#

yeah I will

hexed pecan
#

I would make the water effects with a shader (compute shader possibly) but that's a bit more advanced

static matrix
#

what did I do oh my god

ashen yoke
#

happens occasionally

static matrix
#

I think unity understands that Im out of my current depth and is trying to warn me

#

unfortunately for my computer I will ignore these omens

#

sdfhekd I give up for now

#

Ill make cool water later

potent sleet
potent sleet
static matrix
#

yeah
Im not doubting that

#

its that it'll be a big hassle to switch

#

I might see what it is like

potent sleet
#

unless you have custom shaders, it should be 1 package u download

#

switch out the SO/ done

static matrix
#

wdym by switch out the SO
what is SO

potent sleet
#

Scriptable Object

static matrix
#

ill try (Again)

#

it messes up my materials

potent sleet
#

the HDRP/URP are scriptable pipeline

static matrix
#

ill give it another try

potent sleet
static matrix
#

oki

#

is the converter built in

potent sleet
#

indeed

#

always make a backup/copy project ofc before you do anything. best to practice that too

#

or use VC(version control)
even better

static matrix
#

I do use VC

#

its great

#

GitHub which ik is default Mii VC

#

but it works

potent sleet
static matrix
#

its cool getting familiar with the community because its usually the same couple of people helping with questions

stuck wigeon
#

hey am i suppose to be using Time.deltatime with unitys new input system because when i make a build the mouse sensitivity is super high but when i get rid of it, it feels "normal" but breaks my recoil system.

leaden ice
#

The input system isn't really the main question.

#

If you are reading mouse deltas, you should never be multiplying deltaTime

#

that goes for both input systems

oblique spoke
#

Old input system may have some magic internal multipliers, so you just might need to adjust your values

static matrix
#

my materials died

potent sleet
static matrix
#

any idea why?

leaden ice
static matrix
#

this was a followup from before

leaden ice
#

oh

potent sleet
#

@static matrix it still technically not related to code 😛

stuck wigeon
static matrix
#

yeah
But it would be weird to ping you in graphics

#

do we want to move over there?

potent sleet
static matrix
#

ah

#

does hdrp have water physics or just nice looking water

potent sleet
#

I have not tested if there are any physics , and if you mean Boyancy you could probably just do that with a script.
Unity's Ski Water demo has a script for that

static matrix
#

I mean like splashies

#

I drop item in water it splash

#

or like theres ripples when you walk

#

maybe I can just find a good water shader online

gray mural
potent sleet
static matrix
#

thats quite a good idea
I dont know how I could have been so blind

#

but either way does anyone know a good water shader

potent sleet
static matrix
#

okii

potent sleet
#

not code question

static matrix
#

ill figure it out

hexed pecan
gray mural
#

for example?

hexed pecan
somber kite
#

I have a question about interface implementations. Am I not allowed to implement or override implementation of a method of an interface inside a child?

public interface ISomeInterface
{
  public bool DoSomething() { return false; }
}

public class SomeClass : SomeOtherClass, ISomeInterface
{
  // Not Implementing the ISomeInterface methods.
}

public class ThisClass : SomeClass
{
  public bool DoSomething() { return true; } // <- Not considered an implementation of the interface that SomeClass, and by extension this one inherits?
}
heady iris
#

The original implementation of the interface methods must include the virtual to allow for derived classes to override the methods

#

The code you posted, however, is invalid. SomeClass does not implement all of the methods of ISomeInterface.

#

Make it abstract or implement the methods.

#

Oh wait, I just realized you included an implementation in the interface

#

I'm a little fuzzy on that. I haven't used it myself yet.

#

Here's a description of how that works.

waxen kayak
#

quick question:

#

cam.transform.localRotation = Quaternion.Euler(Mathf.Clamp(cam.transform.localRotation.eulerAngles.x, -45f,45f), Mathf.Clamp(cam.transform.localRotation.eulerAngles.y, -45f, 45f), 0);
I'm using this to clamp the rotation of my camera

#

however the minimum rotation is 0 and when it reaches it it will span back to 0

#

why is this happening?

heady iris
#

clamping euler angles can be very surprising

#

rotating an object around one axis can change the euler angles on the other axes

#

Is this a first person camera?

waxen kayak
#

yeah

heady iris
#

i would suggest just storing the yaw (left-right rotation) and pitch (up-down rotation) as floats

#

and then set the camera's local rotation based on those values

waxen kayak
#

makes sense

#

thanks

heady iris
#

it's what I've done in a few different games

somber kite
#
public interface ISomeInterface
{
  public virtual bool DoSomething() { return false; } // IDE Screams that virtual is a redundant keyword in this context.
}

public class SomeClass : SomeOtherClass, ISomeInterface
{
  // Not Implementing the ISomeInterface methods.
}

public class ThisClass : SomeClass
{
  public override bool DoSomething() { return true; } // IDE Screams that there's nothing to override.
}
dusk apex
somber kite
dusk apex
#

So the original class interfacing the interface would have the virtual member

#

Your inheriting class would override the member

#

Interface just forces the class to implement non implemented methods in the interface. The child would need the parent member to be virtual if you're wanting the child class to override the parent's member.

dawn trout
#

can someone help me please im very new with unity and im trying to make my flint lock push me in the oposit direction i shoot but i cant figure it out (sorry if this is the wrong chat room to send this to im new here)

static matrix
#

finally found a good one

#

(ik not scripting but follow up from before convo ends now)

primal wind
#

Use that as you need

dawn trout
#

i dont think i understand could you please elaborate

heady iris
somber kite
# dusk apex So the original class interfacing the interface would have the virtual member

What I'm trying to achieve is this (from c++)

class Something
{
public:
    bool DoSomething() { return false; }
}

class OtherThing : public SomeOtherClass /* <- This class is the MonoBehavior Class in Unity so it needs to be here*/, Something /* <- This would be the interface since c# does not allow multiple class inheritance*/
{
// Do stuff without implementing DoSomething cause I don't need it to be implemented at this level.
}

class CurrentThing : public OtherThing
{
public:
  bool DoSomething() override { return true; }
}
dusk apex
stuck wigeon
lapis egret
#

For the same reason time.delta makes other code frame independent

somber kite
# dusk apex Was there anything in particular that you did not understand from what I wrote? ...

Well I would like to avoid putting the default implementation inside the top level class. That kinda defeats the point of what I'm showing with the c++ example by using a class that can be reused elsewhere. There will be a lot of methods in that interface adn I don't want to keep redefining all of them inside every class that will implement the interface. The only thing I can think of at this point is to change the interface to a class and the methods to delegates and work from there I guess

dusk apex
stuck wigeon
# lapis egret For the same reason time.delta makes other code frame independent

i think that maybe the problem with my code, but when i try to separate them and have time.deltatime on the end of my recoil instead, it still seams to make the recoil code frame dependent.

  void LateUpdate()
    {
        mouseLook = controls.Player.MouseLook.ReadValue<Vector2>(); //Get Mouses Values

        //Calculates recoil pattern
        if (!gunDataScript.allowInvoke)
        {
            if (!gunDataScript.isAiming)
            {
                xRecoil = gunDataScript.xRecoilPattern.Evaluate(gunDataScript.bulletsShotInARow);
                yRecoil = gunDataScript.yRecoilPattern.Evaluate(gunDataScript.bulletsShotInARow);

                upRecoil += gunDataScript.snapiness * Time.deltaTime * ((upRecoil > 0) ? -1 : 1);
                sideRecoil += gunDataScript.snapiness * Time.deltaTime * ((sideRecoil > 0) ? -1 : 1);

            }
            else
            {
                xRecoil = gunDataScript.xADSRecoilPattern.Evaluate(gunDataScript.bulletsShotInARow);
                yRecoil = gunDataScript.yADSRecoilPattern.Evaluate(gunDataScript.bulletsShotInARow);
            }
        }
        else
        {
            xRecoil = 0;
            yRecoil = 0;
            upRecoil = 0;
            sideRecoil = 0;
        }

        mouseLook.x += xRecoil;
        mouseLook.y += yRecoil;

        //Adds sensitivity & adds recoil to the camera
        float mouseX = upRecoil + mouseLook.x * mouseSensitivity * Time.deltaTime;
        float mouseY = sideRecoil + mouseLook.y * mouseSensitivity * Time.deltaTime;

        xRotation -= mouseY; 
        xRotation = Mathf.Clamp(xRotation, -90, 90); //Clamps the Y axis value that way player dont look past head/feet

        transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f).normalized; //Rotates the Camera 

        playerBody.Rotate(Vector3.up * mouseX); //Rotates the Player on the X axis
    }
heady iris
#

mouse input should not be multiplied by deltaTime

#

let me go fetch the explainer I wrote recently..

#

oh it wasn't very long

#

lol

#

mouse input is an amount of change, not a rate of change

lapis egret
#

Yes, so is time.deltaTime

leaden ice
heady iris
#

it feels weird to just mash recoil and mouse input together into one place

ebon nova
#

Is there a callback or postprocessor I can use to run code when a ScriptableObject's serialized data changes? I'm using SOs as persistent databases, and they contain some unserialized indexes (dictionaries) that are accessed in edit mode. I'd like to be able to refresh those indexes when the serialized data changes.

leaden ice
#

you don't "have to" multiply it by deltaTime, that's definitely not correct for mouse deltas

heady iris
#

I would separate them.

#

compute where the player should, logically, be looking, then add the recoil-induced rotation on top

leaden ice
#

The simple way is to put the camera on a child object of the one you're controlling with your mouse look

#

so it can recoil independently

heady iris
#

oh yeah, that's a good thought

#

a lot of problems get simpler if you just use two or three objects

ashen yoke
#

@wide dock @ebon nova and after all that asset db stuff is done and working, i advice moving it out of unity into separate cs project and compile it into a dll, which you drop into unity

#

so that it keeps running when project fails to compile/load correctly

static matrix
#

ugh why do children of an object bend really weirdly
its annoying

#

like when I rotate it is scales stupidly

heady iris
#

non-uniform scale

ashen yoke
#

non-uniform scale

static matrix
#

can I turn that off

ashen yoke
#

non-uniform scale

heady iris
#

yes, don't non-uniformly-scale anything

ashen yoke
#

non-uniform scale

heady iris
#

i.e. don't have scale that isn't all the same value

#

a scale of [3,1,1] is non-uniform

static matrix
#

ill just unparent them on start to solve the issue

heady iris
#

When you rotate the child object, that changes how it gets stretched.

#

since you change how it aligns with the parent's X/Y/Z axes

wide dock
# ashen yoke <@325929190342000640> <@154475175079968769> and after all that asset db stuff is...

Right now I'm kinda stuck at just checking out how to just reload the scripts with this, kinda got the base idea of how OnPostprocessAllAssets works
Just one more question for now, you said to "lambda it onto EditorApplication.delayCall", but how exactly do I do it?

For now I just did:

using UnityEditor;

public class CustomAssetPostProcessor : AssetPostprocessor
{
    private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
    {
        EditorApplication.delayCall += EditorUtility.RequestScriptReload;
    }
}
```to check out if script reloading even works this way, but nothing seems to be happening
ashen yoke
#

i think theres a different method for that

#

CompilationPipeline.RequestScriptCompilation();

wide dock
#

Yeah, I want to reload the script after saving so that the new enums show up in the inspector

ashen yoke
#

you did make changes to scripts?

#

otherwise what to reload?

wide dock
#

The script is being generated within OnValidate() (for now), I just need to reload it for Unity to notice it

ashen yoke
#

the script is a cs file?

wide dock
#

yes

ashen yoke
#

you are modifying it with File ?

#

did you set it dirty after changes?

#

the MonoScript

#

AssetDatabase.Refresh and others

wide dock
ashen yoke
#

scripts are also simply monitored for changes, and imported as MonoScript

#

but the changes are detected only at specific points

wide dock
spice sentinel
#

I was working on a project and suddenly the methods for the camera class were not avalible in a script. I am referencing the proper namespaces and have regenerated project files.

weary scroll
#

Hi guys please help me, with this 4 build errors

static matrix
#

Can I change a particlesystem to be just trails?

idle iris
#

why audio mixer is not working in build? in editor I can change the sound volume with a slider but the same slider does nothing after building; the mixer setFloat seems to not work at all in build

idle iris
#

how can I access them? do I need to make development build for that?

ashen yoke
#

no

#

AppData\LocalLow /company ..

idle iris
#

thanks, I'll check them in a sec

shut ridge
#

how do i make a joint connect two rigidbodies who do move with one another but whose rotations are independent of one another, like an axle with two wheels that are allowed to spin freely of one another.

idle iris
#

there are some more errors; more work to do xD

idle iris
#

@ashen yoke NullReferenceException: Object reference not set to an instance of an object
at SoundOptions.OnEnable () [0x00012] in <6307d21e8f5740a1896857d764429186>:0

ashen yoke
#

yeah expected something like that

idle iris
#

how come the reference is null only in build?

#

and why onEnable? The script is attached as component to an object

vague jolt
#

so I made a game with playerprefs, i made the build and on other computer it works fine but not on mine, how ?

#

Is like it works fine on the editor and if other people download it it works, but on my computer it does not run right

somber nacelle
vague jolt
#

yeah my bad let me explain better

#

    private void Start()
    {
        if(!PlayerPrefs.HasKey("level"))

        {
            PlayerPrefs.SetInt("level", 1);
        }
    }

    public void sceneLoader()
    {
        if(PlayerPrefs.GetInt("level") == 1)
        {
            SceneManager.LoadScene(1);
        }
        else
        {
            SceneManager.LoadScene(2);
        }

    }
#

when you start the game the first time this happens, in pratice if there is no level variable is set to 1, and then if you press the button it loads scene one

#

on every computer scene 1 is loaded but on mine scene 2 is loaded for some reason

somber nacelle
#

clear the playerprefs keys on your computer and try again

vague jolt
somber nacelle
#

that does not clear the playerprefs

vague jolt
#

where are they stored ?

somber nacelle
#

if you're on a windows machine they are stored in the registry

vague jolt
#

i thought they were stored in the file with all the unity fiels,

somber nacelle
somber nacelle
vague jolt
#

huh

#

so even if you remove and install the game the saves stay

#

didn't knew that thanks

somber nacelle
#

yes

solar forge
#

Hi folks. I'm trying to figure out a way how to use multiple NavMeshAgents to move to single target(wall in this case). When I use target position, it obviously not working well, since all the agents coming from relatively same direction and pushing each other. I am in a process of creating a logic that will provide a unique position near the target, so all the agents will have their own “spot”
Is there some easy way to do it, that I am missing something obvious here?

gray mural
#

does anyone know how to change this top field?

gray mural
worthy willow
#

Hey, I want the Ray i'm shooting out to ignore a layer I choose. How would I do that? I tried looking it up but I didnt get any working answers

leaden ice
#

should have been the first thing that comes up when you search for that

gray mural
#

does anyone know how to get line height of TMP_InputField or TextMeshPro?

#

I just need my InputField's height to be equal 3 text lines by changing its top and bottom values I guess

ashen yoke
#

there should be something like ComputeSize(string)

gray mural
ashen yoke
#

yes

worthy willow
ashen yoke
#

it can help you if you notice me saying "something like"

#

because i remember using it but i dont remember the exact name

glossy mica
#

For the following scene, my A* had an avg exec time of 0.10ms while bidirectional A* at 0.20ms. Is this normal? And it’s been consistent no matter where I put. Am I analysing it wrongly?

quick hull
#

Enemy Sript

public class enemy : MonoBehaviour
{
    public int health = 100;

    public GameObject effect;
    public GameObject player;
    // Start is called before the first frame update
    public Vector3 playerPos;
    public Animator anim;
    public gameManager gm;
  
    
    void Start(){
          gm = GameObject.FindGameObjectWithTag("GM").GetComponent<gameManager>();
        
    }
     void Update() {
        
        transform.position = Vector3.MoveTowards(transform.position, player.transform.position, 2 *Time.deltaTime);
    
    }
    public void takeDamage(int dmg){
        anim.SetTrigger("damageTrigger");
        health -= dmg;

        if(health <= 0){
            die();
        }
    }

    void die(){
        
        //Instantiate(effect, transform.position, Quaternion.identity);
       Destroy(gm.copy);
    }
}

Enemy Spawn

public class gameManager : MonoBehaviour
{
    private int waveNumber = 0;
    public int enemiesAmount = 0;
    public GameObject blob;
    public Camera cam;
    public Text wave;
    public GameObject copy;
    // Use this for initialization
    void Start () {
        cam = Camera.main;
        enemiesAmount = 0;
    }

// Update is called once per frame
void Update () {
        wave.text = "Wave: "+ waveNumber;
        float width = cam.orthographicSize * cam.aspect + 1;
        float height = cam.orthographicSize + 1; // now they spawn just outside
        if (enemiesAmount==0) {
            waveNumber++;
            for (int i = 0; i < waveNumber; i++) {
             copy = Instantiate(blob, new Vector3(cam.transform.position.x + Random.Range(-width, width),3,cam.transform.position.z+height+Random.Range(10,30)),Quaternion.identity);
                enemiesAmount++;
            }
        }
    }
}
#

this is the error i am getting

#

i think its something with deleting the intantiate clone

#

idk if i did that right

gray mural
quick hull
#

Destroy(gm.copy);

#

this is 39

#

die();

#

this is 32

gray mural
ashen yoke
#

and bidirectional should have double amount of structures

gray mural
quick hull
#

should i not store the instatiate in a variable then

gray mural
#

also I don't think it's a good tag

quick hull
#

ok

#

i tried changing the tag

#

but i still cant refrence the gameManager

ashen yoke
gray mural
quick hull
#

it does have the correct tag

gray mural
ashen yoke
#

also use FindObjectOfType<>

gray mural
ashen yoke
#

better practice, generally

zealous pendant
#

I am trying to make some precise movement but the transform component keeps values as floats and therefore can get to some random stuff. Can I force it to show and return values to one decimal point?

leaden ice
#

so no

lean sail
#

this is just floating point precision, you shouldnt see a single noticeable difference in your game because of this

#

if you are comparison positions to another object, try using Mathf.Approximately or tell us what this is for

leaden ice
#

If you're trying to do grid based movement you should use integer grid coordinates at the lowest level

#

converting to floating point only at the final moment for presentation purposes

maiden fractal
lean sail
#

oh thats interesting, == does that while .Equals doesnt

#

guess that makes sense

maiden fractal
#

If Equals did too, it would probably mess up hashsets and dictionaries somehow

glossy mica
idle iris
#

I still can't understand how NullReferenceException: Object reference not set to an instance of an object at SoundOptions.Start () [0x00015] in <8fd0a29f74f54040b4f1f0ce22d43c56>:0 is thrown only in build; if someone can help me please

#
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.UI;

public class SoundOptions : MonoBehaviour
{
    [SerializeField] private AudioMixer m_audioMixer;
    [SerializeField] private Slider[] sliders;

    private void Start()
    {
        m_audioMixer.SetFloat("masterVolume", GameManager.Instance.Settings.m_masterVolume / 1.25f - 80);
        m_audioMixer.SetFloat("musicVolume", GameManager.Instance.Settings.m_musicVolume / 1.25f - 80);
        m_audioMixer.SetFloat("effectsVolume", GameManager.Instance.Settings.m_effectsVolume / 1.25f - 80);

        sliders[0].value = GameManager.Instance.Settings.m_masterVolume;
        sliders[1].value = GameManager.Instance.Settings.m_musicVolume;
        sliders[2].value = GameManager.Instance.Settings.m_effectsVolume;
    }

    private void OnEnable()
    {
        sliders[0].value = GameManager.Instance.Settings.m_masterVolume;
        sliders[1].value = GameManager.Instance.Settings.m_musicVolume;
        sliders[2].value = GameManager.Instance.Settings.m_effectsVolume;
    }

    public void OnMasterVolumeChange(float value)
    {
        GameManager.Instance.Settings.m_masterVolume = (int)value;
        m_audioMixer.SetFloat("masterVolume", GameManager.Instance.Settings.m_masterVolume / 1.25f - 80);
    }

    public void OnMusicVolumeChange(float value)
    {
        GameManager.Instance.Settings.m_musicVolume = (int)value;
        m_audioMixer.SetFloat("musicVolume", GameManager.Instance.Settings.m_musicVolume / 1.25f - 80);
    }

    public void OnEffectsVolumeChange(float value)
    {
        GameManager.Instance.Settings.m_effectsVolume = (int)value;
        m_audioMixer.SetFloat("effectsVolume", GameManager.Instance.Settings.m_effectsVolume / 1.25f - 80);
    }

}
#

this is the code, basically I get data from GameManager and initialize option sliders and mixer volumes

#

in editor everything is fie

#

fine*

dark shell
#

Using the input system, you use events to activate methods, since it is like that, what is the best way to add parameters to the methods called
For example say i wanted to pass a variable to the method Walk...
Input.Move.Walk.started += Walk;

I saw something on the forums about using lambda, but am not sure how that works considering you have to provide the input action callbacks aswell

@ me if you know

knotty sun
quaint crypt
#

the crosshair in my game is a simple png, but in the editor when i run my game, the crosshair gets blurry, even though compression is set to none, and it is imported as sprite (2d and ui). what can i do about this? thanks!

hexed pecan
idle iris
quaint crypt
somber nacelle
knotty sun
idle iris
#

it looks like Unity has some problems calling OnEnable and Start on this component

knotty sun
#

and line 25 is?.
Please dont rush into blaming Unity

idle iris
#

is the beginning of onenable

#
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.UI;

public class SoundOptions : MonoBehaviour
{
    [SerializeField] private AudioMixer m_audioMixer;
    [SerializeField] private Slider[] sliders;

    private void Start()
    {
        //m_audioMixer.SetFloat("masterVolume", GameManager.Instance.Settings.m_masterVolume / 1.25f - 80);
        //m_audioMixer.SetFloat("musicVolume", GameManager.Instance.Settings.m_musicVolume / 1.25f - 80);
        //m_audioMixer.SetFloat("effectsVolume", GameManager.Instance.Settings.m_effectsVolume / 1.25f - 80);

        //sliders[0].value = GameManager.Instance.Settings.m_masterVolume;
        //sliders[1].value = GameManager.Instance.Settings.m_musicVolume;
        //sliders[2].value = GameManager.Instance.Settings.m_effectsVolume;
    }

    private void OnEnable()
    {
        //sliders[0].value = GameManager.Instance.Settings.m_masterVolume;
        //sliders[1].value = GameManager.Instance.Settings.m_musicVolume;
        //sliders[2].value = GameManager.Instance.Settings.m_effectsVolume;
    }

    public void OnMasterVolumeChange(float value)
    {
        GameManager.Instance.Settings.m_masterVolume = (int)value;
        m_audioMixer.SetFloat("masterVolume", GameManager.Instance.Settings.m_masterVolume / 1.25f - 80);
    }

    public void OnMusicVolumeChange(float value)
    {
        GameManager.Instance.Settings.m_musicVolume = (int)value;
        m_audioMixer.SetFloat("musicVolume", GameManager.Instance.Settings.m_musicVolume / 1.25f - 80);
    }

    public void OnEffectsVolumeChange(float value)
    {
        GameManager.Instance.Settings.m_effectsVolume = (int)value;
        m_audioMixer.SetFloat("effectsVolume", GameManager.Instance.Settings.m_effectsVolume / 1.25f - 80);
    }

}
knotty sun
#

do you expect me to count lines?

#

if you are getting an error in OnEnable then you did not save your changes

idle iris
knotty sun
#

no it isn't, it's you not understanding the difference between editor and builds

#

but hey, a few simple Debug.Logs and you will KNOW what the problem is, I leave it up to you

idle iris
#
  at SoundOptions.OnMasterVolumeChange (System.Single value) [0x0000a] in <43a3666bdfb54c90a83941094ae13e78>:0 
  at UnityEngine.Events.InvokableCall`1[T1].Invoke (T1 args0) [0x00010] in <52c27bfe78c147d5b895bd1a8cd729d7>:0 
  at UnityEngine.Events.UnityEvent`1[T0].Invoke (T0 arg0) [0x00025] in <52c27bfe78c147d5b895bd1a8cd729d7>:0 
  at UnityEngine.UI.Slider.Set (System.Single input, System.Boolean sendCallback) [0x0002d] in <c4cd81d65a5748d7876a01a2c95fc090>:0 
  at UnityEngine.UI.Slider.set_value (System.Single value) [0x00000] in <c4cd81d65a5748d7876a01a2c95fc090>:0 
  at UnityEngine.UI.Slider.set_normalizedValue (System.Single value) [0x00013] in <c4cd81d65a5748d7876a01a2c95fc090>:0 
  at UnityEngine.UI.Slider.UpdateDrag (UnityEngine.EventSystems.PointerEventData eventData, UnityEngine.Camera cam) [0x000be] in <c4cd81d65a5748d7876a01a2c95fc090>:0 
  at UnityEngine.UI.Slider.OnDrag (UnityEngine.EventSystems.PointerEventData eventData) [0x00012] in <c4cd81d65a5748d7876a01a2c95fc090>:0 
  at UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IDragHandler handler, UnityEngine.EventSystems.BaseEventData eventData) [0x00007] in <c4cd81d65a5748d7876a01a2c95fc090>:0 
  at UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) [0x00067] in <c4cd81d65a5748d7876a01a2c95fc090>:0 ``` this is the full stack trace btw
idle iris
knotty sun
#

and I still dont know what line that is on

#

but that is build, it's dll stack trace

#

Do yourself a favour, put some debugs in your code then look in the player.log

idle iris
#

I just did that: "ENTERING ON ENABLE SOUNDOPTIONS!
NullReferenceException: Object reference not set to an instance of an object
at SoundOptions.OnEnable () [0x0001c] in <cb314a39dc294bd3ad7271933b89bc62>:0

ENTERING START SOUNDOPTIONS!
NullReferenceException: Object reference not set to an instance of an object
at SoundOptions.Start () [0x0001f] in <cb314a39dc294bd3ad7271933b89bc62>:0 "

knotty sun
#

do you not know how to debug?

idle iris
#

seems like it's breaking from the audio mixer

naive swallow
#

I've got a situation where "time" can be non-linear (you can scrub through playback to get the state of something at a specific time) and I want an animation to be starting at some point in time after when it should start. I have the timestamp of when an animation should have started, I have the current time stamp, and I have the name of the animation that should be playing at this point in the timeline. I need to play that animation at the proper normalized time to where it would be at that timestamp. Easy enough to find what that normalized time is, it's the InverseLerp of the current timestamp minus the start time from the clip's duration.

Only problem: How do I get the duration of a clip by name? I can get the current state info, but entering the state, getting the info, then getting the length from that in order to play that animation again from a new start point seems clunky and awful, and usually with Animator controls that means I'm doing something the hard way.

idle iris
#

are there any chances mixer group references are not loaded in builds?

knotty sun
#

debug which object is null

idle iris
#

finally found it, thanks for the tip, but is kinda cryptic so far; basically the game manager wasn't initializing properly cuz of this: The process cannot access the file 'C:\Users\saita\AppData\LocalLow\SaiTatter\BEARing\Player.log' because it is being used by another process.

#

and I know the culprit; I was deleteing everything from persistent folder when initialising the game manager (was working on save files and wanted clean ones each time)

#

and editor doesnt write player.log

knotty sun
#

Then you have more than one build running at once

idle iris
#

only build so yep...

#

I try to delete it but it's opened by the unity engine so that's a lock; damn shady one

#

at least I can exclude all files but that one so it should be okay; sorry for wasting your time; I think I wasted all my day with this 😦

quaint crypt
#

I have a monobehaviour that is linked a scriptableobject with the settings pertaining to it. should I cache the values of those settings, or is there no performance penalty in addressing the attrs of the mentioned SO?

latent latch
#

A single instance of the SO is created at runtime, the idea is you read from that single instance, so technically it's pretty performative as is

mild orbit
#

Right, so I am trying to make a camera rotate around a pivot point when the middle mouse button is held. The horizontal rotation works fine, but I am having a hard time with the vertical rotation. It keeps flipping around, or other methods will lock it once it gets to the top/bottom. Something just isn't click for me right now. Any advice?

public class SceneCamera : MonoBehaviour
    {
        [SerializeField] private Vector3 _pivot;
        [SerializeField] private float _speed = 1;

        private Vector3 _startMousePosition;
        
        private void Update()
        {
            if (Input.GetKeyDown(KeyCode.Mouse2))
            {
                _startMousePosition = Input.mousePosition;
            }

            if (Input.GetKey(KeyCode.Mouse2))
            {
                Vector3 delta = Input.mousePosition - _startMousePosition;

                Quaternion rot = Quaternion.Euler(-delta.y * _speed, delta.x * _speed, 0);

                transform.position = rot * transform.position + _pivot;
    
                transform.LookAt(_pivot);
                
                _startMousePosition = Input.mousePosition;
            }
        }
    }
analog relic
mild orbit
light rock
#

to tilt the view (up and down) rotate around a horizontal axis (like transform.right) and to pan the view (left and right) rotate the view around a vertical axis (like transform.up)

mild orbit
light rock
#

even with rotatearound?

mild orbit
# light rock even with rotatearound?

With just rotating on the x axis, this is what ya get

Vector3 delta = Input.mousePosition - _startMousePosition;
transform.RotateAround(_pivot, Vector3.right, -delta.y * _speed);
transform.LookAt(_pivot);    
_startMousePosition = Input.mousePosition;
light rock
#

i think the issue is with transform.lookat

#

when you dont include an "up" vector for lookAt it assumes world as being up

#

but im assuming you want your camera to be able to go upside down so that's a no-no

mild orbit
#

Hmm, what direction should I provide then?

light rock
#

i dont think you need to use lookAt at all

#

i think rotateAround preserves the direction towards the pivot

sly shoal
#

hey, i can post code if necessary but im hoping this is a common issue with a simple fix
my character can double jump but sometimes if i mash the jump button, it performs a third jump before the code is able to update the number of jumps left.
even if i add some kinda bool like readyToJump that ensures the number of jumps decreases before a jump is performed, im able to sneak a third jump in.
how do i fix this :]

light rock
#

so how are you doing that?

sly shoal
#

oh hmm. so you think there might be a frame or two where im jumping but still touching the ground so it resets the number of jumps?

light rock
sly shoal
#

im debugging now to check

mild orbit
light rock
#

no problem

sly shoal
#

gaaaaaaaah and now of course since i've asked for help, im unable to replicate the error

#

aha! yep. i think its triggering the reset as i leave the ground

#

so this is how im currently grounding.

#

@light rock how would you recommend i do the grounding check to avoid this issue?

vague jolt
#
    void Update()
    {

        temp.Clear();
        foreach (Transform child in transform)
        {
            temp.Add(child.gameObject);
        }

        if (temp != saved)
        {
            saved = temp;
            saveFile();
        }

    }

Why is the function saveFile is just called when I turn on the game or when script are reloded ?

#

If i change temp saved changes too but save file is not called

#

I just checked and the if statement is not called when i change temp, EDIt it does but it does not call a debug.log

lean sail
#

what is temp and saved even? you havent provided any context for what this is supposed to do

somber nacelle
vague jolt
#

ohh i think i got it, if i say saved = temp know saved is just temp ?

somber nacelle
#

you did update the list, sure. but that doesn't mean that saved suddenly isn't the same list still. List<T> is a reference type. this means when you do something like saved = temp; then both variables point to the same instance in memory until you assign a new list to either of the variables.

#

all you are doing here is checking whether they are the same instance then if they are not you make them the same instance and call your SaveFile method

somber nacelle
#

they are literally the same list in memory

vague jolt
#

and equal the elements

#

Thank you really much

light rock
sly shoal
#

Ah that's a good idea. I assume you have some kind of jump buffer so that if the player jumps in those .2 seconds, it still registers the input and jumps when the time is up?

lean sail
#

that might feel pretty awkward for the user if you buffer the jump like that

#

I just have a cooldown from the last jump, regardless if they actually got off the ground due to ceilings or whatever else

sly shoal
#

Hm fair enough. I'll test out a couple of options. Thanks for the help, all

lean sail
#

the jump cooldown alone really should get rid of most double jump issues at least. Within the 0.2 seconds your character shouldnt still be grounded

#

or whatever timer u set it to. Its really just a few frames that itll be grounded

vague jolt
#
                "entity_number": 6,
                "name": "filter-inserter",
                "position": {
                    "x": 3.5,
                    "y": 2.5
                },
                "direction": 6,

I am trying to get something like this using json utility


    public class StructuresJSON
    {
        public int entity_number;
        public string name;
        public class position
        {
            public double x;
            public double y;
        }
        public int direction;
    }

is this the right way ? if yes how do i declare the class positon?
Because once i declared the new structure i would do json utility to jason of the new class

lean sail
#

Right way to do what?

vague jolt
#

https://www.youtube.com/watch?v=4oRVMCRCvN0&t=246s
This tutorial shows how to get a json string, he uses a class, then si converted to json with json utilities, but it does not show how to do nested values like the position values, so iam improvising a bit but i don't know how to do it

🌍 Get my Complete Courses! ✅ https://unitycodemonkey.com/courses
👍 Learn to make awesome games step-by-step from start to finish.
✅ Unity Basics for Beginners Playlist: https://www.youtube.com/playlist?list=PLzDRvYVwl53vxdAPq8OznBAdjf0eeiipT
In this video we're going to learn what is JSON, how its formatted and how we can use it in Unity to easi...

▶ Play video
lean sail
#

You can test this really easily just by creating a json string. No need to create and write to file

vague jolt
#
            StructuresJSON structureJSON = new StructuresJSON();
            structureJSON.entity_number = i;
            structureJSON.name = structures[i].tag;

i decleared the first values, but how do i declare the rest?

#
        public class position
        {
            public double x;
            public double y;
        }

This, i am not suire nesting classes is the way to go

#

because structuresJSON.position.x does not work, but if i declare the class positon as a new class it will not be all in one string

lean sail
#

you're going to have to instantiate the position, otherwise what would u be setting as x and y

vague jolt
lean sail
#

what do you mean it wont all be in one string also

#

have u printed out the actual json string?

vague jolt
#

i think we are not understanding each other

#
"entities": [
[
{
                "entity_number": 1,
                "name": "centrifuge",
                "position": {
                    "x": 1.5,
                    "y": 1.5
                },
                "recipe": "kovarex-enrichment-process"
            },
            {
                "entity_number": 2,
                "name": "steel-chest",
                "position": {
                    "x": 4.5,
                    "y": 0.5
                }
            },
]

how do i create a class that when i run it trught JsonUtility.ToJson(entitites); i get the json string above

#

i get the aprt where you make a class, but my problem is that how do i decleare a key that has more keys inside

spark shadow
#

is there any studio accept remote student for internship? no salary needed.

vague jolt
#

like entitites is an array, but is not an int or a string, is an array of many things, do i make a class and then declare tha array as a class

vague jolt
#

also why would you want to do job for free

spark shadow
lean sail
vague jolt
#

that would make sence

spark shadow
vague jolt
#

i am a student too

#

if you want to do some game developement you should start doing game jam and try to get a name for youself

#

at least thats what seems a good idea, working for some one else looks sad

#

at least when you start

spark shadow
spark shadow
vague jolt
tacit lance
#

Is there a way to have something like

using System;
using UnityEngine;

[Serializable]
public class ExampleClass
{
    [SerializeField] private int test;
}
using UnityEditor;
using UnityEngine;

[CustomEditor(typeof(ExampleClass))]
public class ExampleClassEditor : Editor
{
    public override void OnInspectorGUI()
    {
         [...]
    }
}
using UnityEngine;

[RequireComponent(typeof(GameEventObject))]
public class ExampleBehaviour : MonoBehaviour
{
    [SerializeField] private ExampleClass example;
}
#

This doesn't seem to work in the editor, which suggests the custom editors only work for monobehaviours?

#

Is there some other way to control how a class will display on the unity editor?

quartz folio
#

Use a PropertyDrawer

tacit lance
mild orbit
# mild orbit Welp... that was it. It now rotates relative to the rotation of the camera, whic...

After banging my against the whole for another 45 minutes... I got nothing.
This rotates the camera and makes it look at the pivot. But it does the rotation around the current axis, not the world global axis.

Which means if you rotate 45 on the X, then 90 on the Y, the Z rotation of the camera is going to be rotated and everything will be titled.

transform.RotateAround(_pivot, Vector3.up, delta.x * _speed);
transform.RotateAround(_pivot,  Vector3.right, -delta.y * _speed);

I know how to rotate the position around the pivot. The hard part is getting the rotation so that when you go past 90 degrees on the x (past looking down at the pivot) the camera will go upside down instead of flipping around.

So if anyone has some direction, I would love to hear it!

mystic yoke
#

@mild orbit gimme 2 sec, maybe one of my repos has this

#

doesn't look like it, lemme whip something up rl quick for you

#

it's a lot easier to not use euler angles

inner relic
#

in general for coding, is it better to just "make something now" and fix it later

#

or is it better to slow the momentum of your project, but do something properly the first time

potent sleet
#

I just need something that works and works well, idc if it needs refactor at some point

#

depends on your intent I guess

lean sail
# inner relic in general for coding, is it better to just "make something now" and fix it late...

The answer to most question like these is it depends on what you are making, really you should be the judge of this. Are u making something thats fundamental to the rest of your program, with everything building ontop of this low level code? If so, you probably dont want to refactor this and a billion other things. You should plan on the structure to minimize changes, but obviously there will be some.

#

If this is just like moving the player, then just get something working

leaden ice
inner relic
#

creating player movement

#

creating interfaces I'll use later

#

etc.

#

I find that I keep on coding these things

#

and I spend a lot of time trying to make it the best I can

#

cause I dont' want performance issues down the road

#

but it kills my momentum

lean sail
#

you'll refactor it anyways

inner relic
#

I don't get things done

#

I also find that I keep on trying to do things in order to get more performance for diminshing returns when I don't need to

mystic yoke
#

@mild orbit here you go

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

public class CameraPivot : MonoBehaviour
{
    // Start is called before the first frame update

    public Vector3 pivot;

    public Vector2 sensitivity = Vector2.one;
    public float cameraDistance = 10;

    float pitch = -30;
    float yaw = 0;
    void Start() {

    }

    private void Update() {
        if (Input.GetMouseButton(0))
        {
            pitch += Input.GetAxis("Mouse Y") * sensitivity.y;
            yaw +=  Input.GetAxis("Mouse X") * sensitivity.x;
        }

        var horRot = Quaternion.AngleAxis(yaw, Vector3.up);
        var verRot = Quaternion.AngleAxis(pitch, Vector3.right);

        var dir = horRot * verRot * Vector3.forward;

        var cameraUp = Vector3.Cross( horRot * Vector3.left, dir );

        transform.position = pivot + dir * cameraDistance;

        transform.LookAt( pivot, cameraUp );
    }
}
mild orbit
mystic yoke
#

yeh, you can also do it using the rotations to set the camera rotation directly but this is conceptually more straightforward bc if you just apply them directly the camera will be facing outward instead of inwards

#

so you need to use the inverse rotations instead which is a bit awkward

mild orbit
#

Yeah, there was a number of ways I had tried doing it. When using LookAt, I kept getting stuck at what/how to pass as the up.

#

I even tried doing it with like a quaterion delta and adding it to the main rotation. It was ugly... and didn't work

mystic yoke
#

yah part of that was using euler angles, since you don't have a decomposed rotation to work with

#

I much prefer working with angleaxis instead of euler when doing any camera rotation stuff

#

first person or 3rd person

mild orbit
#

Huh, good to know. Thanks! Quaternions are definitely a weak area for me, and vector math is a semi close second 😅
So I really appreciate the help!

vague jolt
#
   public bool checkOverlaps(GameObject structure)
    {
        string save = File.ReadAllText(Application.dataPath + "/save.json");
        SaveJSON saveJSON = JsonUtility.FromJson<SaveJSON>(save);

        for(int i = 0; i<structures.Count; i++)
        {
            if (checkOverlap(saveJSON.entities[i], structure))
            {
                return true;
            }
        }

        return false;
    }

    #region variables for checkOverlap

    double x1;
    double x2;
    double y1;
    double y2;

    double minX;
    double minY;

    #endregion

    public bool checkOverlap(Entities structure1, GameObject strucure2)
    {
        for (int i = 0; i < prefabs.Length; i++)
        {
            if(structure1.name == prefabs[i].tag)
            {
                x1 = prefabs[i].GetComponent<snapToGrid>().x;
                y1 = prefabs[i].GetComponent<snapToGrid>().y;
                break;
            }
        }

        x2 = strucure2.GetComponent<snapToGrid>().x;
        y2 = strucure2.GetComponent<snapToGrid>().y;

        //if they are rotated sideways we need to invert x and y aka width and height
        if (structure1.direction % 2 != 0)
        {
            (x1, y1) = (y1, x1);
        }
        if(strucure2.GetComponent<RotateSprite>().rotation % 2 != 0)
        {
            (x2, y2) = (y2, x2);
        }

        //we are getting the minimum distance between the two object by summing half of theyr lenght in both axis
        minX = x1 / 2 + x2 / 2;
        minY = y1 / 2 + y2 /2;
        //check if the distance X and Y are equal or greater than the minimun distance it will return true
        if (Mathf.Abs((float)structure1.position.x - strucure2.transform.position.x) >= minX || Mathf.Abs((float)structure1.position.y - strucure2.transform.position.y) >= minY)
        {
            return false;
        }

        return true;
    }
#

so in my game there is a grid where i spawn game object, i don't want to have them be one on top of the other, so i wrote a script that saves the location of each object in a json, then i read it and check if there are any collision.
How can i optimize it ?

#

after around 500 objects it starts to get really slow

#

one thing i thoght would be to get objects just close to the one i am cheking

quartz folio
#

Firstly, not calling GetComponent repeatedly on the same object inside a hot path will do a bunch

#

Then you've got a bunch of string comparisons in there too for some vague reasons

quartz folio
#

structure1.name == prefabs[i].tag

vague jolt
#

that one is used because i store the name of the structure and i need to find the prefab with stored the value X and Y for that structure

#

is bad ?

fervent furnace
#

Why dont you find some places to cache all the x and y of prefabs and using a dictionary to O(1) fetch

vague jolt
#

would be smart

#

at that point i could just check what tag does the object 2 has and use the x and y from the prefab there

mystic yoke
cobalt gyro
#

for some reason raycast.point is being returned -.4 units off, does anyone know why

lean sail
#

Off from what, I have no clue what that image is supposed to be showing

cobalt gyro
leaden ice
#

You'd have to explain better what that means and what it would be like for "the vertices" to be "right"

cobalt gyro
#

nvm

tawny mountain
#

I have a question about physics ...

#

in the following image the tennis ball falls and the bowling ball goes up and to the right (BLACK ARROWS) ... I want it to go up and to the right (RED ARROW)

#

how can I make this happen? I am using rigidbody2d to handle physics not C#

lean sail
cursive gorge
#

I want to cache the scenes that will be loaded with SceneManager.loadsceneasync in the background. I want to load and resume when necessary, but I don't have much experience with async operations, can you give an example?

stone rock
#

Hello i think i encountered a bug or something with Unity, i am making a script to test how certain values change but for some reason the inspector randomly breaks and only displays 1 value or 3 of the actual 8 it should display

#

anyone know how to fix this?

stone rock
#

These are some of the values it should also display but it doesn't

    [Header("Properties")]
    public float Radius = 0.5f;

    [Header("Calculated Values")]
    public float Load = 2452.5f;
    public Vector2 LocalVelocity = Vector3.zero;
    public float AngularVelocity = 0.0f;

    public float LNSlip = 0.0f;
    public float LTSlip = 0.0f;
#

they are public and nothing special is done with them

#

it just weirdly breaks randomly

#

these errors also show up sometimes entering playmode but this is code from Unity itself

winter nexus
#

sheesh

stone rock
#

this is in the 2022.3.0f1 LTS also

prime sinew
#

maybe try deleting Library folder

stone rock
#

will do, does this version already use toolkit for ui instead of what they had first?

prime sinew
#

not sure. i still use 2021

stone rock
#

if it does i think they switched too soon it seems not production ready because in 2021 it works fine

#

i see there is a 1f1 version now though maybe it is fixed in that one

silver pulsar
#

how do I install AI package manager?

earnest gazelle
#

Do you prefer to put all your different runtime objects in one list with base interface/abstract to save?
or separate them in different lists based on their types?

    public class WorldPersistentData
    {
        public List<DataPersistenceObject> Buildings;
        public List<DataPersistenceObject> Items;
        //...
    }
    public class WorldPersistentData
    {
        public List<DataPersistenceObject> Objects;

    }
glossy mica
#

2dir vs A*

gray mural
#

though I think first one looks more readable and convenient

urban marsh
#

Hello everyone !
I am using Visual studio Code with the Unity Editor.
When I have an unused variable declared in a class outside of a function, I get a warning.
How do I get the same type of warning for a variable declared inside a function ?
(I have no doubt there should be a setting for vs code for hits)

urban marsh
#

yeap

gray mural
urban marsh
#

I think so (it's the one when I double-click on a C# file in unity)

#

(also if possible in the unity console to have the list of 100 unused variable directly :p )

earnest gazelle
gray mural
urban marsh
#

yeah yeah, it's vscode

gray mural
gray mural
#

@urban marsh maybe you consider installing Unity Technologies extension? (I guess)

earnest gazelle
earnest gazelle
#

Because, if I separate them (in my example Building from Item), I need to have different spawn system for each.

foreach(var data in persistenceBuildings){

}
foreach(var data in persistenceItems){

}
urban marsh
earnest gazelle
gray mural
#

type

#

List<DataPersistenceObject>, right?

earnest gazelle
#
 public abstract class PersistenceObject : MonoBehaviour
    {
        [SerializeField] [Required] private Entity _entity;

        private IDataPersistence[] _dataPersistenceArray;

        private void Start()
        {
            _dataPersistenceArray = GetComponentsInChildren<IDataPersistence>();
            WorldStorageSystem.Instance.Saving += OnSaving;
        }

        private void OnDestroy()
        {
            WorldStorageSystem.Instance.Saving -= OnSaving;
        }

        private void OnSaving()
        {
            WorldStorageSystem.Instance.Add(this);
        }

        public void LoadData(DataPersistenceObject dataObject)
        {
            for (var i = 0; i < _dataPersistenceArray.Length; i++)
            {
                _dataPersistenceArray[i].LoadData(dataObject);
            }
        }

        public void SaveData(WorldPersistentData worldData)
        {
            var persistenceObject = new DataPersistenceObject();
            persistenceObject.Id = _entity.InstanceId;
            for (var i = 0; i < _dataPersistenceArray.Length; i++)
            {
                _dataPersistenceArray[i].SaveData(persistenceObject);
            }

            DoSaveData(persistenceObject, worldData);
        }

        public abstract void DoSaveData(DataPersistenceObject data, WorldPersistentData worldData);
    }
#

A base monobehaviour which handles save/load for that gameobject

gray mural
earnest gazelle
gray mural
#

@earnest gazelle

private void LoadSmth(List<DataPersistenceObject> persistenceObjects)
{
    persistenceObjects.ForEach(data => 
    {
        Asset asset = data.GetComponent<Asset>();

        int assetDef = _assetCollection.Get(asset.Id);

        GameObject newObject = Instantiate(assetDef.Prefab);

        newObject.GetComponent<Loader>().Load(data);
    });
}
gray mural
urban marsh
gray mural
urban marsh
#

I have it since I begun using vscode with unity, a yeaar ago.

#

always had warning for unused vars declared outside of functions, never for vars inside them.

earnest gazelle
urban marsh
#

@gray mural the thing you linked is outdated.
searching aroudn on google, I found a few prople with similar problems, but the settings interface changed in the last few years, and I can not find the same settings :/

gray mural
#

I have said that it's according to you

#

and if you would like to seperate them, then you should make a method for them

#

you have said that you did not get it, so I made you an example

gray mural
#

I think you should either ignore it or consider installing new editor e. g. Visual Studio

stark jacinth
#

I have an question on how to have the flashlight in my players hand rotate correctly with my player. Currently, when my player rotates the flashlight follows my player but stays in the same rotation, for example, if I turn 180 I see the back end of my flashlight. Am I suppose to have an empty transform in the flashlight, and then have the flashlight rotate on the horizontal axis inline with my camera's rotation?

#

or is their an easier way to implement this?

lean sail
stark jacinth
#

it is a child of the player

#

it rotates but not correctly

#

the flashlight is a prefab I made in blender

#

I think thats why its not working correctly

lean sail
#

Prefab or not it should still rotate along with the parent

lean sail
earnest gazelle
#

Have you worked with message pack?

Hey, Why can't I serialize/deserialize it using message pack?

  [MessagePackObject]
    public class DataPersistenceObject
    {
        [Key(0)] public Guid Id;
        [Key(1)] public Dictionary<int, IData> Components { get; } = new();
 [MessagePackObject]
    public class WorldPersistentData
    {
        [Key(0)] public List<DataPersistenceObject> Objects;
    }

I have added implemented types

[MessagePack.Union(0, typeof())]
    public interface IData
    {
    }

and it is message pack resolver

 static WorldStorage()
        {
            var resolver = MessagePack.Resolvers.CompositeResolver.Create(
                // resolver custom types first
                BuiltinResolver.Instance,
                MessagePack.Unity.UnityResolver.Instance,
                // finally use standard resolver
                StandardResolver.Instance
            );
            MessagePackSerializerOptions = new MessagePackSerializerOptions(resolver);
            MessagePackSerializerOptions = MessagePackSerializerOptions.WithCompression(MessagePackCompression.Lz4Block);
        }

Components is empty [0] when loading/deserializing.
Objects (list) is OK. It has some elements in
Guid is OK as well.
The problem is Dictionary

Dictionary<int, IData> Components
nimble kernel
#

Does anyone here have experience with Morpeh ECS?

kind wolf
#

WHY DOES VS CODE DELETE WORDS AFTER IT WHEN IT AUTOFILLS

#

im actually going insane nothing ive tried works

#

ive tried reinstalling and that doesnt do anything either

late aurora
#

hello, i`m try to invoke event by his name but i get error:
TargetException: Object does not match target type.
code with getting event:

GetType().GetEvent(eventName).EventHandlerType.GetMethod("Invoke").Invoke(???, new object[] { whatHeDone , whoItDone });

im not sure what i need instead of ??? (previous that i used:
GetType().GetEvent(eventName).EventHandlerType.GetType())
(P.S. GetMethod("Invoke") is successfully get func.)

nimble kernel
kind wolf
#

i found the issue

#

this guy

haughty bobcat
#

Guys im trying to make a raycast with multiple raycast but it looks wrong this is what I mean, How I can fix this? This is a custom wheel collider im not trying to use unity wheel collider. https://cdn.discordapp.com/attachments/831185804746555448/1117047530581147699/image.png This is the code where the angle is calculated https://pastebin.com/tTuqdD6N

steady moat
late aurora
heady iris
#

what are you trying to do?

#

you are XY-probleming yourself here

steady moat
heady iris
#

indeed, since non-static methods must be invoked on a specific object

steady moat
#

However, you should ask yourself if you really need reflection. It is most of the time a bad idea. (Without trying to be rude; Even more for people that do not understand fundamental concept)

heady iris
#

reflection is a last resort

#

you throw away a bunch of compile-time checks

steady moat
#

It is also not performant.

heady iris
#

indeed, since the compiler can't just produce IL that calls a method

#

it has to go find it at runtime

glossy mica
#

For the following scene, my A* had an avg exec time of 0.10ms while bidirectional A* at 0.20ms. Is this normal? And it’s been consistent no matter where I put. Am I analysing it wrongly? The grid size is 30x30. And node radius of 0.5.

fervent furnace
#

why dont you have a look at your search space?

late aurora
#

btw i started do this because i want to let users somehow make a addons for game in the future

fervent furnace
#

the node radius doesnt matter how your algorithm runs, your algorithm only consider V and E

heady iris
#

so it takes exactly as long if you set the destination to be only one tile away?

#

i haven't implemented that in a while

#

it feels like it should be pruning paths that are longer than the best-known path

urban marsh
#

Hello !
I come back with the same question as before, hoping hat there are different people this time and maybe somebody knows the answer :
I use vs-code with Unity.
vs-code is my default unity editor.
When I implement a script and I have an unused var declared outside a function, I will get a warning in the Unity Console, telling me it is unused.
When I have an unused variable inside a function, I do not get a warning anywhere : it is not highlighted in vs-code, and there is no warning in the Unity console.
Do you guys know a way to get a warning somewhere ?

fervent furnace
#

i will get variable is declared but never used if i declare it inside the function but not the reverse case

#

ofc i use vs code

heady iris
#

I get warnings when I have unused local variables in VSCode.

#

Perhaps you can show an example.

urban marsh
#
protected int pif;
protected void func() {
    int paf;
    int pouf = 2;
    pouf += 1;
}```
I get warnings for pif and paf, but nothing for pouf, even though it is a useless variable.
steady moat
heady iris
#

that's not a local variable

#

it's a field

#

and it's a protected field, so a derived class could use it

#

there is nothing wrong here

#

oh, I misread your code

#

🫠

#

can that int ever be visible to anyone else?

fervent furnace
#

declaration of pif should not be warned...

heady iris
#

sounds like something is up with your linting rules

#

it's possible to disable specific messages. perhaps you have done that?

dusk apex
urban marsh
heady iris
#

i suspect there are many ways to do this...but in my case, I've done that exclusively via .editorconfig

#
[**.cs]
dotnet_diagnostic.IDE0017.severity = none
dotnet_diagnostic.IDE0060.severity = none
dotnet_diagnostic.IDE0051.severity = none
dotnet_diagnostic.CS8524.severity = none
dotnet_diagnostic.UNT0028.severity = none
dotnet_diagnostic.CS0282.severity = none

i can't remember what these are

urban marsh
glossy mica
urban marsh
glossy mica
fervent furnace
#

"search space", shows all explored nodes

heady iris
#

if it's not obviously there, then it's probably not the issue

fervent furnace
#

by draw a line from parent to children or simply log the number

#

i prefer first way

heady iris
#

is it about bidirectional search being slower?

gray mural
#

Does somebody know what method executes when the new line is entered in TMP_InputField?
(without using "\n", just when there is too much text)

urban marsh
glossy mica
heady iris
#

i thought you were just asking if that 0.1-ish millisecond runtime was expected

misty reef
#

Hi. This is driving me crazy. If I have a Plane with transform.position center and transform.forward normal, how do I project the vectors V1 and V2 onto the plane and then calculate the angle between the two vectors projected onto the plane? Thank you.
This doesn't work, the drawn rays are wrong:

Vector3 projectedPoint1 = Vector3.ProjectOnPlane(prevhitpoint.Value, transform.forward);
Vector3 projectedPoint2 = Vector3.ProjectOnPlane(hit.point, transform.forward);

float angle = Vector3.SignedAngle(projectedPoint1 - transform.position, projectedPoint2 - transform.position, transform.up);

Debug.DrawRay(transform.position, projectedPoint1 - transform.position, Color.red);
Debug.DrawRay(transform.position, projectedPoint2 - transform.position, Color.green);
heady iris
#

ProjectOnPlane removes the component of the vector that points in the directional of the normal

#

what you're doing feels off here

#

feels like you should be subtracting the position of the plane from the two points before the projection

#

for a trivial example: imagine the plane is at [0,0,1] and the point is at [0,0,1], with a normal vector of [0,0,1]

#

actually, hmm, that might work out correctly..

steady moat
#

You can also express the position of the vector in function of the plane then remove the Y coordinate.

heady iris
#

ah, by just converting from world to local space?

steady moat
#

Kinda.

heady iris
#

i need a whiteboard for this lol

steady moat