#💻┃code-beginner
1 messages · Page 479 of 1
what have you tried so far? it should be pretty straightforward if you're storing the lines and their start or end positions in the grid
I have a button Setup for each poin and when pressed it stores a number of 1st point and when clicked on the 2nd it stores the number of second point. This way i store them like Vectors and in the end it checks for what vectors are stored to establish a shape but it seems very over complicated
when the user creates a line, you should just need to check if your start/end points overlap with another line. See if that forms a connection of 3 lines that comes back to the starting point
Sorry to be here YET AGAIN but I still am not figuring out my issue (fixed parts, new errors) so this time I just took a video, I have also been looking up information and trying hard to understand it myself but my confusion comes from I thought I DID assign the game objects as shown in video, I assigned them on the GameManager script inspector.
I can also provide my code if the problem is actually there
sorry for what I am sure is massive beginners issue and for still not figuring it out even when given advice. I really have been trying to follow it I am not sure what I am doing wrong
yea show the !code. also turn off collapse in the console/make sure the errors are cleared before running it again
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 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.
This is from your video
Unassigned references
Is there a reason that, for example, the "Barrel" GameObject has the "GameManager" script on it?
THat seems wrong
you seem to have attached the GameManager script to several objects in the scene
typically a GameManager is a singleton - i.e. only one in the scene
Alright so that shouldn’t be in the inspector on the side of the other objects?
If it's in the inspector, it means you attached it to that object
So you really need to think about which object(s) this script should actually be attached to
and only attach it where it should be attached
So just the GameManager object I made then?
As for the error itself, it's pretty clear
almost certainly..
ah yes i just noticed as well, when you are clicking those errors its highlighting the actual objects that contain the script as well.
why would you attach it to other things?
New, this is just for an assignment and they completely skipped certain info like how to make the game manager object so I thought I had to connect it for it to use the script. Very silly newbie error I see
“Connect it” but now I know I was just adding multiple instances of it
So thank you
Hi! I'm making a PlayerController, but I have noticed some weird behavior. Whenever I hold down both 'w' and 's' it doesn't move (and it shouldn't). The same is true for 'a' and 'd'. But if I am holding down 'a' and 'd' and then hold down fx. 's' which moves it backwards, and then afterwards also hold down 'w' it doesn't stop moving. It still moves backwards. Why is this? Is it a bug in 2022.3.24f1? Or have I missed something?
private void Update()
{
Vector2 input = Vector2.zero;
if (Input.GetKey(KeyCode.W))
{
// Move up
input += new Vector2(0, 1);
Debug.Log("up");
}
if (Input.GetKey(KeyCode.A))
{
// Move left
input += new Vector2(-1, 0);
}
if (Input.GetKey(KeyCode.S))
{
// Move down
input += new Vector2(0, -1);
Debug.Log("down");
}
if (Input.GetKey(KeyCode.D))
{
// Move right
input += new Vector2(1, 0);
}
// Vector2(x, y)
// Vector3(x, y, 0)
//Debug.Log(input);
transform.Translate(new Vector3(input.x, 0, input.y) * moveSpeed * Time.deltaTime);
}```
Go through your code line by line as if you're executing it with the conditions that you mentioned. What value would input have?
Ah, maybe I misunderstood what you mean.
Thank you for your answer. I have just tried that, but I still don't understand what the issue is. It works when I'm not holding down 'a' and 'd'
In the end you press all the keys and it still moves?
Ok. Start with debugging what's going on. Debug the pressed keys.
Alright. The if statement that checks 's' is not executed when 'w' + ('a' or 'd') is pressed and vice versa
Is it possible to return multiple values like int and string from one function?
There's a chance that your hardware or os is limiting the number of processed keys at once.
You can make a "helper class" that contains multiple values, and then return the class
Wow, okay
Try doing the same thing in a notepad and see if all 4 are printed.
In a notepad it spams the last key that I pressed
I'm trying to think of a game where I can test it
yes, use a tuple
It might be my PC. In the other game I tried, it works the same ;(
Thank you though 🙏
Maybe you just have a shitty keyboard.
Hi there, am i correct that gameobject are positioned in reference to the center of the screen but mouse positions are based on the lower left corner of the game screen?
That's typically the limiting factor
Thank you. I am on a laptop with a built-in keyboard, so probably. I'll try it with another keyboard
gameobjcts are positioned in reference to the scene origin. Nothing to do with the screen.
In 2d games it might happen to be the same point if you position your camera in a certain way
Hmm okay, im guessing you can change the scene origin point?
No. Scene origin point is at 0,0,0. You can change your objects relative to it of course.
Oof okay. Guesd that makes things more complicated. Im trying to get the angle of my player characters "eyes" and the mouse position. But both use different origin points so its gonna be tough
Yup! That fixed it
That sucks, honestly. I would expect better of a 3k laptop. Well, well, well
laptops always have to make compromises due to size
should not be a problem using ScreenToWorldPoint for the mousePosition
Okay thanks for the help ill check it out
have someone made a nice way to call static methods in unityevents before?
if I have a static class, and a static int variable inside that class, and If i modify that variable during runtime, would the value be changed back to default when I run the game or it will automatically save? do i need to handle the saving myself?
public static class SaveSlotStaticManager
{
public static int currentSaveSlotId = 1;
}
It would reset
alright, thanks
easysave saved me all the troubles about any persistent data, I had a working save system before that I wrote for a week and easysave is a ton better than mine 
would reset, you would need to save it into persistient data or to playerprefs manually
following a yt tutorial to make flappy bird, and the text is the same as the video except im not getting the dropdown for variables, his code also looks more colourful than mine
any ideas whats wrong?
configure your !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
you will see intellisense, syntax highlighting, and errors appear in your code . . .
thankyou 🙂
most likely a hardware limitation of your keyboard
Why it doesnt recognize Im clicking E and nothing happens idk why it should open up menu, this is code its small so I screenshoted
how did you verify that OnTriggerStay actually runs
also the second one should be inside an If else statement no If, because just incase the second one could run
because my interactInfo appears
Not sure why its not recognizing vector3 in transform
here but this doesnt fix it
well did you check the first thing I said , the log
what is vector3
check the Unity docs for vector3 . . .
smth looks fishy about it . . .
@rich adder i did here
Should be the X axis here,,,
did you go to the Unity docs page for vector3?
put a log inside the if statement
You need to configure your IDE
!ide
If your IDE is not autocompleting code
or underlining errors, please configure it.
Select one:
•
Visual Studio (Installed via Unity Hub)
•
Visual Studio (Installed manually)
•
VS Code
•
JetBrains Rider
• :question: Other/None
Hello guys, i dont know if this is a good channel to ask this i just legit joined but i am looking for some guidance in terms of creating a simple "turned based game". I am wondering if i could dm someone with a prototype of the game that i have done like years ago (its the interface and concept art of it in photoshop) in order to know if what i done there can be done in Unity and if its worth to do it in Unity or if i should maybe do it in any other language or engine.
Thank you.
Unity can make any kind of game you can imagine.
ive configured it, and am using vector2 the same way in another script for the level
according to that latest screenshot, you certainly have not
no way you are
It would not say this if it was configured
Its not vector3 its Vector3?
we all know that but we wanted them to find out why and configure the tools so it tells them
im a idiot
oh mb.
it works but only if Im moving inside of trigger and I cannot exit it, its weird and buggy but it shouldnt be
NOOOOO! 😱
btw it would've been obvious what you needed, had you looked up the Vector3 documentation like RandomUnityInvader said
https://docs.unity3d.com/ScriptReference/Vector3.html
you have only done one step
there are many steps
follow them all
that's only part of it. did you finish the rest of the setup?
I worked one few projects which was the same game i wanna work in, but the game was extremely old and had an old interface, i had the job to upgrade the old interface and add a modern element to it so i just had done the concept art of it in Photoshop, but i guess the programmers were too lazy to do it or couldn't, so they ditched it. Then i also had another project with another name where the leader used Unity, but he still used the old interface and stuff.
Basically my dream concept art for the game was not done and i decided to try to make it into reality, wondering if i could do it using Unity and if its worth it. I don't expect to make this game playable but mostly to just learn programming/coding, and since the only way i think i will have fun learning is to create a game and maybe a project i always wanted to do. What would be your advice if possible?
was looking at this page having a brain fart moment
put keyInput inside triggers is never a good idea although onTriggerStay should be ok but maybe KeyDown not GetKey (somewhat)
wondering if i could do it using Unity and if its worth it
Yes as I mentioned, you can make any game you want in Unity. As with any game engine you will have to learn it first. Unity is one of the easiest game engines to learn while also being one of the most powerful and flexible.
then how should I handle it
always search the "Scripting API" for code related stuff
click on Scripting API to the left of the search bar (where you typed "vector3") . . .
you typically make a bool for them inside Update you capture them then use it inside OnTriggerStay as you need
bool useKeyHeld;
private void Update()
{
useKeyHeld = Input.GetKey(KeyCode.E);
}
void ontriggerstay()
{
if (useKeyHeld)
{
//watever
}
}```
ahh thanks
I see, would it be possible with your permission to send the print screen to your dms of what i wanna do and maybe if possible you could just tell me what i should search for on youtube or something like that to get started? Like i said, this is not a 3D game or an actual card game, its mostly just images from an Anime and then the interface and the functionality of it behind it. I was trying to learn programming tru cs50 course by harvard and then odin project but i got stuck making a mugen game in scratch, decided to ditch it and try to make my dream project from years ago while actually learning how to code, but unsure what language would be the best language since i also dont know if i wanna be a game developer or anything else, so mostly unsure about the programming language i should choose.
btw you can also do something like this
bool isInsideKitchenArea;
private void Update()
{
useKeyHeld = Input.GetKey(KeyCode.E);
if(useKeyheld && isInsideKitchenArea)
{
//do whatever
}
}
void OnTriggerEnter()
{
if (tagCheckForKicthen)
{
isInsideKitchenArea = true;
}
}
void OnTriggerExit()
{
if (tagCheckForKicthen)
{
isInsideKitchenArea = false;
}
}```
You would be better off starting with learning the basics of the engine
before jumping straight into making your specific game
this is true for any engine
For Unity I recommend !learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
However, in general for a turn-based game you'll want to learn about state machines.
since unity's language is c#, is it not worth to learn programming by creating a game in Unity in case i don't actually wanna be a game developer later on, but for example become a software enginner or a web developer? Afraid of choosing a language right now that i might not stick with. I don't have much time
Damn my brain got confused by my own question
Switching programming languages is honestly pretty trivial
Once you learn a language, it won't be more than a day or two to get up to speed
Yeah i get that, but where else do people use the c# language? Other than game development
Just to know my options in case
C# is used for web+software dev too
It's a fully formed, turing-complete programming language. You can use it basically anywhere for anything, like most other programming languages
In the business world, a programming language is basically "Whatever the first guy likes" and there's very little consideration put into any specific reasons
more like "whatever the first guy used 20 years ago"
c# does seem more common than java for the past few years though
yeah C# is pretty decent for almost every purpose but like really high performance stuff and embedded
also the hard part is learning to program, once you do learning new languages is not a big deal
I'm using to make a real life HUD onto hardware from a unity game, and ofc I'm using C# to communictae that data with my C++ controller that controls a screen
didn't microsoft adopt is mostly to overthrow Java's dominance at the time?
There are jokes it's MS Java
So yes
It's not jokes it literally used to be named "Microsoft Java"
Almost everywhere. It's one of the most popular programming languages.
But as others said - once you know one programming language, it becomes very easy to learn a second, and a third, and so on...
How do i add/subtract the Input of an Input field to an Integer or float?
If you just need to check equality, the easiest way would be to call ToString on the number and check if the strings are equal
if you need to do math like a less than operation, you'll need to do int.Parse to turn the string into an int. Note that this will throw an error if the string isn't formatted properly, you might want to use TryParse instead and handle the case where the string is malformed (such as when it's empty)
https://learn.microsoft.com/en-us/dotnet/api/system.int32.parse?view=net-8.0
https://learn.microsoft.com/en-us/dotnet/api/system.int32.tryparse?view=net-8.0
all of them allow negative numbers or allow other characters
It tells you why, it's a method. You dont assign to it, you call the method with the parameters
dont use a = sign with a method
Recently i decided to start making games in unity. I started by watching a tutorial and made a simple flappy bird game. But everytime I try to send my game to a friend of mine it always has lag spikes for him, i tried running it on my pc and it works just fine, i also tried zipping and unzipping to see if it was something with that but no. Note my friends pc is better than mine so theoretically it should be better.
There's not much you can do aside from profiling the game on their PC. Or asking them to profile and send you the profiling data.
ok ty for your response
you might be able to profile a build on yours and look for spikes as well, just might be more extream in their case
does your game happen to be instantiating and destroying lots of objects?
hey, i followed the Instruction for custom controller but in my case the only thing that doesnt work with my custom FPS Controller is that the Input goes to the player while using the GUI.
Does anyone a fix for that?
I tried some ways, but it wont work.
i would appreciate it. 🙏🏼
I profiled it on my pc only spikes where when i paused or alt tabbed but not enough to lag a lot
yeah it does
good chance the spikes are caused by garbage collection, if its constantly the same objects being created and destroyed
look into object pooling
ill see what i can do
there is a big overhead to destroying objects so the idea is instead of destroying it, you just disable it and restore it to its starting settings
Can you share a screenshot of the profiler graph from around the same point in game where it lags for your friend?
i think its constant lag spikes
if(!uiOpen)
//Process input
i still dont understand why on my pc it works just fine?
There could be a million of reasons.
Do they use a laptop? Maybe they have it use the integrated GPU?
no
Well, then you'll have to profile it on their machine to figure it out.
ok ill try sometime when i can
it is possible to profile across a local network btw, so you do not need to have unity on their machine to do so
But might need to use a VPN.
ill try to export it to him
Hi all, I have recently started working with unity and learning through codemonkey tutorial. Can anybody suggest some other resources to learn unity stuff. My focus is towards project based learning
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
Why doesn't freeze position Y come up?
Rigidbody.constraints = ...
is what you actually want
ah okay thanks
what are the apps that people use for sharing code?
github, github gists, pastebin
thanks
some friend of mine offered to help with multiplayer so i want to show him some code
wait i think u missunderstood me, like for exmaple if i have a long code thing to show i cant just post it here i have to go in a website post it then send the link here, to turn the 100 line code into just 1 link
that's what you're wanting to do?
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 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.
yes thank you
yeah i meant smth like this, itsju st a copy and paste no making accounts no actual files or sum
since those websites do the exact same thing as these
oh sorry i just find these alot easier
he suggested pastebin?
option 1: write a repo (probably overkill): https://github.com/cdanek/KaimiraWeightedList
option 2: paste into a gist: https://gist.github.com/cdanek/0093c681f2bf6a75592eb18e5fe71ac1
option 3: pastebin: https://pastebin.com/LKDf3bSy
ye but it says to make an account and stuff, i dont rlly liek doing that
you dont have to, i dont think
oh, sorry im just to slow if its not like 3 buttons to click then it just gets to hard
hastebin for example is just copy paste click copy button boom
ok
pastebin is hastebin but via larger corporation
its not constant tho
when he alt tabbed back it was smooth
do you have anything in your game like loading, scene loading, etc?
and stutters usually happen when something graphically demanding is happening on screen and its creating a bottleneck with you CPU/GPU
no its an extremely simple game
explain "extremely simple"
flappy bird
it should not lag on anything
+his pc is better than mine and on my pc it doesnt lag
Hey, i'm following danis old movement guide and whenever I move my camera up and down my player moves up and down with it? It is hard for me to tell whats going on.
you likely did something wrong when you set up the hierarchy and/or assign object references on your scripts. Or you copied some code incorrectly. Hard to say really.
you seem to be rotating the player
you can place the cursor at the spikes and get more detail about exactly what is taking the time
yeah still a good idea to look at the detail, also vsync can be a bit of a red hering
ok ill see
more or less if things are v synced at say 60hz, and soemthing eats a bunch of time, and causes it to not be able to keep up and say you can only render 58 frames a second
well the vsync will sync to 30hz causing a large spike in its time when its just in response to something else
wouldnt just disabling the vsync solve my problem?
would reduce the scale of the spikes, and make it easier to see the true cause sure
but having no vsync can cause issues as well, like screen tearing as the frame rate exceeds the displays refresh rate which is the problem vsync is designed to solve
mhm ok ill see how it works without
but yeah if you look at the spike the profiler can show the whole break down of where all the CPU time is being used for that frame
one sec my friend is opening it rn
ill share screenshots of it
this is with the vsync graph disabled
@rocky canyon
https://youtu.be/QznVNFlz_jg
somehow this limits the velocity at which the player can move
and it also allows him to go beoyond the max speed
how do they do it
hey there! i'v installed visual studio code and i am following c# courses but i need a workload called Universal Windows Platform Development, anyone knows how to install this when i'v already installed vscode?
i actually made my own quake/halifelife movement system and its almost a 1.1 replica but what i did is apply a force in the opposite direction of movement so if you strafe you could easily go past it, of course you need a max speed for strafing but its the same thing with some multipliers to slow the player down effectively
he probably is doing something similar
since this is what halflife/halflife 2 does
my question is like how do i limit the force from player input without limiting speed
im not really making a strafing/surfing game
cancel/ignore the inputs if thats what you are talking about
Make sure you're not confusing Visual Studio and Visual Studio Code
Is there a way to rename a variable but preserve the inspector reference?
Rider will add this automatically if you use the Rename feature within the IDE.
what are you trying to show me ?
well i cannot see X or Y or see how fast your RB is actually going so i cannot really tell you why its not working.
i should ask How is it not working?
its not limiting the speed
on the ground or in the air?
the speed limiting will only work on the ground since you are using dani's code
thats just how it works
I dont see anything there that actually limits the velocity
well the first thing i see is a ton of nesting
That's definitely some code. That ternary 
wdym
because there isnt
If you want direct control of what the velocity should be, then just assign the velocity to what you want. addForce doesnt apply right away, it happens during the physics step
Then how is this an issue if you know your code doesnt limit it
i cant set or change the velocity
i cant touch that
i want external forces working on the player
as well as limiting the movement speed
also dani's code relies on its own friction so thats also a reason its not working
And what's stopping you from doing this? You dont have to hardcode what the velocity is. You just add or subtract to it and suddenly that works
what are you trying to do exactly
But still, if you're not limiting the velocity I dont see why your problem is the velocity isnt being limited
we joined this conversation late so you have to fill us in so thats why i asked
Simply put, you cant. The rigidbody doesnt store what an "external force" is. You store this yourself if you want to or dont want to limit that
you have to make those forces yourself to act against the RB
it wont just happen
like you think it will
Did you read the last sentence I wrote? Because it really feels like this is going nowhere. I said you cant, meaning only using the velocity from the rb. You have to store it yourself
In which case, you do exactly what I already suggested.
How do i fix this
Download it?
Did you restart vs code?
yea
Use an IDE that will blow up your computer (vs)
did you restart the PC
the pc needs restart for PATH to update properly
yeah i did restart, ima retry tmr was prolly due to my ide being on a different drive to vs code?
ide being on different drive to vscode ?
vscode is ide
yeah im p sure i extracted net sdk in downloads folder which is on a diff drive to my main so that could be it
ment net sdk
just to be clear you should Install dotnet **SDK ** version on C: drive. Shouldn't matter where VSCode is as long as you can get dotnet command running in command line in main OS path
sum like this
will this thing even fit into float
paste it as text
Easy check, immediately log the value. Convert it to a string first because Debug.Log rounds it for visual purposes
spoiler: it doesn't store this exact value
Paste it in here https://www.h-schmidt.net/FloatConverter/IEEE754.html
(in "decimal representation")
nope, not exactly
then... you do
it was for math
the consequences of that really depend on what you're doing
everything is for math in the land of computing
If you really need absolute precision - there's things like https://github.com/AdamWhiteHat/BigDecimal
Absolute precision can be achieved with the decimal type, at the expense of range, values cannot get too high or too low
Enough for their number
yeah i wondered if i can extend limit of bytes for variable
to use as many as i want
Through software, like my link above, yes.
Your computer's hardware is limited to numbers represented with a certain number of bits - usually 64
And possibly up to 128 with some special instructions (which I think is how decimal works?)
decimal takes up 128 bits but only 102 are really used. The mantissa is bigger than other floating point types (96 bits) so you have an accuracy of around 26 decimal digits
void VelocityControl()
{
Vector3 currentVelocity = new Vector3(rb.velocity.x, 0, rb.velocity.z);
if (currentVelocity.magnitude > current_state.speed)
{
Vector3 fixedVelocity = currentVelocity.normalized * current_state.speed;
rb.velocity = new Vector3(fixedVelocity.x, rb.velocity.y, fixedVelocity.z);
}
}
void SurfaceCheck()
{
onSurface = Physics.CheckSphere(surfaceCheckPosition.position, sphereRadius, surfaceLayers);
if (onSurface)
{
rb.drag = surfaceDrag;
}
else
{
rb.drag = airDrag;
}
}
Your player also needs to have a 0 friction physics material, and some sort of Ground and Air drag like here
if (onSurface)
{
moveDirection = orientation.forward * verInput + orientation.right * hozInput;
rb.AddForce(moveDirection.normalized * current_state.speed * 10f * rb.mass, ForceMode.Force);
}
else
{
moveDirection = orientation.forward * verInput + orientation.right * hozInput;
rb.AddForce(moveDirection.normalized * current_state.speed * 10f * rb.mass * airMultiplier, ForceMode.Force); //Times "Air multiplier"
}
And some sort of air multiplier
This is my controller
does it allow external forces?
as in if i add a suffen explosion force to the player
Yes, its AddForce based and not Direct velocity manipulation
alright thanks so much man
i’ll try it in the morning because im going to bed now
i’ll let you know if it works
Yes please, I would like to help you implementing it when youre ready
Also importantly, decimal stores numbers in decimal format instead of binary like double and float. So fractions like 0.1 will be represented exactly, instead of an approximation like in binary.
one more question though
your setting the velocity once hes above the speed limit
so your directly changing the velocity
Thats true, but Ive used this system for a very long time, including in explosions, and it doesnt seem to cause any issues
You can also put that into a bool, so when the bomb explodes you can turn off that speed control if it does cause issues
i mean true
i mean if i dont figure it out tommorow then im probably going to stick with that
Yeah, Rigidbody controllers are a massive pain
Just saying, that code above doesnt account for what you were describing some time ago. As I said before, there is no "external forces" stored on a rigidbody. everything is an external force. The rb just stores the current velocity, which may have been a combination of a bunch of forces applied
There's actually a huge caveat to this - and kind of "best kept secret" about Rigidbody...
Rigidbody has this: https://docs.unity3d.com/ScriptReference/Rigidbody.GetAccumulatedForce.html
Which tells you the sum of all the AddForce calls up to this point which haven't been applied in the Physics Simulation yet.
You can calculate what the new velocity will be with this
I'm not sure that applies to their problem. What I understood was they wanted to limit the speed from a players input but not like explosions
Well it can help with tracking such forces
In case you didn't get an answer, it is vsync and it acts very abnormally. To be honest the whole capture looks very abnormal. The game execution itself barely takes any time.
Even that method just returns a single vector3 of the force. Theres no difference if it came from 1 script used for movement or another knockback script. Im not entirely sure if I understood their problem but I dont think itd work because theres no information about where forces came from. I do think it's just solvable by keeping track of the external stuff themselves instead of having other scripts addForce directly to the rigidbody.
And then another thing to consider would be how long to apply those forces for
Well usually I think of "external forces" as "things bumping into the object" which is different from forces caused by AddForce, and don't show up in that method. It's true if you have two categories of forces added with AddForce and you want to isolate one or the other, you'll need to track them yourself.
As for "how long" - it doesn't matter too much, you would just do the tracking and compensation each physics frame.
Ah I didnt consider the actual collisions
i was explaining to him earlier that I would project the would-be velocity of my movement before adding the rest of the forces.. then he could just limit his movement forces.. i wasn't even aware that rigidbody even had this 👍
im talking like adding sudden force to the player
to launch him to the side
Letting the cat out of the bag - I use this extensively for the speed limits feature of my asset https://www.youtube.com/watch?v=dRtHHhhKUn4
ohhhh... thats YOURs
yep!
lmao
i tested my implementation earlier.. and it works.. just projecting the would-be velocity of the player movement.. and then adding any other movement later in the loop.. (i added a THRUST FORWARD) mechanic
works great
can only move 10 units/sec with WASD but can boost up to 30 or 40 if u hit the boost button enough lol (while having the movment only contribute 10)
ya, ive told u how to do it before.. but not 1:1 ofc cuz i dont know ur mechanics
vector projection. Vector3.ProjectOnPlane(...)
well thats one way cs void ApplyMovement(Vector2 input) { // redacted til bug sorted } i did this route
may not work in all use-cases tho.. ive only tested it in a straight line lol
ohh yea this is probably better.. b/c just noticed my gravity does affect it
might not work well while turning
im not sure tho
i’ll check
could also be true.. hold im testing the projection onto the plane (before my limiter)
that may be still fine
nope, theres a bug in mine somewhere
lol
how do i get an array/list of every Game Object with a certain component in a scene?
does anyone know why this comes up as a list instead of an empty array?
thats not coming up as a list
You can use findobjectsoftype. Though it's a pretty heavy thing, so might want to reconsider.
but when i made na empty array before it would have the black spaces open like this
thats an array, also you do not see 6 because you serialized it when it was 0, now you put 6 in the script. The original serialized value of 0 is there, you can right click script also and do reset .
thats becasue you assigned 6 slots to it
i c
or just type the number 6
lol.. rekt
or just reset the script lol
i see so the 6 i wrote in the code just doesn't do anything?
yes and no
not if the value serialized was originally 0
if you do that before adding the script to your gameobject, then it does something
.. unity quirks
if you right click it and hit reset then initilizer values will refresh
pro-move ^.. until its a pro-disaster lol
but this will reset everything else so use caution
Hi, I need help with my apple picker. the candy corn won't disappear after touching the edge collide. I input the proper codes but it sill won't disappear.
!ide
If your IDE is not autocompleting code
or underlining errors, please configure it.
Select one:
•
Visual Studio (Installed via Unity Hub)
•
Visual Studio (Installed manually)
•
VS Code
•
JetBrains Rider
• :question: Other/None
The code looks invalid?
Ohh
if code can't compile, its not going to run your latest changes or at all
dont just guess the code, try using proper C# syntax, and configure your IDE like said
You've likely missed a step during the installation (common misstep would be the missing Unity workload). A configured IDE is necessary to acquire help on this server. It'll help you prevent writing invalid code by providing suggestions and auto-completes.
Okay, thank yous
Running the installer again would allow you to configure the Visual Studio ide - it will not reinstall the entire app (no point as well).
Also once it's configured https://unity.huh.how/physics-messages/collision-messages-2d
Hey sorry to bug yall, is this the place to get some pointers on a problem I'm having with my code?
!ask
:thinking: Asking Questions
:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #🔎┃find-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.
-# For more posting guidelines, go to #854851968446365696
but in short yes, please ask
Lol man completely missed that .
So short version, I'm trying to make a top down, 3d game that uses mouse input to control the direction the player faces, but the wasd keys to control the movement(Where W would move the player in the direction of the mouse). So far(With some tutorial code) I've been able to get the movement to work the way I want, and the player to rotate direction with the mouse, but the camera(Despite being a child of my players GameObject) won't follow the player when i have the code that moves the player forward.
Hierarchy of the player object is as follows
GameObject with various scripts
-Mesh, animations etc from blender
-Camera
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.
Oh and I forgot to mention, the only way I could get the player to move forwards correctly was to include the line
if (Input.GetKey("w"))
{
transform.position += transform.forward * 5 * Time.deltaTime;
}
in the camera script
which seems janky as fuck
i would move the camera independantly with the player like
camera.position = Player.position + vector3(0 , 0 , 0)//some offset if needed;
and keep in mind moving the transform of the player will ignore collisions
hmmmm I defintely don't want to lose collisions. Is there a better way to get the character to move(Specifically in the direction it's facing)?
I went with transform.position cuz it was the only thing I could hack together that worked lol
well what i do is have an "orientation" object on my PlayerOBJ which rotates and use that transform to either apply a force if using RB or use Move() if you are using a character controller
both respect collisions
you can also directly set velocity or a RB as well which also respects collisions
Will do some digging to decide the best way to move forward, appreciate the help!
{
Debug.Log("Test");
if (collision.CompareTag("Bullet"))
{
Destroy(this.gameObject);
}
}```
Very confused why this isnt working when the object tagged Bullet enters nothing happens but the Debug
then it doesnt have the Bullet tag
did you make sure the thing your colliding with actually has that?
Yes the bullet object has the tag
can you show that?
The debug is outside the compare tag check, it's not detecting any triggers.
Presumably, you're missing something such as a rigibody2D, or setting the collider to be a trigger, etc.
The debug works but the if statement isnt the bullet is tagged with Bullet which is shown in the screenshot bullet has a box collider and is a trigger and the enemy has a box collider and a rigidbody
wait is this script on the bullet?
no it is on the enemy the bullet only has a moveforward script
have you considered printing what was hit as well as its tag instead of just "Test"?
Hi! I am making a very basic open world 3d car game and right now I am working on a speedometer. I have a TMPro text on th canvas and I made up my own code to get it to constantly display my rb.velocity but my problem is that it has a lot of decimal places and I will like to round it to the nearest integer. I found out about Mathf.Round and looked up the doc for it and tried to implement it but it makes no change to my speedometer readings. Can someone help me please?
I have the rigidbody movement code in Fixed update (I left that part out because it is unrelated and not connected to this code at all) and part of the speedometer code in regular update. Is this correct?
void FixedUpdate()
{
currentSpeed = rb.velocity.magnitude;
}
void Update()
{
Mathf.Round(currentSpeed);
speedometer.text = (currentSpeed + " mph");
}
I have the debug there to make sure its actually detecting the trigger and it is
right but that doesn't actually provide useful info. but you can print that useful info instead
you can get rid of the decimals by using .ToString
Where do I put the .ToString?
The info is useful its telling me that the trigger is working which is all I need it for
where you set the text
currentSpeed.ToString() + " mph"
Spend less time resisting help and just do the thing that will help people help you.
Knowing what you're hitting is exactly how you debug your issue.
but it isn't useful because you don't know why the comparetag isn't working but printing that information will make it obvious why it isn't working
doesnt really tell you its working, since it works with some random object instead of your Bullet
Dont you have to specify the format in ToString as well?
yeah
well you dont "have" to
but for this case you should
Thank you 👍
That isnt my issue im failing to understand why it would help the bullet is the only trigger in the scene so it cant be a random object and the trigger of the bullet is running the Debug but it isnt running the if statement that means something is wrong with the compare tag which I dont know what is wrong with it
Okay, good luck then.
@deft grail @solemn summit hmm it still displays many decimals
Am I on my own for this one lol
add a "F0" i think inside the ()
Certaintly not getting help from me, I don't waste time with people who are resistent to help. Hopefully someone else here is willing to suffer through it.
Im sorry how am I resisting help?
Again, not wasting time. No need to respond/ping me further, thanks.
send a screenshot of the Debug.Log stating the object you hit
Now unity gives this error even though MS visual studios shows no syntax errors
This guy is confusing me 🤦♂️
uhh show how you did it?
Did you put it in quotes? "F0"
void Update()
{
speedometer.text = (currentSpeed.ToString(F0) + " mph");
}
whats confusing? change your debug.log to output the thing you collided with and screenshot it
#💻┃code-beginner message
thats not what i said
Not you. Osteel is sorry my bad
oh quotation marks too? Sorry I was confused
yes
oh nvm I lied visual studio shows a syntax error too 😂 my bad
you insisted on not printing out useful information which is literally how you debug this issue. so you were literally resisting the help being offered by not doing the one thing you need to do to figure out why this is not working the way you expect it to
I closed visual studio before it had time to display the error 😂 too impatient I guess
@deft grail yes it works now, only shows integers. Thank you very much
I apologize im confused what is the info gonna tell me I dont understand.
just do it...
My guy. Please, I am on my knees, pleading, begging. Do what they're asking of you. This is an important lesson in debugging.
if you print what was hit and the tag of the object that was hit, then you'll see exactly why the compare tag call isn't working because you will see what was hit and its tag instead of making assumptions about what was hit because of how you think things are set up
How would I log that?
Im really not trying to be difficult or anything like that I genuinly dont understand
with Debug.Log and using the Collider2D provided as a parameter for the method you will be calling that inside of
Debug.Log(collision.gameObject + ": " + collision.gameObject.tag);
Insert 'firmly grasp it' gif
or even better: Debug.Log($"{name} overlapped {collision.name} with tag '{collision.tag}'");
{
Debug.Log("Test");
if (collision.CompareTag("Bullet"))
{
Destroy(this.gameObject);
}
Debug.Log(collision.gameObject + ": " + collision.gameObject.tag);
}
}```
Alright did that this is what it gives me
copy my log and use that
can you screenshot this code in your IDE as well
Will do
i'm betting there's whitespace in it
yep, your tag has whitespace in it
Got it
boxfriend big brainin' it over here
'Bullet ' != 'Bullet'
Thank you guys a lot I wasnt trying to be difficult or anything I honestly wasnt understanding. you guys are awesome that fixed it I really appreciate it!
Hi people, if you can help me with this code, it's because it can't climb or stop, it just walks.
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 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.
Okay, can you help me now?
You still didn't do it according to the bot
!screenshots
No
Be mindful, if someone requests your code as text, don't send a screenshot!
I don't have nitro to send a lot of text
https://gdl.space/ewaqevadad.cpp mmmm like this?
Have you already tested the code?
Have you seen how the NPC behaves?
nah dude there is not enough info here
sart debugging
I wanted to make the NPC able to climb but he doesn't climb or stop, he just walks without stopping
have you confirmed whether OnTriggerEnter is being called or not?
i'm going to go ahead and guess right now that it isn't considering you're moving this object via its transform rather than with something that would ensure that would be called like a Rigidbody or CharacterController
is that all that is in setbool all the parameters have the setbool
huh?
you don't need to be in debug mode
only my npc has rigid body
if it has a rigidbody on it, then why are you moving it via the transform?
even still though, have you bothered making sure that OnTriggerEnter is actually being called?
That's to put it right because it's not going in the direction from where it is.
i have no idea what you mean by that
this does not answer the question i asked
does anyone know how i can attach an audio source to the script component of an uninstantiated object? its saying theres a type mismatch but im not solve how to solve that
that is an AudioClip not an AudioSource. an AudioSource is the component that plays an AudioClip (the sound asset)
oh that makes sense
this works in play mode but doesnt in build code: https://hatebin.com/ujqiymfqis
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 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.
and have you checked the log files for any errors? can you also be more specific about the actual issue like i asked instead of just dropping the exact same video
how do i check logs in players?
!logs
click the documentation link ☝️
It can't be that he's that st*pid...
this is the only error
I think the game is going to be cancelled, another game is cancelled
that's in the player log?
are you telling me?
obviously not
https://gdl.space/dibofurofi.cpp If you can help me see what the code has that it doesn't do well
have you confirmed whether OnTriggerEnter is actually being called yet?
If you already have the tag on the object and nothing
this sentence makes no sense. you may be using a bad translator service. or if you are not using any translator service, please use one.
...?
whatever that message was supposed to mean though, it still does not answer the question i asked. i did not ask about its tag, i asked if you have confirmed whether the OnTriggerEnter method is actually being called
help please
do you ever plan on actually providing a description of what you think isn't working? those of us who have not been working on your project directly do not have the context needed to know just from your video (half of which was spent just waiting)
when there is only 2 answers to the questions i set the anchorMax of the 0th and the 2nd answer to the 1st and the 3rd answers anchorMax and then when there are 4 questions it should go back to default but it doesnt
Instead of changing it via Code, I suggest you take a look at horizontal Layout, vertical Layout and grid components
I dont actually have time to code it from scratch
yeah layout groups are going to require much less code
Docs?
but i would also like to point out that you are not resetting the anchors on those objects, you are resetting their offsetMin and offsetMax
although rereading the information that may not be the issue so you can probably ignore that
Why does it work in editor but not in the player though?
!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
please do not post random files here
this is a file for beginner code - guess its wrong place to post then?
It is only for Unity development of games
you posted a file with no explanation of what or why, so yes this is the wrong place. #1180170818983051344 would be more suitable
you dont think I could post a virus with the same name?
Noice
Hi, does anyone have an idea/experience for integrating a 3D avatar into a mobile app?
This is the beginner coding channel, you should perhaps ask in a more appropriate channel. Like #💻┃unity-talk #📱┃mobile or whatever would fit the criteria.
Alright thanks
hey, i was thinking that i could save some resources by only rendering the objects that are in the player's camera view so i did that and it works pretty well, but if i get too close to an object, it also disables its renderer, does anyone know if i did something wrong in my code?
this is the script that i apply to all the objects in my scene
void Start()
{
camera = Camera.main;
renderer = GetComponent<MeshRenderer>();
bounds = GetComponent<Collider>().bounds;
}
void Update()
{
if (!renderer) return;
cameraFrustum = GeometryUtility.CalculateFrustumPlanes(camera);
if (GeometryUtility.TestPlanesAABB(cameraFrustum, bounds))
{
renderer.enabled = true;
} else {
renderer.enabled = false;
}
}
what you've described is called frustum culling. and unity already includes it
so the thing im trying to do is useless?
yes because unity already does it for you
All that does is add extra overhead and a source of potential bugs
alright, im not going to use the code anymore. thanks for telling me guys
I can't seem to figure out why my enemies are invisible. Can someone help me out? (They were visible before I made the enemy spawner)
Check that they don't spawn behind the camera
What do you mean behind the camera?
I mean that if they're behind the camera then the camera won't see them and they won't be rendered
How do I check if they are behind the camera?
What's the Y position of the enemies when they spawn, and what's the Y position of the camera and an object that is visible?
Or pause the game, go to scene view, turn on 3d mode and see where they are
Is it because the enemy spawners y position is minus?
What's the Y position of the camera? ¯_(ツ)_/¯
It was 1! Thanks
I didn't know I could go to 3d mode in 2d
😅
click here
why my quad object won't render the image i imported?
nvm im dumb. the image actually shown but it facing the wall 💀
help please
you might like to post a translation of the error messahe, not everyone can read Russian
it says that animator does not contain such a definition
like this
this is strange because I don't have a class called animator
I am trying to make some colliders on an isometric grid. The colliders seem messed up and curved, not like a grid at all.
show the screenshot
I think I understand
Sorry if I should be adding more detail to my first message, I haven't really posted here before.
I clicked on this class in the ad and this opened up for me
So you DO have a class called Animator
there is no script in the files with the name animator, but for some reason the file name is glow animator, while in the script it is simply called animator
I did not ask you if there was a file called Animator, I asked about a class. That restriction has been lifted in latest versions of Unity
as it turned out, there really is a class. In any case, thanks for the help, I think I understand what to do next
anyone know what to do im following tutorial and they dont got this
These samples probably require you to install some packages or enable certain settings. Did you go over the installation instructions?
No.
Where did you get these samples?
can we vc u mute so i can screen share
There should be a readme or some info at least.
No.
i got them in
You can share a screenshot
ok well
Or record and share a video here.
how do i see my samples?
com.unity.xr.interaction.toolkit thats something i put in in the plug in things
You have samples folder in the assets. They're not something included in unity by default.
how do i see them then
You can see them in your assets folder. I'm asking where is that samples folder from?
im starting a new thing so i can restart without the errors
about to make a ground check (3d not 2d if that matters) with the tried and true "just a raycast down", was wondering if anyone had any ideas for something more or is this truly is the end all be all?
either that or a SphereCast/OverlapSphere . . .
Depends on your requirements
It's a pretty good way..what prompted the question, is it not meeting your needs?
I mean I can assume it's the best way for me to do it or I can ask more knowledgeable people if my assumption is wrong
call it curiosity or just learning
"the best way to do" something always depends on the something you're trying to do. Every game has different needs
The shape and movement style of your character is a huge factor
A simple Raycast down wouldn't cut it for a complicated worm shaped character for example.
that does make sense, I was kinda just gonna make an all purpose component that I can put on anything that needs a ground check.
that will be far from efficient in all cases
so I just make a new ground check whenever I need one?
yes, or copy and change. There is no 'one size fits all' as @wintry quarry said
i have a problem, a code helper did made this changes for like coyote timer and the buffer jump
"Jump buffers are when you press jump before you land but because you haven't touched the ground you don't jump, the buffers fixes that it saves the jump in for a short period letting u jump so its less frustrating,
Same with coyote time that lets u jump after u walked off a platform, like a small window of opportunity"
that is what someone said, but however ever since those things were added, the jumping mechanic haven't been working properly that instead i jump higher instead of normal and i just jump normal instead of higher in my jumping frog power-up, you even jump on the walls. i don't know why since someone did made the coyote timer and buffer timer
https://gdl.space/tupijoxuxa.cs
That is a lot of code with not one single Debug.Log statement in it. So how do you know what it is doing?
https://gdl.space/dowalixowe.cs then i choose out of the things that have to do with jumping from the script
you miss my point.
You have no idea if any of the code is being executed
You do not know what paths are being taken through the code
You do not know the affect that your variables have on the output
In the below, I want there to be a short delay before myRigidbody.useGravity = true; comes into effect. What would be a good way to do that?
private void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.tag == "Player")
{
GetComponent<MeshRenderer>().material.color = Color.red;
myRigidbody.useGravity = true;
}
else
{
myRigidbody.useGravity = false;
}
}
Coroutine
i did say that someone made this whole coyotetimer and buffertimer code adding in. even though everything works barely, it's just that the jumping frog and the normal jumping are just switched
I mean feel free to do so if you find it helpful.
Just because it doesn't solve all cases doesn't mean it won't solve most of yours

How do I solve this problem. I solved it once but completely forgot how. I'm not sure if there was a command for it or not
that definitely sounds hard to solve . . .
I don't think I can send photos
It's the .Net Core SDK not being found so it doesn't show any problems with my code but in Unity I have a problem
if you solved it once then google it
I solved it through one of these discords
did some debugging and seems like the jump and doublejump does at the same time, the same for the jumping frog the charge, jump and doublejump at the same time. even though it still looks like they both have switched roles
why does my fps controller player keep falling through my terrain? i tried adding multiple colliders to both but nothing works, it also falls through a plane
Without seeing any details about your setup...
¯_(ツ)_/¯
alr one sec
You would have to show us how its set up, the code, etc.
i got these 2
and this the script i used
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 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 don't see anything odd about the script from the tutorial, o the question is:
- Did you change anything, or not copy something correctly?
- Do you have other scripts
- Is your terrain weird somehow
its the same as the website tho so
it is a terrain from an asset to maybe it has to do something with that, that maybe i didnt use it the right way
certainly don't add any other colliders
the only collider is the terrain collider on the terrain itself
i removed the capsule collider from the player
what is on the "Player" object ?
Can you show Edit -> Project Settings -> Physics and show the layer interaction matrix?
you mean this?
I'm not seeing anything wrong
Can you try with a basic/empty terrain and see hwat happens?
Thanks! The script is on every tile on this chess board. The player moves 1 tile at a time and currently every tile is gonna fall OnCollision. Any idea how I would make it random which tile is gonna fall? I'm thinking 30% chance.
Script again:
private void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.tag == "Player")
{
GetComponent<MeshRenderer>().material.color = Color.red;
myRigidbody.useGravity = true;
}
else
{
myRigidbody.useGravity = false;
}
}
if (Random.value < 0.3f) Fall();```
Oddly, I see no Coroutine usage there
you can also use if (Random.Range(0,3) == 0) { }
perfect
the player also falls through the basic terrain
Can you show the scene, with the collider gizmos visible?
is the player starting above the terrain?
Thats the capsule but cant see the actual collider it should be a green wireframe
you should send a pic that looks like that
@rustic maple
and make sure is enabled
my capsule doenst have a capsule collider becuase the tutorial said i had to remove
I suspect we are about to solve a lot of those player falling through the terrain issues then
It has a CharacterController
which is a capsule shaped collider
And which has a green gizmo just like the one shown in the screenshot above
check underneath the terrain
i bet you'll find it there
It is definitely just misplaced then
I would also highly recommend setting this to "Pivot"
The Center setting can be very confusing and disorienting
pivot shows where the object actually "is"
there are only few specific instances..
Eg Want to rotate a group of objects around a point.. Use Center instead.. but those are very few cases, most times you will use Pivot
my character controller gizmo is not showing green like the picture
show us you have gizmos enabled
so basically what Praetor said lol
thats when i start the game
also if thats the CC it should be on the root object, only GFX should be child
when in edit mode the capsule is on the ground and the character controller is floating in the sky
because your child positioning is off..
reset it
just to be clear the CC should not be on the child
it is on the parent
ok so you clearly have 2 objects
which one is the child then
the "mesh" ? if so it should be ok just reset pos
@dusky nest ⏬
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 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.
it works now!
how do i do this? the script was given to me by the assignment, but the counter integer was added by me as per instructions. i'm not sure if i even added counter correctly.
using UnityEngine;
using System.Collections;
public class Forces : MonoBehaviour
{
int counter = 0;
public float speed;
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
}
void FixedUpdate()
{
float hor = Input.GetAxis("Horizontal");
float ver = Input.GetAxis("Vertical");
Vector3 move = new Vector3(hor, 0.0f, ver);
GetComponent<Rigidbody>().AddForce(move * speed * Time.deltaTime);
counter++;
}
}
also tysm!
first day progress learning unity (all the code is stolen 😂)
well if its only when the ball moves then you should put it only if the velocity is anove a threshold
also Time.deltaTime is wrong on AddForce, we dont add that since addForce already moves the rigidbody with Physics loop. And you're correctly using FixedUpdate so its fine. Just remove Time.deltaTime
how do I start learning C# for unity whenever I find a guide I end up just copying the code without really knowing what it does or how it works
check pins in the channel
Stop just copying it and start reading it and trying to understand it.
the problem with this is you're catapulting yourself right away into some complex stuff, you have to build from the ground up .
well I was inspired by some game I found on roblox and really wanted to recreate it thats why I started
learn how to store a name into a string and print it back, etc
inspirations are great for starting out a field, now that it peeked your interest, start finding out all the necessary lego pieces you need, you will build your own megastructures in no time
Time.deltaTime was created by my instructor so im not sure if i should touch that. i dont know what a threshold is in this sorry. i was thrown into this assignment without much of a tutorial
your instructor is an idiot
yeah he forgot about his online class 😭
not a real teacher, and has no clue how Unity works
I wish freecodecamp had courses for game development, their courses are just amazing for beginning.
and ofc his in-person class is on the further campus
GetComponent in fixed update too... what a leader
big brain moves
i bet didnt even explain what velocity of a rigidbody is and how to use it to calculate a magnitude for speed of movement
which is basically what ur assignments requires
nope 😭 and we're expected to create a game next week
"move the counter value only when its moving"
yours is counting every physics frames even not moving
lmaao
You need the magnitude of you rigidbody, if its above a threshold , start counting
what course would you guys recommend for unity? (preferably free lol)
mate I told you check out the pins lol
particularly do Essentials Pathway and then Junior Programming one
I know but theres like 3 courses and I get distracted with choice
as I said, should do Essentials pathway, then Junior Programmer and then this one https://learn.unity.com/project/beginner-gameplay-scripting
the last link is the one I first learned unity with
they had no pathways when i started :\ consider yourself lucky
alright ill spend today (or however long it takes) working on the essentials pathway
i am talkign with someone who made this coding but i am also waiting for them after the exams to see what is wrong with it
it will be as long as how fast you learn
thanks for the help
goodluck 🫡
i never used unity learn to learn i kinda just winged it, dont do what i did
I did pretty well last time I took a coding course but that was html and css so its not exactly rocket science
its a bad habit 😅
worst part of unity is waiting for a project to load 😭
great now you're using a REAL language
making my ssd feel like a hard drive
mehh stick to c#
if you value your sanity , no reason to ever touch C/C++
embedded system 
I personally dont so i will use it lmao, scratch that I do, i just like C++ for learning game making, etc
its good but very niche usecases atm
its the future! (or at least thats what everybody and their grandmother is saying)
who says that
just like web assembly supposed to replace javascript...yet here we are...
they are a silent one then
not around the right people I guess
Learning C++ would benefit you a lot more than rust imho
I heard more about it when I was big into linux, much less now, so probably just depends what community you're in.
tru dat
dilch knows what he is talking about 
but if ur coming from html/css you're better off just going to c# and not deal with memory management so early on or you will probably quit
yeah C# is way easier than C or C++
c# can pretty much do it all and its easy
but C++ is so so so so fast
but it will make you go insane (if you dont know what you are doing)
irrelevant to unity
The gap is not as big as you might think
yeah true
Code architecture and optimization techniques matter a lot more than the language you're using.
wait till you have to do some c# marshalling to talk to C code

hopefully i wont have to do that 😅
fun times
its a fun little project, try sending some structured C/C++ data to your C# application, you're in for some funsies
but yeah going a bit #offtopic from unity before I get the 👢
My gameobjects enums keep resetting to the first value ? is this a bug , never had this happen before ?
it happens at random times 
and only this specific enum?
Are you overriding the integer value of any of the enum values, or just letting them be the default?
no here is my entire class
https://gdl.space/zoriqusuku.cpp
ChessPieceColors one is fine though
Do you have any third party assets that override the default editor, like Odin Inspector or Naughty Attributes?
none
It's probably an editor script of some sort. Maybe it's a race condition? I wonder if that OnValidate is causing some sort of inversion of order, where something else tries to write the piece type before it actually reads it?
I dont use many assets here but will check, its weird that only that one is basically borked.
that OnValidate was acting strange for me before it wasn't catching GetComponent so it could be something with it. I'll remove it and see what happens without
thats not very modular 😛
that would mean All the pieces still have the same type
i mean you could do
public enum chesstype{
//whatever
}
private enum chesstypes{
//samestuff
}
private void start(){
chesstypes = chesstype;
}
i know its janky
but it may work
not sure I understand
All my pieces need to bet set in inspector as different chesspieces
I think its working now though, I just remade the Enum as something else..I think something got borked in the serialization process..
so far hasn't changed 🤞
well yeah so you have an enum as your "selector" then a private enum and you set the private enum to the "selector" type and just use the private enum for everything in your scripts
if it just started to randomly work then you dont need to do this 😂
Is this text channel where we would ask for help?
Hey does anybody know why my kills/score system doesnt work after resetting the scene?
notice your Score Text refernce goes missing/null
Where?
when you reset the scene this object goess DDOL while still referencing the TMP instance from earlier
!ask
:thinking: Asking Questions
:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #🔎┃find-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.
-# For more posting guidelines, go to #854851968446365696
Keep UI with you on DDOL
make canvas child of the object with DDOL and Score Manager on it
or find it at runtime every scene change
So make canvas the child of GameManager?
New problem😅
Im in Unity3d and I have a rotating obstacle that I want to collide with the player and push them. The obstacle collides properly and pushes the player when it moves slow, but the player phases through the obstacle when it moves fast.
The player and rotating object have colliders and rigid bodies using continuous collision detection, yet faster rotation of the obstacle makes the player phase through it. The obstacle is using rigidbody.moverotation (I used https://docs.unity3d.com/ScriptReference/Rigidbody.MoveRotation.html). The player moves with playerRb.velocity = new Vector3(speed * horizontalInput, 0, speed * verticalInput);
how do you normally hide the retry screen ?
Set the collision detection mode on the rotating object to continuous speculative or whatever it's called
tried that as well
It's already disabled when the game starts
How fast of a rotation are we talking ? There are limits
And there are limits to what the engine can properly compute in terms of rotational collision
oh okay because remember anything in DDOL will not run Start or Awake the time the scene reset, since they are technically still Awake/Start since creation
perhaps you should explicitly hide the retry scene on click
Ok so when the player presses the retry button I should disable the Death screen?
indeed.
ideally you eventually want to have a menu/UI manager of sorts for these 😅
And show the inspector for this object?
Yeah, well that's a bit too advanced for me at this moment
start simple.
for example, just a method that deals with HideRestryScreen() or ToggleRetryScreen(bool value)
Seems fine to me. Perhaps try decreasing your fixed timestep
I'll most likely do that at some point. (If I'm not too lazy to😅 )
you already have a "Score/Game Manager" the concept is the same ( a centralized script that deals with all its related functions/ duties)
The Score system works now but, the bloom effect doesnt affect it after resetting it.
So the score text is no longer glowing or anything
did you also bring with you the post processing / PP Volume
Wait
I feel dumb now😭
DDOL is convenient but tricky too
I am having an issue where my PlayerInputActions. Using the input system is throwing an error.
What have I done wrong?
Yeah... it still doesnt get affected by bloom even tho Global PP is a child object of GameManager
Error code is 'PlayerInputActions': member names cannot be the same as their enclosing typeCS0542
You can't have an action map with the same name as the input object
You have an action map named the same as the asset itself. You cannot do that
is it still enabled after reset scene?
As in one of these needs to be a different name?
Check the action maps in the object
It affects everything, but the score
So I think yes
Yes it's still enabled after the reset
I think its your camera, are you bringing the same camera with you
this is one of the things I deslike about making everything DDOL lol
Now it pretty much works but it says
MissingReferenceException: The variable GameOver of GameManager doesn't exist anymore.
You probably need to reassign the GameOver variable of the 'GameManager' script in the inspector.
GameManager.GameOverScreen () (at Assets/Scripts/GameManager.cs:24)
Enemy.OnCollisionEnter2D (UnityEngine.Collision2D collision) (at Assets/Scripts/Enemy.cs:87)
And both the scripts that the error is about are turning on the death screen
Probably a DDOL object trying to keep a reference to something in the scene, which is destroyed when you reload the scene
Specifically whatever the GameOver variable is referencing
Yeah, but I dont know what
This...
It's referencing a panel to the whole game over screen
Ok, that panel is being destroyed
And then you're trying to use it after it's destroyed
remember anything in the scene that references the DDOL objects will not longer have the same reference when you load (ddol they will go in their own scene called DontDestroyOnLoad)
It's not supposed to get destroyed I've only made it to be disabled
objects get destroyed when switching scene
How can I make things to be in the dont destroy on load
once you make something DDOL if you want anything from another scene to access it, it must be done with something like a Singleton , Or some type of GetComponent/DI
dont start making everything in the DDOL , this is one of the many pitfalls as beginner
learn how to properly get the references when needed
first breakdown, why does a scene object need reference to GameOver display
So they can be restarted?
from where?
your DDOL scripts should be only ones handling it
why does Enemy have it
Enemies should not care about Gameover, or UI or any of that
I don't have a specific ddol script. I have a scenemanager the SceneManager references the death screen to not be destroyed on load
They dont
so which one is turning on the death screen?
Scenemanager
can you show the function Enemy.OnCollisionEnter2D
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.CompareTag("Bullet"))
{
Vector2 knockbackDirection = (transform.position - collision.transform.position).normalized;
rb.AddForce(knockbackDirection * knockbackForce, ForceMode2D.Impulse);
}
if (collision.gameObject.CompareTag("Player") && !isDead)
{
isDead = true;
ParticleSystem playerEffect = Instantiate(playerDeathEffect, transform.position, Quaternion.identity);
Destroy(collision.gameObject);
gameManager.GameOverScreen();
}```
so put scenemanager on the DDOL stack since its a manager
as long its not a scene gameplay object , this is fine for a manager script
if GameManager is ddol script gameManager.GameOverScreen(); is breaking
you're referencing an instance which no longer belongs to that scene
at very least it would be GameManager.Instance.GameOverScreen();
personally though I would opt for an event your enemies invoke, then its up to your game manager how to handle it
GameManager captures all scene enemies on scene load, then subscribes to such event
now your enemies would do their thing without caring about handling game states..
"Instance" gives an error
Severity Code Description Project File Line Suppression State Details
Error (active) CS0117 'GameManager' does not contain a definition for 'Instance' Assembly-CSharp F:\Unity projects and backups\Projects\Shooter Footer Looter\Assets\Scripts\Enemy.cs 87
you realize it was an example right
assuming you were to make GameManager a proper Singleton instance
Oh
What am I supposed to do to fix this??
look at least your ScoreManager has one but its lowercase i
I literally just explained two ways you can fix this lol
what part confuses you
Like the whole thing
anything you link inside the inspector that is now on DDOL will BREAK
including the GameManager
for an open world, how do I differentiate between something walkable and something climbable without tags and layers cuz then it always has to be different objects
do you know why it has instance as static and then assign instance = this

