#💻┃code-beginner
1 messages · Page 832 of 1
aside of that chunks are used for many other things but I only curious about it
I am asking if anything in world record mob farms related to chunks being meshes
at a certain level (eg. mc) it's not necessarily easy to separate the rendering discussion from the logic discussion
not in itself no
if each chunk is a mesh, well... it explains why half the server were crashing on my base
I got so annoyed that some things were not working evenly ect inbetween chunks that made whole ass huge modpack base in one chunk from the bottom to the top
semi unrelated if you wanna read into more minecraft related stuff someone who works on Sodium (big minecraft optimisation mod) did their thesis on transparency related tech https://douira.dev/assets/document/douira-master-thesis.pdf
you know game is good when someone from Uni making an analysis
Guys i have a 2d platformer game. Can anyone explain me why when I use imput system to move the chatacter (cube) with arrows, the cube trembles against a wall when I keep pressing the button? And i also made a checkground system to control the jump but why when my cube collides with the bottom/side of platform it can still jump? I want the cube to be able to jump when on top of platforms. Last thing, im not good at creating sprites so I ask chatgbt to do this, but I would like to use the tiled function on sprites (basically when you scroll with ur mouse or change the sprite size it repeat infinitely) but chat gbt sprites does not support this. What sprites i should use in order to use tiled function?
that first part sounds entirely unrelated to the input system and sounds more like you're moving it via the transform but it has a rigidbody that is causing it to depenetrate each physics update
How to fix that
move using the rigidbody. of course that is simply a guess since you didn't provide any actual details
Hm ok i'll do that
what is it, I just new about using noise , and then zoomed in to make a chunk in that noise
I used perlin-noise to make it btw. And then it will generate the terrain with the noise
mesh generation
What about the other two issues?
how can anyone provide any answers to any of that without any actual details
For the other two things i dont think i need to be more precise
you need to provide details about your current implementation that isn't working
but i'm not going to attempt to help you now since you don't want to do that so maybe someone else will come along and help with that 🤷♂️
The solution to one of them is "actually put effort into something instead of expecting the slop machine to provide useful output" so there's one
Hello ! I have a small question
playerInAttackRange = Physics.CheckSphere(transform.position, attackRange, whatIsPlayer);
My game is a 3D game, i don't want the sphere to be on the enemy, but rather in front of the ennemy, so that if the player is behing the enemy, he's not detected.
- After looking on the documentation, there is not exemple on how to achieve that goal. I could add a value to the enemy's X position, but it would always make the sphere advance in the same direction...
If anyone know how to make it, i would be very thankful ! Thanks
Make an empty child object of the enemy
Position it where you want
create a child gameobject that is positioned where you would like the check to be in relation to the parent, then use that object's position
Use that object's position
that's a really smart way to fix this issue, thanks ! ill make that :) !
There's also the option of adding transform.forward times some distance to the position, which will get you a position that distance away from the front of the object
how can I access a script and its public variables between different scenes
But, having a bespoke game object for positioning it lets you actually see the origin, so that's probably better
Noted, ill check on that, thanks :) !
ohhhhhh mesh generator
it was mentioned in minecraft wiki [https://minecraft.wiki/w/World_generation]
thanks alot @wintry quarry
Hey everyone, again. So I have this problem with sprite. Inside this black box I use "Grid Layout Group". When I add items in HUD manually it looks fine, but when it comes to play test, something wrong happens. Any ideas?
that happens because you did not use anchored positions for your ui elements
you probably just positioned them on your screen
Hello, i am trying to use the SetParent
Here's the code :
var projectile = Instantiate(attackGameObjectParticle, BeakMuzzle.transform.position, BeakMuzzle.transform.rotation); projectile.transform.SetParent(BeakMuzzle);
The BeakMuzzle is a Transform well defined. But when the attackGameObjectParticle is called... It still has no parent !
Would someone be able to help me ? If you need the code, please let me know !
Have a great day :)
hmm, you'd get an error if BeakMuzzle were somehow getting set to null
When I see no obvious problem, I will start checking my assumptions
such as "is this code even running?"
(it sounds unlikely, but what if you had two places that could shoot projectiles?)
I'd log the projectile's transform's parent before and after calling SetParent
For setparent, you need to refer to the object's transform. BeakMuzzle.transform
BeakMuzzle is a transform
(so, notably, BeakMuzzle.transform.position is redundant; BeakMuzzle.position is sufficient)
have you tried setting the parent in the Instantiate call directly
transform.position != transform
(but yeah verify this code is actually being reached as fen said)
transform.transform == transform
I see, i like your way of approaching issue and i will think of it next time, thank you ! :D
But @queen vale got the last word ahah thank you, it was the .transform issue, it's now fixed !
Agreed, maybe im coming in late but they just mentioned
"(so, notably, BeakMuzzle.transform.position is redundant; BeakMuzzle.position is sufficient)"
i guarantee you it was not that, if it was you'd be getting a compiler error
they said that because it's true
i don't understand what you'd have changed to fix your problem
It's true but referring to setparent, it needs a transform not a position
yes, and BeakMuzzle is a Transform, not a Vector3
you must not be reading something correctly here
you're arguing against a point nobody made
I was referring to the prior Instantiate line here
Oh really, oh, uh.. Weird..
Do you guys want extra information to be sure about that ?
what did you change?
show us the new code
sure. as a sanity check, what's the type of BeakMuzzle
also another thing could just be that you changed the code and triggered a recompile when it hadn't before
I don't mean to argue. I just want to answer the persons question regarding setparent
public Transform BeakMuzzle;
var projectile = Instantiate(attackGameObjectParticle, BeakMuzzle.transform.position, BeakMuzzle.transform.rotation);
projectile.transform_SetParent(BeakMuzzle.transform);
yes, and you ended up trying to argue against a tangential point
B ) and I was right
yeah all of the BeakMuzzle.transform here are all equivalent to BeakMuzzle
it has exactly the same meaning, yes
hello I'm trying to get started with unity I already know c# I've already done winform ect someone has good tutorials or can even teach me a little
on what? that transforms and vectors aren't the same? noone was claiming that
... yet i lacked context.. darn
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
That's so weird because now it does work..
if BeakMuzzle was a GameObject, SetParent(BeakMuzzle) would be a compile error
ty
probably this then #💻┃code-beginner message
or it couldve been edited then tested in playmode by accident before
unity can be set to not reload until you leave playmode, yeah
Ah, maybe... That would be very unfortunate of my 😅
because i was in playmode
yes, i think unity just never took time to reload / i did not save. Sorry for your sanity guys 😅
iirc, unity kinda supports hot reloading in playmode but it's kinda wonky
i disabled that a long time ago
i guess that kinda makes sense
I did it at the beginning of the setup. I think it was AI that write it down by mistake XD
I don't have to use AI at all like even for any code help explanation or an example on how to fix something?
yes
imma be real i don't care
I have to get explanation from AI
so you let the AI think for you, and never actually learn to solve problems?
If you knew enough to be able to fact check the AI's hallucinations then you wouldn't need it.
jn order to actually get my brain to work
you aren't actually using your brain there 😂
learn to problem solve for yourself
you don't have enough problem solving skills to fix all the problems AI is giving you lmfao
It's a pointless tool because by the time you can actually make use of it without completely ruining your project you no longer need it.
People really out there thinking AI has always been the solution lol
Maybe you are rightI dont copy paste thats for sure I dont do it what I do is I see examples, explanations and also do all the research for the specific problem like tutorials, docs and other resources and then write the code.
ok, then keep doing that and leave the bs machine out of the equation
But I cant think how you seniors solve problems without the use of AI. Could you please help me understand? I know about divide and conquer or decomposition breaking problem into smaller parts but what if you stuck completely on a problem what are you doing to solve these problems? Maybe I need some more practice in algorithmic thinking like taking challenges on CodeWars or on any coding platform. I really want to improve problem solving skills.
research
Are you creating flowcharts
slam your head into a wall till it works
class diagrams etc?
sometimes flowcharts are helpful yeah
Instead of reading hallucinated nonsense from the plagiarism machine, you can just... read the data it's stealing from
far from perfect but just an example of something i've made in the past incase it helps with inspo
just ways to visualise thoughts
Its called System Design or Technical Design right?
you know how once you get proficient with math, you can do additions and multiplications and stuff in your head without needing scratch paper?
that happens with problem solving too. you might see people just thinking for a bit and giving a solution, they can do that in their head because they've practiced a lot, enough to be able to do that. start with writing your thoughts out, see what gaps are there, research
drop the buzzwords
just start doing
I have made flowcharts and technical design diagrams
those formalized systems help make it more efficient or effective, but they're not going to help much without just the base experience of problem solving
the problem is you know I dont do the right think when it comes to decomposition
I think I am not taking the right steps in breaking the problem into smaller parts
that's normal
I am not doing it the professional way instead of typing immediately I think I have to write first the logic etc on a pseudocode and then actually apply after yeah writing all my thoguths
thoughts
go back and identify them, and see where you can improve
the professional way doesn't matter at this stage
Maybe I need more math knowlege?
Because I wasn't good in maths
in school to tell you
you need more practice
XD
You only know what all you can do the more that you understand the tools that you have. Once you know what is available you can combine different things to find a solution.
is what your doing involving math?
Game Math is something relevant in our industry
you don't need more knowledge
I assume I need Linear Algebra, Boolean Algebra, Calculus, Discrete Math
if what your doing doesn't involve math, then not knowing math is not your problem
i barely know any math lmao
you need those to make stuff. you don't need those to do the actual problem solving
Math actually help you think as a programmer
if you are good in maths then I think it will boost you up
if you know 0% of those, but you can break down the actual problem into needing those, you will have smaller pieces that are easier to research
in problem solving anything
yes, that's with experience, not raw knowledge
just reading 50 wikipedia articles is not going to do anything
doing math problems is a form of practicing problem solving, just as doing phyics problems or what have you
One of my professors told me if you dont study maths in computer science you will be just good in programming not professionals.
and if you refuse to actually go do anything you won't be good at all
i've told you several times
you're in decision paralysis
go actually do stuff
discussing is not going to help
I hope your professors aren't as bad as you describe
you're currently debating how to learn problem solving
rather than solving problems
How to practice Problem Solving and DSA the right way? That's the question.
Algorithmic thinking
by solving problems
Yes but what problems?
problems found in what your making
not random?
What does your game need? What isn't working? why isn't it working?
work on a project and you'll find some
I am not treating anything as a write only. I just want some guidance because I think I am confused. Are there any resources you could provide maybe?
you just gotta work on stuff
bro ive said so many things and you keep asking the same thing lmfao
The tower of Hanoi
i would not recommend that tbh
It's a problem. It needs solved
it's a very specific instance of "problem solving" with a specific solution
That will help me to improve problem solving XD
Its not even a coding issue
it's going to give practice for that one specific use
It's an example moreso than practice. You've all already mentioned practice by doing
Youre asking a question so vague, the only answer you could get is vague. No one knows what problems you struggle with, nor what would be beneficial for you specifically.
so I figured, give an example.
i don't think there are reasonable examples to give here ngl 🤔
🤷♂️
There are many websites that have problems on them, like leetcode or whatever else is popular these days. If you want to learn common algorithms/graph theory/math problems you'll find all you want there.
You will rarely ever actually use these algorithms
I mean some people are really genius in programming and problem solving I mean I think they have a talent by the nature. I dont believe a lot in talent but it exists, and its actually genetics given by nature.
ive gone through that. it's 40% interest and 60% practice.
leetcode or neetcode maybe or codewars for example?
anything right doesn't matter ?
at this stage, most likely not
If you keep thinking you can't learn, then you never will
I am not a beginner.
i'm... aware.
I used a site thats basically local to my area. Just find something you can reliably use and learn from. I didnt like leetcode cause the paid stuff got intrusive at a certain point
I have coding experience and with Unity as well the problem is that I want to improve more my problem solving skills and DSA basically how to use Data Structures properly with Algorithms and actually improve.
you improve by "using data structures with algorithms"
"problem solving skills" and "DSA" are not that closely related
I've been a hobbyist for a decade and still think of myself as a beginner lol.
You learn to solve problems by encountering a problem, and researching the solution.
But is it worth it because you waste your time and actually you dont build something valuable?
i think you need to focus way more on just the "problem solving skills" tbh
You don't build portfolio
Do you want to learn or not
is school a waste of time
is uni a waste of time
Yes.
is pregnancy a waste of time (for the child)
yes
First you say your goal is to learn. Now youre asking about a portfolio. We're in a unity server too.
If you dont know what you want, go figure it out
give that fetus an ipad
maybe for you, since pregnancy is when the brain develops a lot
-# i intend that as a joke, just saw the opportunity...
you keep tacking on random shit that's completely irrevelant to the actual topic at hand here, which is practicing problem solving.
the specific problem you solve isn't going to matter that much at the stage of just decomposing issues
solve math problems if you want, 3b1b has a ton. the focus will not be on specific topics, but the actual problem solving
problem solving is an experience skill. all those others you're worried about, dsa, math topics, are knowledge skills
i lack in the knowledge dept. 
Iam aware that I have to practice my problem solving skills, but my point is to practice them by building portfolio instead of just taking random problems on leetcode or whatever platform there is because at the end of the day you will have to land a job maybe on an indie game dev studio or even on AAA studios when the time comes of course with the use of Design Patterns and all the solid principles which are really helpful.
you are worrying about distant, barely-existant problems
it's like you're trying to make an art portfolio and worrying about Official Color Theory™ with perfectly curved lines and professional techniques despite barely drawing. that's what it sounds like to me
ah to hell with this. it's not like you're going to actually read any of this
I read everything bro all the time, I don't know what you mean
When you see I ask the same question or maybe don't reply on any of your messages doesn't mean I dont read them. I just have my own concerns and keep repeating. Anyway, thanks for the advice I'll see what I can do.
@sage mirage I know others have reiterated on this point but if your current problem is you don’t have a set of problems to solve in order to practice problem-solving with code as a skill, then just try to make something small yourself. Problems will arise. You will need to either solve them or give up. If you choose the former it’s how you practice and learn. But endlessly debating and talking about it won’t get you there
When I double click a script in Unity it automatically opens to the purple Visual Code Studio. However, I only have the blue Visual Code Studio set up for Unity coding. How do I get it so it automatically opens to the blue Visual Code Studio?
the purple one is called visual studio, the blue one is called visual studio code
you can change the selected external editor in project settings or preferences, one of the two. i forget
(preferences > external tools)
Thanks
If I wanted to get a job as a sculptor. I wouldn't put my first sculpture on my portfolio.
Hey everyone, I am currently trying to set up a basic enemy AI that has two modes:
Wander (goes around the map randomly trying to find the player)
Chase (chases the player while they are in sight, if losing sight it does smart checking to figure out player location).
Does anyone have any good resources I can start with or advice where to learn mroe?
Id go about it by having it have two modes:
- try to find player in some radius and check line of sight. If hit go to:
- follow player and try to attack them. If player leaves some radius, go back to searching.
For the player chasing, are there any built in algorithms such as A*? Will the AI by default detect objects in the way?
Thank you for the recommendation by the way
AI is vague and means many things
Unity offers the nav mesh system which can be used to route to some goal with ease
Learn more with this course: https://learn.unity.com/course/unity-for-artists-curricular-framework-resources/tutorial/unity-navmesh
Learn how to create AI pathfinding using the Unity NavMesh components!
This video was produced by Brackeys.
A* (THE ASSET) is really good but the free version is kinda pointless imo
so stick with what unity gives you for now
(also A* is an algorithm anyone can re implement for free)
I do have a lot of programming experience, it is just my experience with Unity development that is lacking
im aware, i was refering to the popular third party asset that integrates it
Ah then disregard that. If you are aware of A* or other similar DFS/BFS algos then you can also implement these but thats extra effort but may fit your use case better.
I know ive heard of it but A* is not that
Yes, the coding is not the issue, I am just looking for Unity methods. I will look into NavMesh more.
Thank you both!
https://youtu.be/l8ADGZTwhmk?si=Y4NTMzjkZT893YGi
fairly comprehensive tutorial using navmesh
Hello fantastic people!
In this video I show how to create a simple but effective enemy AI for a 3D game in Unity.
Even though this tutorial is horror-themed, the same techniques work perfectly for many other types of games.
We build an enemy that:
- patrols between points
- detects and follows the player
- attacks when in range
- returns to ...
a* project has 2D pathfinding tho unlike unity's
pretty sure that's included in the FREE version
there are packages that make navmesh work in 2d too but yea its a dumb limitation
also includes more baking options besides a poly-navmesh such as a grid mesh
which is better for games like tower defenses since easier to add restrictions to the indicies that occupy square units
Thats cool but ive always done A* myself for node based systems
I'd say something.. but idk the A* algorithm, aside from it finding the shortest path
Yeah nodes are fine, and you can get a lot of precision at the cost of more mem, but still a little screwy when you do want to create precise zones to prevent walking.
Oh yea they only work well in some situations
how do you make it so that the camera follows the character as he moves around on the map?
multiple ways, most tutorials use cinemachine (for 3D)
Depends on 2D / 3D but brackeys got some tutorials on it.
can anyone look at it?
Can you expand on "when it comes to play test"?
Why is there a second knife?
First one is to show how it's intended. They share same parent.
By playtest I mean picking up item in the game.
Grid Layout Group supposed to make them all same size
but for some reason it does something to sprite
That's what concerns me
Oh wait, I found the problem, for some reason it changes "InventorySlot" scale to 1.666
I guess, that's because my "Stack" is outside it's parent's bounds and when I create a new copy of this prefab, Unity tries to fit in all item by scaling up parent. But my number is anchored to the right corner so that does not help
testing it rn
nope, it's position doesn't matter
Then, I have no idea
It's easy to fix, and I already did that, but just wonder what's nature of it.
The prefab is the inventorySlot, and the slot is what's being scaled by the grid (iirc)
but grid does not change scale
grid doesn't no, but it shouldn't care about the slots children, just the scale of the inventorySlot itself
yeah
Anyway, I don't really wanna figure out what's the problem rn, gotta get some rest
ty anyway
Sorry : / , sleep well
Hello guys
Im sorry if its not the right channel but it's kind of an emergency
I was testing my game and all of the sudden, it broke. It can happen but here, it's like if everything rollbacked to like 8 hours ago
i lost a lot of progression, some bugs that i fixed came back, some part of my model that i deleted / added got reverted to this morning...
It's like if i opened an auto save... Without really wanting it.
I just pressed "F9" while playtesting my game to record, and went into override > apply all before starting the game because i never did it with my playerCharacter
everything just... Vanished...
Like if i restored the player's prefab from 8 hours ago
Script got removed, everything is glitchy, the error "Unnassigned reference" is spammed...
This will take whatever fields you have set on the current instance and saves them to the prefab
Was the prefab the only thing that was changed? Because it seems either you overwrote something or just never saved it in the first place. Unity doesn't do auto-saves.
I think that i've made a lot of changes to the player without applying them to the prefab and when i finally did.. It, like... Broke everything
Hey
I'm trying to implement a simple dialogue screen with a png as the char,
Currently I'm just using a canvas and an array of objects that has 1: the png, 2: the text
is there a more suitable way to do this?
depends how complex you want to get...
also there are more out-the-box solutions that might do already everything to add manually. One good one is Ink(free), or yarnspinner (paid)
So it also broke my AI's that were perfectly fine and always saved...
It reverted their particles and sound to null like hours ago
words cannot describe my confusion
And now, m afraid it will happen again
did you perhaps check out a previous commit in the version control you are surely using?
or are you perhaps storing your project in some cloud sync path like one drive?
Well, i actually used to use VersionControl, but i no longer do it since yesterday, i deleted it..
And i dont, i installed an autosaver now but im so sad
what has encouraged you to not only stop using version control but delete your previous commits lmao
i no longer do
congrats, you've just learned a valuable lesson on why you should always use version control
The infamous infinite domain (busy for 8:12) glitch
that's not related to using version control . . .
I think it is, a saw it on forum and when i removed version control it finally removed this bug !
everyone should be using version control
And not necessarily UVCS
always use version control. whether it's git or unity version control, or some other actual version control software, you should always use version control
or else you end up with situations similar to this where something has broken irreversably in your project and you cannot revert back
But some sort of version control
if nothing else, just use a local Git repository to checkpoint your work
I trust you guys on the importance of using version control.. The only reason i removed it was because it almost added 8 minutes of booting everytime i started a playtest...
I added this plugin : https://assetstore.unity.com/packages/package/43605
If you guys have any suggestion of great plugins / version control i can use without this glitch, i would gladly take it :')...
This is my Unity version, btw..
github desktop
i have no idea how having Unity Version Control present would slow down entering play mode that much
Personally I would just remember to save, rather than getting an asset for it.
I save so often I'll Ctrl+S periodically on discord
note that remembering to save and using version control are two completely unrelated things
pressing ctrl+S regularly doesn't stop you from deleting something important
I have no idea too, got UVC during one month, got that glitch for one month. Removed UVC, got the glitch removed
But i mean... Ill try to add UVC back then !
I just uuh i-
oh alr
You could also just use git instead
As a suggestion, a lot of people prefer it over uvc
And issues like this dont really happen
Alright, i will configure git with a tutorial then, thank you very much !
Well i also putted UVC and i already have the glitch
It sometime take 8 minutes just to compile when there's UVC, definitly a weird glitch. But i did put Git
I think i understood what happened
i put "ctrl" in my game to run and i think i did things like "ctrl + s" or "ctrl + z" while in game and it broke something
I just got the exact same error after playtesting : got hit by a rollbacl
How would I implement currency into my game? Would I just have one big script to handle it all? And how do I know what is on the client or the server?
implement currency
this is vague as hell
Generally, you probably don't want to handle the logic on the client at all. It shouldn't do anything beyond displaying the data from the server and making usage requests to the server.
And honestly, if you're struggling with such questions, perhaps it's to early to do multiplayer..?
I meant what logic runs on the client vs server
e.g. If I put a script that does x, would it be running internally on client or server?
I haven't implemented multiplayer at all but I'm assuming you store each player's stats in a table
It depends on what networking framework you use and how you implement the script. Normally everything runs in any build - both the client and the server. You should probably go over these before even starting to plan your multiplayer game.
I wonder about multi level world generation, is it based on how many tilemap layers(with different Z level & sorting order) you have?
I made multi layer noise with perlin noise, heightmap texture, perlin worm, spline shaping, using mesh world generator method (similar minecraft).
But the world generation seems cooked, no multi level like 2nd, 3nd picture
I don't have any network framework
Well, then there's not gonna be any multiplayer. No need to worry about that part then.
How would I implement it?
perhaps it's to early to do multiplayer..?
💯
Do you really expect a reasonable answer to that question? It's basically the same as asking "how do I make a game".
Implement what
The obvious answer is "you learn it, plan your game with multiplayer in mind, select the right framework, integrate it based on what you learned, docs and tutorials".
What's a framework to start off with?
Probably the solution that unity provides - net code.
But again, I think this is too early for you.
Even this question kinda reveals it. You need to start looking up/researching stuff on your own. You could easily Google for what frameworks there are, read about their pros and cons, but you didn't do it and just chose the lazy way. That means you're not ready for networking as a developer yet.
I'm asking a reasonable question in a discord server about the literal engine itself
How am I supposed to know without any experience?
You can't expect every developer to know what to ask like they are Linus
You're expected to be able to do minimum Google search. You were already provided with the right keywords many times over.
I'd expect a half helpful answer in a server about it
Most of this can be Googled as suggested.
We're not here to spoonfeed you or provide you a ready solution. We're here to help you grow as a dev. If you expect someone to do everything for you, perhaps this is the wrong server.
Neither are we a replacement for Google.
And also, no. Networking is not "about the engine itself" it's a general gamedev(or even software engineering) concept. And a pretty advanced concept too. Unity does provides tools to implement it in your project(which I already mentioned), but there are many other solutions. And regardless of the tools you use you need to learn the general concepts first.
I was asking what the scripts run on behind the scenes
And I answered it, didn't I? They run on the machine that runs the executable.
There's no separation between a client and server by default, unless you explicitly implement it.
That's assuming I don't run multiplayer
There's no custom script type you use for this? Or do you need to use a networking framework for that?
There's no script for that by default outside of what the dedicated frameworks provide.
Ok
for some reason when I add an image to a sprite renderer only part of the image appears, what causes this. also the image is not fully connected, although all the components save as one. Could this cause it for only one individual component to appear on screen?
collider.bounds.center
is there like a way i could have another version that goes for the top of the collider?
my options really only seem to be like max, min, center, and thats about it
get the y value of the extents then add that to your center
Do you guys have any ideas that use mesh generator, perlin noise, perlin worm, and heightmap texture to make world generator in isometric 2.5d ?
i was only use perlin noise to make world generation but it was... flat
yesterday i knew about mesh generator and about minecraft world generator was using it with multi noise layer
to make world generator
so i try to make it
but now it only generate mesh terrain instead of tiles
There are various procedural mesh generation algorithms. Some generate smooth geometry, some voxel based, some cube based, etc...
thank ye
never used collider.bounds before so it was a lot of experimenting and failing\
void GatherInput()
{
_frameInput = new FrameInput
{
JumpDown = _jumpInput.WasPressedThisFrame(),
JumpHeld = _jumpInput.IsPressed(),
Move = _moveInput.ReadValue<float>() * Vector2.right
};
if (_stats.SnapInput)
{
_frameInput.Move.x = Mathf.Abs(_frameInput.Move.x) < _stats.HorizontalDeadZoneThreshold ? 0 : Mathf.Sign(_frameInput.Move.x);
_frameInput.Move.y = Mathf.Abs(_frameInput.Move.y) < _stats.VerticalDeadZoneThreshold ? 0 : Mathf.Sign(_frameInput.Move.y);
}
if (_frameInput.JumpDown)
{
_jumpToConsume = true;
_timeJumpWasPressed = _time;
}
}
NullReferenceException on _frameInput
Is it possible to display something like that in inspector?
Yeah, just make it serializable
Stats1?
ok, let me just ask straight, how?
Tested, that worked
thanks
You better use System.Serializable to be sure that you are using the namespace.
the monobehavior there doesn't need to be marked serializable for this btw (unless you need it for something else)
Hey, guys! What is the best way to actually assign game objects and componets etc at runtime? Is there a Design Pattern that is really useful in this case? Let's say we have two scenes title and main and you have to do dont destroy on load and then at runtime assign game objects or components? Personnaly, what I do is to create bridges between the Manager class that lives on the first scene loaded and bridge this class with a class that lives on my other scene and attaching the components or game objects at runtime like this
For example
I was wondering if there is more efficient and probably reliable way to handle assignments at runtime when persistence is needed thats the question. Thanks!
I would just avoid persistence between scenes completely
what do you need persistence for?
So, if you were in my place you would just use duplicate Managers in all scenes you have?
thats actually exactly what I do
That's not efficient at all personnaly thats horrible
No you dont have to
Having two game maangers, two ui managers
two audio managers
Hey guys any YouTuber who makes good tutorials for beginners? For c#
thats duplication it break single responsibility principle
I have a prefab called game manager and on that I put the main game manager and other submanagers, that prefab is present in every main gameplay scene. And to avoid repetition I use scene templates.
Why would you need a secondary audio manager
You create an Audio Manager, Game Manager and UI Manager and you are persisting them across scenes thats the efficient way I think
just make a script that works for all cases. Shouldnt be too many
Who said anything about two?
You just have one per scene
During that scene lifetime
Bro when you change scene everything in the previous scene get destroyed
DDOL
The other guy says he is going to create more than one of the same managers
Managers should be 1 and only one in the game
You missunderstood me
I said I duplicate them in every scene, like copy from one scene, paste in another
not that I have multiple in a single scene
well, I don't actually have to manually duplicate anything since I use templates and prefabs
I assume the problem is switching scene and some variables become unassigned, destroyed with previous scene, and now you're assigning newer values that are scene dependent
which in that case you choose not to use DDOL, and just recreate that manager in each scene, but the static accessor stays the same, or just search the scene for the require components (or via another manager), or have those scene dependent options assign themselves to the manager via static call.
like you can recreate the singleton in each scene which is fine. This allows you to go on the editor and do direct assignment
audiomanager though may not be ideal as you do usually want some cross-fade music, and similar type of managers that do fade between
Yes thats what I mean you are copying them thats also bad practice
Managers must be its a "MUST" only 1 of the same type in the game.
singletons can destroy duplicates
that's the entire point of that Destroy in the singleton pattern
you mean DDDOL?
it's not the only solution
yes but my question was and how this conversation started
yeah, thats still the case
the question was
@undone rampart said I copy managers across scenes
(Most people probably wouldn’t recommend this)
Bro that's super inefficient and doesn't cover my question
There is a thing OnSceneLoaded
So whenever you change a scene you can also assigne references at runtime
I did it with scripts called bridges
My final point was if you don't use DDOL, then the managers get destroyed and initialized within the scene's lifetime, that way you don't have to worry about cross scene initialization and references breaking
I feel like yall are ignoring most of the things I am saying
You mean MainSceneUIRefs and TitleSceneUIRefs?
yes
it's structured like you're trying to use this as an abstraction, but you still have that tight coupling there
but i was wondering maygbe there is a design pattern that is really useful
or anything
a structural design pattern
I think
stop worrying about design patterns tbh
they'll pop up if they're useful
not everything needs a fancy name
That's just a way to communicate with programmers
Design Patterns are common solutions to many software design problems and thats why I am asking if there is anything to this one I am dealing with which in fact is a structural issue.
You can try the Core Manager Hierarchy I came up with that I mentioned in this thread #1488843522747531326
This graph shows the structure of it
Starting with every scene containing everything they need to run as a baseline to then add complexity to if needed is not the worst thing you can do.
I dont think thats a good architecture diagram. Game manager doesn't have to manage other managers. Each manager is responsible to manage specific tasks and not only Game Manager should be a singleton I assume.
Player Manager is actually player controller or something?
its not a manager
The arrows point down not up
Why are you taking everything I say backwards 😂
The arrows represent a direct reference
The GameManager is the root
it's perfectly fine for some systems to be repsonsible for others
Each node is responsible for its own logic
Audio Manager handles audio everything related to it, UI Manager handles the whole UI, Settings Manager handles settings of the game, Game Manager handles states like game over, ennd state. I mean the duplication thing you said with managers bro thats horrible and my quesdtion was about efficient ways to handle assignments at runtime and that wasn't really helpful, but anyway it is what it is.
Bro...I just said I am not duplicating anything in the scene
You don't want any rigid game design diagrams or patters in game dev. Each project requirements can be drastically different. You should only go by general philosophy to break down complicated pieces and responsibilities.
It's mostly trying things and refactoring, actual structure can drastically change depending on changing features etc.
Yes it is but not when it comes to managers I think because a manager is on its own responsible for himself and for other classes maybe there are dependencies on managers as well like you can think lets say a Controller Manager that handles Player Controller and AI Controller maybe yes.
efficient ways to handle assignment is just do it on the editor if you can
all of the design patterns in the world won't do much if you do not actually make a game
to quote Joel On Software from back in 2001...
When you go too far up, abstraction-wise, you run out of oxygen. Sometimes smart thinkers just don’t know when to stop, and they create these absurd, all-encompassing, high-level pictures of the universe that are all good and fine, but don’t actually mean anything at all.
And it's much more important to know with what purpose certain design pattern was created to solve what problem, than to know how to rigidly implement it. Because you often need some elements of it and not others.
in my own game, I have a structure like this:
GameControlleris the god-object. It is a singleton. It bootstraps itself on game start and is responsible for switching modes (e.g. from the main menu into a gameplay scene).- Each scene contains a bunch of
*Managercomponents. These are singletons as well, as you can only be in one gameplay scene at a time. They are thrown out when you switch scenes, since none of their state is allowed to survive from scene to scene.
1# ControllerManager is created each scene and PlayerController is referenced directly referenced from the editor in each scene
2# SceneManager (unique per scene) has reference to PlayerController and assigns it to ControllerManager on Awake, or through GameManager entry point call.
3# PlayerController on Awake assigns itself such that ControllerManager.Instance.SetPlayer(this)
You should implement code that does what your game needs.
I didn't create VisionManager because of some kind of design philosophy or grand plan. I made it because I needed a way to gather a bunch of visibility checks together so I could run a single giant RaycastCommand and return the results on the next frame.
er, well, that's not quite right; that's VisionSystem 😉
I like doing GameManager entry point assignment where on sceneload the GameManager fetches all static scene accessors and does assignment.
I don't know how some people don't have an idea of Design patterns they actually write implementation of a pattern but they dont even know what is this implementation XD
I do this ^^^
It's very common to have multiple managers in a scene, so this tree makes it easy to reference those managers without having to manage and remember multiple singletons.
I have a friend that is a programmer I told him about Design Patterns and he said what are these stuff that are you talking about
It happened to me, I learned events and started figuring out that I can decouple a lot of stuff by using them, so I did the observer pattern without even knowing about it
i don't think about "design patterns" consciously, but I certainly design my software
I don't think "time to use the observer pattern!"
I think in terms of what will not cause race conditions
and most proof concept is just have a manager entry point
A lot of us use "design patterns" without even knowing they exist
There are in total 23 Design Patterns all of them categorized in 3 types Creational, Structural and Behavioral of course with their pros and cons as well and they are used in different scenarios. PErsoannaly, I do think about design patterns I want to implement because I dont know a lot for now only State, Observer, Singleton and object pooling
I think we need a special "architecture & design patterns" thread
That would be cool if there was a channel specifically for game architecture and design patterns and these stuff.
I think you can just create a thread in #1390346827005431951
24/7 chat of debating what dependency injection really means
it sounds like you just read a blog post about design patterns and now think everything is a nail that this hammer needs to be used on 😉
there are absolutely not a specific number of "design patterns"
DI is when you get things
float Add(float a, float b) => a + b;
Behold, DI!
void GatherInput()
{
_frameInput = new FrameInput
{
JumpDown = _jumpInput.WasPressedThisFrame(),
JumpHeld = _jumpInput.IsPressed(),
Move = _moveInput.ReadValue<float>() * Vector2.right
};
if (_stats.SnapInput)
{
_frameInput.Move.x = Mathf.Abs(_frameInput.Move.x) < _stats.HorizontalDeadZoneThreshold ? 0 : Mathf.Sign(_frameInput.Move.x);
_frameInput.Move.y = Mathf.Abs(_frameInput.Move.y) < _stats.VerticalDeadZoneThreshold ? 0 : Mathf.Sign(_frameInput.Move.y);
}
if (_frameInput.JumpDown)
{
_jumpToConsume = true;
_timeJumpWasPressed = _time;
}
}
Anybody can explain, why recieving NullReferenceException on _frameInput, if it's created there
Which is the line you are getting the exception from?
New frameInput. 3.line
!code so we can see the line numbers and what is the exact error
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
If you get an error when creating the frame input it means something inside the object initalizer is null
so either jumpInput or moveInput is null
(pedantry time: that's the object initializer, not the constructor!)
but yep, that's spot on
importantly, this kind of thing would not cause an error
var foo = new Bar() {
thingy = thisIsNull
};
(assuming thingy is a simple field, of course)
the mere presence of null is fine; trying to access a member of null is what causes problems
1 frame before my character spawn something in object is null?
Share the entire script and then show us the error message, so that we can be sure what's going on
Whenever that line of code is executed, either _jumpInput or _moveInput is null
Quick question is this the "proper" order of things:
// 1. Enums / Nested types
// 2. Constants / Static fields
// 3. Serialized fields ([SerializeField])
// 4. Private fields
// 5. Properties
// 6. Events / Delegates
// 7. Unity lifecycle (Awake → OnEnable → Start → Update → FixedUpdate → LateUpdate → OnDisable → OnDestroy)
// 8. Public methods
// 9. Event callbacks (OnCollision, OnTrigger, UI handlers, etc.)
// 10. Private / Helper methods```
Order for what
no, because there is no "proper" order
as with all things related to code style, if you're consistent with it then it's fine
Oh awesome. Thanks!
I noticed that when I am more consistent with how I order stuff, it makes it easier to learn and debug.
So, if there was a recommended one or something I'd just follow that. But seems like I am fine with what I have 🙂
there are several recommended* ones as set by like, companies for internal consistency, and you could use those
-# * recommended as in, within the company. outside it's just a set that definitely works that you could use so you don't have to figure it out yourself
lot of languages usually want some type of method declaration at the top however
c# dont care tho
I do sometimes interleave fields and methods, but only really for "debug" stuff
so that it stays out of the way of the normal fields
a lot? i know of only c and c++ that would do that, though i'm not very familiar with lower level languages
wait no, c/c++ also don't care in a class
this only matters in languages that require you to declare a symbol before you use it
e.g. HLSL or C
well, header files help prevent the compiler complain about those issues
hmm i kinda have conflicting thoughts on this comparison
but yeah, 'most' languages could be reduced to mostly lower level languages today
this is within a class, and afaik, no language has this kind of requirement for classes? only some for free functions in eg c, c++, python
and the free functions one i feel is a different situation
i guess c# does indeed also not care for local functions, but i feel like that's not relevant to the specific topic at hand
The general pattern I see and use most often is loosely:
- private/protected fields (serialized or not)
- public fields (if any) and properties
- Events/delegates
- Common Unity lifecycle/event methods/ “callbacks” (Awake, Start, OnEnable, OnDisable, Update, OnTriggerEnter, etc.)
- Class-specific methods, loosely in descending order by how common or core they are to the script.
- Less-common/core methods and helper/utility methods.
But this isn’t some “correct” order. Just what has seemed to work for me and most of the people I work with.
But most important is just to try to follow some general format across your scripts so you don’t need to recalibrate your thinking every time you look at a different script.
I forgot to put const/statics in the list there, but usually those will go near the top as well. Don’t have any hard rule there though.
eh while we're sharing, i had this mess for one of my projects lmao
My code order:
Wherever it goes, it goes
(You shouldn't be writing code so long you need a style like this, IMO)
you do have a style, maybe you just haven't written it down :P
that's the punchline
if you start having to think really hard about order, something has gone wrong!
not that I'd ever write a monstrous 1000 line long class
no sir-ee
oh i didn't have to think of it for myself, but i realized it was kinda convoluted so i formalized it for someone else who was offering help
Still having some sort of consistency is helpful even for short scripts. It’s really irritating to find a critical field randomly among method definitions even in a script that’s <100 lines.
Like Fen mentioned earlier it’s fine if that field is just used for debugging or something so you don’t really want to pollute the “header” area of the script with it, but if it’s a field that’s critical to the class it’s annoying to find that whoever made it just placed its declaration in some random line in the body of everything else.
I do try to put all the fields at the top
roughly grouped by meaning
(since that order affects what you see in the inspector!)
thats a new one
:loudspeaker: Collaborating and Job Posting
We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
• ** Collaboration & Jobs**
Is this the chat were I ask for help and therapy? I'm losing my mind with a bug
!ask
:thinking: Asking Questions
:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #🔎┃find-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.
-# For more posting guidelines, go to #🌱┃start-here
Idk why but when I reload the scene its not initialized properly. I tried debugging for persistent objects but nothing came up
save the scene before entering play mode. when you load it via code again it loads whatever was actually saved to disk
I'm guessing I can ask this here. (I hope)
I have a Stack Camera, but I haven't prepared for it in-code. I have a Dynamic FOV thing and the stack camera doesn't inherit the FOV of the Main Camera -- Can I make it so the stack camera inherits the FOV automatically or do I need extra code?
huh?
what about that is not clear? your scene is not saved, you need to save it
I do save it, like hitting file and save I do that
it was clearly not saved in the video you showed
having an asterisk or a dot beside a filename is an indicator that it's unsaved
make sure that asterisk disappears when you try to save
if it doesn't disappear, you didn't save
oh I see, sorry. The issue still persist tho
you should describe exactly what the issue is, because if you've saved then it is loading the scene as it was set up. so if something is going wrong then something else is the issue
Hello guys, I need help. How do I define the position of an object and instantly update it via a script, so, for example, location = 0 is pic 1 and location = 1 is pic 2?
hint: take a look at the Transform class
but also consider going through some basic courses, this is like one of the very first things you learn how to do
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
hello any one help me with this i just started unity some days ago and im getting this error after i try to make my buttons
also this happened after i added
public
Like this
public void singleplayer()
{
SceneManager.LoadScene("Game");
}
also my ui is messed up after that
this is how I reset my player, hope this helpr. // Reset player transform exactly
if (player != null)
{
player.transform.position = new Vector3(-6.54f, -0.02f, 0f);
player.transform.rotation = Quaternion.Euler(0f, 0f, 0f);
player.transform.localScale = Vector3.one;
im guessing player is the name of the object
the tag
hes right tho, theck out documentation on the transform class
player in that code snippet is the name of the variable
restart the editor, just looks like an editor bug
yeah -- if you see "UnityEditor" in the error, it's probably not your code
and most of these UI bugs are fixed by either:
- restarting the editor
- resetting your layout to one of the presets (there's a dropdown in the top right)
the latter will help if there's a window that has somehow wound up with invalid data stored in it
Thanks you
I fixed the problem by updating the unity version Control in the package manger
hello everyone. I've got a little problem. I have this app imp building in unity where I generate some trinkets and they're supposed to fall on a littl platform. works perfectly fine locally, but they fall through that floor on a web build on Play. is there a common issue I need to be aware of when deploying to Play?
You migjht have framerate dependent code, or you might not be moving your objects properly via the physics engine, or you might not be using the appropriate collision detection mode.
Okay. I'll look into those possibilities
ik, was testing usage of this tag
if you share your code and how your objects are set up here, we could potentially help you identify such issues
Hi guys.
Im currently remaking my isometric world generation so i have a question, so when i make multi level terrain, i set base tilemap layer height is 10 (in the image) , and make a world generation, it will generate a flat world
but when i use perlin-noise to make world generation , it will generate to this image
so the question:
Do i need to make a function that auto generate multiple tilemap layers to make it like 3d terrain? or just use 1 tilemap , and then change the height of the tiles
this stuck in my head for days
Changing the height of the tiles seems like the obvious solution to me. 100 layers = 100 tilemaps is crazy, not to mention having to then communicate between them if you're moving along the surface of the terrain.
The only headache I can foresee is that it'll be hard to actually figure out which tile you're clicking on
You can't just map a screen position to a grid cell anymore
since the cell you hit depends on the height of the tile
this also means that you can't change elevation by more than 1 unit at a time
"100 layers = 100 tilemaps" , yea i was thinking about this , that why i have to remake my world generation.
i was thinking about change the height of the tile solution too, but thinking about the logic is easy but do it in 3d isometric is
kinda tough 🙁
thank you two for giving some solutions
is there a way to make an animator have an event from a script that isnt on the same as the animator component?
im trying to crunch down memory usage as much as possible and i cant have mutliple of the same script on different objects, its inneficent
No, animation events have to call a function on the object that animation is playing. Having a small component that just fields the event functions is fine?
mk, if i have to then ig i have too
Why do you think you need to do this?
im using an OLD version of unity 5.6.6f2, because im using unityfor3ds to well, make games for the 3ds. and the 3ds is very limited with memory. so im trying to limit the amount of scripts i use a scene
seems like the memory of the animator itself would overshadow anything like that
hm probably, i should also look into that
do some profiling, see where the memory loads actually are, rather than going after small details
an animation component would probably use less memory given that it doesn't have to keep track of layers/states/transitions/parameters 🤔
though also the assets themselves would likely be significant memory
<@&502884371011731486>
not a place for AI-generated advertisement spam
damn straight for the neck 🤣
hey, read the text
the logo isnt even right 😭
Please keep this advertising off the server. This channel is for coding help.
Bye!
you pointed me in the proper direction. it was the framerate. Now I need to try to get this thing to work in unity play on phones.
Here comes a new question! I'd like to send a family friend a little project on Unity Play. It currently works just fine on desktop browsers, but I have to switch to desktop mode on the phone because Unity play says the game is not supported on mobile. Are there build settings that I can change to get it to work in chrome/safari mobile?
See the "Web browser compatibility for mobile" section at the bottom of https://docs.unity3d.com/6000.3/Documentation/Manual/webgl-browsercompatibility.html
Also make sujre you're building from a new enough version of Unity
ty
question, I tried 2 layers on an animator but they aren't let's say "fusing", both layers each have their own mask, one is upper body and lower body. The animations on each layer only handle the parts of the body they should be managing.
I tried watching tutorials but they always use imported animations, I'm using .anims in my case so I can't convert my anim into a humanoid as they do in the tutorials
I'm kinda lost
this is a code channel. perhaps you want #🏃┃animation
How long I have to keep license for code. Very soon at least 50% of code will be changed
What license for code? 🤔
i imagine they are referring to a license that came with code they acquired elsewhere. in which case, that entirely depends on the license
Classic MIT
read the license to find out. and don't seek legal advice on discord because you will still be liable for any advice you take
I'm making a Parkour game in Unity, and I want to make a simple Jump feature where the character jumps when the player presses the spacebar. The Jump button won't work normally, because when I click the spacebar, the ParkourController is looking for an obstacle in front of the player so I wanna make it so that the Player should jump when click the spacebar, but if they are facing an obstacle, they perform a Parkour Action like usual
[Header("Jump Settings")]
[SerializeField] float jumpHeight = 2f;
[SerializeField] float gravityMultiplier = 2f;
bool jumpRequested;
if (!hasControl)
return;
// Jump input
if (Input.GetButtonDown("Jump"))
{
jumpRequested = true;
}
if (isGrounded)
{
ySpeed = -0.5f;
if (jumpRequested)
{
ySpeed = Mathf.Sqrt(jumpHeight * -2f * Physics.gravity.y);
jumpRequested = false;
}
}
else
{
ySpeed += Physics.gravity.y * gravityMultiplier * Time.deltaTime;
}
public void CancelJump()
{
jumpRequested = false;
ySpeed = 0f;
}```
``` ParkourController.cs
private void Update()
{
if (Input.GetButtonDown("Jump") && !inAction)
{
var hitData = environmentScanner.ObstacleCheck();
if (hitData.forwardHitFound)
{
foreach (var action in parkourActions)
{
if (action.CheckIfPossible(hitData, transform))
{
playerController.CancelJump(); // stop jump
StartCoroutine(DoParkourAction(action));
return;
}
}
}
}
}```
I don't know if you've given enough information on what this is doing or why its not doing what you're expecting
if parkour action is found... then cancel jump
where problem?
you might want to invoke ParkourController from inside your PlayerController.cs. Or at least the part that checks for the jump input
the way you have it right now: if the parkour controller is running first before playercontroller, its going to cancel a non existent jump
and then the jump gets created when the playercontroller runs after it
I dont have enough info but thats where I would start
you can just have a raycast
check if there's any layer mask in front, if not then just jump normally
Hello, am I doing something wrong or it's justi mpossible to serialize generic type?
you're expecting to serialize just original, or...?
yeah
the serialization rules manual doesn't mention anything about generics, so i don't think there's anything special there
wait are you expecting those maxHealth etc props to be serialized
Somewhat, I was thinking about unity displaying original
so I could easily change that
props aren't serialized
fields are
original isn't prop...?
if you want an autoprop there, serialize the backing field, [field: SerializeField]
but maxHealth etc are
ye
I didn't notice that
thanks
gotta check that I guess
but I already to implement different solution lol
you need to serialize the property with [field: SerializeField] . . .
im trying to have a minimap in the upper corner that will follow the ship, since most of this is text panels except the map you click to move your ship, but right now the minimap isn't loading but the ship is confined to the box, but the camera doesn't follow it so it just drags across the screen
wouldn't the minimap be UI, unrelated to the actual ship
wdym?
that worked, in a wacky way, but worked
i mean what i said. i don't know anything about the context you're working in, other than what you gave, which is.. not much
well, that is how you structured it
if you want it to serialize just that 1 field, you would probably need something like a custom inspector/drawer/serializer.. not sure how those would work though
Maybe there is way to play around with serialization to display this Original as Max Health. Maybe operator =?
ye
So pretty much the goal is to have a map on the upper right that acts as your way to control your ship, so you press somewhere on it and your ship turns and moves there and the map follows. The rest of the screen has text panels and stuff. Right now the ship just moves around in its little confined square but there’s no map and the camera doesn’t follow it. I guess the final goal is for it to look like the ship isn’t moving because the camera follows it yk?
Does that make sense
I mean, it's kinda fine
operators have nothing to do with this
unity introspects the structure, not the interfaces
mk
and what is that map? a canvas, or what exactly?
or do you intend for that "minimap" to be a window into the gameworld
Right now I have it set up on a canvas as a UI element that you click to make the ship move
If you click anywhere on it the ship moves there
Maybe more similar to that
The actual movement and world map and everything is in that upper right window
The rest of the screen is UIs for text and information and terminals and stuff
how are you actually representing your world
it's starting to sound like it's not actually a minimap, but the only spot where it's not UI
Yeah more that tbh
I’m just not sure how to apply it
The whole screen is UIs and then the upper right is the actual “gameplay” for the most part
So I guess minimap is the wrong word
It’s just the map
But small and in the corner
i'm not sure what the ideal fix for this would be, but i have a few ideas
- static camera, ship doesn't move, world moves around the ship
- moving camera, moves along with ship
- static main camera, ship moves in some other place, there's another camera that follows it and that's used in the main ui
A little bit of AI help and we have a good solution.
not sure if I need to override GetPropertyHeight, but I don't think it's crucial
I sort of like the ship moves somewhere else and there’s just a camera showing it I think that would work best
How would I set that up tho where I can click for the ship to move still?
the camera would follow the ship
I see..
I successfully to make a procedural world generation with the height of the tiles, but there's something off about the grid/tile
detail informations:
i also successfully created the river ye, but the position of the tiles are shit
hey, can anyone recommend a good tutorial for state machines for 3d character movement? Just asking because idk how to implement state machines with 3D movement and the tutorials that i've seen are so confusing...
anyone got a suggestion for how i could make a part rotate when i scroll the mouse up and down (snapping between a few different angles)?
guys i need help i cant attach my script and i have no idea what's the problem here
wait ik ill try to help
can u try to right click on the script and click reimport it worked for me one time
your ide appears to not be configured properly
!ide
If your IDE is not autocompleting code or underlining errors, please configure it.
Select one:
•
Visual Studio (Installed via Unity Hub)
•
Visual Studio (Installed manually)
•
VS Code
•
JetBrains Rider
• :question: Other/None
the issue is likely that your class isn't being picked up because there are compile errors. configuring your ide will highlight said compile errors for you
this one doesnt work sorry mate but thank you thou
should i install a different visual studio instead?
vscode can work fine
you just need to configure it
it seems like you were midway through configuring it but it's not done
aight lemme try
if you've configured it fully, the using UnityEngine; should not be grayed out, and you should see some errors highlighted.
aight, also is this correct?
i just installed this, idk if this is the one you were talking about
it is not
i specifically said "using that .net install tool"
the one you installed in vscode
with this one you have to restart your pc or something. i don't remember, i haven't used this
if you install it with the extension, you just have to restart vscode
you've installed the extension. my question was have you used the extension to install .net
those are settings
you do not have to change any of those
open the command palette (ctrl+shift+p) and search for install .net or something along those lines
i got these
The Scripting API page has all the available properties and functions for a given component https://docs.unity3d.com/6000.3/Documentation/ScriptReference/Rigidbody2D.html. Usually everything that can be changed in the inspector can also be in script, the other way around may not be true as often
iirc the first, i don't recall seeing that 4th one
it's okay mate i already solved it, thank you for the time thou
does anyone know of a way to benchmark all thread groups of a compute shader? waiting for readback gives unusable results as it's impossible to tell how much time was spent on the compute shader, and how much was spent in reading the data from the buffer. any hint would be really appreciated, it's difficult to decide what optimizations to make without knowing for sure how code performs
https://paste.myst.rs/74ubmr3c
Anyone know how I could clamp the speed or like, set it to the max speed automatically after it reaches it?
This is for a simple missile.
a powerful website for storing and sharing text and code snippets. completely free and open source.
@spice burrow you can use the Lerp function, so you can kinda have a smooth clamping. or else you can use
Vector2.ClampMagnitude(vector, maxSpeed);
yeah seems like you'd just clamp the velocity
Is there any Mouse.current.middleButton scrolling function? I want to check if the scroll wheel is being scrolled down or up to change between two settings/modes.
The old system has https://docs.unity3d.com/ScriptReference/Input-mouseScrollDelta.html so i would assume there's something similar with the new one too
there are bindings for the scroll wheel, yes
i can check the exact name once my project opens
how would i learn c# basics from literally 0 programming knowledge
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
however, you also may want to start with C# on its own
I can't offer any strong opinions on how to do that – I picked it up with extensive prior experience in other languages
i just want to learn how to use visual studio and what the main things of c# are
We occassionally get beginners here asking that question. There is no feasible way to just explain what the "main things of C# are". Do the learning courses.
the unity ones?
Unity Learn is a good place to start yeah
could some one show me how to make an moving 2d animation in unity?
I think u should change to rider
cz for me, VS Studio is so heavy and laggy
so i change to rider
pretty lighter
If I want to implement short hopping for jumping (ie. if the player releases the jump button early), what typically is the best feeling approach? Adjusting the rigidbodies gravity? Or adjusting the velocity over time?
an impulse to the rigidbody
And what if the player releases their button halfway through the jump? they should start to fall
the apex of the jump should essentially be dictated by how long the jump button is held, with a minimum and maximum
you can apply a continous force as long as the button is held
up to a certain amount of time per jump
When releasing early, you could limit the Y velocity or even set it to a negative value depending on how snappy you want it to feel
Have you ever tried the gravity approach?
i am new to unity, i want to find the value of a variable in the logic script for use in another script but i dont know how?
Choose the best way to reference other variables.
i dont understand
be more specific
i have a variable in logic script, that i want to use in another script (lets call it scriptA), i kinda understand how to make a reference but it cant get a line of code which accesses the variable from the logic script. I dont know what to write?
Yeah that's what the link I gave you explains
The first thing you need to do is figure out the relationship between the two instances of the two scripts in the game are.
.e.g are they on the same object? In the same scene? In different scenes? One on a prefab one not? etc...
Pick the one that describes your situation above, and follow it^
ok
im so lost. i genuinly started unity yesterday. i cant understand what anything means
are you not understanding specific words/phrases? if it's that then feel free to ask
we don't know what you know or don't know, so we're not going to explain every little detail, but we also don't expect you to know every little detail
i know like genuinely nothing, ill try to explain in a sec
Have you ever done any C# coding?
Let's just let them tell us what they're confused about
I think it's clear they have not
Fair
hello guy I am new to unity and I was thinking about making a vr game do you think as a new unity user that doesn’t know how to script or design would be a good idea
Start with something simpler
At least noe or two basic practice projects
So, I'm using AsyncOperationHandle from the Addressable package to get references to items I want my game's containers to spawn I now feel like that was a bad idea? Once the asnyc operation has been completed, if I wanted to store the results of the operation in a seperate collection, IE, the player inventory I wouldn't be able to Release the operation handle right? Or am I understanding that incorrectly?
both objects are in the same scene. ive used references before to find values such as the x position of another object but never to find a variable from a script. as i have just started using c# yesterday my knowledge is almost nothing so i cant really understand either of the links too much despite how simple they probably are. i do not care about efficiency of the script, just need it to work. i know im not being very helpful. would i use get component? im just not sure at all ngl
you can release the handle whenever you're done with it
So do you think I should start with the unity tutorials
ive used references before to find values such as the x position of another object but never to find a variable from a scrip
That is exactly the same thing. You use the same exact technique
The only difference is you are using your own custom component instead of a Transform.
uh u never followed any tutorial projects like the one brackeys have?
or unitys official tutorials?
unity have a pretty insane roadmap with step-by-steps and levels that i wish i knew about when starting out
public Transform xform;
public MyScript myScript;
void Example() {
float pos = xform.position.x;
float whatever = myScript.whatever;
}```
Nothing is different except the names/types etc, depending on exactly what data you want.
Bro you are very good man
i still dont understand whta i would write tho. im in void update. when i do gameobject. it doesnt come up with any game objects so i know that is not what i am meant to do. sorry im being so useless
i know im meant to drag a reference into something under the script in unity, but i dunno
when i do gameobject
Don't do that
whya re you doing taht
Make a variable for your reference
use that variable
Without any details from you I can't be any less vague than this
If you want specifics, you need to share your code
ok
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
under LogicScript, i have defines the variable (public int playerScore;), in a seperate script i need to access this variable for a calculation. i just cant understand how i would make a refence in this context. if imake a variable it wont let me drag and drop likely because i define it as int. i just dont know. i am the most beginner of beginner. thx for helping so much
In thje separate script you do:
public LogicScript myLogic;
Then assign it in the inspector
Then you can do myLogicScript.playerScore when you need the score
you used LogicScript.playerScore, meaning "the playerScore of the class LogicScript", but that doesn't exist
playerScore exists as a non-static field, meaning it exists for individual instances, not the class as a whole
show us the actual code you wrote
you.. didn't do what praetor told you to do
I can't guess at errors without seeing what you tried
consider the difference between
Vector3 someVector = new Vector3(4, 1, -2);
Debug.Log(someVector.magnitude);
```and```cs
Debug.Log(Vector3.magnitude);
im sorry for being so confused. here is all of my relevant code. im sure it isnt to do with incorrect capitalization.
the second LogicScript in the second image is incorrect
read again what praetor wrote
(also consider this)
Look at my example where I use the variable. Notice I do not write LogicScript there, I wrote myLogicScript which is the name of the variable.
In your case you named the variable Logic
o my god i am so blind thank you so much. i must look like such a bot
Just a beginner making beginner mistakes
no you just look like a beginner 😄
you'll get better with experience
LogicScript is a class. playerScore belongs to a specific instance of LogicScript. Which instance of LogicScript do you want the playerScore from
is my world generation cooked?
when i change sort order from bottom left -> top right ,it's become multi level terrain but the tile and the grid is not suit of each other, is there any solutions?
the grid:
do you guys know any issues ?
@pliant bridge This is a #💻┃code-beginner channel. If you have a #🖼️┃2d-tools question ask it there. And make sure you've followed the manual on how to setup tiles https://docs.unity3d.com/6000.3/Documentation/Manual/tilemaps/work-with-tilemaps/create-tilemap.html including renderer sorting.
thank you so much for the help, it worked! I am REALLY happy with how its looking so far
yeah LOL, the map panel looks awesome!
it can now fly to where you click, spends fuel and turns, and falls into orbit around planets!
Hello,
I'm trying to use ECS DOTS to do multiplayer game. I try to keep my project simple as I can.
Here I'm strugguling :
I create a static object cube in a subscene
When I start the game I cannot see this gameobject in "Physics Debugger Tabs"
var physicsWorld2 = SystemAPI.GetSingleton<PhysicsWorldSingleton>().CollisionWorld;
Debug.Log($"[World: {state.World.Name}] Active body physics : {physicsWorld2.NumBodies}");
This show me 0 on Update Method.
@solar hill transform.RotateAround(Center.transform.position, OrbitVector, Time.deltaTime * OrbitSpeed);
Orbit vector is currently 0, 0, 1
I should mention it's a 2d game
you need to cache the tangential velocity
How
gimme a sec
// get the center of rotation what wre oribiting around
Vector2 center = Center.transform.position;
// get current object position
Vector2 pos = transform.position;
// this is the radius of your rotation circle.
Vector2 radius = pos - center;
// then we find the perpenducilar direction or rather the "tangent"
// this is basically the direction of the object while its rotating.
Vector2 tangent = new Vector2(-radius.y, radius.x).normalized;
// RotateAround according to the API uses degrees, but for the math you need radians so just convert it
float angularSpeed = OrbitSpeed * Mathf.Deg2Rad;
//simple enough formula, you multiple the angular speed with the radius
float speed = angularSpeed * radius.magnitude;
// this is then the exact velocity your object has while rotating
Vector2 velocity = tangent * speed;
then when you need it to no longer orbit
transform.position += (Vector3)(velocity * Time.deltaTime);
Thx
actually woops that needs to be a vector3
Is this the way to find the closest object?
foreach (var Orbitable in GameObject.FindGameObjectsWithTag("Orbitable") {
if ((Orbitable.transform.position - transform.position).sqrMagnitude < (ToOrbit.transform.position - transform.position).sqrMagnitude)
{
ToOrbit = Orbitable;
}
}
Yes but ToOrbit is probably null before the first run right? (if so it needs to handle this case too)
Yeah
I was going to say that this would be a fine place to use LINQ (especially if you aren't that worried about performance)
but I forgot that MinBy is an extension method I wrote and not something built in
it'd look like this
var targets = GameObject.FindGameObjectsWithTag("Orbitable");
var closest = targets.MinBy(target => Vector3.Distance(target.transform.position, transform.position);
alas
Oh thanks
(this won't work without some extra code :p)
it's just the idea that came to mind
It does the same thing you're doing here – find whichever one has the smallest distance
hello, i am a beginner, how would i access the value of a variable in the logic script from a script in a prefab of the same scene? i know very little
You'll need to get a reference to the component whose data you want to access.
(each thing in the inspector, like "Transform" or "Box Collider", is a component)
Do both things exist in the scene when the game starts, or does one of them get spawned?
thanks for helping, one of them is spawned but due to it being a prefab, i cant drag and drop so i dont know how i would make a reference
would using a tag work?
ah, then read this!
tags are good as a beginner i guess
Whoever spawns the prefab should tell it about the other object
MyCoolThing thing = Instantiate(thingPrefab);
thing.Init(this, otherThingy); //Call function on spawned instance component
this can be used to refer to yourself in code (learn more)
hey! how do i make the text and circle sharper? theyre getting softened rn and its supposed to be more pixel perfect instead of smoothed, going for that retro terminal type vibe
TMP? Change the shader from sdf to a pixel one (there are a few tmp shaders to pick from)
circle is however its rendered and not relevent to this channel
ur right, my bad
thanks for helping but i still cant understand after looking on the website sent by Fen, here is my code for the instatiate, ive tried to get it into the format of having an = but i cant get it to work
If pipe is GameObject then you can get a component after spawning it
it is a prefab
Yes but if the variable is of type GameObject (as you can actually use a script type too)
@idle saffron
GameObject newPipe = Instantiate(pipe, somePos, someRotation);
MyComponent c = newPipe.GetComponent<MyComponent>();
c.DoCoolShit();
Spawn, keep reference, get some component, call function or assign to some variable
sorry for being useless as i have only just began using unity but i understand that the Pipe has to get told the reference by its spawner and store it as a variable (correct me if wrong), but i do not understand how it would transfer that to the Pipe or what c means in the code u hav provided (is it a placeholder?)
Yea its a placeholder for whatever your component type is
the thing to understand is you can get the script/component instance from the new object and interact with it
c.coolVar = 15; or something
if that still confuses you then you need to learn more c# basics
ok
what do you expect us to tell you?
thats its going to be easier elsewhere?
because its not, youre free to use what you want, but if youre switching just because of the learning curve you are in for a rude awakening
I actually learned godot forst than unity
For me godot is much more easier than unity
Game development is difficult overall. Not sure how changing interfaces will make it any easier.
Is there a way to check with the new input system if any key or control is moved to get out of an idle anymation?
or to do press any key to start
I have this loop with a delay of 0.05, but when i test it, it appears much slower
public class Click : MonoBehaviour { float sizeincrease = 0.1f; int iterationCount = 3; public float delayBetweenSteps = 0.05f; void OnMouseOver() { if (Input.GetMouseButtonDown(0)) { StartCoroutine(ScaleOverTime()); } } IEnumerator ScaleOverTime() { for(int i = 0; i < iterationCount; i++) { transform.localScale += new Vector3(sizeincrease,sizeincrease,0); sizeincrease += 0.1f; yield return new WaitForSeconds(delayBetweenSteps); } } }
How can you even tell?
you're going to have a much easier time with unity in the long run
you also just joined 3 days ago
Isn't that too complicated?
not really, everyone has their own styles
I mean, I would use Update() or FixedUpdate() and count deltaTime for my timer
WaitForSeconds(x) will wait for ≥x seconds, just according to how the frames line up. if you need to loop like this, you might not want to use WaitForSeconds at all
yes really. unity is more developed and has more documentation and community archived posts than godot does
python is the reason not to use godot
godot has several languages one of them being C#
godot is open source and wonderful, but unity is the more mature engine
and godot supports another language that might make more sense to someone who has more experience with similar languages
and godot has a different node architecture that just might click easier instead of unity's model
oh wow, I was teached to use python
i'm not saying godot is better or unity is worse, but everyone has their own pre-made preferences
sometimes those align better with something else
the common pattern for this goes something like this @thin lotus
float elapsedTime = 0;
while (/* some condition */) {
while (elapsedTime >= /* time per iteration */) {
/* do thing */
elapsedTime -= /* time per iteration */;
}
elapsedTime += Time.deltaTime;
}
I am working on player physics of a FPS and I check cc.isGrounded before allowing a jump. For some reason I cannot jump at all whilst standing still (even after moving) and my jumps are far flatter than they should be when input whilst moving. Removing the cc.isGrounded == true condition allows a regular jump which moves much higher. Does cc.isGrounded just suck or is there something else I need to adjust?
post some code
hehe im back , and i enjoyed unity for time being :3
How do I complicately design this ui with custom stuff
it looks plain
and pain
design how you want it to look first, then implement it
also, this is a code channel
once you figure out what you want, if you're having issues, ask in #📲┃ui-ux
make sure you only have one Move per update
thanks I did and now i can at least jump even whilst standing still
how you are too much active here bro
People who are active here are typically also working on their own projects at the same time
Helloo, laddies! Im having some trouble using the animator. I have a few transitions but the main problem is that they queue. For example, if im reloading and am spamming the shoot button, itll wait for the reload to happen, then shoot as many times as i pressed, yk? how can i fix that?
if you have hasExitTime checked, the animation will play until the end
this is #💻┃code-beginner
go ask in #🏃┃animation
My bad, thanks
What are the conditions for onCollisionEnter2D to get called? I have two box collider2d's, one of them has a script with that method yet it isn't called
how can i paste code into discord properly?
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
thanks
using UnityEngine;
[RequireComponent(typeof(CharacterController))]
public class PlayerMovement : MonoBehaviour
{
public float jumpHeight = 2.5f;
public float gravity = -29f;
// References
private CharacterController cc;
private InputHandler inputHandler;
private Transform cameraTransform;
private Vector3 velocity;
private float currentHeight;
private void Awake()
{
cc = GetComponent<CharacterController>();
inputHandler = GetComponentInParent<InputHandler>();
cameraTransform = GetComponentInChildren<Camera>().transform;
}
private void Update()
{
if (inputHandler == null) return;
velocity.x = 0f;
velocity.z = 0f;
HandleJump();
ApplyGravity();
Debug.Log(velocity.y + "|" + cc.isGrounded);
cc.Move(new Vector3(velocity.x, velocity.y, velocity.z) * Time.deltaTime);
}
private void HandleJump()
{
if (inputHandler.JumpPressed && cc.isGrounded) // && cc.isGrounded (makes jump flatter but prevents air jumps)
{
velocity.y = Mathf.Sqrt(jumpHeight * -2f * gravity);
}
}
private void ApplyGravity()
{
if (cc.isGrounded && velocity.y <= 0)
{
velocity.y = -2f;
}
else
{
velocity.y += gravity * Time.deltaTime;
}
}
}
Removing cc.isGrounded in HandleJump() makes the jump higher but I do not understand why
Can somebody please explain why?
So I'll create a rigid body with zero gravity
Though why does it neeed a rigidbody?
Because physics?
What if you wanna just invoke a function when 2 things start overlapping?
Use the OnTriggerEnter version instead, if you don't things to physically collide. You also have to set the IsTrigger flag on the collider.
thx
On both colliders?