#💻┃code-beginner
1 messages · Page 758 of 1
private void BuildMap(string outPath)
{
Debug.Log($"IsValid={Steamworks.SteamClient.IsValid}, IsLoggedOn={Steamworks.SteamClient.IsLoggedOn}");
Debug.Log(outPath);
if (Directory.Exists(outPath) == false)
Directory.CreateDirectory(outPath);
ModToolUtility.BuildAssignedBundlesFor(mapAsset.mapScenes, outPath, BuildTarget.StandaloneWindows64,
BuildAssetBundleOptions.UncompressedAssetBundle | BuildAssetBundleOptions.AssetBundleStripUnityVersion | BuildAssetBundleOptions.ForceRebuildAssetBundle);
var json = JsonConvert.SerializeObject(mapAsset.mapBundlePaths, Formatting.Indented);
Debug.Log(json);
File.WriteAllText(outPath + "/mapmanifest.json", json);
Debug.Log("Created map manifest");
}
why am I getting this error? Doesn't matter if folder exists already or not it throws that error until I press cancel then it builds the asset bundle anyways??
iirc this relates to having scene files assigned to assetbundles that have non-scene content?
if that maybe helps
Hello. I'm from Brazil and I'm still a programming beginner. I have to develop a rhythm system for a project. Does anyone have any tutorial suggestions?
obligatory reading for any rhythm game in Unity: https://www.gamedeveloper.com/audio/coding-to-the-beat---under-the-hood-of-a-rhythm-game-in-unity
Quick guide to some of the programming that goes into creating a rhythm game. The article uses Unity to build a game, but the principles could be applied to most engines.
Thanks for the suggestion. I appreciate it.
hii guys, i have a question. is there a way to speed up unity compiling after script changes? it takes seconds and seconds even if i change a single number in my script hahahah
maybe some way to compile at the same time i make changes or idkkkkk D::
You can disable automatic refrresh in the editor preferences to prevent it from compiling automatically(would need to trigger it manually when you're done with the changes though).
thank uu, does it speed up my development?
If automatic compilation in the middle of script changes hinders your development speed, then yes.
something you need to get used to at this moment, no way to speed up. Instead of changing numbers in script and compile again, expose them in the inspector so you can change them with variables there
thank u guys, appreciate it ❤️
sad reality of old backend, they're supposed to be merging to new core clr so hopefully that happens compile will be much faster
i know there'a a "tool" called "hot speed reload" or something like this
but idk if it's worth
hot reload ? don't know much about it but seen mixed feelings on it
You could also disable domain and scene reload on compilation, which should speed up iterations quite a bit, but there are some things you need to be aware of ig you do it. Check the documentation for more details.
Sure that wasn't nike
So hot reload is a major thing in Unreal engine 5.. and it was buggy as heck so it was recommended not to use it as it just lead to crashes etc
Why?
they tell me to just do it and then tell me to do non beginner stuff
Well doing non beginner projects can also help to understand how things work as you will do more research and search out in google for solution
just do what? and what "non beginner stuff"?
words i dont understand
i can't know what they are if you don't say the words
you can ask about those words or keep not understanding them, which would you rather
Start with unity learn
And if general c# you can check out Microsoft education page
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
I'll find a link for you
ty
hey I'm trying out the navmesh system and I'm having a problem with the enemy starting halfway inside the surface area
Is the nav mesh agents property set up right, if you have a capsule and it's a child object you raised 1 unity unit up, and the agent component on the main parent object it will make the capsule go down by 1 unit
my enemy hierarchy is a GO with just a transform and navmesh agent with 2 children, 1 for eyes and 1 for the body and they both have a capsule collider and mesh
the agent has to be on the same GO as the collider?
I mean I'd put your colliders onto the enemy as well as the agent as opposed to body
And set it properly, the eyes wouldn't want to have colliders unless they are physics objects
awesome thanks
works
I thought I could have a parent GO just for the navmesh agent and the script that I could attach to with children that contains the colliders, etc.
In general parent passes down to a child.. scripts go onto parent and on the rare occasions a child needs a script it should be able to be called from the parent too
oh so I'd just get the navmesh agent from the child in the parent script?
For a 2d pickup system. What's the better approach?
- a 2d criclecast and then iterate over the pickables
- Registering/unregistering via ontriggerenter then iterating over the items
I'm expecting my pickup range to be modified via buffs
I kinda know how DFS works, but I have no practical examples of using it. How did you do it?
Hey I'm making a local mulitplayer game, I wanna add a Lobby in which the players can already spawn.
Those players are stored in a static List. When changing to the next Scene a game initator is looking through this static List and is supposed to spawn all player gameObjects in the List.
The problem is that the gameObjects are getting destroyed when loading the next Scene. Does somebody know how I could prevent this or has another take on spawning players in a new scene.
I want to spawn the same gameObject because I think I dont have to handle any things like, which controller is connected to which Player because thats handeld by the Player Input Manager.
i want to play this audio called thruster when the user presses his left mouse button and to stop when he releases it. i know that i am supposed to get the audio loop set to true, but i don't know what to do to access it...
you cant loop audioClips, only the audio source has a loop setting you can set to true, now you have to load the audio clip into the audioManger and play it now
also, audioManager is an instance of the class Audio
i do have the audio for sfx set into the audio manager...it's called SFXSource
or should i create another moethod inside the Audio class to set loop = true?
just a minor nitpick, generally in at least unity the term Manager tends to be associated with a Singleton / singular instance of a specific class. ideally if it is 1 singular manager the class should be AudioManager or if it's not it might read better as AudioController
what do you mean when you say singular instance?
no i think its just rather audioManger.SFXSource.loop = true; instated of audioManager.thruster.loop = true;
i have a problem
like if an enemy has a component that handles audio, that is more of a "controller"
but if this was a class that is only meant to exist as 1 instance only, that is more of a "manager"
this is correct but also in PlaySFX() you would need to use Play() instead of PlayOneShot()
sure
but the thing is...i have other sfx instead of just the thruster. won't it start looping them as well?
i get an error on the last asset I try installing
thats what im trying to say, you can only enable a loop on a audio Source and not a audio clip
does Play(), inherently set the audio clip for a looping mechanism?
the audio clips are just "used" in the audio sources
is the asset for your unity version?
look this is rlly anoing and I tried fixing by switching the location
unity player
the opposite, Play() plays the clip in that audiosource and if that audiosource is set to loop, then it will loop
as the name says, PlayOneShot() will only play one shot of that clip regardless of the setting
wait, then how the hell do i manage two diff SFX, one of which i wanna loop and the other which i don't wanna loop?
i try making a vr game but the first step that is hard to fail, I fail at!! AND IT'S ALWAYS MEEEE 
just create another source, its not weird to have multiple audio sources for each sfx
yea thats a pain, most of the time we need one audioSource for one specific audioClip
It can get abit more complicated the more you get experienced and comfortable with it but in general you probably want an AudioSource for each "kind" of sound seperated by if those sounds might be playing at the same time
can anyone just help
it would be so much easier if we could set an audioclip to loop....
that would not help you
why not
ok so look at the latest img i sent in this channel
imagine this is your audio source
this is 1 AudioSource/Speaker
then you put 1 AudioClip/Cassette into the AudioSource to play it.
you can play the song once, on repeat etc. but if you want to put another AudioClip/Cassette in, you'd have to take the current one out
except with playoneshot, but that is not compatible with looping
you can also do audioclip.length then play it again after that length also
pls HELP MEEEEEEEEE
What sounds are you trying to play right now? Some context might help
I CANT INSTALL UNITY PLAYER
or you could implent a boolean in your PlaySFX Method, one that would enable loop, or disable it
bro chill
if you gonna cry like that nobody gonna help you
when i leftclick, i want thrusters to work and i want an audio clip to play on loop while it's active
Thrusters on?
it's active when i press leftclick, and stops when i release
as in
spaceship
ok cool, and you play as the spaceship right
Lovely, Just so i'm sure, could you post the full script that deals with that mouse stuff you showed here?
A tool for sharing your source code with the world!
do you have enough storage space on your machine?
Just make an audio source specifically for thrusters. Set it to looped. Whenever you want to play it, just do audiosource.play, then audiosource.stop
yes
ya doing that rn
yes
you mean thats what you already did and it's not working or you're currently doing that to fix it?
no, i meant, i am trying to change it to what you said, which is what the others recommended too
oh alr gl
Thank you, gonna give you some more general advice that isn't the fastest/most direct way to solve your problem but might help you understand how to do this abit better in the long run
so first of all, your Audio class has some shared responsibilities, it's meant to play some stuff for your player but also it's got stuff like the music for the game. Personally I think it's better to separate this kind of thing as it's important to consider which part of your code should "own" something.
eg. make
AudioManager (or even in a/the GameManager)
-Exists in the scene a single time
-Is basically "god" and is responsible for the "global" audio (eg. music)
then honestly put the audio stuff related to the Player/Ship in Player directly, separate from the AudioManager
then from there, like what we've suggested previously have an AudioSource per type of sound so they can be configured for different purposes. if your game is simple that might just mean an audiosource per audioclip
if that is confusing let me know and/or feel free to ignore for now 😄
let me know if i am wrong. what you are saying is for me to make a class called AudioManager which doesn't really have any members which are audioclips. Ideally i would wanna have the audioclips present in the player controller script and access AudioManager to play clips the way i want to using it's methods?
I understand why you would think that and that's not a bad line of thinking but I mean more like
AudioManager (or directly in a GameManager)
AudioSource musicSource;
AudioClip musicClip;
private void Start()
musicSource.Play();
you could potentially do what your describing if you want more control in that regard later down the line though absolutely
but im more so pointing out how stuff will be abit easier to manage when each part of your game "owns"/controls that part of the game specifically
and this is where i say that i kinda understand the theory part but i don't know how it's even applicable. Once this game is over, and i start my next one, i am gonna have to refer to it....
ya...the way the tutorial managed stuff is absolutely dog
Another example of this is in your Player class right now, your managing the games high score and scene reloading. Should the Player be responsible for the games high score and scene reloading?
Are you using this video as a reference? I really like this one. https://www.youtube.com/watch?v=N8whM1GjH4w&t=48s
In this Unity 2D Tutorial we'll learn How to add MUSIC and SOUND EFFECTS to a Game.
In this Audio Manager Tutorial we'll add background music and various sound effects to our 2D Platformer game. We'll Create very simple Audio Manager C# Script to control music and SFX.
Enjoy the video ☕
——————————————————...
the player being responsible for moving around, activating it's booster mechanic, reacting to incoming collisions etc. all makes sense for the Player/Ship to be in charge of
this was what i referenced after, that's why i had the same variable names
actually just try to restart you pc and install it again
helps sometime
By the way, audio managers are usually more for 2d games. They are still applicable in 3d games but because the sound is expected to be "global" (mono), it's not used for all sounds in 3d games.
thx for the info but i wont be making any 3d games, my pc wont be able to handle it xD
its just a naming convention / responsibility allocation, it has no correlation with if the game is in 2d or 3d
The audio manager they are using (the one in the video) is used in a different way compared to what you're talking about
It's a global audio manager that plays oneshots of sound clips. The audio manager is referenced in scripts and a function is called that plays the oneshot.
that isn't correlated with 2d vs 3d
it is, as the audio manager is always expected to be 2d (mono) since it's global
My unity wasn’t installing because I had it installed on two discs the C and D and the C was completely full and I had it installing on C so I had to uninstall it on drive C. Now its installing on D
The sound itself is played from the audio manager, it doesn't change position. That's why it can't be played in a 3d space if you're looking for stereo sounds.
wdym i have intel(R) 13700 i7 and no gpu (I do have intergrated gpu) and for me it works fine
maybe try getting rid of temporary files on c, also, i think this is more a topic for #💻┃unity-talk maybe?
i have a 3rd gen i3 no gpu 8 gigs of ram
Owwww you are so smart how didnt i know
Owww well ill be complaining while i dont have to
I guess I’ll be uninstalling the temporary files then
alright
people have been leading me to wrong places
ima just learn from vids and w3s
for scripting
final
👍
I didn’t wanna wait so I just already deleted the files, so yeah
Now let’s see how many disc space I have I just got one gig for yes sir
Oh never mind there’s an update
Me?
from the amount of videos you are already posting, yeah
and you already cry like a big one
no offense
-# if you do you better learn how to screen record
Yeah ik
oh nah not anytime soon
I dont take things personal
might be an advantage
I am autistic ahh fuh so
you are a unity autist right
Go to offtopic so we dont get banned
there isn't an off-topic channel here
How do u know I have autism
There's no off-topic here
Oh noo
gg
yeah the server is kinda focused on unity help/discussion
@earnest meteor Also this is a coding channel, if you have general questions use #💻┃unity-talk next time
i love w3s😭
I'm super confused on why my bean is floating up, I was reading up on some stuff and I think its something to do with flattening the camera's forward vector, and normalizing it but i have no clue what I need to do for that
The movement script needs to be on the capsule, not the camera
if it's with an RB, make sure you've locked X and Z rotation
configure your ide
!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
now its not seeing the rb
well yeah of course, you're not ignoring the y component of the camera's forward vector
so if the camera points up you're gonna move up
what do you mean by "it" and "seeing"
i got it to detect it
what could i do to make it ignore it?
set it to 0
(not on the actual camera, just a copy of the vector)
and then normalize it so you still move at the same speed
The issue was already solved by using the correct object to determine the direction. None of that is necessary anymore
def not fixed lol
make sure you're rotating the right things
well yeah of course, if you make it so you can rotate the player around the x axis it's gonna rotate around that axis
generally, the camera should be a child of the rigidbody, and the camera only pivots up and down, while the rigidbody can rotate left/right
also, configure your IDE if you haven't. it's a requirement to get help here
idk about a requirement but it's definitely a good thing to do either way
The movement script should be on the capsule. Keep the camera rotation script where it was
it is a requirement.
(you shouldn't be screenshotting code from your ide anyway)
If you're following a tutorial, set it up the same way as it is in the tutorial
I'm mixing a bunch of code and getting bits i need from tutorials
If you're not following a tutorial exactly then you should at least make it clear to yourself what each part does. The keyboard movement should move the entire player (the capsule), looking up and down should move the camera, and looking left and right should rotate the capsule
👍
have you configured it?
im trying to figure it out
im confused on what its wanting me to do...
bc i have it installed and everything it highlights errors but idk
lol im just a bit confused
we have no idea what step you're on
Why can I not rotate my head bone via transform even if I masked it out with a layer mask?
are you referring to an avatar mask?
layermasks don't inhibit movement
true but i also don't know where to start
yes
Curious, question about the unity tilemap if anyone is familiar with it. is streaming enabled for it by default? i feel like it is, since i loaded a massive amount of tiles using bounds and the game performed just fine.
perhaps ask the folks in #🏃┃animation then
are patterns beginner coding concepts
there are steps laid out for you
If your IDE isn't providing autocomplete suggestions or underlining errors in red, then it needs to be configured.
depends on the pattern, and depends on what you consider "beginner"
this would have been nice it sent me somewhere else with the other one
that links to the same page
the first step in this page is just going through the page linked in !ide
i'm bit dumb so i'm considering MVC pretty beginner level
rn I am making a gui manager and scene manager interface that gets implemented to pass stuff between the two. This is what i have but it just feels like a fancier type checking.
-# i mean aren't most programming patterns just fancier type checking
-# they run command of implementations without knowing the type, just an overarching interface 🤓 🤓 🤓
yeah, which i got half of it down, not checking what type of scene it is.
but the other half
idk if there's a way to do away with hiding what type of data is being passed.
you could also pass interfaces or abstract classes in there if you're feeling very fancy
Hey guys im trying to figure out which game engine to stick to, tried godot,roblox,unity and unreal engine, im trying to start out with a 2d game, what do yall recommend i pick
Im also not good at scripting
configured
your gonna have to get some experience scripting
but how would those interface know what manager they're in
which one did you like more? it's really about preference more than anything
do they need to? you're referring to the ones passed to the HandleX methods right?
I want unity but i hear its not good for beginners
I want unity because i just feel used to it
where did you hear that? it should be just fine for beginners - it has a lot of free resources online and abstracts away a lot of the lower level details
I see, 1 question: do u know how to code?
well.. yeah sorta?
How long did it take to get where you are rn
yeah
the idea is that multiple managers implement this. They all do different things with each data.
if the method param passes an interface, and calls the interface's methods, how does the interface's method know what to do
hmm i started i think in late 2023 or early 2024
but i started actually seriously learning programming/gamedev around summer of 2024 iirc
Was it worth it? Do you feel a change between what you can do now and before, or are u still lost?
don't base your expectations off other people's experiences. your journey will not be the same as anyone else's
well i can definitely do a lot more now than when i just started haha
i didn't start with unity right away tho
I know that but im trying to set some expectations
but yeah definitely, everyone learns differently and at their own pace
i literally just said to not use that for expectations
Well im gonna but i will take it with consideration
it can take 2 different people 2 weeks or 5 years to reach the same point
Alright well
and what you learn will be specific to what you want to make as well
thing with roblox is that it's not exportable
neither the game you make nor half of the skills you use.
it's also a bit limited
tbh, from my experience, a lot of skills in terms of coding transfer between (even seemingly completely different) languages and engines
definitely
(in general) there's 3 major parts to programming:
- Language - The syntax, structure, and paradigm of each language
- Library - The interfaces and utilities that each environment or toolset provides
- Logic - The algorithms to do work at runtime
Logic is almost completely transferrable between each language and environment, you just have to learn the specific Language and Library that you're using
Language is also shared quite a bit between languagesof course, learning 1 part at a time is easier than learning everything at once, which is why tools like scratch or code.org are popular as coding courses for beginners, especially kids, because it only focuses on the Logic aspect
coding transfers definitely
but effectively using the editor doesn't
(you might be thinking of "portable"?)
(maybe, i'm not fluent in terminologies)
but anyway i'll probably stick to this for now
and hope it doesn't become a nightmare to upkeep
on another note
should i give every class monobehaviour
i heard as long as Update methods are not declared, the cost should be insignificant
only if they make sense to be components
Btw
not all classes need to be components
just ask your question, you don't need to lead with this btw
Is it better if i just watch tutorials, try to make a game and watch relevant tutorials as i go
this seems a bit weird, why would the interface care about who called it?
and if it absolutely needs to care, then the caller should be provided as parameter
that can work, yeah. just make sure you're learning/understanding what you're doing, rather than just following completely blindly
say i have a weapon
it can be a display, or it can be functional
but both will need access to a data class. should the data class be a monobehaviour or is it find as native c#
imo, the best approach is to watch tutorials and NOT follow them, but instead, try to apply what they show in a different way
sounds like the data class should be an SO (ScriptableObject)
i see way too many people blindly follow tutorials and then be unable to do anything on their own
Sounds gud
The idea with that interface was
-instead of the individual data types being passed into different method
-one method handles with an interface param will just call the interface's method.
Except the sceneManager is meant to be implemented by classes that handles the data differently
so in this case Building needs to implement handleTypeA even though it has nothing to do with it?
this handleTypeX approach also looks a bit weird, when working with OOP you expect to have this kind of thing abstracted
I can't think of many similarities between "building" and "sailing", what do they have in common?
I think the root of the issue here is mixing data with implementation
if you consider that the instances always have their data set up, what other interface methods are left?
Stupid question: If I use a dynamic rigidbody and move it with movePosition and rotate with moveRotation but set its drag and angular drag to Inf, does it basically act like a character controller? I.e. simple controller but reacts to collisions
why not just use a character controller? also pretty sure move position and move rotation ignores collision
Because I need a non capsule collider unfortunately, or rather a horizontal capsule. You sure about that?
building and sailing just reuses the same gui
the gui passes reference that are mapped to a catalogue
well, if i use abstract class it wouldn’t need to
moveposition and moverotation do not obey collisions - they're more intended for kinematic rbs
the other strat would be to pass a delegate from building / sailing to the ui manager for the scene
i think
but that sounds cursed and doesn’t really resolve the type issue
fucking hell. So it's impossible to do what I want without actual use of forces? I would need to do some raycasting or capsulecasting or whatever to determine whether I can turn around in a horizontal position?
unless i keep the delegate in a dictionary
which sounds even more cursed
what is it that you want
to rotate my body with respect to collisions
impossible with char controller
you can use angularVelocity or AddTorque for that
angularVelocity would have similar logic flow/behaviour to MoveRotation, so sounds like you want that
I can't if I crank the drag and angular drag to infinity
so why have them at infinity
you can set angularVelocity to 0 yourself if you want it to stop rotating at some point
because whenever I try a rigidbody, it always spins and bounces uncontrollably
that seems like a separate issue
make sure you have constraints where appropriate, and make sure you aren't touching transform which would cause desyncs and unpredictable behaviour
also make sure your values aren't wildly high - might happen if you put in deltaTime where it's not supposed to go, for example
all I know is that whenever I've tried a rigidbody for motion, the results are a casino simulator as to what happens
rigidbodies work for a lot of cases, so im inclined to believe it's something to do with your setup rather than an inherent issue of rbs
make sure you aren't doing AddX/MoveX in Update, as well
this doesn't really change the fact that you'll be providing an empty implementation, at best
to me it looks like you're trying to implement the wrong abstraction
yeah that seems off
since you mentioned MVC before, try having a look at this: https://www.jacksondunstan.com/articles/3092
I am not convinced that's the case. My character crawls and turns in tight tunnels where he barely fits. Basically it's constant collisions. I'm inclined to beleive that rigidbodies are too stupid to handle that
if you're turning in said tunnels, are you sure the colliders actually fit through the turn
i’ll take a look, thanks
it would be good if they didn't fit, that would work as desired. However, I just bounce around and spin instead
...you expect the rigidbody to be able to turn even when it doesn't fit?
no, I expected it to stop when it can't turn, not launch me around
when I tried? I can't remember honestly, I've tried multiple things like addForce, addVelocity, MovePosition etc
and for rotation too
currently I'm using a char controller but now I need to fix that cause it can't do what I want
so have you tried the setup ive been describing
what? I think I added the forces in fixedUpdate, isn't that what you're supposed to do?
yeah, that's correct - i'm referring more so to using velocity
to recap:
- no charactercontroller, only the dynamic rb
- normal or 0 drag
- movement using assigning to linear/angularVelocity, and setting them to 0 when you don't want to move
- appropriate rotation constraints on rb (X+Z, it sounds like?)
make sure the velocity doesn't compound as well
I actually need rotation on all axes
you want the RB to roll around too?
I can't remember what setups I tried honestly. I don't think I set velocity to 0 when not moving tho
when I want to only
have you considered like, just rolling the camera rather than the rb for that
but sure
I would need to roll the collider too
isn't it a capsule
the purpose being to twist the body if it can't fit while fully horizontal
it's radially symmetric, no?
ah, mb. i mustve gotten mixed up from the character controller discussion
no, I actually meentioned a horizontal capsule but that was wrong. THat was what I was trying to get from a CC, but anyway a rectangular one would work better
i'd recommend constraining X/Z rotation for now just to reduce variables though
it would go from shoulder to shoulder, thin on the height and down to the belly or something
Wouldn't it be simpler to tell rigidbodies to fuck off? I Could detect collision while rotating but I don't really know how to do that as it would need to detect in an arc, rather than a straight line
collisions don't really care whether they're from rotation or movement
wait...I didn't think about that. Ye but for example, they would care if I used transform to rotate. Then it wouldn't collide, right? Maybe I could use a trigger? hmm
if I used transform to rotate
that's just out of the question if you have rigidbodies
well, hence the entire discussion
could I not instead use trigger enter and then I wouldn't care about all that stuff
i don't see how that would solve anything
How so? Turn transform. If trigger enter, stop turning. But can turn the other way (maybe I'd need to move it slightly back first)
turn transform + trigger enter just doesn't really make sense
you shouldn't touch transform at all when you have rigidbodies. that can cause physics desync
I'm talking about ditching rigibodies
then triggers wouldn't work either
dynamic rigidbodies are what drive the physics engine
no rigidbodies means no collision/trigger detection
oh, yeah, you're right. You need a rb on one of the objects, true
but still, I don't think I would have problems with transform rotation there
Hi, I'm new to unity programming. I'm trying to make a simple first person movable character, but there is an issue. For some reason, I'm not sure why, the camera only moves on the X axis and not both X and Y. But if I select another camera, It only shows the Y access. Why is that?
Show how the objects are related in the hierarchy
you would
it could manifest as inconsistencies or perf issues
the transform would not be rotating, it'd be teleporting in the eyes of the physics system
no interpolatation or continuous collision detection
ok but wouldn't it be teleporting frame by frame? What you're saying is, with interpolation, it would be more precise because the next frame would figure out it had gone through after the last frame and slightly adjust it or something?
it that the gist of it?
also, what about checking for overlaps?
no, the detection would be on the fixed timestep
interpolation is for checking between steps
man, what can i do to convince you that the physics system is just not meant to be working with modified transforms
I'm I missing something?
alright, so what about checking for overlaps?
all the same issues.
to be blunt, you have 2 options. you can use the existing physics system or you can rebuild your own. you can't mix them
Well everything is just flat with no hierarchy there. The idea is that the camera should be a child of the player model so that when the model rotates on the Y axis the camera rotates with it
charactercontroller effectively builds its own, for example
so what you're saying is I must use physics to rotate a mesh?
not what i'm saying, no
if you're using physics for other stuff, then you have to use physics for the rotation
like this:
Probably yes
you have another choice - not using rigidbodies at all and making all the physics checks yourself
ok, continue
so what if I'm not using physics for anything
see my previous message
ok but what do you mean by that? You mean checking for collisions while using a rigidbody, rather than rotating with torque, or whatever does that naturally?
could you rephrase your question? not sure what situation you're referring to
when you say I have to do physics checks, you said I essentially need to use a rigidbody and rotate in the appropriate way (not with transform).
Are you going back to saying I need to use physics and torque for rotation, or just that I can detect collisions and rotate in another way, but still with a rigidbody?
ah, no, the physics checks im referring to would be stuff like overlap and cast checks
yeah, excellent, I was steering towards that
you can do all those yourself with no rigidbodies, or you can let the existing engine handle it for you
but you said here I can't do reliable cast checking if I'm using overlaps
with transform
no? that was referring to using the physics engine combined with a rotating transform
that's not what I meant in that case
I meant rotating via transform and checking for overlaps
but without involvement of the physics engine, you'll just have to do the interpolation yourself
ah, thought you were still talking about using triggers in that case
so, if I'm a big hater of physics. Let's say I slap on a kinematic rb and a collider on my char. Then I check for overlaps only while moving or rotating, that seems legit?
Its working now, thanks 🙂
how would you check for overlaps exactly?
(so far it sounds legit, just that it's not quite a complete picture without that detail)
overlap the shape of my collider at the exact point of my collider. If it overlaps with the terrain collider, I stop moving or rotating.
To go back or rotate the other way, I'm not quite sure if I would need to bring it back first to stop it from overlapping
but that's essentially the plan
you'd also have to snap it back to depenetrate
yeah, that's what I'm saying
make sure to consider cases where you'd phase through collision
what do you mean
if you're referring to the fast bullet going through something at a really high speed problem, that should be irrelevant in my case. At least that's the only thing I could think you're referring to
basically that, but also consider it with rotation and corners
imo, I don't need such precision
it's a first person game
wouldn't be visible anyway
I consider it a non-issue
I don't quite follow but that's ok for now
also
at first, I considered keeping the char controller for motion and using that special collider for collision checks, but would it then make sense to ditch the char controller now?
like, does it do me any good?
they'll be fighting for control of the transform. use one or the other
well, the charactercontroller and the rb previously mentioned, not the collider
charactercontroller itself is already a collider, so you could consider using that. not sure it can be horizontal though
it can't be and that's a problem
also it can't turn, which is a problem for me
probably not the right choice then
I think it has a nice feature where you go diagonally if you hit a wall at an angle which would be nice, but that couldn't happen anyway with my new rectangular collider
so I could just code that or something
it would be perfect if rigidbodies would work for me but I already went through the trouble of simulating drag and inertia with the speed of movement for my char controller so best not reopen that can of worms
i'm referring to cases like this. if you don't have continuous detection, then whether or not you can phase through the corner would be up to timing and the time step
don't fall for the sunk cost fallacy on this one lol
I don't know...isn't it always best not to use a rigibody when you can do that?
what? no definitely not
precisely because you can't control rigidbodies how you want. I heard it's basically very bad practice to use them in car games, even though it might seem natural to use them
sometimes you need something more specific that the physics engine doesn't cover or handle well. in that case you would consider making your own physics engine built with the specific task in mind
maybe this is one of those cases, but honestly with the context you've given it doesn't seem like that to me
it shouldn't. It's probably a perfect case for a rigibody in theory, but in practice I want get it to work so idk
because you can't control rigidbodies how you want
you can though. their entire API revolves around that
I mean you can if you go through the effort of stopping every force and controlling everything when you need when you want that
but at that point why use it?
you can prevent things from giving forces
you can prevent things from receiving forces from certain things
if you want to control every aspect, then maybe you don't actually want physics - and that's fine, you don't need to use an RB for everything
but RBs definitely aren't useless
if they were, they wouldn't be in the engine
so do you agree they are bad practice in racing games?
depends on the kind of racing. for something akin to mariokart, yeah probably - the physics there aren't very realistic, you'd want more customization
for something hyper-realistic, like racing sims, there's a lot of complexity that would probably benefit from a dedicated system. like, it could work with RBs, but it'd be better with something built with racing in mind
for something like trackmania? RBs would probably be fine.
i also maked sure that the Ground Collider is flat, i mean i also useing a "BoxCollider2D" so its should be in a straight line
hey, i use this map currently in my Game. i know that this game maybe took some years so i just wantet do make a Collider2D for every Ground, Wall etc. i know that i can use a Tilemap Collider but i actually want to set every ground by my self for hidden roomst etc etc.. but curently i use a Ground better said a Empty GameObjct with a Collider2D, i stretched it around the whole ground but the Player is falling a liitle bit. I cant really explain what i mean because of my Englisch Skills. For that reason i want to share a Video =>
well, check in that location if there's a gap in the collider or something
okay i will do it, but tbh the collider is still around the whole ground: Hers is also a picture.
@naive pawn so I tried checking overlaps for rotation. It kinda works, the only problem being I get jittering when I keep trying to rotate to an unrotateable position.
What I'm doing to saving the rotation of the player every frame, and when an overlap happens, I start checking when there's NO overlap but I also return the player's orientation to the last saved one before the overlap.
perhaps check the y position if it's actually falling or if it's an animator issue
I swear Discord is taking forever to load a few seconds video
i hope that the Players Code dont make this problem, i use my costum Gravity and im also Apllying Gravity when the Player is not on "Grounded" better said i apply Gravity when the Raycast is not hitting the Ground
real
there is a Website for postiing Videos, they give u a link that u can share here, its 10000 faster than discord
so you're snapping it to a position that's still significantly outside of the collision? it's just rotating a bit more to get to the overlap point then, no?
perhaps log the values you're setting the rotation to
Well yeah, I guess that's it. It's far enough from the overlap I guess that you notice when you keep turning.
Maybe I should actually only rotate if there hasn't been an overlap in the next frame. That would fix that
Only, it would have a slight delay
So, actually trying to prevent it from overlapping in the first place
@earnest meteor This is a code channel, if you need help with code post your problem
How might i use a custom Polygon collider 2D as the "area" a particle system uses to spawn particles from?
Im dynamically creating shapes with a line renderer, using those points i create a Polygon collider 2d. That i want particles to spawn in
hey where can i ask my 2d Animation Prblems, the Enemys Animation sudenly change his Position on a few Frames, What channel should i use?
hi can anyone help me becouse my joystick doesnt work anymore (i dont think that its an code issue) https://paste.mod.gg/zfjheucskbbi/0
A tool for sharing your source code with the world!
Thanks u!
any errors or warnings in the console?
no
is Collider.cast as difficult for rotation as is sounds?
what about the movement, can you see some proper values in the console?
what do you mean?
the player returns 0 if i debug it and i tryed using WASD for the movment but it doesnt work too
I mean, it goes in a straight line for movement, seems easy. But to prevent rotational clipping, it needs some proper math I'm guessing
Can you explain what you mean by rotational clipping?
I mean to stop collision while rotating, i.e. not clip through the wall
if you want to simulate it rotating while moving yeah you can't do that with a Collider.cast
Are u talking about Collider2D? 3D colliders don't have cast. There is Raycast. They are different
you'd have to do something like make a secondary physics scene and simulate it moving and rotating in there for however many timesteps you need
I presume yes they mean 2D.
allegedly, it's been added from unity 2019 onward for 3d. But I couldn't find definitive info so I may be wrong
It has not - but 3D has always had Rigidbody.SweepTest
sigh, I guess I can try going back to rigidbody motion
and how does that work?
My unity started randomly doing something weird, if I am coding and save the file it will randomly pull unity as a the focused window until its doen rebuilding the script.
Also since this started happening my unity will get stuck at reloading domain randomly, and I have to close with task manager. How can I fix this?
How might one create a sprite mask from a polygon collider 2d?
Ive read so far i need to convert a sprites shape to fit the collider but ive had no luck
can someone teach me how to make vs code do auto filling for my code
auto suggestion thingy
!vscode
If your IDE is not underlining errors in red or autocompleting code,
please configure it using the link below:
Yes i did come across this. It just seems way too much for what im trying to do
I downloaded it and trying to figure out how it converts a sprites shape but no luck so far
not sure, wouldn't hurt if you were more specific on your particular issue / usecase.
stupid quastions dont exist
thorfinn type shit
but yeah no reason to steer this into offtopic
So im making "clouds" for my game that are any kind of shape i can draw in editor.
I want the polygon collider 2d of these clouds to act as a sprite mask to show a particle system (Cloud visuals) ONLY within the bounds of clouds.
I have the sprite mask properly showing clouds only within a sprite i select.
but im struggling to "reshape" the sprite to match the polygon collider2d's shape.
this seems like a glorified raycast. How does that help with rotational collision checks?
SO i need to either reshape a sprite to fit a polygon collider 2d's shape
Or somehow mask through a collider?
so you basically want particles to stay within a shape or I misunderstood
I haven't been following the convo, just replying to the last message you asked about
it is indeed a cast but shaped as the mesh
Anyone know why my classes that inherit from an abstract class seem to be unable to get reference to a singleton,
gameCon = Gamecon.Instance works just fine in my classes that do not inherit.
Here is the abstract class and its awake method
public abstract class EnemyAI : MonoBehaviour
{
private ShipObject shipObject;
private WeaponObject weaponObject;
[SerializeField] GameCon gameCon;
private void Awake()
{
shipObject = GetComponentInChildren<ShipObject>();
weaponObject = GetComponentInChildren<WeaponObject>();
gameCon = GameCon.Instance;
}
}
private is default
serializefield just explicitly serializes (and shows in inspector as a result), doesn't mean it's public or protected
I have a particle system of clouds that are traveling right uniformly across the screen.
I only want to "reveal" this particle system effect through the shapes i draw.
That way if shapes are touching, the cloud effect isnt broken.
ik, I just serialized so I could see what was going on
this is a code channel
private is private, inheriting classes can't touch their ancestors privates
you might want protected
OOOOHH
apologies for the phrasing.. its 5am
sorry
is there anyone i can ask basic ass unity questions to lmao
oh I see.. maybe use a reveal shader?
Right, I checked this and it doesn't help with rotation. So how WOULD you check for rotational collision?
id rather talk to someone than rely on a tutorial
: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
ask in the relevant channel, and don't ask to ask
thank you! that makes sense, I'm surprised this is the first issue I've come across, still new to the inheritance thing
gotta find it for the first time eventually 😄
lol true
i would but do i rlly wanna send 15 questions to a public chat about the same project lmao
I mean you should make an attempt to even debug / google things on your own first
without knowing how to self-debug / problem solve you will not go very far in development
I have no experience with shaders. Would that be kind of like giving the clouds a material that acts as a mask?
tbh im tryna figure out how to do basic basic ahh 2d movement
but theres like
500 different ways to do it online
you could open a thread
spritemask but be easier but with shader you have more control, basically you can have the cloud have the material that is revealed with a shape defined by another shader that acts as a reveal for that material
some (very old/classic) architectural questions:
with heavy usage of composition - where do "normally" one put a state management logic? like, do I make "a meta component" who orchestrate on decoupled components OR do I make the components with tiny state machines inside them with some "meta state machine" enabling/disabling the components, dunno? I kinda want to try to make a composition as my core structure, but I still don't know HOW/WHERE do I put the state logic itself, not the business logic of "an action gameObject be doing", if I can phrase it like that, lol.
and i want to like
then your fucked
yes there are 500 ways to make movement and it all depends on what you want your movement to look like
that is why no one can give you a straight answer, because there are dozens of ways to solve a problem , you need to find one that makes sense for your game / project
Sleep and pray
i cant believe i took ap csp and intro to comp in uni
just to not know a thing
this isn't a social chatroom, if you have a specific unity code question ask it otherwise move on
hmm I tried private protected, protected, and even public, it seems the inheritors still can't get the reference but for some reason the fields that are getting reference via GetComponentInChildren<>() are all working fine?
you'd need to show code
Btw its a singleton, u can just call the class directly without caching a reference
this is also true
Talking about movement, ill explain the situation. I'm making a restaurant game, so when you walk to a client and select a table, the client walks to the table you selected. Just like in Dead Plate. But I'm not quite sure how to move my NPCS to the table, Ive watching some videos but it seems that their case isnt exactly similar to mine. So im a little confused of what to do now. Any good advices about moving NPCs from a starting point and changing their path depending on what the player selected would be so nice
hmm I tried that, I'm specifically trying to get access to an event in the GameCon singleton, this however gives me an "Object Reference is required for the non-static field, etc, "GameCon.TickEvent"
public class GameCon : MonoBehaviour
{
[SerializeField] private int Ticks;
public event EventHandler TickEvent;
public int getTicks {
get{ return Ticks; }
private set=>Ticks=value;
}
public static GameCon Instance;
}
public abstract class EnemyAI : MonoBehaviour
{
[SerializeField]private ShipObject shipObject;
private WeaponObject weaponObject;
[SerializeField] public GameCon _gameCon;
private void Awake()
{
shipObject = GetComponentInChildren<ShipObject>();
weaponObject = GetComponentInChildren<WeaponObject>();
_gameCon = GameCon.Instance;
}
private void OnEnable()
{
GameCon.TickEvent += OnTickUp;
}
}
GameCon is a monobehaviour, an instance
Instance is a static field in GameCon
(youd want GameCon.Instance.TickEvent)
aaaahhh okay, yeah that looks like it works
sorry, been a bit since I did this stuff, my memory is half there
where is Instance assigned ? this is gonna return a null ref
you generally want to access Instance of singleton in Start
since most of the times assignment is done in Awake, you wouldnt want to rely on the order of scripts to hope the accessing awake runs after
I'm very new to this so I hope this is the right place for this. I have my player capsule set up and I set the values to my liking, but when I hit play, they reset. Like "Jump" keeps unticking, movement speed and rotation speed keep resetting to defaults. I don't know why this keeps happening.
we dont know either because we have 0 information on the code or setup
oh good to know, thank you, I'll start doing that
hmm I'm still getting a nullref using GameCon.Instance.TickEvent += OnTickUp;
no error in editor though
show where you assign the Instance and where you access it
any idea why this script isnt working correctly
using UnityEngine;
public class MouseMovementScript : MonoBehaviour
{
public float mouseSensitivity = 100f;
float xrotation = 0f;
float yrotation = 0f;
public float bottomClamp = -90f;
public float topClamp = -90f;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
//locking the cursor to the middle of the screen and making it invisible
Cursor.lockState = CursorLockMode.Locked;
}
// Update is called once per frame
void Update()
{
//getting the mouse inputs
float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;
float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime;
// rotation around the x axis (look up and down)
xrotation -= mouseY;
// Clamp the rotation
xrotation = Mathf.Clamp(xrotation, topClamp, bottomClamp);
// Rotation around the y axis (look left and right)
yrotation += mouseX;
// Apply the rotation
transform.localRotation = Quaternion.Euler(xrotation, yrotation, 0f);
}
}
here, I am accessing the instance directly in OnEnable(), the object this script is on is already enabled in the scene, is it possible that OnEnable() is running too soon because of this? I can try seeing if it works if I enable it after starting
this script here doesn't show assigment anywhere for Instance
what exactly isn't working ?
also 👇
📃 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.
also you do not want to multiply mouseInput with Time.deltaTime
it just goes all over the place
thx for the advice its my first time so im not used to all this scripting
this is what happens
ok I tried having the object disabled and manually enabling it in the scene after starting, everything is working correctly, so yeah I'm guessing OnEnable() was just coming in before the GameCon script
thank you for the help, nav
well rotating both the x and y on the playerbody would not make much sense
if you remove the x rotation on the localRotation it will probably work better but you still need to rotate the x on the CameraHolder if the goal is a FPS
Im not sure how
Im stuggling to even get a sprite mask from my collider.
Considering using shader now
How might i begin to do that?
probably a stencil shader / buffer
I'm sure spritemask could probably do it I jus don't know, but with shader should be as simple as doing that
so how will i make x rotation work
Everytime I add a script i am getting stuck at this until I end task on the editor just randomly popped up and am not sure whats causing it in the slightest unless this is a side effect of multiplayer play mode?
you would reference the camera, or ideally make a parent for the camera and rotate that on its own for Up/Down look
have you tried deleting the Library folder and refreshing the Cache , sometimes this works for me when unity acts weird
deleted the library folder, how do I refresh the cache?
just by deleting the folder and opening the project again will generate brand new
oh yeah that didn't fix it any other ideas?
( a blank scene will be open)
depends whats causing it tbh. You'd have to narrow down
when did it start happening?
which version ?
I use 1.3.3 without issues in Unity 6.0.33f
1.3.3 on 6.0.32f1
if its not because of that I wouldn't have a clue
i commented out the code I have running in ondomainreload
was about to say.. start disabling stuff and see what happens
do i need to use two collider? for the legs? and would that not mean that tha player can do 2 times damage?
Have you checked editor logs after terminating the editor process to see if that gives any clues on what it was working on?
Base a damage event on the attack not the collision count
if its a rigidbody it gets compounded into 1 collider
1 attack can hit 20 colliders in one enemy
But the attack should register if it's hit an enemy or not in it's lifecycle.
whether or not to put a collider there is kind of a question of gamedesign
but how do Game Devolopers mamnage to build week points than?
You'd consider collider metadata within the attack
no, i just aksed wrong, i mean i want two collider one and tha back that i a WeakPoint so how can i code that`?
depends if you're using rigidbody or not, You can still seperate them by different layers too
"Is weak point" on one of the colliders (or first collider) hit within an object = critical hit.
would that be achivable if i give them seperate tags?
should be able to check the tag sure
putting a component is easier
a component that defined it to be a Hittble point and then you can determine if its a crit zone etc.
somehow its facepunch steamworks causing this but there is litterally no editor code in it?
okay so i will add 2 Colliders, but one for the weakpoint, but how can i say "Player dont hit two Collider at one time"?
strange.. doesnt need to be editor code but loading the assembly somehow causing issue? maybe seperate it from the rest with asmdef ?
could i say? "If the Player hits the Enemy Combarrrrring , diesable his "AttackRegisterColliders" for 0.2f Seconds but enable his "Body Collider" that dont receive any Damage?
so this Enemy cant fly out of the Map.-
Its a managed dll and a native dll in the plugins folder it should be seperated already correct?
I think soo...I know streaming assets doesn't process the file at all, I think plugin does but I'm not 100% on it
Not sure I understand what you're asking here
wait.
I wonder if this is some kind of undefined behavior in valves native api, this started when I started using MPPM so the server calls SteamServer.Init the client calls SteamClient.Init might not be supported by the library internally and causing some sort of bug
AI
“If the player hits the enemy during combat, disable the enemy’s AttackRegisterColliders for 0.2 seconds, but enable its BodyCollider, which doesn’t receive any damage. This way, the enemy won’t get knocked out of the map.”
can i use that to prevent that the Player can hit boht Collider? (CritCollider) (NormalCollider)?
it might be..
What I would do is make a copy of this project / commit to GIT.
Then remove PlayMode package, try using ParrelSync and test with that. If no issue then you isolated to PlayMode / steamworks not playing nice for some reason
how are you hitting the enemy in the first place
isn't mppm the same concept as parralel sync?
when I open other instances its seperate processes in task manager
yes but parrelsync is a bit more mature
it's way worse for iteration times but something i picked up from modding stuff is there's a nice third party asset called UnityExplorer that provides serialised inspectors at runtime which i've found handy for debugging my own multiplayer builds
eg.
That can work, if you want to decouple it further than keep the collider active and make the i frame system in the script by adding a check in whatever method makes the enemy take dmg when hit
the Player has currently 2 Fighting style. Currently he attacks with hes Rifle but not with hes Sword.
Keeping the collider active prevents future issues, such as falling off the map not registering
is that using IMGUI.NET ?
the Sword will be added with "TriggerColliders" to do damage and the Rifle deals Damage with a RayCast
i think so maybe
I hope I dont have to result in going that route. benefit of mppm was not having to build each time you want to test.
however I may use this none the less for other stuff
it looks like it could be useful
amazing for modding 😛
what is i Frame? and how do i programm that?
google it
I frame stands for invincibility frames, it’s basically a small amount of time where something is invincible after getting hit
this is literlly a dev channel for asking
So in the example you gave that would be 0.2 seconds of invincibility
this is exactlly what i need!
google before asking
Uh oh
okay, i will do it next time.
Its as much work to help them as to tell them to Google
If you aren't up for it, I dont think sitting in help channels with folks trying to learn is a good idea
give a man a fish and he'll be fed for a day, give a beginner google and they'll be solving problems forever
whenever i try to make a 3d movement i always got that error
Again, if you aren't interested in helping people, why be here at all.
!input
To set Active Input Handling, go to:
Project Settings > Player > Active Input Handling
• Input Manager (Old): Use the original Input settings.
• Input System Package (New): Uses the new input system package.
• Both: Use both systems.
@sour fulcrum Now you are in situation that I was before 🙂
This channel does not substitute a search engine. If you find an unfamiliar concept search first, then if you still don't understand then ask questions here. Doing personal reserch yields a lot more information than a simple answer as well.
this is exactly what i said befor
Ok, now your on your own 😄
Wut
mine is using Input System Package (New) should i switch it to both or old?
what??
the error is telling you're using the old, switch it to both or adjust the code to new systen
@sour fulcrum okay you are not in situation that I was before because I did know my point of view but you are not realize your situation
ok man
yo that make sense does it easy to adjust the code to new system? can it be doned with just a few codes
yes
using a InputActionAssetReference will pretty much make things a lot easier
Its a lot more flexible, on the one hand, but more cumbersome to setup (if doing it from scratch)
Imho
But you should be moving to it
and there are dozens of ways to use the system which may come off intimidating at first
on my way thanks mister
check how Unity uses this in context of Polling with movement and Jump button key
alr
instead of doing
Vector2 input = new (Input.GetAxis("Horizontal"), Input.GetAxis("Vertical") ;
Vector3 move = new Vector3(input.x, 0, input.y);```
you're doing
```cs
Vector2 input = moveAction.action.ReadValue<Vector2>();
Vector3 move = new Vector3(input.x, 0, input.y);```
I do think (given input is often the only way players can really interact with your game), its worth putting time into it and learning it. And it'll pay off in the long run.
especially when you need to do rebinds 😭
old system was so trash for that they had dozens of assets for it
yeah that makes sense i had a homie who was trying to do a 3d game fastest possible. IN the end of the day he had completely erased the entire project he maded due to having tons of errors . so thats why discipline beats motivation.
I’ll add on to that, if you run into an error fix it before you make more errors lol
got it
i just realized somthing
it would be extremly smart to make one flip Script and use it for every enemy
a tipp for every other begginner!
thats a great learning step 😄
eventually you gain a bunch of learned knowledge that makes every project easier like that
even better, make a virtual common enemy class, and allow make other enemies have their own scripts that can inherit from it
this allows them to have common behaviours but also allow said behaviours to be overridden or changed by a certain enemy if necessary
double edge sword of inheritance
what if you also want non-enemies do the same thing ?
common entity class
Behold! Interfaces 🌟
I wish Unity would actually let you serialize them in the inspector by default 🙄
As I mentioned, use a secondary physics simulation
I didn't understand that comment
Is there a way to render a gradient?
As in, a rectangle on the screen (preferably with a variable z axis) in 2d, with a verticle gradient
you need a shader to do it but it can be done easily with shader graph
yeah its like, two nodes(?)
this should do to get you started: https://learn.unity.com/tutorial/introduction-to-shader-graph
ask in #1391720450752516147 if you need help with shader stuff
Free tutorials, courses, and guided pathways for mastering real-time 3D development skills to make video games, VR, AR, and more.
I just tested on a plain cube with addForce while torquing and I'm not seeing the issues I previously described (i.e. spinning and teleporting uncontrollably).
Maybe I left of transform rotation with the mouse or something when I was testing. Hmm...
Hey if i use this in my Script => [ExecuteAlways] and the Script is NOT in the Scene better said my GameObject that uses This Script is disabled would that cost performacne?
No, only when the GameObject with the script is active in the scene . . .
okay thanks!
So this channel is only for code related topics, right? sorry i tend to overthink.
If unsure, just read the channel description . . .
Be careful with using the attribute. It will impact performance if you have a lot of code, especially in Update . . .
Execute always will cause all monobehaviour event message functions to be called in editor. So any instance will be affected by this (be it in a scene or prefab editor)
the old attribute ExecuteInEditMode does not work in prefab stage (what the prefab editor thing is called)
okay i currently using them in 2 Scripts. and im deactivaitng them if i dont use them.
well it only affects you in edit mode and if its not doing much its okay
just dont over use it for no good reason
i use it for debug pourpuse
Hey i use this Script ```using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
[ExecuteAlways]
public class BaseGroundCheck : MonoBehaviour
{
[Header("Ground Check Settings")]
[SerializeField] private bool useGrounded = true;
[SerializeField] private Transform RayCastOrigin;
[SerializeField] private LayerMask GroundLayer;
[SerializeField] private float GroundCheckDistance = 0.3f;
private bool isGrounded;
[Header("Gizmo Settings")]
[SerializeField] private bool useGizmos = true;
void Update()
{
isGroundedCheck();
}
private void isGroundedCheck()
{
if (!useGrounded || !RayCastOrigin) return;
RaycastHit2D hit = Physics2D.Raycast(RayCastOrigin.position, Vector2.down, GroundCheckDistance, GroundLayer);
isGrounded = hit.collider != null;
}
private void OnDrawGizmos()
{
if (!useGizmos || !RayCastOrigin) return;
Gizmos.color = isGrounded ? Color.green : Color.red;
Vector3 start = RayCastOrigin.position;
Vector3 end = start + Vector3.down * GroundCheckDistance;
Gizmos.DrawLine(start, end);
}
private void OnValidate()
{
#if UNITY_EDITOR
SceneView.RepaintAll();
#endif
}
}
i want that the Frog a Boss in my Game should see from this Script if he is Grounded.
the Problem is or better said i think in the future will be that maybe another Enemy that use this same Script can manipulate tha "isGrounded" Check for the Boss
i want to know, how can i read for every GameObject the right "isGrounded Bool"
i needed because i want to Impement the Jump Code for my Boss, here is also a Script =>
!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.
A tool for sharing your source code with the world!
it's a typical way to handle things like trajectory calculations. https://docs.unity3d.com/6000.2/Documentation/Manual/physics-multi-scene.html
One of the prime use cases
I also want to Implement the Logic, i learn that i can find the Direction from the Player to the enemy, i do that and i save the value inside of a Vector2
but for this case i saw a Syntax in Unity Docs but i dont now how to convert a Vector in a float, in Unity Forum i saw that doesnt work beacuse Vectors took more Data than a float (X, Y, Z) etc. i thought about Filtering it down to a float, because for this Case i only need to know tha X Achses, but i dont find the Syntax. Can sombody help me also there?
if you want only X then access just x
no idea, not even sure what you're going for lol
HAHAH, i want that the Boss Jump at the Player
im just try somthing, im also dont know that this work tbh
i hope this work, for me this makes sinn but maybe this is a problem
Chis theacthed me this
this is why i wanted to filter it down to a X Value
but maybe i dont even need to filter it down

Couldnt use Go.x?
how hard would it be to train an AI agent to run a complex enemy entity?
it didnt work, i found a other way but this also dont work i actuially dont know why
but this also dont work, i dont know why
sounds unnecessary and expensive to run to me
but i have a idea, i think the could be a problem from .normalized
its reduce my upwardforce again
i will try it
how unnecessary? i dont think any games have enemies without a small subset of moves
normalizing sets its length to 1
YEAH
this is what i thinked
i do this everytime
yeah, but training an ai for that seems pretty pointless
Arc Ryders have that
theres ml agents, which i think #1202574086115557446 is the forum for. this really cant be answered though. It all depends on your ability
they are extremly smart
it is unneccessary for the vast majority of games
it's costly and probably won't produce better results than manually coded enemies
can someone help me with a problem i have been having for over 10 hours now and its driving me crazy, i am new to coding and unity but this help would really make my day, am i in the right place for support?
You can see in the clip i am trying to get my character to change in the creator section, but I have no idea what I did wrong to break this as I had it working earlier but I just can't figure it out 🙁
https://gyazo.com/729a94156fb4b875884c4f169ff607ae
!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
you need to paste relevant code if you expect help with the code
we also have no idea what you did wrong if you don't show the code
it was a free package that came with code etc, and because of my issue I asked chat gpt for the fix and it was giving me code but didn't fix my problem, is there a way i can show someone?
!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.
so i just paste in my cs code and it will tell me where I went wrong?
what's the "it" you're referring to?
sorry i am very tired i was supposed to say "in"
past u code inside, click in top left on save
it's just showing how to send code
copy the URL and post it here
it's not some magic that will fix the problem for you, it's just a way of sending code to make it easier to read
with 3 of this => ´´´
DAYUMN
bro u are a pro
10 hours trying to fix something that would take a real pro 2 seconds lol
i wish i can help u but im goofy at coding
is there a way i can screenshare might be easier?
just because someone has a bunch of scripts doesn't mean the scripts are good 😛
DAYUMN
true
Mr woz u allowing that he is talking with u like this?
-# i'm talking from experience
taking a break from the problem and let the mind do its thing also helps
it doesn't bother me I have only been doing this for 1 week
so yes they are probably right
thorfinn type shit like always
taking breaks definitely does help a lot yeah
I can't settle till this is done, only because I had it working this morning
and i just can't figure it out
thats even more reason to take a break.. it happens.
i had same thing happen, i come to the problem next day and solve in 2 mins..
mind needs time to reset a bit
subconscious still works on the problem
i wasn't exactly doing code I was just changing the ui asset I had etc and maybe I deleted something by accident, i really do not know. I took many break today 🙁
i would screenshare to show someone who has experience if no 1 is busy for a few minutes
thats not how this server works. you should be able to properly form a question if you expect help
all you've shown is a video of something "not working". no one here can provide help without more information
that is why i mentioned about screensharing. But it's ok.
I thought this was a discord to help people, but I guess not.
🤷♂️ it is, scroll up and you can see people getting helped for years. if you cannot form a proper question, what help can anyone offer you?
if you aren't sure what code is relevant to your issue, thats something you need to figure out first then
@maiden crest you don't know what you do to get what you get so you here to figure what did you do to get what you get, whould you be able to help somebody with such issue?
thanks for nothing
Hey guys, what's up with my code? My timer is not incrementing normally. For context, I'm using the new input system and I set up a positive/negative binding to change my camera, so < is -1f and > is 1f, but Idk I logged my timer, it isn't really incrementing. Just kinda fluctuating
using System;
using UnityEngine;
public class RotateCamera : MonoBehaviour
{
private bool m_IsRotating;
public float m_MoveTime = 1f;
private void Awake()
{
Application.targetFrameRate = 60;
}
private void Update()
{
// We set m_IsRotating to true when we press the button
if (PlayerInput.Instance.Camera())
m_IsRotating = true;
if (m_IsRotating)
{
// We're rotating
// Assign a timer and reset it to zero
float timer = 0f;
if (timer < m_MoveTime)
{
// Increment the timer
timer += Time.deltaTime;
transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(0f, 90f, 0f), timer / Time.deltaTime);
}
else
{
timer = 0f;
m_IsRotating = false;
}
}
}
}
@maiden crest one of the goals of community support servers like this is to facility asynchronous help - one person can post a question, and someone can answer some indefinite time later
VCs or screensharing kinda go against that, hence why a vast majority or servers like this don't use VCs for support
we also can't help without necessary info/context though. it's kinda on you to figure out what exactly is the thing you need help with
you're setting it to 0 every loop
I'm wanting this to act like a camera rotator. You press the positive button, it rotates 90 degrees, you press it again, it adds 90 degrees, same thing with the negative binding but it goes in reverse
consider using one of the proper smoothing methods, though i don't remember if quaternions have that. ill have to check
it worked, but it doesn't work if I press it again
I removed Time.deltaTime from float t and just used timer
ok yeah quaternions don't, though there is Mathf.SmoothDampAngle
No it does
@umbral hound this is your main issue
I changed it to this and it works
Yeah I fixed that
using System;
using UnityEngine;
public class RotateCamera : MonoBehaviour
{
private bool m_IsRotating;
public float m_MoveTime = 1f;
private float timer;
private void Awake()
{
Application.targetFrameRate = 60;
}
private void Update()
{
// We set m_IsRotating to true when we press the button
if (PlayerInput.Instance.Camera())
m_IsRotating = true;
if (m_IsRotating)
{
// We're rotating
if (timer < m_MoveTime)
{
// Increment the timer
timer += Time.deltaTime;
transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(0f, 90f, 0f), timer);
}
else
{
timer = 0f;
m_IsRotating = false;
}
}
}
}
alright, just keep in mind that that's wrong lerp
but it works?????
Applying lerp so that it produces smooth, imperfect movement towards a target value.
i didn't say it doesn't
oh god it isn't even wronglerp too
new pattern 😬
i would advise not inventing these new patterns
you basically have an accelerating wronglerp
it... reaches the target though, lmao
Okay
using System;
using UnityEngine;
public class RotateCamera : MonoBehaviour
{
private bool m_IsRotating;
public float m_MoveTime = 1f;
private float timer;
private void Awake()
{
Application.targetFrameRate = 60;
}
private void Update()
{
// We set m_IsRotating to true when we press the button
if (PlayerInput.Instance.Camera())
m_IsRotating = true;
if (m_IsRotating)
{
// We're rotating
if (timer < m_MoveTime)
{
// Increment the timer
timer += Time.deltaTime;
Quaternion rotation = transform.rotation;
rotation.y = Mathf.Lerp(rotation.y, 90f, timer);
transform.rotation = rotation;
}
else
{
timer = 0f;
m_IsRotating = false;
}
}
}
}
Let's hope this works
timer/duration
prob
that's still the new wronglerp pattern, and you're accessing a component of a quaternion there and making it non-normalized
that's definitely wrong
Okay well I went to the link you gave me and it said used Mathf.lerp
What lerp do you want me to use?
wronglerp is not about the method used, it's about the parameters you give
Okay is this right?
using System;
using UnityEngine;
public class RotateCamera : MonoBehaviour
{
private bool m_IsRotating;
public float m_MoveTime = 1f;
private float timer;
private void Awake()
{
Application.targetFrameRate = 60;
}
private void Update()
{
// We set m_IsRotating to true when we press the button
if (PlayerInput.Instance.Camera())
m_IsRotating = true;
if (m_IsRotating)
{
// We're rotating
if (timer < m_MoveTime)
{
// Increment the timer
timer += Time.deltaTime;
transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(0f, 90f, 0f), timer / m_MoveTime);
}
else
{
timer = 0f;
m_IsRotating = false;
}
}
}
}
One issue is that it doesn't rotate 90 degrees again when I press the button again
arent you telling it to go to the same rotation ?
you probably want currentRot * Euler(0,0,90)
as target
So I make a variable that keeps the current rotation?
you'd need to cache it so it doesn't always keep going 90
I think this is probably why doing it with a coroutine is easier
you see the coroutine example caches those before the while loop every frame
Okay, I got it thank you so much
it doesn't go the opposite way with the negative binding, I wonder why
what you mean with "with the negative binding"
are you not using a binding ? I think thats easier for WASD
This isn't WASD
this is still a weird version of wrong lerp
This is a bool for changing my camera angle
same thing
Then just tell me what I need to do
please
i'd probably go with smoothdampangle to allow consecutive changes before the previous one is done
Let me tell you something, I have a learning disability, I can't intepret social cues well.
So sorry if I feel a little annoyed
do you understand what lerp/wronglerp are, actually
i feel like you're kinda missing the point of what wronglerp is
I know what a lerp is, it transitions A to B
the intended, "correct" use of lerp is along the lines of y = lerp(a, b, t) where a and b don't change and t increases
the common wronglerp pattern is where a does change - a = lerp(a, b, dt) where dt is deltaTime. that gives smoothing but mathematically doesn't make sense, and it's framerate dependant
what you have now is like, somewhere in between, a = lerp(a, b, t)
So I just need Time.deltaTime in place of dt
that would be wronglerp, it'd at least be following a known pattern, sure
the last one they sent was fine
but i mean, it's called wronglerp for a reason - it has its issues
it was still the a = lerp(a, ...) pattern
they did
timer += TIme.deltaTime
instead of
common mistake of timer * DeltaTime
im not saying it doesn't work, to be clear - im just saying it's an "incorrect" use that can lead to inconsistent results
adding the timer/duration give it correct t
that doesn't change the reassigning part though, does it
oh like the startPoint ?
yeah
I think the target is the one that should be careful changing it
also true, would cause spikes in speed
and weird behavior regarding timer
im not convinced this is framerate independent though
I usually use IEnumerator though so I do it correct with caching it.
but I have seen it used in Update and a long as t was timer/duration & timer+=delta instead of timer * delta
I think doing timer * delta is what keeps with that vague arbitrary constant
multiplying an increasing time value by deltaTime would not make any sense, yes
There are two common ways that people use the lerp function:
- Fixed start and end points with an increasing
targument - Variable start and end points with a constant
targument- This is the 'wrong lerp' that was described above
Okay let me ask this. How do I turn these into floats? Like yeah this action is a bool, but how do I make it so the negative one is -1 and the positive is 1?
can you show the entire input action window with Camera selected?
You can do action type Value but much easier to just use a 2D composite
Change the Action Type to "Value".
yeah it's definitely framerate dependant @rich adder
which one?
a = lerp(a, b, t)
with t as a normalized value increasing over time (as in the normal lerp)
indeed: that cannot possibly be framerate-independent (and also does not have a very clear meaning)
If you just need a single number (kind of like a scroll wheel), you will want the Control Type to be "Float"
This input action will produce values like 1, 0, and -1
i'd recommend this then for consistency
this also smoothly handles changing targets