#💻┃code-beginner
1 messages · Page 839 of 1
There's also an attribute that you can use of which the name slips my mind, then it just auto assign this. That's also very useful here.
I've tried using awakes, they didn't seem to work
Try anyway, it should just work. Otherwise that's a problem worth tackling since you can't work around not using awakes
hang on I tried characterController but I cannot put anything into it
if you have a public CharacterController field, then you can drag an object with a Character Controller on it into that field
show me what you've done
ok hang on I got confused I got that but the problem is that the script I'm trying to call exists within the parent
drag whatever object has the controller on it into the field
unity will grab the correct component from it
ty
- Player <-- has the CharacterController
- whatever
- thingy <-- has the Animator and returnRun on it
- whatever
drag Player into the field
You can also right click on Player in the hierarchy and open another inspector panel by hitting "Properties"
This is useful if the component is ambiguous
e.g. you have two of the same component on the object
hi
i need help i cant use unity for some reason
im on linux (cachy os, arch based distro) and when im using unity, fonts are very small in unity app
i tried 2x scale but its so big
how can i scale it 1.5x or else?
does not have much to do with coding why post it here
Hi, yes this is a common scaling issue on Linux with Unity. You can set custom scaling like 1.5x instead of only 1x or 2x by forcing UI scale through environment variables or desktop scaling settings. Try launching Unity with this command: GDK_SCALE=2 GDK_DPI_SCALE=0.75 unityhub , This gives something close to 1.5x scaling.
it didnt work at me, nothing happened
i raged and uninstalled
i will use godot
Ok, try using that.
but godot is really hard 😫
Let's connect then
Turns out that making a video game is hard and you're not gonna avoid it by picking a different engine
youre right
😢
Quick question, what's BurstDebugInformation and why should it not be shipped?
the Burst system compiles C# into native code
to make this easier to debug, BurstDebugInformation provides extra information about this generated code (e.g. which lines of C# correspond to what parts of the generated code)
it's not massively harmful to give this to players, but it's not useful for them
(i guess you'd care if you were really, really secretive about your soure code)
is it a good practice to swap input system based on the state of the game?
like maybe battle input/menu input, etc.
that's what input action maps are for!
thank youuu
is it good idea to group things together in the level design or keep them all separated and under the main root?
If it's reused, in its own Level design scene that is loaded with the levels.
Hello, I'm really confused. I'm trying to use a Unity asset in Unity 6, and the official documentation says it should work. It's imported into my project correctly.
do you see all of those same errors in the unity console?
-# also that new test() part looks like it should be an error no matter what
i said unity console
not sure
so the answer is no, not all of those errors show up in unity. this means you need to address the ones that do show up in the unity editor, then regenerate the project files and visual studio should start seeing the package
ok so i'm planning to make a script that has an entity look at you if you're close by it... and i think the Update function would be too much each tick for all entities to check the posiiton of all players? Or will this be fine?
i guess i could have a collider? but for each npc?
i would go with something like an overlapsphere (or overlapcircle if in 2d) to check whether a player is nearby, then you can just put that into FixedUpdate so it isn't checking every single frame (which is pointless anyway since physics only automatically updates collider positions on FixedUpdate frames anyway)
and if you are concerned about performance, then use the profiler to see if there even is something to be concerned about
closing it and opening it fixed it thanks
Hey 👋 , i just installed unity and made a simple 3D project and installed VS 2022 with the unity options but now when i open any mono behavour script from unity i dont have any library loaded or anything present execpt from the script itself
(not sure if this is the place to ask for help but couldn't find the channel ;w;)
!vs
If your IDE is not underlining errors in red or autocompleting code,
please configure it using the link below:
• Visual Studio (Installed via Unity Hub)
• Visual Studio (Installed manually)
You probably want to update to VS 2026. Also make sure the vs package in your unity project is updated
everything from the • Visual Studio (Installed manually) is doen correctly
How do i change the member of a list?
I'm trying to do this OpenTalentTree.instance.unlockedTalent.Find(x => x.Item1 == talentName) = temp;
find returns the object, you need to get its index and assign to YourList[index]
ok ty
when im cliking the regen project files its just hang for a sec and does nothing, should i see a status update or anything ?
no, that's normal
hm. doesnt seam to work :C
then you did not, in fact, complete the steps to configure it
restarded the ide seaams to work
ah, so by "doesnt seam to work" you mean "didn't follow all of the steps"
im not missing any chromosome i know how to follow step, unity just needed a project reload
not its working thanks
i know how to follow step
but you didn't follow the steps that make you restart visual studio
i restarted my vs, that diesnt work. when i restarted my unity and vs that worked
are you certain that the CC is being rotated correctly? this would make it move relative to the forward direction
Nevermind, I just realized why
I'm a dumbass lmao it was feeding into a Vector2 instead of Vector3
just so you are aware "the ide" is visual studio. so when you say "restarded [sic] the ide", that implies restarting vs not unity
Hello, just wanted some help on an error I'm getting since I upgraded to Unity 6: Library\PackageCache\com.unity.render-pipelines.core@9d79d0cd2cf7\Runtime-PrivateShared\InternalBridge\RenderPipelineEditorUtilityBridge.cs(14,70): error CS0117: 'RenderPipelineEditorUtility' does not contain a definition for 'TryMigrateRenderingLayersToTagManager'
I literally just made a new project and I inmediatly got x2 of that error and I've been trying to fix it for a while but nothing works. Does this happen often?
Hi. I'm studying from a textbook, but I've run into a problem because textbook was published six years ago. Could you please explain what I should do in this situation?How can I fix the code and why is this happening?
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
Thank you so much!
fyi this is just a typo, the textbook probably does say Log lol
casing matters
Yes, I already understood that the size of the letters can be very important, but I didn't understand it then.
If you don't have actual Unity question about code, please don't post off-topic here.
oh sorry alr
guys what is superior to start as a beginner?
it could be 2D because its simple but it has animation stress
it could be 3D because it doesnt have tougher animations, but you have to manage a lot of things like performance for instance..
Since i opened Unity the Canvas keeps disappearing, i didn't change a thing, since the last time i used unity. i also tried, to print out a debug message. The Canvas seems to no even load. The Dialoge Canvas is still working fine
there are three errors at 0:29, you should research about them, seems like your code was wrong
at console
neither is "harder", but they are different
consider what you'll want to make eventually, start learning that
if it isn't working out, try the other
thanks friend
the 3rd log (the error) may be related, also make sure to save the scene
(only one of those is an error btw)
...warnings are similar to errors.
please don't recommend AI to a beginner, they won't have the necessary experience to actually utilize it
and it won't help with learning
similar yes, but they still aren't errors.
i apologise
The error just disappeared as well, while reaching. The canvas didn't even get load. that's what's causing the nullref error, the object didn't even load. i tried reimport all already.
try this: Debug.Log(canvasObject);
or since the UI is actually "Menu" and not "Canvas", you can try this too: Debug.Log(menuObject);
also i noticed that when you searched "UICanvas" while in-game, that object was deleted or hidden, technically i dont know what scripts you are managing so any script could be the culprit for this
It depends on what your goals are as a designer
I'm learning 2D starting out, but I wanna learn 3D once I learn how to 3D model lol
i tink this are the script from the Conversation Add on that i use
i am just chasing to make a functional game...
Same here, man
Spent the past 2 hours fixing my camera, haha
did you found it out yet?
oh lol camera position adjusting is indeed tough
Definitely, especially when adding room transitions like I was trying to do
i duplicated the Canvas, deleted the old one, now everythink works normal again, odd
I fixed it, but my camera is still too wobbly due to the x, y, and z positions not being neutral
tried fixing it, but the z position reverts back to the original position
by the way if you are talking about 2d... just set the camera to follow your player with.. a 3cm-6cm delay and you can see everything in front of your player, thats user friendly!
oh i see the culprit is a script
it might be deleting your old canvas everytime you play
and your new canvas would have had a new name ig
LOL the z position was set to "freeze rotation"
no wonder it was weird
@bleak hemlock by the way if you dont mind, why dont you showcase your project ?
It's not very far in development, and I'm using assets to learn how to do it
oh i see take your time buddy
if you are beginner than i understand- lol i havent even made a simple enemy AI in my projects yet...
Enemies and AI are always the hardest part!
I'm learning collision, level design, character animation, stuff like that
I am learning art so I can use my own assets for my bigger projects
I'm doing this all myself, I wanna learn all aspects of development
indeed, but you can setup a range system and go for if condition like if Player in range, shoot player (just example)... and thats the simplest AI
oh i recommend pixelorama if on 2d, blender for 3d
That's the plan!
and yeah i agree making your own assets feels like success before success
My biggest influences include Zelda and Final Fantasy, so I'm trying to do a top-down action rpg thing
like moba 3d or just top down 2d?
Definitely! My achilles heel is the actual drawing part haha
My coloring and shading aren't too bad
top-down 2D. It may evolve into a 2.5D thing later, but I'm not sure
I haven't really messed around with 3D development much, so it will be a while before I become confident
i have tried 3d developing, tried to make a 3d cube roll while moving but its too fast or sometimes the gravity breaks
Hmm... is it something with the speed of the cube? The gravity breaking sounds like a collision issue
nah it was actually the script, i didnt organise it well and got cooked
but dont worry i will look forward to making a new fresh script
Pixelorama? I'll have to check it out! I'm using Krita atm, but I wanna upgrade later. I have Blender for when I learn 3D later, but I'm pretty much self-taught lol
Ahh, that's always the hard part! The mistake I always make is missing (); or { } haha
its like this, very customisable, see if you wanna try
Very similar layout to Krita, I like!
I suck ass at Krita and art in general, so it's been a learning curve
indeed... and you can literally get it right now, free, portable, and like 50-100mb in size
dont expect me to be an artist either, i use... razer deathadder white essential gaming mouse for art... too unemployed to get something new
I use a mouse too! Small world
I bet you can create something awesome, don't doubt yourself! 👍
thanks a lot !
by the way have you learnt complete C# or just the basics like Input.GetAxis, Vector2... etc.? of course there are too many complex things after this ;-;
about me, im learning collision
I know VEEEEEEEERY basic C# from classes I took in high school, but not much beyond that
I understand what they do once I apply them, but I have no programming theory knowledge
like? Console.WriteLine right?
and Console.ReadKey()
A little bit more basic than that. I didn't really pay attention because we were learning Scratch. At the time, I was very stubborn and ignorant
so I didn't learn as much as I could've
yo you can actually go for visual scripting too, thats without writing code... but you have to understand whats happening, i have tried that and yeah, normal coding is much better
visual scripting? I know a bit about block code, but I don't know much about visual scripting
Although, I've probably applied it without realizing it
oh i understand
when you learn yourself, or even better, with a friend, thats when you understand better
its like connecting blocks with blocks so things function properly, its literally available in your unity
As a teenager, I had an IT brother-in-law who would bully me for my ability with computers. On top of my very limited mathematic knowledge, I thought I'd never be able to do it
I just wanted to learn game design because I want to make the game I want to play the most
and I just learned not to care what people think
bully for good ability? looks like you are like me... you definitely know much about computers than your surroundings
I have musical and SFX knowledge from my audio engineering course, so I'm not very worried about that
more like making a game that doesnt exist... should exist. thats my goal
interesting, so you can make swoop* weapon sounds
Really? I'm glad you think that way, haha. I'm not very computer literate, but I've always wanted to be. I suppose this has always wanted to be something I've wanted to do. I played my first video-game at one-year-old and grew up playing everything
I mean, I didn't have much else going on at that age, haha
That's definitely the plan. I have audio equipment that I'm going to use to record them
i am computer literate tho, and i started gaming at 4... and yeah i grew up playing everything, too.
If I ever get around to it, I may record something like that and send it to you once I clean it up
would like to hear what you make
I wouldn't say I'm a computer "idiot," but I'm not a computer genius either
thats what i though too
I'm basing a lot of my level design on games I love. Mega Man X has been a massive influence on how I approach level design
I'm more interested in the game design and director side. However, I want to be able to be competent in all things
If you want I can tell you some notes I've taken so far for basic 2d games
it's why I'm approaching it all on my own
the best way to learn that stuff is to do it yourself
with the internet being as big as it is, there is no better time to make games
I'd love to hear it!
Always excited to learn new things
of course you dont have to manage a million things, your knowledge i have seen by far is too good already
you guys should make a thread
sorry, am I spamming the channel?
welcome here buddy, and of course you can tell
I know basic things, but I have a lot more to learn
i mean you guys have been basically using the channel in lieu of dms for the past few minutes
i think a thread is better for everyone
for sure man, sorry mate!
in my opinion you would cook if you learn C#... a little advanced C#
-
Use [SERIALIZE FIELD] to make a private variable modifiable in the explorer
-
Try to not use bland numbers in code since it makes it hard to read (it makes it hard to read and isn't open to modification later) unless it's zero
The rest of the notes I took are very specific and its kind of a long list
Most of them are from the unity basics video made by the same guy who runs the big unity game jam
Don't start with random videos. Better way is to follow a course. This one https://learn.unity.com/pathway/junior-programmer Then Junior Programmer one.
I have been trying to get myself in some of those. I started with that one yt vid where I could get the basics down
Video tutorials with rare exceptions are there to gather clicks not to convey large amount of information needed.
The more comprehensive the course the less gaps in knowledge you get moving to the next subject.
!Learn - checkout courses on Unity Learn!
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
There's no groups. Start with courses then move on to #🕹️┃game-jams , where you can meet people to collaborate with. Start doing small projects yourself.
ty
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
how can i hide these attributes if a value is false on the editor?
inspector
its correct?
What is this attribute from?
flax engine
EditorAttributes, NaughtyAttributes and Odin all have things for "hiding this if something is true/false"
i though would have smth like [visibleif]
ok, but might not be neccesary
or its?
i mean which kind of player will be playing with the editor
its hard?
Easy if using premade ones such as EditorAttibutes (free)
Odin is the best solution (paid) for inspector customisation
BUT all of these solutions will override custom inspectors unless they are changed to inherit from the package base one
If not using a custom inspector it just works
https://catlikecoding.com/unity/tutorials/pseudorandom-noise/perlin-noise/
Im going through this but feel like im making no progress
does anyone else get that feeling
also I dont know how helpful this chapter really is. can someone more experianced dime in for feedback
You may know but unity provides noise generation in a few ways (including a burst compatible one) but if this is just to learn, what part is confusing?
Im just trying to learn. For me, the confusing part is trying to figure out if this is useful for my future. Trying to get into techincal art and my first goal I guess after copy pasting the code from this chapter series is creating my own voxel world. Im guessing that makes sense as a first project doing solo after going through this
but to me. these chapters in pesudoranom noise is very heavy on theory rather than application. Im asking if u find it useful to understand these chapters in depth
Learning how to write and implement an algorithm is not the same as learning where it can be used
But knowing how you may impement such a technique in future is useful, expecially how to make it performant and efficient (as this can be harder in c#)
have u personally gone through these chapters. AM i taking this apporach correctly with what im doing now?
I haven't but I already have many years of dev experience
whats ur feedback for me. Should I continue on this path im going in?
I think its worth learning how these algorithms work so yea try to finish it then expand on learning shaders and compute shaders
How long did it take u to get comfortable with all of this
To me ive been doing it for 3 months now. Feels like Im just studying theory
Hi, i got some problem with my player controller. im learning on how to handle slopes/stairs and i got a small bug on when im decending the slope im kinda yeeting myself from the point where i was insted of sliding/gliding down of it. Any idee ?
Once core language concepts are understood (OO programming ect) you can just start making things.
I can remember doing one of those programming challenge things as that helps you practice thinking up a solution to a problem (or researching it)
!code
📃 Large Code Blocks
Use links to services like:
https://pastes.dev/
https://paste.yunohost.org/
https://share.sidia.net/
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.
thx
I always always always recommend game jams to new devs, there are game jams specifically for technical art stuff too. If you feel like all you're doing in learning theory, try applying it in a small project. Like you're learning noise generation rn so try applying it to make a little infinite runner game or water shader. You dont need to finish it or release it, just try to make something with what you learned. If you're feeling like learning the underlying algorithms feels pointless, the usefulness of learning these kinds of complicated systems isn't always in actually knowing them. It exercises your brain for programmatic thinking that makes you capable of solving more and more difficult problems. Although for technical art, I'd think knowing perlin noise would be pretty important
What makes u say infinite runner game. Im confused on its relation to what I went through in this chapter
how do you think tiny wings generated its levels
np
for slopes you want to project your movement vector onto the slope's plane (what the drawing shows). When you check for the ground, you can get the actual ground object you're colliding with, and the normal of the collision. Use that normal to then set velocity to the result of Vector3.ProjectOnPlane(orginalVelocity, groundNormal) * originalVelocity.magnitude. I'm not sure of Physics.CheckSphere() will give you a normal since I think its just checks for colliders contained in the sphere rather than doing an actual physics cast, so you might need to change your ground check to a Physics.SphereCast(), and get the normal out of raycastHit.normal.
mb i was making it a reply
i did that, was skeetchy but seams to work now :p
i also made a state for when the player is jumping since the slope thing was killing my upward velocity
as a side note its generally advised not set a rigidbody's velocity directly each update since it can result in some jank behavior. Unity is alreay simulating forces on that rb, so youre basically fighting with it over control of what should happen. But tbh I only start see issues from doing that if Im making a game with a lot of rigidbody interactions.
if you start seeing things like your player jittering around when they're pushed, or phasing through walls, that usually means you hit one of those problems. In that case you can use AddForce() with ForceMode.VelocityChange (i think thats the right mode), make a kinematic controller which is a massive pain, or use unity's character controller component (or any other on the asset store).
okay, that nice to know. thx :3
Im playing around with making some player interactasble thing like door and some stuff with the animator
I have a question about manually creating behavior when buttons are clicked
Because im trying to do different stuff based on the state of the object
Ive already done this successfully and it worked great.
I kinda of copied that whole "Menu" and started working on a shop feature instead
now using the ClickedOn() does nothing
dispite working for my other buttons just fine?
if the log is not printing in the console then you are probably not clicking the button
interesting I'll see if something is somehow blocking the interaction
if you're using new input system you can inspect whats being clicked on through inspector of event system
old input system would let you see hover events too
got it working
Could i borrow someones eyes for a moment?
I'm working on a basic interaction system and when I added a sort of debounce to avoid getting hundreds of interactions I seem to have messed something up. The player can now only interact once, before needing to leave the interactionRadius, and re-entering it. I can see the the 'canInteract' does return to true, but if i remain in the radius, it doesn't allow me to interact again.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Your coroutine will run while canInteract is true. Which means once canInteract is set to false the actual logic for starting the interaction won't run until the coroutine is started again when the player re-enters the trigger
So i should add a second bool playerInRadius that the coroutine runs from..
Yep that would be the easiest fix
Np
I'm trying to access particle system material type from another object to use in the object I script for. I do have it that script knows which object do I want to read from (other parts of the script interact with that correct game object).
What should I write to get material from target object to the object I'm scripting?
Currently the code I have is as follows:
particlesRenderer.material = currentTarget.GetComponent<ParticleSystem>().material
Here "particlesRenderer" is reference to ParticleSystemRenderer of the object I'm scripting in and "currentTarget" is the target object from which I'm trying to get material. Problem is that it throws out CS1061, where it doesn't recognize ".material" at the end.
yeah because you need to assign from ParticleSystemRenderer
are you trying to copy material from one system to the other?
the object i script for shoots raycast at a target and "steals" targets particle system material
makes sense
can somebody help me with the buyoncy of a ship in unity urpl ?
i have tried everything but i can t make it work
can anyone explain what I'm doing wrong here?
seems like you need another argument of type bool
that didn't help, still get the same error
oh, it returns UnitaskVoid, but Action needs to return void
🤷 perhaps ask #1390346492019212368
ok
with some knowledge etc, is it possible to use the networking unity has, like fishnet + steam api, for a ok 16 online world map?
lowpoly, darker, baked etc, high fps game
but also deal with the desync and all that stuff?
You need to wrap it inside another function or lambda to match the return type requirement
Async functions usually return a task type hence this not working (if it wants void)
"lowpoly, darker, baked etc, high fps game"
none of this would have major effect on networking at all
well i know that, but i never made any multiplayer stuff, just wondering if a game like that, not a huge map/world, 16 players roughly.
easy to keep in sync? or alot of testing etc?
this warning shouldn't matter here right?
Add .Forget() to the end to stop the warning + ensure uncaught errors are logged
oh brilliant, thanks
Is there any reason i shouldnt use a singleton with ANYTHING that qualifies?
Ive been using it for game manager type objects, but is it okay to use with other scripts as long as i never have more then 1 of them
If you want to make testable systems or flexible systems then yes because things relying on a static field are not flexible
what does "flexible" mean, though?
i think they're very flexible :p
Of course, if you realize that the thing isn't a singleton, you've shot yourself in the foot
It's very difficult to describe why all-singletons type architecture is bad until you run into the issues that it can create. You could look up why global variables are considered harmful in modern programming (C# doesn't even have true global variables) since singletons create similar kind of global access. Basically passing references around is sometimes cumbersome, but that's a good thing because it forces you to think about how to structure the code better and what responsibilites different objects have. If you get an easy access to everything from everywhere, you easily end up with spaghetti code that gets tangled more and more until it becomes unreadable and unmaintainable at worst
isnt that a good thing or?...
Assuming its something that wont cause issues and you just need to reference it without "searching" through tags
Past the beginner stage you should probably never need tags again
If you are very sure that only one instance of a thing will exist and must exist then a singleton ref works
"easy to type" and "good design" are not the same thing
I encountered an issue relating to singleton use recently at my work (was a camera preset system)
Past designs presumed only one would exist at once but a new project changed this and thus started breaking things
The solution? Change to direct serialized references + pass a ref.
Does anyone have any advice for someone who is new to game development?
start small
i have 1 question. Is there any good tutorials to learn C# where the guy explains well and teaches what the code does without making you repeat the video multiple times just to understand 1 line of code and does stuff in order. Yes im asking for too much but ive learned some luau before starting C# so it feels really weird. I mix stuff up. It feels really hard to get used to this.
Participate in game jams
Pinned in this channel
Also my own question unrelated to that
Where does one even begin with "saving data"
the most ive ever done is use playerprefs for setting and saving small stuff for small games.
I just added a shop to my game and i need to save a list of "owned abilities"
where would i start with that
The basic process is "Write a file that says what you have" and "read that file and turn it back into variables"
There's a lot of ways to accomplish that. JSON serialization is the easiest, because you can serialize and deserialize entire objects by just calling a function. Then all you need to do is create an object that serves as your "save data" in game that everything else reads from to know what you have loaded
my buttons are clickable all over the place
why is that?
im on the second camera and still being able to click it
It's because the button is on canvas
Buttons aren't attached to camera they attached to canvas
Yeah but how is it possible that my button is clicked far away even tho canvas is unreachable.
This doesn't sound code related first off. More like #📲┃ui-ux . Second, you'd have to share your setup
I'm doing the essentials pathways tutorial, and I've run into an error with my code, but I can't find what I've placed incorrectly
I've redone the section twice, in case I was just missing a mistake, so I think I'm not grasping where I'm supposed to put the line, maybe?
you would have to show us the details. Almost certainly you didn't copy something correctly, yes.
!code
📃 Large Code Blocks
Use links to services like:
https://pastes.dev/
https://paste.yunohost.org/
https://share.sidia.net/
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.
did that work, correctly?
and thank you, I realised that was a large chunk of text
Is this sufficient details, or is more info needed?
Can you share what error you're getting?
You said "I've run into an error with my code"
Assets_Unity Essentials\Scripts\Collectible.cs(33,1): error CS1027: #endif directive expected
thank you, by the way.
Are you sure this is the file mentioned in the error?
you're using #if on line 24
Check Assets_Unity Essentials\Scripts\Collectible.cs
let me see if I can set it off again?
Oh - wow how did I miss that
NVM yes it's what Chris said
# makes a preprocessor directive - maybe you accidentally wrote this by habit for comments from other languages?
Yeah are you a Python user by chance?
# is not a comment in C#
C# uses // for inline comments
(tbf quite a lot of languages use #)
Python is the most commonly used tho 😛
not really, I did python back is hs, ages ago, I don't remember any of it
ok, let me go over it again
Ok well - regardless, you accidentally added a #
you also didn't finish writing the if statement
or rather - you didn't get the brackets exactly right as it mentions you should make sure you do
found it! thank you!
I appreciate both the help and the patience. I've noticed not everywhere is kind to newbies
I am using NetCode for multiplayer gameplay. I am spawning the players manually, this is my code that is fired when the player connects
private void HandleClientConnected(ulong clientId)
{
if (NetworkManager.Singleton.IsServer)
{
GameObject playerInstance = Instantiate(playerPrefab);
GameObject spawner = spawners[currentSpawnerIndex];
currentSpawnerIndex += 1;
NetworkObject networkObject = playerInstance.GetComponent<NetworkObject>();
networkObject.SpawnAsPlayerObject(clientId);
playerInstance.transform.SetPositionAndRotation(spawner.transform.position, spawner.transform.rotation);
Debug.Log($"Spawning player for client {clientId} at {playerInstance.transform.position}");
GameManager.Instance.RegisterPlayer(clientId, playerInstance);
}
}
but my players are getting spawned at the origin
i have removed the pplayer prefab from the networkmanager
think you need to set the position before you do any of the actual spawning?
so get the spawner first, instantiate at the spawners position and rotation, and then spawn it across the network
try that and see if it works
Well for one why not spawn it at the correct position in the first place? Instead of Instatiate(prefab) use the Instantiate(prefab, position, rotation form.
Im trying to make my player jump using the AddForce to do movement for my player. Every time I move my player in the air I think it 0s my Y how can I keep the same momentum moving left and right in the air without halting my jumpforce?
Here is my current code for the player movement I have in FixedUpdate:
rigidbody2D.AddForce(new Vector2(playerMovement.inputDirection.x * playerMovement.SpeedMultiplier, rigidbody2D.linearVelocityY),ForceMode2D.Force);```
This is the force i apply to my player when the jump button is pressed:
{
jumpButtonPressed = true;
rigidbody2D.AddForce(Vector2.up * playerMovement.jumpSpeed, ForceMode2D.Impulse);
} ```
https://discord.com/channels/489222168727519232/1498343150207373312 don't cross-post
this fixed that issue. but later in the game i want to teleport the player to a different position, but i am not able to do that
for (int i = 0; i < players.Count; i++)
{
Debug.Log("Positioning player " + i + " at start position.");
GameObject player = players[i];
PlayerController playerController = player.GetComponent<PlayerController>();
playerController.enabled = false;
NetworkTransform networkTransform = player.GetComponent<NetworkTransform>();
networkTransform.Teleport(startPositions[i].transform.position, startPositions[i].transform.rotation, Vector3.one);
player.transform.SetPositionAndRotation(startPositions[i].transform.position, startPositions[i].transform.rotation);
playerController.enabled = true;
}
the position of the player doesnt change
Where is this code running? On the server? On the client? What's the network topology and NetworkObject ownership setup? TBH if you're asking networking questions in #💻┃code-beginner you're really in the wrong place. #1390346492019212368 is more suited, and you haven't provided nearly enough info to appopriately answer these questions
created a post there https://discord.com/channels/489222168727519232/1500597584882827276
Hello Ppl !!
I have a little problem with a FPS controller. I'm learning level design and I just want a very simple GO to walk around my scene.
I've get a basic FPS controller. It work (the view move with the mouse, WASD work great etc...) BUT, the mouse is not "locked" in center of the screen 😕
in my script, I have :
void RefreshCursor()
{
if (!cursorActive)
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
else
{
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
}
}
at the start of the Update function, i've put a Debug.Log :
LockState: Locked | cursorActive: False | visible: False
Anyone know why my cursor is "locked" and "visible False" in my engine, but not locked and still visible in the Editor ?
I've try to build the game, and I have the same problem with the build 😕
ver: Unity 6000.4.4f1
thank all for your help 🙂
Is RefreshCursor ever running?
Are you actually calling it anywhere?
yep, It is call at the end of Initialize, and in a ProcessInput function (called in the Update)
if ( inputKeyDownCursor )
{
ToggleLockCursor();
}
what is inputKeyDownCursor? How does that get set?
Maybe just show the full script
I've got this script from a thread on the Unity website (I'm not sure (don't remember ^^')),
But FYI, i've try the "Starter Assets - FirstPerson | URP" on the Asset Store and I have the exactly same problem 😕
What is input key down cursor? When is it assigned?
!code
📃 Large Code Blocks
Use links to services like:
https://pastes.dev/
https://paste.yunohost.org/
https://share.sidia.net/
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.
the inputKeyDownCursor is :
inputKeyDownCursor = Input.GetKeyDown( keyToggleCursor );
[...]
public KeyCode keyToggleCursor = KeyCode.BackQuote;
But stop searching haha
I think I've found out the origin : I'm a BrainFarter !
I'm working on a REMOTE machine !
The visible and not locked cursor is on the CURRENT machine....... The remote one seems to be unvisible AND locked '-_-
Sorry for the time '-_-
And thanks for help 🙂
https://hastebin.ianhon.com/adc6
So I am trying to get the head moving but it doesn't seem to work
my bad for teting in the wrong channel, idk if this is a big ask but is there anyone who can help me code a simple 2D platformer for a school final?
ok so i am trying to use the ik rig but it's not working
{
if (!animator) return;
if(lookingAt != null)
{
animator.SetLookAtWeight(1);
animator.SetLookAtPosition(lookingAt.transform.position);
}
else
{
animator.SetLookAtWeight(0);
}
}```
[SOLVED]
I think I'm misunderstanding Unity's built-in ObjectPool. Here's the important bit of my code: https://pastes.dev/NADWSIUxuh
As far as I know, ObjectPools should prefer to use "actionOnGet" as long as there exists a disabled version of the desired object. And it should certainly do this when the number of objects in the pool is less than the maxSize. But in my experience it seems to continually call "createFunc". I have defaultCapacity and maxSize set arbitrarily low to test this
the bullet has no code to destroy or disable itself, all of that is handled by the script that contains the code in the link
please @ me with any response 🙏
Not enough info here. We need to see your patterns of calling Get etc on the pool
But generally it will be always calling both createFunc and actionOnGet on newly created bullets
and it won't be able to reuse any bullets until some have been returned to the pool
I think it ended up being a dumb mistake of me calling my chosen release method instead of the objectpool's release haha, i wish i caught it before sending the question
ah yep - should be pool.Release(bullet)
indeed. all works now. thank you for taking a look regardless! i'll keep in mind the bit about needing more detail for future questions
Not code related
i not understand
Look at which channel you are in
just learn
hello,
I am currently making a camera zooming script and I noticed a bug whilst in the editor, when I am scrolling down my inspector it now zooms my camera, because Mouse.current.middleButton.isPressed is technically true, even though I am not trying to zoom in the game viewer. How would i go about fixing this?
Pretty sure unity still sees the game view as active, so it's still listening for inputs.
I usually just tap my windows key and click out of the game view, like your assets or heirarchy window.
okay ty 🙂
hello
i having problem
im making unity multiplayer game and im using unity transport and got the network manager script and all
i put the port as 7777 and we are using zerotier which my friend is on the network and is authorised and so am i
the address is also the correct address in the zerotier so its not that
we both gave access to the game in our firewall and when we launch i host the game and it works but friend clicks client and it doesnt even do anything
i can host on one instance and join myself on it
my friend can also host on one instance and join himself i just cant join him and he cant join me
we only have one host at a time so its not that i just dont know why this is happening
i tried ai and he said this script should work hostButton and clientBUtton are buttons and their good
using Unity.Netcode;
using Unity.Netcode.Transports.UTP;
using UnityEngine;
using UnityEngine.UI;
public class ConnectUIScript : MonoBehaviour
{
[SerializeField] private Button hostButton;
[SerializeField] private Button clientButton;
private void Start()
{
hostButton.onClick.AddListener(HostButtonOnClick);
clientButton.onClick.AddListener(ClientButtonOnClick);
}
private void HostButtonOnClick()
{
Debug.Log("HOST CLICKED");
var transport = NetworkManager.Singleton.GetComponent<UnityTransport>();
transport.SetConnectionData("0.0.0.0", 7777);
NetworkManager.Singleton.StartHost();
}
private void ClientButtonOnClick()
{
Debug.Log("CLIENT CLICKED");
var transport = NetworkManager.Singleton.GetComponent<UnityTransport>();
transport.SetConnectionData("127.0.0.1", 7777);
NetworkManager.Singleton.StartClient();
}
}
just fyi, that input control is for clicking middle mouse, scrolling is a separate control
how do I disable srgb sampling for my rendertexture? I am storing a packed normal map and srgb is skewing the vectors
how is the normal getting into the render texture? Does it even need to be a render texture and not just a normal tex2d?
created at runtime. packed via. *0.5 + 0.5 then unpacked with the inverse. therefore 0, 1, 0 gets packed to 0.5, 1, 0,5, skewed by srgb and then unpacked completely wrong
yea but that doesnt answer the question i asked
anyway you should be able to create a render texture srgb conversion disabled https://docs.unity3d.com/6000.4/Documentation/ScriptReference/RenderTextureDescriptor.html
you can create a plain old texture with your data thats not srgb too
I am converting a changing height map into a normal map with compute shaders
ah im dumb it must be a render tex to be a render output
then the solution is to create the render tex at runtime with the correct parameters via a render texture descriptor
does srgb only take place when read in a material or do I have to go over the entire project now and change it to linear for any buffer textures too?
my Update() function in a script thats on a prefab is not firing whatsoever when its instantiated from a list, regardless if the list is for a GameObject or ScriptableObject, everything is being initialized just fine, but if i drag in the prefab into the scene through the editor or instantiate the object but not from a list, Update() fires just fine.
📃 Large Code Blocks
Use links to services like:
https://pastes.dev/
https://paste.yunohost.org/
https://share.sidia.net/
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 an object exists in the scene, it will run Update.
Either you're not actually spawning it, you're getting an error which is preventing the rest of the update function from happening, or it's running update just fine and you're just not checking properly
or it’s not enabled and/or active
the script is enabled its in the object, everything except for Update() is running, though i did figure this out and im actively fixing it, hopefully whichever solution i figured out works, as the objects are a child of a manager, and whatever is not selected gets disabled
If a parent object is disabled all of its children are also disabled
I dunno if its the right channel but how do i make this character appear in the game section? I'm following the tutorial but something dont work lol
She has some kind camera on tutorial and i dont know how to spawn it
This isn't, no. #💻┃unity-talk
However, this is the classic case where your camera is simply not pointing at your character. Start with setting your character to 0,0,0 so it's at least somewhere useable. Then position your camera at something like 0,0,-10 so it's sharing the same x/y but pulled back a bit so that it can actually see it.
Okay, thanks and i'll switch the channel next time lol
I keep getting this error message for my looking around character control script. I can't find the error, can someone maybe see it or help me out?🙏
tells you exactly which line and collumn the error is on
(30,6)
and if you're not getting compiler errors highlighted in your ide you need to configure it
!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
is anyone here atm?
I'm following a tutorial on how to make a 2D platformer for my final and I'm not sure why the enemy isn't moving
heres the code so far
!code
📃 Large Code Blocks
Use links to services like:
https://pastes.dev/
https://paste.yunohost.org/
https://share.sidia.net/
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.
not the best code bin to choose
It is at the top of the list
Debug.Log(isGrounded);
Show the inspector for Enemy
do this and tell us what it says
alright alright thank yall
also how do I do this?
Screenshot
https://screenshot.help/ has commands for every OS.
Is your ground actually set to the Ground layer?
yeah
You're using a 3D Raycast to detect the ground. Does your ground have 3D colliders on it?
so far it's better than the others, do you have a better one in mind?
literally every code bin is better
you can capture specific windows btw
the others don't support the viewer changing the language
it only has 2D which does explain a lot...
you got a suggestion for one that isn't out of business or filled with Ads?
pasteofcode is neat
does it support changing the language, as a viewer?
i didn't find that last time i checked
also where should I put the debug log?
Any time after you set it, but using a 2D raycast should solve the problem
put it into the Update , ideally right after your isGrounded = code
also also I sapologize in advance if I sound incompetent to this. I'm an animation major that knows little to nothing about coding 💔
It's not the easiest to spot, it took me a bit before I noticed. I was expecting the issue to be related to the layering
wait also does RayCastHit2D not count as a 2D raycast?
should i put 2D after all the raycast commands?
nice catch, the Debug.Log would have solved it too
I have at last encounted another issue :[
I'm very unsure of how I can code animation(how to code the left and right walk cycles since the charcater's left and right profiles are different) I also couldn't get the other animations to work following the Game Code Library's tutorial. Unsure what I did wrong or how I can fix it after looking at neumorous animation tutorials
I provided the code link along with the ss of the inspector
you would have different clips for walking left vs walking right, and you could use a blendtree to choose between them (while not duplicating the entire logic of walking)
#🏃┃animation fyi
about the other animations not working (i presume just jump?) make sure you've linked up the transitions and params correctly, try debugging to make sure the params update as expected
I've managed to get them working but it's still killing me that the walking left animation is walking in the wrong direction
and also that the character keeps getting stuck to the walls and I'm not able to wall climb
for getting stuck to walls, you might want to add a frictionless physics material to the walls
is it oky if we can dm and call?
I might need multiple ways of help t complete this game by tmmru
also I did along with the player, but I'm still having problems
it's okay if you don't want to dm and call. My bad for bringing it up when we just met. I'm panicking because of finals
Hello, I'm making a game that will have many enemies in it and I want to try to make a spawner object that can assign models and behaviors for enemies so that I dont have to make a million different prefabs for very similar enemies. I heard scriptable objects may be the way to go, but I dont know if the spawner itself should be the scriptable object or the enemies?
I want to assign things like enemy model, bullet type, health, movement angle, etc
i have a raycast that i am drawing using a linerederer with a slight offset from the camera center. but when my player moves the linerederer appears to flicker and somtimes move like infront of the camera for a sec.
i tried moving the drawing code to lateupdate but still getting the same
You'd have to show the code and explain how your character movement works
that would defeat the purpose of having a community server 😉
also it seems like you have multiple unrelated issues right now, tackle them one at a time
SOs are just giant stacks of data, youd have a different script that takes the data and inputs it into gameobjects
Okay, so I have this stack of data here
public class SpawnerData : ScriptableObject
{
public int enemyHealth = 1;
public GameObject enemyType;
public GameObject bulletType;
public Transform spawnPoint;
public float enemySpeed = 2;
public float movementAngle = 0;
}```
How do I take the data from here and assign it to my enemy spawner? This is my attempt at a spawner thus far, but it doesnt seem to work.
```public class EnemySpawner : MonoBehaviour
{ [SerializeField] private SpawnerData dataList;
private float enemyInterval = 3f;
public Enemy enemyType;
private IEnumerator spawnEnemy(float interval, GameObject enemy)
{ yield return new WaitForSeconds(interval);
EnemyTest newEnemy = Instantiate(dataList.enemyType, dataList.spawnPoint.position, dataList.spawnPoint.rotation);
newEnemy.enemyHealth = dataList.enemyHealth;
newEnemy.bulletType = dataList.bulletType;
newEnemy.enemySpeed = dataList.enemySpeed;
newEnemy.movementAngle = dataList.movementAngle;
StartCoroutine(spawnEnemy(interval,newEnemy));
}
}```
it says "\EnemySpawner.cs(10,12): error CS0246: The type or namespace name 'Enemy' could not be found (are you missing a using directive or an assembly reference?)"
when I try to change public Enemy to public EnemyType it says "error CS0029: Cannot implicitly convert type 'UnityEngine.GameObject' to 'EnemyTest'"
You're trying to store an EnemyTest class as a GameObject ur gonna have to convert it/change the class of newEnemy first
How would I do that?
And also ur gonna need to show me ur enemy script too
{
[SerializeField]
public int enemyHealth;
public float enemySpeed;
public float movementAngle;
[SerializeField]
private EnemyTest configuration;
private void Start()
{
enemyHealth = configuration.enemyHealth;
enemySpeed = configuration.enemySpeed;
movementAngle = configuration.movementAngle;
}
private void OnTriggerEnter(Collider other)
{
if (other.CompareTag("PlayerBullet"))
{ enemyHealth -= 1;
Debug.Log("I got hit by playerbullet");
if (enemyHealth <=0){
Destroy(gameObject);
}
}
}
void Update() {
transform.Translate(new Vector3(0, 0, 2 * enemySpeed * Time.deltaTime));
transform.eulerAngles = new Vector3(0f,transform.eulerAngles.y+movementAngle * enemySpeed * Time.deltaTime,0f);
}
}
``` This is what I have for the enemy so far. I only have the public floats there right now because it'll give me errors that data like movementAngle isnt found
I ment the script containing the Enemy class
I dont have one actually... I tried asking someone else how to make this work and they told me I need to use "Enemy" but when I asked why they never responded
Im sorry. Im very new.
So I need yet another script?
if you don't have an enemy class you can't reference an enemy class
Simply put you are trying to tell a newborn to get you noodles when you havent explained what a noodle is yet
Makes sense. Probably a pretty big thing to ask but, how do I make the enemy class script?
Also how have u been coding if you dont know how to make your own classes?
Tutorials mostly. I know, I know, its better to actually get c# knowledge first...
Hey, is there a way I could use asset in a folder? Like get an image in a folder and set it as sprite?
you might need to be more specific
Wait. Isnt my EnemyTest script pretty much that though?
Like having a png file in persistentdatapath for example
and set it as a sprite at runtime
Yea but you named the class EnemyTest and not Enemy
sure
As for this you might want to google "how to get a component from a gameobject unity"
But i recommend trying simpler projects to start
I see. Okay so I changed the name and yeah it still says cannot convert to gameobject. I guess I'll google...
This is technically my second project so I thought I could do something a lil more challenging. Once I get this spawner to work my game is basically finished so Im very close
Oh nvm then you're good then
Hint: || public Enemy enemyType isnt really doing anything here you can get rid of it||
Thank you
Ah Ive used GetComponents<ComponentType>() before. I dont quite understand how that can be used to change Enemy into a game object though.
you cannot change something thats one type into another type like that
How would I do it? Im trying to do it like
SpawnerData newEnemy = (GameObject)Instantiate(dataList.enemyType, dataList.spawnPoint.position, dataList.spawnPoint.rotation);
and
SpawnerData newEnemy = Instantiate(dataList.enemyType, dataList.spawnPoint.position, dataList.spawnPoint.rotation) as GameObject;
but its giving the same error
why are you casting to GameObject at all?
Because unity seems to be upset that its not a gameobject (I guess since Im trying to assign transforms?)
Instantiate will return the same type of object you pass as the first parameter, so if dataList.enemyType is a SpawnerData then it will return a SpawnerData which, presumably, cannot be cast to GameObject. if it is a GameObject then it will return a GameObject thus the cast is entirely pointless
what is the actual error you receive
Assets\EnemyScripts\EnemySpawner.cs(17,44): error CS1503: Argument 2: cannot convert from 'Enemy' to 'UnityEngine.GameObject'
Same error when I replace "enemy" with "spawnerdata"
i, of course, was referring to without the cast. but it seems that dataList.enemyType is an Enemy, not a SpawnerData
Yes, I was just trying SpawnerData to see if anything would change 😓 Sorry
can someone help me with the problem a bit higher?
How do I change a sprite at runtime by an image that i have in a folder
I know how to change a sprite but how do I reference it
is this a sprite on the end-user's machine, in Resources, or just in your assets folder?
ok so just for the sake of getting answers faster, you can just skip to the getting the reference part
since thats the actual thing you don't know
Whatever like persistent datapath or something
Like appdata locals where my saves are
quite a few places to look at here
This is my general understanding
Scriptable object = where I store the enemy stats
Enemy = What is meant to be the actual enemy object that spawns, is meant to pull data from enemy spawner
EnemySpawner = What Im trying to spawn enemies from and assign them their stats
you need a class that inherits from scriptableobject
fix the types in your code then provide the actual error message you are receiving if you still need help
Thats what I tried to do in my Enemy script
private SpawnerData spawnerdata ;
private void Start()
{
enemyHealth = spawnerdata.enemyHealth;
enemySpeed = spawnerdata.enemySpeed;
movementAngle = spawnerdata.movementAngle;
}
based on this message i don't think you know what inheritance is
this kinda stuff might be a bit too much for you to grasp for where your at c# wise, no disrespect
Well I'm not going to give up when Im so close to having the game done thats for sure. I'll go take a look at what inheritance is n see if I can get any closer.
What Type is dataList.enemyType
Okay, reading up a bit on inheritance and I'm kinda seeing it. So I make Spawnerdata the parent since thats what Im trying to inherit from, so then I would instead have public class Enemy : MonoBehaviour I would have it be public class Enemy : SpawnerData? Or would I inherit spawnerdata in EnemySpawner?
Gameobject
So it will return a GameObject. Not a SpawnerData.
If you want it to return a SpawnerData, you need dataList.enemyType to be of type SpawnerData
Enemy type is meant to be where I determine the prefab 3d model
Does the object have a SpawnerData component on it
SpawnerData is a scriptable object, when I try to use public SpawnerData dataList; on the EnemySpawner nothing seems to be happening
So, your instantiate cannot return a SpawnerData. Trying to store the result of instantiate in a variable of that type cannot work.
Maybe scriptable objects isnt the right way to approach this at all?...Im just trying to make a spawner that can assign attributes to the enemies it spawns
Instantiate returns with a circle(GameObject) you are trying to put the circle in a square hole(SpawnerData)
it is potentially a right way but you (again respectfully) don't understand what your doing enough in order to use them
If your scriptable object contains the data you want, you can probably just have that reference the prefab you want to spawn. Then you get your SO object with all the data you want, get the prefab you want, spawn it, and set whatever other data you need from that SO
Im trying to learn, hence why I'm asking for help. I'm sorry.
Heres one enemy type I made. It has the prefab n such in it.
Okay, so, you'd have your spawner reference one of these spawner datas.
Then you'd instantiate the enemy type from this
I assumed public SpawnerData dataList; was doing that and then I could drag the enemy type into it, but no option appears
Do you have any compile errors still
It still says Argument 2: cannot convert from 'Enemy' to 'UnityEngine.GameObject'
On what line
17, 44 on EnemySpawner
StartCoroutine(spawnEnemy(interval,newEnemy));
So look at the parameters spawnEnemy takes, and actually give it those types
I am setting those types I think, with interval set to 3 and newEnemy is set to the Instantiate
Enemy =/= gameobject
Thank you
What parameters does spawnEnemy take, and what types are interval and newEnemy
I asked about that and got there is no where from a Mod no less.
@opal plume Don't post off-topic here. If you have a question about moderation, create a mod ticket.
@opal plume Also to clarify, this is a server about creating things in Unity not promoting your tools.
that was a unity announcement i think?
IEnumerator spawnEnemy(float interval, GameObject enemy)
Okay, so yeah Enemy is an instantiate which isnt directly a gameobject. Should I be using it like this?
StartCoroutine(spawnEnemy(interval,enemyType)); Since enemyType should be a game object
The function expects a game object. You have to give it a game object. Which object do you want to give it
pretty sure they're referring to the first time that person had posted ai nonsense and gotten it removed
does that spawnEnemy method need to accept a GameObject object rather than an Enemy object? if there is no specific reason to use the GameObject type for that parameter, then use the type you actually care about
enemyType I suppose, since thats the actual model the enemy will use? but its giving an error still
Assets\EnemyScripts\EnemySpawner.cs(18,44): error CS0103: The name 'enemyType' does not exist in the current context
To have to use something that exists
You ought to read the errors, they tell you what the problems are
enemyType should exist though, its in the SpawnerData
you seem to be just changing random things with no understanding of what should be changed or why.
you should start by learning the absolute basics of how C# works if you don't understand. there are beginner courses pinned in this channel
Is the code that has the error in SpawnerData
No, its in EnemySpawner
So why would it existing in SpawnerData have anything to do with it
I understand its not existing in EnemySpawner, What Im trying to do is getting EnemySpawner to get the data from SpawnerData
They are not my tools? Don't assume. I wish you just directed me to the right channel but instead you were aggressive and dismissive which I do not understand when I am genuinely trying to help others. Fine it was the wrong place, so direct me instead of saying there is no channel. You had the opportunity to lead but instead you took the lower road and I am really not sure why as I have never had an issue on this Discord or any Discord. I am just trying to contribute.
If I told you to take a flight on my private jet, and you asked me where it was, and I said "Warren Buffet had a private jet" would that in any way answer the question
No. Im sorry. I know Im lacking some key c# knowledge, I just feel like I'm so so close to getting this to work.
If you are not here to learn about working with Unity, you are not on the right server. There's no promotion of external services on the server. And stop spamming this channel with off-topic as well.
it wasn't an external service in this case
So, on the object calling spawn enemy, what object do you want to pass to it
They are promoting their "AI" plugin. There's no advertizement here.
The enemies that it spawns. The object that moves around and attacks.
there most recent post in this channel that sparked this current conversation was regarding the recent thing in #📢┃announcements, i can't speak on anything they posted prior
Okay, and does the thing calling spawnEnemy have a reference to that object
Im trying to do so by putting public GameObject enemy; to the top but all these errors are still happening
How about you read the first error and tell me what you think it means
It means Enemy script doesnt have any of that info
And, does it?
I thought it would by having SpawnerData called but it seems not.
{
enemyHealth = spawnerdata.enemyHealth;
enemySpeed = spawnerdata.enemySpeed;
movementAngle = spawnerdata.movementAngle;
}```
thats not how c# works
you need to know that in order to be doing these kinds of things
Code isn't magic. It does what you tell it.
If you say Enemy.enemyHealth, you're saying to get the enemyHealth variable from Enemy
If Enemy doesn't have a variable called enemyHealth, you can't do that
So I need to give this enemy script its variables. I want to do that without having to make several different Enemy scripts all with slightly different stats. But I cant seem to attach the Scriptable Objects I made to the Enemy without having to get rid of these errors by giving them their own variables anyway.
I'm sorry if Im being a bother.
It's not that your being a bother persay it's just that it's this weird point in which we aren't really qualified to teach you the big gaps of knowledge you might be needing for this and answering your questions directly isn't getting far because you don't understand what the answers are saying
Attaching an object will not solve compile errors. You can't solve these by dragging in an object
You have to actually write code that makes sense
You have to use variables that exist. You have to give functions the types they require.
And all of this makes sense. Like. I know. I know a computer can only do what you give to it. I know it wont just fill gaps for me. I feel embarrassed now saying this now but I know quite a lot of C++ and I thought maybe C# wouldn't be all that different but I was very very wrong. I definitely am very lost.
I just felt like I was very close and thought maybe a gentle nudge could make this work but theres clearly something very very big Im missing. I'm sorry.
It isn't. None of this is C# specific. This is all basic syntax that all languages share
it's kinda offtopic but if Start() was a constructor the snippet above would work in python right?
You can't pass an int to a C++ function that expects a string. You can't get a .name variable from a char
You might want to restart from the basics
sorry for budging in the conversation but I've been trying numourous times trying to fix the movements along with the animations with my platformer, but I've had no success
is there anyone who could help?
Dont ask to ask, just ask
I'll keep trying to learn on my own. Sorry again. Have a good one anyways.
I just didn't want to butt in the middle of someones convo
https://paste.ofcode.org/Ugs4L3JYWa8Z247LbvkM7Y
I've been trying to get my character to wall jump and slide while also maintaining the animations and their transitions. I've been trying to use shortcuts like yt tutorials but it hasn't been helping at all
whats wrong with the code like im trying to make raycast door opening and closing but when i hit play its like door itself opens and doesnt even close
\
Log if it enters PlayerAnimation and the else statement, see if that works
Seems to me like it would close too quickly after opening but it's easier if it's known if it enters the code at all
!share
There's no command called
share.
i dont get it, why do people use animations to open/close doors? why dont just rotate it in unity?
i feel like youre overcomplicating it for no reason + you have easier and better control over the speed, angle, direction, everything is easier and better
If you already have a workflow for animating everything else in the game then making an exception for doors wouldn't be that great
Also I would argue that with proper animating tools you get much more control than with just code
animation curves can also control these quite easily and visually
wow that theme is beautiful, what theme is that?
hello is anybody able to help with why this script, it doesn't make the turret of the enemy tank track my player tank which i move around? it also only shoots in one direction and at an angle aimed slightly higher which I am unsure why it's doing it, although glad it is at least shooting it's not quite there
Are you certain the target is correct?
Log some of the values to see what they are.
A common mistake would be referencing a prefab rather than the actual target.
Other than that, you'd need to verify if the values are correct.
oh i see it might be that bgl
ngl
How do I use unitys documentation "better"? I was looking for some info about how to use Rigidbody and since many of you tell me to NOT use AI I did it the way everyone tells me to do: googeling stuff and using the documentation. However searching for "Rigidbody" in the unity docs gives me hundreds of results. when I search in the unity manual https://docs.unity3d.com/Manual/30_search.html?q=rigidbody I get 176 results and in the unity scripting API https://docs.unity3d.com/ScriptReference/30_search.html?q=rigidbody i get 436, so even more. Under these circumstances, I would rather use AI to safe time but I do sacrifise reliaibility. Anything I can improve to not be overwhelmed by the docs?
If you want to know about rigidbody, you should click on the one that says rigidbody.
It conveniently lists every single member function and property of the class in one page (which are the other links you can see)
If you want to know how to use AddForce, look up AddForce
It's not really that hard. You search for something, then click on that thing
It's pretty easy if you're not being willfully obtuse to prove a point
hey, any good place i can learn how to make a hud, like a proper one ?
i have a leads of just making text on a 2D plane and that above everything else
and display my stuff there but all the tutorial are like from 2019
and i dont really want to use something like ai to learn this
how to make a hud, like a proper one
make the logic proper first that works without UI then attach UI later
they should still work, unless you're using the new ui toolkit i guess. cant think of anything that has changed that would make the tutorials not work anymore
where do I look first? the manual or API?
What specifically are you trying to look up? If it's just for light reading, then this covers a lot of things:
https://docs.unity3d.com/6000.4/Documentation/ScriptReference/Rigidbody.html
the manual will be more like an overview..
the api will be more about individual methods/parameters and stuff
i guess it depends on how comfortable u are and what exactly ur wanting to find
If you want to just know about rigidbody in general:
https://docs.unity3d.com/6000.4/Documentation/Manual/rigidbody-physics-section.html
Rigidbody is just an example, since I started learning unity and coding 1-2 months ago I dont know what there is I can type. for example moving a rigidbody using Rigidbody.linearVelocity is not something that comes to my mind when I never coded before.
then #💻┃code-beginner message Osteel's first suggestion
like a big-ole cheat-sheet
but that happens to us all
at first u just dont know what u dont know..
you'll eventually learn what works for u.. what u use the most.. and then that type of thing just becomes muscle memory
whats the difference between Properties, Static Methods and Public Methods? since they all "do something" to the rigidbody
properties are like settings..
myRigidbody.isKinematic = true;
methods are like the actions..
myRigidbody.Move()
No, they don't. Only methods "do something".
well... properties are technically just syntactic sugar around methods
hey guys i suck so bad at coding yet i have so many dream games to make, any tips? onne is a fps shooter game with a market, stats and inv with cases in game and the other is similar to my summer car
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
first tip:
- get better at coding
tip: make a bunch of easier/smaller games for a while to level up your skills
its possible tho
without a team.. ur basically ust gonna burn urself out w/ a big project
it is very possible..
dont get the wrong idea here
but wasnt like msc made by one person
possible != probable
not for a single person, not for a person this inexperienced
eventually it can and will be
regardless of how BAD they are now
just takes the drive..
You're not going to skip on the "learning" phase by wishing hard enough.
Hit the books.
yup.. lol
it will be possible but the idea of having patience requires a lot of self control
the learning part is kinda mandatory tho
ik
bingo
oh hi Kuzmo 👋
few years
u can start making basic games and stuff well in the first year
maybe not the best games.. but its a start
im pushing my 6th year.. still no published games 😭
lol
theres also no guarantee your dream project will be successful or make any money
i hope i can atleast make the menu with cases this year
its mainly for fun
oh yea.. that'd be easy
one of them atleast
if u have any art background.. UI is pretty easy to start working with
if u keep it this way.. you'll have a much better chance of success
a little bit maybe
oh yes
lol.. that was my first gamer nick-name ever.. back in the 1990s i went by "Wrath", eventually became Wraf, then Wraffy or Wrafsicle 😄
holy 1990's??
uncle
yooo
hi
im here for inspiration.. if old-man me can game-dev any of u young-bucks can 😉
guys what is the easiest program for designing levels and maps for unity
A sheet of graph paper
a combination of probuilder and blender
depends on what you mean by "designing"
also how is this a code question
I have come across my my most discouraging problem yet. If i grab like (50 units), and put them in a formation that has circles under each tile where a soldier should be. Not only do units like to awkwardly path in efficient vertical lines like they are waiting for a return. Worst of all it takes them too much time to get in formation, it would probably be much easier what no unit collusion but this game has 1 space = 1 space occupied 99% of the time. So they are bumping past each other and trying to find ways to get to the location they want. But i think its doing it wrong. I asked a programmer friend on how to fix this, and he wasnt sure including another programming friend. So then i resorted to AI and AI did not give me a workable solution. What am i missing. Is there some kind of math formula combination im missing. I used to have something more normal but i took a break to do a few weeks of memory management and reduce lag for large amount of units as much as possible. And i think this creeped up on me through the changes
Hi everyone. Does anybody now how to fix this? i try to install Unity AI
also I faced this behavior after install this package. It's just freeze like this.
Congratulations you've invented Dragoon Pathing
(Zero clue if this will embed)
https://external-preview.redd.it/vOhRHzUbjwYSngXTpLoi41AV_alNg2xKPtEXPHwaEPs.gif?width=461&format=mp4&s=4c1c8fe3877519dcdf7037e7e5323b84753256c8
ha
This is a very non-trivial problem to solve. It might not even be worth trying to solve
The first thing that comes to mind: how do you assign each unit to a spot in the formation?
if each unit wants to travel a long distance, you'll get tons of collisions
ideally, each unit should move as little as possible
(this is probably one of those intractable NP-complete problems, because everything interesting is...)
hello so im doing a dash script, im getting back into unity and I got a question, what is the alternative of rigidbody.velocity = ...
you mean the new one in Unity 6? It was renamed to linearVelocity
thank you and um whats the difference between linearVelocity and angularVelocity?
One is line. The other is spin.
oh ok makes sense thanks
the IEnumerators also changed I see, whats their replacement?
They haven't
am I missing any using directives then?
how should we know without seeing your code/error messages?
Yeah, probably
ok it was System.Collections
I found that there is a new input system and it gives me an error the way I implemented it, how do i swap the input code?
!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.
or if you want to actually migrate to the new system: https://docs.unity3d.com/Packages/com.unity.inputsystem@1.19/manual/Migration.html
thanks
Hi guys! I'm really stuck with something. I think I'm missing something super simple, but I just can't seem to figure out what it is.
I'm currently working on customizing my inspector a bit, using VisualElements in a PropertyDrawer. Essentially, you have different QuestTypes, and depending on the QuestType I want to show different fields in the inspector.
I'm Adding the right children to the root, and it does work with the initial QuestType picked, but when I change QuestType in the inspector, no children get displayed.
Again, it should be something so simple, yet I can't seem to figure out what I'm doing wrong. Anyone here have any experience with VisualElements?
#↕️┃editor-extensions message
Ah thank you, wasn't sure if this was the right channel 🙏
so im working on an outline system for a port im making but once i walk up it an object that can be outline, it will outline that object plus all other objects that can be outline
using System.Collections.Generic;
using UnityEngine;
using System.CodeDom;
public class OnHover : MonoBehaviour {
[SerializeField] public GameObject highlighted;
// Use this for initialization
void Start () {
StartCoroutine(timerDelay());
}
// Update is called once per frame
void Update () {
}
[SerializeField]
private void OnTriggerEnter(Collider other)
{
highlighted.SetActive(true);
}
[SerializeField]
private void OnTriggerExit(Collider other)
{
highlighted.SetActive(false);
}
IEnumerator timerDelay()
{
yield return null;
highlighted.SetActive(false);
}
}```
im using unity version 2018.2.19f1
So whats the issue
instead of it js outline the object that im near it outlines all objects that can be outlined
Why are you serializing OnTriggerEnter and OntriggerExit and what is timerDelay() supposed to be doing here
lwk the serializing was to test what it does but its useless in this case and timerdelay is adding a delay before it removes the highlight bc the highlight was starting on enabled even tho disabled
Theres no delay before the code is run
wym
You didnt add a delay so there is no delay
The code is run on start, theres no delay
its skiping the first frame bc the outline was getting enabled before the code initalizes so i added a delay
it works
yield return null causes a single frame delay
Ah thats what u ment nvm
This is happening because OnTriggerEnter() is called every time the game object enters a collider
its lwk. not
Start adding some logging
e.g.
private void OnTriggerEnter(Collider other)
{
Debug.Log($"Highlighting {highlighted.name} from script attached to {this.name}");
highlighted.SetActive(true);
}```
Also yes SerializeField doesn't make any sense here at all.
And:
private void OnTriggerExit(Collider other)
{
Debug.Log($"Un-Highlighting {highlighted.name} from script attached to {this.name}");
highlighted.SetActive(false);
}```
why doesnt my animation play?
which animation are you expecting to play and what are you doing to make it happen?
the armature_walk
why my tree are pink
Maybe an invalid/missing diffusion profile in the material, something related to subsurface scattering/translucency anyway.
Not a code question though
But it's not because I made the project high 3D, right?
i finally got overwhelmed with coding AI (Game AI) that i bent the knee. I think about something i dont really understand and suggest using a hungarian algorithm to solve it. This is a complete shot in the dark and I highly doubt thats correct. Yet AI tells me its a great idea and tries to implement my super hard problem with something I just casually floated to them. The fact that Sam Altman and these morons have coding AI of all things just agree with the users is so unbelievably dumb. I cannot believe people code this way
I also use AI
I dont understand how people do it. Im gritting my teeth in frustration the whole time
Not even about the AI solutions but the way it relates to you and toxic positivty
He helps me; so far there has been no problem, only with the trees
i dont use ai and i recommend everyone to do the same
I would love a discord room in here specifically for that, because ive hit multiple walls using AI when i lose all hope in fixing something myself. And yet many people say they do entire projects in it. I dont understand how thats possible
One must know what one is asking him
I guess if i was trying to ship some buggy piece of trash then it would work. But if u truly want a mastercraft ud expect from a triple AAA studio i dont know how u could use AI
AAA games are made with hundreds of thousands of dollar at minimum and highly experienced devs, not ai
it doesnt know what it's talking about, just a random guess using stolen data
is there a way to find a game object by name in a scene but not using GameObject.Find
that only works for items that are currently active in the scene
i cant use Find.GameObjectsByTag(s) since the game objects already have a tag that allow me to interact with them
ive been trying to figure this out because every time the player goes to a new area, this script would then lose the reference, so i need them to regain the reference when i reenter the scene
finding by name is not efficient and not good architecture in general
Maybe if you explain your situation in more detail a better approach can be suggested
For example what do you mean by "the player goes to a new area"? And what script is this that is "losing tje reference"? Scripts don't just randomly "lose" references.
is the red thing on the bottom normal?
just begining to use unity
the "red thing" on the bottom is the same error you're seeing there in the console window. Now it's not "normal" but it's probably relatively harmless, though I would encourage you to upgrade to the latest version of 2022.3 to get all the latest bug fixes etc
how to update?
unity hub
and the package manager for the package updates
found a solution to do it like once per scene change but ive discovered a new problem
basically this is a game object that does not get destroyed on load, a sort of master script that tracks the player's overall progress
my new problem is that i dont know how to get it to keep track of the player's last position in a specific area
for example, lets say this is sort of a hub location and they press on statues to leave
i wanted it so that when they did eventually come back to this hub, it would immediately teleport them back to their last location, basically on the same frame they returned
my system was to have it be part of the script that was sending them to other scenes, that it would take the current transform of the player, store it, and then when we got back to the correct scene, it would use that transform's position and relocate the player
unfortunately, this falls apart nearly immediately, because what it does is take the current transform, stores it, and then the moment they get to a new scene it completely voids it
You said you have a script that tracks the player's overall progress. Just store it there
You definitely don't want to store a Transform
i did and it lost the transform
A Transform is a component on a GameObject
i need something else me thinks
as soon as you unload the scene it gets destroyed
Store the position
Vector3 or Vector2
ah okay vector3 then
thank ye 🫡
and the rotation if you wish
It's... it's really hard to do anything in a game engine without Vectors...
im simply very determined
i think i used vector2 a bit back to check how much of an enemy was on screen but its not necessarily my go to i must admit
Anyone know how much it would cost a dev to observe a 40k code base and fix AI from having crap pathfinding. I think I am too mentally cooked. Its been ruining my sleep. Its been making me not go outside
Idk who would want to do game dev but it has to be up there as a horrible hobby/career
this worthless crap is apparently not enough to solve something as seemingly simple as multi agent pathfinding
I told you before, this is a massive undertaking. Proper swarm pathfinding isn't something you're gonna find a line or two and fix. It's the kind of thing that took most of the biggest names in RTS several decades to work out
Starcraft 2 only barely got it right and I'm pretty sure it's still the highest budget RTS game ever made
You might just have to accept a bit of suck, or put in some fail safes like temporarily disabling colliders if they spend too long without going anywhere
simple and multi agent pathfinding do not go together
haha
Hello. I am currently getting the error below, despite me having installed the unity transport package. Would anybody be able to point out what the issue is?
The type or namespace name 'Netcode' does not exist in the namespace 'Unity' (are you missing an assembly reference?)
that's the transport package, not the netcode package. do you have the netcode package installed?
thank you, I do not. It looks like this package is in preview. What are people currently recommending for games using dedicated servers?
what netcode package are you looking at that's in preview? because it's been fully released for a while now
oh... the link that came up on google sent me to an old version (0.0.4-preview), it looks like there is a 6.6 now. My bad 😅
are you using ECS? if not, you should be using Netcode for GameObjects
Ah right, I see ok. Thank you for this information. Not knowing that would have sent me down the wrong path :p
Assuming this is the one you are talking about? https://docs.unity3d.com/Packages/com.unity.netcode.gameobjects@2.11/manual/index.html
okay, thank you so much 🙂
how do I test my multiplayer functionality on another instance? What i've been doing so far is using build profiles and clicking "build and run", but this doesn't support hot reloading and it is also very tedius to manually rebuild it after every small change.
#1390346492019212368
but if you are on a version that supports the package, unity has a Multiplayer Play Mode package that allows you to do that. otherwise there are third party assets like ParrelSync
The manual also has a helpful Testing and debugging section that outlines these options
thanks guys 🙂
!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**
Currently trying to make a movement system with acceleration, and made this Mathf.Lerp function to gradually interpolate the moveSpeed to the maxSpeed/0 by accel/decel. It seems to be working, but the problem is that the acceleration/friction is so fast that even setting the numbers to 0.1, it pretty much accel/decels instantly and acts like there was none in the first place. How can I fix this?
update: setting the numbers super super low gets the accel working but the object still stops instantly. I suspect this is because "direction" goes to 0 instantly when I let go, even if the current moveSpeed isn't 0 it still stops
not quite sure how to fix this though
Lerp is the wrong method for that. Use MoveTowards instead
doesn't this just move the object linearly instead of moving the speed value towards its maximum?
Mathf.MoveTowards, not the vector version
Use it to change the moveSpeed value instead of lerp
thank you! this is a better way of doing things
that said it still stops instantly when I let go of the button - the direction still instantly goes to 0 when I let go, which makes the velocity 0
is there any way to make it so the object gradually decelerates instead of stopping instantly?
Current code.
Deceleration works now, but I'm trying to make it so that moving the opposite direction decelerates to 0, then moves it that way, while what's currently happening is that changing directions is instant
would AddForce be better?
If you let go of the controls, the direction will be 0, 0 so it doesn't matter what the speed value is
If you want to set the velocity manually you'll have to manage everything like this so in that sense using forces would be easier
I've solved that one by saving the old direction before letting go, my current issue is that I'm trying to make it so changing directions doesn't just turn instantly with the same speed
Hi, is this the right place to ask for help with some code problem I'm having?
Yes, as the channel description suggests.
I thought so, just wanted to make sure.
Im having an issue when my player is constantly being set to 0,0,0.
It first happened yesterday morning altering working on it Thursday afternoon time, I saved it and it was all working well, put it on diversion repo, and when I opened it yesterday it was like that, like in the video.
I did a bit of research and supposedly it could have been a problem with the file itself.
So I remade the project yesterday but when I came to it today it was the same as it was.
It's your code of course
Something to consider
Position relatie to z would be locked
I'm like 96% sure it's their scripts and not that
I had checked the code but nothing is setting its locations, im getting a screenshot of it now though
This is also X axis motion based on the videos
Yeah, most definitely
No screenshots please
!code
📃 Large Code Blocks
Use links to services like:
https://pastes.dev/
https://paste.yunohost.org/
https://share.sidia.net/
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.
I had changed this, and its going to be a 2.5D game so thats why z is locked
Oh thanks
The quality is quite terrible but certainly some script is modifying the position of the object.
These are the two scripts attached to the player character
What other components are in your game? Do you have a camera script?
Yea, I'm using cinemacine though so it's not a script. There are 4 scripts for the projectiles with them all being almost the same, I can send them over if that helps?
Wait isn't it pretty clear from your video that it starts working after you remove the Rigidbody?
Doesn't that answer the question directly about what's responsible for it?
Yea, that's right
So that's it then
Yea, i got that, but my character needs rigid body to move, I'm wondering if there's a way to fix it or if i need to use something else for movement
I'm kinda failing to see what needs to be fixed here
After removing the rb component, were there any errors? Show the console window. Something may be referencing the object and moving the object using the rb component.
Why do you need to be able to drag it around by the move tool at runtime? And if you really need to, you can just make it kinematic
There was no errors, but im out of lesson now so I can't get any more screenshots
Because when I remove the rigid body the player cant move, since thats controlling the player movement
Why do you need to remove it
For instance, this would have thrown a missing reference exception if you hadn't disabled it.
Again I'm failing to understand why it matters that you can't drag the object's position in scene view at runtime
Also there were definitely errors, I saw them in the video you just didn't have the console open
Oh, my mistake.
I'm under the assumption that they're illustrating that the object simply cannot be move by any means (as though something is reseting it's position) and had illustrated it through physically dragging the object in the scene view.
I'm only partially here so I may be wrong.
I don't think it was shown that it can't be moved "by any means". Presumably it can be moved by the script.
Yea, thats right, and i have the player controlled with a/d but its not noticeable when doing it that way, which is why I moved it editor
That being said there's actually nothing in your movement script that's actually moving the object aside from the Dashing logic
I think you just forgot to put the main movement code in
The Move function only does two things right now: rotate the character, and dash
Oh and jumping
Also both left and right dash seem to be listening for q
A does nothing
Look at line 100 and 106
Both are doing GetKeyDown "q"
Forgive me, but I dont know how to explain how it works right, but the movement does work, the line float xValue = Input.GetAxis("Horizontal") is what's getting the a/d. And it was working for the movement when I left it, I have it working in other projects too.
Right ok so then it's all working
And yes if you have code setting the velocity to 0 every frame, then yes the Rigidbody is going to force your object to not be able to move externally
And your code is indeed doing that when the input is 0
You basically have the universe's most powerful brakes engaged with that code
Yea, which is the idea for when the player stops moving, and it was working when last played, when I can I'll try send a video how it should work.
"how it should work" is exactly the thing that's missing from your explanation here. Because right now I can't figure out what you're actually expecting this to do that it isn't doing right now
You can probably quickly verify if input is producing your unexpected behavior by simply setting linear velocity to an expected value:```cs
void Movement()
{
float xValue = Input.GetAxis("Horizontal");
Vector3 velocity = rb.linearVelocity;
velocity.x = xValue * playerSpeedHorizontal;
rb.linearVelocity = Vector3.left * playerSpeedHorizontal;//velocity;
}```
Guys, I've been trying to install unity for a friend of mine, but Visual Studio isn't suggesting the keywords.
-
Unity version is 2022.3 LTS
-
Visual Studio version is 2026 (18.5.1)
-
In the unity preferences, the External Script Editor is set as
Visual Studio [18.5.11716](only vesion installed) -
Visual Studio has the Unity module installed (and no other)
We have:
- Reinstalled Visual Studio
- Reinstalled the unity module in Visual Studio
- Read the installing guide and watched a few videos
Is there anything we've missed?
If your IDE isn't providing autocomplete suggestions or underlining errors in red, then it needs to be configured.
If your IDE is not underlining errors in red or autocompleting code,
please configure it using the link below:
• Visual Studio (Installed via Unity Hub)
• Visual Studio (Installed manually)
If you aren't getting Intellisense, you've likely missed a step in the installation process. The common mistake would be missing the Game development with Unity workload during the Visual Studio installation process. You can run the VS installer again to simply add the workload without having to uninstall/reinstall the application. Basically #3 in the installation configuration process (it isn't applied by default thus why folks often miss it - VS IDE isn't solely for development with Unity so the workload isn't selected by default).
hello guys, im trying to simulate a RCS thruster activation on a spaceship. when i press the key to move the ship, the thruster will play and when i release the key, reverse-thruster will be played to simulate auto-stabilization system. yet, in my code, the thruster activation are buggy. i dont know which line are problematic
Buggy in what way?
Shot explanation : I press key w(forward), forward thruster on. After release w key, backward thruster did not play, sometime play. Press s key(backward), backward thruster on. After release s key, forward thruster did not play at all.
Likely because you are reading input/key presses in FixedUpdate (should be done in Update) so some key presses are missed completely
Update: Read inputs and update particle systems
FixedUpdate: Add continuous forces
That's how you should do it
Also:
If the Particle System is already playing, the system continues to play and reset the playback time to 0.
https://docs.unity3d.com/6000.4/Documentation/ScriptReference/ParticleSystem.Play.html
If you continuously call Play if it's already playing, it will reset
Help, how do I recover an unsaved scene? My engine crashed just before I coiuld
there's no _Recovery folder in Assets
I already reopened the engine
You only have a recovery scene until you reopen the editor
If you've already reopened, it's already been cleared
dang okay i didnt even know it was unsaved until i reopened the engine and my progress was gone
any way to stop future crashes?
Don't code in any infinite loops? Hard to tell without knowing what crashed it
I don't even have a single .cs file in this yet 😭 i was setting up UI
!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**
this is why we use version control.
and save frequently
but i guess those 2 are related concepts.
Unfortunately, engine crashes are version-dependent and sometimes even hardware dependent. But like someone else mentioned, it can also be your own fault sometimes if you code an infinite loop (among other things). If you have your debugger active you can always an infinite loop and force execution outside the look though lol (if thats indeed the problem).
You should look into using version control, even if its just you. A GitHub repo that you simply push to will go a long way 🙂
Huhh
read the bot message
Does LookAt() not effect children? I've got a gun and it can rotate fine with LookAt() but the empty firing point child isn't effected by this
the firing point is a child of the gun?
did you ever figure this one out ?
you can use something like rotateTowards/smooth damp, or lerp
What makes you think the child isn't affected?
So I've figured out it's not that actually, I put a sphere on the fire point and it's moving with the gun, so it looks like it's the instantiating, which doesn't make sense to me
Because this should work right?
It will take firing_point.rotation, whatever that is
but the shells aren't moving away from the initial position of the firing point
Sounds like you're probably referencing a prefab or something instead of the actual firing point object in the scene
Either that or the object you instantiated has a script that's moving it unexpectedly
What's supposed to be moving them?
what is the code that moves them
What's going wrong exactly?
Hang on I'll get a clip
The place it spawns? The rotation it spawns at? Or the motion after it spawns?
The gun is rotating but the shells are still spawning from the same place even after rotating the gun
Right that sounds like what I said up here
Whatever object you assigned to firing_point is not the correct one