#💻┃code-beginner
1 messages · Page 655 of 1
aren't the yellow boxes indicating unsaved changes
probably, yeah
no i highlighted the code 58 - 63
as pointed out, the error is pointing to a different line, save your code, recompile, and see if the error still occurs
Like it doesn’t even show it’s baking or that a blue high light is around it. From what I gathered from the tutorial it shouldn’t take less than a minute/few seconds?
great! now you just need to realize that you are looking at the wrong object or the object you are looking at had the array filled in after that method was called
baking that should be incredibly fast. we can also see that the navmesh data was created, did you perhaps disable gizmos?
Possibly, where would I enable them if I did?
Oh, now I feel silly
how long it takes depends on a lot of factors. what you showed should be fairly quick
Yeah I got it now.
I’m planning to use this test game as a base.
I wanna create a horror game with puzzles, clues. Trying to leave a room by finding them and opening prompts.
It’s ambitious since it’s my first game, but I just want to start with making one room for it
Im attempting to make a Player Lobby for readying up for a local couch co-op game, but can only find good tutorials for Hosted Multiplayer and Steam multiplayer, anyone have a good tutorial?
Since there's a nice component system here where I can just tack on features as needed (its modular), should I use long inheritance chains less?
is there a problem if i put a bunch of #region and #endregion in my code? i'm trying to keep stuff organized and being able to toggle out of view the stuff i dont need is nice
why would it be a problem? it doesn't have any runtime effect
it's purely an ide QoL thing
just wanted to make sure lol
It's potentially an indication of putting too many disparate things in a single class/script
well, it's a player character with run, jump, attack and a few other minor things, i dont think i'll be needing to just jump or run or attack so i dont need to separate them
its better than to make code spaghetti like i did in another project where i put every character ability in separate scripts that comunicated with each other
one to move, one to jump, one to wall jump, one to dash, one to ground slam, one to slide on walls...
you get the idea
Sure, I only said "potentially". Not making any judgements here based on no info
hey guys i just started learning unity could you guys help me fix this issue which is i cant make a C# script for some reason :/
MonoBehaviour Script
third option from the top
is it the same ?
yes
oh thx then
also you don't have to make those with a menu command, you can just make the file
well the line numbers don't seem to match the error. Share your !code properly
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 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.
ops seems i didnt scroll down to see the newer messages
hey there in this code the player seems to be having a really wide jump its like theres so little gravity which i dont want, i want the player to jump be in the air for a couple of seconds then fall
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 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.
share code properly
If only a large block of text had appeared mere moments ago with the title "Posting Code" that explained how
is there a unity library thingy that lets me get the angle between two rays?
the simplest answer to your question is to either increase gravity or decrease the "jumpForce"
Vector3.Angle ?
When I plug rays into Vector2.angle it says it doesn't work with rays
.direction on the rays
oh ok
Angle(a.direction, b.direction)
thx
it worked
Should I use character controller or rigidbody for first person player movement
What's the difference between the two
you should use a kinematic controller (like character controller) that does not use simulated physics forces, which is the difference
Why so
because 'realistic' physics are generally not what you want for the behaviour of a player controller
so if you go with the simulation-approach you will be "fighting" the physics to get what you want
But without physics (rigidbody) I have to do a lot of manual work like adding gravity through a function in a script.
Rigidbody seems easier. Just put constraints and I am good to go.
Can I make a custom character controller component
Like written from scratch and not using the existing character controller that comes with unity
yes
active rigidbody character controllers are only easier for about 5 minutes
in 3D projects, unless you need something non-standard (character walking on the ground), you'd use this (free) asset https://assetstore.unity.com/packages/tools/physics/kinematic-character-controller-99131
I want to make a hooking system like of bioshock infinite where we hook on to metal stuff
You have played bioshock infinite? If not just look at youtube
you can get very far with that asset above
it includes an example controller to get you oriented/started
the meat of that asset is the 'motor' which solves pretty much all commone issues with character controllers
hi probably a silly question but i can't figure out how to implement a small delay inside a while loop (I'm trying to make a burst mode for a gun). I've been trying with a corroutine but it goes in a infinite loop, code snippet below: ```void Update()
{
if(!isReady || isShooting || isReloading){
return;
}
else if(mode == fireMode.burst){
if(Input.GetKeyDown(KeyCode.Mouse0)){
while(burstCount>0){
if(!isReady){
continue;
}
shoot();
burstCount--;
if (ammo == 0){
StartCoroutine(Reload());
break;
}
StartCoroutine(RecoverInBurst());//sets isReady flag
}
StartCoroutine(RecoverFromShot());
}
}```
isReady = false;
yield return new WaitForSeconds(recoveryBurstTime);
isReady = true;
}```
you probably want the loop inside the coroutine so you can yield return null; inside of it to wait a frame for each iteration. loops run until their condition is no longer met so it won't allow the frame to end
Once you enter a while loop, nothing else in the program will run until you hit the end of it. continue just means "Check this number again"
How do I make a capsule grapple hook and fly like batman games
So, if burstCount is greater than 0 and isReady is false, literally nothing else will ever happen besides those two values getting checked until the universe ends
time and experience
All that just in first person
Tell me what to do. What function to call or something like that
not how it works
oh i thought the corroutine could still run , thank you i'll go implement the loop inside the IEnum
you have to learn how to know what to do
How do we know what we know how do we know what to do? How do we know Anything at all?
Coroutines run alongside the normal code. That's what makes the "co" routines
I will scroll through some tutorials
There isn't a "GrapplingHook" function. You're going to need to write one, which means you're going to need to actually really understand what a grappling hook does and tackle those problems a little bit at a time
but you just said when in the while loop nothing else would run
Yes, because they still need to be checked to see if their condition is up, and that never happens if the current frame ends. They don't pause the function you started the coroutine from. That function still needs to end in order for the next frame to happen
can i make this texture detailed or is the texture itself too small?
and since the calling function isn't paused, and it isn't ending, the frame can never finish
Show code
this is a code channel.
#🔎┃find-a-channel
theres litt no code for it i just got a pic and pasted it
Then why are you asking in a code help channel
mb jeez
the blur is probably Filter mode on texture
Nav mesh
Howdy folks, Using the starter assets fps controller and trying to make it work friendly with a pause menu, I have a public pause bool public static bool GameIsPaused = false;
inside the start assets input screen I have placed the if paused condition inside of every type of movement, and it does stop the movement in the pause screen. However, as you can see, If i am moving while i pause, when I unpause, it's still moving
(in the video near the end when im quickly pausing and unpausing, I am not pushing the W key)
If you're skipping over input reading when the game is paused, it's probably skipping over the release of the buttons as well
Ah i see what youre saying
Let me double check the pause logic
This is all that happens when the game pauses
Maybe stopping time means the button release isnt registered?
Well, and all the !newpauseLogic.GameIsPaused checks in your input callbacks
Which means that it doesn't read any inputs when the game is paused
which includes releasing of buttons
the release of a value type is provided as an InputValue with the value set to a 0 (for example Vector2.zero for a Get<Vector2>())
Probably don't eat inputs when the game is paused
How else could I disable them?
freeze the output, not the input
receive the input and update the internal state, but don't set that internal state to anything else like moving
Disable the thing that does stuff, not your input reading
I have the script here is that a bad thing?
It's not attached to anything
I'm obviously new to unity and kinda experimenting with what works and doesn't work
Not sure what that has to do with anything
Okay so that doesnt matter okay lol
Just, instead of checking for the pause before reading inputs, you want to check for the pause before doing things with the inputs
doesnt look like a script tho
Pressing W does not move your character. You have code that moves the character when you are pressing W
Instead of having your pause logic say "don't read W", you need it to say "Don't move when you get a W"
So if i put the input script in here and disable it during pause
that should work right?
Oh wait
Disabling a script means it no longer receives unity messages like Update, that might work but it depends on how you've coded it
I think my code works but only in these
My issue is I cannot drag the script thats attached to the gameobject that has the playerinput, into this 'scripttodisable' field
Drag the entire object into the slot
If that object has that script, it will work
okay so yeah that's given me the exact same result.
Surely there is code that actually makes the movement happen, in an update?
what does this mean
No cameras enabled in scene
it means you have no cameras rendering to Display 1
how do i fix that
add a camera I guess
when I added a texture render to my camera it said this, the tutorial I was following literally just said to uncheck the warning if you already have a camera.
Found the code that actually 'makes it happen' not the input, and all is fixed. thanks for the help
It means no cameras are rendering
yeah because now your camera is rendering to the RT not to the display anymore
hence - there are no cameras rendering to the display
ohh I see
Often I've moved the player around and the capsule gets disaligned with the Main Camera. And when I try to move the player it moves either one or the other. Is there a way I can connect the two and have the move and transform together?
If you want to move both objects at the same time you can do CTRL + Click on them to select them both
For some reason when I do that, the moving arrows appear all the way in the sky
You probably are getting confused by the tool handle position setting
Press Z to toggle between Pivot and Center
You'll want it on Pivot
You definitely have it on Center right now
Well there's usually a toolbar thing for it but you seem to have hidden it in your scene view
Press the Tilde key in scene view to access the menu to show it again
Yes you're looking at your canvas
What has this to do with code?
sorry jus realised i sent it in the wrong chat and sent it at shaders
also chill dude i didnt hack the chat
just looking for help
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 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.
Hi all,
https://paste.mod.gg/nrtsxcvntyth/0
I'm creating a clone of Asteroids to help me learn. This is my solution for spawning asteroids randomly around the map, but it's not instantiating the prefabs for some reason. I put debug messages throughout the code to make sure it's actually going through the entire coroutine and not getting caught somewhere, and it is! I've made sure to place the prefabs in the inspector. Is there something simple I'm overlooking?
A tool for sharing your source code with the world!
If I subscribe to an Action with += do I have to call -= to avoid creating garbage/memory leaks if I set the action to null?
so if I did myEvent = null instead of myEvent -= myHandler, would that create garbage/memleaks?
So i'm looking to make some 'jumps' in my horror game, Obviously, I'm going to do alot of triggers when you hit certain trigger colliders, Whats the best way to have something happen only once, I'm assuming just use a bool variable?
No, setting the delegate to null with dereference all the handlers and garbage collect them.
or:
void OnTriggerEnter(Collider other)
{
// Do Something
}
https://docs.unity3d.com/6000.0/Documentation/ScriptReference/Collider.OnTriggerEnter.html
Yeah i get that I was just wondering the best way to make something happen once
Just did it with a bool
private void OnTriggerEnter(Collider collision)
{
if (!happened1)
audiosource.Play();
happened1 = true;
}
Also does anybody know if the starterassets first person controller has footsteps? I had footsteps working but seemingly the option has vanish so i'm kinda lost
it used to afaik but I haven't touched them in a year or so
Does anyone know why my changed states and transitions keep being deleted and reverting back to original states after I ctrl+s? I am using a free asset from itch.io
where is the code question ?
this is the original animator that it keeps reverting back to
thank you. ill use that for future problems. turns out my problem stems from using aseperite imports.
Howdy! I'm trying to make a simple walking sound script. I have a long walking sound that goes on for like minutes, I want it to start whenever i'm holding W, A, S or d, and to stop when I let go. Someone suggested using a timer but I find that kinda confusing as i'm new right now.
void Update()
{
if (Input.GetKeyDown("w"))
{
footstepsound.Play();
}
else
if (Input.GetKeyUp("w"))
{
footstepsound.Pause();
}
}
}
Issue with this is, I think is keydown is going to keep going whilke I hold w
Actually it doesn't even play the sound at all
Oh wait so it should work in theory?
I would recommend using the keycodes though
check your console for errors
Sweet this works
I figured this out. Instantiate can't take screen space. Using ScreenToWorldPoint to convert the screen.width & screen.height fixed it.
What site do you guys use to share code again
I have a slightly longest script thats abit much to paste here
!paste
/paste
i have a script that detects collision with another capsule, i have tried OnCollisionEnter too & this code doesn't work, capsule has a rigid body with isKenematic on to prevent the capsule from falling:
using UnityEngine;
using UnityEngine.SceneManagement;
public class EnemyContact : MonoBehaviour
{
public string scene2 = "Scene2";
private void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Enemy"))
{
Debug.Log("Enemy trigger entered! Loading scene...");
SceneManager.LoadScene(scene2);
}
}
}```
oh ty, i fixed it
is there someone who can help?
i did try to put the name of the scene directly too
it didn't work
capsule's tag is "Enemy"
it doesn't print the debug.log stuff
ah no, i meant the text
its in the #854851968446365696 but the bot command is ! code without the space
OH, im so sorry ur right i did say it
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 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 steps will guide you through some steps to debugging
but i meant the text i'm so sorry
i'll check them & tysm
https://paste.mod.gg/rfekyihhcwax/0
Okay so i tried to make a basic footsteps script, Just running off the WASD keys, I have an issue though, I can see why it's happening but not sure on a fix.
If i'm walking with W. and I tap either A,S,D while still holding W, It picks up the Getkeyup from them and stops the sound. Any ideas how to resolve?
A tool for sharing your source code with the world!
yeah still didnt work
Keep track of the currently pressed keys and only stop the sound of all of them are not pressed.
Couldnt I just do a single 'iswalking' bool?
And only activate if it's not true
You can, but wouldn't it get set to false with your setup as well?
It would yeah, My brain is staring at this knowing there is a simple fix but it's just not coming to my fingers lol.
A simple fix would be to have a local variable that is set to false originally, then |= on each input.
You'd need to query if the key is being pressed at the moment instead of up/down
bool dirty = false;
if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.D)) {
dirty = true;
}
if (dirty) {
Debug.Log("Input is dirty, char's probably moving");
} else {
Debug.Log("Input is clean, flag was originally set to false at beginning of frame and no input ever set it dirty.");
}```
void Update()
{
if (Input.GetKey(KeyCode.W) || (Input.GetKey(KeyCode.A) || (Input.GetKey(KeyCode.S) || (Input.GetKey(KeyCode.D)))))
{
iswalking = true;
if (iswalking)
{
footstepsound.loop = true;
footstepsound.Play();
}
else
footstepsound.Stop();
iswalking = false;
}
Okay so like this?
It's making the sound when I'm not walking now (lol)
yea i just used both these recommendations
well thats simple to fix..
you just Invert the if statement
or invert the boolean
guys any help? i really need to fix this
I'm lost
I inverted the if statement
and it's doing the same
How is that possible
Actually maybe it didnt save my fauly
why do u have the else if
maybe "else if () {}"
how does it not work
I need the if to stop the sound no?
i don't know 😭
-_- i ment which part of the code isnt working
not with the setup that was mentioned earlier..
the bool is set false EVERY frame..
sooo if you've let go of the walk keys.. it'd stop at teh end of the frame..
the audiosource will stop itself?
only if the keys are being held GetKey not GetKeyDown or UP.. would it get swapped to true..
well no.. but u would at the end of the frame..
Ah yeah that won't work
Also my bad i sent the wrong screenshot, I'm using getkey
is it not detecting when an enemy triggered?
void Update() {
// Reset dirty flag at top of frame
movementDirty = false;
// Check if any movement key is pressed
if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.D)) {
movementDirty = true;
}
// Use the dirty flag to control audio
if (movementDirty && !footstepSource.isPlaying) {
footstepSource.Play();
}
if (!movementDirty && footstepSource.isPlaying) {
footstepSource.Stop();
}
}```
no
@high summit like this 👇 read thru it step by step.. see if u cant work out what its doing #💻┃code-beginner message
it should detect if the player collides with another capsule (enemy)
& it loads the scene
and its not detecting it? i need information on the problem ur having
exactly it doesn't detect it
Oh smart! I think that's got it, I see you used the isPlaying
ya, to be sure it doesn't try to Play() when it already is..
or try to Stop() when it already is
try using this and then disabling the trigger on everything but things with the enemy layer
public class EnemyContact : MonoBehaviour
{
private void OnTriggerEnter()
{
Debug.Log("Enemy trigger entered! Loading scene...");
SceneManager.LoadScene("Scene2");
}
}
it works if you read all the steps correctly, what did you try?
every step
breakpoints
etc
nothing works
now imma try this
I agree, its always best to make things simple as possible to test
isolate the system and give it as few options to fail as possible..
the results from a test like this will show the most important issues first
this doesn't work too
didya do this
is trigger?
(example of a trigger system being used for only certain gameobjects)
no the layer overrides
give the enemies an Enemy layer and exclude every other layer
how does it not work -_-, give me more details
the player just passes through the enemy
send a ss of the collider
just tested ur script
dang unity hates me
did you.... not tag your gameobject
no i did tag
also why would you include player when you are checking for enemy collisions
idk
cuz i saw ur ss
that was an example of a trigger being used
show both gameobjects.. and their inspectors..
full screenshots with components expanded
ok
and also tell us if ur using ur old script or the one i sent
enemy
wheres the rigidbody?
not in the ss
i like how u just made Everything Enemy.. lol
but it is a component in the nemy
oh yeah 😂
full screenshots please 😭
like this plz
it is the same rigid body i sent earlier
minus the taskbar.. we dont care about ur taskbar
player has character controller, enemy has rigid body
scroll down here
we just want to see the rigidbody
and also more of the collider too
i sent the collider
full collider
oh wait i didnt set the layers in the rigid body 🤣
||just added rigidbody||
no
lol.. u wasnt supposed to read that!
lmao
also u excluded the player layer
oh
as a complete begginer to unity, what projects would you reccomend me doing? I'm currently working on a half decent flappy bird clone with a shop, multiple difficulties and power ups (first ever project). I'm half decent at 2D art, 3D art, Music production, sound design and some other technical and arty kinda skills.
and also give the player the player layer
make 2d games
yeah, i was planning on doing that, especially for my first few projects anyways
flappy bird, angry birds, temple-run but with rolly balls
make small projects
as spawncamp said
idk those usually pretty good to get u goin enuff to want to break off on ur own
i started out with a clicker game but !learn is good too
yeah, so clones of pretty basic games to begin with then
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
if u really want a challenge u could make u a little Pokemon clone
and the safest bet to learn from
& for a 3d game make a gta clone 😂
is it working?
lol.. u could probably do the OG version
no
maybe lol
i'd say open a new scene.. or try like this #💻┃code-beginner message 👈
test with just the most basics of basics...
i did 😭
then theres something MAJORLY wrong
yeah, well experimenting is one way to learn
collision code is harder than making an AAA game itself 😭
2D collisions seem to be fine (for now)
urmm, it isn't open in my taskbar, what am I looking for in task manager to close it?
Full Tutorial 😄
close it in task manager
UnityEditor
ok thx
got it
i think it may be a HUB bug..
yeah
if i open more than 2 project theres always one that seems to go missing
that i can't even find.. (i can hover over my taskbar and see the preview) but when i click that. nothing happens
Heres what I have at the moment (excluding the main menu
lol.. i assure u thats not the case..
ur probably just overlooking something really simple..
i ammm
I should probably add something to the buttons, like making them larger and flash a bit when they are clicked
one of those facepalm moments.. once we realize what it actually is 😅
collisions should be simple 😭
the powerup icons I mean
me speedrunning adding trigger collisions
did the pipes just explode?!
hacks!
soo it works for just you and me now..
atleast im not alone 💪 lol
dang nice work
doesn't work for me tho :)
you guys names are too similar lol
who?
ur doing sth wrong because that should work for literally everyone
KrayTik and Kyran
also in the video, u might see the fish particles briefly overlap with the pipes, any idea how I can fix it? I've tried using different layers for the Game Objects and stuff but everything I have tried doesnt seem to work
oh yeah 😂
im not i assure you
yea, the first thing i thought of was maybe he had isTrigger marked on both colliders
2nd thing i thought was his rigidbody is not on the collider or above the collider..
i have a character controller on the player
ahh, okay so its a Character Controller.. those will work with Triggers afaik
set the sorting layer of the pipes above the particles
god damn how does this shit not work
its under the sprite renderer
i'm deleting this code shit
ok I did that, now the pipes are invisible lol, I think they might be behind the background layer
but that means the fish are also infront of the pipes?
its important to organize every sprite into a layer so this doesnt happen later on
yep
did this fix the issue?
ah, u got the order wrong
so top should be background
yup
ah ok
alr Ima test it
nope, the fishes still briefly go over the pipes and then go under
hmm hold on
what do you mean by this, exactly
if u look in this video, near the beginning after the game starts, look on the right where the fishes come from and u will see what I mean
did you assign the layers to the particles?
wait, I'm not sure, where do I even find the sorting layer for a particle system?
yeah, however the order in layer was set to -1 for some reason
and the pipes are at sorting layer 3?
and the bug still happens?
yeah
in that case i have no idea why thats happening
yeah, I asked chatGPT and a few other AI's the same thing, they all said they can't help me lol
imo, asking ai for help is a bad idea
yeah
I've been trying to fix this bug for a few days now, maybe over a week, I can't figure it out lol
can u make the pipes farther on top?
wdym? like add filler layers in between?
on top of everything perhaps? just askin, i ahvent been keeping up with the convo
they are already
oh ok
This is the current sorting layer
strange
yeah
Share your camera settings
the calvary!
which settings in particular?
Just take a screenshot of the camera component/object inspector
Ok, so the camera is orthographic.
What I'd do next is pause the game when the issue happens, and inspect the draw calls via the frame debugger.
what are draw calls? and where do I find the frame debugger? sorry lol
Google that. We're not gonna make a lecture here.
alright
Also, before everything else, I'd inspect the issue in the scene view.
paue the game, switch to scene view, switch the view to 3d, rotate the camera and see if that fish is physically in front of the pipe
I think I found my issue, the particles must have velocity on the z axis
I think its the z anyways
It is. Make sure you don't apply velocity on z.
no? only on the x which is whats causing them to move across
Take a screenshot of the whole particle system object
maybe the particles are spawning on a randomized z axis?
pesky dimensions lol
in the inspector or the scene?
or both
if ur wondering why the material is called clouds, its bc my original idea for the scene was for it to be in the sky like normal flappy bird and these were meant to be clouds, but I shifted from that, I should probably rename it lol
Several things that bother me:
- Renderer mode being billboard. I wonder if it makes the sprites rotate towards the camera and clipping through the pipes because of that. You don't need them to be billboards if the camera is orthographic.
- Shape being a box/ emit from volume and the scale of the box is 1 on the z axis. This might cause the particles to spawn at varying z positions.
ok so which render mode should I set it too?
What are the options?
oh and theres the options for shape
should probably be sprite renderer now that I think about it, however idk?
According to the docs, the orientation of the billboard is controlled by the Render alignment property. So if you set it to local it should keep the rotation of the object.
https://docs.unity3d.com/Manual//PartSysRendererModule.html
Probably a rectangle..? A rectangle is a 2d shape as opposed to box
so I should change render alignment from view to local?
yeah
Also, this:
"Box Emits particles from the edge, surface, or body of a box shape. The particles move in the emitter object’s forward (Z) direction."
https://docs.unity3d.com/Manual/PartSysShapeModule.html
You should make it a habit of reading the documentation/manual about features you have never used
its a little bit off topic but your game is SO fun i tried high score in that 😭
ok, makes sense
rectancgle still has the same issue
Hey Everyone! I'm trying to figure out the best way to do some kind of Queue system with Vector3's.
online it says to use: myQueue = new Queue<Vector3>();
but does this have like a Push(); Pop(); functionality that i can use?
Dequeue & Enqueue
https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.queue-1?view=net-9.0
although moving it behind the pipes should work, right? it wouldnt fix the fact that they are moving in the wrong dimensions but it would fix the fact that they are infront of pipes temporarily?
If you look up Queue C#, you'll find links with how to use the collection (all of its properties and methods) . . .
Take a screenshot of the new settings.
Also, for future reference, this question has nothing to do with coding. Please keep your questions in relevant channels.
ok, sorry
Hmm... Weird. Maybe set the z scale in Shape to 0
Also, try disabling the noise module to see if it fixes it
both are no
I did fix my original bug of them going infront however they still move on the z axis so yk
Are they actually moving on the z axis? Or just spawning at random z positions?
moving
Click on the arrow next to start speed. You should be able to modify each axis separately. Or set the start speed to 0.
no, however I will try set it to 0
oh wait... setting it to 0 works
maybe the direction that start speed moves in is the z
Yeah. I've no clue why it does that. If you're curious, you should spend some more time investigating it.
yeah, will probably check it out, thanks
Vector2 playerPos = GameObject.FindGameObjectWithTag("Player").transform.position;
Vector2 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
float distance = Vector2.Distance(playerPos, mousePos);
if (distance <= range)
transform.position = mousePos;
else
transform.position = playerPos + ((mousePos - playerPos).normalized * range);
// Rotation
Vector2 toShield = new Vector2(transform.position.x - playerPos.x, transform.position.y - playerPos.y);
Vector2 playerRight = GameObject.FindGameObjectWithTag("Player").transform.right;
float angle = Vector2.SignedAngle(playerRight, toShield);
transform.rotation = Quaternion.Euler(0, 0, angle);
// Velocity calc
velocity = rb.angularVelocity;
print(velocity);```
Hey epic lads, why isn't my velocity ever changing?
I'm trying to change the color of my object when the velocity reaches a certain amount
Because you're not setting it anywhere
{
[SerializeField] float range;
public float velocity;
private Rigidbody2D rb;
void Start()
{
rb = GetComponent<Rigidbody2D>();
}
void Update()
{
// Movement around range
Vector2 playerPos = GameObject.FindGameObjectWithTag("Player").transform.position;
Vector2 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
float distance = Vector2.Distance(playerPos, mousePos);
if (distance <= range)
transform.position = mousePos;
else
transform.position = playerPos + ((mousePos - playerPos).normalized * range);
// Rotation
Vector2 toShield = new Vector2(transform.position.x - playerPos.x, transform.position.y - playerPos.y);
Vector2 playerRight = GameObject.FindGameObjectWithTag("Player").transform.right;
float angle = Vector2.SignedAngle(playerRight, toShield);
transform.rotation = Quaternion.Euler(0, 0, angle);
// Velocity calc
velocity = rb.angularVelocity;
print(velocity);
}
}```
mb should of shown the full thing
I set it to public just so I could see the actual value
You're still not modifying the velocity anywhere. At least not in this script.
If you're thinking the velocity can be inferrred from modifying the transform position, then you're wrong. At least the physics system doesn't do that and shouldn't.
yeah that should of been common sense mb, thanks
If you don't care about physics, you could calculate the velocity manually by storing previous position/s.
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
Ya'll learned from here?
I think i should learn basics first and then just learn by making stuff
Ty
When I started learning, it didn't exist yet.
Basically yes. Unity learn portal will help you with getting these basics.
Nice
learn basics, make a basic game (70s/80s arcade) to give yourself a reachable goal, then follow the path that interests you
Ok
I will also participate in game jams
you'll have to figure out how serious you are about making games, depending on that you should decide which people's advice to follow and what resources are suitable for your goals
Oh, ok
Thank you for the tips man
dam thats op. thats like over 2 months of 10 hour days 
you don't have to do all of it, in fact you probably shouldn't
you don't need to know vr, mobile, first-person, third-person, top-down, sidescroller all at the same time if you only want to do one of those
do the walking tutorials and then change out to ur running shoes >8)
Hi, I have a problem with this code. The NPC doesn't move. I've already used the navmeshagent, but it doesn't move. It only moves if the player pushes it. Well, it does the animation, but it doesn't move where it should go. I also put an objective on it, but still, yes=it doesn't do anything. Look, here's the code.
https://paste.myst.rs/qc0buxj4
a powerful website for storing and sharing text and code snippets. completely free and open source.
if i increase the time.timescale in unity project setting, is it normal for the object to move faster in real time right?
That's what it's for, yes
thanks that's what i gather from the doc. deepseek trying to gaslight me into thinking timescale 10x should result in same real time speed.
why are you using unity 2018?
also just for testing set the destination of one in the Start() method
see what happens
Do you really want to know?
sure why not
I have a sh#tty laptop that's why
thought the reason was more interesting
anyw
did you try putting the destination in Start()?
also see if you baked it
Could anyone give some feedback on the movement script? the axisspeedlimit is intended to create a elliptical speed profile. currently there is still a bug with accelerated diagonal movement that i am trying to figure out.
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 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.
Vector3 GetNormalizedForceDirection(Vector3 FDirection)
{
if (FDirection.magnitude > 1f)
{
FDirection.Normalize();
}
return FDirection;
}
here i'd recommend just completely get rid of the check as it probably decreases performance since you have to calculate a square root (pythagoras) every time you access .magnitude
@wind holly Is there a reason not to normalize when the magnitude is less than 1? if not so, you shouldn't check as cookie said. Even if you need it, you would end up calculating the square root twice (.magnitude and .normalize) which you could avoid by using Vector3.ClampMagnitude (one root)
If I want to detect when someone is crossing a door, should I use a boxcollider? Is this a bad idea? I'm not sure how I would handle collision then between the player object and the door if I use a box collider to detect crossing the door's threshold
nvm im dumb
but is this standard? or is it a hacky solution? using box collider to see if something crosses a door in game
Are you talking of trigger collider or regular collider? I would do that programmatically myself but trigger is likely fine too (and more of a standard solution)
oh i was using a regular one I'll take a look at trigger collider thanks
Oh, did I understand wrong what you were doing? Are you talking of doors that you can walk through or ones that teleport you somewhere when entered?
Teleport when entered
Yeah, right. Then regular collider should do fine
_requestedCrouch = input.Crouch switch
{
CrouchInput.Toggle => !_requestedCrouch,
CrouchInput.None => _requestedCrouch,
_ => _requestedCrouch
};```
got any ideas how to change this into a hold crouch system instead
{
_requestedCrouch = input.Crouch switch //CrouchInput is a enum
{
CrouchInput.Toggle => !_requestedCrouch,
CrouchInput.None => _requestedCrouch,
if (_crouchSwitch && InputActions.Crouch.WasPressedThisFrame)
{
CrouchInput.Hold => _requestedCrouch
}
else if (_crouchSwitch && InputActions.Crouch.WasReleasedThisFrame)
{
CrouchInput.Hold => !_requestedCrouch
}
_ => _requestedCrouch
};
}``` tried this but doesn't seem to work as intended
oh dam, yeh i need to do this next time. sorry am new still.
CrouchInput is a struct
...why?
good point. so just "return FDirection.Normalize()" would do the trick then.
was just following through with the tutorial, but i get why it was done
{
None, Toggle
}```
i think cos i figure the mag would always be >= 1. yeh, i will get rid of the if cos it does the job without it.
that's an enum, not a struct
yea i accidentally typed it wrong lol
anyways, if inside a switch expression isn't even valid, how'd you end up with this
mb
if that's not immediately flagged in your ide, you need to configure it
pretty sure it'd be return FDireciton.normalized; not return FDirection.Normalize();
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
anyways, in general you can't just "try things out" with random language features/syntax and expect it to work
when is CrouchHandling called?
every frame?
so it'd toggle every frame...?
no
it'll only switch when the button is pressed
CrouchInput.None => _requestedCrouch,``` flips the _requestedCrouch state if and only if you press crouch
lemme just pastebin gimme a sec
A tool for sharing your source code with the world!
so sounds like you'd need to either:
- have 2 extra states,
PressandRelease, which would yield a value oftrueandfalserespectively
- then from
Player.Update, choose whether to sendToggleorPress/Releasedepending on whether toggle or hold is set
- remove
Toggleand usePress/Release, which are sent according to the button state
- then from
PlayerCharacter.UpdateInput, choose how to handle the input depending on whether toggle or hold is set
though both might have issues if it's released in the same frame it was pressed. im not sure that's possible though
i thought lower case too at first but using normalize gave me an error about can't find it in context. also simplifying to the one return line gives a "assign type void to vector3 error" so i had to use these 2 lines instead/// FDirection.Normalize(); return FDirection;
im pretty sure not even tas can do that
lemme try implement it
it wouldn't be up to tas or no tas
it'd be up to how the system decides to handle it
pressing and releasing a button in the same frame can definitely happen, but does "was released" trigger on the same frame or the subsequent frame? that's what matters
Hello, I'm a bit confused with how Unity initialize materials. I have a model with a skinned mesh renderer which has 3 material slots. 2 of those slot use the same material in the editor. But when I launch the game, those materials are replaced by instanced materials, and each slot as a different material instead of the 2 similar slot using the same instanced one. Can I only fix this using code or is there a setting in Unity to tell to optimize material initialization to keep it like it is in the editor ?
not normalize;, it's normalized;
this is a code channel, if you're asking about how materials work in general you'll probably get a better answer in #💻┃unity-talk probably
Ok thanks
on method 1 so i create a bool like crouchSwap, then an additional enum CrouchHold that swaps between Pressed/Released?
so then i run a simple if statement to check if the crouch was toggled or not
the if(crouchSwap) should be outside then have my original code nested in one end and the hold system on the else statement
you don't need an extra enum in either case, just extra enum members
so i add the states Pressed, Released
which method you choose depends on where you want to store "should crouch be held or toggled"
in the original snippet then do i need to declare their behavior?
like CrouchInput.Pressed => _requestedCrouch?
yeah, so you can handle that kind of input (as in, between classes)
When i press LeftShift the dash doesent work. Ive tried binding it to many keys bu the only one that works is D
have you tried debugging the separate conditions?
also, what method is this code in?
ill just send an ss of the script 1 moment
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 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.
huh
see the bot message about posting code
? CrouchInput.Toggle
: CrouchInput.None```
From the player.cs, how should I handle the Enum's additional states?
wdym
!screenshots
No
Be mindful, if someone requests your code as text, don't send a screenshot!
you'll be better off if you can use a pastebin so we can see the full context/code
you are right
if you're on toggle mode, use the existing logic
if you're on hold mode, send Pressed if it's pressed this frame, Released if it's released this frame, and None if neither
@wooden star you've answered neither of my questions, and please don't use images to show text
Im trying to figure out pastebin
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.
in your FixedUpdate, you reset the speed to the normal move speed even when you dash
do i just put the is dashing above rb.linearVelocity?
sure, that'd work
thanks
Do people use the tagging system? Or just store the tag data as some sort of enum?
the 1 tag per object seems pretty bad unless I'm missing something that allows for more than just 1
i get that but it's more like I'm not too sure how to actually code the scenario
{
Rotation = playerCamera.transform.rotation,
Move = input.Move.ReadValue<Vector2>(),
Jump = input.Jump.WasPressedThisFrame(),
JumpSustain = input.Jump.IsPressed(),
if (!crouchStateToggle)
{
Crouch = input.Crouch.WasPressedThisFrame()
? CrouchInput.Toggle
: CrouchInput.None
}
else
{
if (input.Crouch.WasPressedThisFrame)
{
? CrouchInput.Pressed
: CrouchInput.None
}
else if (input.Crouch.WasReleasedThisFrame)
{
? CrouchInput.Released
: CrouchInput.None
}
}
};```
something like this?
ok vscode question. the c# devkit has broken once again, or it just doesnt correctly find the scripts for whatever unknown reason. what should i do? just revert back to an older version? just before it broke i think i somehow didnt have the devkit enabled or something and it was working flawlessly. but now with it on nothing is working 
onmisharp is like the most unstable thing i've ever seen in an IDE. its actually crazy
could you be more specific about what the issue is?
what versions of stuff are you using?
intelisesne is just not working at all
and every file i have it says this:
[info]: OmniSharp.Roslyn.CSharp.Services.Diagnostics.CSharpDiagnosticWorkerWithAnalyzers
Analyzer work cancelled.
[warn]: OmniSharp.Roslyn.CSharp.Services.Navigation.FindUsagesService
No symbol found. File: [my file here]
one sec, let me get them all
for vscode:
C# language support extension: v2.72.34
C# Devkit Extension: v1.18.25
for unity:
Visual Studio Code Editor: 1.2.5
Visual Studio Editor: 2.0.23
what's your vscode version?
uhh, wherever you check the version for most apps for your os?
like here for mac for example, but idk for windows, haven't touched it in a hot while
Version: 1.99.3 (user setup)
Commit: 17baf841131aa23349f217ca7c570c76ee87b957
Date: 2025-04-15T23:18:46.076Z
Electron: 34.3.2
ElectronBuildId: 11161073
Chromium: 132.0.6834.210
Node.js: 20.18.3
V8: 13.2.152.41-electron.0
OS: Windows_NT x64 10.0.26100
and everything's up-to-date?
i havent checked if vscode is, ill run the update real quick but everything else should be
ah yeah ,vscode is fully updated too
so as far as i know yes
do you have any logs beyond what you got in output?
holdon, it says something about file paths "exceeds the OS max path limit. The fully qualified file name must be less than 260 characters."
which i assume is resulting in this error:
[fail]: OmniSharp.MSBuild.ProjectManager
Attempted to update project that is not loaded: c:\Users\Documents\GitHub\Unity-Package-Development-Space\PackageDev\LUTTextureGenerator.csproj
could it be thats whats causing the issue here? just too long paths??
but how then did it work before and not now?
seems odd that that issue would pop up just now yeah
i dont really know what i can do about too long path names anyway. like i dont really want my files to be less descriptive of what they are lol
what, thats crazy
i disabled omnisharp and its back to working
who knew using omnisharp was a bad idea
Yooooo guys
I have an issue
how do I call a function of the object that collided with another one??
{
if (isP1 == true)
{
if (other.transform.CompareTag("P2"))
{
var genThing : GeneralThing = other.gameObject.GetComponent(GeneralThing);
genThing.RemoveVida(damage);
}
}
}```
I tried this but it didn't work
"GeneralThing" is the script I want to call when it collides
this is the error I get
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
Idk what does it means
You got some weird syntax going on there. Look online for examples how to actually use GetComponent
I actually went to a unity website with the same issue
and I paste it
but it didn't work
yeah that's ts, not cs
That is ancient isnt it
ohhhh
That code is probably 15 years old isn't it
unity doesn't support ts anymore afaik
What's the date there lol
damnn I didn't see that
its 2014 😭
not even const 🤮
Yeah unity used to support a JavaScript derivative
oh derivative, huh
It was a custom language Unity made that intentionally resembled JavaScript, but actually had nothing to do with it. It compiled to .NET, same as the Boo language.
you should really do some c# basics, theres a link for intro to c# pinned in the channel.
also still configure the ide #💻┃code-beginner message
okok thanks
sup guys
I solved this problem
but for some reason the trigger does not work
did you configure your IDE as was recommended for such errors ?
In what order is OnCollisionEnter executed ?
I have both objects as "isTrigger"
congrats, go through the entire troubleshooting steps
the guide has several steps mate..
do people just click 1 thing and go "oh well it aint it.."
i will look
Ok sorry I see the flowchart for the execution order, but maybe I'm missing something but when 2 objects collide, is it random for which one is executed first?
maybe its on the bottom of the page il keep reading
it's deterministic/consistent, but don't rely on the specific order
It's based on Script Execution Order, which, unless you've specifically declared some scripts as higher or lower priority, is basically arbitrary
you should basically treat it as random, is there something specific you're trying to solve here?
yes I was following a tutorial and they have Player colliding into an object, the object changes its tag when collided into and the player checks the object's tag, to execute something in its own oncollisionenter function
this sounds like a victim to the execution order
that also just sounds like bad design. why can't one of the two objects just call a method on the other instead
i know ahahah i want to change stuff but I just want to learn unity basics rn and dont want to end up with a codebase diverging from the tutorial
well it might be better if the tutorial is bad lol
depending on the use case, either the object should be calling some method on the player or the player calling a method on the object. I wouldnt really try to just copy a tutorial 1 to 1 if you know better. Most tutorials are complete shit
ya for sure, I just am missing the basics of unity lol I don't know the tools available to me yet
like i didn't know cinemachine was a thing, I had to manually do camera stuff in monogame and thought i would have to do it in unity too
well you had to before cinemachine was basically bought off from unity. It used to be a paid asset
if you're familiar with c# or coding already, you can just skim over tutorials to see what components they're using and roughly what its for. Then just experiment around in your own game
must have been the dark ages
lots of tutorials just have plain wrong information, or whatever they're doing only works specifically for the video. everything gets bad once you try expanding on it
hey
most solutions are specific to a project anyway, you're meant to takeaway the approach someone used then you can better it yourself but you do need to know more
yeah learn the concepts, not the specific implementation
sorry my bad
Hello guys! I do have a problem. Currently im trying to make something lock in place, and then start moving again. My problem is that im trying to make something like:
ball.constraints = RigidbodyConstraints2D.FreezePositionX | RigidbodyConstraints2D.FreezePositionY;
And then to free it i do
ball.constraints = RigidbodyConstraints2D.None;
But atfer i unlock it, my ball stays mid air. Someone can give me a hint on this?
Does it have gravity enabled?
and is it simulated?
Yes. Id does.
And is it awake?
And is it non-kinematic?
Turns out there's a whole buttload of reasons a rigidbody might not move
if its not working in code i usually replicate the logic on my own in the inspector.. at runtime..
can u check constraints in the inspector and then disable them and have it work as desired?
if that works i turn my attention back to code
Hmm...it is checked, but i dont know what non-kinematic is. An easy fix that i found was to give it a very very small force on it, or in the inspector i have to check the use auto mass, but it doesnt change the gravity in any value.
non-kinematic means the rigidbody is set to dynamic
if giving it a very small amount of force makes it start moving again then it sounds like it was asleep
What does it mean that is asleep?
The physics engine puts non moving rbs to sleep
as an optimization
so it doesn't have to do any computation for them
You can wake it up with https://docs.unity3d.com/6000.0/Documentation/ScriptReference/Rigidbody2D.WakeUp.html
This worked. Thank you very much!
how do I 'use' editor scripts? I am trying to use https://gist.github.com/mickdekkers/5c3c62539c057010d4497f9865060e20#file-snapshot-camera-demo-zip to convert/generate a texture2d from a texturerender
You could also bind this to a MenuItem or any other editor script you want: https://docs.unity3d.com/6000.0/Documentation/ScriptReference/MenuItem.html
so I apply this monobehavoiur to the rendercamera and then?
also unsure where the output is if any.
You would pass the filename of the PNG you want to save into the SavePNG method https://gist.github.com/mickdekkers/5c3c62539c057010d4497f9865060e20?permalink_comment_id=4517346#file-snapshotcamera-cs-L112
always best to take a peek and see what the code ur importing does. lol
also
test scene probably has all the info u need
im robbing that SanitizeFilename() method
mayeb this isnt doing what I want then, I just want to convert the rendertexture of my rendercamera to a static image seperate of the render camera
ahh tahts simple then eh?
just create a Texture2D variable.. and then in ur code u could set it to the rendertexture
but when I leave the scene the rendertexture becomes blank
Hello could anyone be so kind as to explain to me why I get the compiler error
CS0120 An object reference is required for the non-static field, method, or property
On my CharacterAnimator reference?
private CharacterAnimator playerChar;
private void Awake()
{
i = this;
character = GetComponent<Character>();
playerChar = PlayerController.i.GetComponent<CharacterAnimator>();
PlayerController.OnPlayerStep += HandlePlayerStep;
}
where, exactly?
First step is to show the full error message and which file and line number the error refers to
Most likely it's the PlayerController.i and the PlayerController.OnPlayerStep parts - because you need to actually have a reference variable for an instance of PlayerController to do that, you can't just use the PlayerController class name there. I'm assuming that's a class name though, because you didn't show enough of your code for me to know for sure.
i sounds like it's for a singleton
Yeah sorry PlayerController is a class name but its a singleton
So which line is throwing the error exactly? Share all of the relevant information please if you want the best help.
Yes sir,
So I get the error on any line I try and reference my playerChar variable, atm only here
public static Vector2 GetSnappedPosition(Vector2 moveVec)
{
Vector3 moveOffset = Vector3.zero;
if (playerChar.MoveY == 1)
moveOffset = new Vector3(0, 0, -0.5f); // Player moving Up
else if (playerChar.MoveY == -1)
moveOffset = new Vector3(0, 0, 1.5f); // Player moving Down
else if (playerChar.MoveX == 1)
moveOffset = new Vector3(-1, 0, 0.75f); // Player moving Left
else if (playerChar.MoveX == -1)
moveOffset = new Vector3(1, 0, 0.75f); // Player moving Right
return moveOffset;
}
The full error is: CS0120: An object reference is required for the non-static field, method, or property 'PetController.playerChar'
Huh?
Cna you please just share the full error merssage
and the full script
that will make this a lot easier
you are overcomplicating things
yeah so that's a static method, and playerChar is a non-static field
you can't access an instance field directly from a static context, you need an instance, and a static context doesn't have an instance
Right so the code you shared earlier wasn't relevant to the error at all 🥹
well, the first line with the declaration was
What im completely confused, I get the error on the variable itself? so how can that not be relevant
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 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.
wdym by you get the error on the variable itself? That particular error is not going to be present on the declaration of the variable.
wdym, could you show a screenshot of where you're seeing the error underlines?
im having a problem with my code, and i have no errors nor warning, so i dont really know why. Could anyone help please
https://dontasktoask.com
can't help without knowing what you need help with
i am trying to make a flappy bird type game just to get use to the coding, i just cant make it flap
describe the issue - what you want to happen, what isn't happening as expected, and relevant code shared according to #💻┃code-beginner message
even trying to follow this guide im still cooked
why is it so hard to save a png
Sure so heres the entire class: https://paste.mod.gg/hseruegdcqdv/0
And I get an error every time I try and access the variable:
A tool for sharing your source code with the world!
Yes, because you're in a static method
trying to access a non-static variable
Ah
Yeah that was dumb of me thanks for pointing that out
For the record Chris did here #💻┃code-beginner message
yeah so in your first codeblock, only the declaration of the variable would be relevant, nothing else
i want to sprite to go up when i click space and i got the code down for that i think "if (input.GetKeyDown(KeyCode.Space) == true"
Yeah gotcha, I wanna say I promise there was an error on the actual declaration but I went back to it and it had dissapeared so either visual studio had a funny 5 minutes or I did
Thankyou both
ok so what's going wrong with it?
Make sure you have your console window open when you are running the game so you can see any runtime errors.
also, have you added the component to your bird
when i press the space key it simply wont do anything
- make sure you added the component to the bird
- make sure you run the game with the console window open and look there for any errors
yea i added the ridgid body 2d collisions and the script
the console is apamming this error what does it mean
did you read it?
yea i dont understand it
unity has 2 input systems. you're trying to use the old one, but you told unity you would use the new one
it means exactly what it says
your code is trying to use the old system
but your project is set up to use the new one
To fix it, go to Edit -> Project Settings -> search for "Active Input Handling" and set it to the old one.
basically you're using a tutorial for an older version of Unity. New versions of Unity have the new input system set by default
It means you are trying to read Input using the UnityEngine.Input class, but you have switched Active Input Handling to Input System in Player Settings.
don't the newer versions that have the input system installed by default also have the active input handling set to Both by default to avoid exactly this? seems more likely they installed the package (or some other package with a dependency for it) and just allowed it to change it automatically without considering what that would do
Do they? I'm not sure.
they used to.. 6.1 has it defaulted to NEW (atleast for the URP template) @slender nymph
"give em a little nudge" - Unity Input Handling Team
well that just seems silly. they should have left it as Both for 6.1 and probably for 6.2 as well and not change it to Input System by default until 6.3 (the next LTS) to give more time for people to transition since a good majority of tutorials for the engine use the input manager
ya fr, imma have to start telling ppl to keep an eye out for it when they use the Input class
They should really just give a better experience than that error message. Like some prompt should come up with a button that switches it for you.
i set it to both it fixed the problem, just making sure that setting it to both wont make anything worse with the way i code later on
tbh using the old input manager just makes the code worse 🤷♂️
i can't imagine that setting would be any different in that template, of course unity has made some silly choices before so i wouldn't put it past them
do i have to change somthing in the project or in the code, so it can work with the new input manager
You just did
you would have to completely redo the input handling, yes.
I recommend not worrying about it at this point in your journey.
oh ok thanks for the help
there is no "new input manager" it's called the input system, the input manager is the one in the project settings literally called input manager and that is the old way to do input.
if you are just starting out, it may not be worth attempting to switch just yet, you want to stick to what the courses you are following do
ok i will stick with the old input manager
thanks
and just fyi, it's usually better to stick to the same unity version (at least the major version, newer patches are fine) as the course you are following to avoid issues like this where some setting or feature has changed and you don't understand enough about the engine to even know what changed
nope, its defaulted to New in the BiRP as well..
swapped it over to Both.. cant remmeber if i recall seeing this legacy message.. but there it is
now we know 🙂
Are the videos broken? Or don't they just play on my pc ?
Free tutorials, courses, and guided pathways for mastering real-time 3D development skills to make video games, VR, AR, and more.
they're not working for me either
Okay ty.. well.. then proceed with the description text
👋
I have a little platform like this
When my character controller tries to get off this platform, it's grounded state becomes false until it lands in the terrain
It acts like it's a staircase with air
Also depends where the check is being made to determine grounded or not. If it's dead center of the object, then when you step off you'll count as not grounded because the center is not on anything
If this is an issue, you may need multiple points of contact to check for
Yeah I get the point but when I'm trying to walk off it acts like a stair case
So I can stand in the air if I try to walk off but don't do it fully
I want to make it so that if I'm walking off at the edge it fully drops me
So doing grounded checks in my own instead of using character controller?
But that still wouldn't change the fact that the character controller stays in air as you walk off the edge
CC ground check is not very reliable, always make your own when you want more control
I'm aware but I'm just looking for a simple one, can't I fix it in another way?
there are many solutions to a single problem
Is there a possible solution that doesn't involve doing your own grounded checks?
Because I've tried doing it myself once and it didn't go well
probably not because the CC groundcheck is limited to the collider / capsule touching stuff
Eh, fair enough
in real life we don't ground check in our center lol we have two feet to "probe" the ground for solid check
but also in game you're limited to how the capsule collide reacts to just hanging off the ledge, you have to either at some point shrink the collider a bit when standing on edge or push/nudge it in code..
i just realized not too long ago how complex my CC's ground check is...
it seems like it casts towards the most outter edge/solid ground
no clue how its working as of yet lol
uses either Raycast/Raycast Array/Spherecast but it seems like after the initial ground flag. it does more magic
glues u to that (l)edge
https://github.com/Jan-Ott/CharacterMovementFundamentals is the CC if anyone is curious or wants it..
it was a paid asset (35 USD) up until just last month
howso? how did u do the groundcheck?
why do u say it didn't go well? what exactly went wrong?
do you want assistance figuring it out? or have u moved on?
I moved on sadly so I don't really remember
But I'll try it once again and see if I can do it
i use the default CC groundcheck against Nav's advice, and for all intents and purposes ... it works fine for me
goood luck!
📌 helpful tip: use OnDrawGizmo function while u build it out
the CC grounded does the job, when you need more control and needing things like Normal of surface then rayhits are a must
true true..
it means that on whatever line that error is pointing to, you're trying to use transform where it doesn't make sense.
i understand that but i dont know how to fix it
and i don't know why it wouldn't make sense
because it is code from a tutorial
Well if you want better help you should share your code with us and the full exact error message
I'm not a mind reader. Presumably you copied something from the tutorial incorrectly.
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 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.
Hey Everyone, Why is it when i ReloadScene i noticed my boolean variables don't change even though the whole scene restarts? how can i get all the variables to reset also?
Whether the variables are boolean or not is not relevant.
The relevant bit would be whether the variables are static or not, or if they exist on objects that are either DDOL or not part of a scene in the first place.
the only things that will "reset" are things that are actually part of the scene and are getting destroyed and recreated
so a boolean would need to be static to get a proper reset on scene reloading?
no
quite the oopposite
static variables will NOT reset
and variables on DDOL objects will NOT reset
i have zero static variables in my project currently
YOu will need to share more context if you want to know why certain specific variables you are concerned with are not resetting
show your code
and explain which variables are not resetting as you expect
oh you know what... i am using Time.TimeScale.. that is static.. thats the variable that's not reseting and i thought it was one of my booleans... that probably makes sense right
Yes, Time.timeScale is a project-wide thing that is outside of any scene.
and it's definitely not a boolean
ok that makes sense. thank you
i mean't that i had a boolean that checks to see if the game is paused. when i restarted the scene, the game was paused... so i thought my boolean was == true.. therfore triggering the timescale.. but it's just the timescale because it's static. very good to know. thank you!
i copy pasted it like it said
Share the code, I cannot help you without seeing it
if you copied it and it has that error, then you either copied it wrong, or the thing you copied was wrong in the first place
i am diong it now
{
public CharacterController controller;
public float speed = 12f;
public float gravity = -9.81f * 2;
public float jumpHeight = 3f;
public Transform groundCheck;
public float groundDistance = 0.4f;
public LayerMask groundMask;
Vector3 velocity;
bool isGrounded;
// Update is called once per frame
void Update()
{
//checking if we hit the ground to reset our falling velocity, otherwise we will fall faster the next time
isGrounded = Physics.CheckSphere(groundCheck.position, groundDistance, groundMask);
if (isGrounded && velocity.y < 0)
{
velocity.y = -2f;
}
float x = Input.GetAxis("Horizontal");
float z = Input.GetAxis("Vertical");
//right is the red Axis, foward is the blue axis
Vector3 move = transform.right * x + transform.forward * z;
controller.Move(move * speed * Time.deltaTime);
//check if the player is on the ground so he can jump
if (Input.GetButtonDown("Jump") && isGrounded)
{
//the equation for jumping
velocity.y = Mathf.Sqrt(jumpHeight * -2f * gravity);
}
velocity.y += gravity * Time.deltaTime;
controller.Move(velocity * Time.deltaTime);
}
}```
You failed to derive your class from MonoBehaviour
what does that mean
It means you didn't copy and paste like you said
compare this part of your code
with the tutorial
i did copy paste
You cut off the part on the right
i dont know why it didnt do that
Hello, I was wondering if there are significant differences for basic projects between unity 2022.2 and unity 6000 (current one), I want to follow a rough tutorial but am unsure if I can do so on the most recent version, or if I should stick to the guide's version
Some things change, but the core functionality is the same. It should be fine to follow older tutorials. If you encounter an error, google it or the related API to see if it has changed recently.
Is there any way to code like a starup and count down sequence then this slop I cooked up?
private void Update(){
remainingTime -= Time.deltaTime;
if(isPreMatch){
PreMatch();
}
}
private void PreMatch(){
if(remainingTime > 4f){
preMatchText.fontSize = 80;
preMatchText.text = "First to 5 points wins";
}
else if(remainingTime <= 4f && remainingTime > 3f){
preMatchText.fontSize = 300;
preMatchText.text = "3";
}
else if(remainingTime <= 3f && remainingTime > 2f){
preMatchText.text = "2";
}
else if(remainingTime <= 2f && remainingTime > 1f){
preMatchText.text = "1";
}
else if(remainingTime <= 1 && remainingTime > 0f){
preMatchText.text = "GO!";
}
else if(remainingTime < 0){
preMatchText.text = "";
isPreMatch = false;
ball.StartMatch();
}
remainingTime gets set at start
I mean if it works, but otherwise if you want to eliminate some of the logic here, start low and compare high
if remainingTime < 0
else if ....
is there like a premade unity method to do something like this? or do i gotta do it manually
put them in an array and use a loop instead of this
or wait you're just trying to make a countdown timer here?
Round down the timer to the nearest int, that's your number. If that number is zero, show GO.
well its a countdown timer but i also wanted to show the earlier text for a certain amount of time before the countdown
Hashset ;)
will do that
int remainingSeconds = Mathf.FloorToInt(remainingTime);
if (remainingSeconds > 4) {
preMatchText.fontSize = 80;
preMatchText.text = "First to 5 points wins";|
return;
}
preMatchText.fontSize = 300;
preMatchText.text = remainingSeconds.ToString();```
Really just some struct/tuple
something like this
it floors the float and gives you back an int
e.g. 3.1415 becomes 3
but also -2.452 becomes -3
basically rounding *down * to the nearest integer
Thank you 🙏
This doesn't have the prefered comparison logic but a little switch expression like this could clean it up abit aswell right?
(float,string) displayText = remainingTime switch
{
float i when i > 4f => (80, "First to 5 points wins"),
float i when i <= 4f && i > 3f => (300, "3"),
float i when i <= 3f && i > 2f => (300, "2"),
float i when i <= 2f && i > 1f => (300, "1"),
float i when i <= 1f && i > 0f => (300, "GO!"),
_ => (0f, string.Empty)
};
yep
hey the gameobject bullet isnt destroying or going away when it hits the cube with the tag target how do i fix this?
nvm i fixed it
When I'm handling input actions, should I set it up directly through the project settings or create a separate inputactions object and work from there? Is there a functional difference
more customizability? for seperate objects
oh right yea ty
https://www.youtube.com/watch?v=Kgjth3nRsFc&list=PLiyfvmtjWC_Uzpqn_76LTJYa9cn3DzUk6 this is the tut i used
Learn how to create your own classic First Person Shooter in Unity!
Get the assets for this series here: https://www.dropbox.com/s/juihs7yq93x1aon/GPJ_FPS_Assets.zip?dl=0
Don't forget to hit that like button and if you'd like to see more gaming goodness then subscribe for more!
Support the show by pledging at http://www.patreon.com/gamesplu...
based on the fact that the bullets go sttraight through the box they're clearly not colliding with anything
so it's not surprising OnCOllisionEnter is not running