#💻┃code-beginner
1 messages · Page 226 of 1
I had beef and pasta last night.
Im having chicken and pasta tonight. We dining like kings out here
I haven't had chicken in a long time, mostly beef and turkey.
chicken is very dry
Cue a good video on inventory so I can start building off of it???
Whoever is making chicken for u is making it wrong then lmao. Chicken shouldnt be dry
Off topic tho lets stay on code
What type of inventory u plan on making? I think most ppl end up over complicating them they arent hard
I don't get you.
To have things sorted, a quick-access panel in the center, to be able to drag and drop items around the inventory, etc.
also to be able to put on equipment
like in Minecraft.
Ive said this like a dozen times as of late but just use unitys UI interfaces to pick up mouse events
OnPointerEnter, Exit,etc
That shouldnt be to hard honestly. The only part of that i think might be complex is equipable items since they tend to modify data / stats on the player
yes
Because of this, I need some sort of base of movement and item equip.
That's just slots
Finding a slot-based tutorial will give you a good head start. Then you make slots that only take items of a certain type
Slots could take something like an item interface to make it more flexible
Yeah. That's what I was thinking for the item type
That way u cant drag in food items / potion items into the equip slots
And they can have a overrideble method like OnEquip() that way each equip item can have there own implementation
How to make a folder and a script not conflict with the same name?
Invetory folder, Invetory.cs
can someone help me with this
that's weird. what's the folder for?
Not a code question
#💻┃unity-talk
to keep everything inventory-related in it.
You could just change the name of the folder? I don't think I've ever heard that issue tho
I've an object with many properties (e.g., health, ammo). If I have two scripts modifying the same property (e.g., damage, healing), how should I manage the value? Should I have all properties in a single script and then use observer or set/get functions to manipulate the value? Or should every script its own copy?
the class should handle its own state. an observer pattern will do fine . . .
just looked at my old project. my folder is called InventorySystem . . .
ty
Hello, how can I make it not take so long to stop the car because it lasts a long time...
!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.
I can't do that the code is too long
I pass around interfaces such as one called entity which exposes limited functionality. But if we're talking about modifying one unit in particular (such as connecting managers to scripts) it would be a top level script with an observer pattern mostly but could always substitue with a service locator static reference, or static reference lookup with some combination of events if seem fit.
look this is the code
Read the "large code blocks" part...
Dude, use the links I sent you
use the links provided to copy/paste your code, save it, and send us the link . . .
I really hope this is not what your code looks like while you're working with it. Is this Notepad
If it's the notepad, don't even think that I make the codes in it, the codes I'm doing it in another PC because this one doesn't handle almost anything
I don't use wheel colliders, but should you perhaps be stopping the motorTorque when braking?
It looks like it can keep getting set?
hey guys, im just curious: how can i make an octopus AI? I mean its gonna be large boss, Maybe it will shoot something later but its usual attack is melee (I mean with its tentacles)
Pretty broad question. Can't really answer unless you have some specific problem with implementing it
Like what makes the octopus unique, and not just a normal enemy with octopus animations?
such a panel should be in the same parent as the inventory so that I can move things there?
Provide more context
I just wanted to know how the combat works for it
Does it all have to come with an inventory? So I can drag and drop things into the slots? Or can the inventory be created on a different canvas?
especially the tentacles
The thing is, you should tell us how the combat should work
So that we can give hints on how to implement it
I dont see how drag n drop is connected to a specific canvas so I would say no they dont have to be in the same canvas
thank you
and how does the different UI of an item get passed around in the first place?
What do you mean passed around ?
Well, quick slots is a separate UI and Inventory too, how should I link it all together?
I cant answer that since I have no idea how your quick slots nor inventory work
oh ok:
- its gonna be big place but a little space for our character
- octopus is gonna try to hit us with its tentacles, maybe sometimes grabs us?
- we are gonna block the octopuses tentacles with our sword and not really attack it
i mean thats it, hows gonna tentacles find way to hit character?
You can use a physics query at the tentacle's position to detect hits.
For example, Raycast, CheckSphere, SphereCast, depending on how you want to detect the hit
You can have a list of classes for the tentacles. The tentacle class could be a Monobehaviour on the tentacle, or just a plain C# class (not inheriting from anything) stored in the octopus script
Hmm okay but how do i do the movements of the tentacles
what movement method respects colliders?
when I move enemies using transform.position = Vector2.MoveTowards(transform.position, target.transform.position, enemyData.Speed * Time.deltaTime); they all stack
detecting hits wouldnt be that hard but i really have no idea how to do movements of the tentacles
Well either traditional animation or some complicated IK chain that can form a procedural motion
Or a verlet integration of the positions of the bones
so it will be like: when ray hits to our character, tentacles joints are gonna grow longer and hit our character
Velocity change or adding force in case of RB. Move in case of CharacterController.
if i make the octopus on blender wouldnt it be hard to control tentacles
im trying to avoid using rigidbodies as im going to have a lot of enemies
any way around that?
since the colliders dont grow longer with the animation
Custom physics if you think you can do it more performant than unity.🤷♂️
2D or 3D?
3d
First you probably want a skinned 3D mesh for the tentacle - either separate mesh or part of the octopus
And then use animation and/or IK like Uri mentioned
Collisions in unity are handled by the physics system, which in turn requires a rigidbody on moving objects. If you don't want to use rbs, you basically go against the unity physics system.
hmm ok i will try
Implement a performant local avoidance algorithm
I suggest orca https://gamma.cs.unc.edu/ORCA/
We present a formal approach to reciprocal collision avoidance, where multiple independent mobile robots or agents need to avoid collisions with each other without communication among agents while moving in a common workspace. Our formulation, optimal reciprocal collision avoidance (ORCA), provides sufficient conditions for collision-free motion...
thanks
is the gist that each enemy checks a circle around it and moves away accordingly
Probably quite a bit more complicated than that.
how do I stop an overlap circle from detecting itself?
when it is also detecting other things of the same type/layer ie enemies
When iterating the results in a loop, you could just skip if collider == myCollider
Or use a layermask that excludes the layer of your collider
Or temprarily disable your collider
im doing it and it works but feels super scuffed
I have a string "a", I need to convert it to int then use it in switch case.How do I do it?
I think it would be more efficient for you to just use rbs.
it definitly isnt
my game literally crashes lol
The problem is switch case. whatever after case must be constant
how many enemies are you generating?
If the amount of rbs causes it to crash, then it's probably not something for the gameObjects workflow. You should consider using ECS.
over 20
200
think vampire survivors
But I'd debug the crash properly if I were you. Unity shouldn't crash even with thousands of rbs.
that's nothing, I have a game with 1,500+ rb running without problems
Well, what made you think that the issue is the amount of rbs?
because when I remove them its over 200 fps
Are you doing something like cs foreach(var enemy in enemies) { foreach(var otherEnemy in enemies) { // ... } }
That's not a very wise conclusion
Maybe your setup was just very inefficient
perhaps
then there must be something seriously wrong with your setup or usage
the only thing the rb is doing is changing velocity in update
So, you should debug the issue instead of nuking the whole physics system.
what kind of colliders are you using?
It's like burning your house because you found one cockroach inside
circle
well its clear theres ways to do enemy ai without rbs and rbs are espcially expensive
And now you have to rebuild your house and you don't even know how
Well, what part exactly about the rbs was expensive?
first thing you can do is move your rb.velocity to fixed update
It's really triggering me when people make wrong assumptions and just go with them...
seemed like just existing
even turning off movement caused lag when loading in the enemies
That's very wrong. Nothing takes CPU time by just existing. Something in the physics system or your code was processing these rbs and using a lot of time. But you never investigated what it is.
can you sreenshot your rb setup
so you are doing continuous interpolation, do you really need that?
really you should only need continuous interpolation for very fast moving objects
yes, if you could add some exclude layer overrides it would also help, so see if you can improve your layer usage
ironically the rbs improved performance because im no longer checking 100 colliders in one frame when the enemies are stacked up lol
my matrix is setup already doesnt that mean the overrides are fine as it is?
or do they do something different
thats ok
For future reference, you should use the profiler to diagnose a performance issue before attempting random fixes.
true ^^
I did but I just assumed rbs wouldn't work for that many enemies judging by what people say about vampire survivors
I've been following Mikes Codes survival series just for core concepts, and I am having trouble with player movement. I can not jump when my players view is maxxed out to the clamping point
the vast majority of people do not know what they are talking about when it comes to things like this @native seal
Wdym with 'players view'
When the mouse y is clamped at max +-
whats the best way to learn unity?
not a code question but !learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
circle colliders > box colliders generally right?
We're gonna need a lot more information. I don't know Mikes Codes, so I dunno how it is done.
I find it odd that the view is having anything to do with the movement?
Basic information needed:
Is this 2d or 3d
How do you move (transform, rigidbody)?
Is movement fine otherwise?
Circle is mathematically cheaper of course
kk
I wouldn't say BETTER though, if that's what > means
better for performance
3D, transform, movement otherwise is fine, just jumping when the camera is at clamp
Then yes
Ok can you show !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.
I am actually heading to bed now, but someone should help
If you want to push even further you should consider DOTS and ECS. But that's a totally different workflow.
https://hastebin.com/share/itobudaxub.csharp
This is both of my move files (mouse and player), combined into one paste file, seperated by dashed line
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
But unity physics already is pretty optimized if you use it properly. There's no point discarding it(and rbs) with gameObjects workflow, unless you don't need physics at all.
Couple things before I leave. Don't ever multiply mouse input by deltaTime like that. It's already a delta from the last frame
Also, you are using a CharacterController, not the transform
Very very odd that the view is affecting the jump. I don't see anything that should cause that
I'm also noticing that the characters goes slightly airborn when going backwards if I'm looking down
same thing if looking up, seems it launches towards the immediate forward point then gravity catches back up
Does anyone have just a solid functioning player movement script with move and jump that I could link in and see if its a straight up code issue or an IDE/Engine issue
Are mouse movement and player controller scripts on the same object?
You should show your !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.
Ah sorry you posted alredy
tryna find where the mistake is when it isnt registered as an actual error is actually painful
And use the debugger to step through code
Well, then it would make sense why it's going into the air. You're rotating it on the x axis and using it's transform.forward to move the character controller.
like rn im following this tutorial (part of a series), and his works perfectly fine but mine doesnt work at all despite not seeing a difference in our code
can you screenshot the inspector for PlayerMovement @sterile moon
What about it doesn't work
the bullet holes arent appearing on the surface like they do for him
And is your camera in the hierarchy that you put into transform.Find
Because it's different from the tutorial
Did you properly set up that canBeShot layerMask?
Just make sure you follow all the steps correctly. Re-watch it if needed
i beleive so
he set it to everythingn and then removed the player and weapon layers
Do you get any errors in the console while playing, when you should see bullet holes?
which i also did
Sure one sec
So your transform.find is not working
The importance of properly sharing the issue
yep, 5 posts before sharing a very obvious error
since the camera holder isnt parented to the player like his is
do i just reference the cam and not holder/cam
there you go
@languid spire
the question is why is it not set in the inspector? why does it need the transform.find?
nothing obviously wrong there
Thats what I thought too
but for some reason it does not work right
@languid spire do you have a standalone move script I can drop in with little modification to see if its a client side issue or a code issue?
sorry, no. I do not generally use Unity build in scripts
do couroutines instantly finish when on an object that's destroyed?
should do, yes
Coroutines stop on the yield statements so if an object is destroyed, those are no longer continued
makes sense
Hello Everyone! I'm trying to create a game where the user shoots hoops and score points, it is a 3d game where the player walks around, can hold the ball and shoot hoops, although I am having a few issues during the creation. Has anyone run into an issue where your player moves toward a gameobject (in this case, a basketball) and as soon as the player has contact, the player automatically moves in a weird direction. Could this be because I am using transform.translate in my movement script?
wait can i set an IEnumerator to private
Are you using rigidbodies? transform.Translate does not respect the physics system.
Ok
Well. What do you think private does?
Yes, I am. If I use add force, wouldn't it make the player accelerate and deccelerate for movement?
Yes, but transform.translate will mess it all up
You can set anything to private
So, should I not use Rigidbodies?
Only move rigidbodies via the rigidbody (AddForce, MovePosition, .velocity...), not via the transform
Just ditch the transform.Translate instead
Why do you need that if you are moving via AddForce anyway?
Okay, I'll give it a go!
I'm not
Ah I misread this
like a reference?
What does making a field private do?
@topaz thistle If you want 'instant'/snappy movement, you can directly modify rigidbody.velocity instead of AddForce
It makes the field inaccessible outside of the class its in
it makes it a private reference and so i cant make a reference of it
Epic, thank you! I'll let you know what happens!
It makes it private, giving it privacy so other classes, objects, files, etc. can't touch it. useful for when hiding things or showing things to an API
Haileykins has it right. If makes the field inaccessible outside of the class it's declared in.
wwhen i click on the error it redirects me here
Aka if you made that Enumerator private, and it's giving you an error, that's likely the issue.
so should i set it to public?
its inside a method
I know my shit quite well, have run Java and C# before, just never run with the Unity library
Is this an inline method?
maybe, we need to see more
Please configure your !ide before asking for help. This issue would have been prevented if your editor worked correctly
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
Can you show more of the script?
sure
i already have
No it's not
you can see from the mismatched } it's an inline method
And after your configured your editor please
c# access modifiers
Namely this page
before i wrote this there were no errors
Ah yep, thanks
why is your spacing so weird
your ienumerater is inside Update
because it wasnt formatted 😉
this syntax error, you have to configure your VScode properly
If you are on Windows I suggest you just use Visual Studio
vs community is better anytway

hell yea!
have you tried the new Unity plugin for it?
Ya I have.
What new Unity Plugin?
@queen adder So please configure your !ide or consider using Visual Studio if you're on Windows. VS is much easier to configure and VSCode is generally kinda bad at doing things.
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
for VSCode
Oh nvm sorry Mb
so much easier than using the old method
I think the last time I tried it, I was able to get it working. It's just I had issues where copy-pasting code would lead to freaky formatting issues.
I've gotta ask, is there any difference between installing VS through Unity Hub or Manually?
So I just said fuck it and went back to Visual Studo.
one installs the workload already
yea im installing visual studio rn
VS for mac is getting phased out this summer, so mac users have no choice
or shell out for rider
Ur kidding
What? Why?
MonoDevelop ?
Did Apple do a dumb again?
because its old xamarin editor
VS is probably hacked together to work on Mac
they prob consolidating
So, I've got a Mac and am using manually installed VS
Should I switch IDE's or smth?
It will still work, they just wont update it anymore. Just patches
Is there any advantage to working with VS Code as opposed to VS when it comes to C# + Unity?
On Windows
no
it uses less than a gig for me
See that's what I kinda wanted. Using VS feels like I'm driving a semi.
and it looks nicer :)
There really isn't. VSCode is very good when it comes to supporting everything, but often a IDE targetting a specific language works better than one that works with all of them
Ah, that makes sense
same
Wait, how so? Do you have some HLSL plugins or something?
vs plugin for HLSL doesn't highlight correctly for me, but other than that there's no intellisence or anything
just clean shader code syntax <3
Here's the issue I was having. Imagine copying some section of code.
Then pasting it
Tabs dont get cleaned up.
What HLSL plugin do you use for VSCode?
you pressed the formatting shorcutt?
Gets especially bad when you paste to a scope with a different number of tabs.
i dont like that it doesnt format yes, but you can press ctrl K + ctrl D
"Format Document"
Every time?
I format document all the time
trying to find a way to make it auto lol
Wait this is intended behaviour?
No
No that cant be right. I worked with Javascript in VSCode and it formatted fine every time.
No way this is base behaviour.
I think it's screwing up the formatting because you have an error
nah happens regardless
oh god i just configured vs and there are so many errors
That's such a weird hotkey IMO.
VSCode has Alt+Shift+F which is quicker/more accessible
holy shit
wait im on vscode rn
search "format" in settings
actually no idea what shortcut that is lol
the thing is if i remove the IEnumerator from the update i get like 10 errors
ahh alt shift F works on mac too @verbal dome
Alright I guess I'm getting VSCode to work at 4am.
here we go
wwait so should i remove the IEnumerator from the update?
yes
yes
You should not nest methods unless you know what you're doing 😛
I don't think there's many options beyond the HLSL tools package, but there is one for built-in unity support but that's not been supported in forever
I primarily use https://xibanya.github.io/URPShaderViewer/ for unity macro lookups, function calls, ect. It also has syntax highlighting too if you post your code into it.
Alright, I'll check it out next time I have to touch HLSL. Recently I mostly used Shader graph and Compute shaders
wait what is a namespace error because i have way too many of them
Compute Shaders are so cool conceptually. I gotta get into those.
now you're on vs
yes
before you showed vscode
i wwas told to switch
show the complete script
Going to be honest man. Post the entire script in a hastebin or something. You have some odd formating somewhere.
okay
Not just odd formating. It's missing the whole class
Or is that cropped
I guess it is
We don't need those.
They hold us back.
yes prob missing a curly brace
whats the command for hastebin?
@rich adder You mentioned some new Unity VSCode extension?
the one from microsoft
Alright well the paste setting actually works.
ive copy pasted the code into hatebin how do i export it
But now it takes 2 Ctrl+Z to undo it 😛
hit save, send link
:\
I joke. It's fine.
I'll give it a try for a day.
See if it feels good.
Thanks regardless 😛
Ive saved it like it auto formatted itself so i just copy and paste the link?
yes
Save it on the website too
ive saaved it is it supposed to show a name option?
What name option? Just
- paste your code into the site
- Hit save 💾
- Copy the link from your browser and paste it here
ive done the same thing but it doesnt show anything
I personally don't like Rider, I find it way too intrusive and it interrupts my flow too much when I'm coding
This is as clear as he can possibly be.
Do it again. Wait for the link to change after hitting save. Then copy & paste it.
I stand corrected.
He has made it more clear
remote desktop is next
I was hoping we don't need a video tutorial for this one
Maybe they hit Ctrl + S in the browser. Who knows
lol
why
It's not possible
omg
📃 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.
Honestly how big can this class possibly be?
Can he just copy-paste the whole damn thing into discord?
here
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
better learn to do it right
We're so back.
im so sorry idk why it wasnt working
wait
If it's too long, discord uploads it as a text file, which you can't view on mobile without downloading it.
your whole Update method is outside of a class, well and all the variables too
I'm going to assume the top part of the code is copied and the bottom is their own?
probably
yes the dash part
is mine
yeah
no wonder the formatting is crap, that is not correct c# structure
I'm confused, you already had an Update method, why make another one?
I'm going to assume he got this script from a Tarodev video, wanted to add a dash to it and has been trying to do so without getting a hold of the fundamentals.
By the way we're not trying to blast you.
nothing
so, best to go do some basic C# courses
Agreed.
any recommendations?
okay thank you so much
No problem. Programming is mostly problem solving, so it's important to get the fundamentals down first.
Once you know the syntax and general flow, it'll be much easier to make sense of the tutorials, and figure out what you need to do to get the behaviours you want.
Hello there, i've just started today with unity, i've been checking some code (mostly for movement and physics), and dont understand why people use Update + Time.deltaTime instead of ussing FixedUpdate for movement like gravity (?
because those people are wrong :)
lmao xD k tnks
Were they using CharacterController?
yup
AFAIK that is supposed to be moved in Update with deltaTime, yes
With Rigidbody and other physics related stuff you should use FixedUpdate
wouldnt you still do it in fixed update though?
what's the difference using Rigidbody and CharacterController (except that Rigidbody automatically does gravity and mst of collisions)
Because this goes back to my previous problem that frame skipping breaks cc if they fluctuate too much but then again I've only done limited testing with it
You can probably do it in fixed too yeah
But it doesn't have interpolation so it might be slightly choppy
But fixed is more consistent ofc
FixedUpdate is probably gonna be laggy/weird as CC is not interpolated
If I were to use CC, I would probably do FixedUpdate and interpolate manually
Having movement tied to framerate in any way is sketchy to me
I'd check what's the recommended approach in the docs for CC and use that 😄 And only worry about it later if I have issues
CC is rigidbody lite if you do want to manage the physics a bit more yourself than relying on the built functionality that comes with rigidbodies
tnks, i've just been checking now and seems that when CC collides with a rigidbody causes some glitchy movements (it just happened to me and thought it was other thing) so i guess i'll just go for rigidbody, i can do more stuff, even if i do not use them at least i've the option to use 'em
Non-kinematic RBs tend to be annoying for character controllers as they do a lot of non-snappy stuff. And doing a kinematic RB CC yourself is on the difficult side.
Non-snappy stuff sounds like you are using AddForce and not taking current velocity into account
AddForce is taking current velocity into account. Problem is you need to start manage velocities yourself.
I like to do this: cs Vector3 desiredVel = ... Vector3 currentVel = rb.velocity; Vector3 difference = desiredVel - currentVel; rb.AddForce(difference * someMultiplier)
Use the difference to target velocity as the force
Then the next thing is lets say you want stairs, now you need to do more stuff to support that so that the RB doesn't just get blocked by the stairs
And suddenly you're doing all the stuff yourself - which gives you best control but is high effort
Whereas the default CC just handles most of it
Adds greater force if you are far from the target vel. If it's already similiar, no force will be added
While the usual AddForce(moveInput) is really floaty
Agreed, forces are only good if you're doing proper physics stuff. As in, you have balls and cubes and stuff and want them to behave physically correctly.
hello ! i'm a complete beginner and i have a question : what's the best way to change a text between two scenes ? (that stays until another modification). I have a button that leads me to a new scene when i click on it. on that new scene there is another button, i want that when i click the first button from the first scene changes his text :) thanks in advance
I've more respect for RB after dealing with accumulative forces and not clipping through every wall after testing a few things
For CCs you end up fighting the RB more than being helped by it :/ (or at least that's been my experience)
subscribe to sceneLoaded event, when it fires get a reference to the button, change the text
mm... store the value in a global place and read it from the other scene
i think for me the global value is the better option since there will be a lot of these but how do i store something in a global place
can you tell us a bit more about what are you doing? what's that all about? 🙂
it is an app (for the moment there is a main menu with buttons that leads to other menus) each menu gives you sort of challenges, and when you complete a challenge it gives you points for the specific menu score
should i use this
public class GlobalVariables : MonoBehaviour
{
void Start()
{
// Load the global score from PlayerPrefs, defaulting to 0 if it doesn't exist
int score = PlayerPrefs.GetInt("GlobalScore", 0);
// Assign the loaded score to your global variable
GlobalScore.globalScore = score;
}
void OnDestroy()
{
// Save the global score to PlayerPrefs when the object is destroyed
PlayerPrefs.SetInt("GlobalScore", GlobalScore.globalScore);
PlayerPrefs.Save();
}
}```
Perhaps not. This saves across sessions. If that's what you want- it's an option.
yes it is what i want, it's gonna be the player's score forever
Yeah, but is it the same for the button thing you mentioned?
once gained the point stays (unless removed by another script)
Okay, so this is good 👍
thanks i'll try it :)
do i have to create a script for every button that gives a score ? every button gives a point for a different score (strenght, stamina,...) is there a way to have one script that can be attached to all buttons ?
like "if examplebutton pressed give one point to example"
You can have just one script but make a variable for what score type it is
How do you make variables remain even when changing scenes?
how can i tell to a button to which score it should add a point ?
The score type should be stored in the script on the button
For example, make an enum for your score typescs public enum ScoreType { Strength, Stamina ... }
And then the script that adds score, you would have a variable of ScoreType
´Then pass that scoretype as a parameter into the method that changes the score
Lets step back, how are you adding score currently?
i'm a big code noob it is my first time so i don't understand everything
currently i don't have anything but i may use this
I need help; as soon as the resolution changes, sizes in the game also change. However, I want the game to look the same on all devices. How do I achieve that?
I assume those are UI objects. You need to adjust the canvas scaler on the canvas
Select your Canvas GameObject (in the hierarchy panel).
Go to the inspector panel, and see the Canvas Scaler (The image down there)
Change the UI Scale Mode to Scale With Screen Size
Reference Resolution = 2560x1440 (because you are using a 1440p display, but I believe you can use whatever you want)
(Optional part. I personally like doing this)
Go to the inspector, and see the Canvas component
Change it from Screen Space - Overlay to Screen Space - Camera.
If you successfully do this, the text will appear the same in all screen sizes, whether it be a small mobile phone or a huge TV, regardless of resolution.
@pale vault and @pallid nymph i kiss you
@acoustic crow Just to clarify though, it may be a bit more involved than that depending on the complexity of the menu. You need to assign proper anchors and pivots to the elements as well. And you should test with the various expected screen ratios. 🙂
But if it's just a few buttons in the center - that'll probably be good enough 🙂
The problem is that it works perfectly with the “World” scene. My phone is 2960x1440
and I would like if someone has a cell phone with 4k or something that also looks like me in the "World" scene, then it works too, but in the "MainMenu" scene I have it the same as set in world, 2960x1440, but at 4k everything disappears and it doesn't work with the other resolutions. I'm confused @pallid nymph
World
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NewBehaviourScript : MonoBehaviour
{
// Start is called before the first frame update
private string ad;
private int number=20;
void Start()
{
ad = "Eileen";
Debug.Log(ad);
Debug.Log(number);
}
// Update is called once per frame
void Update()
{
}
}
that is not 'attached to a gameobject'
also your script name and class name do not match
create empty game object in the hierarchy then Add Component, somewhat strange your tutor did not teach you this
After creating your script, drag it and drop it on your GameObject in the hierarchy panel
Or you can use the Add Component approach mentioned above
but not until the naming problem has been resolved
Change it to this:
using System.Collections.Generic;
using UnityEngine;
public class DegiskenManager : MonoBehaviour
{
// Start is called before the first frame update
private string ad;
private int number=20;
void Start()
{
ad = "Eileen";
Debug.Log(ad);
Debug.Log(number);
}
// Update is called once per frame
void Update()
{
}
}```
Change the name of the file to DegiskenManager
No problem 🫂
ı did both the naming and adding component
I suggest looking up some tutorials, but remember to TRY, or else you'll end up in somewhere called "Tutorial Hell"
Also, when it comes to coding/scripting, don't be afraid to ask AI (ChatGPT, Google Gemini) for help. They can give valuable insights and improve your knowledge.
omg yes it's such a huge pain making everything the same but still getting errors
!learn may be a good place to go
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
we do not recommend using AI spam bots in this server
Hmm, never been there
Gonna go check it out.
ı use chatgpt almost everyday ı'm a computer engineering student and it helps me with my problems a lot
I wasn't referring to AI in that sense lol
chatgpt likes to invent functions in the unity api that don't exist though, just make sure to question it all the time lol
alright thank you in advance
Same
Except I use Gemini instead becuase I prefer it
That doesn't happen very often for me
But if it does, I also question it a lot
That's honestly how I learned coding and became a (kinda) experienced coder
is it better?
I've tried it and it works
Can't really say it's better because I haven't really gotten into detail when it comes to comparison
One thing I can say is:
ChatGPT: Helps you with debugging
Gemini: Aggressively debugs it and even tries to change your code. But it doesn't mean I don't recommend it.
ChatGPT: spat me back the same code i gave it while making up a random error when i tested out its debugging
would not recommend either tbh
ı mostly use them when ı get an error asking how can ı solve it but ı dont usually ask them to give me the full code or functions practicing always works better for me ,more efficient at least
I guess our experience is different
That's a good way to learn using AI
still useful ı think just gotta find the best way for you to use it
I personally think writing entire scripts using AI is not a good way to learn, and the code itself is also very unfunctional
agreed
I only learned when I did the coding myself, and only used AI for explaining something I don't know
When I play games on my phone I feel like the game is very sloppy but. It's fluid, but the things that move look strange. I don't know if it's due to too low FPS or no plan. What can I set in Unity's project settings to make it smoother?
e.g. at first, all I knew were void functions, but then I learned that any type can have functions
Then I learned about namespaces
Bla bla bla
All those stuff, I learned by AI, and it saved me so much time in comparison to tutorial hell 💀
What are your phones' specs?
@pale vault I don't know everyone either, it's a Samsung s10+ but of course it should run smoothly on other cell phones. It actually runs very smoothly. I just don't know if it's my imagination or what I don't like about the object. When I look at it, I feel like I'm holding on and then I see that there's a black film behind the picture
That phone is like 5 years old lol
To be fair, it's still hard to determine the cause because we don't know what the problem looks like
im on an s8 and most stuff works pretty well on that one, is it your game that works worse on the phone than in the editor? what's the actual issue
wait i upload it on youtube and send you then the link wait a 5minute
Wait, are we allowed to send links in this server?
you should be able to share a youtube vid of your problem, but recheck the rules just in case 😄
seems like its fine
⚙️ Content
• Where applicable, attach supporting materials such as screenshots, videos, or code for better clarity and understanding.
I think videos is referring to mp4 or that kind of stuff
Hello! I was wondering how to edit my collider so my character doesn't rotate when coming into contact with one
should be fine anyway
I think it's in the Constraints property in the Rigidbody component
(At least in 2D. Not sure about 3D)
Oh 2D yeah
oh! yes I see thank you
in my game i save a score to an inputted id using playerprefs which it does as seen in my debug statements, but in a different scene when i want to see the score of a id searched, it always says the score is 0
could use help resolving this, i think the issue is somewhere in the savescores() and OnSearchButtonClick() methods
can you show the line you save, and the line you load the score? 🙂
Yeah it would help if you only share the relevant piece of code
i'm guessing your issue is here:
PlayerPrefs.SetInt($"TotalScore_{studentID}", playerScore);
int lastRecordedScore = PlayerPrefs.GetInt("LastRecordedScore", 0);
saving to a different key than you are loading, not seeing where LastRecordedScore is saved ever
thanks ill have a look
So, do the ids of the students match?
Generally I'd advice you place the key in a constant to avoid mistakes with magic numbers/strings, but that does not seem to be the issue here so not something you'd have to do currently
havent implemented the suggested fix but yes the id is confirmed to exist and match, but the score is always 0 (the default)
i have a question how to make a negitive effect like a curse that only effects enimies in a game and not?
and thats why i wanted the exact code 😄 was looking at the wrong place, can ignore the LastRecordedScore thing. agreed with FusedQyou, const strings all the way for pref keys
This is a very broad question, and not something that can really be answered without specifics
I see, the code does not appear to have any issues so I'm not sure
Unless you load the data before saving it
But that would have been obvious
i have a kind of a curse in mind in a game so i want it to be when ever i pick and use the curse it inverts gravity for all the enimies
So I guess whatever handles gravity should check if the curse exists, and if whatever it applies gravity on is an enemy. You would need to differentiate enemies from players and keep track of enemies you spawn so you can give the curse
For example, with a manager that handles spawning
public Enemy enemy;
public GameObject target;
public bool curseObjectUsed;
if (curseObjectUsed && && target.isEnemy && enemy.inEffectRange) {
// Attach effects
}
Super SUPER broad way of applying the effects, requires extra back end code not provided
Or have the enemies subscribe to a singleton manager that can apply effects, and have it trigger when the effect is given
thank you so much this worked
Either way your first task would be to figure out how you tell enemies of the curse effect, and then you should actually differentiate enemies from players
wait really? xD i thought the issue was what was being printed in the onsearchbuttonclick. glad it worked out though!
thanks
hi can someone please help me with something
Only if we know what it is
ofc
using System.Collections.Generic;
using UnityEngine;
public class CollectCoins : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
private void onTriggerEnter(Collider other)
{
if (other.name == "Player")
{
Destroy(gameObject);
}
}
}
heres a script for a coin
its supposed to be destroyed one a player collides with it
but my player just passes through
OnTriggerEnter is misspelled
@timid marlin to prevent any possible confusion I would suggest using other.tag instead of .name
private void OnTriggerEnter(Collider other)
{
if (other.tag.Equals("Player"))
{
Destroy(gameObject);
}
}
You set the tag in the inspector window, very top, there's a preconfigured option for Player
How about
other.CompareTag("Player");
?
Compare tag would work just as well for sure, I'm weird and am partial to equals because it reads a little cleaner for me
Wait a minute.
other.name is supposed to be about the name, not the tag, right?
hello ! coudl you tell me how do i link "ForceDisplay" to a text ?```public class ForceAdd : MonoBehaviour
{
public Text ForceDisplay; // Référence au texte où afficher la variable
private int Force; // La variable à incrémenter
void Start()
{
// Charger la variable à partir de PlayerPrefs ou utiliser une valeur par défaut
Force = PlayerPrefs.GetInt("Force", 0);
UpdateDisplay();
}
void UpdateDisplay()
{
// Mettre à jour le texte pour afficher la valeur actuelle de la variable
ForceDisplay.text = "Variable : " + Force.ToString();
}
public void Increment()
{
// Incrémenter la variable et enregistrer la nouvelle valeur dans PlayerPrefs
Force++;
PlayerPrefs.SetInt("Force", Force);
PlayerPrefs.Save(); // Enregistrer les changements
UpdateDisplay();
}
}```
the script goal is to add 1 to force value on click
Is there GameObject.CompareName(string)?
not sure, but I wouldnt doubt it
You do that in Unity itself, by giving the parameter ForcedDisplay in the inspector a textmeshpro, you will first want to change Text to TextMeshProGUI
noted
so doesn't work with a legacy text ?
It probably would, but TextMeshProGUI is the modern integration and will usually carry logner term support without later risk of deprication
Just checked, it doesn't exist
ok thanks :)
Hm, good to know
Why would that exit in the first place?🤨
It would really help if it existed
I don't see how..?
It's a reasonale method honestly, surprised it doesn't exist
and do you know how i can reset a playerpref value for testing ? because if it is saved forever for editing the game too it's not easy
wdym? Like, a variable that you configure in hard code?
Actually, you can make it exist like this:
bool CompareName(string Name)
{
if (Name == name)
{
return true;
}
else
{
return false;
}
}
i have a variable that is like a high score, i want it to stay forever for the player but not for me while editing
Lmao I made this code on Discord
using System.Collections.Generic;
using UnityEngine;
public class PlayerCollectCoins : MonoBehaviour
{
public int points = 0;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
private void onGUI()
{
GUI.Label(new Rect(10, 10, 100, 20), "Poiddsfsdfadsfsdafadsfasdfasdfasdfasdfdsafsdfadsnts: " + points);
}
}
can anyone tell me why the gui label isnt showing up on my screen? thanks
Why not just use name == someString directly?🤷♂️
OnGUI is misspelled
Are you wanting to save the high score to a file? Or just hide it from your screen or? I'm not understanding what you are wanting to do
Same reason why someone wouldn't do
GameObject.tag == otherTag
my program save a value using playerpref but it is saved for me too between sessions and i can't test the game well
And that is?
ty
Because there is a more concise option: GameObject.CompareTag(string)
Add a line in the code as a dev line to reset the number on game start, or set a keybind to reset the number. Essentially build a cheat code via key bind. This is the initial reasons that cheat codes were invented in the first place, they were developer debugging tools, they got left in a game for players to find and eventually players did, it became a standard
Depends on preference
I like CompareTag(string) for its conciseness
That's not why CompareTag is recommended
Why is it?
ok thanks i'll try that ^^
Hmmm
Learning new things every day
i can't find how to add a parameter to the TMP 
is it to add a component ?
its over in your inspection
You create a textmeshpro game object in the hiearchy, then name it, set it in the hiearchy where you want it, and link it by dragging it into the field on the inspection labled ForceDisplay
i don't think i am understanding how to do it even if it seems simple
Do you know what your inspector is
where do i drag the TMP ?
yes
but can't find forcedisplay, do i have to create one ?
it is only on my script for now
Okay, when you click on whatever game object has the script above, do you see a field that says ForceDisplay on the inspector that has no file in it yet
oh i havn't added the script on anything yet
my player is jumping but it doesnt stay on track
was waiting for me to link text with display x)
Yeah, you need to have your script attached to a game object before you can link anything to it
doesnt stay on track in what way
wait i send u ss
how can I configure my IDE on linux kali? I have both installed
i attached the script to the button but still can't find the field x)
@sterile moon
like this
its working fine on left and right input
but not jump
show me your inspector when you have the button selected
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.
my code @sterile moon
its not related to that, but thats because you didnt finish changing text over to textmeshpro I bet. I can't read any of what that says because I do not speak French
the name cant be found
so check your class for errors
it looks to be a NPE, and since you changed to TMP its most likely you didnt update all instances of text to TMP
well i can't find any remaining "text" anywere
nowhere on that button inspection do I see a script added
on click
where else can i add one ?
on click - no function - ForceDisplay
oh yes so i had to do "add component"
you create your ForcedDisplay game object and drag it here
this appared as i added the script as a component
so i guess it is good
but i can't add anything to that field btw
how can i drag something from one scene to another
to add something to the force dispaly field you need to have a text mesh pro game object to put in there. It wants a TMP object
dose any one know how this is made any detials videos or and readable metaril would be greatly appriciated
like how to select a ability in the start screen and then get it in the game
You would need to use a GUI or a keybind, some sort of trigger to get what they selected, then just implement that item into the game
i am new to game dev so i applogise in advance for my stuipd questions
but the TMP displayed the force value is on another scene
!configure
!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
I have visual studio
it saya error acquiring .NET!
so doesnt autocomplete
I also downloaded vs externally
not via unity hub
That's fine. Visual Studio downloaded correctly?
Make sure you selected the correct workloads
yes
Im using linux
vs tried to get net 7 on its own but failed
so im trying manually
wdym
how do I get the path to the folder with the game (i.e. where the executable file is located)?
Get the path via code, or like, navigate to the path on your pc
I need to get the path with code...
path = Application.dataPath;
That's part of the step, assuming you use VS
the GameName_Data folder is not what I need
that might be dependant on how the game is installed then. May need to link into whatever distrobution manager you plan on using
maybe Environment.CurrentDirectory ?
yea I do
Im installing .net 8 now
hope it works
you know Unity does not use .Net 8, right?
thanks
As in unity .NET 7? Also not the case
Versioning in .NET is weird, Unity uses something called .NET Standard
Too lazy to explain but you can think of .NET Standard being the interface where .NET 7/8 is the class that implements the interface
Assuming you even know what these are
hey, i still can't manage to find a solution to my problem. I have a button on a scene that have to increase a PlayerPrefs value, and a text on another scene, where the game starts, that have to display that value. How can i do that ? i tried multiple things, i probably should use a DDOL but i can't manage to do it
this seems very easy but is unbelievably hard for me
and can't find anything on google
Get the value from the player prefs and update the text with it.🤷♂️
i just cant manage to do that
Doesn't sound code related.
don't even know where to start
do you have a script with a method that saves the value to PlayerPrefs?
i deleted what i made since it was useless
well make a new one
Well, since you already save to player prefs, you should know how to load from it. And the only other thing is assigning a string to a text component.
is this a good script to add 1 to the playerpref value ```using UnityEngine;
using UnityEngine.UI;
public class IncreasePlayerPrefsValue : MonoBehaviour
{
public string playerPrefsKey = "PlayerScore"; // The key used to store the value in PlayerPrefs
}
void IncreaseValue()
{
// Increase the PlayerPrefs value by 1
int currentValue = PlayerPrefs.GetInt(playerPrefsKey, 0);
int newValue = currentValue + 1;
PlayerPrefs.SetInt(playerPrefsKey, newValue);
PlayerPrefs.Save();```
define good
full of errors 😄
i see no reason why it need to GetInt everytime
it can do that on Start and cache it, and increment the cache
also assuming its a bad copy and paste since it has a bunch of syntax errors
yes sorry
public class IncreasePlayerPrefsValue : MonoBehaviour
{
public string playerPrefsKey = "PlayerScore"; // The key used to store the value in PlayerPrefs
void Start()
{
// Increase the PlayerPrefs value by 1
PlayerPrefs.SetInt(playerPrefsKey, PlayerPrefs.GetInt(playerPrefsKey, 0) + 1);
PlayerPrefs.Save();
}
}``` how about this
feels like you are guessing now, since that only runs on Start now and still does all the work in 1 step, instead of caching anything
if you have no idea what you are doing, which is what it looks like !learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
You need to follow ide config guides !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
i used chatgpt to get thoses last scripts since what i was doing what trash
to have an example
and you do not know the rules on using AI code?
so you are not understanding the code it gives you then trying to ask others to fix it
vs reading it and learning what it does
{
public Text ForceDisplay; // Référence au texte où afficher la variable
private int Force; // La variable à incrémenter
void Start()
{
// Charger la variable à partir de PlayerPrefs ou utiliser une valeur par défaut
Force = PlayerPrefs.GetInt("Force", 0);
UpdateDisplay();
}
void UpdateDisplay()
{
// Mettre à jour le texte pour afficher la valeur actuelle de la variable
ForceDisplay.text = "Variable : " + Force.ToString();
}
public void Increment()
{
// Incrémenter la variable et enregistrer la nouvelle valeur dans PlayerPrefs
Force++;
PlayerPrefs.SetInt("Force", Force);
PlayerPrefs.Save(); // Enregistrer les changements
UpdateDisplay();
}
}``` this is what i made
but since it wasn't made the correct way
yeah did those
still doesnt auto complete
but you said you were using TMP and I distincly remember someone telling to check all Text references which you said you had done
i used text legacy then tmp
What ide are you using?
yeah never use the legacy text system
but i was thinking i could link the text from a scene to the inspector's of a button froma another scene
its literally just a using import and type swap to use tmp
you cant link across scenes like that from the inspector
linux
yes so i ask for help
why is it damn hard to install net sdk 7 to linux
i was told to use a DDOL
Wrong answer.
not much resources
since there is no insurrance all the scenes would be loaded at once
Linux is not an ide
yeah I use vs I thought that was obvious
Which of the things that you listed is an ide?😬
vs on Linux? I don't think so
Obviously, it was not obvious. If you're using vs, share the unity workload installed and the IDE selected in the external tools in project settings.
thats VS Code
This is not vs
yeah
At this point you're just trolling
yes MS is bad at naming things, but VS Code, VS for Mac and VS are all totally different things
oh wrong aplication
why would I
just started linux
I googled install visual studio for linux
and did that
here we are
This looks configured properly though. I think. I don't use vs code for unity.
if you don't know the names of the apps you're using then you should not be using them
though i heavily recommend if its a option to use windows or mac as a dev envirmeoment for unity
Visual studio is not the same as visual studio code(what you're using)
linux support exists, but you will have less help with it, and its less stable
Visual Studio is windows only IDE
does not exist for Linux
Visual Studio Code is a code editor for all platforms
yeah vs code that is
but I strongly suggest if you do not know how to use Linux then don't use it
VS Code is listed in the above
It should be working imho.
it does. but doesnt autocomplete for unity libraries
For example?
also being new to unity, programming and linux at the same time as asking for a lot of trouble
to put it very mildly
my character keeps going to movepoint after camera moves
first part of the video: normal movement script
second part of the video: tile based movement (a.k.a the ss i sent :P)
doesnt auto complete gameobject
or rigidbody
or gamemanager button stuff like that
autocompletes stuff like private public readonly float int
Maybe remove that private above?
@queen adder did you follow this guide
https://code.visualstudio.com/docs/other/unity
no I didnt I followed visual studio thought that was the one I was using
let me do it real quick
so you followed the guide for the one you are not using, but expect it to work after that was pointed out?
im trying to solve this for days :/
basically this script updates character position after switching to next area but i don't understand why character tries to go back
FINALLYY
i solved it guys
sometimes i feel like dumb
can i get help with my maze generator code please? I've made a node in 2d with 4 different walls and im trying to use a depth first search to do so but I keep getting these errors.
Miscounted, you have too many closing braces
check your syntax, specifically line 15
Nevermind, ignore me. I can't parse code that has { on the same line lol.
I have corrected that now my syntax was completely wrong
also don't nest methods unless it is useful
This is my first attempt do you know any other ways for random maze generation other than a depth first search
because im trying to explore methods on doing so and which works best for what I am doing
is referring to you defining the GenerateMaze inside of Start
tbh that is irrelevant if you cannot write correct c#
let start be its own method, then have the generate one as its own method too, dont put one in the other
school project I have to do it
first learn then do
how would you suggest doing that
my first time using C# and i hate it tbh
Start() {
IEnumerator GenerateMaze() {}
}
This is what you did ☝️
This is what you should do
Start() {
}
IEnumerator GenerateMaze() {}
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
learning some of its basics, you got multiple syntax errors, that would be obvious after even a bit of introductory learning about C# or really any C like language
yes i went thru my code line by line and corrected it
thank you
thank you sm
ill keep that in mind
Why would my grid be so massive? this is default, on 1,1,1 and the 2nd image is if i make the grid scale values tiny.
what's the size of you robjects?
and sprite import settings, etc
also camera settings
are you using an orthographic camera? could be that your grid is closer to camera than objects, changing relative size
Does anyone have a good tutorial for adding a cutscene to a 2D game? I want to trigger an ending scene based on a specific pickup
size of what?
just the size value in the inspector that zooms it in/out
what's the size of your game objects, and what is your sprite pixels per unit
and how large are your sprites
nevermind i fixed it somehow..
happy to help
ty
llol
I'm moving my Rigidbody2D by changing velocity in FixedUpdate...
I noticed that without vsync the movement is horrible. Am I doing it in an ugly way?
you'll have to better define horrible, buuut you maybe need interpolation on some rigidbodies
well I mean horrible as in clearly bad practice for some reason, trying to educate myself 😄
I can just force VSync and looks good
but will look into interpolation stuff, thanks
problem is that horrible is not descriptive, and whatever I say is a guesstimate
yeah, fair enough
is the camera moving choppy? are other objects moving choppy? (choppiness is entirely my guess here btw)... or it could be something entirely different
anyways depending on monitor refresh rate, the character itself (whom camera follows) is choppy
position isn't updated smoothly (like it is with vsync) but "jumps" to new positions quickly
144hz is pretty much blurry, 60hz the "jumps" are slower/clearer
have you enabled interpolation on your rigidbody
interpolation should always be enabled for things like your player character
Quick issue, I have code that is supposed to load a new scene when I collide with something but I can't seem to trigger it? Should I post the code? It was tied to an empty game object with a collider and then rn I'm trying a specific sprite but neither of them are working
seems like not, will do that
thanks
did it make the movement smooth? there shouldn't be any jittering whatsoever, if there is then something is still wrong somewhere
can try in handful of minutes, fiddling with my project during work 😄
but I'd guess it will make it all pretty
perhaps try to add debug message when you collide to make sure that collision itself is actually happening
loading level itself should be fine, as there is no fancy logic other than
SceneManager.LoadScene("name");
also adding interpolation indeed fixed my weird movement, thanks again guys
huhh I can't seem to figure it out?
My character is physically colliding with the object?
then use OnTriggerEnter2D instead (or similar for 3D)
that doesn't collide "physically" but tells you when you went inside
ah you already are
It's not marked as trigger
It doesnt change anything if I mark it
Well it needs to be a trigger if you want to use OnTriggerEnter/Exit
could you explain to me how i can make this button be the ForceAdd Button please ?
You are mixing Input buttons and UI buttons. Not related
Just hook up the method in the OnClick in the UI button's inspector
Yeah I get that now just I dont know why it just doesnt do anything other than let me walk through it
The Three Commandments of OnTriggerEnter:
- Thou Shalt have a 3D Collider on each object
- Thou Shalt tick
isTriggeron at least one of them - Thou Shalt have a 3D Rigidbody on at least one of them
I have all that but 2D?
how do i do add ? ^^'
Then why are you using the 3D method
i know how to hook up a script but a method
whats...the 2d method
What
how do i hook it up in the onclick button
In this box, put in the method you want the button to call
nvm
there are tons of methods without any "3D" mention what won't work for 2D.. always good idea to check if "2D" one also exists if something doesn't work
not sure because i'm not english speaker, what is the method ? it is in the script right ?
I didnt realize I was using something for 3D aa my bad
the script is already added to the button but it's not especially a script for the button
method is the "proper" name for what you might call a "function". It's the thing in code you're trying to call with the button
yes it is what i thought :) but how can i drag it to the on click field ?
Drag in the object with the script you want on it, then choose that script and method
i can't really do that but maybe is it because it's the wrong method
Why not
ok I changed the code but I'm still having the same issue as before. I said that it couldnt load scene 2 bc it wasnt in the build settings so I fixed that which got rid of the error but it's still not taking me to the next scene? I tried messing with the trigger effects and I added the proper tag on the player character ("Luin") Do I have to edit the tag on the frontdoor too? I tried replacing "nextSceneName" with 2 since that's the name of the scene I want loaded but that wasnt valid so I'm just at a loss rn
actually i have an object to which i added my script. i addes this object to the button
i can't choose anything
in function ?
Show the inspector for the object this is colliding with
What function are you trying to call
i have this but apparently it's wrong. I just want to link this or whatever to the UI button
That's a controller button and has nothing to do with the UI button
what should i use
Your UI button calls a function when you press it. You need to make a function for it to call
OnCollision means not a trigger
does it call a function or a script ?
Neither object can be a trigger
It calls a function
how can i link the button to the function
Show the whole object inspector
Like this:
#💻┃code-beginner message
sorry it's very dumb lol
but there is no function related to the button
i may have to write it in the script but what do i write ?
What do you want the button to do
add 1 to a value
Then write a function that does that

