#š»ācode-beginner
1 messages Ā· Page 283 of 1
It is its own little math function
In this case we're using it to move the velocity vector towards a new value slowly
alright thanks for the help ill check that out! you the goatš
*sorry, typos
Can i export and send someone my unity project assets for help?
i made my final project to complicated for my skill and doing way more than i needed too and needed to get a 30 day extension and i am almost out of time and i desperately need help
Nobody's gonna do that, but you could ask isolated questions with details.
Well,
I cant get the durability text, game over text, spawn points, or mystery crate effects to work
thats pretty vague, focus on one issue at a time. And read the #854851968446365696 on how to ask specifically
To be fair, i think i followed all those "DO" steps
This still has different results at different framerates
yes it's going to unless you use FixedUpdate
I see
this is why physics uses a fixed framerate
otherwise aceleration always makes things different at different framerates
You can get linear motion to work fine with a variable framerate, but not acceleration or any other second-order effects
you've done exactly none of them
I see, I got it in my head from a few forum posts that only rigidbody event should go in fixed update lmao
That's always the thing about these hard and fixed rules
there's always exceptions
you could also implement your own fixed-rate tick system if you want, but FixedUpdate is convenient
yes so where is the code, the description of the problem with context, any error messages, steps you've taken, and a full paragraph with the info ready?
you've said "this doesnt work" and showed a screenshot of the editor
really it's "Physics simulation code needs to go in Fixed", which usually means Rigidbody stuff. But you're essentially implementing your own physics here. So you should also do it there. Of course if you move all your movement etc to FixedUpdate you're going to have to deal with visual stuttering and you then either have to manually implement interpolation or just switch to using Rigidbodies anyway
So if physical consistency is important for your game... I recommend using a Rigidbody
can't you change the speed at which physics updates happen in the project too?
You can change the fixed timestep yes
Putting my old code within fixedUpdate worked too, is multiplying it every frame inefficient tho?
Is it not good practice?
It's fine
- Done
- Done
- Done ig
- Not done admittedly
⢠Use post sites: N/A
ā¢N/A
ā¢I have youtubed, googled, and chat gbt'd
ā¢Ive given a list of what i need to make work, but im really not sure where to start or how without just sharing my current coade and assets
Remind me, this is code-"beginner" channel right?
Im at the end of an 8 week game design course, so ya, pretty new here
Please be patient with me
instead of arguing of what you've done, maybe try to focus on specific issue as i told you above.
#š»ācode-beginner message
then post relevant context. all you've said was "this doesnt work"
I found this discord because i am at if not past the limits of my ability and understanding
I'm confused. Would you like help?
You have to understand none of us know anything about your project. So you'll need to share all the relevant details about your problem if you want help.
Mechanics need to take a look at the engine if you want them to fix it.
And nobody is going to download your project to help you, because that is the kind of behaviour you should be paying for
Is making a rigidbody controller better than using the character controller?
What is a situation where it'd be better to use a character controller?
Okay, thank you
That is constructive feedback. I am not fully aquainted with the etiquette.
Alright, let me think how to word my problems better
A situation where you'd need a very simple controller.
I see
Character controllers can't move rigidbodies too iirc
Imagine a game like Obduction or Firewatch, or What Remains of Edith Finch
something where the player movement isn't the point of the game and needn't be precise or consistent
They were asking you to do the stuff under the "DO" section btw. Like posting code.
Not the 1,2,3,4 part at the top
Alright, so
When the game opens, it shows the title and 6 difficulties to choose from, that works, great
Ideally, when selecting a difficulty, i want to be able to have the player and one or more enemies spawn in set locations depending on the difficulty. I also want the rate of certain objects spawning from the sky to increase at higher difficulties, but havemt started that yet.
What happens currently, is 1 enemy and 1 player spawn, in the wrong spots, regardless of difficulty, and now can't move from their spawned spot, and the enemy ai just sits there doing nothing, when prior i had the controls working just fine and enemy moving just fine. I'm guessing they are getting stuck on the spawning onlbhects somehow? But even if i code the spawning objects to destroy themselves after the game starts and they do their job, the player and enemy still can't move.
The next issue is that i had it working at one point, but now, the ui that is supposed to show and change with the player's Durability (health) doesnt display anything. Same thing goes with the game over text, that i had triggering and showing different text depending on of player or enemy(s) got destroyed, but now that doesnt work, and I just dont inow how to fix this.
The last big issue is i have tried every logical method i can think of. But can't get the mystery crates to work. Ideally, if the player destroyes one, one of 3 random effects is supposed to trigger, but nothing happens when they are destroyed
if you need this behaviour, you can always do stuff like addForce but i'd be careful doing this because you really can get really wonky cases. Its nice if you are able to keep every entity using the same movement system, character controller, a custom kcc (kinematic character controller), or rigidbody. When you start mixing them up, you need extra logic to handle other cases.
Couldn't you also have a rigidbody that's a little bigger on the character controller
Or like a sphere on the body
I got desperate ao i started plugging my code into chatGBT to fix it
And it worked with some stuff, but messed up others, but now it changed things and i feel like i dont know my north from south anymore
I understand what you're saying tho
Start from solving the issues one by one. You don't need to tell us about all of them at once. Describe one issue and provide relevant details/code/video of the issue. As well as describe the steps you took to debug it.
i havent tried it personally, because i havent really used the built in CC much. I assume it would work to some degree, but any collider will push a rigidbody away. You dont specifically need a rigidbody on your CC. A rigidbody will try to depenetrate itself from other colliders
And that's one of the reasons you shouldn't use chat gpt as a beginner. At least not like that.
Naming convention
the name of a variable always changes nothing
but whats the exact point of using an underscore?
just to pinpoint variables easier when reading?
its convention some people use to indicate a variable is private
i personally dont use it
If you look closely at the code, you'll notice a pattern. Naming conventions are to denote certain category of variables.
so if you use [serializefield] its still considered private?
No
As you said, it's for readability purposes only
It doesn't change anything functionally. Aside from maybe a discard
underscore usually denotes some sort of private variable backed by some property field
it kinda helps, but im lazy with them too
I've seen it being used for method arguments/parameters too. It depends
because sometimes you shouldnt be accessing the private variable outside of the property field as the property may have some extra logic it needs to do
updating UI, ect
how can I activate a child gameobject from an script attached to the father object?
GetComponentInChildren or assign that reference
Reference it in the inspector.
Honest learning question
Would it not just be easier to personally open the project?
Like to hit play to see what happens, see what assets are where, look at the code that way, instead of translating the problems from static pics, or video snipits, or parts of code, and to rely upon my amateur coding/developing vernacular?
Like, not saying to fix it for me, but easier to visually see whats wrong where and tell me what i need to do/fix?
It would be less easy than you just telling us the issue
It would be a fairly time consuming task, and require explanation anyways
Plus I don't download stuff from strangers generally. On servers
It would, but it would take time and effort of the one helping you. It is often enough to understand the problem from pics, videos and code. The difference is who's working harder: you or the person helping you. The rule of thumb is that you shouldn't make a person that volunteers to help you to work harder.
Hi guys, I'm trying to create a pause menu. The game is pausing but the actual image of the pause menu won't appear? It might be something to do with the camera rendering the player map but not the pause menu but im not sure what exactly to check
How do I debug this problem: when I click on a gameobject during play, the unity editor consistently crashes. I'm using 2023.3.0b8.
downloading a project, loading it, running the game until you come across the error, and looking through the code is a very time consuming task.
And tbh if someone jumps at the opportunity to download your project, i would assume they are just trying to steal stuff. Most people who know what they are doing wouldnt download someones project to begin with
This is how it is before pressing play
Also, note that most people here are answering when they don't have access to their PC(at work breaks or on the move), so it's technically impossible for them to look at your project. And when they do have access to the PC, they have better things to do.
game is paused, when I pause the scene I can see it but not when I press play
which is annoying
i'm on my phone 90% of the time I'm on here
Dang. The "this" emoji was for dlich. Slow phone messaging making a good example haha
Fair, ig i just assumed looking at the project and fn with it hands on would be easier for the helper, im definitely more of a hands on/visual kinda guy than going off explanation alone, but thats me
Yeah I just noticed, look at the view of the "maincamera"
it doesn't even see the pausemenu
Can you take a screenshot of the game view as well?
Show inspector of the canvas
Fair, tbh its just for a school project so im not to worried about that, but i can see the risk for sure
how it looks in game when play is pressed, haven't pressed pause yet
after pressing pause it does the same
Is it there if you deactivate your tilemaps object?
this might be alot to ask but is their anyone i could dm with help on making an appropriate grid lock for my game. I learned the basics but I need to alter the grid to this item. thanks
For some added perspective, this may be one of those old dog new tricks issues here,
I am 28 years old and just starting to persue learning something I have wanted to do since i was 8 or younger lol
But i spent my life being gaslit into game development being a waste of my time and stuck in survival mode instead of living and doing what i enjoy
End Segway *
Hmm... Do you have some black full screen image? Or is it black because of camera settings?
do you have your pause menu on a separate canvas? because from your previous screenshot, i see it is not on the screen space overlay canvas
That's fine. I started learning gamedev around that age as well. You just need to put effort and not expect it to come easily. Follow structured learning path. There are many dependencies for proper learning of gamedev.
Yeah it is, I don't even have the tilemap in a canvas it's just within the grid
show the settings for the canvas that contains your pause menu
ok
wait it's here
in this image, you see that white box whose corner is in the center of your camera's view and extends up and to the right? that is the bounds of your canvas. you need to put your menu stuff within those bounds
also check the documentation in #š²āui-ux to learn how to use unity's UI stuff
I digress, did the more thurough explanations of my issues help explain my problem, or the screenshots?
i need someone to point me in the right direction here i have two buttons i want each one to when clicked spawn a different player prefab heres my code for the room manager im using https://hatebin.com/hzcgnjhtnv
Ngl I was just thinking if it ain't broke don't fix it cause I have a canvas for my battle screen and that works fine, got that all set up
It was a mess of several issues and none of the explanations provide actual details of the implementation. Start with selecting one issue and going deeper into it.
Try selecting the canvas in the hierarchy and pressing F in the scene view. What happens when you do that?
but it is broke because you don't have your objects within the canvas's bounds
So why am I only having issues with this particular screen but not with another screen that I've created within a different canvas
just zooms in
I've moved it within the canvas bounds
because your other canvas is set up properly and the ui objects are actually on that canvas
again, see the documentation pinned in #š²āui-ux to learn how the canvas works
yes, this is how screen space overlay canvases work
which you would know if you'd bother reading the documentation
im just saying its a bigass canvas damn
sounds like you should probably learn more about unity before doing networking though
it wasnt the networking that was the issue it was the button system
i should of been more clear
this is literally the normal and expected size of a screen space overlay canvas
was trying to make a function that makes it so i can change each buttons skin value
but ive got it working now
ššæ
Hi, as you can see on the bottom left, there is a picture of ironman. But, when I make the screen a bigger size, the position of the canvas changes and I don't want it to. My canvas was always scale with screen size. But it is the position of the images that are changing. Is there any way to fix this?
check the documentation pinned in #š²āui-ux to learn how to properly anchor and scale your UI when the resolution changes
^^this. Anchoring is very important
also consider setting your game view to a specific aspect ratio instead of Free Aspect so you can see how it actually behaves on the target resolution
Ok
where is the free aspect?
look above the start game button in that screenshot
might wanna fix your reference resolution, doubt anyone has a 4:3 monitor now days lol
Oh thanks
am i using the transform.position = currentCheckpointT.transform.position; in a correct sense according to my code?
its attached to the player, when the player reaches -10 on the 'y' axis or presses the reset button (r), the position should change to the current checkpoints transform position
I had a read through of the documentation and tried to see if I can fix it but I think the scale of my UI elements are so off that I'd spend a long ass time just having to resize everything so it fits properly within the canvas. Thanks for linking it though I appreciate it
Imma probably have to come up with something else if I wanna do this
i mean, you scaled your UI objects down from what they would have been when you added them to the canvas initially. just add them again manually. and keep in mind this only applies to the UI because it is in screenspace not world space like your tilemap and stuff
Yeah it's just that having to scale also the tilemaps would be a pain and I have to reassign all of the objects if I re-add the UI elements
you shouldn't be scaling your tilemaps for this at all
your tilemaps do not belong on the canvas and are in world space with your camera
turns out it was maybe because i had both a 'player.cs' and a 'playercontroller.cs'
merged them into one script
attached to the same player
It works!
Thanks for the advice
how do I add flips to my vr game? I want them to be like the Blade & Sorcery mod, but I'm not good at coding so if somebody could help i'd appreciate it sm
i want my gun to stay rotated constaly and not once how do i fix it void OnCollisionEnter(Collision collision)
{
print(gameObject.name);
if(collision.collider.tag == "wall")
{
Gun.transform.Rotate(90f, 0, 0);
}
}
Do OnCollisionStay or set a bool to true in OnCollisionEnter
(OnCollisionEnter only runs ONCE per collision, the first frame when a collision occurs.)
I've got a bit of a tricky issue here. I have this line of code that makes my character always point towards the mouse cursor:
player.transform.rotation = Quaternion.Euler(playerBody.transform.position.x, playerBody.transform.position.y, angle);
and I am trying to make it so that on click you swing your tool, so I tried to do something like this:
if (Input.GetMouseButtonDown(0)){
player.transform.rotation = Quaternion.Euler(playerBody.transform.position.x, playerBody.transform.position.y, swingAngle);
}
and obviously, since they are both in the update function, the rotation of the second function works but immediately goes there for one frame and then goes back to the mouse cursor the next frame. Is there some way I could have it offset the angle by some amount over time to make it swing?
I could make it lerp to it and then back maybe, but I'm just not sure how to set that up.
you're overwriting the rotation. you need to stop assigning the rotation using that first line for the duration of the swing rotation
hm. so instead should I have the line that have it points toward the mouse cursor afterwards and have something inside that modifies the angle for some time when i swing instead?
also the way you have it set up now, it will only ever rotate for the swing for a single frame
i figured
so what you could do is instead of just rotating it immediately right there in the if statement, instead start a coroutine that will slerp its rotation over some desired period of time and while that coroutine is running prevent the mouse position from affecting the rotation
that was one solution I was thinking of, but I think it might teleport at the end if you move your mouse durint the swing. Another I was thinking of was to lerp the angle variable over time to be angle - swingAngle and then back to normal so that even if i move my mouse cursor during the swing it wouldnt teleport at the end
Hey i may have a problem in coding something is there anyone willing to help?
Don't ask to ask. That's a recipe for never getting an answer.
Check #854851968446365696 guidelines on how to ask questions properly
I don't quite get what your saying
The solution is not to ask to ask, but just to ask. Someone who is idling on the channel and only every now and then glances what's going on is unlikely to answer to your "asking to ask" question, but your actual problem description may pique their interest and get them to answer.
Don't ask "can anyone help me" without providing any details on the actual issue.
Okay
thx
the problem that i have an inventory in my game and it seems that if i get to the second Item in the inventory it Disables It's code i don't why it just does it with the everyitem under the first one
Are there any errors in the console when that happens?
Well, then you'll need to fix them.
Why not?
cuz they're happening because that script is being disabled
look at the very first error in the console and you'll likely find the root cause
Ill have a look
Also, there's a chance you're confusing the cause with the effect.
Good note
thx
I Have Done as you said still nothing
show the errors, starting with the first
the first is a null reference which because of the script not being enabled as i said before
but the weird one is the second
it states "UnityEngine.GameObject:SetActive(GameObject, Boolean)"
a component being disabled will not cause a NRE
what will do so is calling SetActive on a GameObject variable that is null
so show the errors and the !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 i'll show the code but please don't judge im that good with coding
https://hatebin.com/gcecgecvkl first this is the gun code and this is the error NullReferenceException: Object reference not set to an instance of an object
Booty1Shooty.Awake () (at Assets/Scripts/BootyShooty - Copy.cs:64)
your GameObject.Find call is failing causing the NullReferenceException
So how do i fix it?
avoid any of the Find methods when possible and use a better way to get a reference to the desired object
the problem is i want the script to find the object without me assigning it in the inspector so that's why im using find
and the problem with that is that the object it is trying to find does not exist
there are plenty of ways to get a reference to an object, GameObject.Find is objectively the worst
why are you avoiding inspector?
Cuz in my game this object im using the code on is not gonna be always with you you know
i can't keep setting the inspector for everybit
It doesn't need to be "with you". You can pass the references around via code.
so pick one of the many other ways to get a reference that does not rely on searching the entire scene via string comparison for a gameobject's name
yea GameObject.Find is very britle
Yea but... isnt that the whole point of this server? To help others in need whether their a newbie or the most experienced user of Unity? Like, I get there is a whole website, but seriously, not everyone has the time to sit there on a website for hours on end trying to figure out one singular issue when it could be easily solved by others helping. Also, isnt it a cardinal rule of a community to help others in need? We reached out asking for help and we bascially get slapped in the face by getting redirected to something that may not even prove useful for the current issue(s) being experienced. And all we wanted was a nitrous system and a digit only speedometer for 9 hours straight! it's called "beginners" for a reason, not "shun away people to a website who don't know how to script"......
even if we did pull a script from a youtube video it still gave errors. even after copying everything down to the T. forgive me if I sound like a jerk, but where i come from, if you come askin for help, you get it no matter who you are. Apologies in advance but with something like this.. we get stressed. :/
So GameObject.find is terrible So what do you guys prefer using?
whenever inspector is not possible pass the reference around through injecting them
https://unity.huh.how/references/simple-dependency-injection
Yes it is the whole point. And we are here to help you. No one shunned you. This is a misinterpretation of what happened
You never provided information on what you did or how we could help. Just said you wanted a "nitrous system" which is rather bespoke. Provide code and we can help correct it and find bugs.
See the #šācode-of-conduct and #854851968446365696 channels for what is expected to get help here though
this isn't the place to just get free handouts of code or have someone walk you through coding an entire mechanic one step at a time. as has already been pointed out to you, you can ask for help with your implementation to help resolve errors in your logic and exceptions and the like. but just asking for someone to give you code or to do the work for you is a waste of everyone's time, including your own.
Not everyone has the time to teach you gamedev and programming for free. If you need a private tutor there are many online services that provide it for remuneration.
Thank you very much
i appreciate the help
bro the whole interaction was "idk how to code i haven't started"
"oh thats cool that you're getting started, here are some resources to help you!"
"fuck you"
"???"
mans was just tryna help and u got mad
To be fair, it was the boyfriend that got mad for no reason. This user AT FIRST seemed understanding. This recent comment is a pretty wild take though
I'm still more than willing to help. But we haven't been given anything we can help WITH! Lol
maybe they were asking for help on how to add a script to a gameobject to start coding? I don't think it's fair to format your messages as if it's a riddle though
@mental flower if speedroute is right about what you wanted, you simply drag the script onto the gameobject (likely the car?)
Or click "add component" in the inspector of the object and type the name of the script in
nah, they were legit wanting someone to write the script for them. #archived-code-advanced message
Well, that is not help. That is work
I'm not so sure. They didn't specify what they wanted to be in the script, they just essentially said "I don't know how to code, I haven't even started"
they weren't asking anything
The car does move, and we'd need the script written in C#, with a separate script for the sound and key binding for the booster. (Left shift if anything) Is this the right place to come to?
anywayyy, could someone help me figure out why this swing animation thing isn't working?
if (Input.GetMouseButtonDown(0))
{
angle = Mathf.Lerp(angle, angle + swingAngle, swingSpeed * Time.deltaTime); // modify angle so swing will happen no matter where you move your cursor
}
player.transform.rotation = Quaternion.Euler(playerBody.transform.position.x, playerBody.transform.position.y, angle); // point towards mouse cursor
because you only lerp for a single frame which is why i suggested a coroutine earlier
Also. Never multiply the third variable in lerp by deltaTime
Nor should you use the assigned value IN the lerp
You generally want the first and second params to be unchanging
even if we did pull a script from a youtube video it still gave errors. even after copying everything down to the T.
Show tutorial, show code, show error
oh
InputGetKeyDown is not a fire and forget event
you need amount over time
Coroutines / Update loop
ohh ok, that makes more sense
Why not multiply by deltatime?
If you google wrong-lerp - ah, too slow
In short, the third parameter is not a "rate" or "speed", it is a current percentage between parameters 1 and 2
oh thanks, that explains it very nicely
@mental flower @tired pilot If either of you want to share this let me know I'd love to add it to The Counterā¢ļø
do I need a method to trigger a coroutine, or can I just call the routine by doing exampleRoutine(); at any point?
you should look up how coroutines work because you have to use StartCoroutine for it to work correctly
I've been trying, the official unity coroutines page and the one from this link ^ aren't very helpful
The docs one has example code
well i'm not about to explain every detail of how coroutines work so read the documentation for them and if you have specific questions, then you can ask them
StartCoroutine(myMethod())
But definitely look at the docs. That is just one part of what you need to know
thank you :)
Hello, is there a way to make like one-sided colliders in unity? im making a collider that would decrease the score of the player when for say, he enters a no entry zone. It works but when I enter it from the other side where entry is possible, it decreases the player's score and I want to avoid this. Is there a technique for this?
i know 2d has platform effectors which might be able to work like that. otherwise not really, you would probably want to check the direction that the player enters from manually
Hello, i'm trying to put a cloud on material but the size shredded and im trying to back it to the normal size to put it on the praticle
or you could have 2 colliders, and figure out if one is touched before the other then do this bc it wou8ld mean it came from this direction
if one was a bool set to true and then passed in the second "do this if bool is true" would be easier
do i can back my material to the average size
or the default size
is there any way that I can access the local variables from the update function in a script outside of the function as it updates?
no
local variables are only accessible within the scope they are declared in. so variables declared inside of Update cannot be access outside of Update because they simply do not exist there
use fields (class-level variables) if you want to access them in other objects
alternatively you can pass data as a parameter to a method if you just need to access something when you call a specific method
if you find a better method let me know, that seems like something i should remember later on
Is it 2D game or 3D game? Cuz I do believe one sided collider exists in 2D game
yea its a mech for platformers
Ye, i just forgot the name
that would be the platform effector i already mentioned
i know its called something... it effects it... hmmm
you didn't seem very confident when you said it
you definitely put an italicized might
i am not confident that it can be used for that specifically. but i am confident that it is called platform effector
lol its on the tip of my tonguee
Isn't platform effector used like escalator-ish ways?
I might be wrong, haven't used in while
you should check your sources on that
I think I'm gonna like it here.
trying to mess with boxfriend failed, hes unphased
Who's messing? Just clearing my doubts 
Nvm yes it's possible for one way
I mistook platform effector for surface effector
another way you could check is just check the velocity.x of the player or wtv at the time it hits the collider and if its positive then add to the counter and if its negative then you dont add to the counter maybe
i don't know what you mean by "escalator-ish" but it's used to provide one way collisions for platforming, like when mario jumps up through a platform to land on top of it
@slender nymph mistook cuz of similar names
Mb
however i am not 100% certain if that works at all for trigger colliders and whether it would prevent the OnTriggerEnter2D message from being sent
especially since trigger colliders do not produce collisions
does anyone know about particle thing
What do you mean? The particle system? What about it?
this is a code channel, and no offense but your messages made very little sense. possibly due to a very bad translator
that's fine!
as you guys out of questions will you look at my problem (dont mean to be rude)
how do you even access the returned value(s???) of the function?
just mention put it on a parameeter if it asks the same data type or assign it to a variable if both are the same data type
there are beginner c# courses pinned in this channel if you do not know how to use methods that return values
variable = Method()
variable.accessedThing
ty ā¤ļø
dude that's the same answer ;c
š¦
That was incomprehensible honestly. I had no idea what you were trying to say
you are using a horrible translator that makes it impossible to understand the point you are trying to make. try seeking a different translator
fam im new to this stuff and im sure your explanation would make sense to someone experienced who knows most the terms but I just wasnt sure
I have a decade of experience and it made no sense at all
then speak my language i can help you
right so in my situation I don't think I actually do need to return anything from the coroutine, I just need the rotation value to lerp there and back, but because I can't access the local variables from the update function, I can't just put the line of code I normally would there. I could just set up the same local variables that I did in the update function, but then that creates the same issue, that the animation will be overlapped!
i'm sorry, i didn't know that my english is that bad.. i was just trying to help and it's okay i understand our friend
i will try to practice english more and im not using translator XD
ay man its okay, I was able to somewhat understand it afterwards, I do see now that you said that you can assign it to a variable
ty for trying to help
you should consider using one. this isn't a dig at your english skills or anything, i know learning another language is hard. it's just that your messages are nearly incomprehensible and you would be much better off if you used a translator so that the people in this discord actually understand what you are trying to say so that you can not only receive help, but help others as well
if anyone is free i need a bit of help with a bit of my code... My error is Assets\Scripts\GunSystem.cs(24,12): error CS0246: The type or namespace name 'CamShake' could not be found
and dont give that link to that help tab thing i have it set up i need real people help
start by configuring your !IDE
after that make sure that you have a type called CamShake
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
⢠Other/None
i just said i have that set up
well you don't
i have followed that document, multiple times
like your screenshot very clearly demonstrates you do not have proper syntax highlighting or errors underlined
so you either missed something or you need to restart your pc and/or regenerate project files
but if you cannot get vs code configured, then consider switching to a real ide like visual studio which is easier to configure and much less likely to randomly break
I think that might be a custom coloring scheme
Because it seems to recognize references.
it highlights float but not the other types and does not provide errors underlined
Ah, true that.
What ide is that anyway? Vs or vs code?
vs code
it's vs code. vs doesn't do code lens for fields
Good luck configuring it then.š
Hi, in my game, I have a total of four scenes. When I play the third scene by itself, I can see the UI text when I lose and win. However, after I connected the scenes and start from the first one and get to the third scene, the UI text becomes hidden although I could see a panel in the same canvas. I don't know what the issue is.
Actually nvm I fixed it
hey guys, please help me with this
You'll need to provide some context...
close your project, make sure the Temp folder has been deleted, if not delete it, open project
How to delete the temp folders
Windows File Explorer
I don't know if this is where to mention this, but there is a bug with my unity pathway (Unity Essentials) where the first quiz isn't counting. Any idea what I can do to fix it?
this is a code channel. not really relevant here.
you could try signing out then back in and see if that works though or try another browser
You right, my bad. Ill try, thank you
is there a way i can get a bool value for an animation like while the player is running i want a bool value that animation is still playing = true
what would the purpose of that be? I ask because that is typically an xy problem
im not sure if thats a thing, but you can create your own method and set it to run at specific points in an animation and set a custom bool's value then call that value
i see how you might think this is, but they might just not be familiar with specific calls. if someone asked how to find a gameobject in a scene without assigning it manually, i wouldnt assume that thats an xy problem, but instead just a person whos unfamiliar with specific unity functionalities
checking if an animation is playing is usually the attempted solution to finding out when an animation has completed. so yes, that is usually an XY problem and the typical solution is to use animation events
I'm starting to get a fair amount of singleton manager type objects (SFX manager, enemy manager, projectile manager) Is this bad?
I feel like there are a lot of systems that need to connect to a more central system
And my go-to solution has been to just make a manager, but it feels dirty
I thought the point of making a manager was so that it doesn't feel dirty...
It felt good in the moment but now that I have like 6 of them and am looking at my 7th it feels less so
Hey I cleared most of the files in Temp, the rest is being used
Did you not close your project?
It should work now right ?
I did
Wait just to be clear, I typed "%temp%" in the Run box.
And then I deleted files there
is that right ?
uh oh
Oh ...
Sh*t
Sounds like something's wrong
you're probably okay, like 90%
What about the other 10% ?
Probably best to reboot the PC just to be on the safe side
hi, i have make animation and now when i jump we see the knee of my character, can i do something to make my camera follow like the head of my character ??
this is a code channel
where i can ask this??
is_grounded = Physics.Raycast(transform.position,Vector3.down,playerHeight * 0.5f + 0.2f, ground);
if(!is_grounded)
{
can_roll=false;
}
why is the is ground not working?
this has troubleshooting steps for physics queries like raycasts: https://unity.huh.how/physics-queries
but either your raycast is not as long as you think it is, it isn't in the position you think it is, or there is nothing in its path on a layer contained your ground layer mask
no its like
i m on a terrain
sometimes the ray cast is hitting
somtime it doesnt
i assume it is cuz of the ununiform nature of the terrain
i tried using the ongizmos func but i cant set a specific length to the drawn ray
although you probably want a query that has some volume like an overlapbox or something instead of just a tiny little raycast
yea that would be better
let me try using checksphere ig
yea worked
thanks
https://paste.ofcode.org/32YtDjRyPwYpJrmn9YSYXgw I am working on a dash and i have a problem, here where after adding the && canDash && !dashed it is no longer working anymore
candash is false and will always be false
I dont see how, it starts off as true, then is set to false when dashing then set back to true at the end of the coroutine isnt it?
how is this set to true?
thanks
Hey guys, is there way to compare 2 game objects ?
Sure, the same way as you compare any other variable.
public GameObject A;
public GameObject B;
if(A == B) {
Debug.Log("I'm ugly");
}
Like this ?
hello guys where do i start learning coding?
!learn
:teacher: Unity Learn ā
Over 750 hours of free live and on-demand learning content for all levels of experience!
Honestly, the Pathways are the best, start with the Unity Essentials.
Hey! So I'm trying to make a grid-like movement system in 3D, but it's not really going according to plan...
https://gyazo.com/4359c75f70a90452372e1dc19e3df2f6
This is the result I'm getting, now I know that the reason some of the movement in this happens is because the targetPos is just 0,0,0 + whatever is pressed, but I have no idea how to fix this to make it from the current position or anything like that. Am I approaching this whole system incorrectly? If so, what should I do instead?
every single movement you see in this is just 1 key press btw, I'm not pressing both D and S to go from the top tile to the right one, just D.
is there a way i can shoot a raycast from the center of my camera?
https://docs.unity3d.com/ScriptReference/Camera.ViewportPointToRay.html This with (0.5, 0.5)
Or just make a ray with camera position and camera forward
It's unclear how you want this to work?
What's the goal
if (input != Vector3.zero)
{
var targetPos = transform.position + input:
StartCoroutine(Move(targetPos));
}```
Don't you just want this @fossil gulch ?
Thanks for the response. I think so, yes.
https://gdl.space/anogolisuj.cs
I'm currently trying to incorporate something like what you've written, however I'm struggling with this switch...
The one in FixedUpdate
It keeps returning "Object reference not set to an instance of an object"
I thought that Event.current.keyCode was the correct thing to use for this switch, but I think I'm mistaken...
I'm unable to find anything else that could work by myself
scrap that, I googled it and switches are not the way to go for this.
you can just await the coroutine until thenext action is performed
or do a queue of inputs if you wanna go that way
https://gdl.space/wevusonuha.cs
This revamped script works perfectly fine, I just have one issue with it. I sometimes have to press a button 20+ times for it to actually register it as a button press, even when isMoving is false.
https://gyazo.com/012c7ce78217fa8b650fc39d64001986
keep input in update
if it is moving in fixedupdate
and as I was saying, you can probably queue the last input so they will instantly respond to it when they get to their destination
it's just caching the input someway instead of discarding it when the player is in an action. You see it usually done in networked games to combat latency
I'm thinking of storing the queued input in an array, working on it right now
Hi all, Im using the Unity Splines in-built component, and am able to move amy player along the spline, but I wanted to make my player object do a jump over an obstacle when key is pressed, but Im stuck because the character just keeps on moving ahead, instead of completing the jump action.
post code that moves the player
You would make the jump curve relative to the spline
Hey hey!
I am trying to do a simple menu for my game. However, when following a tutorial I came out with a question, how do I check a scene index? How do I know that my "Game Scene" is index 1?
File>Build Settings>Scenes In Build
Thanks! ā¤ļø
Hey my friend
Im using SplineAnimate component on the player to move it along, so the player is usually never touching the groundlayer, just floating a little bit above it.
void Start()
{
rb = GetComponent<Rigidbody>();
}
private void Update()
{
// Jump when space key is pressed
if (Input.GetKeyDown(KeyCode.Space) && jumpCooldownTimer <= 0)
{
rb.AddForce(transform.up * jumpForce, ForceMode.Impulse);
jumpCooldownTimer = jumpCooldown;
}
// Decrease jump cooldown timer
if (jumpCooldownTimer > 0)
jumpCooldownTimer -= Time.deltaTime;
}
THis is the code that makes it jump, which works nicely when I am not using SplineAnimate, but it struggles when SplineAnimate is active.
All I want to do is get an effect like something we used to see in the iTween library.
SplineAnimate is built in?
Yes
and it works great to move the character along the spline, but it prevents the character from jumping, etc. via RigidBody because two forces are acting on it at the same time (probably).
i doubt it uses forces to move along the spline
most likely it simply sets transform.position
or MovePosition
rigidbodies canāt be moved by forces, but also be told to follow a specific trajectory at the same time. the two requests are mutually exclusive
itās like calculating two different positions of where you want it to go. you can only pick one
there are several ways i can think of doing this
- animate an empty root transform along the spline, and animate the player model locally (jump) while its parented
- animate a completely separate transform, and write code that follows that transform
second will keep the whole thing physical
when I do this sort of thing, I keep a ground-lock variable
itās a variable to tell me if my character is supposed to ignore all other forces and try to move along a ground slope
i think you can make 1 also fully physical
the way I describe no. Because you always get vertical force to try to conform to the ground. you need to be able to disable that to jump
and turn it back on when you touch ground in a groundable state
i hope that makes sense, even tho it makes the machine state more complex
why not? you add up all the vectors, some controllers use this approach
separate the vectors, manage influence/weight, use counter force, i seen it done well
you cannot because if you tell your RB āapply force to conform to this floorā, and you also apply force to jump, you will get really weird behaviour
you need to really shut off the force that snaps you to the spline so you can force only one to happen at a time
otherwise, you are applying counterforce to cancel out the force you added, conditionally
which is the same thing as what I said, but with more steps, because you add the wrong force, then later need to know what it was you added to properly counter it.
Yeah, and I really like the SplineAnimate component and it has all the fun ease-in, ease out, ping pong, etc. but it completely ignores the groundLayer, which -- I think -- I will probably need to apply the force for the jump.
alos, the splienanimate rotates the object in the direction of the spline.
i feel like player movement just isnāt the case where you want to use this component
probably a projectile, or a bat, or something that just isnāt grounded
so you donāt have two people grabbing the same steering wheel
how do you think games like Inside did it?
idk that game
if you are in 3D, I would try KCC first tbh
it has a lot of the stairs and slopes and camera already figured out
I wonder how the iTween guys did it many yrs ago?
A simple, powerful and easy to use animation system for Unity developed by Bob Berkebile of Pixelplacement. Focusing on the established solutions and frameworks of projects such as TweenLite, Tweener, and other tweening systems, iTween is a battle-tested solution for streamlining production in the Unity environment.
at the end of the day, you need to calculate where your character needs to be, and where it is going next
Look at tht Path constrained character example.
not supported on mobile lol
if I had to do it, whenevr I get a jump command, I would put a hard stop to current pathing, and totally recalculate the next destination
you basically need to change your trajectory from one frame to the next
idk. physics is hard, and idk how much i trust tweening for it
as opposed to clearly defined forces that calculate next proposed position/vel solely from the current frameās position/velocity
a proper spline requires using multiple frames of information, and physics information can dramatically alter what you are doing one frame to the next. so i find trying to juggle old data to not be worth it
i think its possible to keep character locked to a path, if you only need left/right movement along that path, you will need to sample the point periodically, generate the movement vector by looking ahead on the spline, and compensating with forces only perpendicular to the spline on 2 horizontal axis
while keeping it all physical
yeah. lot of work
a lot of work that I feel is inappropriate for #š»ācode-beginner
but it's fun. and I thank you all for your suggestions, some interesting things to learn.
so I will stop using SplineAnimate and then work from the grounded work, then rigidbody to jump around.
i didnt use that package (?) but i guess you first build the spline itself using objects and SplineAnimate is just additional component?
yes, Spline is built-in, and SplineAnimate is separate component that I've added to the player to follow the spline, so I can remove that, and get the raw spline points, and follow it along like waypoints.
iām just saying this is a more difficult problem than #š»ācode-beginner
Hey all. I am again here with the same problem. I have a door prefab. This door teleports my player to the gizmo when activated. It works all fine until I put another door. The second door (on the left) teleports my player to the first door's destination point. I drag the destination transform in the inspector.
and this here is the code that is responsible for teleportation
https://hatebin.com/jdgjovfruf
if both objects do EventManager.OnSoftLoadStart and both coroutines are started which one takes priority?
am i correct to assume that both teleporters are starting their coroutines at the same time?
since they both sub to the same event
Yes that is the case I believe
They only work when interacted though. So When I go for the second door shouldn't it use its own destination?
no its undefined, since OnEnable order is undefined
ah okay
So when I go to the second door. It acts like this because of subscribing the same event?
I am just invoking the softloadstart event on interact.
then thats the issue
you designed it so that only one teleport can be enabled at a time
otherwise it will be random
https://hatebin.com/smrshwmitp this is where it happens
hmm so I can just put the teleports individually OnInteracts without utilizing events
So they both call them seperately without doing the same thing
typically people use IInteractable interface for this kind of thing
or something similar
less optimal imo, but serves the same purpose
All right. Thanks a lot.
you can, in theory pass the context (teleport that was interacted with) in the event payload
as an argument you mean?
its just a less obvious and more convoluted way that solves it in xyproblem manner
yes
Hey i tried working with the Scriptable Render Pipeline and created a Custom Renderer Feature that should render the Depth-Texture to the Screen (here Source) but somehow this doesn't seem to work. Any ideas why or do you have any good documentation about Renderer Features (becuase i haven`t found any good so far) https://pastebin.com/UFzaUngi
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.
Why is Rigidbody2D not turning blue?
IDE isnāt configured properly
!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
⢠Other/None
try rebuilding solution
sometimes IDE can be properly configured, but weirdly gives up if it canāt build the solution properly.
i see, so do i click a certain one or can i choose either
first follow the links in the bot. then try rebuild solution if that doesnāt work
kk
dont forget to show hidden folders in your project root and nuke .vs folder
im a little confused
where does it say "edit"
Why are you in the hub?
thatās unity, not VS
ohhh
visual studio and unity are two different programs
VS is an IDE for making C# code, which may or may not be going into Unity.
@gray rivet Since you said edit, I assume you're looking for the external tools menu? That is in the Unity Editor, not the Hub
if VS is not configued properly, you need to fix VS
so this is what i installed?
I'm having an issue with my scroll wheel inventory system where i can scroll between 2 items fine but when i drop one and try to scroll to the other, the other doesnt show up
script - https://gdl.space/eqepaquboh.cs
I guess so, yes. Not sure what that has to do with this though
it says to go into the unity editor
Yeah, of the project you are working on. Just open your project
I need to rotate characters at random direction at random time and move towards it. how to do that?
yep, done
This should be causing an infinite loop that will freeze your program
Well, I guess it would just use the last Time.deltaTime
It would still complete all in one frame
The frame cannot complete until update does, which cannot complete until the entire while loop does
Close vs and click regenerate project files
bump
hi! my animation wont play even though the animator says it is?
void Update() {
if (Input.GetMouseButton(0)) {
// Debug.Log("CLICKING");
anim.SetTrigger("Active");
}
Please help idk what i did wrong
that sounds like a trigger to go from atk to still
yeah i have that but the attack animation never plays
i turned on the clicking debu log and the animation never plays
bbuummpp
how the f does weaponSlots[targetSlot] end up out of the bounds of the weaponSlots array?
If weaponSlots has 0 elements
it has 4
i have break points, when my code hits the break points, i checked all the values. weaponSlots was fine
Then the error happened a different time the code ran
probably another copy of the script where weaponSlots is empty
Debug.Log will be easier here than a breakpoint
Show code for SwitchWeapon
Can you show the full stack trace?
void SwitchWeapon(int targetSlotIndex)
{
if (weaponSlots[targetSlotIndex] == null || weaponSlots[targetSlotIndex].isEmpty)
return;//dont do anything if the target slot is empty or just dosnt exist
if (!SelectedSlot.isEmpty)
{
SelectedSlot.weapon.PrimaryAttackInputCanceled(default); //Cancel the shooting on the active weapon before switching
SelectedSlot.weapon.gameObject.SetActive(false); //Deactivate the current weapon
}
//change the weapon
selectedSlotIndex = targetSlotIndex;
weaponSlots[targetSlotIndex].weapon.gameObject.SetActive(true);
weaponSlots[targetSlotIndex].weapon.DrawWeapon();
UpdateWeaponIcons();
}```
bump
while building the game this error appeared, any idea how to fix it?
Assets\Scripts\DeathMenu.cs(3,19): error CS0234: The type or namespace name 'SearchService' does not exist in the namespace 'UnityEditor' (are you missing an assembly reference?)
using System.Collections;
using System.Collections.Generic;
using UnityEditor.SearchService;
using UnityEngine;
using UnityEngine.SceneManagement;
public class DeathMenu : MonoBehaviour
{
public GameObject canva;
void Awake(){
Time.timeScale = 1;
}
void Update(){
if (IsAlive()){
canva.SetActive(false);
} else{
canva.SetActive(true);
Time.timeScale = 0;
}
}
bool IsAlive(){
if(GameObject.Find("Player")){
return true;
} else{
return false;
}
}
public void RetryGameButton(){
Time.timeScale = 1;
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}
public void MainMenuButton(){
SceneManager.LoadScene(0);
}
}
private void FixedUpdate()
{
if (!childOverlaps)
{
UpdateMom();
}
}
private void MoveLeft()
{
partTransform.transform.position = new Vector3(transform.position.x - 0.4505f, transform.position.y, transform.position.z);
}
private void MoveRight()
{
partTransform.transform.position = new Vector3(transform.position.x + 0.4505f, transform.position.y, transform.position.z);
}
private void OnTriggerEnter2D(Collider2D other)
{
if(other.transform.tag == "SideCheck")
{
print("Entered");
childOverlaps = true;
MoveRight();
}
}
private void OnTriggerExit2D(Collider2D collision)
{
if (collision.transform.tag == "SideCheck")
{
print("Exited");
childOverlaps = false;
}
}
Iam programming a tetris like game and I have trouble with coding the boundaries... UpdateMom() Updates the Renderer of the Part(Its called like this because the renderer is on the parents Part) But if I move into the boundary and the trigger goes of the Renderer is allready clipping over the boundary and then snaps back
I would appreciate it if smb could look into that and If needed I can send a video clip of it
why do you include the namespace
you cant use UnityEditor in builds
this too
It currently works only for the left boundary that is snaps back
if you really need it you can do
#if UNITY_EDITOR
using UnityEditor.SearchService;
#endif
I believe I don't need it at all, no Idea why it is there
well then just delete it
maybe it was intellisense
- What do u mean by "namespace"?
all these using things are called namespaces
np bro
i dont get it
Wait I send a video clip
It snaps back and I dont want that therefore I implementet "UpdateMom()" This teleports the renderer onto the current position but it shouldnt go to the position if the hitbox which searches for boundaries has found one
You cannot use anything in the UnityEditor namespace in a build
Just curious... Why?
Because in the build, you aren't running it in the editor
youre making this a little more complicated than it needs to be
there's no editor to run editor code in
Yes I thought of that too but then rotations would make it worse
why?
you can still rotate it but you have to handle the math...
it shouldnt be too much more to rotate it
ok I will try it
But then I would have to make a big array and set all rotations of the parts
that would take hours
use a 2d array
yes i meant 2d
using grid system should be much easier
i have no idea how to detect if a line if full and cutting the collider in physics system
As I said its not exactly like tetris it would work in my game
anyway to answer your original question the problem is youre setting the position then checking if its out of bounds then you move it again
No I check it every frame with OnTriggerEnter
i believe the trigger doesnt get called until the next frame
ok but then how do i fix this
you change the position in frame 1, in frame 2 the move function is called
you need to check if its out of bounds first
which is why i recommended the grid system
i dont think you can make it work easily with your current system
maybe a work around would be to check the width o f the shape and calculate if its position is past the bounds position
quick fix i guess
Rotation would again destroy this concept
why
so take the left most and right most squares and see if they are out of bounds
this isnt gonna work with physics so just scrap that
you dont have to do the grid system but you can try this
what do you mean by "the left most and right most squares"?
Yo, I just made my first game! It looks like shit. However, thanks for the aid guys ā¤ļø
if the position of these are past the blue line dont move it
theres a function like get position at corners or something
no, no hitboxes no physics
just from the renderer?
lets say position of lines is(-4,0) (4,0)
checking the (logical) position of each block of the falling tile
if I had a dime for every tetris tutorial that used colliders for their game i'd be rich
before you move or rotate the item, check if that position will be past the bounds of the lines
Iam not doing a tutorial.. I wish I would
yeah that seems much simpler then I would have to track the rotation but that should be easy
thank you
I've got 3D tetris code that doesn't use colliders
for rotation you could get the top most square and rotate it about the origin then check the bounds
how would i check if a certain thing is in the Hierarchy with code?
simple way could be FindFirstObjectByType<T>
I think I missunderstood sth this feels illegal haha
private void CheckRight(int curr)
{
float[] positions = { transform.position.x + 0.4505f, transform.position.y};
for (int i = 0; i < positions.Length; i++)
{
square_pos[curr, i] = positions[i];
}
}
private void CheckLeft(int curr)
{
float[] positions = { transform.position.x - 0.4505f, transform.position.y };
for (int i = 0; i < positions.Length; i++)
{
square_pos[curr, i] = positions[i];
}
}
private void CheckDown(int curr)
{
float[] positions = { transform.position.x, transform.position.y - 0.4505f};
for (int i = 0; i < positions.Length; i++)
{
square_pos[curr, i] = positions[i];
}
}
private void CheckHere(int curr)
{
float[] positions = { transform.position.x, transform.position.y};
for (int i = 0; i < positions.Length; i++)
{
square_pos[curr, i] = positions[i];
}
}
private void CalculateSquares()
{
if(this_part == Parts.t_block)
{
CheckRight(0);
CheckLeft(1);
CheckDown(2);
CheckHere(3);
}
}
and thats only one part one rotation every part has 4
it writes down the coordinates of every square
your grabage collector:
there is s struct called vector2
The fun thing about Vectors in Unity is you can do this:
Vector3 myV3 = new(4, 5, 6);
for (int i = 0; i < 3; i++) {
print(myV3[i]);
}```
although I'm not really following what this code is doing
ok so i think your way is a little inefficient
Ok explanation: I want to make a tetris like game and want to check if the block would be outside of the boundaries if I move it therefore I need to know every position of every square of every part so even if I rotate I can check If its outside and this should calculate every square pos of the T-Block in tetris
Hey! With the help of some friends I was able to get the movement working how I want it to. This is what it currently looks like
https://gyazo.com/7c20d9784c71d11181382bdda3b5ca18
https://gdl.space/besajiruyu.cs
That's my script.
I just seem to be stumbling upon one small issue, and that is that the animation is glitching out because the player stops on the nodes/points of the grid for a split second. I have no idea how to fix this...
Something is wrong with the synthax guys ?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CustomGravity : MonoBehaviour
{
// Update is called once per frame
void Update()
{
AddForce(Vector3(0,0,9800), ForceMode.Acceleration);
}
}```
yes, AddForce need a Rigidbody instance to work on
https://gyazo.com/c370d6a01ca7ad15351e0c1e83187d22
The glitching is more noticable when walking in a straight line.
It is meant to move on a grid?
yes. Give me a second, I've hidden the grid points. I'll show them
your animation state is changing to movement -> idle -> movement
so if you dont want the hiccup then you need logic that bypasses the idle if you've got continuous input
@merry spade lets say you have 3 square wide object and each square is 1 distance, origin is in the middle. when this object is spawned we can take the distance from the origin to end of the object. in this case its 1.5. now when we try to move left we will calculate our new distance and subtract 1.5 from it.
Ah, I see
please ?
you're not adding force to anything
yeah but if its rotated its only 0.5 distance
ping to reply please š
oh, yeah, sure, I'm here purely for your benefit
could checking if there's inputs in the queue work?
So like, If there's a queue then don't set the forward animation float to 0
yes thats right
It just seems that the animation is not looping correctly
are these trigger animations or bool animations
because if it's a bool you'd just loop it ^
yeah but youre right thats much easier
I will try it again
to be honest I have no clue
Got this
I didn't make them, they're placeholders
well if they are bools then you dont want to flip them off if you're continuing in a direction
new Vector3
yes in that case I only have to write down the distances for every rotation that should be simpler
i have a game where you can pick up things. but when you go near the wall, the object goes through it. Does anyone have a script or any ideas that makes it so it collides with the walls?
Is there like a self alternative in c# ?
this
and it is still wrong, monobehaviour is not rb
!ide
this
!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
⢠Other/None
also this
you dont really need this. in c# unlike python
configureyour IDE first
no
lol
then you will get no help here #šācode-of-conduct
Explain how did i got help ?
Im sorry ?
You're being an ignorant bastard
set up your ide
You won't get help wihtout setting your ide first
if you refuse I have no issue contacting Mod about it
Excusse me ?
they are spending their time to help you and this what they get? cringe...
Technically they broke the rules by answering someone with an unconfigured !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
⢠Other/None
forgive me for being direct
Now that we know, it won't happen again
Didid i say something wrong ? English is not my maiin language
language doesnt matter
you have to configure your IDE to be able to spot errors in your code more easily. Without it, helping you is more or less impossible.
You literally have compile errors, and that is part of the solution
Then just explain why setting up the ide, you never said how it gonna help
firstly so you can avoid compile errors such as this obvious one you wrote
You said it to late
Im sorry if i don't know c# alot
But it's not a reason to insult me of b word
well more reason to use a configured IDE
I still don't really understand
I configurated it but it doessn't work
i have my doubts you did.
show that its configured
I've tried checking if the queue is empty, adding a small delay before ending the MoveRoutine, etc. And It's still glitching out. I'm really bad with animation, So I struggle to understand what is causing the issue
This tho
!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
⢠Other/None
it says right there that its disabled
It's written in little couldn't see it
You were being disrespectful to those trying to help you. I was just pointing that out.
that's not an ide. Unity pairs with VS Code, but its a challenge to setup
it's just a statemachine, and if the animation is going back to idle then that's a problem if you want to continuously loop.
By insulting me ? I was just confused and didn't (wanted) to hurt anybody but i forgive it
of course there could be other issues but id make sure that's working first
not true not anymore at least
ah I see
also there are more steps for VSCode did you do all of them
and yes ur running it in Restricted mode it wont work
VS Code is an ide? I guess it has highlighting, debugger and intellisense...
well I think the best way to go about this is just not stopping the movement coroutine at all until the player is done with their inputs, (the player stops for a split second when moving to the TargetPosition) because it also causes my shadow (gameobject) underneath to glitch out.
how do i disabled that ?
I was mainly talking about the setting up part.
Yeah its not in the technical term an IDE but with extensions it pretty much is..
first you should be opening the scripts from inside Unity
that generally opens the editor not in Restricted mode
but idk how to do this, the only idea I'd have would be giving the player full control but that kind of defeats the points of the grid system
Ok i found i
I wish unity had a built-in code editor
Just like godot 
hell naw
wasting more disk space, I like
Ahhh the good old godot days(litterally 5 days ago)
whats the problem
oh yeah, we really need an IDE designed and developed by game devs
Unity hasn't even made their own VSCode plugin , I would not trust them making an IDE
Say I have several panels in canvas. How can I choose which canvasgroup to play with its alpha? Without dragging them on inspector.
Tags or Component search
or Simple Dependency inject
All right. Thanks navarone.
There used to be a thing called MonoDevelop which was built into Unity I think?
It still exists
no MonoDevelop is a sepearate app
well, in the video I showed there is no problem. Here you can see the actual problem:
https://gyazo.com/ebd9006151dc7be3f8e660c7667034de
See how the character is glitching out? The reason is because the player stops moving for a split second before they continue moving, I think this has to do with my queue system. I have no idea how to fix it.
Any ideas? anyone?
looks like something is wrong with your animations or transitions between clips
if it has something to do with your queue system then we cant help cause we dont know what that is
It's in my code. I can explain it if you want
The problem is that the animation float state thingy "forward" returns to 0 at the end of the MoveRoutine while I still have moves queued
we'd have to see the !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.
oh ops
I think you may be running the coroutine multuple times
I tried doing
animator.SetFloat("forward", 1);
else
animator.SetFloat("forward", 0);
but it doesn't work, as, for some reason, the queue is empty
but it's obviously not, seeing as the queue is working how it should
Anyways, the way I thought about fixing this was by not stopping on the next grid spot at all while another move is queued
Id check the coroutines first
could make it like snake and just run in the direction until you queue another direction
;)
store it inside a coroutine variable, make sure u dont run it multiple times
start new Coroutine wont stop previous so might cause issues
i cant read it all right right now but peek the queue and see if the vector has changed, if not dont do anything
but that'd be mad annoying... you'd have to manually stop the player
1s I can show you guys what the issue is
actually not peek just get the dequeue vector
Look at the rigidbody's speed
property
it goes back to 0 when touching the next grid point
which makes sense
because when a move is queued it's making 2 movements, not 1 (It's running the MoveRoutine coroutine twice)
And because the coroutine ends, the float also returns back to 0
so how can I make it move 2 grid points when holding a button and not stop on the first one..... that's where I'm stuck
the goal is to just make movement like an old gameboy game but in 3d
ok im on break lemme check the code
ok so
you can set Forward to true, set isMoving = true, start moving, once you reach destination check if key is still down, if true just continue queueing another move
if im missing something lmk
hmm let me try that
thanks
small problem
no clue how to do that
I've been looking through my code to see where I could put the check
1 sec
but the new movedirection is being selected at the top, and just replaying the coroutine again would lead to the same issue as I'm currently having
private void CheckQueue()
{
float horizontalInput = Input.GetAxisRaw("Horizontal");
if (horizontalInput != 0f || verticalInput != 0f)
{
Vector3 direction = new Vector3(horizontalInput, 0f, verticalInput);
inputQueue.Enqueue(direction);
RotateCharacter(direction);
return;
}
transform.position = targetPos;
isMoving = false;
if (inputQueue.Count == 0)
animator.SetFloat("forward", 0);
}
sorry for formatting lol
you can put that after your while loop in in MoveRoutine
i think that should work or something similar
hi, i try to make a link between two script but he tell me this:
i've done a serializerd fied but it don't work
Then something on that line is null but you're trying to use it anyway
What's that line?
I think I destroyed my Unity project when I was deleting files in my C drive.
What are the consequences of deleting the Library folder?
Is there a quick way to repair project?
This is a class. Where do you assign a value to the variable PickupItem in your Animation Script?
did you drag drop PickupItem
The consequences of deleting the Library folder is the next time you start up it will take a while
That's it
i need to asign a value into my 2 script??
You have to tell it which PickUpItem you want the variable PickupItem to hold
Other than the fact that this is a function and can't be inside of MoveRoutine, some variables don't exist (I've made them) and it doesn't fix anything. (Sorry if that sounds rude I didn't mean it in a rude way :( )
Well is it worth deleting trying to recover a corrupt project?
Do you have any other suggestions?
@polar acorn
I have no idea what "corrupt project" means, it could be many things. But deleting the Library can't make anything worse
It's purely ephemeral data and gets rebuilt if it doesn't exist on next startup
my bad i copy pasted some things from your other code
remove the verticalinput part and RotateCharacter
what else is wrong
The error I am receiving is There were problems loading project Assembly-CSharp.csproj There's nothing wrong with dotnet and I can make/open other Unity projects.
What if I just deleted the .csproj files?
how i can do that??
you should be able to call that function from inside the coroutine
Usually by dragging it in
The thing I need is to check whether the same key is still being held down that caused the initial movement, and if it is, continue moving without stopping, at the end of the Move Coroutine. (I just don't know how to do this) :d
Not much will happen. csproj files are for opening in Visual Studio, so you can still use any other code editor
Unity will regenerate the csproj file anyway
Is there an easy way to rebuild my project without having to fuck around?
and i can't drag the scri^pt
There's nothing wrong with "my end" of the project. I just deleted a shit tonne of files when I was drunk without thinking.
he reconize variable but they don't work
Realistically, Assets and Packages are all I need, right?
try it and see
That is not concrete.
so basically define a variable called lastInput or whatever. after inputQueue.Enqueue set lastInput to the key that caused the movement. now in move routine, once the loop is finished youll check the input again. compare the new input to lastInput. if its the same queue another forward, if not stop the movement
the problem is that queueing another movement would result in the same problem, as the player still stops upon reaching the grid point (as the targetPosition is reached)
the queue exists so that, if a button is held down, it doesn't stop upon reaching the next grid point and that you'd have to press the movement button again
sorry i didnt get it
and you didnt use Version Control why?
I never implied I was deleting any project files.
I thrashed my C drive from Microsoft bloatware(TM)
cant you scrap the queue check input, start animation/movement, set isMoving true, if input is received while isMoving is true ignore it, once MoveRoutine finishes check input again, if its still the same dont do anything and let movement continue, if its different or none change/stop movement?
doesnt make my statement any less valid
Maybe a few extra files were lost in the process, you can't help casualties.
realistically, all you need is the assets folder
You still need project settings, n manifest
What is the path to: things like Project settings and my URP asset settings?
Exactly what I'm after
Delete the csproj file and click regenerate project files inside the external tools menu š¤·āāļø
Edit: Woah. There was a lot said after that. My bad
@rich adder Granted, I would still like to know the path.
the path is the root of the project
ProjectRoot/ ProjectSettings
etc.
Oh cool, thanks
i just reread it and it doesnt seem like the queue is doing anything that cant be done with the isMoving bool
URP settings are typically Scriptable Objects so they exist in the Assets folder
Hi, why my animation event not firing? I'm adding an animation event at runtime. It is expected to be fired at the end of the animation clip. This is my code:
private void DefineAnimationClipEvent()
{
AnimationClip standUpClip = _animator.runtimeAnimatorController.animationClips.First(x => x.name == "StandUp");
if (standUpClip.events == null)
{
AnimationEvent standUpDoneEvent = new AnimationEvent();
standUpDoneEvent.functionName = "StandUpDoneAnimationEvent";
standUpDoneEvent.time = standUpClip.length;
standUpClip.AddEvent(standUpDoneEvent);
}
}
private void StandUpDoneAnimationEvent()
{
_npcBehaviorMode.NPCBehaviorMode = NPCBehaviorModeEnum.PathAction;
Debug.Log("StandUpDoneAnimationEvent");
}
I can just copy that entire folder and paste over once I make a new project, right? @rich adder
I would export project as Unity packages and click (include dependencies)
Great idea.
Maybe standUpClip.events is not null, but empty (like a list with 0 elements in it would be; its Count would be 0)?
Make sure the code inside the if statement is running by debugging
I want to try delete the csproj files first and regenerate them before I start a new project. I know sln is a solution file, but can this also be regenerated?
@rich adder
yes both can be deleted and regenerated
the .sln and .csproj files are regenerated every time you open your project
@languid spire Then clearly I have other issues with my project then?
Also whilst I'm here, how do I change a material preset for TMP during runtime?
https://forum.unity.com/threads/getting-setting-tmp-material-presets-via-script.923501/
first result
Nah doesn't work
wdym "Doesn't work" ?
My bad, you are right. standUpClip.events is not null, it just empty.
The default material preset persists.
hmm worked for me last time.. weird. Gonan try it again
I tried doing what you said but I just can't get it working at all
ok gimme a minute ill show you what i mean
does that work
that's all?
the player is still technically stopping on the grid points, but at least the animation isn't glitching out anymore
wait let me show you
https://gyazo.com/47fedb163f0d8491fe7d953b3584b0a2
Look at the shadow
under the player
you can see that the player is still stopping by the shadow stopping for a split second
but that is something I'm willing to live with
and touching a collider causes a stack overflow lmao
or well, it seems trying to leave the grid causes a stack oveflow
oh i thinkn the problem is with either the animator or the lerp
oh theres no lerp lol
the shadow or the stack overflow?
gimme a sec i gotta do something at my job
the grid idea making me want to make some snake adventure game
for me it came from playing old pokemon games
games like X&Y and Omega Ruby & Alpha Sapphire have this grid esque system as well
not that those are old, but they achieve it in 3D
im also making a grid game based on a GBA game i played when i was a kid
megaman battle network
ohh I think I might've played that as a child as well
I Have an issue of play sound on collision here is the script:
***`using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour
{
AudioSource audioSource;
void Start()
{
audioSource = GetComponent<AudioSource>();
}
void OnCollisionEnter(Collision collision)
{
foreach (ContactPoint contact in collision.contacts)
{
Debug.DrawRay(contact.point, contact.normal, Color.white);
}
if (collision.relativeVelocity.magnitude > 2)
audioSource.Play();
}
}`***
is there a collider at that edge?
there is not
can someone help me in the script ? pls
wdym debug?
identify what's not working?
actually i think im wrong
and why it's not working
do you know where the error comes from
Mate, its what you were told yesterday when trying to seek help.
You weren't describing your issue and someone had a painful experiance trying to extract information from you.
no clue
all I know is that it tries to move off of the grid and that causes a stackoverflow
Hey guys, sorry to bother but I've reached a dead end so any help is welcome, so basically my game has a Quest System where the Player can interact with NPCs, depending on the NPC he can accept Quests, when accepting the Player needs to go after a specific item , if the player passes over the item, the item disappears from the world and appears in the inventory, the player returning with the necessary item to the NPC the mission is over
The problem is, I have a function that checks if the Quest can be finished, it checks all inventory slots and checks if the item needed for that quest is present, if it is present the player can talk to the NPC again, if this happens, the NPC removes the item from the player's inventory and the mission ends.
But this function to check if it can be finished isn't working, I've already tried using debug logs and breaks and it didnt return anything, so i dont know what could be causing all the problem (the console in VS returns zero errors too btw)
TL;DR i have a function that his purpose is to check if the Quest can be completed although i don't have any errors in vs or unity the function seems to not be working