#archived-code-advanced
1 messages · Page 8 of 1
there are plenty of tutorials on the subject that cover all your questions
Well almost all tutorails are like ray tracing as a gpu concept
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
Unity is all i got lmao
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
Well im not dealing with light
And i dont care about fps
Its a technical demo
You align and press render
That is a tough problem to tackle
I'd watch tutorials on how to make a raycast engine from scratch
Is it possible to make an Abstract Scriptable Object?
So I can have functions In it that are different for every Object I make.
Sure
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
yes, but it's a poor way to model something
you shouldn't model card game cards as scriptable objects
or pieces of them
Why not? A hearthstone game for example could use scriptable objects for each card
i'm just guessing what game it is
BEcause you'll regret your life when you have 1000 cards
what kind of game is it?
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
Whats the alternative then? A json with all the data?
OnRenderImage and apply a shader is iirc possible
use a shader to achieve this
Idk about render pipelines
Imagine I have a gun with 4 different types of Bullets, each spawn differently or act differently.
Wouldn't it be good to have a scriptable object for each bullet and an abstract class to also add functions?
no, create 4 bullet prefabs
compose their functionality out of scripts
I dont wanna code a shader right now
Really? that doesn't sound like the proper way to do it
I just want to do this in cs. I dont care about preformance at the moment
that is the proper way to do it
a great example is bloons TD
Its just gonna be a "Click to render"
If I have 200 Different bullets wouldn't be easier to just make one scriptable object for all of them
they represent all their towers very literately as prefabs
no
create 200 different prefabs.
@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
if they don't have meaningful behavior, i suppose it doesn' matter. you should procedurally create it in code in that case
Than should I just have a script to manage them all?
if they spawn and behave differently, it makes sense to use components to achieve that
For prefab, you gotta use path and dynamic loading like from Resources but it supports verification
you can drag and drop them into a Bullet[] slot
they do all spawn and behave differently.
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
sounds good, Thanks a lot!
that's unity component model
@jolly token Having the path or something like that as a variable, right?
it is true, but than I wonder when do we use scriptable objects
other than heartstone cards of course
Yes, I do it like [Resource] public string PrefabPath { get; set; }
And verification checks if it is correct path
Gonna take a look at it then.. I was just starting to create every item with a scriptable object so.. hahha
Thanks n.n
Does somebody have any idea how to fix this? https://forum.unity.com/threads/objects-are-trying-to-be-loaded-during-a-domain-backup.1264967/page-2
https://i.imgur.com/Sp0LaSs.mp4
in what kind of world This is OK to release ??!?!?!?
i downloaded the latest Version all 3 LTS and all have the same...
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.
are you using odin?
honestly there aren't any insights here
that could help us understand why this is happening
ye I am using odin, but they assured me they have fixed this already
objects are trying to be loaded during a domain backup, what don't you understand?!
lol i'm jk
what even does the error message mean
:D
it sounds like it's fundamental to the architecture of odin
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
you can copy the package from Library/PackageCache into Packages/ and make the change there
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
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.
are you doing the raycast in a fixed update
Yes, and sadly it still doesn’t work.
you shouldn't be
what is your objective?
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.
okay
so is it first person?
or third person or?
First person
Not entirely sure what that means. I am using Rewired.
To my knowledge, no
okay
my camera, which is not jittering at all.
there's no significance to this
is your character a rigidbody?
Yes, non kinematic
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?
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"
for now, this is good
but advice for a good movement system is also good
under project settings > Time
set your fixed timestep to 1/60
and set your maximum allowed timestep to 1/60
then set your application.targetframerate to 60
hmm you probably want to ask in code beginner then
1/60 is 0.016 repeating. It looks like fixed timestep and max allowed timestep only take in decimals
or use an asset to learn from
go ahead and enter 1/60 into the editor and hit enter
it will just work
ah, thanks
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
Oh, performance wise? Yes, it runs very easily
where do i set the targetframerate?
in any script?
you can at least try the timing changes
and see how that goes for you
i think follow up in code beginner and you'll get the assistance you need 🙂
alright, thank you!
@livid kraken have you seen this asset? https://assetstore.unity.com/packages/tools/modeling/mesh-combine-studio-2-101956
how big is your environment?
they have a tool that combines all shadowcasters into a single material
which means they know something
did you try to remove project cache?
Temp, Library, .VS, Obj
did only delete library
also do you use Mono or IL2CPP?
Mono
it's a bug in odin
does the scriping backend have an impact on play mode?!
so a script (maybe odin) trying to allocate an object before unity app domain reset
dont think so
90% from odin
try to remove odin from everywhere even in package caches in appdata
you copied shadergraph package to your local asset?
and if you want to update that package?
Odin dictates your components and makes too much coupling to remove
you want to copy it everytime?
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
tbh i can't never go with such unstablity
Too much 😄 I'd just use excel for my data
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
Not the c++!
actually after 2 year spending on cpp i face very small amount of bugs and fuckery xd
modern c++ syntaxes just scare me off
why it looks like a lot to c#
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
C# is kinda going similar way with ref readonly struct etc lol
how can I make a function that is called when a variable value is changed?
expression bodied members
Using properties. Kind of a #archived-code-general thing 😛
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?
look into getters & setters
Also this raycaster is for a top down game, camner aangled at around 75 degrees
are you saying you're trying to make a minecraft kind of game?
or to load what chunks exactly?
what is the game?
Its a top down 3d game
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
i think you're on the start of a long journey
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
I love this series, its been super helpful in texturing terrain but sadly not exactly what im going for
I think ive figured out my problem though
I appreciate the help!
And yes long indeed, Ive made proc gen in the past but never with biomes and humidity
Wish me luck brother
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.
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
You can render lines with a shader using a different render queue, disable depth test, but, terrain must have a custom shader with render queue different too drawing before the lines.
anyone have any tips on selecting the verts/edges/faces of a Unity cube. similar to how it works in say Maya?
get to know the Mesh API
looking at that now.
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
Not big enough to warrent the purchase of this asset. Its already split into 21 chunks. The entire level renders in 30 draw calls. Thats with bloom too. Framerate is not a issue.
very good very good
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
Are you using it to create a bullet?
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
I'm trying to do a parabolic arc to determine if my jump parabola would clear a platform and land on it
oh
but that doesn't seem to be a thing outside of some iterative raymarching-esque approach
yes usually people use a separate physics scene and rapidly solve for those visualizations
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;
}```
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 ?
Changes to SO's are not persistent in a build. I made an asset called ScriptableObject Pro to get around this
same happens if you're using scriptable objects as event channels
persistence issue should happen when i unload every thing or quit the application , right ?
yes
then i'm not doing that
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
Sorry I misunderstood your problem.
an scriptable object asset should work as a singleton through out the project, but it's not
I guess the SO is being reloaded with the new scene
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.
make a seperate go with the dontdestroyonload and hold your SO reference there then use that in both scenes
but now this thing is causing issue in build & fun thing it's not 100% . sometime it works , magically
tried. but same thing . scene is not able to serialize this properly & create new instance of that same asset
And if you hold the SO reference as a static value in a static class?
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)
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
found it & it worked
neat
thanks 🙂
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.
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 
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 
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
UPDATE: This tutorial is a bit outdated and will cause issues if you're also instantiating objects during the game that aren't present in the scene at start.
I've made an update video, which you should watch after this one, here: https://youtu.be/tAbEvzZVz5E
The scripts for this tutorial, including the V2 script for the updated video can be fou...
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 
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
a scene generator i created in unity
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 :]
if you have proximity checks in the the millions you should look into spatial indexing data structures, instead of looping through a giant list
😐 I dont :[
maybe 40 people have downloaded my game? :]
average ccu is 0 and can't even get it rn
:[]
Like SpatialOS or something? xD
Yesh please elaborate i dont know what you mean either
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
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 😦
also replace distance with squared distance, when there's so many checks in a single frame it does make a difference
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
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;
so how do i add the projectile to it?
somehow add its presence?
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
let me check
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
{```
does this help?
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
is there a better website i can paste the .cs file?
that's fine. just gimme the class and line number ¯_(ツ)_/¯
ill look around 1 min
can i add it here? [EnumFlags] public InteractionObject InteractableObjects = InteractionObject.Player;
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.
you can look at the source of blender to get started
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
I am restricted in my approach to no third party assets
i'm just trying to use Scriptable Object as Runtime Data Container while application is running
that is a mistake
what is the game?
sorry didn't get you , what is the mistake ?
so kinda like "player has to do x y z"
are you trying to say a Quantic Dream / Telltale style interactive cutscene?
oh no game. VR object creation using only cubes
you shouldn't use scriptable objects as "runtime data container"s
maybe like what's the big picture experience
or purpose
what is your objective
and as "RuntimeSet", which is explained in unity talks ?
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?
i think that was a bad talk and a bad idea. the platform evolves. sometimes even official stuff is bad
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
i think that was a bad talk and a bad
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
Big picture is for Arc Viz measurements app. Use 3d cubes to define the bounds of real world objects. Use the dimensions of the cube created to return the general size of an object
like for interior architecture?
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
by normals
okay
so you can download one of these assets and study the source
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?
in my experience it makes a cool demo but normal people don't really do "handles" and "gizmos"
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
its a vr experience allowing the client to place measurement object in a space and output the label and measurements to a json file. Those measurements will then be used to create 3d representations of said space
client meaning someone who is trying to decorate their home?
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
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
Doesn't sound like a code question so far... #archived-urp ?
[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
The error above the highlighted one looks relevant
did you restart unity
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 :))
yes
no, it's just the locale package i installed, it's a totally different things
What would be the best replacement for UniRx since that project is not really maintained anymore?
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
You can create custom property drawer
But you cannot use generic for it so you should create derived class
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
You need to create concrete type like class FloatSupplier : Supplier<float> then set custom property drawer
Yeah it’s Unity restriction
I've decided to do MonoBehaviourSupplier<T> and ScriptableObjectSupplier<T> and have a ScriptableObjectSupplierToMonoBehaviourSupplier<T> : MonoBehaviourSupplier<T>

why not having an interface implemented to both?
so you dont need to do this ScriptableObjectSupplierToMonoBehaviourSupplier<T> 👀
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
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
Well you could turn off ZTest from your shader I think.
Yeah BT is superior FSM than Mecanim so I just don’t put any logic in Mecanim. So BT can control all the logics.
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
with the method I mentioned above, you can use SerializedReference to serialize the interface, much cleaner
matter of preference I guess
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?
Well if you didn’t turn it off, entering PlayMode reloads domain and reset all states
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?
I don’t think so, but what kind of async task are you performing? Is it UnityWebRequest?
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.
And your Unity version is?
2020.3.33
So is it only stop working while Playmode or have you tested on Edit mode too?
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
Is the game playing or not when you send request from Editor window?
Yes, it's playing
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
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
Unity does override for SynchronizationContext with their own version so technically they do have control over it
Not enough context still... I've been using async/await in customEditor with zero problems
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
any idea how to blend two heightmaps? they are in float[,] form
adding and then normalizing doesnt work
average either
Yeah I might just try refactoring the system to handle executing API calls through edit mode
Seems that would be a better way to do it
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
It's a C# concept not a Unity one so google for "c# method overriding"
Sorry for unclear question, i just read it and it's totally misleading, found code where person overrides LayoutGroup (unity class) and is doing some cool tricks, i am not talking about normal overrides when i do it on my own scripts, I am talking about overriding unity built in methods and classes
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
sure but that, takes time which i wanted to shorten little bit with good examples
Most MonoBehaviour events are virtual if defined
to improve my imageniation on that way
So you could start from there
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
UI stuffs you could see
https://github.com/Unity-UI-Extensions/com.unity.uiextensions
Contribute to Unity-UI-Extensions/com.unity.uiextensions development by creating an account on GitHub.
But I think your sample code is already from here
Lol.
my example is from unity forum, maybe he took it from here tho 😄
thank you very much ❤️
For non-UI stuffs there is not much things worth overriding. Good luck with your project
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
can someone help?
okay I have a funny question
if you know the dll is there, make sure the build targets are correctly set in the inspector & it's included in the assembly
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
depending on your IDE there should be a way to see a list of all references
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
e.g in Visual Studio
does that actually find all references in unity
i'm searching for prefabs that make use of this script
perhaps I'm misunderstanding what you're actually trying to refactor here
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
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?
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
i did
btw, it worked before
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
so what changed?
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);
}
}
}
}
}
ok, maybe ik why, the assembly definitions
how can i fix it?
Does Unity cache GetComponent now? Or am I better off doing my own caching?
It never did, cache yourself if you intend to access multiple times
Thats what I figured, but I was reading somewhere that they cache it now. So.
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
Perfect, will do then.
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
what are you gaining from this inheritance scheme?
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
Sounds like you're overcomplicating something.🤔
why?
I think this example is a bit too esoteric
oh
I think I got it?
Would
public abstract class A
{
internal A()
{}
}
work?
probably not, huh
Probably not.
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
Why not have WeaponDataType as a property of Weapon?
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
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.
:C
I guess I'll just make a constructor in Weapon that will throw an error on initialization
and override it in Weapon<T>
No clue what you're trying to achieve. A simple Data field/property in the actual weapon class would make more sense imho.
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
Weapons are ScriptableObjects in my setup
whats weapon data then?
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
can't tell from your description if thats smart and necessary or needlessly convoluted for no reason
inside
abstract class Weapon<T> : Weapon where T : WeaponDataType
I have
protected static T _weaponData
it certainly isn't obvious why you'd want to make it that way
this way I have a separate static object for each class deriving from Weapon<T>
why is it a scriptable object?
isn't a weapon something that actually participates in a scene?
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
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
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
i think you are architecting it in a convoluted way
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
how many weapons and projectiles do you have
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
is there like a good way to refactor the type of this variable
you can do something like
GameObject projectileObject => projectile.gameObject;
then inline projectileObject to get rid of the field.
and adding new things should have as little required knowledge as possible
okay but how many
you have to say the real number
so far
it's okay if the answer is 1
1 weapon 1 projectile
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
okay, so you have 6 weapons
but it doesnt matter
I will have more, and I need to make it future-proof
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
I have that, I have 2 prefabs for each type of weapon
meaning instead of "specializing" via generics, use a script
you should have 6 prefabs
it has "bullet" code on it
but it can be anything from a bullet to a laser source
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
will they really? so far I've used generics many times and it's always super useful
that whoever takes this project after me will know this stuff
trust me, the generics will guarantee no one will ever add a weapon
what
yes
why
because it's arcane and adds no value
right now how many people are working on this?
I took the project over from someone, currenty I'm alone, but someone might take it over from me
or someone may join
what was wrong with the way weapons were implemented
when you received it
were there 6 weapons then?
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
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
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
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
and it's very hard to come up with an innovative weapon in this genre
can tyou give me a specific example of two weapons?
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
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
does tmpro support some way to detect when a particular word is hovered over?
yes
a singular word within a longer text on a component?
or hover over any text that's on a component
singular word in longer text in tmprogui component
okay well my final opinion is that if you can't share two example weapons to talk about, it's going to be hard for you to work with other people. i'm another person, i'm trying to work with you, and the feedback is that you're making it unnecessarily hard
i found lots of results in google
is there something about those results that didn't work @vestal condor ?
i think my brain is blanking on some important keyword
because i’m not finding lol
i just searched "textmesh pro hover"
is it the link thing?
it's TMP_TextUtilities.FindIntersecting... methods
i was searching something like “inline gameobject” lmao
hmm
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
there's a method "TMP_TextUtilities.FindIntersectingWord"
all the results have various learnings in them
i wanted to do something like a code block formatting
i think you can handle it from here
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 ?
but can’t figure out how to do this using pure tmpro formatting alone
i assume so
there is an asset store asset for a code editor you might like
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
i think so, but the font assets supported don’t seem powerful enough to have such behaviours
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
hmm, why did you say code block formatting then...
that's called a tooltip
and it's in the first result for "textmesh pro hover"
because i have no clue how else to express the idea of boxing the word
i see
in a thing
to show that it is hoverable
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
right, thanks
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
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
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
alright well i think you can figure this stuff out
in my opinion, you shouldn't be using scriptable objects for this stuff
well, I disagree, it's either that or 10 different prefabs
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
yeah
but how would I make 10 variations of the same weapon then?
I need to make 10 instances of a class somehow
yeah, but why wrap it in a gameobject, when it doesn't need to be one?
you have certain subjective / normative associations with what a game object is
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
I don't think we understand each other
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
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
it's your prerogative
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
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*
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
sometimes that's just how it goes in #archived-code-advanced
I don't see how SOs and that weird construct, you plan on using, related.
I use SOs for data all of the time.
If you want to be able to hold them in the same list just inherit from one type or implement an interface. I don't see a reason to make them generic though. How does it help you with initialization?
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.
Use SO as just simple immutable value structure that you can import as asset
It's nothing more than that
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
https://unity.com/products/vivox Unity bought Vivox which does voice chat
is it possible to write a cameras output to a mesh using a depth shader
you mean modify the mesh geometry based on depth texture?
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
In this 2018 VRDC @ GDC talk, Neat Corporation's Joachim Holmer discusses the ins and outs of the design behind Budget Cuts' portal translocator device, and offers practical insight into the technical implementation of the system, as well as his team's solutions to making it perform well.
Register for GDC: http://ubm.io/2gk5KTU
Join the GDC ma...
@21:54 the first 2 steps are stumping me.
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
I have to give that a try. Still learning so, this may be a bit to start off with
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
@torn basalt https://github.com/alelievr/HDRP-Custom-Passes is this helpful?
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
It's antialiasing I think then, I also had this problem recently
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
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.
- 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 usinglistener[i].OnEventRaised()Is there much difference or a reason to use one over the other?
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
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.
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
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
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...
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...
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...
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:...
Anyways, you answered my question above. thanks.
Thank you for the references but 🤮
Why they want to couple themselves with more assets.
Dead UniRx would be much better than that
SO events are an idea, not an asset (if you don't want to). Its a perfectly fine architecture when used responsibly and is primarily nice because you can editor-assign the event channels. Might not be useful for you, but its very useful for a lot of projects.
You have to create an asset to use SO. That is whole point of SO.
It is static and it will consume lots of time to manage/refactor your system.
You can go ahead and use it all you want, I'll pass.
Does anyone have a method for finding the vertices of a mesh that are within a volume?
how are you defining the volume?
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
pick one
cube
ok so... go through ecvery vertex
most robust
and see if it's within the cube
as long ass the cube isn't rotated it's a simple comparison
You could even use https://docs.unity3d.com/ScriptReference/Bounds.html if you want
kk awesome. what would be the best method if the cube needs to be rotated?
convex colliderr?
yeah, so the idea is some simplistic autorigging. Not sure if rottaing the mesh is an option
not rotating the mesh
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
virtually rotating the mesh data?
yes
not sure I understand that. any reeferences i could look at?
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
kk, word! I'll look more into comparing bounds, as I've never got into it. Thanks for the help!
https://docs.unity3d.com/ScriptReference/Bounds.Contains.html is the important bit
use unirx
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
before i added BarrelMoves() i could rotate my spaceship with mouse. now after adding it i cant do it. why?
are you using the same rigidbody on both of them?
yea
can u use only 1 moverotation for 1 rb?
I guess you need have rigidbody applied on both of (not sure)
because both need to have physics
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
What here does the actual saving?
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
Yuck, BinaryFormatter
ye, im not happy to use it either
You shouldn't use it
You cannot ‘save’ GameObject in scene like that
But that code again doesn't save any tiles
it saves the floor tilemap object
(public GameObject Floor;)
so what am I sppoused to do
How do you place down the tiles?
through a random generation code
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
only problem, doesn't use a seed
What does it use then?
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
Unity's Random is seeded
so how will I change it to be seeded?
It is, you can also change the seed
hmm, just make a varrible that will hold the result of the GetRandomCardinalDirection() result?
No
so how
Give Random a seed at the start, and save that seed
It could be the time for instance
When Unity decides to open
it will take the time and then use the time as a seed?
You can certainly do that
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?
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
should this work - Vector2Int seed = new Vector2Int(Random.Range(0,10000000), Random.Range(0, 10000000));?
Where on Earth did you pull that from?
my brain
Well put it back
You don't know how to use the method from that docs link to provide a seed to Random?
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
You've called many methods before
the function uses A vector2Int and the random gives a float
I'm not sure how code related that is honestly
No, it takes in an integer
but my function uses a vector2int
We're not on about that though
It's literally a method call
just copy and paste it?
Do you know how to call methods?
yes
So call the InitState method from the Random class
It will ask you to pass an integer parameter, just pass it 1 for now
where should i call it?
@shadow seal please help on this
Call it before you load the world
No, did you even read what I said?
Yea, can suggest some other channel
where should I put the result of the init?
Thanks
It doesn't have a "result", the method returns nothing
so put it inside of the random direction method?