#archived-code-advanced

1 messages · Page 8 of 1

scenic sage
#

Oh theres camera.screenpointtoray

#

well now i just need to be able to set the cameras pixels in code

silk sable
#

there are plenty of tutorials on the subject that cover all your questions

scenic sage
#

Well almost all tutorails are like ray tracing as a gpu concept

silk sable
#

But I guess if you want your own render engine you would 1: not want the camera render in the first place and just write directly to a blank texture 2: Not use unity

scenic sage
#

Unity is all i got lmao

silk sable
#

The problem you are tackling is one of the hardest problems in computer science

#

A game engine based on this would need so many optimization to even run at a low resolution at 10+fps

scenic sage
#

Well im not dealing with light

#

And i dont care about fps

#

Its a technical demo

#

You align and press render

silk sable
#

That is a tough problem to tackle

#

I'd watch tutorials on how to make a raycast engine from scratch

rotund citrus
#

Is it possible to make an Abstract Scriptable Object?

So I can have functions In it that are different for every Object I make.

flint sage
#

Sure

jolly token
#

I mean you can have abstract scriptable object class and derive from it

#

different for every Object I make
I don't get this part tho

undone coral
#

you shouldn't model card game cards as scriptable objects

#

or pieces of them

hollow rapids
#

Why not? A hearthstone game for example could use scriptable objects for each card

undone coral
#

i'm just guessing what game it is

flint sage
#

BEcause you'll regret your life when you have 1000 cards

undone coral
#

what kind of game is it?

scenic sage
#

Ok let me reask my question. How can i grab the render texture from the camera. Modify a few pixels and then display it to the screen? Im searching online and cannot find any answers

hollow rapids
#

Whats the alternative then? A json with all the data?

flint sage
flint sage
#

Idk about render pipelines

rotund citrus
undone coral
#

compose their functionality out of scripts

scenic sage
#

I dont wanna code a shader right now

rotund citrus
scenic sage
#

I just want to do this in cs. I dont care about preformance at the moment

undone coral
#

a great example is bloons TD

scenic sage
#

Its just gonna be a "Click to render"

rotund citrus
#

If I have 200 Different bullets wouldn't be easier to just make one scriptable object for all of them

undone coral
#

they represent all their towers very literately as prefabs

undone coral
#

create 200 different prefabs.

hollow rapids
#

@jolly token That looks cool, gonna take a look to it.. do you know if it allows gameobject references tho? For a model to isntantiate for example

undone coral
#

if they don't have meaningful behavior, i suppose it doesn' matter. you should procedurally create it in code in that case

rotund citrus
undone coral
#

if they spawn and behave differently, it makes sense to use components to achieve that

jolly token
undone coral
rotund citrus
undone coral
#

yeah

#

use prefabs

#

i'm not sure why so many people replace prefabs with scriptable objects. they are always describing "compose a bunch of programmatic behaviors." that's a prefab

rotund citrus
undone coral
#

that's unity component model

hollow rapids
#

@jolly token Having the path or something like that as a variable, right?

rotund citrus
#

other than heartstone cards of course

jolly token
hollow rapids
#

Gonna take a look at it then.. I was just starting to create every item with a scriptable object so.. hahha

#

Thanks n.n

proven phoenix
#

I followed pretty much every posts advice in that thread and still getting spammed with that error...

#

It is so annoying, and I don't know what to do anymore.

undone coral
#

honestly there aren't any insights here

#

that could help us understand why this is happening

proven phoenix
#

ye I am using odin, but they assured me they have fixed this already

undone coral
#

objects are trying to be loaded during a domain backup, what don't you understand?!

proven phoenix
#

and people are getting the error without odin

#

well i dont understand anything

undone coral
#

lol i'm jk

proven phoenix
#

what even does the error message mean

undone coral
#

yeah it's a weird one

#

i have no idea

proven phoenix
#

:D

undone coral
#

it sounds like it's fundamental to the architecture of odin

proven phoenix
#

i am 99.9999% sure at this point it doesnt have to do with odin

#

idk some guy posted in there about tweaking some shadergraph file

#

which can fix it temporarily for me

#

but obviously because its from a package, it goes back to normal after a while

#

so it might be shadergraph, hell do i know

undone coral
proven phoenix
#

hmm thats good advice, ill try that

#

im not even sure if that change is legit or it will break smth, but at this point i rather break smth than live on with a red log message in my face

#

ok maybe i am rid of my error now at least

#

thanks for that tip

#

i didnt know u can do that

jaunty geyser
#

My physics RayCast is switching between slightly different angles every frame and jittering. It’s based on the position and direction forward of my camera, which is not jittering at all.

undone coral
jaunty geyser
undone coral
#

what is your objective?

#

and what is your game, in one sentence?

jaunty geyser
# undone coral and what is your game, in one sentence?

My objective is to fix my movement code. It seems to be the source of the problem, as once I put the movement code in FixedUpdate, I started to see the screen shake at the same frequency as the raycast. I am working on a small horror game where the goal is escaping a facility.

undone coral
#

so is it first person?

#

or third person or?

jaunty geyser
#

First person

undone coral
#

is it a cinemachine camera?

#

are you using new input system?

jaunty geyser
#

Not entirely sure what that means. I am using Rewired.

undone coral
#

okay

#

and no cinemachine right?

jaunty geyser
#

To my knowledge, no

undone coral
#

okay

#

my camera, which is not jittering at all.
there's no significance to this

#

is your character a rigidbody?

jaunty geyser
#

Yes, non kinematic

undone coral
#

okay

#

so there are a lot of issues

#

it really depends what you want to hear

#

do you want a fix to your problem?

#

or do you want to create a working movement system?

#

or do you want to just build your game?

jaunty geyser
#

My plan is to pay a tutor to tell me all the ways I wrongly implemented elements. This is my first Unity game, and I've basically gone with "it works, so its what i'll do"

jaunty geyser
#

but advice for a good movement system is also good

undone coral
#

set your fixed timestep to 1/60

#

and set your maximum allowed timestep to 1/60

#

then set your application.targetframerate to 60

undone coral
jaunty geyser
#

1/60 is 0.016 repeating. It looks like fixed timestep and max allowed timestep only take in decimals

undone coral
#

or use an asset to learn from

undone coral
#

it will just work

jaunty geyser
#

ah, thanks

undone coral
#

let it do the math for you sure

#

does your game work at 60 fps?

#

if not, you can set application.targetframerate to 30, and change those values to 1/30

#

if you're on a mac you can use 48 and 1/48

jaunty geyser
#

Oh, performance wise? Yes, it runs very easily

#

where do i set the targetframerate?

#

in any script?

undone coral
#

and see how that goes for you

#

i think follow up in code beginner and you'll get the assistance you need 🙂

jaunty geyser
#

alright, thank you!

undone coral
#

how big is your environment?

#

they have a tool that combines all shadowcasters into a single material

#

which means they know something

sweet pine
proven phoenix
#

whats the project cache?

#

library folder?

#

(yes)

sweet pine
#

Temp, Library, .VS, Obj

proven phoenix
#

did only delete library

sweet pine
#

also do you use Mono or IL2CPP?

proven phoenix
#

Mono

sweet pine
#

try IL2CPP

#

that domain sound like C# AppDomain to me

undone coral
proven phoenix
#

does the scriping backend have an impact on play mode?!

sweet pine
#

so a script (maybe odin) trying to allocate an object before unity app domain reset

proven phoenix
sweet pine
#

try to remove odin from everywhere even in package caches in appdata

proven phoenix
#

cant it will break my project pretty sure

#

well

sweet pine
#

just make a backup of your project

#

zip it

proven phoenix
#

moving the shadergraph package fixed it

#

so far

#

so im not gonna tinker for now

sweet pine
#

you copied shadergraph package to your local asset?

proven phoenix
#

from packagecache to packages

#

and i added a line

#

like described in the thread

sweet pine
#

and if you want to update that package?

proven phoenix
#

then i will update it

#

lol

jolly token
#

Odin dictates your components and makes too much coupling to remove

sweet pine
#

you want to copy it everytime?

proven phoenix
#

well tbh

#

im not gonna update any time soon

#

so i dont care

#

and yeah, dont tell odin devs, but i am pretty much done with it

#

too big, too much coupling

#

too much fuckery

sweet pine
#

tbh i can't never go with such unstablity

jolly token
#

Too much 😄 I'd just use excel for my data

sweet pine
#

i must be the worst one here i do 60% of stuff in my cpp plugins lol

#

usually just use unity for visual presentation of my data

jolly token
#

Not the c++!

sweet pine
#

actually after 2 year spending on cpp i face very small amount of bugs and fuckery xd

jolly token
#

modern c++ syntaxes just scare me off

sweet pine
#

why it looks like a lot to c#

jolly token
#

like && or {} 😂

sweet pine
#

well well

#

in c# there are so many things i never knew xD like today i just found out
public vector3 stuff => new vector3();
i mean wtf is that xD

#

or ()=> as action

jolly token
#

C# is kinda going similar way with ref readonly struct etc lol

lusty egret
#

how can I make a function that is called when a variable value is changed?

versed warren
#

Im workin on a chunk loader and this is what I have so far, I have no idea how to use the boundires to load the chunks I want though. Does anybody have any ideas?

obsidian glade
versed warren
undone coral
#

or to load what chunks exactly?

#

what is the game?

versed warren
#

pretty much im making procedural generation

#

and I want chunks to load as the player and subsequently the camera moves

#

chunks are planes with an area of 10 by 10

#

The ground plane in the script has a Y value of 0 because that is the height that terrain is being generated at

undone coral
#

have you looked at the moremountains topdown asset?

#

you might also be interested in this @versed warren https://www.youtube.com/watch?v=xlSkYjiE-Ck

Welcome to this series on procedural landmass generation. In this episode we begin work on an endless terrain system.

The source code for this episode can be found here:
https://github.com/SebLague/Procedural-Landmass-Generation

If you'd like to support these videos, I have a Patreon page over here: https://www.patreon.com/SebastianLague

▶ Play video
versed warren
#

I think ive figured out my problem though

#

I appreciate the help!

versed warren
#

Wish me luck brother

untold moth
#

That's like totally different from what you were trying to do though. I'm not even sure how to approach it. The top side doesn't seem to rotate, so in the real world that would only be possible if the the bottom part rotates 180 degrees in one direction, then 180 back. It doesn't make full rotation.

#

Or is it just twisting through itself(not sure how to describe it otherwise) in the middle? Something that would not be possible with a real world ribbon?
If so, then you can do that with the current implementation I think. Just set the top part rotation to 0.

tall briar
#

How do you draw something that wraps over terrain? Like how the troop placement markers hug the hills and valleys here. The only way I know how to describe a line is with Calculus and I'm at a loss how I'd apply it here

uncut seal
torn basalt
#

anyone have any tips on selecting the verts/edges/faces of a Unity cube. similar to how it works in say Maya?

torn basalt
#

looking at that now.

sly grove
#

Or use the ProBuilder API

#

there is a runtime API for it

chrome osprey
#

Is there a quick and easy way to do a parabola raycast?

wind pasture
# chrome osprey Is there a quick and easy way to do a parabola raycast?

no built in way that I know of. You can calculate parabolic trajectory and then do a physics.spherecast at its end point or something to that effect. I've seen other people use a series of iterations using custom colliders that go from the minimum parabolic height upwards and see if any of those colliders hit anything. You could also do a physics.simulate

livid kraken
livid kraken
#

My recent profilling showed that the entire playerloop takes about 1.2ms

#

The rest of the time up to 8ms is spent on Oculus.waitfor bla bla frame sync

versed warren
#

Because if that is the case it might make sense to make small raycasts forward

#

and at the end of every raycast create a new ray which is curing down a bit

chrome osprey
#

I'm trying to do a parabolic arc to determine if my jump parabola would clear a platform and land on it

versed warren
#

oh

chrome osprey
#

but that doesn't seem to be a thing outside of some iterative raymarching-esque approach

undone coral
regal olive
#

I'm making a roguelike with a looping system, when you beat a run you go back to the beginning and the difficulty increases

I'm trying to create a system for defining level generation and drop rates for each level in a loop
And then a system for holding all the loops for each mode / challenge / secret seed sort of stuff

I have 3 scriptable objects:
GenData (Holds generation data and all the enemies that spawn etc)
GenLoop (Holds an array of GenData for each level in the run)
GenMode (Holds up to 2-3 loops for that particular run, after 3 loops it will just keep using the last GenLoop in the array)

Is this a good way to do this?
I'm going to have to do an insane amount of dragging and dropping like this
Does anyone have any better ideas or ways to reduce the time it will take me to set each drop of each level of each loop of each mode?

[CreateAssetMenu(fileName = "GenData", menuName = "Gen/GenData", order = 1)]
public class GenData : ScriptableObject
{
    public int ChunkSize = 10;
    public int MapSize = 100;
    public float DistanceMult = 0.001f;
    public float OWChance = 1;

    public TileWave[] HeightWaves;
    public TileWave[] DiffWaves;
    public TileWave[] AltWaves;

    public TilePreset[] Tiles;

    public List<MineResult> DropTable = new List<MineResult>();
}

[CreateAssetMenu(fileName = "GenLoop", menuName = "Gen/GenLoop", order = 1)]
public class GenLoop : ScriptableObject
{
    public GenData[] AllGenData;
}

[CreateAssetMenu(fileName = "GenMode", menuName = "Gen/GenMode", order = 1)]
public class GenMode : ScriptableObject
{
    public GenLoop[] AllGenLoops;
}```
tired basin
#

i'm using Scriptable Objects as runtime set . write operations is in one scene & read in another scene(which loads additively). both scene have that scriptable object reference in their respective serialize fields .
in-editor => this runs fine.
in-build => this doesn't work fine(both scene creating there own instance of that same scriptable object).
this bug shouldn't be there . is there any work around which let me maintain this flexibility ?

upbeat path
tired basin
#

same happens if you're using scriptable objects as event channels

tired basin
upbeat path
#

yes

tired basin
#

i'm not trying to save anything , i'm just trying to use Scriptable Object as Runtime Data Container while application is running

#

one scene is adding some entries in that scriptable object & other scene which loads additively is using that entries.

#

everything is running

upbeat path
tired basin
#

an scriptable object asset should work as a singleton through out the project, but it's not

upbeat path
#

I guess the SO is being reloaded with the new scene

tired basin
#

if an asset "abc.asset" is given in serialize fields in multiple scenes , it should be the same instance , right ?

#

i've a very big project & this architecture is major part of it.

upbeat path
#

make a seperate go with the dontdestroyonload and hold your SO reference there then use that in both scenes

tired basin
#

but now this thing is causing issue in build & fun thing it's not 100% . sometime it works , magically

tired basin
upbeat path
tired basin
#

it's a designer friendly system . most of the systems actually.
& we're using static classes just as functions library (decided by the tech leads)

upbeat path
# tired basin ^

It does sound like the SO is being reloaded on scene change so I cant think of another way to persist changes made in scene 1 to scene 2

tired basin
#

found it & it worked

upbeat path
tired basin
regal olive
#

Can i get some code level assistance please. https://gist.github.com/Caraveo/34ca9e18e8eede32a234a1f557d1044a I have this code that creates a list of "Activators in random space" then when the player is near one of these activators is spawns asteroids or whatever that item is. it works pretty well but when the player is away from that item what is the best way to deactivate that item? Code is linked and i have the system working im just getting a multithreaded error i think.

Gist

Asteroid Manager. GitHub Gist: instantly share code, notes, and snippets.

#

hmmm

#

it seems to be working without the errors now

#

strange

#

it was a question about race condition and threading :[

#

yes?

#

ill check for movement

#

i need to make sure that if the player moves

#

the items get created

#

i thought that would be the best way to do it

#

basically its a way to manage a scene with 1,000,000 objects

#

but the objects are just a list

#

so they are only created if the player is near them

#

i don't even know if im going to use it

#

ol

#

just something cool to have

#

😅

#

yesh its an interesting problem to solve....

#

i thought it was

#

basically any direction you go in

#

it spawns objects around the player

#

since its a space game i thought it would be needed to optomize and my
"space" levels are procedural or w/e

#

yeah people were using physics collision detection

#

i didn't think that was a fast solution

#

photon...

#

no they were using triggers

#

like a collider

#

sphere sollider i think

#

or even raycaster

#

i really didn't think those would work

#

and i wanted to code it

#

okie

#

oh

#

so basically static objects though

#

lol

#

im going to use a seed to generate my worlds

#

so the objects are random and the gameobjects are placed based on seed? so im going to sync the seed between players so that the players seem to have the same worlds 😄

#

and what you are saying is kinda what im already doing

#

im trying to screen record

#

but the new mac security "features"

#

basically anything around they player is activated MikuShock

#

The acticator is a class im going to build up to be different types of objects like planets, suns, moons, asteroids, items etc.

#

*I haven't thought this through

#

no gpu

#

?

#

i thought i was doing pretty good ARCambiance

#

alright ill have to look up how to use that ;]

#

the game spawns about ~500 game objects around the player

#

and also i think the asteroids have like rigid physics and stuff

#

ill have to check

#

yes they do lol

#

i followed a cube totorial and just made it work in all directinos

#

one sec ill link it

#

oops

#

this is what i base it on

#

but i just made it work with the random item placer and made it work in all directions

#

im sure he did a better job

#

but i tried to simplify it MikuStab

#

alright i ill have a read

#

yeah the reason its so slow is because its of the whole coroutine being in update

#

lol

#

ill do some type of event manager

#

I didn't want to attach a monobehaviour to every object and then deactivate itself lol

#

memory allocation ;]

#

so is this considered object pooling? lol

#

15FPS

#

LOL

#

mmm

#

check this out

#

well no im going to have an array of game objects to spawn

#

coins

#

or whatever

#

fuel

#

music elements

#

Thats my game

#

I would link it but i didn't pay my developer fees cry 😭

#

im just optomizing it because it was super bad with so many objects

#

these images are from my game

#

lol

#

its my aop

#

my app

regal olive
regal olive
# regal olive

A screenshot of my game in the Apple App Store(That was taken down because im bad)

#

':]

#

i still consider myself a beginneeer

#

lol

#

Yeah i have no idea how to even start with LOD

#

i want to tackle that eventually :]

rugged radish
#

if you have proximity checks in the the millions you should look into spatial indexing data structures, instead of looping through a giant list

regal olive
#

😐 I dont :[

#

maybe 40 people have downloaded my game? :]

#

average ccu is 0 and can't even get it rn

#

:[]

regal olive
regal olive
rugged radish
#

you're looping through a million of points in space to check if they're close enough

#

instead of looping in a general vicinity of the player

regal olive
#

ok ok

#

understandable...

#

the points are just vectors and not game objects loaded in memory or anything like that

#

yesh i probably could optomize the deactivator 😐

#

I was inspired by a game i haven't even played yet 😦

rugged radish
#

also replace distance with squared distance, when there's so many checks in a single frame it does make a difference

brave solstice
#

can someone help me? im trying to make my ball(projectile) the player throws to activate my button. currently it only activates by player standing on it

craggy spear
#

You require the player to be present to reach the StartCoroutine(Press());

protected override void OnInteract(Collider other, CanInteract player)
    {
        if (_playerPresent || !isEnabled)
            return;

        _playerPresent = true;
brave solstice
#

somehow add its presence?

craggy spear
#

actually, I read the code I shared incorrectly - I find this paste site difficult to read

#

Where is OnInteract() called from?

#

You need to add to that a check for the projectile and call it

brave solstice
#

think the interact script

#

i see this?

#

protected abstract void OnInteract(Collider other, CanInteract interactingObj);

#

OnInteract(other, interactingObj);

#

OnInteract(collision, interactingObj);

#

its combined with the interact script

#
{```
brave solstice
craggy spear
#

nope

#

if there's some check above it, that would stop it being called... how am I supposed to see that from just copying a line.

#

I know HOW methods are called.. that's what you showed me.. how it's called... not where

brave solstice
#

is there a better website i can paste the .cs file?

craggy spear
#

that's fine. just gimme the class and line number ¯_(ツ)_/¯

brave solstice
#

ill look around 1 min

brave solstice
torn basalt
#

without using Probuilder or the Mesh API. Can someone point me in the direction of some other resource for dragging to create a cube like in a 3d modeling package. Basically click + drag to define the W and L of the cube then release the click which then allows to define the H. Clicking once again finalizes the object and exits creation mode.

undone coral
#

when you saying "without using" what do you mean? there are many assets with modeling capabilities you can explore. at runtime, not as many

#

How do they handle saving game mid-cutscene?
you shouldn't save mid cutscene. use a skip button.
Do people just hardcode everything into a single use monobehaviour on scene that controls the flow
this works well for me yes. i use a big async method, you could use a coroutine. master cinemachine, and if your assets are good, timeline

torn basalt
undone coral
undone coral
tired basin
undone coral
#

so kinda like "player has to do x y z"
are you trying to say a Quantic Dream / Telltale style interactive cutscene?

torn basalt
undone coral
undone coral
#

or purpose

#

what is your objective

tired basin
undone coral
#

require specific events in order like "npc does x, player has to wait and then do y"
okay well is this something the player can interrupt by walking away and doing something else?

undone coral
#

okay so that just sounds like an RPG

#

is that what you are trying to say?

#

you are trying to design RPG quests?

#

it doesn't sound like a cutscene has anything to do with it

#

if the player can walk away in the middle of a "cutscene" and do something else

#

it's not a cutscene

#

maybe you're trying to describe just a sequence of objectives

tired basin
#

i think that was a bad talk and a bad

undone coral
#

hmm... well is there a game you can reference that would help me understand?

#

but how to make all this designable from editor for someone who doesn't know code?
there are a lot of answers to this, it just depends on what you're asking a "designable" person to do

torn basalt
undone coral
#

sorry i mean for something meant by professionals/knowledgable people or by normals?

#

it sounds like you want an RPG asset

#

they have purely visual / editor tooling for defining quests as a series of linear objectives

undone coral
undone coral
#

you can also study the blender source

#

but it's huge

#

i understand you're seeking probably something a bit more robust or long term if you want to author it yourself

#

so it's a long journey

#

i don't 100% understand yet how what you're describing is different from a traditional RPG quest

#

you used the word cutscene and that is really throwing me off

#

you have to learn the names for these things

#

are you being tasked with designing an RPG quest design tool?

#

are these metaverse crypto people or something?

#

what is the game?

undone coral
#

like be real with me: is the actual product a video of the VR experience?

#

like is it a design fiction?

#

i think your best bet in that case is to create a cube with interactable handles baked in, and program just pulling on those handles and changing the shape of the cube, as a standalone prefab

#

without any notion of a bigger modeling system in place

#

using the asset store VR interation toolkit assets

#

especially the ones that will render a hand model wrapping around a ball-and-sticks skeumorphic scaling/transform gizmo pinned to the face of the cube you want to extrude or whatever

#

because that kind of immersion will pay way bigger dividends than a modeling framework no one will see

#

if you want to model, use the appropriate tool. nothing in a VR headset is an appropriate tool. you might need something as complex as 3d coat for that to make sense

#

okay well i'm just trying to help you out

#

is this a metaverse something something game?

#

this will help me guide you to something that makes sense

#

because what they are asking for might be so ill specified as to be meaningless - they could be looking for the psychic experience of designing quests, not the actual drudgery of building an RPG

#

what the player has to do to make a bunch of events go brrr and what would be the next thing to do and so on"
anyway an RPG asset in the asset store has a good editor for this stuff already. it is pretty tricky to try to mosh this together out of an existing unity package like timeline, because it's not designed to "wait"

#

you also can't really use c# features alone, because you can't save the state of an async method. you have to create a framework for a display tool explicitly

torn basalt
undone coral
#

they put on a VR headset?

#

i think you can build this by attaching stuff from the vr interaction toolkit assets from the asset store

#

to a cube

#

that's probably your best bet

solar hawk
#

Please someone help, so i have this problem, ive been searching through reddit and apparntly there isnt a fix but sometimes there is

#

and its scaring me

#

so

#

i installed Universal RP

#

then i got to the step of

#

changing all the materials to work with it

#

bc theyre all magenta

#

and i get these erros

sly grove
solar hawk
#

[Worker3] Shader error in 'Universal Render Pipeline/Lit': Couldn't open include file 'Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl'. at line 146

#

[Worker4] Shader error in 'Universal Render Pipeline/Lit': Couldn't open include file 'Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl'. at line 146

#

idk im sorry ill go there

tidal maple
#

someone knows how to fix this?

#

dll is there

#

and it worked before

unkempt nova
#

The error above the highlighted one looks relevant

plucky laurel
pastel harbor
#

hello 🙂 Any news on when will Streaming Virtual Texturing (and its potentially huge performance benefits) be eventually supported under URP? Is it somewhere on Unity's roadmap currently? Pls tag me with the replies - thx :))

tidal maple
tidal maple
jolly token
#

What would be the best replacement for UniRx since that project is not really maintained anymore?

vestal condor
#

i'm doing a bit of "functional" programming and i'm running into some issues

#

I'm trying to make the equivalent of Supplier<T> so I can pass certain things around

#

the thing is that it can either be a scriptableobject or monobehaviour

#

but I want to be able to drag this thing into inspector

jolly token
#

You can create custom property drawer

#

But you cannot use generic for it so you should create derived class

vestal condor
#

Yea basically I wanted to specify like a Supplier<float> or something

#

I guess I could just force it to be a MonoBehaviour and have a different MonoBehaviour that takes in a different supplier that inherits ScriptableObject and make it supply and return the result

#

just that it's a bit roundabout

jolly token
#

You need to create concrete type like class FloatSupplier : Supplier<float> then set custom property drawer

#

Yeah it’s Unity restriction

vestal condor
#

I've decided to do MonoBehaviourSupplier<T> and ScriptableObjectSupplier<T> and have a ScriptableObjectSupplierToMonoBehaviourSupplier<T> : MonoBehaviourSupplier<T>

jolly token
#

What..?

#

I don’t follow lol

novel plinth
#

why not having an interface implemented to both?

#

so you dont need to do this ScriptableObjectSupplierToMonoBehaviourSupplier<T> 👀

heady bane
#

Is there a way to change render order so something that is behind an object will render infront of it?

#

I have a lin renderer that cuts through a mesh that I want to have appear infront of the mesh

#

alsoI have an odd bug where a enum in the inspector is failing to update when it changes

jolly token
#

When I have BT or own state machine I just use mechanim to switch aniation from any state

#

Or even just animator.Play. No point of managing two state machines

jolly token
#

Yeah BT is superior FSM than Mecanim so I just don’t put any logic in Mecanim. So BT can control all the logics.

vestal condor
# novel plinth why not having an interface implemented to both?

basically in my inspector i'm sort of forced to "choose" either to have a field MonoBehaviourSupplier<float> or ScriptableObjectSupplier<float> but I think the former is more flexible (?)

either that or i make custom property drawer for each type i want to use but that defeats the purpose of generics

novel plinth
#

with the method I mentioned above, you can use SerializedReference to serialize the interface, much cleaner

#

matter of preference I guess

rich estuary
#

Does Unity Stop/Control Async Tasks When Running Editor Window?
Hi, I've currently got a big issue with running async tasks through my editor tool...
I have a custom editor window that I use as a tool for executing API calls from the client in Unity to our services on AWS.
I enter play-mode to run the tool behaviour in the editor window, but the moment it hits the first "await" call in my state machine, the task just disappears!
I have fully validated my scripts, and I know for certain that the API call successfully executes on the server and it successfully receives the response data back to my callback functions in my unity scripts. I have multiple try-catches, as well as cancellation token handling as I am experienced in async tasks, but for some reason the task is just no longer there executing the rest of the behaviour after the "await" call. It's as if something else has pulled the task off its thread and paused it from running.
Does anyone know why the task just stops executing? Does Unity take full control of the async tasks that are running, and hold them in a queue on a different thread or something?

jolly token
#

Well if you didn’t turn it off, entering PlayMode reloads domain and reset all states

rich estuary
#

Yes I am aware of this. I make sure to explicitly clear any existing stored data in the tool script before executing it. Also, I don't start executing it until I am already in play mode

#

I use a custom Progress Bar (EditorUtility.DisplayProgressBar) when the tool is running to display to progress and state while it's running. Would that cause unity to halt any running async tasks?

jolly token
#

I don’t think so, but what kind of async task are you performing? Is it UnityWebRequest?

rich estuary
#

Nope, for AWS, I use their SDK for doing it, which uses their function, and their function uses HttpClient:

#

I also do PlayFab API calls (an account data cloud service), which I made my own async wrapper class to handle their requests asynchronously, and I discovered that the same thing happens with that as well. It just stops running my task the moment "await" is called, and I successfully receive the response, just the task no longer is running, nor completed.

jolly token
#

And your Unity version is?

rich estuary
#

2020.3.33

jolly token
#

So is it only stop working while Playmode or have you tested on Edit mode too?

rich estuary
#

The async functions all work perfectly every single time when executing normally through the game in play-mode, but it just doesn't if called from the editor window

#

Though here's the thing, sometimes on the off chance, it does actually successfully do the async behavior through the tool, but I have not changed anything when it does work... really weird

#

Like 1 out of 10 times it works fine

jolly token
#

Is the game playing or not when you send request from Editor window?

rich estuary
#

Yes, it's playing

jolly token
#

Have you tried sending request while game is not playing?

#

I wonder about that is relevant or not. I’m pretty sure async/await works well in Edit mode

rich estuary
#

Yeah the async behavior works fine when in editor mode

#

Problem is that I need to be in play-mode when I run it, so that it does PlayFab client connection API behavior, allowing the tool to also execute PlayFab API calls

jolly token
#

Unity does override for SynchronizationContext with their own version so technically they do have control over it

novel plinth
#

thread dispatching sorta needed (to work comfortably) if you're accessing threadPool

#

otherwise just switch the context manually, tho mind you, if you're doing it improperly you may facing locking

regal olive
#

any idea how to blend two heightmaps? they are in float[,] form

#

adding and then normalizing doesnt work

#

average either

rich estuary
#

Seems that would be a better way to do it

deep scaffold
#

Hello, can anyone show me the ways to find goo examples of unity method overriding, i found things like this and wanted to use things like this by myself and understand when i need to do so

devout hare
#

It's a C# concept not a Unity one so google for "c# method overriding"

deep scaffold
jolly token
#

It’s not like technique that has pattern or common best practice. You just look their class definition and source code sometimes to see what to override

#

Because most of time documentation is not enough really

deep scaffold
jolly token
#

Most MonoBehaviour events are virtual if defined

deep scaffold
#

to improve my imageniation on that way

jolly token
#

So you could start from there

deep scaffold
#

thanks, that's what i will do for sure, but if there are some good examples online which someone share with me, that would be appreciated much

jolly token
#

But I think your sample code is already from here

#

Lol.

deep scaffold
#

thank you very much ❤️

jolly token
#

For non-UI stuffs there is not much things worth overriding. Good luck with your project

graceful forge
#

I have the animator cull mode set to CullCompletely, which works for frustum culling I believe but it doesn't change on LOD culling.

Is there a good way to stop animations when LOD culling?

And / Or is there a way to get the animator to enable disable upon LOD culling? I tried doing a renderer.isVisible but it ALWAYS returns false, even if the players are in the camera or not, or LOD culled or not

tidal maple
vestal condor
#

okay I have a funny question

obsidian glade
vestal condor
#

I was previously using GameObject projectileObject to specify a projectile to spawn, and then doing some GetComponent<Projectile>() to check whether the specified object indeed has the script I want

this is because I previously did not know that I could instead just do Projectile projectile and then instantiate it using projectile.gameObject

is there like a good way to refactor the type of this variable

#

From GameObject to Projectile and somehow make every instance of this script in existence use a reference to the Projectile script contained within rather than the entire GameObject

#

I could probably use an editor script to do the replacement for me but it would be ideal if i can figure out where I used the script

obsidian glade
vestal condor
#

as in like um

#

reference in UnityEditor

#

like instances of the script in unity? i guess?

#

it's in a parent class so i need to somehow catch all instances of derived scripts

#

and perform the replacement

obsidian glade
#

e.g in Visual Studio

vestal condor
#

does that actually find all references in unity

#

i'm searching for prefabs that make use of this script

obsidian glade
#

perhaps I'm misunderstanding what you're actually trying to refactor here

vestal condor
#

basically I changed the type of a variable in a monobehaviour

#

now I have type mismatch in unity

#

how can I locate all of these type mismatches?

#

key issue is that i made heavy use of polymorphism so there many scripts that inherit from this parent class, which means I can't simply do a guid search or something

obsidian glade
#

you have things assigned in the inspector, and you want to change the type in your class and have the inspector fields automatically update with the new type without the reference being lost?

vestal condor
#

yup, my intent is to write an editor script that can sort this out for me, but first i must be able to locate the gameobjects in the first place to feed to my editor script

#

I tried doing a find in project in sublime to at least locate places where at least the same variable name has been used

obsidian glade
# vestal condor I tried doing a find in project in sublime to at least locate places where at le...

I don't know a good way of having Unity automatically update those fields with the new type and keep the reference - I'm sure it's possible with an editor script as you said though
the finding references mentioned above will help you find all uses of the Projectile class and you'll be able to manually go through each script that uses a GetComponent<Projectile>() though - VS has some support for finding which prefabs in Unity are using it, though I don't think it works with scene objects

obsidian glade
novel plinth
# vestal condor yup, my intent is to write an editor script that can sort this out for me, but f...

A colleague of mine wrote exactly for this purpose. You can just error them out, and yeah you still need to manually replace them but at least you now know where they at.

Pretty sure he steals it from the internet, somehow it looks familiar to me lol

    var objects = GameObject.FindObjectsOfType();
 
    foreach (var go in objects)
    {
        var components = go.GetComponents();
 
        foreach (var c in components)
        {
            SerializedObject so = new SerializedObject(c);
            var sp = so.GetIterator();
 
            while (sp.NextVisible(true))
            {
                if (sp.propertyType == SerializedPropertyType.ObjectReference)
                {
                    if (sp.objectReferenceValue == null && sp.objectReferenceInstanceIDValue != 0)
                    {
                        Debug.LogError("Missing reference found in: " + FullObjectPath(go) + ", Property : " + sp.name);
                    }
                }
            }
        }
    }
tidal maple
#

how can i fix it?

oblique lake
#

Does Unity cache GetComponent now? Or am I better off doing my own caching?

fresh salmon
#

It never did, cache yourself if you intend to access multiple times

oblique lake
#

Thats what I figured, but I was reading somewhere that they cache it now. So.

flint sage
#

I guess it's not caching but they changed it in 5.0 to be a lot faster

#

So you should probably still cache it yourself

oblique lake
#

Perfect, will do then.

turbid tinsel
#

Does anyone know if you can make an abstract class inheritable by only one other class? I'd make it internal, but I need the deriving class to be public

#

I need access to it from everywhere, but I need it to be inheritable by only one class

sly grove
turbid tinsel
#

I got something like this

public abstract class A
{}

public abstract class A<T> : A
{}

and I need to be able to refer to objects as A, but I need to be able to create only objects that derive from A<T>

#

now I can make class B : A
and make objects of class B
I don't want that to be possible

#

I only want class B: A<something> to be allowed

untold moth
#

Sounds like you're overcomplicating something.🤔

sly grove
#

I think this example is a bit too esoteric

turbid tinsel
#

oh
I think I got it?
Would

public abstract class A
{
internal A()
{}
}

work?

#

probably not, huh

untold moth
#

Probably not.

turbid tinsel
# sly grove I think this example is a bit too esoteric

I got a abstract class Weapon, and abstract class Weapon<WeaponDataType>
I hope that makes sense?
I want to be able to have a list of objects whose classes derive from Weapon<WeaponDataType> but I need to be able to refer to them as Weapon

untold moth
#

Why not have WeaponDataType as a property of Weapon?

turbid tinsel
#

eh
it's kinda complicated
I have a
abstract WeaponDataType
abstract Weapon
abstract Weapon<T> where T : WeaponDataType
abstract Projectile<T> where T : WeaponDataType
and classes that derive from Weapon and Projectile

untold moth
#

Feels super counter intuitive. I wouldn't do that, but you can do what you described

public abstract class Weapon { }
public abstract class WeaponData { }
public class Weapon<T> : Weapon where T : WeaponData { }

You can't prevent Weapon from being inherited by anything else though.

turbid tinsel
#

I guess I'll just make a constructor in Weapon that will throw an error on initialization

#

and override it in Weapon<T>

untold moth
#

No clue what you're trying to achieve. A simple Data field/property in the actual weapon class would make more sense imho.

compact ingot
#

maybe a non-generic base type (to be editor-assignable) derived from monobehaviour that can be configured by a constrained SO-derived type that is then accessible in a property on the mono-derived weapons

turbid tinsel
#

Weapons are ScriptableObjects in my setup

compact ingot
#

whats weapon data then?

turbid tinsel
#

it's a way to pass data from weapon to projectile, I have many weapons of the same type, and many different types of weapons

#

it should be ProjectileData

#

it's generated inside weapon dynamically

#

and passed to projectile

#

I'm a bit tired and had to keep rereading my code to figure this out... I should take a break

#

since a weapon is a scriptableObject

#

I hold it as a static WeaponDataType object inside weapon, and when player switches weapons its regenerated in a method

#

basically

compact ingot
#

can't tell from your description if thats smart and necessary or needlessly convoluted for no reason

turbid tinsel
#

inside
abstract class Weapon<T> : Weapon where T : WeaponDataType
I have
protected static T _weaponData

compact ingot
#

it certainly isn't obvious why you'd want to make it that way

turbid tinsel
#

this way I have a separate static object for each class deriving from Weapon<T>

compact ingot
#

why is it a scriptable object?

#

isn't a weapon something that actually participates in a scene?

turbid tinsel
#

no

#

I can create classes from Weapon, each as a different weapon type

#

and within that class I can make different weapons of the same type

#

just with different data

compact ingot
#

doesn't explain why weapons are SOs

#

you could just as well have a Weapon monobehaviour that gets specialized by a config&behaviour SO for each different type

turbid tinsel
#

class Weapon holds data all weapons have
classes deriving from Weapon<T> have data for each type of weapon, and implementations of stuff like Shoot or something

compact ingot
#

i think you are architecting it in a convoluted way

turbid tinsel
#

that's likely, tbh

#

but then again
I dont have weapons as gameobjects
I just have projectiles
and I'd need to make a gameobject for each weapon if I wanted it this way

#

ehh
I really am tired, maybe it doesn't make that much sense

#

in your approach, for each weapon type class I write, I'd need to create a separate gameobject, with a monobehaviour, I'd need to link them, etc etc
I guess when I figure it out rn it's gonna be cleaner my way
the end product
although to be fair, I am not sure anymore

undone coral
turbid tinsel
#

right now not many, but I will have who knows how many

#

it might get tedious, plus I cannot assume that whoever takes this project after me will know this stuff

#

so I need to make it lack-of-knowledge-proof

undone coral
turbid tinsel
#

and adding new things should have as little required knowledge as possible

undone coral
#

you have to say the real number

#

so far

#

it's okay if the answer is 1

#

1 weapon 1 projectile

turbid tinsel
#

doesn't matter
right now I have 2 types, 3 weapons from each type

#

and each type has different way of managing the stuff, some spawn multiple projectiles of different types, some spawn 1 "projectile" which is in fact a laser beam

undone coral
#

okay, so you have 6 weapons

turbid tinsel
#

but it doesnt matter
I will have more, and I need to make it future-proof

undone coral
#

Anikki made a good suggestion

you could just as well have a Weapon monobehaviour that gets specialized by a config&behaviour SO for each different type

#

you should have 6 prefabs and compose your weapon behaviors out of scripts

turbid tinsel
#

I have that, I have 2 prefabs for each type of weapon

undone coral
#

meaning instead of "specializing" via generics, use a script

#

you should have 6 prefabs

turbid tinsel
#

it has "bullet" code on it

undone coral
#

oh yes

#

i get it

#

so you don't need to use generics at all

turbid tinsel
#

but it can be anything from a bullet to a laser source

undone coral
#

well i can only offer some perspective on this that the generics are bad

#

they will not help you at all

#

they will only get in the way

turbid tinsel
#

will they really? so far I've used generics many times and it's always super useful

undone coral
#

that whoever takes this project after me will know this stuff
trust me, the generics will guarantee no one will ever add a weapon

turbid tinsel
#

what

undone coral
#

yes

turbid tinsel
#

why

undone coral
#

because it's arcane and adds no value

#

right now how many people are working on this?

turbid tinsel
#

I took the project over from someone, currenty I'm alone, but someone might take it over from me

#

or someone may join

undone coral
#

what was wrong with the way weapons were implemented

#

when you received it

#

were there 6 weapons then?

turbid tinsel
#

no, and that was the problem, there was 1 weapon and it was all clumped up in the same class as movement

#

I was tasked with creating more weapons

undone coral
#

it was all clumped up in the same class as movement
i see..

#

is this an FPS?

turbid tinsel
#

with my solution, all people need to do is create 3 classes, a weapon scriptableobject type, a bullet monobehaviour, and a data type

#

not... exactly, a TPS I guess

undone coral
#

okay

#

well it sounds like you're still learning, if you want an opinion on how this stuff should work i can offer one

#

can you give me an example of two very differentw eapons?

#

then i can illustrate for you a really good approach

#

imo, you guys should use an asset store asset if your goal is to deliver a game

#

for building a third person / first person shooter

#

since these games tend to follow a lot of traditions, and that is the actual challenging part

turbid tinsel
#

I want to make a system in which it doesn't matter what you want a weapon to do, you can just make it easily
I have a weapon type right now that spawns many bullets, each with different properties
and I have a weapon right now that spawns 1 gameobject that fires a laser

#

I mean

#

that's not the point

undone coral
#

and it's very hard to come up with an innovative weapon in this genre

undone coral
#

like just their names

#

i think i can figure it out from that logline of their behavior

#

then i can show you wht the inspector would look like on th eprefabs

#

for a good approach

turbid tinsel
#

I mean
I'm not exactly a beginner tbh
and it's not exactly a tps either, it's just closest to this genre

I was just trying to find an optimal way to make it easier for other people to add many various weapons types, the weapons I have right now aren't really that important

#

it's the workflow of adding whatever you want that's important

vestal condor
#

does tmpro support some way to detect when a particular word is hovered over?

turbid tinsel
#

or hover over any text that's on a component

vestal condor
#

singular word in longer text in tmprogui component

undone coral
undone coral
#

is there something about those results that didn't work @vestal condor ?

vestal condor
#

i think my brain is blanking on some important keyword

#

because i’m not finding lol

undone coral
#

i just searched "textmesh pro hover"

vestal condor
#

is it the link thing?

undone coral
#

it's TMP_TextUtilities.FindIntersecting... methods

vestal condor
#

i was searching something like “inline gameobject” lmao

vestal condor
#

i’m interested in 1. Making it clear that this word is hoverable and 2. Making this word actually hoverable

#

the thing is that tmpro supports quite limited text styling

undone coral
#

there's a method "TMP_TextUtilities.FindIntersectingWord"

#

all the results have various learnings in them

vestal condor
#

i wanted to do something like a code block formatting

undone coral
#

i think you can handle it from here

split blaze
#

CommandBuffer.DrawMesh
https://docs.unity3d.com/ScriptReference/Rendering.CommandBuffer.DrawMesh.html
has 4 forms/overloads:

public void DrawMesh(Mesh mesh, Matrix4x4 matrix, Material material, int submeshIndex, int shaderPass, MaterialPropertyBlock properties); 
public void DrawMesh(Mesh mesh, Matrix4x4 matrix, Material material, int submeshIndex, int shaderPass);
public void DrawMesh(Mesh mesh, Matrix4x4 matrix, Material material, int submeshIndex);
public void DrawMesh(Mesh mesh, Matrix4x4 matrix, Material material);

Documentation has explained the first one.
I am interested in what happens if we use the last one that takes only 3 arguments. Does it draw all the submeshes ?

vestal condor
undone coral
#

textmesh pro might not be powerful enough for what you want to achieve

#

i don't remember if you can change fonts with rich text tags

vestal condor
#

anyway the context is simply a weapon description with some damage values provided

#

i wanted it such that hovering over the value gave additional information like its damage type etc

undone coral
#

that's called a tooltip

#

and it's in the first result for "textmesh pro hover"

vestal condor
#

because i have no clue how else to express the idea of boxing the word

undone coral
#

i see

vestal condor
#

in a thing

undone coral
#

well i think you have everything you need

#

to do this

vestal condor
#

to show that it is hoverable

undone coral
#

that sounds to me like a link or anchor

#

and it's in the examples, and it's in the google result

#

anyway i think you're learning the names for these things which is great

#

good luck out there

vestal condor
#

right, thanks

turbid tinsel
# undone coral okay well my final opinion is that if you can't share two example weapons to tal...

I don't really have the weapons done, since I'm in the process of fleshing out the system to make them
but alright, here's some weapons ideas that should be possible with my system
weapon type 1. simple gun, let's say it shoots multiple different bullets at once
weapon type 2. a laser, going from the gun forward
weapon type 3. a weapon that just hits every visible enemy
weapon type 4. that slows down enemies within range
each weapon in a weapon type should be able to have completely different data

with my system, each weapon type is a scriptable object class
each particular weapon is an instance of a particular scriptable object class
each weapon class has implementations on prefabs to spawn, where and how to initialize them, using a separate data class that derives from the base weapondata class
I also have a monobehaviour class for every weapon class, called a projectile, this represents the laser beam, the shots going to all enemies, the slowdown generator, each bullet shot
those are the things initialzied by my weapon scriptableobject class

to make a weapon, you need data that is unique to the weapon, this is stored in a class deriving from WeaponData
you need a class deriving from Weapon, which holds a reference to the type required, along with an implementation on how to spawn projectiles, and manage some of the VFX
and you need a class deriving from projectile, which holds a monobehaviour implementation of the behaviour of the projectiles/weapon
I use generics, so that it's super easy to both connect those things together, and reference any possible weapon from a list in some other arbitrary class, from which a weapon is selected
I don't see a way to do it all without generics, at least not easily, so that it'd be possible to add other stuff in the future easily

#

and sorry for making it difficult to talk to me

undone coral
# turbid tinsel I don't really have the weapons done, since I'm in the process of fleshing out t...

okay here's an example for Weapon 2:

(Inspector)
Weapon

  • name
    // what you do when you press the fire button, i.e. the "trigger" on the weapon
  • trigger behaviour (type Trigger)
  • ... other stuff common to all weapons
    ContinuousBeamTrigger : Trigger
  • game object to activate when pressed
  • damage per hit
  • frequency
    add the laser beam to the hierarchy
    Trigger is an abstract base class with "OnTriggerPressed" and "OnTriggerReleased" - i.e. the user inputs.

Weapon 3:
(Inspector)
Weapon

  • name
  • trigger behaviour
    HitsEveryEnemyTrigger : Trigger
  • damage per hit
    ...
#

that's it. you basically have a script that's common for all your weapons, and you have scripts that basically starts with, "what happens when the user presses the trigger, what happens when the user releases the trigger"

#

does that make sense?

#

you can make some conventional behaviors in their own scripts, like "AutomaticProjectilFiringTrigger"

#

"SemiautomaticProjectileFiringTrigger"

#

etc.

#

i would expect most weapons to just be made of two core business logic scripts, and some scripts for their animations

#

these would all be gathered up in a prefab

#

everything else is just faff. you don't need the scriptable objects

#

you can reference the prefab if you need to spawn it

#

you don't newed weapon data

#

if there's something common to all weapons, it belongs in the Weapon class

#

that you shouldn't inherit from

#

you need inheritence for the sake of specializing stuff in very narrow cases, like if you need to override a method

#

my approach works well because it is focusing on what is actually reusable

#

i have omitted a script that helps render the UI based on what is relevant on the weapon - you would have to author those too

#

the thing that is common / reusable among weapons is how the user interacts with them, rendering onto the UI, that they can be picked up, etc.

#

but what happens when you press the trigger button - you can put that into another script

#

no generics necessary

#

they provide ZERO value

#

here

#

i mean you might conceive of some value they provide, but i could solve this problem better with no generics

#

and for that matter no scriptable objects

#

no need for them

#

you can gather the data about a weapon from its weapon class fields

#

when you reference the prefab

#

🌈 that's it🌈

#

that's my opinion

#

also because you probably have other stuff that can be spawned in your game

#

you would have a Spawnable behaviour

#

that you would attach to your weapon prefab, and that's what your spawning logic would reference, instead of the Weapon behaviour

#

that would contain settings specific to spawning related to the object* like how large it is

#

you would probably hav ea Spawner that says things like frequency ia Spawnable spawns, attached to a gameobject in your level

turbid tinsel
#

The flow in my project currently works like that: I have a player class, with a list of scriptableObjects, let's say 10 scriptableObjects (weapon variants) per each of the 4 different classes (weapon types)
it's all in the same list
and I choose a weapon I want, and I want to fire it
to do that, I call a function on the scriptableObject
the scriptableObject spawns prefabs, sets them up, and lets them do their thing

I don't think in my case I can get away without scriptableObjects
I mean I could replace them with monobehaviours on prefabs, but why? that's what scriptableObjects are for

and generics help me make initialization hassle-free, without duplicating code anywhere, which is important in my case

undone coral
#

alright well i think you can figure this stuff out

#

in my opinion, you shouldn't be using scriptable objects for this stuff

turbid tinsel
#

well, I disagree, it's either that or 10 different prefabs

undone coral
#

that's what scriptableObjects are for
i know you might read somewhere or watch a video that says something or agrees with you

#

and that's fine, that makes sense, but tools evolve

#

most people, very much most of the time, should not be using scriptable objects

#

advice is old and tools evolve

#

10 different prefabs will be more intuitive to a Unity beginner

#

someone who wants to author a weapon will just want to duplicate a prefab

#

and hope it works

turbid tinsel
#

yeah
but how would I make 10 variations of the same weapon then?
I need to make 10 instances of a class somehow

undone coral
#

prefab variants

#

it's right in the name

turbid tinsel
#

yeah, but why wrap it in a gameobject, when it doesn't need to be one?

undone coral
#

that the sooner you rid yourself of it, the better you can use the tools unity provides

#

a game object might as well be called an Entity

turbid tinsel
#

I don't think we understand each other

undone coral
#

some people get hung up on Actor / Pawn in Unreal Engine too

#

the prefab variant approahc is an excellent way to have variations of a weapon

#

it's very logical and intuitive to me, and supports a lot of very simple and intuitive ways to customize a base weapon

#

for example, by adding specific art and graphics, or changing specific fields, or adding or removing or modifying behaviors

#

if you're about to say "but game objects are heavy"

#

well, tools evolve, advice changes, i know that is something tha tmay have been true a while ago...

#

but now, you know, it doesn't really matter

#

besides, when people say stuff like that they just mean "i don't lik eit"

#

i'm hearing a lot of "i don't like it" which is okay

#

as soon as you did Weapon<T> : where T extends WeaponData you architected somethign poorly

#

that's just the reality of it

#

for starters, polymorphic data objects are toxic, they're almost always wrong

#

so just the notion of having a hierarchy of WeaponDatas, assuming that's what you mean by the name, that it's strictly data

#

you know, it's wrong

#

and don't take my word for it

#

i see some results for "what is wrong with polymorphic data objects" but i think this is too high level for google

turbid tinsel
#

but you're basically saying, that I can have prefab variants with instances of a component on them
and in the component I can have my data
and I'm saying I can just make scriptableObjects

I don't even need to spawn the prefabs at all
I just need the data and code that is on them
and I can have a scirptable object, with more easily accessible data, work in the same way

undone coral
#

but i think it'll all work out 🙂

#

no one is going to be able to make heads or tails of your generics thing

#

or initialization

#

if they want to initialize something it's intuitive to put it in a void Start

#

the stuff you're talking about, you're not being realistic about how arcane it is

#

you're reinventing game objects, to a certain extent, and i don't know why

#

it's probably more comfortable for you to be in the code tools than in the unity editor

turbid tinsel
#

in my experience, making a custom inspector, or a editor window to edit components on gameobjects is super annoying, and this is just one of the issues I have with your approach

#

prefabs*

undone coral
#

making a custom inspector, or a editor window to edit components on gameobjects is super annoying
well i don't know who the audience of your future collaborators are

#

i never author custom inspectors

#

okay i gotta go

#

juyst think about this

#

no one is validating your approach here

#

3 people have looked at it and told you it's kind of crummy

#

so what can i say

untold moth
#

I guess the problem that I see with your approach is that you make your code artificially less readable. Less logical. Even if it saves you a few lines of code, harming the readability of the code is not great imho.

jolly token
#

Use SO as just simple immutable value structure that you can import as asset

#

It's nothing more than that

ashen ravine
#

Hey everyone, I have question regarding adding voice chat support to my game. There are tons of alternatives in google. Do we have some library for unity or some documentations that I can follow?

#

A direction would be great

shadow seal
torn basalt
#

is it possible to write a cameras output to a mesh using a depth shader

plucky laurel
#

you mean modify the mesh geometry based on depth texture?

torn basalt
#

I am trying to follow this old GDC talk about the portal effect from Budget Cuts and I am trying to figure out what is meant by the breakdown. towards the end

#

@21:54 the first 2 steps are stumping me.

plucky laurel
#

alright, so you can in theory do that with a stencil op

#

im not sure exactly how to overwrite camera zbuffer (they are essentially doing a hack there)

#

a hack in a sense they are relying on existing pipeline doing a thing its supposed to, but hacking it so it does what they want

#

so my broad guess would be write to stencil buffer with the circle geometry, convert that buffer to depth buffer on the camera, let it render

torn basalt
#

I have to give that a try. Still learning so, this may be a bit to start off with

plucky laurel
#

i think they key here is finding how to properly write to zbuffer on your pipeline

#

seems there are lots of options

#

so main camera has a hole where z value is max, and portal camera has it min, and it should work? i gues

undone coral
versed warren
#

I have a script that creates procedural chunks and textures them at runtime. Does anybody have any idea why each plane has a weird line going through it?

#

They are faint in the picture but very present in game

#

I cant see the lines in the editor but they are visible when in the game view

low adder
#

I fixed it by making my the uv's on my texture slightly smaller than the texture

#

Idk how this applies to your thing tho

earnest otter
#

I've been looking into a ScriptableObject Event System, and I've seen two ways to do it, and I'm wondering if there's an advantage one over the other.

  1. When the event is raised, it's triggered to the listeners using (UnityAction) OnEventRaised?.Invoke()
    Or 2) that keeps a list of listeners and then iterate backwards through that list using listener[i].OnEventRaised() Is there much difference or a reason to use one over the other?
jolly token
#

Just who is spreading this usage of ScriptableObject as event broker?

#

To answer the question I think iterating list could be little faster when adding/removing listeners
but it wouldn't be much difference

#

But it's not a good idea to use ScriptableObject as event broker
Do dependency injection to make context would be better idea

earnest otter
#

There were several Unity hosted chats about Scriptable Objects as frameworks for an Event System. Why are you against it? I like what I read and heard so far.

jolly token
#

Because any C# object can be event broker. It is no point of using ScriptableObject for that.
Even Unity document says they are only meant to store data.

#

It should treated as customizable data container, not something else

earnest otter
#

That's not what the devs say in the Unity events where they talk about using them for so much more. You should watch these:
https://www.youtube.com/watch?v=VFOGGml_N6g
https://www.youtube.com/watch?v=6vmRwLYWNRo
https://www.youtube.com/watch?v=raQ3iHhE_Kk
https://www.youtube.com/watch?v=PVOVIxNxxeQ

BMo

Richard Fine and Ryan Hipple really paved the way with their Unite talks in how you can use Scriptable Objects to completely transform your project.

Introducing the Scriptable Object Variable you can make in your Unity Asset folder. This approach blew people's minds back in the day, and it still acts as an incredibly powerful tool to decouple y...

▶ Play video

Get the assets here: https://github.com/richard-fine/scriptable-object-demo

This session goes over ScriptableObject class in detail, compares it to the MonoBehaviour class and works through many examples of how it might be applied in a project.

Richard Fine - Unity Technologies

00:00 Intro
1:34 The MonoBehaviour Tyranny
5:58 Uninstantiated pr...

▶ Play video

Scriptable Objects are an immensely powerful yet often underutilized feature of Unity. Learn how to get the most out of this versatile data structure and build more extensible systems and data patterns. In this talk, Schell Games shares specific examples of how they have used the Scriptable Object for everything from a hierarchical state machine...

▶ Play video

In this video, we are going to show you how to use Scriptable Objects to manage your data in Unity.

Download the Unity Royale Project here!
https://on.unity.com/33FplpG

Learn more about Scriptable Objects here!
https://on.unity.com/33PzcJR

Get Inspiration on what else to do with Scriptable Objects here!
https://on.unity.com/2RKXXkK

Chapters:...

▶ Play video
#

Anyways, you answered my question above. thanks.

jolly token
#

Thank you for the references but 🤮
Why they want to couple themselves with more assets.
Dead UniRx would be much better than that

compact ingot
jolly token
severe trail
#

Does anyone have a method for finding the vertices of a mesh that are within a volume?

sly grove
severe trail
#

maybe intersecting a cube?

#

or collider, or bounding box?

#

I'm trying to set the boneweight of vertices in a skinned mesh, if they're within a 3d area

#

so bascially get all the vertices in the mesh as an array, then thee ones within the volume, set a new weight

sly grove
severe trail
#

cube

sly grove
#

ok so... go through ecvery vertex

severe trail
#

most robust

sly grove
#

and see if it's within the cube

#

as long ass the cube isn't rotated it's a simple comparison

severe trail
#

kk awesome. what would be the best method if the cube needs to be rotated?

#

convex colliderr?

sly grove
#

easiest is rotate the mesh points instead of the box 😛

#

and continue to use bounds

severe trail
#

yeah, so the idea is some simplistic autorigging. Not sure if rottaing the mesh is an option

sly grove
#

just kind of "virtually" rotating the mesh data as you analyze it

#

you need to be transforming the mesh data into world space anyway if you're going to check it against bounds etc

#

since mesh data is always in local space for the MeshRenderer

severe trail
#

virtually rotating the mesh data?

sly grove
#

yes

severe trail
#

not sure I understand that. any reeferences i could look at?

sly grove
#

basically you need to be doing transform.TransformPoint(vertex) for each vertex from the mesh data anyway. you ould change that to like transform.localToWorldMatrix * Quaternion.Inverse(theBoxRotation) * theVertex

#

not 100% sure that's correct.. but that's the kind of idea

severe trail
#

kk, word! I'll look more into comparing bounds, as I've never got into it. Thanks for the help!

sly grove
novel plinth
#

unirx package is mega humongous 🧐

You can make your own pretty simple @earnest otter

    //usage var i = new MyListener<SomeType>();
    // i.value += () => { Console.WriteLine("changed!"); };
    public class MyListener<T>
    {
        private T _value;

        public Action value;

        public T Value
        {
            get => _value;

            set
            {
                if (!EqualityComparer<T>.Default.Equals(_value, value))
                {
                    _value = value;
                    OnValueChanged();
                }
            }
        }

        protected virtual void OnValueChanged() => value?.Invoke();
    }
#

just to give you an idea, and yeah you should modify it to your needs

regal olive
#

before i added BarrelMoves() i could rotate my spaceship with mouse. now after adding it i cant do it. why?

rapid flume
regal olive
rapid flume
#

because both need to have physics

dusky dust
#

how do I save a tilemap inside of a costome save system? here's the system - ```cs
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.Tilemaps;

[System.Serializable]
public class SaveManager
{
public static SaveManager instance;
public float[] playerPosition;
public GameObject Floor;

public SaveManager(PlayerMovement player)
{
    playerPosition = new float[3];
    playerPosition[0] = player.transform.position.x;
    playerPosition[1] = player.transform.position.y;
    playerPosition[2] = player.transform.position.z;
    Floor = GameObject.Find("Floor");
}

}

the Floor var is the problem
shadow seal
#

What here does the actual saving?

dusky dust
#
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using UnityEngine;

public static class SaveSystem
{
    
    public static void SavePlayer(PlayerMovement player)
    {
        BinaryFormatter formatter = new BinaryFormatter();
        string path = Application.persistentDataPath + "/player.save";
        FileStream stream = new FileStream(path, FileMode.Create);

        SaveManager data = new SaveManager(player);

        formatter.Serialize(stream, data);
        stream.Close();
        Debug.Log("Saved");
    }
    public static SaveManager LoadPlayer()
    {
        string path = Application.persistentDataPath + "/player.save";
        if (File.Exists(path))
        {
            BinaryFormatter formatter = new BinaryFormatter();
            FileStream stream = new FileStream(path, FileMode.Open);

            SaveManager save = formatter.Deserialize(stream) as SaveManager;
            stream.Close();
            
            return save;
        }
        else
        {
            Debug.Log("Save file not found at " + path);
            return null;        
        }
    }
}
``` this
shadow seal
#

Yuck, BinaryFormatter

dusky dust
#

ye, im not happy to use it either

shadow seal
#

You shouldn't use it

jolly token
#

You cannot ‘save’ GameObject in scene like that

shadow seal
#

But that code again doesn't save any tiles

dusky dust
#

it saves the floor tilemap object

shadow seal
#

Where

#

You can't "save" a GameObject

dusky dust
shadow seal
#

How do you place down the tiles?

dusky dust
#

through a random generation code

shadow seal
#

So you could save the world seed to a file, and regenerate it based off the seed

#

You'd still need to save any changes made to the world after generation

dusky dust
#

only problem, doesn't use a seed

shadow seal
#

What does it use then?

dusky dust
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public static class GenAlgorythem
{
    public static HashSet<Vector2Int> simpleRandomWalk(Vector2Int startPos, int walkLength){
        HashSet<Vector2Int> path = new HashSet<Vector2Int>();
        path.Add(startPos);
        var previousPos  = startPos;

        for(int i = 0; i<walkLength;i++){
            var newPos = previousPos + Direction2D.GetRandomCardinalDirection();
            path.Add(newPos);
            previousPos = newPos;
        }
        return path;
    }
}
public static class Direction2D{
    public static List<Vector2Int> cardinalDirectionsList = new List<Vector2Int>(){
        new Vector2Int(0,1),//UP
        new Vector2Int(1,0),//RIGHT
        new Vector2Int(0,-1),//DOWN
        new Vector2Int(-1,0)//LEFT
    };
    public static Vector2Int GetRandomCardinalDirection(){
        return cardinalDirectionsList[Random.Range(0,cardinalDirectionsList.Count)];
    }
}

``` this
shadow seal
#

Unity's Random is seeded

dusky dust
#

so how will I change it to be seeded?

shadow seal
#

It is, you can also change the seed

dusky dust
#

hmm, just make a varrible that will hold the result of the GetRandomCardinalDirection() result?

shadow seal
#

No

dusky dust
#

so how

shadow seal
#

Give Random a seed at the start, and save that seed

#

It could be the time for instance

dusky dust
#

hmm

#

can you give an example?

shadow seal
#

When Unity decides to open

dusky dust
#

it will take the time and then use the time as a seed?

shadow seal
#

You can certainly do that

dusky dust
#

my question was, how do I make it a seed?

#

just make a varrible that will hold the time, make it a number and use it as the direction?

shadow seal
#

You can initialise Random with a seed

#

So if this is a new world, get a seed (maybe the date) and seed the RNG, save that seed.
When they open this world later, grab our seed and use it to seed the RNG, should produce the same world

dusky dust
#

should this work - Vector2Int seed = new Vector2Int(Random.Range(0,10000000), Random.Range(0, 10000000));?

shadow seal
#

Where on Earth did you pull that from?

dusky dust
#

my brain

shadow seal
#

Well put it back

dusky dust
#

🙂

#

i dont really get how to make it

shadow seal
#

You don't know how to use the method from that docs link to provide a seed to Random?

dusky dust
#

no not raelly

#

never done something like it before

signal trout
#

Hi, can someone please help on following issue

3D model's back stretched in Android Build
For generic 3D model all animations looks fine in Unity but on making android build, in walk animation model's back get stretched.
It's super weird and I tried many solutions like applying 4 bones etc, please help

shadow seal
#

You've called many methods before

dusky dust
#

the function uses A vector2Int and the random gives a float

shadow seal
shadow seal
dusky dust
#

but my function uses a vector2int

shadow seal
#

We're not on about that though

dusky dust
#

can you please help me

#

I really don't know how to implement that

shadow seal
#

It's literally a method call

dusky dust
#

just copy and paste it?

shadow seal
#

Do you know how to call methods?

dusky dust
#

yes

shadow seal
#

So call the InitState method from the Random class

#

It will ask you to pass an integer parameter, just pass it 1 for now

dusky dust
#

where should i call it?

signal trout
shadow seal
#

Call it before you load the world

shadow seal
signal trout
#

Yea, can suggest some other channel

shadow seal
dusky dust
#

where should I put the result of the init?

signal trout
shadow seal
dusky dust
#

so put it inside of the random direction method?