#archived-code-general

1 messages ยท Page 263 of 1

ashen jasper
#

i havent programed in unity for a while

#

but i look into that

mild coyote
#

Note that I'm not sure if it will work when run in game, I just tested it in editor mode XD

ashen jasper
#

that actually works but there a problem that comes to this

#

the mouth left and right have different propertys

#

the plan is to basically let the game know if he is facing left to change the angles of all the armitures to mirror animation

#

Actually now that I think about it. This could save me on resources

ashen jasper
#

So umm i was wrong there are many issues when it comes to this

woven veldt
#

Hi, I have a model which has a bone structure with objects added to the end, which are rotating in an endless loop. This is pared with the rest of the mesh which is not animated. I want to try and convert this object to a single entity. Is this possible or would it come out as 2 entities. One which holds the animation and one which holds the other static mesh?

lean sail
flint swallow
#

i'm trying to distribute a points on a scale of 1 to 10 evenly using this code, but it's just spitting out 0s:

 private float[] scale;

// Start is called before the first frame update
void Start()
{


    scale = new float[5];

    for (int i = 0; i < 5; i++)
    {
        scale[i] = i / (5 + 1);
        Debug.Log(scale[i]);
    }
}
somber nacelle
#

you are doing integer math

flint swallow
flint swallow
somber nacelle
#

do you know the difference between integers and floating point numbers?

fervent furnace
#

not code general
int 1/int 2 =0

flint swallow
#

ya i do

#

wait

#

il cast it to float and will that fix it?

somber nacelle
#

just slap an f on one of those magic numbers

flint swallow
#

ok

flint swallow
somber nacelle
flint swallow
#

why is 1/2 = 0 in int

somber nacelle
knotty sun
flint swallow
#

๐Ÿคฆโ€โ™‚๏ธ im dum

somber nacelle
#

so then the answer to this question #archived-code-general message
was very likely "no, i do not know the difference between integers and floating point numbers"

flint swallow
#

no i just had a brain malfunction

#

so how can i fix for this code:

#

im trying to distribute points evenly on a circle

knotty sun
#

cast i to float

somber nacelle
flint swallow
somber nacelle
#

and you've actually saved/compiled the code after making that 1 a float?

flint swallow
#

k casting i to float fixed it

#

ya

#

im not that dum

somber nacelle
#

well casting i to float wouldn't be necessary if the denominator is already a float because int divided by float returns a float

flint swallow
somber nacelle
#

prove it by removing the cast

flint swallow
#

does that function correctly map the values evenly from 0 to 1?

flint swallow
fervent furnace
#

range of i is [0,count-1] where dominator is count+1

flint swallow
#

this isnt correctly mapped tho

#

this is my coords function:

somber nacelle
flint swallow
flint swallow
somber nacelle
hexed pecan
#

Classic

flint swallow
#

the mapping code supposed to give 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9. but its giving:

somber nacelle
#

anyway, this is what i had done for something similar. I was shooting raycasts in a cone/circle rather than putting points on a circle, but the concept is really the same

var maxAngle = _fovAngle / 2f;
var offset = _rayCount > 1 ? _fovAngle / (_rayCount - 1) : maxAngle;
for(var i = 0; i < _rayCount; i++)
{
    var angle = -maxAngle + (offset * i);
    var dir = Quaternion.AngleAxis(angle,Vector3.up) * transform.forward;
    Debug.DrawRay(transform.position, dir * _rayLength, Color.green);
}
flint swallow
#

y isnt mine woring

hexed pecan
#

Btw the Mathf.Clamp line does absolutely nothing

flint swallow
#

ya i figured that out

#

the trig functions are periodic

visual tendon
#

Guys, are fancy filters supported by AssetDatabase.FindAssets? I'm trying the code below but always gets 0 results even when the file do exists:
string[] guids = AssetDatabase.FindAssets("p: dir:\"UI/Controls\" MyFancyUIDocument.uxml");

#

It does work in Unity's search utility ๐Ÿ˜–

hybrid relic
#

ur using the values you get without like "smoothing" them

flint swallow
hybrid relic
#

also seeing the rest of your messages, you might want to take a basic C# course

wicked elbow
#

hello
i kinda need help

flint swallow
hybrid relic
knotty sun
visual tendon
wicked elbow
#

so i follow a tutoral and he put rigid body on sb but i cant see the rb place on mine i have exactly the same code

hybrid relic
#

stop cross posting

wicked elbow
#

wth is cross posting

somber nacelle
#

posting your question across multiple channels

hybrid relic
flint swallow
#

ya il post there from now

hybrid relic
#

Also please look at a C# Tutorial so you understand the coding language

flint swallow
#

i just saw general and popped in here

flint swallow
#

(i dont know how making a monogame game proves my c# intellect but... just trust me)

hybrid relic
#

you dont just forget interger math

flint swallow
#

i dont like int

hybrid relic
#

unless you dont code much or like had a big pause

flint swallow
#

ya i had my final exams

#

so i had a loong pausr

hybrid relic
#

anyways before asking such basic stuff again, look at these to refresh your knowledge, should help you get back in:
https://www.youtube.com/watch?v=gfkTfcpWqAY
https://www.youtube.com/watch?v=XtQMytORBmM

C# tutorial for beginners: Get up & running with C# and code in just 1 hour! No prior knowledge needed.

โญ๏ธWant to learn more from me? Check out these links:

Courses: https://codewithmosh.com
Twitter: https://twitter.com/moshhame...

โ–ถ Play video

๐Ÿ”ด Get bonus content by supporting Game Makerโ€™s Toolkit - https://gamemakerstoolkit.com/support/ ๐Ÿ”ด

Unity is an amazingly powerful game engine - but it can be hard to learn. Especially if you find tutorials hard to follow and prefer to learn by doing. If that sounds like you then this tutorial will get you acquainted with the basics - and then gi...

โ–ถ Play video
flint swallow
#

btw if i needed someone to playtest my game, is there a channel here for that or am i gonna have to make friends

hybrid relic
#

or put it on itch, with the warning that its a playtest / alpha

flint swallow
#

but what if i finished only the movemnt and wanted someone to tell me if it feels well

#

its like 1 minute of playtesting or smth

#

like, the art is just borrowed from random files i have from modding games (this one is from celeste)

lime gazelle
#

what happens if a server passes in a wrong argument in a client RPC which will lead to a error on a client (listOutOfIndex) will the client crash or will it be ignored if so will the list return null?

somber nacelle
#

it will throw an exception on the client just like doing that in any other context would

#

whether there are ramifications depends on the actual context of the exception just like literally any exception
also #archived-networking for networking related questions

lime gazelle
#

k, thanks.

visual tendon
hybrid relic
hexed pecan
#

The backslashes seem out of place in the code, especially the first one

somber nacelle
#

they are escaping the "

hexed pecan
#

Aah, makes sense then

#

I really gotta learn regex and such

nova leaf
#

so, i am using asset bundles for mods and it works perfectly, however, if i spawn a prefab, audio clips are not found, even tho they are in the asset bundle too

quaint rock
#

How is audio referenced

nova leaf
#

it is just inside of an audiosource within the prefab, but the clips are also iuncluded in the asset bundle, do i have to load them manually?

quaint rock
#

Should not have to, as long as the audio clips are referenced they should auto be included in the bundle and get loaded with it

nova leaf
#

hmm ok...

quaint rock
#

If you don't manually include the audio clips, I would check and see if they get auto included because the prefabs reference them

nova leaf
quaint rock
#

Other dependencies are being pulled in fine?

#

Like textures, materials etc

nova leaf
quaint rock
nova leaf
#

u mean in unity in the folder?

quaint rock
nova leaf
#

ah

#

found the issue

#

strange one

quaint rock
#

Oh what was it very curious?

nova leaf
#

the object the audio source is on has to be active, in the prefab it was not active because i set them active in a function

#

very strange

#

why is it like this tho

#

the modles which are not active work

quaint rock
#

Hmm never run into that before, but it seems very counterproductive

#

Will test when I get to work later

#

What unity version?

nova leaf
quaint rock
#

Work around I guess is keep then active in prefab and disable on Awake

nova leaf
#

yeah

#

will do that

quaint rock
#

Hmm will look at that later, I am using 2022.3 for a project at work too. Though using addressables not bare asset bundles

somber nacelle
neon plank
#

Ups

static matrix
#

What would be a solid solution for detecting when something can jump to follow something?
I was thinking something like shoot a raycast in the direction of the prey, if it hits something, shoot another raycast from that X but the Y of the prey, and if that hits then presume you can jump to the ting

static matrix
#

ontriggerenter calls both ways right?
like it calls on a trigger when it enters a collider or no
no
im wrong

flint swallow
#

how can i create a mask inside which i can draw a texture using a list of points

somber nacelle
static matrix
#

so if a trigger enters a non-trigger is ontrigger enter called on the trigger?

flint swallow
#

i have this line renderer that displays the edges (the blue thing) i want to fill it with a texture

#

k il wait

somber nacelle
static matrix
#

oooh thats
interesting
you should use a polygoncollider

static matrix
# flint swallow

unsure how to fill it with a texture, but you could use an occlusion mask(?) to just render that texture everywhere but have it be hidden outside the area

flint swallow
#

ya thats what i was thinking

static matrix
#

although i've only done that the other way around, having it be vis everywhere except the target area (for flashlights)

flint swallow
#

so basically (if u read my prev msgs) i make those points move in a circle. its likea slime character but using rigidbody physics so i will use these points to render the skin of the player but make them have wall collision and stuff, so itl feel more softbodylike

#

but i didnt think abt how i can make the texture inside respond to movement

#

i havent got this figured out yet

#

if the player moves the points rotate clockwise or anti clockwise (right and left respectively), i want to make a fill that's mostly procedurally generated

#

so a texture wont work probably

#

mabey a gradient fill between each points

#

will i be able to generate a mesh to fill the inside of the polygon and use an uv

#

so i could to warping and stuff

hexed pecan
#

You can even generate a skinned mesh (mesh with bones), it could fit the usecase for softbodies

#

Skinned mesh would be good since you wouldn't have to regenerate the mesh every frame, just move the bones to warp it

flint swallow
#

idk how

hexed pecan
#

It's a bit more advanced though since you have to generate bone weights/bind poses

flint swallow
#

where can i learn

hexed pecan
#

It doesn't cover skinned meshes/bones though. That's more advanced stuff.

#

If you don't like reading then I don't have any video tutorials to suggest but they probably exist

flint swallow
#

so smth like this and i can apply an uv to it?

hybrid relic
flint swallow
#

ooh

hexed pecan
flint swallow
#

whats a slimey shader

hexed pecan
#

I didn't read the whole convo tbh

hybrid relic
#

a shader that makes the object look like slime

flint swallow
#

does it give like textureing and stuff

hybrid relic
#

a shader is something that changes the visuals

#

yes

flint swallow
#

i also want it to jiggle

hybrid relic
#

yep can all be done in shaders

#

sounds way less complex then your way of archiving it imo

flint swallow
#

but not affect other objects due to jiggling

hybrid relic
#

a shader doesnt affect anything

#

its just visual

flint swallow
#

where to learn shaders

#

feel like i should be in code-beginner rn

somber nacelle
hybrid relic
#

how are you always sniping my answers

scarlet viper
#

what if i first hit an object, then hit another? Will **OncollisionEnter **get called twice and **OnCollisionExit **not at all (if i still touch them) ?
Or is the method OncollisionEnter going to be called once, but will contain contacts for both objects that i collided with?

somber nacelle
#

OnCollisionEnter would be called twice there, yes. And OnCollisionExit will only be called if any of the pairs of objects colliding stop touching

hard viper
#

If one gameobject is involved in multiple collisions, then it will potentially get multiple calls on that frame.

#

Beware that collision calls are not invoked in any particular order

#

If mario collides with a super mushroom and a goomba in the same frame, and you detect by OnCollisionEnter, then you better make sure the same thing happens whether the mushroom or goomba collision gets called first.

static matrix
#

I was like "damn, its only 930? it feels like its been much longer"
then I realized its because I was not used to being this productive ๐Ÿ’€

plain spire
#

how can you create a custom character collider?

#

I'd like to try and make my own custom controller, without using unity's physics or anything

#

and I'd like to make it cylinder shaped, and not a capsule, but how would you detect collision?

leaden ice
leaden ice
#

You're better off using a kinematic Rigidbody and a Cylinder-shaped mesh collider

plain spire
#

raycast based, rather than collider based

leaden ice
plain spire
leaden ice
#

Custom collider shapes aren't possible

plain spire
#

it's not that important to me I just always wanted to try this out

leaden ice
#

aside from MeshColliders

plain spire
#

oh yeah I know, I just thought like

#

surely there's a method of raycasting that can allow custom shapes? idk

leaden ice
#

There is no custom shape casting other than SweepTest

plain spire
#

hmm alright

#

I'm mainly asking because I saw a tweet by a guy making a skating game

#

and his entire thing is ps1 styled so his character doesn't use rigidbody physics

#

the map is still made of colliders obviously but it doesn't like, use physics like that it's all raycast based

leaden ice
hazy basin
#

does anyone have template for a runner game like subaws surfer ?

plain spire
#

ah neat!

plain spire
leaden ice
#

but I don't see the issue with having a Rigidbody

#

just make it kinematic

plain spire
#

oh yeah but there's checkcapsule too fair

plain spire
leaden ice
plain spire
#

idk fun? try make a character controller without the colliders and stuff

plain spire
#

I am gonna download this and rip it apart and find how it works

hybrid relic
spring creek
hybrid relic
#

Arent they quite heavy in big amounts ? Especially in the amount you would need with a character controller

spring creek
#

You can use a LOT of them no problem
It's a common misconception that they are expensive though

lunar python
#

I am currently using Kinematics Rigidbody for all of my GameObjects and currently trying to set up my own physics sytem. I have recently read an article about Integration Basics which covers Semi-Implicit Euler, Explicit Euler, and RK4. Here's the implementation code: https://paste.ofcode.org/Mc7kMmw9gNLunsDNZDiMxS. I wonder which system would suit best a 2D top-down game. The article also mentions symplectic integrators but I still wonder which one is great. Can someone give me some recommendations?

junior pond
#

Hello! I'm working on this turret, and for the first few seconds the bullets move as expected. But then after a couple of seconds the bullets fly to the left side of the turret. How can I fix this?

tawny elkBOT
junior pond
knotty sun
#

I would suggest, looking at your code, that the problem lies with Lean Pool

#

Although maybe you dont want firePointL.rotation or firePointR.rotation but firePointLforward and firePointR.forward

junior pond
#

In LeanPool.Spawn?

knotty sun
#

I have no idea what LeanPool is but LeanPool.Despawn(this) looks odd to me

lunar python
#

Seems like an Object Pooling script

knotty sun
#

for all I know it could be a subscription to the local swimming pool, lack of information

lunar python
knotty sun
#

Well if it is object pooling why Spawn a gameobject and Despawn a script ?

lunar python
junior pond
#

It turns out that for the bullets I needed to use OnEnable instead of Start because of LeanPool

#

But thanks for helping out!

knotty sun
#

So I wasn't far off, not bad for a guess

ancient magnet
#

I just made an override of a super complicated script with a bunch of variables that I'd have to reassign, but unity won't let me copy and paste the values into the override, is there any way to fix this?

ancient magnet
knotty sun
#

sure, data is type specific i.e. is linked to the type of the class. in order to overcome this you need to write a custom editor to expose the underlying class to the editor rather than the inheriting class

static matrix
#

if i have Update in a class as well as in it's child class (both private) do they both run?

heady iris
#

No. The Update method from the actual runtime type will be executed.

static matrix
#

so the lowest public one I presume?

heady iris
#

If you want to run both, make the parent method virtual, override it in the child, and call base.Update(); in the child

heady iris
heady iris
static matrix
#

cool

heady iris
#

its Unity messages are protected and virtual

#

so child classes can override them

noble moth
#

Hello everybody! I am having issues building (for windows). The build is taking longer and longer each time, but more importantly: the first time the game loads, it seems multiple effects are disabled (post processing, volumetric fog, some materials). after reloading the scene in the game, it looks OK. I tried loading other scenes before and then my main scene, but it still looks wrong the first time. Does anyone has an idea about what could it be? (everything works fine in the editor)

hexed pecan
static matrix
#

cool

#
public void ShuffleClats(){
        foreach (var item in SpawnedClats)
        {
            if(item.GetComponent<Loot>()){
                item.GetComponent<Loot>().enabled = false;
            }
            var BasePos = item.transform.position;
            var RandOther = SpawnedClats[Random.Range(0, SpawnedClats.Count)];
            transform.position = RandOther.transform.position;
            RandOther.transform.position = BasePos;
        }
    }

I had hoped this code would shuffle around a bunch of objects, but that does not seem to be the case, I get a result like this (note the stacking)
any idea why?

#

(ignore the loot disabler that is not important to the rest of the function)

#

noooo wait something isn't working right
its not disabling the loot script and I can't collide with them anymore

hexed pecan
leaden ice
static matrix
#

im so dumb

leaden ice
#

Also better way to write that Loot thing:

            if(item.TryGetComponent(out Loot loot)){
                loot.enabled = false;
            }```
#

instead of GetComponent twice

hexed pecan
#

Small tip, you can replace the double GetComponent with ```cs
if(item.TryGetComponent(out Loot loot))

goddamnit praetor
static matrix
hexed pecan
#

Or even have the list as List<Loot> if possible

#

If it doesn't always have a Loot component then no

static matrix
#

does not always have a loot component

#

also I use SpawnedClats in a lot of other places so changing the type would mess up things

hexed pecan
#

What's a clat?

#

I know it's jamaican for cloth

static matrix
#

uh
ok so
you know school gyms

#

they have those little like
smol cones?
im calling those clats bcause y not

#

these things

hexed pecan
#

Ah those

static matrix
#

(except these ones animate and swarm you but potato potahto)

#

I wanted to shuffle them so the one that detects you/is shootable is not the same for each iteration

heady iris
#

oh, those doohickeys

static matrix
#

these frikin guys are as buggy to all hell
sometimes they do damage you, sometimes they dont. Sometimes they grab you correctly, sometimes they dont. Sometimes the hand moves right, other times it gets stuck
its infuriating
i'll fix em later tho

dark atlas
#

I have a question. In Unity, how do I swap a Skinned Mesh Renderer with another mesh thats in an already loaded asset bundle? I was told to use this __instance.gameObject.GetComponent<SkinnedMeshRenderer>().sharedMesh However I don't know exactly how to specify the mesh from the asset bundle when using this.

#

I have confirmed that the asset bundle I am using already is loading properly.

static matrix
#

ugh the collider just sometimes does not work

#

idk why

hexed pecan
static matrix
#

Im fine if it passes thru things just preferably it would detect when it ran into something with OnTriggerStay or OnCollisionStay (2D)
moving it with changing transform
ill finnik with a couple things first hmm

heady iris
#

add a kinematic rigidbody and move that.

spring flame
#

can I depend on an asset inside Resources/ directory, so that when it updates, the dependent scripts also update?

heady iris
#

I don't know what that means.

#

"The dependent scripts also update"

#

Are you trying to make a "manager" object that runs methods on a bunch of other objects?

spring flame
#

I am in a process of writing a package, and it depends on some shader partials (.hlsl files) that are later #included in a shader, but this shader is generated by a custom asset. I want it to behave in such a way, that when the included .hlsl file changes, it takes effect in unity, so possibly notify the shader-generating asset that the include changed, so the final shader has to recompile

heady iris
#

ah, okay, you're talking about shader compilation

knotty sun
#

do you know what a reference is?

spring flame
#

I am trying to write a custom asset (or something) that generates a shader source. This is an editor utility btw

spring flame
heady iris
#

I thought Tooster was talking about something happening at runtime with component instances. That is not the case.

knotty sun
#

no, just in general, because it sounds like you think when you reference something it makes an actual copy

heady iris
#

I'm not familiar with how Unity deals with changes in #include'd shader files

spring flame
knotty sun
spring flame
knotty sun
#

if in doubt write your own AssetPostProessor to handle dependencies

spring flame
#

idk If i'm not in the XY problem territory, because for now I have a "common shader include file.hlsl" inside a "Package/Editor/Resources", and I just didn't see any change when I updated the .hlsl file that the final shader recompiled or updated (and the method for generating final shader returns a fixed string right now that simply imports this include)

spring flame
knotty sun
#

AssetPostProcessor is actually pretty simple

static matrix
#

hmmmm
I wonder what is causing this

#

wait does that store all the debug.logs or warns?

knotty sun
#

yes, of course, it's a log

static matrix
#

I didn't know that it was saving those anywhere

#

oops

cyan roost
#

I need help for some wheel colider that doesnt wana move

deft timber
#

Cool

eager steppe
#

Hey all, just some quick math things, if I'm trying to calculate the length of an Image via the length of a song, and it's BPM, how would I do that? I know it has something to do with speed = distance / time but I suck with game engine math and honestly couldn't think of any better math to use here

#

Here's the same timeline from a few days ago, I just need this to explain the other metric I have

leaden ice
eager steppe
eager steppe
# eager steppe

Like, I have a line running through the entirety of the timeline, which just shows the current position of the song, like how Unity Animation Panel works?

#

I'm not sure how to incorporate in into a formula to use though

leaden ice
#

How are they related?
Wouldn't the image size itself always be the same?

#

It's more a question of positioning objects (notes) along the line

eager steppe
leaden ice
#

yeah isn't that always going to be the same length?

eager steppe
#

unless I'm going about this the wrong way

leaden ice
#

It depends how you want to do it

#

like is this going to be scrollable?

eager steppe
#

Yeah, essentially

leaden ice
#

there are many ways to do this

eager steppe
#

It's scrollable and has objects that are dotted along the timeline, depends where the user wants to place events dwon.

leaden ice
#

I don't think BPM has anything to do with this particular calculation. It's basically just totalSongDurationInSeconds * pixelsPerSongSecond

eager steppe
#

hm.. alright

#

I'll try this, thanks

smoky atlas
#

I'm having a really hard time working with Elevenlabs. It's 50/50 when the files are playable.
I have a good file and a bad file I have saved.

From the bad file I get this error: Error: Cannot create FMOD::Sound instance for clip "" (FMOD error: Error loading file. )
The good file plays without any issues.

Both files play in external players, ran both files through file analysis and all the metadata looks correct.
I'm not sure what to do at this point.

UnityWebRequest req = UnityWebRequestMultimedia.GetAudioClip("file://the path".Replace(" ", "%20"), AudioType.MPEG);
req.SendWebRequest();

    var clip = DownloadHandlerAudioClip.GetContent(req);
    if (clip.length == 0)
    {
        Debug.LogError("bad file failed");
    }
zinc parrot
#

so I use async tasks to use multithreading, but I forgot how I used to effectively deep profile specific parts in the async task functions. Whats the proper way to profile these on the CPU?
I have also been having difficulty with finding info on this for specifically async tasks, as I often get a bunch of less than useful stuff not actually relating to tasks themselves

knotty sun
smoky atlas
knotty sun
#

can you not chose the codec to use for the recording?

smoky atlas
#

I wasn't not sure the default, maybe something with they. I do have these options:

#

PCM_24000 looks like the default

tawny mountain
#

Does anyone know if I can Center my line reneder on a navmesh surface?
the rainbow line is what gets generated , the black line would be what im trying to achieve , the clean corners

knotty sun
#

MP3-44100-x (probably 128) would be more common

lean sail
tawny mountain
#

thankyou

knotty sun
#

!code

tawny elkBOT
undone prism
#

yeah srry iknow

knotty sun
#

rotation is a Quaternion, you are treating it as an Euler

smoky atlas
tawny mountain
undone prism
knotty sun
#

this
Mathf.Clamp(cam.transform.rotation.x
is never gonna work because .x is a Quat value

quartz folio
#

Really shouldn't be trying to clamp values read from a transform's Euler rotation either. You should track and clamp your own values that are then applied to the transform

#

Or, better yet, use Cinemachine and don't write your own camera controller

lean sail
half sphinx
#

hi, im making a room spawn system that spawns a series of rooms in a random order, the way i have it done is for each room theres an empty game object (or more) called room connectors. these spawn other rooms at their position and rotation. the problem is that some rooms have room connectors on all sides, and sometimes (most of the times) some rooms end up clipping through eachother. heres a pic and the code. if theres a way to do it without a grid system then that would be amazing, this is what ive been trying but i cant get it to work. if anyone has any idea why please tell.
https://pastebin.com/GiGX91Cs

hexed pecan
#

Or even Rect.Overlaps if you convert the XZ coordinates into 2D rects (and the rooms are never rotated)

#

Or Bounds.Intersects if you need verticality

regal oak
#

Hello! I want to make a game with PCG platforms. The 'routes' will be created out of chunks of platforms/blocks(4 types to be exact for now) and they all square. By chunks I mean there will be different widths and lengths to them and they will have a route(doesn't have to be straight for or fully filled with max width of blocks and length.
Anyways, does anyone have an Idea how and where can I find algorithms for these kind of PCG?

half sphinx
#

i linked the code

hexed pecan
#

Checking the rotation with == seems a bit sketchy. Not sure if that is reliable

#

This etc. roomConnPos.rotation==Quaternion.Euler(0,-90,0)

#

Looks like you have the "edge case" log which would inform you if anything went wrong. Does that ever log?

half sphinx
#

nop

half sphinx
hexed pecan
#

Not sure, I would personally probably store it in a simple variable like a float (y angle) or an enum

#

The way you are doing it might be fine though.

#

One thing that comes to mind is that you might have to call Physics.SyncTransforms after spawning a room

half sphinx
#

oh, ill try that

hexed pecan
#

I also suggest that you confirm that your OverlapBox is correct

#

With Gizmos.DrawCube or something like that

half sphinx
#

yeah thats what i was gonna ask

#

how to do that

#

cuz ive been spawning an empty game obj with a box collider and applying the scale snd position manually

hexed pecan
#

OnDrawGizmos, loop your connections and use the same values for Gizmos.DrawCube

#

Or Gizmos.DrawWireCube

half sphinx
#

okay

hexed pecan
#

Actually it's a bit more complex if your boxes are rotated

#

Are they?

half sphinx
#

yes

hexed pecan
#

I don't see you taking rotation into account in your overlapbox

#

That might actually be the reason

half sphinx
#

they spawn with the rotation of the room connection

#

really?

hexed pecan
#

Yeah your OverlapBox is using a zero rotation by default

#

Try giving it roomConnPos.rotation

#

The center needs to be rotated too.

half sphinx
#

how do i do that

hexed pecan
#

You currently have this as center:cs new Vector3(roomConnPos.position.x, roomConnPos.position.y, roomConnPos.position.z+roomDimensionsHalf[i].z*2)
You should do something like:cs roomConnPos.position + roomConnRot * new Vector3(0, 0, roomDimensionsHalf[i].z * 2f)

#

If I understand your code correctly

half sphinx
#

lemme try

hexed pecan
#

roomConnRot * rotates the vector after it

smoky atlas
#

@knotty sun ended up switching to google's speech to text away from elevenlabs, issue resolved.

hexed pecan
#

You can rotate a vector by multiplying it with a quaternion

hexed pecan
half sphinx
#

yeah i added that too in the code

hexed pecan
#

You have those if-statements just for different rotations, right?

#

I think you can just get rid of them

#

And use one OverlapBox that takes rotation into account

half sphinx
#

nothing changed tho, for some context, the scene has a room that has 3 connections, only one room spawns and the console spams cube like 5 times

half sphinx
hexed pecan
#

Try to set up the Gizmos next

#

@half sphinx When doing procedural stuff, visualization is important so you know what is actually happening

half sphinx
half sphinx
hexed pecan
#

The one you are connecting to/from

half sphinx
#

yeah thats why i multiply it by 3.9 instead of 4

#

just to make sure

hexed pecan
#

Alright

half sphinx
#

4 should be a perfect fit tho

hexed pecan
#

I would use 4 and then loop the colliders that OverlapBox returns

#

Only return true if they aren't the parent room's collider

#

Alternatively you can disable the parent collider first, then do the check, then re-enable it

half sphinx
#

yeah

#

but for now

#

ill get to the point where rooms spawn and then worry abt that

#

also, how exactly should i draw the box, ondrawgizmos cant take any inputs

#

wait no

#

nvm

hexed pecan
#

Oh yeah since you have rotation, you need to use Gizmos.matrix

half sphinx
#

i was just abt to ask that

hexed pecan
#
Gizmos.matrix = Matrix4x4.TRS(pos, rot, Vector3.one);
Gizmos.DrawCube(Vector3.zero, roomScale)```
half sphinx
#
        Gizmos.matrix = Matrix4x4.TRS(roomConnPos.position + roomConnPos.rotation * new Vector3(0, 0, roomDimensionsHalf[i].z * 2f),roomConnPos.rotation, roomDimensionsHalf[i]*3.9f);``` this right?
hexed pecan
#

I edited a bit, maybe easier to set matrix scale to Vector3.one and then draw the cube with the actual scale

#

Note that DrawCube wants full size, not half size

#

And it needs to be in OnDrawGizmos (or OnDrawGizmosSelected)

half sphinx
#

so gizmoz.matrix can be anywhere

#

right

hexed pecan
#

Yeah, think of it like making the gizmos a child of something

#

After that, everything will be drawn relative to the matrix you gave it

#

So Vector3.zero as position will actually be the room position you put in the matrix

half sphinx
hexed pecan
#

Show the code you used for that

half sphinx
#

i think the gizmo is correct

#

hopefully

hexed pecan
#

The matrix should be set in ondrawgizmos instead

#

Before you draw

half sphinx
#

yeah but how do i pass roomConnPos to it

hexed pecan
#

Do a foreach loop for the connections

half sphinx
#

ok

hexed pecan
#

And set the matrix again every iteration

rain bear
#

Hi, I'm new to this server. I have a question to ask, should I wait until your conversation is over or can I just throw it out there?

hexed pecan
half sphinx
#
    {
        if(started)
        {
            foreach(Transform roomConnPos in roomConncections)
            {
                Gizmos.matrix = Matrix4x4.TRS(roomConnPos.position + roomConnPos.rotation * new Vector3(0, 0, roomDimensionsHalf[i].z * 2f),roomConnPos.rotation,Vector3.one);
            } 
            Gizmos.DrawCube(Vector3.zero, roomDimensionsHalf[1]*2);
        }
    }```
#

this should work right

hexed pecan
#

Other than that, it looks ok to me

rain bear
#

Thanks! My issue is with my background animated graphic rendering above my UI text. The background graphic is an empty object containing a LineRenderer script that generates a wave (sine curve). However it obscures my UI text. I used separate Sorting Layers to try to fix it, with the UI sorting layer being above the Background sorting layer - to no avail! Should I post some screen shots?

half sphinx
#

prob the positioning is off now

hexed pecan
#

Also do the * 3.9f multiplication in Gizmos too. Currently you only have * 2. It should be * 2 * 3.9, or whatever is double of the scale you use in the other method

hexed pecan
#

Just wondering if it's world space TextMeshPro

#

Or maybe your canvas is in world space

rain bear
#

It is Text Mesh Pro, I'm using the asset Doozy UI Manager to create all my UI elements. It's a title of Text Mesh Pro inside a View, inside my Canvas which is set to my UI sorting layer.

#

The UI sorting layer is layer 2, and the Background sorting layer is layer 3, so it should be behind.

#

Let me check for World Space, that may be the issue.

#

The Canvas is set to Screen Space - Camera.

#

I don't see anything on the LineRenderer object showing world space or screen space.

half sphinx
hexed pecan
#

Since you can see what's going on

#

I hope the gizmos are correct, I'm pretty sure they are

rain bear
#

Actually, there is a checkbox on the LineRenderer that says Use World Space, and that's checked.

rain bear
#

Unchecking it didn't make any difference.

hexed pecan
#

I was asking about TextMeshPro because there are two types, one for UI and one for world space UI

#

And AFAIK a linerenderer should always render behind normal UI (which is what you want, right?)

#

Might depend on the material on it, though.

rain bear
#

Yes, I want the line renderer to render behind UI

#

The pink curve should be behind the UI text.

#

How do I check which type of TextMeshPro I'm using?

#

I'm happy to change the material on anything if it helps.

hexed pecan
rain bear
#

This is the Title that renders behind the LineRenderer

hexed pecan
#

Yeah that's the UI version which is fine. I don't know, could be something related to the asset you mentioned. Ask in #๐Ÿ“ฒโ”ƒui-ux instead, this is a code channel anyway ๐Ÿ˜„

rain bear
#

This is my Hierarchy, the Wave01 object at the bottom is the LineRenderer that makes the curve.

hexed pecan
#

Hmm so the linerenderer is a child of the canvas?

rain bear
#

Ok, thanks!

#

No, it's outside of the Canvas.

#

I tried putting it inside the View and it didn't make any difference.

#

Everything from EventSystem down is outside of the Canvas.

hexed pecan
#

Ah yeah, I was just looking at it crooked

rain bear
#

Okay, thanks for your time.

half sphinx
#

but if that still doesn't work and i give up on physics.overlap, are there any other options

swift falcon
#

Is there a way to pull a vector2 and tell what direction that character is moving? I am trying to set up an animation to change from left to right and the character moves on the following code:

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

[RequireComponent(typeof(Rigidbody2D))]

public class Movement : MonoBehaviour
{
    public float speed = 8.0f;
    public float speedMultiplier = 1.0f;
    public Vector2 initialDirection;
    public LayerMask obstacle;

    public Rigidbody2D rigidbody{get; private set;}

    public Vector2 direction {get; private set;}
    public Vector2 nextDirection {get; private set;}
    public Vector3 startingPosition {get; private set;}

    private void Awake()
    {
        this.rigidbody = GetComponent<Rigidbody2D>();
        this.startingPosition = this.transform.position;
    }

    private void Start()
    {
        ResetState();
    }

    public void ResetState()
    {
        this.speedMultiplier = 1.0f;
        this.direction =  this.initialDirection;
        this.transform.position = this.startingPosition;
        this.rigidbody.isKinematic = false;
        this.enabled = true;
    }

    private void Update()
    {
        if (this.nextDirection != Vector2.zero) 
        {
            SetDirection(this.nextDirection);
        }            
    }

    private void FixedUpdate()
    {
        Vector2 position = this.rigidbody.position;
        Vector2 translation = this.direction * this.speed * this.speedMultiplier * Time.fixedDeltaTime;
        this.rigidbody.MovePosition(position +  translation);
    }

    public void SetDirection(Vector2 direction, bool forced = false)
    {
        if (forced || !Occupied(direction))
        {
            this.direction = direction;
            this.nextDirection = Vector2.zero;
        }
        else
        {
            this.nextDirection = direction;
        }
    }

    public bool Occupied(Vector2 direction)
    {
        RaycastHit2D hit = Physics2D.BoxCast(this.transform.position, Vector2.one * 0.75f, 0.0f, direction, 1.5f, this.obstacle);
        return hit.collider != null;
    }
}
#

I want to make a new piece of code and just get the vector in order to set the animation each time the direction swaps from left to right but trying to print the Vector2 value in a debug log didn't enlighten me as to how best to do that.

zenith estuary
#

le epic

cosmic rain
quartz folio
#

Type normally. This title-case stuff is obnoxious and unreadable.

untold hemlock
#

So I have a game where you can shrink and grow. The scale is set via a script. You can also spawn props like a crate and chair. But when you spawn props that are a different size the contact offset in unity by default does not change. I tried changing the collider offset still no change. This causes OnCollisionEnter to fire way to early ruining the effect of a sound when it hits the ground. When the prop is small the radius is too big, when the prop is big the radius is too small. I am using Unity version 2021.3.26, my colliders are mesh colliders that are convex and I am changing the values by an array of colliders (private Collider[] colliders).

cosmic rain
untold hemlock
cosmic rain
#

*to your issue

untold hemlock
# cosmic rain I'm not sure how that setting is relevant to anything..?

It's basically when the collider point is less than the distance. It calls stuff like OnCollisionEnter. And I use that to make a sound when the object collides with the ground. But when the object is small it does not change causing the collision to detect to early. I tried setting the colliders contact offset via script and it did nothing.

cosmic rain
#

Why would your colliders be smaller than .01 units..?

#

I'm sure that's gonna break more things than just the collision events.

#

And if not, it should really make any difference at all. .01 is a very small distance.

eager cliff
#
void Start()
    {
        dropdown.ClearOptions();
        List<TMP_Dropdown.OptionData> dropdownOptions = new List<TMP_Dropdown.OptionData>();

        dropdownOptions.Add(new TMP_Dropdown.OptionData("")); 

        foreach (ItemEffect itemEffect in itemEffects)
        {
            dropdownOptions.Add(new TMP_Dropdown.OptionData(itemEffect.name));
        }

        dropdown.options = dropdownOptions;

        dropdown.onValueChanged.AddListener(delegate { ApplyitemEffect(dropdown); });
        dropdown.value = 0;
        dropdown.RefreshShownValue();
    }

Hi, I cant see my dropdown text after update to unity 2022.3.16f1. The text can only show when the dropdown option is selected. How to solve it?

#

before selected

#

after select

rocky kite
#

can i ask about visual studio stuff here?

celest musk
#

hello, im looking for some help with my game to get my enemy to move and attack the player if someone can help me that would be great

cosmic rain
swift falcon
# cosmic rain What vector safe you talking about? Where do you debug it?

I had attached a debug log just to get the direction for that specific character and print it but I think I did so incorrectly. I'm not really the programmer, I'm just supposed to implementing animations here. The vector I though I could use was the one named "direction". Sorry for slow reply, got busy with other stuff.

cosmic rain
eager cliff
celest musk
cosmic rain
swift falcon
cosmic rain
swift falcon
#

Got it, thank you.

runic nimbus
#

How would I get this kind of behaviour without parenting?
Where it follows the point, at an offset. It also rotates with that point, keeping that offset.

#
[RequireComponent(typeof(Rigidbody))]
public class GrabInteractable : MonoBehaviour, IInteractable {
    private Pose grabbedPose;
    private Rigidbody rb;

    private void Awake() {
        rb = GetComponent<Rigidbody>();
    }

    public void OnPicked(Hand hand) {
        grabbedPose = new(hand.transform.position - transform.position, hand.transform.rotation * Quaternion.Inverse(transform.rotation))
        rb.isKinematic = true;
    }

    public void OnHeld(Hand hand) {
            transform.position = hand.transform.position - grabbedPose.position;
    }

    public void OnDropped(Hand hand) {
        rb.isKinematic = false;
    }

I already have the position part working
but the rotation has me stumped

white crater
#

Hey guys ๐Ÿ‘‹ im trying to add ground detection through raycast but my current logic uses on collision. i am for some reason having trouble separating grounded logic from on collision.

#
private void OnCollisionStay(Collision other)
{
    // Make sure we are only checking for walkable layers
    int layer = other.gameObject.layer;

    if ((int)whatIsGround != ((int)whatIsGround | (1 << layer)))
    {
        // If the collision is not with a walkable layer, exit the method
        return;
    }
    
    for (int i = 0; i < other.contactCount; i++)
    {
        Vector3 normal = other.contacts[i].normal;

        // Check if the collision is with a floor
        if (IsFloor(normal))
        {
            // If wall running was active, disable it
            if (wallRunning)
            {
                wallRunning = false;
            }
            grounded = true;
            normalVector = normal;
            cancellingGrounded = false;
            CancelInvoke("StopGrounded");
        }

        // Check if the collision is with a wall and on the Ground layer
        if (IsWall(normal) && layer == LayerMask.NameToLayer("Ground"))
        {
            // Start wall running
            StartWallRun(normal);
            onWall = true;
            cancellingWall = false;
            CancelInvoke("StopWall");
        }

        // Check if the collision is with a surfable surface
        if (IsSurf(normal))
        {
            surfing = true;
            cancellingSurf = false;
            CancelInvoke("StopSurf");
        }

        // Check if the collision is with a ceiling
        IsRoof(normal);
    }

    float num = 3f;

    // Schedule methods to stop grounded, wall run, and surf after a delay
    if (!cancellingGrounded)
    {
        cancellingGrounded = true;
        Invoke("StopGrounded", Time.deltaTime * num);
    }
    if (!cancellingWall)
    {
        cancellingWall = true;
        Invoke("StopWall", Time.deltaTime * num);
    }
    if (!cancellingSurf)
    {
        cancellingSurf = true;
        Invoke("StopSurf", Time.deltaTime * num);
    }
}
soft shard
# white crater Hey guys ๐Ÿ‘‹ im trying to add ground detection through raycast but my current log...

Looks like you have a lot of different logic happening there (grounded, wall stuff, surfing stuff), I would try to move each of those into their own functions, if youd rather use a raycast instead of a collision check, often youd do those ray checks frequently, such as in Update or FixedUpdate, and in the Physics class, some raycast calls return a bool if it hit anything, if performance is a concern, you can also use non-alloc versions which return a number of hits instead of if anything was hit - see the "Static Methods" section: https://docs.unity3d.com/ScriptReference/Physics.html

For example, a typical setup might look like this:

bool isGrounded;

void Update()
{
GroundCheck();
}

void GroundCheck()
{
isGrounded = Physics.Raycast(...);
if (isGrounded) { DoGroundStuff(); }
}

You could even use another bool to track when "isGrounded" and the other bool differ, set them to the same value, then fire an event if you want to do logic on the frame that the player becomes grounded, not sure if that helps - one other note about .Raycast, is it is a single line in a direction, so cases like literally standing on edges or slopes may cause strange results depending on the origin of the cast, for those cases there is also things like .SphereCast or .BoxCast, depending on the accuracy you need, sadly visualizing the cast is a bit tricky, as youd either need to use OnDrawGizmos or Vertxyz's debugger package for anything that is not a simple ray, for that you can use Debug.DrawRay or Debug.DrawLine, which may be useful for Physics.Linecast - also, something that may help, if you prefer, you can assign layers through the inspector with a LayerMask type

runic nimbus
#

Doesn't look all that crazy when you can see the whole method without scrolling. New line brackets bloat up code and make it less readable.

soft shard
# runic nimbus What terrible advice. Yeah turn the script into a maze of one use methods. I can...

Im not sure I understand your concern? It sounded like OP wanted to change from using OnCollisionStay to using raycasts, and it looks like his current logic has several different things beyond just a ground check happening, which can be confusing, my suggestion is to put those into functions so its easier to manage, im not sure how that is a bad thing? I may be misunderstanding what your concern is, but it seems like you are just concerned about the bracket formatting in the example provided? Im not sure I get whats "terrible" about this, could you elaborate?

runic nimbus
#

I don't agree with the idea of creating methods that are only used in one place. If you're gonna do that, you're essentially naming the code. Thats what comments are for.

void Update() { // Terrible
  Shit();
  Piss();
}```
#

Instead, because I do agree the script looks messy, you can apply some basic formatting to make the script a lot shorter than it was. Then it looks much more digestable without those one-use methods everywhere.

lean sail
lunar python
#

readability and maintainability

runic nimbus
#

yeah and I disagree

runic nimbus
lean sail
#

๐Ÿคทโ€โ™‚๏ธ you can disagree but its whats commonly done in professional environments

runic nimbus
#

Professional code sucks ass. Have you ever looked at Unity's scripts?

#

Photon's scripts? Any large professional library's scripts?

#

They're horrible beyond comprehension.

lean sail
#

i dont get your point, you'd rather all the code in one giant block? Thats your preference, do what you want in your own projects. you'll not get far in professional environments

#

this is just a matter of you not wanting to write it in a nice way

rigid island
runic nimbus
lean sail
runic nimbus
lean sail
#

yes, so a junior

runic nimbus
#

Not a newbie though. I've finished several projects and come to that conclusion.

lean sail
rigid island
lean sail
#

goodluck in the real world with your mentality

runic nimbus
#

In no world is the one on the right more readble, "nicer", or more maintainable

#

You're just naming the code and making it longer.

lean sail
#

and why is making it longer an issue

soft shard
#

Typically, code would follow "S.O.L.I.D", I dont personally believe that comments should be used to organize or describe code, unless it actually adds value (such as explaining a math formula being used) - if I have a character controller, I would rather have a function for each part of my code, a function for input polling, a function for ground checks, a function for movement, jumping, abilities, etc, (or possibly states) rather than everything in Update organized by comments (which is the S of solid, single responsibility), I guess in a way thats "naming code" but you can also have your entire project on a single line of code in 1 script, itll just be impossible to debug or add features to, but it may come down to preference in code style

runic nimbus
#

You should always strive to make your code as short as possible so long as it doesn't impede readability

lean sail
#

"takes more space" yea i dont wanna entertain this anymore.

rigid island
#

says random dude with 3 years exp vs those with many years in industry

rigid island
#

you're wacked out

runic nimbus
rigid island
#

thats the stupidest point i've heard in a while

runic nimbus
#

Works on my machine

lean sail
#

we're just being trolled at this point

rigid island
#

fr

#

someone makes these statements have to be trolling or have 0 clue what they're talking about, which goes well with former

runic nimbus
rigid island
#

less lines doesn't mean better or more legible code..

runic nimbus
#

Say what you guys want. The less your eyes have to move around the script the more readable it is. That's how it's always been in my experience. Short code is readable code.

rigid island
#

thats like saying driving a car with a binocular is better than your own two eyes because is less for your brain to process ๐Ÿค”

runic nimbus
#

Completely broken analogy

rigid island
#

you're talking about eye movement as your point

#

thats nonsense

runic nimbus
#

When trying to analyze a script it is simply easier to analyze less.

#

If the street was smaller, of course it's easier to drive.

rigid island
#

some people can't read well LINQ and thats less lines, what are you talking about

#

less doesn't always mean better

runic nimbus
#

Of course it doesn't always mean better

#

Nothing always means better

#

But in my expereince the shorter you can get a script down to, usually measured by lines, the easier it becomes to maintian because you are simply maintaining less.

#

Here's one of my scripts that handles weapon handling. Look at all of that well sectioned and "named" code that you don't need to jump around to find!

#

Ignore the fields

lean sail
#

consider that you said "comes down what you consider 1 thing to be" and then you said "handling jump, move, and turning in a character controller is all a good thing to bundle up in 1 method"

rigid island
#

messy

runic nimbus
#

yeah, that "1 thing" is basic player body controls

lean sail
#

ok and my 1 thing is just my game

#

do i put it all in 1 script?

runic nimbus
#

There's a hard limit because sometimes you actually need methods for their intended purpose, to reduce duplicate code. So no, at some point you would have to divide it into sections.

#

Classes too

lean sail
#

anyways your code really isnt readable either

runic nimbus
#

Aww

#

guess I'll go blind now

#

I love my code. That's probably my proudest script.

rigid island
#

so much to learn ๐Ÿฅน

runic nimbus
#

If I ever need to change something about recoil, I'll go to the big green line that says "Weapon Recoil" and change it

#

while you guys keep bickering about maintainability or something

#

"Go back to your code after 3 months and tell us if you understand anything" GDL said... those snobs.

soft shard
#

At this point I think this is "agree to disagree", we both have different philosophies for how we see code, I use functions to separate logic in my code instead of comments, I can see your view, I just disagree with it, it would be a hinderance to code that way for me, simply because of how I see "1 method" differently than you do, but thats because my brain prefers to see separation of logic rather than one big thing and ive adapted to scanning code that way, I look for a "recoil" function or class rather than a comment containing the words "recoil" in it - its also nice having the ability to comment or condition a function rather than several lines, but we may just not see code the same way

lunar python
#

shorter doesnt mean more maintainability

#

how do we even cope with this

runic nimbus
lunar python
#

I did competitive programming and we could do the entire program in a few lines with alphabetical variable naming. That is horrible for any team to work on.

#

idk if you have been in any coding team whatsoever

runic nimbus
#

Have not. Code golf goes far beyond the reasonable assumption of what I mean by "short code" though.

sage latch
#

Also a thing I noticed is that I also use implicit private modifiers and braces on the same line :D

sullen drift
#

i have a question, could you access a static varible from another script on another scene that havent be loaded?\

sage latch
#

Yes

west lotus
#

What no

lean sail
west lotus
#

If the scene is not loaded you aint accessing shit from it

sage latch
#

Static members always exist

sullen drift
#

okay, then it should be fine. Im transfering a list of data into a static list from another script in another scene. Just trying to make sure i could access it. Thank you then

lean sail
west lotus
#

My bad I jumped the gun here

sage latch
sullen drift
# lean sail whats the data? seems like an odd use case to need static here

Im creating a fishing minigame for an rpg game. Lets say there are many fish areas that have their own certain type of fish. I already have a list of fish in every areas accordingly, so every time the player click the fish area, those list will be transfered to the minigame script that has a static list variable to contain the previous fishes. Its for the reward ramdomizer

lean sail
#

Not really much different, but it'd basically protect you from a friend (or yourself in the future) from changing the public static list when its not meant to be changed, and then wondering why the whole minigame stopped working

sullen drift
#

yeah, actually ive been thinking to make a singleton, but lets say some architectures from my lead programmer doesnt want me to do that hahaha (i know its weird)

west lotus
#

If he doesnt want you using a singleton he will for sure not want you to use a unprotected static field in a class

lean sail
west lotus
#

Must one of the people who saw online โ€œSingleton Badโ€ and now just parrots this sentiment

sullen drift
lean sail
#

a different way would be have a game manager. This creates the minigame manager (whatever you wanna call it). Then you create fishing areas, pass the minigame manager to a script on the fishing areas. On click, do whatever you need

sage latch
#

Or make a scriptable object ๐Ÿ™ƒ

latent latch
#

singletons are a much cleaner architecture than most static alternatives since you can control its lifetime between scenes

merry stream
#

can anyone point me in the right direction to be able to save scriptable objects to json using newtonsoft

fervent coyote
#

Okay, so I'm using

AudioSourceObj.volume = 0.01f, and even through debugging proving it is set to 0.01, it STILL. IS. 1!!

Can someone please help me figure out why is is reverting to one?

latent latch
#

or is it readonly data

merry stream
#

i am writing to them, using them as an inventory

cold egret
#
  • I have a transform and a vector3 that represents a local position within the transform. What is the most efficient way to get a matrix4x4 that ocrresponds to that position?
fervent coyote
#

When I set the volume to 0 in script, it mutes it. It seems it can only be between 0 and 1

latent latch
merry stream
#

well doesnt the ID of the SO change so serializing that would be useless

#

you cant save references to SO's i thought

latent latch
#

if you're using SOs and creating variations using the asset context menu, then you're creating different variations of defaults of the script. If you were to keep track of these by ID, you can probably save yourself from serializing more data than you need to, but you still need to serialize all the data in which you write to. An example would be writing to a weapon SO, you'd write the damage values if you are to modify them, but it's not likely to modify the sprite, so you might as well just load it from the SO.

#

just depends how you're using them is the question, but if you're using SOs to write data to, I'd assume you have some specific set already when making copies of it

#

otherwise you'd just use plain ol' c# scripts

lean sail
latent latch
lean sail
half sphinx
#

it works now!

#

ty for helping me

#

400 rooms!

knotty sun
half sphinx
knotty sun
half sphinx
#

ohhh i see

knotty sun
#

but a damn good effort none the less

merry stream
#

how could I give a scriptable object a unique guid that is assigned once and can not be changed?

latent latch
#

unity assigns an asset ID to one, but you can just generate your own otherwise

soft shard
#

Whats your use case where a SO might need a unique ID? Why might you not be able to use the SO itself? Assuming you likely would have unique SO's to begin with (for example, you probably wouldnt have 2 of the same weapon), or are you trying to generate SO's of a certain type with a editor script or something similar?

latent latch
#

for saving and loading asset presets

soft shard
#

Wouldnt you still be able to use the SO itself?

latent latch
#

well, how would you write that to JSON and load from

#

you can either write by the path, or the easier way, an ID that's mapped to that path

soft shard
#

Ah I see, in that case if the SO is being saved to JSON or something that isnt an asset in the project, then I can see generating a guid for each SO

lyric panther
#

when i read transform.localrotation.x it goes from 0-360 but in the inspector and also while setting it via "transform.localrotation.x" it's diffrent. when looking up it reads 270 but in the inspector it's -90. how do i read what the inspector's seeing?

latent latch
# soft shard Ah I see, in that case if the SO is being saved to JSON or something that isnt a...

When you create an SO instance from the asset context menu, you're creating a copy which you can define different values to, though it's not a different type. This makes serializing by type not the solution if that's what you're thinking of, but assuming you do want to write to the SOs and serialize all its data, then yes you can probably do that.

Though, the idea of IDing the SOs is that you're not always overwriting (personally I never write to SOs) the data in the SO, so why serialize data when you can just make a lookup for your SOs and load it from there?

#

Similarly to prefabs, you wouldn't serialize prefabs completely, you'd have a manager that handles the construction of these assets which is defined by IDs.

lean sail
lyric panther
#

so if i just read localrotation.x it'll show what it says in the inspector?

lean sail
#

No because it is a quaternion

lean sail
#

If you can work purely with quaternion it is better so you dont need to have your own local euler system going on

soft shard
# latent latch When you create an SO instance from the asset context menu, you're creating a co...

Right, I usually use SO's as "blueprints" so for example I might have a SO that creates weapons, but id likely not have 2 "glock 18"s, even if I have 2 "pistolSO", I can see if your trying to save a serialized class inside the SO to file file to load into a SO instance (weather you save that back as an asset or just use it at runtime) make sense, otherwise if the SO is already in your project assets, I agree having a lookup of some sort makes sense but I cant see a reason to save the SO in a different form/JSON/etc outside the project, maybe I misunderstood something there

lyric panther
#

I have a value that sets the x euler angle, when that value is -90 the camera looks up, but when i read the localrotation euler angles it's 270, I just need to read the localrotation so i can get that same measrement

latent latch
#

unless you're writing all data from that SO type then deserializing it as a pistolSO then there wouldn't be ambiguity, but then you're required to update the whole base SO with those values

lean sail
lyric panther
#

you really didn't

lean sail
#

I did, if you didnt understand something then you can ask me to clarify. But reposting the question really isnt gonna get you a different answer

lyric panther
#

I thought i clarified enough

#

i've found the answer, it was this

lean sail
#

I have a feeling like you arent properly reading my messages. I said you can ask me to clarify

lyric panther
#

sorry it's really late and i've been coding all day

#

I applogise for being snarking

#

snarky

lean sail
#

Anyways that alone is not a solution to the real issue at hand, I dont even think quaternion will return an euler value greater than 360

lyric panther
#

that solution works for my use cases tho

#

the rotation is clamped from -90 to 90

#

it's a fps camera thing

lean sail
lyric panther
#

I'm manually rotating the camera in another script, so when i finish rotating it i need to know what i need to set the variable that's moving the camera in the fps controller

lean sail
#

Though if it works then ๐Ÿคทโ€โ™‚๏ธ carry on. I feel like there are edge cases where this might not work but I am too tired to think of an example right now

lyric panther
#

if there are edge cases, i'll cross that bridge when it comes to it

soft shard
# latent latch unless you're writing all data from that SO type then deserializing it as a pist...

Maybe it depends on how the SO is used, I often use them like this:

[CreateAssetMenu(...)]
public class SomeSO : ScriptableObject
{
public SomeData data;
}

[System.Serializable]
public class SomeData
{
//pistol data, damage, ammo, etc...
}

For myself, I would be saving SomeData to JSON, and loading that into a SomeSO instance if I needed it, I personally have not tried saving the entire SO itself, though SomeSO in this case would be the "PistolSO" or "WeaponSO", etc

lean sail
lyric panther
#

I'm not manually setting it in the inspector I'm manually setting it via "transform.localrotation = quaternion.eulerangles()"

latent latch
lean sail
frosty snow
#
        Debug.Log("found UI");
        {
            UnityEngine.UIElements.Button button1 = new();
            Debug.Log("create button 1");
            button1.clicked += () => button1.text = "CLICKED";
            Debug.Log("add clicked to button 1");
            ui.rootVisualElement.Add(button1);
            Debug.Log("add button 1 to ui");
        }
        {
            UnityEngine.UIElements.Button button1 = new();
            Debug.Log("create button 2");
            button1.clicked += () => button1.text = "CLICKED";
            Debug.Log("add clicked to button 2");
            ui.rootVisualElement.Add(button1);
            Debug.Log("add button 2 to ui");
        }
        Debug.Log("return");
[ now : 20:38:6:535] [ since last : 0:0:0:6 ] found UI
[ now : 20:38:6:551] [ since last : 0:0:0:16 ] create button 1
[ now : 20:38:6:552] [ since last : 0:0:0:1 ] add clicked to button 1
[ now : 20:38:6:554] [ since last : 0:0:0:2 ] add button 1 to ui
[ now : 20:38:6:555] [ since last : 0:0:0:1 ] create button 2
[ now : 20:38:6:557] [ since last : 0:0:0:1 ] add clicked to button 2
[ now : 20:38:6:558] [ since last : 0:0:0:1 ] add button 2 to ui
[ now : 20:38:6:559] [ since last : 0:0:0:1 ] return
[ now : 20:38:6:559] [ since last : 0:0:0:0 ] invoked queue action
lyric panther
#

Quaternions are on too high a level for my understanding lol, I'll just use Euler's in the meantime

frosty snow
#

what parts of this can be executed on a background thread ?

#

eg, gameObject property must be called on the main thread, but what else must be called on the main thread ?

cosmic rain
#

And even if it could, you probably shouldn't.

frosty snow
#

why

#

i want to try to avoid getting stutters on the main thread when instantiating my ui

fervent furnace
#

anthing that not interact with scene

#

eg Debug.Log

cosmic rain
#
  1. There's no reason to.
  2. You don't wanna mess with threads too much.
  3. Overhead?
frosty snow
#

eg, can i build UI components in the background and then attach them to my scene on the main thread ?

cosmic rain
frosty snow
#

Debug.Log does work in any thread

cosmic rain
#

Hmm... Must be fake memories then.

frosty snow
#

eg

        RunOnBackground(() => {
            // build UI in background
            UnityEngine.UIElements.Button button1 = new();
            UnityEngine.UIElements.Button button2 = new();
            button1.clicked += () => button1.text = "CLICKED";
            button2.clicked += () => button2.text = "CLICKED";
            RunOnMain(() => {
                // attach UI in foreground
                ui.rootVisualElement.Add(button1);
                ui.rootVisualElement.Add(button2);
            });
        });
cosmic rain
#

I wouldn't be surprised if it's not possible, but you can try and see ๐Ÿคทโ€โ™‚๏ธ

fervent furnace
#

i doubt when you new a uielement you are interacting with the scene

#

Btw check if some calls are interacting with the scene not a strict test to indicate if the call can be called in background

quartz folio
#

As with anything Unity, it matters whether the implementation is interacting with the engine in a way that isn't thread-safe, which is a lot of the native APIs. Luckily UITK is implemented a lot more in managed land... But not all of it. So might have mixed results, and due to a lot being event based, it could trigger different things with minor changes

#

The answer is try it and see, and the longer answer is, even if it does work it doesn't sound robust to change

upper pilot
#

How do I find x,y position of a top/center sprite?

#

I am trying to use bounds, but I can't figure this out.

scarlet viper
#

guys i cant do Input.GetAxis in non-monobehaviour scripts ?

upper pilot
#
        Vector3 spriteTopPosition = CharacterSprite.bounds.center - CharacterSprite.bounds.extents;
        //Vector2 newPos = Camera.main.WorldToScreenPoint(CharacterSprite.transform.position - spriteTopPosition);
        Vector2 newPos = spriteTopPosition;
        selectorInstance.transform.position = newPos;
scarlet viper
#

its highlighted as error

latent latch
#

well, what does the error say

#

if it says define it with UnityEngine, do that

scarlet viper
#

Nvm had to add UnityEngine.

#

No the problem was that

#

it didnt tell me what was wrong

#

I mean it did

#

but not very obvious

latent latch
#

sometimes the IDE will give you hints

scarlet viper
#

depends on IDE i guess

#

or extensions

#

i use VSC coz it feels faster and less packed than VS

#

and its free unlike Rider or however it was named

latent latch
#

oh I see, yeah probably not as much help as vs

frosty snow
#
    public class ThreadRunner {
        ConcurrentQueue<Action> currentFrame = new();
        ConcurrentQueue<Action> nextFrame = new();

        public void RunOnBackground(Action action) {
            Task.Run(action);
        }

        public void RunOnMain(Action action) {
            // the current action may repost itself to run each frame
            nextFrame.Enqueue(action);
        }

        public void RunMainLoop() {
            if (!nextFrame.IsEmpty) {
                var tmp = currentFrame;
                currentFrame = nextFrame;
                nextFrame = tmp;
            }
            while (currentFrame.TryDequeue(out var action)) {
                action();
            }
        }
    }

would this do?

knotty sun
#
var tmp = currentFrame;
                currentFrame = nextFrame;
                nextFrame = currentFrame;

whoops

scarlet viper
#

so confusing to read

frosty snow
#
                // swap action buffers
                var tmp = nextFrame;
                nextFrame = currentFrame;
                currentFrame = tmp;
#

this maybe ?

knotty sun
#

no, thats the wrong way round, you had it right before

#

actually no you didnt

frosty snow
#

rip

#

what would be the correct way to swap two objects

knotty sun
#
currentFrame = nextFrame;
                nextFrame = new();
#

you dont need to swap

frosty snow
#

that would incur allocation overhead

knotty sun
#

this is correct

var tmp = currentFrame;
                currentFrame = nextFrame;
                nextFrame = tmp;

currentFrame should be empty at this point

#

so you swap an empty queue for a full one

half sphinx
#

but ill go with 1

knotty sun
#

what I would do is look to see if there is already a potential connecting room and limit the room generation so it gets a connection

half sphinx
#

true thats also something

#

but it prob wouldn't happen so often

#

unless yea i limit the generation

#

ill see

knotty sun
#

you're on the right track though, good proc gen is hard

#

and then comes the fun of doing it in real time

frosty snow
knotty sun
#

exactly

frosty snow
#

also changed to

        public void RunOnBackground(Action<object> action) {
            Task.Run(() => action(action));
        }

        public void RunOnMain(Action<object> action) {
            nextFrame.Enqueue(action);
        }

        public void RunOnMain(object action) => RunOnMain((Action<object>)action);

so we can do RunOnMain(r => RunOnMain(r)); // repeat every frame

#

RunOnBackground(r => RunOnBackground(r)); might be a bad idea tho, since doing such would basically be

while(true) {
    Thread.run(() => {});
}
```which would probably be expensive and a thread pool may deadlock while adding a thread while running an existing thread if all threads happen to do so

T1 add T1 // thread 1 runs and re-adds itself to the pool
T2 add T2 // thread 2 runs and re-adds itself to the pool
deadlock, cannot add thread, capacity 2, active 2, both T1 and T2 cannot exit until a thread has been added, but a thread cannot be added until one has ended

knotty sun
#

still not sure what you hope to achieve with this

fervent furnace
#

swapping the queue should be slightly faster then using one concurrency queue at all.....just little bit since the worker still need to process all the task at first but he dont need to get the lock when dequeue

frosty snow
#

yea

#

it also avoids endlessly running the same task

#

eg

we deque task 1
task 1 runs
task 1 queues itself
we deque task 1
...
fervent furnace
#

why the task one can dequeue itself

knotty sun
#

but why? it seems like you are building a game engine within a game engine

frosty snow
#

a task may wish to run itself every frame for whatever reason, or tasks may wish to run other tasks

#

for example, a layout engine may need to postpone its layout until the next frame due to a change

#

idk

fervent furnace
#

you worker should be

public void Enqueue()
private void Work(){
  while(true){
    if(queue.tryDqueue(out work)){
      work();
    }
  }
}
```obviously the work can enqueue itself to the queue but it cannot call work() on your worker
#

btw this is simple consumer-producer model

frosty snow
#

i know

scarlet viper
#

i have a silly code design problem, there are 2 approaches ive tried to a problem:

  1. put engine code on Engine Monobehaviour script, etc, reference engines etc from Car class
  2. create separate non-mono classes for engine functionalities like throttle etc and reference them from a car (instead of engine)

with 2. i can edit these things just when i have my car selected and i dont need to search for engine and other children in car transform hierarchy
its so much better to debug
but i think it shouldnt be like this, these variables should probably go to Engine since theyre engine related

#

I guess i can just put them in engine and make it all Serialized so that i can edit them from the main car script inspector

latent latch
#

It probably would make most sense on the gameobject that's driving that specific instance

#

and for that it must be a mono

#

Ideally you'd have a Car script on the Mono too which includes an instance of Engine so this way you just need to have a reference to the Car to access Engine

#

In that case you wouldn't need Engine as a Mono since it's the Car script that's on the gameobject

#

So yeah, I believe it aligns with your number 2 suggestion

#

Unless you have a physical model for the engine (which could be damaged), then it could make sense for it to also be a mono

frail thorn
#

Anyone know how to work with AR?

eager steppe
#

Just wondering if anyone knows how to get the x position of my mouse click, when it clicks on an object that is scrollable?
My object is contained within a scrollrect, with a scrollbar controlling where we are on the timeline. When i click on a place on the object, I want the song time to skip to there, but how do I do that when I won't know where I am within the current bounds of the scrollbar?

frosty snow
#

hmmm for some reason my code isnt working o.o

#
[ now : 22:53:40:878] [ since last : 0:0:0:4 ] posting runnable
[ now : 22:53:40:888] [ since last : 0:0:0:9 ] posting runnable
[ now : 22:53:40:889] [ since last : 0:0:0:1 ] posting runnable
[ now : 22:53:40:890] [ since last : 0:0:0:0 ] posting runnable
[ now : 22:53:40:890] [ since last : 0:0:0:0 ] no new actions for this frame
[ now : 22:53:40:898] [ since last : 0:0:0:7 ] no new actions for this frame
[ now : 22:53:40:914] [ since last : 0:0:0:15 ] no new actions for this frame
[ now : 22:53:40:930] [ since last : 0:0:0:16 ] no new actions for this frame
[ now : 22:53:40:948] [ since last : 0:0:0:17 ] no new actions for this frame
[ now : 22:53:40:964] [ since last : 0:0:0:16 ] no new actions for this frame
#
            Debug.Log("posting runnable");
            tr.RunOnMain(() => {
                Debug.Log("attaching ui");
                // attach UI in foreground
                ui.rootVisualElement.Add(button1);
                ui.rootVisualElement.Add(button2);
            });
        public void RunOnMain(Action<object> action) {
            if (Thread.CurrentThread == main) {
                Debug.Log("running action on current thread");
                action(action);
            } else {
                Debug.Log("posting action to next frame");
                nextFrame.Enqueue(action);
            }
        }
#

shouldnt i have gotten at least a compile error ? o.o

frosty snow
#

welp i definitely get a compile error with this

(27,16): error CS1061: 'ScriptManager.ThreadRunner' does not contain a definition for 'aRunOnMain' and no accessible extension method 'aRunOnMain' accepting a first argument of type 'ScriptManager.ThreadRunner' could be found (are you missing a using directive or an assembly reference?)
#

so thats good

somber nacelle
#

and what is aRunOnMain

static matrix
#

is it possible to add attributes to a predefined unity class?
Like lets say I wanted to add an attribute to LineRenderer Called TargetPosition Could I do that?

deft timber
#

you cannot directly add attributes to predefined classes

somber nacelle
#

i assume by attribute you are actually referring to a property or variable. but the answer is no either way. at best you can create extension methods

deft timber
#
public class ExtendedLineRenderer : MonoBehaviour
{
    public Vector3 targetPosition;
    private LineRenderer lineRenderer;
}

somight like that might work for you, depending of what will be the use case of targetPosition

static matrix
somber nacelle
#

nope. and keep in mind this isn't java, attributes in c# are something different

static matrix
#

I actually know c# better than I know java heh
or I like to think
maybe I mean properties?
either way, the game working does not hinge on this being a thing
I will just have to write some slightly messy code

somber nacelle
#

you might be able to inherit from LineRenderer (i can't actually find it in the cs reference at the moment to check whether it is sealed or not). or just use some wrapper class that has those desired properties on it and manages the linerenderer component for you using those properties

deft timber
#

you cannot directly inherit from built-in Unity components -> they are all sealed

heady iris
#

I'd just make a component that handles a LineRenderer for you

#

LineRendererWrangler

#

maybe pick a more specific name

frosty snow
#

to see if it actually errors

static matrix
frosty snow
#

welp i dunno wat to do now

static matrix
#

write code

frosty snow
#

i dunno wat i wanna write lol

static matrix
#

functional code :3

obsidian jasper
#

Is it possible to input two buttons for 1 function ?? for example i have public string btndwn; Can i input two buttons in this ??

static matrix
#

what do you mean

somber nacelle
#

if you mean for something like Input.GetButton then no, you need a separate call for each button you want to query

static matrix
#
if(Input.GetKey(KeyCode.A) && Input.GetKey(KeyCode.B){
  Debug.log("Wowhua Two buttons are held");
}
#

like this?

#

oops forgor to close string

obsidian jasper
#

ya but i need to use Public string btname so that i can input btn name in inspecttor

static matrix
#

oh you can just do Key I think

#

theres some Type you can put in the inspector to have a list of all the keys but I cant remember which one it is

somber nacelle
static matrix
#
    void SetTargetPos(ref Vector3 TargPos){
        TargPos = transform.position + Random.onUnitSphere;
    }
    Vector3 SetTargetPos2(){
        return transform.position + Random.onUnitSphere;
    }

is there any bearing on which of these two functions would be faster? presuming that the calculation to get the final TargPos will get more complex (raycasts and shtuff)

obsidian jasper
#
public string F_Pause_Game(){return Pause_Game;}```
now i wana input like two keys in the inspector how i do it ??
static matrix
leaden ice
static matrix
#

do public KeyCode Pause_game;

#

yeah or this

#

you are smarter than I Mr.Blue

static matrix
static matrix
#

I need to learn it better heh

static matrix
#

ref makes me feel smarter I will use that

#

also something something memory allocation

heady iris
#

don't forget in and out

#

and, in C#12, ref readonly, the weirdo

somber nacelle
heady iris
#

I use out when I need to return a success/failure value and communicate a result

static matrix
#

out is like extra return values right?
sorta?

heady iris
#

It's like ref, but it's write-only.

#

It also demands assignment.

static matrix
#

like a return value

heady iris
#
public bool TryGetThing(string thingKey, out Thing result) {
  if (CanGetThing(thingKey)) 
  {
    result = FindThing(thingKey);
    return true;
  }

  result = default;
  return false;
}
static matrix
#

I see out a lot more in other people's code snippets so maybe I should learn that one instead of ref
idk
back to code writing!

heady iris
#

ref is inferior because:

  • it doesn't assure that something is written to the variable
  • it implies that the function might care about the variable's contents
#

ref means you can't do something like...

#
TryGetThing(string key, out var result);
#

if you tried to do this instead, you'd get a compile error because result isn't definitely assigned

#
TryGetThing(string key, ref var result);
static matrix
#

hmmm interesting

heady iris
#

well, it also might just be a compile error for some other reason

#

maybe you can't even declare a variable in a ref argument at all

#

but it'd be for the same fundamental reason

somber nacelle
#

i'd assume that would be a compile error

heady iris
#

oh it's definitely a compile error

static matrix
#
 void RecalcFeetPos(ref Vector3 EndPos){
        Debug.Log("TryRecalcFeet");
        var TryPoint = Physics2D.Raycast(transform.position, -(transform.position - (Conv0(transform.position+Random.insideUnitSphere))).normalized, FootLength, ground);
        if(!TryPoint){
           
        }
        else{
           EndPos = TryPoint.point;
        }
        
    }

but for this function I might prefer to use ref as it can be possible for the point to be null

heady iris
#

can't let an uninitialized local variable escape like that (this is not about RecalcFeetPos; i was talking about my code above)

#

Vector3 can't be null.

#

This is a perfect application for returning bool and assigning an out parameter.

#

TryFindFootPosition

static matrix
#

huh well this code works fine

static matrix
heady iris
#

I would want to know the difference between "the point didn't change" and "I couldn't find a point at all"

#

but it's probably close enough

somber nacelle
chilly surge
#

If the goal is to mutate a variable in place, then ref is fine. Try pattern is good for "returning result from an action that may or may not succeed"
I do rarely find myself needing to mutate a variable in place though.

static matrix
#

well i think it keeps it from trying to assign the feetpos to null which as Fen stated is something that cannot be done

#

idk
if it ain't broke clearly there is no room for improvement (trust)

somber nacelle
#

i'd like to see what you're doing at the call site because i'm sure your choice for making this a ref parameter is making you do some weird stuff there and that is also something you should consider when making choices like this

#

but also it's not preventing the variable from being assigned null because that is not possible at all anyway

heady iris
#

what it is preventing is failing to assign to an out parameter

#

that would be a compile error, because out parameters must be definitely assigned

#

undefined != null

#
Vector3 what;
#

what is not null

static matrix
#
 feet[0].SetPosition(0, transform.position);       feet[1].SetPosition(0, transform.position);
       feet[2].SetPosition(0, transform.position);
       //Debug.Log(Vector3.Distance(feet[0].GetPosition(0),  feet[0].GetPosition(1)));
        if(Vector3.Distance(transform.position,  feet1Position) > FootLength){
            RecalcFeetPos(ref feet1Position);
        } 
        if(Vector3.Distance(transform.position,  feet2Position) > FootLength){
            RecalcFeetPos(ref feet2Position);
        }   
         if(Vector3.Distance(transform.position,  feet3Position) > FootLength){
            RecalcFeetPos(ref feet3Position);
        }
        feet[0].SetPosition(1, Vector3.Lerp(feet[0].GetPosition(1), feet1Position, 0.08f))       ;
        feet[1].SetPosition(1, Vector3.Lerp(feet[1].GetPosition(1), feet2Position, 0.08f))       ;
        feet[2].SetPosition(1, Vector3.Lerp(feet[2].GetPosition(1), feet3Position, 0.08f))       ;

this is the feetcalc stuff
its somewhat messy
tbh I did not use out because I didn't consider it because I didn't really know how it worked

heady iris
#

i've been reading the C# specification more and more recently. all hope is lost.

static matrix
#

the west has fallen, billions must read documentation

#

theres just so many silly purple words

heady iris
#

it's just a sign that i've lost it :p

static matrix
#

actually reading docs instead of blindly stumbling your way through code like a real programmer

knotty sun
dawn nebula
hexed pecan
static matrix
knotty sun
static matrix
#

or \s?
I don't really like tone indicators
you don't end a normal sentence with (sarcasm) when you are talking
but maybe thats just me having trauma from being overbellittled heh

knotty sun
#

'actually reading docs instead of blindly stumbling your way through code like a real programmer'
and
'actually reading docs, instead of blindly stumbling your way through code, like a real programmer'
say 2 completely different things, that is why punctuation exists

static matrix
#

oh haha
lets eat grandma moment

#

ah well
I should go write code

fervent kernel
#

Hey guys could someone help me with getting OnParticleTrigger to work?
I checked the Triggers module on and all the options to callback.
But the OnParticleTrigger function doesn't actually trigger.

green ice
#

Hi guys,i would change the position of an object at the start method,but later it returns in the original position,do you know why?

dusk apex
fervent kernel
leaden ice
#

Which object did you put that script on?

fervent kernel
#

Don't pay attention to the sphere collider attached, I was running out of ideas as to how to solve this ๐Ÿ˜„

leaden ice
fervent kernel
leaden ice
# fervent kernel Wait, so what do I need to put there?

To begin, specify which Colliders in the Scene the particles can interact with. To do this, assign one or more Colliders to the Colliders list property. To increase the number of Colliders in the list, click the Add (+) button beneath the list of Colliders. To remove a Collider from the list, select the Collider and click the Remove (-) button. If you have not yet assigned a Collider to an index of the list, you can use the smaller Add (+) button, to the right of the empty entry, to create and assign a new Collider. This creates a new GameObject as a child of the Particle System and attaches a Sphere Collider
to it, then assigns the Collider to the empty entry.

After you add the Colliders, you can then specify what a particle does when it meets the criteria for passing a particular trigger event type. There are four event types that describe how a particle can interact with a Collider
https://docs.unity3d.com/Manual/PartSysTriggersModule.html

fervent kernel
leaden ice
#

yes

#

It can only interact with colliders in that list

#

Can I ask what you are actually trying to do with this stuff?

jade vault
#

Hi, anyone familiar with terrain generation using Perlin Noise on a tilemap?

thin kernel
#

Is there a way to disable touch input (but keep the mouse input) from windows touch screen build?

I found only Input.simulateMouseWithTouches function in google, but that doesn't seem to do anything.

fervent kernel
# leaden ice Can I ask what you are actually trying to do with this stuff?

I have an ice attack coming up from the ground, from underneath the enemy.
The gameobject of the ice attack includes multiple children with all of them having a particle system attached to them. Each of the children is a different part of the overall particle system which make up the ice attack.
I want the child which has the particle system of the actual ice spikes, to collide with the enemy and fire an event once it does, I don't want the enemy to stop its movement when it collides with the ice. I want it to keep moving through the ice.
The enemy has a non trigger collider attached to it.

fervent kernel
leaden ice
#

the particle system collision stuff is sketchy at best

knotty sun
#

or you want your children to have trigger colliders if the enemy has a rigidbody

fervent kernel
fervent kernel
knotty sun
leaden ice
fervent kernel
#

9 Stylized Ice Attacks done entirely with Visual Effect Graph.

This package includes:
-9 Stylized Ice Attacks (3 customizable VFX Graphs)
-Highly Customizable (change texture, mesh, rate, color, size, etc. in the inspector)
-Textures (smoke flipbook, impacts, flares etc)
-Shaders (1 ice dissolve shader)
-HDRP and URP only
-Limited Mobile suppor...

โ–ถ Play video
jade vault
#

I am just wanting to set transition tiles between two biomes, I'm not looking for code but just general ideas on how to accomplish this. Is tileset rules a good idea?

dusk apex
fervent kernel
heady iris
#

Using particle colliders to produce actual gameplay effects sounds a bit flaky to me.

fervent kernel
#

wait but if I set them to not interact through layers... wouldn't that mean I won't be able to discern if they collided at all?

fervent kernel
heady iris
#

use a trigger collider or do a physics query

fervent kernel
#

The ice attack comes froward and not all at once from underground

heady iris
#

then i'd use several trigger colliders, or I would use OnTriggerStay and ignore enemies that aren't in range yet

knotty sun
fervent kernel
knotty sun
#

'The gameobject of the ice attack includes multiple children with all of them having a particle system attached to them. Each of the children is a different part of the overall particle system which make up the ice attack' ?

fervent kernel
knotty sun
#

and you want to trigger them at different times of the attack?

fervent kernel
#

The attack comes out forward and upwards

knotty sun
#

so add a trigger to each child so you know when that particular type of effect has hit the enemy

fervent kernel
knotty sun
fervent kernel
knotty sun
#

that would depend on you

heady iris
#

you will probably create other attacks that move in a "wave" like that

#

figure out how to reliably detect hits once, then use that logic many times

green ice
#

it is like it returns in the position of when the session starts

tawny elkBOT
green ice
#

Basically now i am trying to first put an object in the designed new posizion and then try to modify the position of the player

#

line 172 is when the object modify his position

naive swallow
green ice
#

but it is like it moves in the position i want and then it returns in the position of when it spawns

naive swallow
green ice
#

the object that i want to modify the position

#

i will send you the video

naive swallow
green ice
#

a normal gameobject

#

like you can see the blue controller moves in the position i want but then it returns in the spawn position

naive swallow
#

Well the first thing I notice is a whole bunch of errors, any one of which could be causing code to halt execution

#

You should take care of those before you try to do any debugging

dawn nebula
#

Holy red