#๐ปโcode-beginner
1 messages ยท Page 675 of 1
typically people find it helpful when you help them ๐
The main issue they have is that their naming convention is causing great confusion. Bad formatting of class names, the fact Unity has a CharacterController themselves which means you confuse their class with your own.
but i didnt even respond after that comment what ๐ญ
I actually think the main issue is that a few different programming things haven't quite clicked yet, so I provided an explanation that used their code on the offchance that a penny would drop!
Amongst plenty of other things, sure
idk if you remember what it's like to be new to all this, but I always found it useful having explanations be grounded in things that I'd already written
When I was new I didn't pick up Unity immediately. It does nobody good to learn both .NET and a whole game engine framework (which implements c# very poorly). Better to just learn basic C# before you take on anything else.
I don't think this advice is as strong for everyone
one of the better ways of teaching someone is usually to use their own thing in the discussion, pointing out what they did wrong, could've done better, and did right, i did understand a significant amount of what you said
that worked for you, it doesn't necessarily work for everyone - it's hard to get the motivation to teach yourself fundamentals without seeing fun things move about on the screen
Depending on the person I do think jumping straight into engine can be solid if you've done a simpl-ish codeacadamy esque c# lesson
The only relevant argument could be experience with previous languages/programming fundamentals. This never applies to anybody here.
Let's be realistic, Sila should take beginner C# courses. Appreciate the help, but you're helping somebody that should take a step back
spoonfeeding is usually also discouraged. I'm not directly speaking about the situation above, but we have seen this same scenario many times of an individual refusing to (learn the basics/configure their IDE) because someone chimes in to give them an overexplanation or just the code solution.
yeah that's valid
learning fundementals doesn't exclusively mean taking full on beginner c# courses. I think for a lot of people they would be better off going in engine at a certain point then doing straight c#/net stuff
Learning C# with a game engine is actually a perfect way to learn the principles of object oriented. You get to see how object and class references work visually rather than just reading about them and running console applications
i'm the type of person that enjoys the struggle, and hate reading so much text or learning from a video, i can't ask questions, sometimes they go too fast, or i get confused by some of the wording, that's not struggling, that's just falling behind.
i like having that human contact because i can ask questions and learn from others experiences rather than a video.
Which no one takes issue with, the issue is seeking that free advice while being uninterested in following the "give a man a fish and he'll be fed for the day, teach a man how to fish and he'll be fed forever" methodology
i'm not uninterested, and the advice is here, i feel no guilt in asking for help, whether someone wants to give me their advice is up to them, otherwise i would've done something else.
Learning how it works yet a lot of beginners here dont know what a constructor is, and barely understand the concept of passing a reference? The only part you see visually is drag and dropping objects as references. This isn't at all applicable to any other aspect of CS
It most definitely is not the perfect way to learn
when was the last time you used a constructor in unity ๐
You literally can't use it, that's the point
an hour ago
I think learning in engine is really strong because it allows you to make comparisons between pre-existing games in order to understand how things work in practice
i swear to god you can teach 99.9999% of beginner to intermediate concepts by making examples out of minecraft
I would agree with you if Unity wasn't so poorly implemented. Not just because it's years behind on it's version, it also does a very bad job at giving you the ability to write code in general (because of the constructors, or the side effects of using null-coalescing on things like gameobjects)
neither of these things matter at the level we are talking about
You don't just learn C#, you learn a game object AND the fact you can't even use C# properly. Start with the basics first
learn a bunch of things you're not going to use in an environment that is boring as hell - solid advice ๐
The "level" you are talking about is learning Unity alongside C#. I have been clear enough on that
learning beginner level unity alongside c#
Overwhelming, confusing. A beginner is not going to learn anything when they juggle an engine alongside C# basics
i did
I mean each one learns differently. It helped me seeing stuff visually in the inspector, such as how a boolean represents 2 values, which a checkbox can only have 2 values. Learning about null references and how different objects reference each other in the game world solidified my understanding better than when I were to just write code in the IDE and try learning that way. I found no real example doing it that way. Also learned interfaces alone in unity which was a tough concept for me to grasp.
The majority of people won't be able to do this without getting stuck, it doesn't matter if you did
are you sure
That's no argument
what makes you so certain that we are the minority here
I appreciate your argument but I have seen enough cases since coming here in 2019 to know what the approach should be
People bite off way too much at once when beginning. Too much ambition to do things. They just get stuck and end up here, overwhelmed
the good thing about learning in 2025 is that:
- there are big active discords where you can get help with a specific problem and get explanations based on stuff you've already written
- if you don't fundamentally object to the tech, you can ask AI literally anything and be 60% sure what it's telling you is true
- there's a ton of free content on youtube
what makes you think they would have a better experience learning c# outside of unity
Most people have no idea how to learn from video's or AI. Especially AI is heavily discouraged here because of the massive spoonfeeding
Video's are also just taken for granted. Written over with no idea how it works
The amount of people we've seen outright quit or get extremely frustrated to the point of mods telling them to stop is a pretty big indicator.
Especially a bit issue when a beginner is watching videos. No idea how the syntax even comes together
(fuck ai)
yeah that one was a bit tongue in cheek ๐
Learning the syntax, learning how proper C# is written. Understanding how you build words at all into something that compiles. Followed by principles like OOP, polymorphism. All without having to worry about what is C# or what is another Unity feature/fuckup
Doesn't even have to be much, just understand how to write basic C#. That's something that's very often skipped
I don't think that's a viable metric though. I know many people struggle with learning Unity and c# at the same time. What I'm saying though is I don't believe a lot of those people would actually have a better time dropping the Unity part of that, they would probably have an even worse experience.
The people in question here want to make video games. Removing the video game part of it makes it a lot harder than it does easier.
People do not want to do this
And there you have the issue
They go straight to Unity and C# as a complete beginner and get overwhelmed
Programming is not about what you want and how fast you can do it
telling people that are struggling to make a video game to struggle less making something else does not solve the problem
fyi OOP and polymorphism are actively bad for games ๐ composition is way more useful than polymorphism in unity, so there's one thing it's largely useless to learn, and OOP is how most things work but DOP is typically better for games. So should we be telling people to go learn DOP instead of OOP?
Then the same can be said that two individuals claiming they properly learned c# and unity at the same time is not a viable metric. Infact none of us have defined a metric at all in terms of what success vs failure to learn c# looks like
I don't disagree with this
Imagine telling a beginner wrking with Unity not to use polymorphism because it's worse. They will skip a huge feature of C#
One of the many reasons to just take the basics first
i think the question you should all be asking is if something is genuinely needed for the project the person is doing.
the reason i don't hop into fundementals right away is because 90% of the time, most of it is completely useless to what i'm trying to achieve.
Ah the age old composition vs inheritance. When the real answer is that both have valid use cases and its never a "always pick one over the other" scenario
so i'd rather learn what i need to know, then when i go into fundementals, i can approach the topic i know i need
@burnt vapor I think a lot of what your saying applies under the assumption we are talking about people who want to program because they want to program
I'd wager 9/10 people coming into this channel want to program to make video games. The programming is just what they need to learn in order to do that. If you take away the video game aspect of it they aren't going to be interested in the programming
fwiw I largely don't use inheritance in unity beyond a monobehaviour or scriptable object, unless I'm doing something very specific
Then you likely could be setting things up better
that would be the "very specific" part ๐
there are very few cases where it's actively better than a simple interface and composition
(in unity)
to be clear if it helps you visualise things and you work best with it, it's not awful, but Unity works on composition and you'll often end up with a mess of inheritance that makes it more difficult to work in a larger project
i'm glad this became an actual conversation, i'll hop on fundamentals when i know what i want to learn, but a lot of the time when someone tells another to go do something like that, it breaks spirit.
not to be combative to that response but i dont think any of us disagreed on learning the fundementals first
its just defining what "the fundementals" actually covers and to what extent
i dunno, some of it seemed like disagreement
the application of fundementals is different for every person, and it's easier to hold in knowledge when you know what and why you need to hold what you're learning in.
I guess in saying this though i'd be curious what you think "the fundementals" actually is
my idea of fundementals is a cake.
I'm aware you also did suggest to learn the fundamentals but a lot of your messages too did seem against it
#๐ปโcode-beginner message
beginners would see this and think it means they should open unity first thing and be fine
i'll elaborate.
I think there are game dev fundamentals and programming fundamentals, there's some overlap - but if you start with programming fundamentals you will learn things that aren't important, and will miss things that are
and learning by doing then asking questions is good actually
Again it's not a one or the other. It never has been. Both have valid use cases that make it easier for specific problems
what i mean by a cake is 6 slices of knowledge (this isn't literal), and each piece has different bits of knowledge that apply to different things.
by eating the whole cake, you stop when you're full, and theres a huge chance on missing out on what you actually wanted to eat.
while just trying ingredients and saying "yeah i want this in my cake", when you go to eat the cake, you know which slice you actually want to eat.
some people ARE able to eat the whole cake and get exactly what they want, that's fine, but i'm not that way, i'd rather know exactly what slices i need to eat to understand what i want, and i can eat the other pieces later.
in order to know what i want, i need to eat the ingredients, even if i don't understand them at first.
is is less effective, can be, but it's how i like to do it, i physically struggle to learn by eating the whole cake.
so when people tell me "just go eat the whole cake and come back", it drives me away from wanting to even look at the cake, that's too much cake.
whilst if i asked what i used ginger for and someone tells me the uses of ginger and it's application, i better understand "ok, so maybe i don't need ginger right now"
i have no clue if any of this was understood, but that's what i think fundementals are.
a big ol cake.
and unlike many people, the only reason i get 'burnt out' is because i see something else i wanna go and try, i think it's an adhd thing, i never really get 'burnt out' unless i'm drawing for 3 days nonstop and have nothing left on my mind.
(hoho i'm so different i know)
They typically mean you shouldnโt eat in slices but in layers. So itโs the same idea, tilted 90โ
Thatโs precisely the frustration that advice givers have with receivers
The example definitely fell apart at times which is understandable given you dont have so much experience. Though analogies usually never encapsulate the full scenario. I dont want to make analogies for this now because i dont want you to get the wrong idea.
The main thing is you should learn enough so at the very minimum you aren't struggling with the syntax. Meaning how to write a variable, define a method, define a class.
Then naturally you can learn stuff like for loops, arrays, lists and whatever else an actual structured course will teach you. These very basics WILL be useful for you in unity.
it fell apart because half way through i realized it wasn't working as intended and continued anyways
this i can understand, i appreciate the usage of saying what i should go and learn
instead of saying a vague term that can mean anything
fundamentals are vastly different amongst many groups
that might not make sense outside of my own brain
I find your argument confusing. Not everybody wants to learn everything, they just want to make a game. Yet you want to waste time by falling constantly instead of just learning it properly and implement your game, likely faster as well?
yep! i'd rather fail a bunch learning how to do basic things, because i find it easier than sitting down and learning it step by step.
I'm not saying you should learn the language because I expect you to do more outside of your project. You are just going to get overwhelmed by combining everything, even with a single project
I am not sure what else I should say here, we're going in massive circles here
Part of what I gathered from your cake analogy was that you fear you might not use some things you learn. This definitely won't be the case especially if you stick to something like the intro to c# link pinned in this channel. You will be able to apply pretty much everything you learn
failing is literally how you learn! Like, it's the fastest way to learn by far
you have to do things wrong to learn how to do them right
it solidifies your knowledge
Only if that failure leads to changes in behavior
yeah that's fair
i also just like being able to ask questions others might find stupid because i'd rather the human interaction
offtopic but i hate ai call centers, anyways.
failure -> feedback cycle is important
Failure by taking stuff at face value wastes time when you could have just done your research
I'm not sugar coating it. If you are aiming to complete a project you should not do this
but if you do it wrong then are told how to do it right, that knowledge sticks
times not wasted if you enjoy the process
Trial and error, action, is the best way to learn. Actually performing a task repetitively and building a pattern until itโs solidified
There's a big difference between trial and error when you at least take the basics. There's plenty more you will encounter during the actual project
this is what i've been saying, i'd rather fail, than look at a fundemental and still not understand anything after, because i'd rather write 100 lines of code, mess up 75 times, than reread the same paragraph about class 50 times trying to understand something
Remember the initial issue that sparked the conversation was caused by gross inexperience of absolute C# basics. Could have just started with a very basic project that takes maybe an hour to learn this
(or codeacadamy esque tutorials)
i told you all, i tried, i really tried, this was about a system for first person, that was it, that was the entire thing, but because of unity's recent updates, the changes have made following ANY tutorials practically impossible.
Unity doesn't update C# syntax. Your issue sparked because you had poorly formatted code
Look at this conversation. One guy is running in circles with their arguments and 5 other people try all sorts of approaches to figure out what we are even talking about. 5 are learning, one is not.
Also, back to my initial point of Unity just making things more confusing, the framework has its own CharacterController which just made your issue worse
Unity hasn't changed much to where the previous methods no longer work, not sure what your talking about in this specific case
i tried to do a flappy bird tutorial from 3 years ago.
the dudes code worked perfectly, i followed it, tried to learn it, and while his pipes were within camera view, mine were EVERYWHERE, i checked it multiple times, and eventually was just told to jump on in instead of doing the tutorial
Think he means deprecated code, but I could be wrong
was that the GMTK one? That one still works for me in Unity 6.1
even things like pressing space were changed, because i had to go around using the space bar by typing in (a much easier verison) of what i wanted.
That difference in their project vs. yours does not sound like anything Unity has remotely changed
it was though
you can still do the old input stuff
i looked it up, the specific terms used had been changed
i did, and it still messed up!
i'm not joking
oh they did change rigidbody.velocity to rigidbody.linearVelocity?
this is one of the only ones i can think of where something got actually replaced
yeah
yeah, and that messed me up as a beginner because i didn't know what it meant at the time, i only found out after looking it up
that wouldn't cause the issue you mentioned though?
one of the ones for pressing buttons got replaced too i believe
theres a new way, the old way still works
i still haven't found an answer as to why my pipes were so messed up
FindObjectOfType now is FindFirstObjectByType as well lol
oh yep
it genuinely confused me
i then followed someone elses first person tutorial and it ended up spinning my character a lot
its just deprecated though, not replaced right?
was it the GMTK one? I can poke mark and tell him that a few things have changed
and while, yes, i won't deny it could be me, i also checked that one half a dozen times and gave up to go find a different way to make a first person camera
FindObjectOfType is deprecated
the linearvelocity thing is only thing i can think of where the old way outright wont work anymore
and now this one is slightly changed too, there's an error when i type the same thing the dude in the video typed
you gotta be a little cake pilled in order to mix and match tutorials like that
i don't get it, maybe it was the name, but after changing the name, it still didn't work
oh no i, deleted it.
and started over
Unity should prompt you that it will update any scripting API to its newest version if anything is deprecated
You should allow it to
Doesn't the old variant still exist here, though? It would get a deprecation warning at best.
Or just manually fix it
This is usually how it's done. if they didn't provide the old variant then that's quite a big fuck up on their end
no they straight killed that shit
afaik
anyways for the last several days i've just been running into issue after issue with unity, even so far as to when i booted it up and got errors upon booting it up.
That's dumb. Just makes it confusing and annoying to update
sorry for light mode but it looks like fused is right
none of the tutorials i've tried to follow have worked properly for some reason, so i've been running in circles with it, and i'll admit, it's been kinda fun.
might just be rider being clever though
I found the whole renaming of variables in unity 6 kind of pointless and annoying. I only switched because the splash screen became a voluntary choice
I did notice a few typos in your original code - when you're programming, you've got to be incredibly precise with naming
that could be why things don't work
not saying it definitely is, but e.g. case matters
it could be, i didn't deny it, i've slowly been getting better
anyways this is what i was talking about with the bird
i'm gonna go back and look through the video, but i was pretty sure i did everything the same way.
maybe i'm missing something here
what did the tutorial have ๐
(i think i found the problem btw :P)
i believe this was the line that handled randomizer
post whole thing
i'd need to see the whole thing
take a look at your highestpoint for me rq
here you've got ||highestPoint = transform.position.x + heightOffset||
ah beaten to it ๐
spoilers
right around void? or below that in the instantiate?
where you set its value
i really have considered just quitting sometimes.
but then i remember i have a task i need to do.
this is one of those times however.

do you see the issue ๐
there's one letter difference between yours and the tutorial!
two if you count the function name being spawnPipe and not SpawnPipe but that wont cause errors
easy mistake to make!
oh well, it's why i make mistakes and talk to people, i now know to look closer when i'm setting positions
i remember years ago i messed up and didn't realize i needed to capitilize certain things, still make that mistake from time to time but it's not nearly as bad as it was
everyone makes mistakes, the lesson to learn here is getting into the habit of troubleshooting.
the pipes are in the wrong place? what code relates to the pipes? what code relates to what place they are being placed?
thank you
getting good at programming isn't avoiding making mistakes but learning how to identify, research and solve them
the worst issues are the ones that don't have an error message ๐ญ
I have some absolutely rancid modding related issues that have driven me crazy in the past lol
ahahaha yeah I can imagine
the more i write, the more i understand (just really slow)
i've also been going back and forth with the unity wiki or whatever it's called
hey actually got the error i made this time for once, i'll stop being pesky here for now lol
No, Rider doesn't virtually support old syntax. This means Unity does properly deprecate the old field/property.
It's not bad to continue using it, especially because Unity never removes deprecated features. However, the new variant should be preferred and likely works better
can any one tell me why my collison or trigger not working
whats the problem exactly?
is your ide configured?
we figured it out
they did
at least
it was a single letter i messed up
is humbling
happens to the best honestly
Yeah
void OnCollisionEnter(Collision other)
{
}
this is the actual function
not OnCollisonEnter
!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
I already tried it
It's not working .
Hello, im looking for a little direction. Ive been working on thei buoyancy script which seems to work mostly ok, other than I seem to get constant bobbing up and down. I think I maybe need to slow the force applied as it gets towards the surface plane but im not really sure how to approach it. Here is the code I have so far: https://paste.mod.gg/sirlvfszrrtn/0
A tool for sharing your source code with the world!
isn't there a built-in buoyancy effector?
Oh perhaps I see a 2D one but was attempting to roll one myself to learn it.
good morning
how can u snap meshes into another mesh? without having to move it with x y z axis because building scenes is really difficult
Roblox studio had something like that so i think Unity has it too
a simple way to give it is How can I build maps easier
Why it creats particles but it're doesn't play
!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.
Guys, you are all hope. How can I make all the Boolery functions on False when I click the "New Game" button? Because the object has a DON'T Destroy On Load. That is, I move from the scene to the menu, and when I transition, I have the same object (Objectbar), and the button reacts to a new object, but there is no to the old one. Therefore, when clicking on the "new game", on the contrary, the game continues, because one BULEV function = True in the old object
When the game is rested, everything is fine
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
!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.
see the "large code blocks" section.
you'll probably want some method to reset stuff to the initial state (don't call it Reset though, that's a unity message)
Thx, but i'm already fixed it
still, read it for next time you ask about code here
not the right channel
check modular assets for starters
water is incompressible for most purposes, so the buoyancy in water is typically not dependant in depth
it's dependant on how much the object is in the fluid though
is the bobbing you see constant, convergent, or divergent, and what's the desired effect?
Hello, any idea why this doesnt work guys?
IEnumerator MoveMonsterJumpscare()
{
JumpscareSound.Play();
while (Vector3.Distance(Monster.transform.position, TargetEndPos.transform.position) > 0.1f)
{
Monster.transform.position = Vector3.MoveTowards(Monster.transform.position, TargetEndPos.transform.position, monstermovespeed * Time.deltaTime);
yield return null;
}
}
the jumpscare sound plays, but the monster doesnt move
i've assigned everything aswell
Use debug.log to make sure the code is running
In the loop
I've been around for a while
ya maybe
btw,
nvm ima ask it later
lemme do that log
hey wait, i figured it out. it only moves an inch?
i think its my targetpos thats too close
nope, i changed to pivot and its still way over
also, it only moves like an inch forward.
or lets say towrads the empty object
Did you do the logging?
My guess is it's only running for one frame or so
The logging will tell you that
That's why I asked
ah i figured it out
i was destroying the object im playing the coroutine on instantly
i instead destroyed it once the monster reached the destination
That would have been my guess
oh yeah also,
do u know the easiest way to make fades?
fades meaning like
fade a blackscreen in
slowly
A coroutine or a tween library
yes, ik coroutine but what do i do in the coroutine?
also which of those is better, tween library or coroutine
Fade the alpha of a black UI image covering the screen
That's what I just said...?
Hey folks, I noticed I can change the main URP assset 'cast shadows' function at runtime, I'm creating a 'potato pc' option for my game to run on old hardware, And I'm wondering if there is a way to toggle this option via code?
I actually ended up figuring it out, I had my values the wrong way around when applying the dampening so it never actually slowed when in water. Now it works like a charm!
I have no clue why this is happening. I disabled all scripts for my player but the player capsule (height of 1.9), will not rest on the ground and is constantly moving on the X and Z axes by tiny float values. Usually at rest, the Y position should be 1.45, I even try to set this manually yet it goes to this weird slightly hovering state?
hey,
cant i do smth like this?
public void FadeIn(float duration)
{
StartCoroutine(Fade(1, 0, duration));
}
public IEnumerator Fade(float startAlpha, float endAlpha, float duration)
{
float elapsed = 0f;
while (elapsed < duration)
{
canvasGroup.alpha = Mathf.Lerp(startAlpha, endAlpha, elapsed / duration);
elapsed += Time.deltaTime;
yield return null;
}
canvasGroup.alpha = endAlpha;
}
}
i think this should work
(Skip to 0:14 btw)
maybe the collider
unless u have a controller
like charactercontroller
like the radius of the charactercontroller
I disabled the playercontroller script.
hm idrk then
without seeing the whole setup we cant really say whats causing this. maybe first do a sanity check and create a new capsule in scene. give it a rb with frozen rotations and see if it functions how you expect. start adding the same logic that you have on this player to that capsule until you find what is causing this
I found part of the issue, the sword has a capsule collider on it too. This shouldn't be an issue though since there is no rigidbody attached to it??? Aditionally, the sword collider is not even touching the ground?
Adjusting it here fixes it but I need the collider to be that shape
oh i missed the sword collider. its still a part of your RB since it is a child
ah, i see
is there any way to make this not the case ๐ญ
you could probably get away with making the sword a trigger collider instead, since you probably dont want it pushing stuff around either
okay thanks ๐
it worked ty
I think I need that anyway to check for hits and stuiuff down the line
there are also layers and setting up the physics layer matrix which you'd want to use if setting up hitboxes on characters
Im following this tutorial but when i want to add a second path my cat stops after the first instead of following the second
https://youtu.be/11ofnLOE8pw?si=fs0XhFSRT_MRn_Su&t=560
#unitytutorial #unitymovegameobject #unitymove #unitymovement
In this video tutorial, I will show you the way how to make a game object move by Bezier curve. Also we will see how to make a game object follow some interesting and unusual paths using several Bezier curves. In other words, you will be able to create any path to follow using any num...
any ideas? I can send the script but im pretty sure i did everything like in the video with the exeption that my cat is a prefab
Im not fully sure what all of the using things mean, but should i be putting using Microsoft.Win32.SafeHandles; and using System; at the start of my scripts? I'm alreeady putting system collections and the input system in for IEnumerators and the input system.
Well i don't really know what they do
ok i think i fixed it and the paths need to connect to work together
it was automatically put in my other script so idk what it does
using statements just mean "import this library" (to oversimplify)
I know that its just that i kinda have to guess what it means cause it doesn't really tell me.
that's all it means
It does, if you hove rover a type it tells you what namespace it's in
like i have no idea what microsoft win32 safehandles is
And if you're not using it anywhere, it'll tell you that too
saying its in microsoft win32 does not help me
if i had to guess, it's windows file handles
example: I'm not using System.Collections in this class, I can remove it
But you could hover over the classes you are using in your project, and see which ones are part of that namespace
and that tells you "This is the namespace that lets me use this class"
or delete it and see what errors come up ๐
which, presumably, you do know what its purpose is
or else why would you be using it
real i agreee
i should delete system 32 and see if i get any errors for the win32 thing
windows didn't let me
windows sucks
it was most likely put there by autocomplete if you chose the wrong type in the intellisense suggestions
im trying to use if (InputSystem.actions.FindAction("M1").WasPerformedThisFrame) in an attacking script and everything should be fine but its giving me this method group error, i have literally zero idea how to use the input system so idk why this isn't working
Did you intend to invoke the method?
then invoke it
what does that mmean
call the function, Function()
WasPerformedThisFrame is a method that returns a bool, it's not a bool itself
you have to call it to get the bool from it
is this another one of those things
it's a basic c# thing
you should probably go brush up on basic c# if you weren't able to solve this
it's a very basic issue
don't rely on copy-paste
do some actual learning
there are resources pinned in this channel
i mean nobody even told me what a method is and i finished the beginner programming course in the unity help thing
the beginner programming course is for unity programming specifically, isn't it?
about unity messages and such
you still need to learn c# itself as a language
see the resources pinned in this channel
i have before
!collab
: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 there a simpler way for a car to follow a road and loop?
well, if you don't know what a method is, then clearly you didn't go through it enough, then..?
ignoring the fact you probably shouldn't put this here why would you advertise this in a beginner coding channel ๐ญ
!collab
: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
because people will advertise wherever
they aren't reading rules, why would they read anything else
i went through both the beginner and intermediate unity coding tutorials and thought it was enough
can u stop spamming it in this channel :c
You're supposed to read the message not call the bot again
go through the intro to c# thing
Oh Sorry
ok guys but do u know how to make a simple follow along path animation that doesnt have to deal with the curves ?๐ฅบ
actual begginer asking a code question
of course the literal only thing i don't open is the most important one ๐ญ
Anyone Interested?
read the bot message.
yeah i'll fr write code for you trust me im so good at coding bro (this is a joke by the way)
<@&502884371011731486> spamming multiple channels, refusing to follow instructions
you can use waypoints and lay them out in the shape of a curve..
Where Can I Offer This?
but at the point why not just use a curve
read the bot message
If only you were sent a message like ten times that tells you where to put this instead
thers no soliciting here
Oops my bad
Send Me link In DM
If you're going to be this annoying, you will be kicked from the server. You have been provided the link where you spammed in #๐ปโunity-talk : #๐ปโunity-talk message
Brother it was a gif telling you to read
well its a road like this, i honestly just want a car going from the bottom to the tunnel and another doing the oposite on the other lane
and im pressed on time+a noob when it comes to unity
I mean, you could just do a series of positions and some MoveTowards calls
but splines are pretty powerful, especially if you ever want more involved shapes of paths
i think curves are kinda overkill for this if you're pressed for time
i installed the spline thingy but i dont see it under the window tab and i dont know how to put them in :c
yeah and also they look wonky bc the road is straight anyway and i need to fiddle with bezier positions
well u could just do a movetowards if it even exists in 2d
(it does, but you could even if it didn't)
MoveTowards is just math
ill try doing that
Movetowards -> nextPosition..
if(distance to nextPostion < threshold) -> nextPosition = nextNextPosition; and so on
a loop would be ๐ค
Hey, Just wondering is this a very resource intensive way of doing this raycast? I'm optimizing the code/game as much as I can and this being called every tick could potentially be overkill?
(but I'm unsure) I need to happen the instant the player looks at something so I guess there is no other way realistically
the raycast takes less than ur actual Tag comparisons
Oh nice, So it's not as expensive as I thought
i wouldnt worry about a single raycast every frame
ohh no ofc not..
raycasts are cheap
id only worry if ur doing like 100 raycasts every frame..
then its probably time to reconsider ur code ๐
i have a sailboat that shoots about 30 every physics tick. not soo bad
Actually that's a point. I have a seperate raycast script that is for doors, but in theory I coulld merge that into this 'raycast controller' and use the same ray
Donโt overthink it tbh
or u can disable the one's you're not using
You should be using && rather than & here. Also look into the profiler so you can see how long things actually take to run
hey guys, what type of vfx should i do for a jumpscare? i can also tell what type of jumpscare it is if u guys need more info
This is a code channel
later on u absolutely could use a single raycast script..
i use Interfaces.. if the object has one of those interfaces it just calls the correct function
void Update()
{
ray = new Ray(cam.transform.position,cam.transform.forward);
if(Physics.Raycast(ray,out RaycastHit hit,distance,mask))
{
if(hit.collider.TryGetComponent(out IInteractable interactable))
{
cachedInteractable = interactable;
cachedTransform = hit.transform;
cachedHitPoint = hit.point;
if(Input.GetKeyDown(interactKey))
{
cachedInteractable.Interact();
Dbug.Italic($"Interacted with {cachedTransform.name}");
}
}
else
{
ClearCache();
}
draw = true;
}```
3 different types of interactable objects.. all 3 just using an IInteractable Interface
Yeah I'm doing something very similar
actually, the same thing lol
๐ช
ya see it would be very simple to just manage all the interactables in that single raycast script..
but as said.. dont worry too much about it.. unless u feel u need to
components > tags in a lot of cases like that ye
i cant see much of this script.. but it appears that it doesn't respect the Single Responsibility principle... (seems like 1 script is managing all the interactables so far)
that'd be more concerning than using too many raycasts.. just food for thought ๐
but if it works.. and its manageable.. its bout preference
u can remove the .gameObject. part of that if u wish.. u can just tryget from teh collider.. just a ๐ก tip
Alright I've literally done everything i cannot find a singular reason why this is causing this error
static bool IsDown(InputAction action) => action.phase == InputActionPhase.Performed;
the exact same code that i even copy pasted in to check from another script is working in the first script but isn't working in the second. I have absolutely zero idea why this is happening and i haven't found anything in the unity docs or by looking anywhere i can online.
Assuming that line is the one throwing the error, action is null
Should this be static? Also, what if action is null?
Its static in the first and action shouldn't be null because it isn't in the first script
my brain kinda shutdown for a moment, how do i call classes from other scripts? without inheritance
static / singletons, serialized references
idk either i just use get component and pray it doesn't fry unity
Well.. whatever's calling it is passing it null apparently
any other ways?
it doesnt matter what happens in the first script. the code is telling you it is null, so it is null
Probably
[SerializeField] private MyComponent myComp
Choose the best way to reference other variables.
check out this page.. it covers a few
But it shouldn't be null there is nothing else referencing it in the first script that wouldn't be in the second script so there is literally zero reason that it shouldn't be working since i even copy pasted it
"shouldn't be null". but it is, and the code is telling you it is
it isnt lying. you need to debug why and how you are passing null to it
The error states that it's 100% null
I've been trying but it just hasn't been working
Now you've just got to figure out why.
follow along with its progression... try to find when it happens
Your error lies elsewhere
alright i know this is stupid but im just gonna add a character controller to the script JUST incase to see if it fixes it
lol.. ok
Yeah it didn't work
The error says that action is null. It's null.
Guaranteed
Yeah i know that
ty
So, maybe try some logs or the debugger to find out which thing calling the function is passing the null
dont you need myAction.Enable();
@split plover perhaps look through the stacktrace to see where action is coming from
What is stacktrace ๐ญ
I dont even think i have that
its saying its happening when the 30th line is called which is when the function with an if statement is called
but idk whats wrong with the if statement
The stack trace will show you first what line the error is on, then what line called that line, and so on all the way out.
So, look at the line where you're actually calling IsDown, and that line is passing null to it
Show some code
You ought to be calling IsDown somewhere with some variable that's null
Well unrelated but i added returns to the if statement and the function and now its back to saying that the isdown bool is the thing showing null again
this is all i can really fit in a screenshot and i dont wanna flood chat
it is everything thats included in the errors thoug hso
whats that lonley GetComponent doing nothing
So... Mi Input is null
wdym
So, if that first line is the one that's calling the line that throws the error, M1Input is null
GetComponent<MovementScriptBaseCharacter>(); is doing nothing
Your third line of start does literally nothing
Its how im calling the isbusy bool from my other script
There likely wasn't an object-action called "Mi" when Start occurred
so people cant do stuff while doing other stuff
No it isn't
mi?
You literally are not using the result of that function
no it isn't. you're just getting the component and not doing anything
wait where are you seeing that
I think you misunderstood what GetComponent does
i dont have anything called mi
You could delete that line and literally nothing changes
he's referring to M1
m1Input
oh
you're trying to get actions from playerInput before you assign playerInput
also, !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.
if you don't want to flood chat, see the "large code blocks" section
I'm surprised there wasn't an nre prior in Start
-# it would be slightly more performant
I was almost hoping this didn't work so that I didn't feel as stupid ๐ญ
there mightve been ๐คท
put a break point or Debug.Log(M1Input) after M1Input = playerInput.actions etc.
or maybe the object wasn't active or the component wasn't enabled lol
What do you mean
As a way to check if it is being assigned a value
Basic debugging steps
was nav right? were they just not enabled?
wdym? the issue was that i had something referencing the player input before i got the player input component
oh idk lol I was just reading the docs i never used Input Action like that had no idea it had a method
yeah pretty average of me to make a simple mimstake
better than making big mistakes..
Honestly atleast big mistakes would be harder to miss
this would probably be easier just to assign the InputAction in the inspector
(no worries about event order since its Dependency Injected)
big mistakes may require refactoring entire systems tho..
much easier to change a keyword or two ๐
Some big mistakes are unrepairable. You ought to never ask for pain.
atleast i would learn from the mistakes, im probably gonna forget about what i just did and end up doing it again
i dont have those but if i did then believe me they would be
don't worry for me it takes 3-4 mistakes on the same thing to actually learn from it
thas about average tbh. if u dont make a habit out of it manually.. u have to make a habit out of it organically
I tripped on the same step in school so many times like years ago that there was an indent on the stair
i got in trouble cause they thought i was kicking the stair not tripping on it
shoulda gotten a plaqe?? <plack> ? with ur name on it installed ;D
you got metal shoes?
i mean there was a nail in the shoe for some reason
but the stairs were pretty weak, idk what it was made of, could've just been the paint scratching off too idk
okay.. im all about reminiscing but we're trending offtopic ๐
true
anyway did you add the log and test if m1 is null in start
Yeah thats working now
it doesn't even recognize the input though so i'm probably just gonna take the lazy way and use keycode anyways ๐ญ
plaque?
actually let me try something
you should def learn a bit more of input system before going further with it
looks weird
there is literally so many ways to use it , can be overwhelming at first
nah bro trust me ๐ฅ
yup thats it tho.. thanks ๐
btw isnt InputAction serializable? You could assign it in the inspector anyway
it's french, of course it is
don't you need InputActionReference
i believe this is the way im using it
for now i stick to "Generate C# " class and just use type safety
I will probably regret it during rebinding though lol
thats the reason im doing it this way ^
i believe
im just using sendmessages now, and i agree with nav on this
so i got these classes. i am trying to call them from another script. doesnt seem to work the way i thought they did, i am tryna find a way around a serialized field then dragging the script, anyway to do it incode or nah? i dont want inheritance
you didnt add the namespace its declared in
do you really need namespaces though
if you're a beginner you should probably just avoid them to reduce complexity
also why do you have 2 PlayerMovement classes lol one MB and one poco
anyway if you wrote FirstPersonMovement.PlayerCamera then it would work
public FirstPersonMovement.PlayerCamera cam; or
using FirstPersonMovement; //in header
public PlayerCamera cam;
So before i do this im gonna assume it is 100% a stupid and non performant way of doing actions by switching action maps every single time i want to switch between the character moving and attacking
and i should probably jump put everything in the same action map anyways
should i do it anyways
i havent alot of experience with input system but that does sound silly
i should?
like would it be smart so i could learn the input system better
anything u can do will help u learn.
if you wanted it to be recognized..
even if it doesnt work out
yeah it could make for a really unique game idea too
True i probably wont do it
holy shit, it worked, tysm
namespaces are like folders your classes are stored in
nav mentioned it first but np ๐
The real fix was not trusting myself โค๏ธ
yeah i didnt know i had to mention them entirely, it hought it was visual organizing
if u store things in a namespace u have to reference that namespace somehow
nah that would regions
#region Fields
private int one;
#endregion```
i see, understandble, tysm guys
Im making a car game but
I'm stuck trying to make my car drive properly, even though I added a Rigidbody and tried some scripts it just doesnt move
forces are too low.. or the rigidbody is too heavy / too much friction/drag
forces being too low is the first thing i always check
i can sent screen shot if you want
the code would be more helpful
kk
possibly a screenshot of the Hiearchy setup and Inspector of them
btw i got the code from yt
are you sure it was not null after Start method ? how did you verify it was working
Maybe show the new error and it's stack trace
that can be multuple things on 32
you have to log and see which one is null
before use put Debug.Log
i already know its the M1Input
i tested before
i tested it is the exact if statement
then again.. you need to test it in Start and see if its assigned
Movement script seems to be null
im just gonna make sure M1Input = playerInput.actions.FindAction("M1"); this is perfectly fine right (the action is called "M1")
look put this line
M1Input = playerInput.actions.FindAction("M1");
Debug.Log($"isM1 null? {M1Input == null} ")`
Its not null
oh
ill put that instead i just put Debug.Log(M1Input);
ohh weel colliders ๐คข .. sorry i can't help with those
maybe i need to do it in a diff way?
Its not null
so like now im just confused
then its probably movement as Dalphat mentioned
https://assetstore.unity.com/packages/tools/physics/prometeo-car-controller-209444 if u want u could download an asset that works out of the box and perhaps inspect their setup.. and their code
maybe I'm missing something but I don't see where you're actually moving the car?
or even adapt it to what u need
kk btw i got the car from asset store maybe the problem is in the model?
its within these functions
Im so confused it only stopped working once the M1Input started working ๐ญ
im genuinly going to go insane
maybe i need to add binds or smth
because you fixed 1 error and now moved on to another most likely
if its a NRE stopping the rest of the code cannot run
u can test ur input.. with Debug.Logs
thats the way these things go
i did test it with debug
is rotating the wheels what moves the car? I would have expected you'd just wanna apply a velocity or force to the whole rigidbody
go step by step.. first log ur inputs and see if they're working..
then so on and so on
could be a friction thing
nah, the wheels rotating are just visual..
no like i even removedthe M1Input part before and the main code started working perfectly so i know it was working before
it kinda slides to be honest..
i can send the rig body if you want
atp should i just put everything in a single script so i dont have to deal with this
again only way to know is to put Debug.Log before that if statement and check each item that can be null, then go from there
you cannot move on to something as a fix without finding the root cause
wheel colliders are rough to work with.. (even as someone thats experienced).
When you modify too much code, the inspector could reset some fields. Your movement script variable is null atm
probably 80% of dev is debugging
i prefer hovering cars with raycast suspensions.. and fake wheels
then where is the car being moved? it just looks like he's rotating the wheels by adding a torque
I dont know why it would be null
another random question, so after i called my class from the other script, can i just like... make it run the entire class? exacly the same, no changes
thats why we Debug lol
whats that
yea this would be a much better solution imo
wdym "run the entire class"
Use your eyes and look at where you're setting it's reference (through code, inspector, etc)
wdym where im setting its reference
it's just when a serialized field's name changes, because the inspector/serialization just sees one field appearing and another disappearing
Where do you assign movement script it's value-reference?
eg
myItem = someValue
or inspector does the same
above start where i assign all my other variables
holy fucking shit
I'm pretty certain that's where it's declared..
And that you're assigning it through the inspector
and if i do it that way will the wheels move like a normal car does
did you assign MovementScript in the inspector
show that
wdym in the inspector?
ay yea it is torque that moves it
before coding anything you should probably learn what the inspector is..
no offense lol
I mean i know what the inspector is
so what confusing about what I asked lol
show the inspector for where MovementScript is
100... u can still rotate the wheels with code.. (can tie it to the cars velocity.. so the faster the cars moving the faster the wheel graphics are spinning
I just dont know what you mean about assigning it in the inspector
so ur basically just using physics to move the actual car.. and the wheels are just there as graphics.. and whats keeping the car up off the ground would be raycasts (suspension forces)
can you send me a vid link pls?
it doesn't even let me do that
It's a public field that I'm assuming you're assigning through the inspector. Also, wth is up with this line in Start?
Jinx
wdym
that IS WHY its null
thats where i assigned it
In this series of videos we will learn, How to make a simple Car movement, Camera follow and add Engine sounds to our Vehicle in Unity 3D by using C#.
In this specific video we will learn the basic and most efficient way to make a Car move, steer and brake by using Unity's Wheel collider component.
SUBSCRIBE FOR MORE !
โค https://bit.ly/3dR...
thanks
okay should i select capsule then
i think this is a good one.. its a long series.. so it goes into lots of details
may not be what u want. but u could def learn from it
you have to drag inside the object with that component
btw can i message you in dms if there is a problem
nah, i dont accept DMs sorry.. but u can feel free to ask here
well it doesn't do null errors anymore
great minds think alike hehe ๐
im not the best person to be asking tho.. im anti- unity wheel collider ๐
yeah but there is a chance that you are not online when i ask
which is why you should ask here
what does that mean? did you assign it now and it fixed?
Well the if statement itself still isn't working but atleast im not getting any errors
unity actually has a documentation page that goes thru their wheel colliders.. and how to set up cars in the heiarchy and so on
let me see if i can find it for u
at least you can see with some basic debugging these are easy fixes, just gotta breakdown and narrow down where the issue is to fix
kk but first ima try to watch the tutorial
https://docs.unity3d.com/Manual/wheel-colliders.html heres all the info you'll need
I dont like the idea of easy fixes taking this long ๐ญ
kk thanks
the 4th one is important ๐
You've got to be a bit more creative in your response. It's a rule to help better acquire support and not just make folks explain everything because a person is unwilling to explain what they do not understand. #854851968446365696
ok..
well for now its not as quick but with time you get to them quicker
I used to be hung up on a problem with a string being misspelled and spent 3 hours on it..
just the way these things go
The problem is that i don't even understand why i don't understand or what i don't understand
i feel like im blind in all of this
so basically, i called the class. i just want it do the exact same thing that wirtten in that class, i edited the script, i tried calling it using a function, but seems i am struggling
oh god
that just sounds horrible
yes which is why I started Opting for Components and type safety instead of Tags ๐
you live and you learn
"easy" is always in hindsight and relative ๐
just making sure this is the left mouse button right
nav getting messed up by string formatting?? what in the world.. cant be lol
So.. which part of my response were you not understanding? There were two parts. You can only pick one at a time to work on.
i mean.. what else could it be
public void FadeOutVig(float duration)
{
StartCoroutine(FadeVig(1, 0, duration)); // from transparent to opaque
}
public IEnumerator FadeVig(float startAlpha, float endAlpha, float duration)
{
float elapsed = 0f;
while (elapsed < duration)
{
canvasGroupV.alpha = Mathf.Lerp(startAlpha, endAlpha, elapsed / duration);
elapsed += Time.deltaTime;
yield return null;
}
canvasGroupV.alpha = endAlpha;
}
any idea why the FadeOutVig(); doesnt do anything
damm has it really been 5 years since I picked up unity...time flies..
u debugging any of those values to see if they're doing what u expect
Im at the point where still everything i search up isn't working and its the only thing i could even think is wrong with it
btw the game im trying to make is smth similar to the need for speed games (i know its hard to do but i have 3 months and i think that i can at least do the basis)
soooo... i think i am doing everything possible wrong
what do i debug
What do you mean "Called the class"
like does assigning alpha actually change anything
and is the lerp moving
Also you have functions in your function
why is everything nested in that function
you're putting everything in a method
wont know until u try.. and once u do u'll get a better idea of what u want to do.. whats working for u whats not working for u..
everything in the entire script works but the lerp
theres always alternative ways to do everyhting in unity
you should probably step back to learn basic c#
cause i just want to call the function, nothing to edit, just purely there
got a point
Okay, so, you have a variable of that type? Is that what you mean?
kk
you can't just cram everything in there and expect it to do what you think it does
Update wont run properly if its nested inside another function @thick spoke
Unity wont be able to find it
i tihink so...
print elapsed inside the while loop and see if it's doing anything
So, you've made a variable named playerCamera that can hold an instance of your PlayerCamera class. What do you want to do with that reference?
You might need to follow a tutorial or somethign, seems you're just guessing your way through this lol
...oh.... any ideas around it before i go re-learn c#
also what is canvasGroupV
What are you even trying to do by wrapping Update
you havent really explained what you are trying to do.. forget the "calling the class" part. explain the end goal here
canvasgroupV is a canvasgroup
"if it works, leave it"
If im using the left mouse button do you guys think its just fine to use a keycode? cause like who would even wanna rebind that anyways ๐ญ
but it wont "just work" lol
just letting u know now tho... wheel colliders are rough.. (said that bout 3 times already)... maybe an Arcade setup is better for what ur going for..
unless ur making a racing game or something arcade car controllers are pretty good..
(they involve just basic rigidbodies that are hovering off the ground w/ raycasts and "suspension forces" with the wheels drawn in after..
or theres a version thats just a ball (sphere) thats rolling around.. and u then draw in the wheels..
but again.. its up to you. i'll let u cook now ๐ฅ
Does it work though
"If it works, leave it" is a fine heuristic -- if it works
coding is one thing that i feel this only works if you dont understand the code yourself, which if you wrote the code there is probably an issue there and if you didn't write the code then you should probably atleast try to understand it
well, the elapsed just stays at 0 forever
those first two points are just, incorrect?
kk
is your timescale 0
my timescale is fine
I mean if you wrote code and you dont understand the code then there is an issue isn't there
ya, never seen a baby run first and learn to crawl second ๐
wait wtf i just realized why is elapsed frozen
im trying to make the driving more realistic.
i mean i learnt to fall before i learnt to stand ๐ฅ
okay.. then ya if u want realistic i'd say give wheel colliders a shot ๐
i wish u the best
not exactly something easy to do, thats why assets exists
yeah, which is why you generally shouldn't do that
you understand it first then you write it
analysis before synthesis
so wait you were disagreeing with me before but now you're agreeing with me?
kk i will see which one to use
this video helped me greatly, its raycast based.. it has a nice feel
https://youtu.be/CdPYlj5uZeI?si=2iEkdyBl_xDPB9Q9
A detailed look at how we made our custom raycast-based car physics in Unity for our game Very Very Valet - available for Nintendo Switch, PS5, and Steam.
BUY NOW!! https://toyful.games/vvv-buy
~ More from Toyful Games ~
- Physics Based Character Controller in Unity: https://youtu.be/qdskE8PJy6Q
- Instant "Game Feel" Tutorial: https://youtu.be/...
^ yes thats the setup i was describing earlier
he also does that with his character controllers ^
unique feel for real
@polar acorn @rich adder so i am tryna attempt to make a script, where i can call functions from it. as you saw, i have a class in Script A, i managed to call that class from Script B. after that, i just want the code there, like if i paste this code rn inside the script, it works perfectly fine. i want to do the exact same thing, but call it from another script.. i doubt you understood a thing
kk thanks
You'd reference the instances
Which functions from your script do you want to call
this only works if you dont understand the code yourself
this implies you just don't know enough about code yet - you just need to learn more
which if you wrote the code there is probably an issue there
code you write yourself generally doesn't tend towards have issues. sure maybe the first time you missed something, but just because you wrote it doesn't mean it'll have issues - this again just points to inexperience, trying to write code before you actually know what you're doing
if you didn't write the code then you should probably atleast try to understand it
this is true
I mean if you wrote code and you dont understand the code then there is an issue isn't there
it's certainly an issue, yes - it just shouldn't happen. if you don't understand it, you shouldn't be writing production code, you should be trying to understand it first
thats the point, i dont have a function to call :/ i am tryna just cram everything to 1 function and call it, which is quite wrong, i tought it would work for some reason
let me see
So if you don't have a function to call... why are you trying to call it?
my point is that if you dont understand the code you wrote, there is a problem, and if he's able to use the excuse at all then there is kinda an issue cause it would mean he doesn't understand the code
What are you trying to do
i think you're throwing everything into "call the thing" even though that's not really what you need
scriptname.ThisFunction();
i was trying to create a function, by basically pasting ym entire code inside of it and hoping for the best, it obviously didnt work
if you don't understand the code you wrote you probably shouldntve written it
Don't try to use code words, you don't understand them. What are you trying to actually do
What is the thing you want to be happening
i think all i need is to learn c# from scratch
Make a public field. Drag and drop the object you want to reference (using the inspector) into the field. You will now be able to access all public members of that object.
I mean yeah
idk its quite hard to explaini already did that part
what is it that you're actually trying to do with the class
what are you trying to achieve
Right. Now, what are you trying to do with that reference
you're falling into an x/y problem here
let me try, i just want to run the class inside of another script, like i got a script which hold some classes, i want those classes to be called and ran in other scripts
You have an object in a box. What thing do you want that object to do
That's more code words
"Run the class" is nonsense
Stop trying to use code words
Tell me using actual things you want to see
"I want this cube to move when I press W" kind of stuff
what is the outcome you want
right now you're talking about what you're trying to do to achieve that outcome
see the link here
I think you're misunderstanding stuff. Classes don't run. You can run code from a class instance in another script by referencing the class instance.
You know what, I have an idea. Let me rephrase how this works into something more familiar:
i wnat the class to run without writing the whole code in the same script, i want 1 big script, hold all classes/functions, and from other script, i just say, run this thing
gulp-
classes don't run
that's just not a thing
yep, and thats exacly what i am tryna figure out,
A Class is a Cleanroom, full of Machines. You can have your Bender and Extruder and whatnot in the Cleanroom, right? Each one of those machines does a specific thing. You give it a metal plate, and it spits out a metal pipe. Right?
@thick spoke go read the link here
yeah i know thats where i am lost, i want smth similear to that
were getting somewhere, i figured out that when i touch the triggerbox, time.deltatime freezes completely. i just need to fnid where that happens
we have no idea what you want because what you said just doesn't make sense lol
so that would imply you're setting timescale
You set up your AE2 wires to feed in a bunch of different kinds of metal, and your cleanroom routes those metals to your various machines, and spits out the results
i want wireless connection, so basically it got my stuff inside the cleanroom with a ae2 wireless connector, when i want smth from it, it sends in the items and the output gets exported into my ae2
are you getting multiple elapsedTime/deltaTime logs?
So, when you're setting up your auto-crafters, you just put the Interface on the input of your cleanroom, and let the machines work, then you pipe it back into the AE2 system
That is calling a function. A function is a singular machine.
A class is a cleanroom.
It's a collection of machines, some of them might feed into each other
but the cleanroom itself doesn't do anything. It just holds the machines
nope, just one number around at 0.3 - 0.4, after i trigger my jumpscare/triggerbox thing it freezes it (debug.logging in update)
They need to be in the cleanroom to actually work, but the machines are what do the work
is it possible to call the entire cleanroom at once? basically a chain reaction, or a ae2 subnet, it gives items, it does everything on its own and just gives you the output, which the thing you actually care
what do you mean by "freeze" exactly?
There's no such thing as "Calling a cleanroom"
The cleanroom simply contains the machines
the cleanroom doesn't do stuff. it is stuff. you can have the stuff inside do stuff
pattern providers ontop of input hatches basically
like its moving
0.34
0.4
etc etc
jumpscare happens
frozen completely at the specific value it froze at, like an example:
0.368382
i am tryna do a subnet, give it items, and filter teh storage buses and see how it goes
Right, but a cleanroom that doesn't have any machines in it isn't going to do anything, right?
and you're getting multiple logs that say that number?
one debug.log, all i did was
Debug.Log(Time.deltaTime);
basically a chain reaction
(a chain reaction implies doing multiple individual things)
but are you getting multiple logs
yeah, but i think i got my machines in the picture i sent earlier, right?
no, one log
Let's say you've got a cleanroom that contains a single production line. You'd still need a machine to start it, and that machine pipes into the next, into the next, and so on. You're not giving items to the cleanroom, you're giving them to the first machine in the chain
cool.. you ghost pinged someone lmao
ye
The cleanroom just passes the items along to the first machine
you don't need to ping at all, i'm still in this chat
so no that's not "freezing"
is the entire game/editor frozen?
oh yeah, got a poin
no, no timescales in any script whatsoever
So get a machine to specifically tell all of the other machines what to do. The clean room doesn't actually do anything other than house the machines.
nothing
that's not what i asked
if u have a class u dont want running at a certain time its simple as Disabling the script (component) or disabling the entire gameobject
ok let me rephrase my question using gtnh
Explaining Code using GregTech Metaphors
ye, i answered the first one too
frozen as in, can you interact with anything in the game/editor
yes
i can interact
with everything as normal
ok so there's not actually any issue with Time.deltaTime then
the loop just exited normally
it wasn't "frozen", nothing was frozen there
but it just stops?
so have you checked elapsedTime?
i'm new to unity, any tutorials or tips i should use for starting out?
the logs stopped, not Time.deltaTime
check the pins
check out !learn and the pinned resources
:teacher: Unity Learn โ
Over 750 hours of free live and on-demand learning content for all levels of experience!
thanks ๐
https://www.youtube.com/playlist?list=PLFt_AvWsXl0fnA91TcmkRyhhixX9CO3Lw : my default response
but that doesnt make sense, elapsed is still equal to 0 (even tho im setting it to deltatime)
you aren't though, you're adding deltaTime
so i should set it equal ur saying?
//////////////
void Update()
{
Debug.Log(Time.deltaTime);
}
public void FadeOutVig(float duration)
{
StartCoroutine(FadeVig(1f, 0f, duration)); // from transparent to opaque
}
public IEnumerator FadeVig(float startAlpha, float endAlpha, float duration)
{
float elapsed = 0f;
while (elapsed < duration)
{
canvasGroupV.alpha = Mathf.Lerp(startAlpha, endAlpha, elapsed / duration);
elapsed += Time.deltaTime;
yield return null;
}
canvasGroupV.alpha = endAlpha;
}
oh the log was in Update
yea
so.. the object got destroyed/deactivated or the component was disabled
i have it in update
the object of?
you shouldve had it in the coroutine - debug the values where theyr'e actually being used
the object that the component is on
u mean the script component, right?
..sure?
so if the component was destroyed, the object was deactivated, or the object was destroyed, then the coroutine wouldve stopped
what if i just disable the Is Trigger
on the trigger
instead of destroying
can i do that
that would make it a solid collider, probably not what you want
i have no idea what you're trying to do
what if i just disable the box collider completely ๐ญ ๐ญ
go read that
figure out what behavior you want it to actually have
what the flow is between these actions
i'm not psychic, i don't know what your game is
perhaps form a complete thought before hitting enter
when u hit the trigger, canvas goes fully visible (canvasgroup)
monster movement happens using a while loop to transform the position to a set target position using an empty gameobject
destroy the monster and trigger to avoid double collisions
ok, and what does destroying the trigger represent
forgot it
what does it achieve though
i meant what does destroying the trigger achieve lol
avoids double hits
like if the player walks in it again
it might re-trigger it
i dont want that t o happen
this is for when the player hits the trigger?
yes
so this script is on the trigger?
i used a ontriggerenter, where it checks if the collider was the player and it starts the MoveMonsterJumpscare Coroutine