#💻┃code-beginner
1 messages · Page 206 of 1
Thank you guys
object reference not set to an object, why?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class buttonpress : MonoBehaviour, IInteractable
{
public Animator buttonAnimator;
public AudioSource source;
public AudioClip clip;
public TMP_Text buttoncount;
public int counter = 0;
public void Interact()
{
counter += 1;
source.PlayOneShot(clip);
buttoncount.text = counter.ToString();
buttonAnimator.SetTrigger("press");
}
// Start is called before the first frame update
void Start()
{
buttoncount = GetComponent<TextMeshProUGUI>();
}
// Update is called once per frame
void Update()
{
}
}
probably u set it to prefab?
Is the button in the same object as this script?
yes
Show the inspector for it
for the button?
You are changing the reference of buttoncount on start even though you have it assingned in the inspector , are you sure that is a valid reference?
For the object with this script
oh, ill try deleting it
Is the TMP_Text below this?
Ok, keep in mind that GetComponent only finds components on the SAME object as the script, and the text was not on this object
aaaaaaaaaah
I just learnt yesterday thay I should try to not use GetComponent at all if possible so...
You're free to use it. Just cache the results when you can.
Hi I have an issue:
I asume that the issue is that I need to use an else statement in this code, but not sure how to code it so that it freezes in it's position explicitly:
void OnMouseDrag()
{
if (weaponInstance)
{
poschange = mouseWorldPosition - originalPos;
if (poschange.magnitude <= maxLength)
{
GetMousePos();
weaponInstance.transform.position = mouseWorldPosition;
SetBands(mouseWorldPosition);
}
}
}
I would not agree with this at all
Still running into issues here. The charging behavior works once and then the enemy wanders forever and can't look at the player again. The last if statement here (if Vector3.Distance(transform...) is never triggered ever and I don't know why.
idk what is causing this but it looks cool
_robotObject.SetActive(false);
will this disable the robot and its update calls?
Well, I was told that is just way better to reference it directly from the inspector if possible since it is easier to mantain the reference through changes in the project and it is less demanding to have a direct reference instead of go checking a List to find it
You should favor serialized references when they're possible.
This doesn't mean you should literally never use GetComponent.
how can I use else to freeze the coords
This time I went out of my way with serializing
Firstposition is updated each frame to the player position, so comparing checking the distance between it and the player position is... always 0...
This question is too abstract and out of context for anyone to answer properly I think, could you explaining this better?
i believe that because it just has an if statement, it will exit the if statement when the condition is no longer met, resulting in the object and bands from no longer going to the mouse, even when the accepted length is met again
@swift crag
Hey, I was looking over your replies earlier. But unfortunately i'm just being too stupid to really understand here.
Would you be able to point out to me exactly how you would change this to suit your modifications?
I just want it to smoothly decrease the health text when damaged, and also not have the issues with the health actually being something like 89.872 instead of 90 when I only deal int damage
using System;
using System.Collections;
using TMPro;
using UnityEngine;
public class HealthController : MonoBehaviour
{
[Header("Health Parameters")]
public float smoothDuration = 0.5f;
[SerializeField]
private float maxHealth = 100;
[SerializeField]
private float currentHealth;
[Header("UI Parameters")]
public TMP_Text healthText;
public UnityEngine.UI.Image healthBar;
[Header("Colour Properties")]
public Color healthyColour = Color.white;
public Color criticalColour = Color.red;
private void Start()
{
currentHealth = maxHealth;
UpdateText();
}
public void ReceiveDamage(float damage)
{
StartCoroutine(ReduceHealth(damage));
}
private void UpdateText()
{
healthText.text = currentHealth.ToString("0");
}
private IEnumerator ReduceHealth(float damage)
{
float damagePerSecond = damage / smoothDuration;
float timeElapsed = 0;
while (timeElapsed < smoothDuration)
{
currentHealth -= damagePerSecond * Time.deltaTime;
currentHealth = Mathf.Max(0, currentHealth);
healthBar.fillAmount = currentHealth / maxHealth / 2;
healthBar.color = (currentHealth / maxHealth <= 0.4f) ? criticalColour : healthBar.color;
UpdateText();
if (currentHealth <= 0)
{
break;
}
timeElapsed += Time.deltaTime;
yield return null;
}
}
}
Learn single responsibility rule
But like, we don't know how the rest of the code is working or the setup of the game
Store the displayed health percentage in a field. Use Mathf.MoveTowards to steadily move it towards your actual health percentage.
Honestly, i would still disagree with that too
But it is a helpful way to do it
It's important to keep in mind that there is still work the processor does to reference the serialized fields, and it's not much less than GetComponent. The issue is surety and clarity
Ah that, funny enough it that script mostly deals with movement
Probably once you have already pressed to hold the sling, it should stop checking anything else and enter a state where it just moves relative the mouse until you release it
Yeah like 90% is movement and chasing logic
thats what its already doing, but once it leaves the range it freezes, and even if the mouse enters the range again, it won't follow the mouse anymore
Pretty sure it is checking if the mouse is pressed AND in range at the same time then
You should only check if in range to do the initial press
not sure what you mean
How to create an interface?
Just add new script and remove all text leaving only interface?
I know how they work, Im not sure how does unity implements them
like what do you mean, to implement them you just extend from it
There's nothing special about interfaces and Unity.
public class MyThing : MonoBehaviour, IMyInterface {
(there's very rarely anything "special" going on in C#-land)
doing so will force you to define all of its methods
If you don't show the entire code I don't think I can be of much more help, but pretty sure that you are indeed checking for two conditions in an if statement and fulfilling only one once you move out of the interaction range
Sure, so here's what I've done.
using System;
using System.Collections;
using TMPro;
using UnityEngine;
public class HealthController : MonoBehaviour
{
[Header("Health Parameters")]
public float smoothDuration = 0.5f;
[SerializeField]
private float maxHealth = 100;
[SerializeField]
private float currentHealth;
[Header("UI Parameters")]
public TMP_Text healthText;
public UnityEngine.UI.Image healthBar;
[Header("Colour Properties")]
public Color healthyColour = Color.white;
public Color criticalColour = Color.red;
private float displayedHealth;
private void Start()
{
currentHealth = maxHealth;
displayedHealth = currentHealth;
UpdateText();
}
public void ReceiveDamage(float damage)
{
StartCoroutine(ReduceHealth(damage));
}
private void UpdateText()
{
healthText.text = Mathf.RoundToInt(displayedHealth).ToString();
}
private IEnumerator ReduceHealth(float damage)
{
float damagePerSecond = damage / smoothDuration;
float timeElapsed = 0;
while (timeElapsed < smoothDuration)
{
currentHealth -= damagePerSecond * Time.deltaTime;
currentHealth = Mathf.Max(0, currentHealth);
// Smoothly updates the displayed health towards actual health
displayedHealth = Mathf.MoveTowards(displayedHealth, currentHealth / maxHealth * 100f, smoothDuration / timeElapsed); // Calculate smoothness based on remaining time
healthBar.fillAmount = currentHealth / maxHealth / 2;
healthBar.color = (displayedHealth / 100f <= 0.4f) ? criticalColour : healthBar.color;
UpdateText();
if (currentHealth <= 0)
{
break;
}
timeElapsed += Time.deltaTime;
yield return null;
}
}
}
I have a question though as it has to still be wrong, I am spamming my trigger to deal 5 damage as a test, but if I do it rapidly. It seems to mess up the health somehow, for instance, I am currently on 13 health even though it should only be taking 5 damage?
please share large blobs of code on a paste site: !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 my bad, sorry
Do not mess with how the player actually takes damage
Don't smear out the damage over time.
You're strictly smoothing out how you display your health
Hmm, could you point out to me where I'm going wrong here then?
I'm genuinely not sure where I've messed up
You're starting a whole coroutine when you take damage
Just subtract the damage from your health. That's it.
You said you are managing health as ints, why are you declaring the health as floats then?
That's all of your logic for changing your actual health value.
Then, in Update, you can smoothly move the displayed health percentage towards your current health percentage
You can throw out ReduceHealth entirely.
It doesn't make sense to start a coroutine for every instance of damage, all of which fight over the health text
void Update() {
float currentPercentage = currentHealth / maxHealth;
displayedPercentage = Mathf.MoveTowards(displayedPercentage, currentPercentage, Time.deltaTime * 3f);
healthText.text = $"{displayedPercentage:P0}";
healthBar.fillAmount = displayedPercentage;
healthBar.color = displayedPercentage < 0.4f ? criticalColour : normalColour;
}
that's pretty much it
Okay got it, sorry about that and thanks also.
Genuinely braindead right now lol
Haven't taken a break in hours
in short: separate your actual values from your displayed values
If you don't you will get weird results such as taking damage that sets you to 0 health but you still have to wait for it to do the transition even though you are already dead
yeah
Yeah, think that was the kind of thing I noticed earlier too
For bonus points, extract this logic into a Healthbar component
It can keep track of its smoothed out values on its own
transform.position should be the AI's position though
i'll do agent.transform.position tho and see if that helps
nope, still doesn't trigger the block
Add a Debug.Log to tell you the two positions you are checking and the distance between them, that usually helps a lot to spot this kind of issues
Not sure what to make of this. It charges directly towards the first known position of the player once the timer hits the certain point, but then it goes back to wandering
what is this? is in the ar project template
Doesn't seem to be... actively calculating the distance maybe?
Regarding this, I just had one more question
public void ReceiveDamage(float damage)
{
currentHealth -= damage;
}
private void Update()
{
displayedHealth = Mathf.MoveTowards(displayedHealth, currentHealth, Time.deltaTime * 5);
healthText.text = displayedHealth.ToString("0");
healthBar.fillAmount = displayedHealth / maxHealth / 2;
healthBar.color = displayedHealth < 0.4f ? criticalColour : healthyColour;
}
Is it not inefficient to be running this update every frame even though the health will only change on damage or healing?
I was wondering if there's a more optimal way to do this so that it is still smooth but not wasting any resource?
The distance should definetly be a float, those are positions
Do Debug.Log ( "Position: " + transform position + " // Target Position: " + firstPos + " // Distance: " + Vector3.Distance (transform.position, fistPos))
what does this mean?
how can I square a vector
What does what mean
or, more specifically, make it exponentially smaller
the reference
What about it
what do you mean square it/make it exponentially smaller?
why is it there?
...because that's where you're using this function?
get a vector (for move direction/speed) and if it goes above a certain threshold: decrease it (and decrease it more if it's a higher number)
then that has nothing to do with my problem : (
You haven't mentioned a problem
I can't seem to be able to click the button I made to go to the next site
Yo again, I’ve got a new asset for a turret I’m working on, it’s the sci-fi turrets (cannon) asset from unity asset store, and I want to have the user use the left and right controls to move the turret left and right (this is a placeholder, I am supposed to use a robot to move it later on, but I know how to make the change). I’ve done something similar with a very basic turret I made using cubes, the code for that is here: https://pastebin.com/6qezXDh5. I want to convert this code into now be able to change the x axis of the turret (its split into 2, the base and the gun). Are there any videos, or any steps where I can learn that.
Show button
Probably just some preview image for the template package
actually it's an icon
so you have value v. threshold t1, threshold t2 above t1. clamp v to t2 at the top. take diff = abs(v - t2). then damping = diff / (t2-t1). multiply damping by v. you could also square damping for a faster dropoff. math might be slightly off but the basic idea is you are applying a damping factor between 0 and 1 based on where your value is above your threshold, up to a full dropoff threshold (t2).
Maybe what you want to do is to Clamp each of the axis of the vector????
I have figured out mainly all of the basics of c# and i want to start coding with unity 3d, but i dont know where to start with all of the new code
check the pins in this channel
plenty of resources to learn
just start making a simple project and look up all the things you need to do
bad way to learn..
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MonkeyScript : MonoBehaviour
{
private bool canThrow=true;
[SerializeField] private GameObject MP;
float targetPositionX;
float distanceX;
[SerializeField] private float WantedDistance;
[SerializeField] private float speed;
void Update()
{
targetPositionX=GameObject.FindWithTag("Player").transform.position.x;
distanceX=Mathf.Abs(targetPositionX-transform.position.x);
if(!(distanceX<=WantedDistance))
{
float step = speed * Time.deltaTime;
transform.position = Vector2.MoveTowards(transform.position, new Vector2(targetPositionX, 0.2f), step);
if(canThrow)
{
Instantiate(MP, new Vector3(0, 0, 0), Quaternion.identity);
canThrow=false;
DelayThrowing();
Debug.Log("Threw an object");
}
}
}
IEnumerator DelayThrowing()
{
yield return new WaitForSeconds(0.5f);
canThrow=true;
}
}```
Does anyone know why the Debug.Log doesn't write anything?
that's one way but learning by doing is also a completely valid way
here's the code
https://gdl.space/ufekecodoh.cs
they said they figured out hte basics of c#
@mild mortarhey man you fixed it? I wrote 120 lines of codes myself in the moment (with 13 errors left to fix now)
people say a lot of things, doesn't mean its true
is there a question here ?
ok well... i've been doing this for a long time and looking up every item i want to do is how i learn
Hey bud, yeah it's fixed now. I managed to use someone else's suggestion 🙂
Thanks for everything
Does anyone know why the Debug.Log doesn't write anything?
It was under the code
can you reference the solution
everyone can learn
It's completely fine.
your condition is never true
Log hit.transform.gameObject inside your raycast, but outside any of those if statements. See if it ever hits anything at all
But shouldn't it be true after 0,5 seconds after throwing AND in the beggining?
if the log is not writing
A. either script is not running
b. you have compile errors (see #1)
c. Your if statements aren't evaluating to true
Hey man, my Player object has the scale of 1,2,1
What do i have to do ?
I can't ruin the scale
It was originally a sphere
Can I make turn the sphere into a capsule ?
Hey guys, can you call a OnCollisionEnter function on an empty parent object?
not the first 2
That's why I suggested parenting the visual object to the player object
the Visual can be scaled however you want
okay so either canThrow = false
or the other one
!(distanceX<=WantedDistance
the Player should have a scale of [1, 1, 1]
yeah your right
"maybe" set it to change in update once its changed?
yh
I see it now
thx
What's Visual ? (in this context)
the thing you see
How do you mean? I've been trying to find out a way to solve it similar to what you said, but I haven't been sure
There is nothing to solve. Just update the text and healthbar every frame.
It's fine
maybe my man has a thing with optimizations
h1mmm
Is Sphere the Visual here ?
Experimentation is good, but it's way less frustrating when you know the basics
And, well, way more efficient
Correct. You shouldn't have anything else parented to it.
Is that the thing you see
Compare your hierarchy to the one I showed you.
No worries, I'll keep it more or less as it is then, thanks for you help 🙂
All I've done for now is just put it inside an if statement checking if the health matches
to be able to update health only when it changes
Add a component that responds to OnTriggerEnter
Have it call a method on something else.
i'm not saying blindly experiment, i'm saying have some simple project you'd like to make and each time you need to know how to do something to make that project, look up what you need to do.
public class Hitbox : MonoBehaviour {
[SerializeField] Player player;
void OnTriggerEnter() {
player.Hurt();
}
}
So I can't avoid the script on the children?
e.g.
how can I restrict the force that a rigidbody has? (Stop player from going 2786 mph from holding w)
Or maybe serialize the child?
If a parent has a Rigidbody on it, then components that are siblings to the Rigidbody can receive trigger and collision messages.
clamp your velocity
Rigidbodies don't "have" force, they have velocity
how do I restrict the velocity then
If a child has a RB/Collider, I can't call it on a parent object, right?
Either clamp it directly or don't add force or add reduced force when going too fast
another option is add drag forces
or use the Rigidbody drag feature built in
maybe he means addforce and got confused
I know this man he is total beginner
Yes I know what he meant just clarifying a misconception to make his understanding more clear
"rigidbody" and "collider" are two extremely different things
I take mild offence to this
A rigidbody allows an object to be affected by physics. It uses all of the colliders that are parented to the object.
Im sorry didnt mean that. maybe people could help you better if they know this
Trigger or collision messages involving the child collider will also go to the rigidbody's object
Although, I am not sure off the top of my head if a receiver on the child will "eat" the message
i.e.
I mean I started doing unity and c# like a week ago so I'm pretty proud with how well I'm doing
- Root <- rigidbody, trigger-listener
- Child <- collider, trigger-listener
I'm not sure if Root will get OnTriggerEnter messages
anyway, this is the most general way to do it.
very good man
It's also very useful.
damn I just added 1 drag and the problem is solved
You can add information that's specific to that collider (imagine a head hitbox that causes more damage)
Root <- script
Child <- collider, rigidbody
This is what I have, I want to trigger "OnCollisionEnter" on the root script
To centralize stuff you know
Why is there a rigidbody on the child?
Is this bad practice?
I think only the root will get the messages here
well, if Rigidbody is non-kinematic, it'll fall away from the Root
oooooh that's why
I just don't see why you aren't putting the rigidbody on the root
The rigidbody defines what the object "is"
Ok and for the "rendering", I leave it on the child right?
You generally want to parent the visuals to something else, yeah.
how can I allow player to walk up a hill/steps without a character controller because I have a rigidbody and last time I checked they don't work well together
Like Root > Collider/Rigidbody/Script
Child > Renderer?
The collider can also be on a child.
Ok
But you can leave it on the parent if you don't have a strong reason to put it somewhere else
For the headshot/Torso shot... etc?
Definitely for these. You'd attach the colliders to various bones on your armature.
Ok man, thank you, you're amazing
is there any way to make a line renderer keep rendering? when every my camera gets too far from the center of my line, it stops rendering even if some of the line should still be visible (like this)
Looks like the answer is "both"
Maybe your camera's far clipping plane is too low
god this test project is a mess
characterController?
Make sure your Renderer's Bounds are correct https://docs.unity3d.com/ScriptReference/Renderer-bounds.html
the built in component
You'll need to look for stairs and pull yourself up them yourself, then
that's why people like to use the CharacterController (:
why not use it?
You'd raycast downwards, starting from a little in front of your character, and see if the ground isn't much higher than the player
if so, raise yourself up onto it
he doesn't have this in the tutorial but when I remove it I get about 30 errors
Oh, interesting. I remember wrong then
how does one raycast
characterController has built in var for that kind of movement. why not use it?
It kinda handles things poorly in many cases.
It can be perfectly fine to use though
so does raycast
If I have all my enemy prefabs searching for the player on Start, would it be better to have a general script just to store a reference to the player to reference it directly from there instead of searching it anew every time or it doesn't really matter?
False
Plus the cc USES raycasts
i have this button with the code:
using UnityEngine;
using UnityEngine.SceneManagement;
public class Button : MonoBehaviour
{
public void NextScene()
{
SceneManager.LoadScene("SampleScene");
}
}```
when i try to click on it it dosent take me anywere. any suggestion?
It's probably better to just directly pass the reference to the enemy script as you spawn it, from the spawner script.
Rather than "finding" it
Why do you have a random block section with no condition or loop before it
give whatever spawns the prefabs a reference to the player and it can just pass the reference to the prefabs on spawn
Does the code actually run? Did you put a log in to make sure it runs? Are there errors?
You have to actually set the function you want it to call
yes, the code runs, not i didn put a log in, there are no errors
🤷♂️
you added the button script not a gameobject which has the button sript
can you explain more?
I mean when you walk down the hill
How d you know the code runs if you didn't put a log in?
The thing is, I was planning the spawner to be a separate prefab object instead of a general manager that stays in scene
there has to be something there
There's No Function assigne dhere
did you actually link the function
the code is definitely NOT running
i start the run time?
so>?
What about it?
Raycast is perfect for that
something is gonna have to put it into the scene though and that can just pass the player reference along
isnt that the code starting?
No
Okay, are you calling this function in Start somewhere then?
so you'd have to forcefuly apply - gravity
This is how you set up your button to run the code, and you haven't done it properly
See how it says "No Function"
As you do with cc
But you DON'T have to do with raycast and dynamic rigidbodu
I prefer SphereCast over Raycast when doing grounded/movement sensor checks. A ray can go through a tiny gap which is usually unwanted
oh yeah i saw that
but i dont see anything useful there
because as someone already mentioned, you dragged the wrong thing in
you dragged the script in
that's not correct
u need to drag the script from the object
not from the project folder
script instead of gameobject with script
step offset?
oh ok, so i add the script to my button, and then drag it as function
what do I do?
I must've assumed/misremembered that it works like OnCollisionEnter, which gets sent to the rigidbody only. Which I don't see mentioned in the docs anywhere 🤔
sure, but I would advise against putting scripts nested in UI objects. But ofc do whatever is easier rn
About what
It's quite clear you don't really understand, and that is fine. But raycast is not the alternative for character controller
Rigidbody or transform movement is.
CC USES raycasts to do what you're talking about
no you drag the GameObject that has the script attached to it into the button slot
it doesn't have to be the same object the button is on
but it could be
somethng like this?
why is Length returning high values? (correct value + 1)
using UnityEngine;
using TMPro;
public class MenuUIHandler : MonoBehaviour
{
private TMP_Text playerNameText;
void Start()
{
// text GO within text area GO, not the placeholder
playerNameText = GameObject.Find("PlayerNameText").GetComponent<TMP_Text>();
}
void Update()
{
if (playerNameText.text.Length > 0)
{
Debug.Log("\"" + playerNameText.text + "\" = " + playerNameText.text.Length);
// always greater by 1 than it should be?
// "" = 1
// "t" = 2
// "test" = 5
}
}
}
my problem
naming your script Button is a bad idea
Yes - though the fact that you named your script Button is causing that annoying naming conflict you see
This might be that invisible character problem
What is your problem? I don't know what this question had to do with you adding in a debug log to check your raycast which you haven't done yet
If that TMP_Text is the placeholder text for a UI Input, there's an invisible character at the end
oh ok, but now what do i need to put as function?
try to avoid the names unity already took, until you start learning namespaces
The function you want to call
@polar acorn Was it you who was familiar with this? Invisible character at the end of TMP_Text.text
What do I add?
next scene?
isnt that what you want to run lol
Yes, I'm checking my post history to find that character code
well thanks. I intentionally finished the sentence with ? for a reason
you think I know what that means
It was meant to be a bunch of prefab levels where the spawners are preset on a possition and whatever they spawn of if they spawn anything at all to be somewhat randomized
Found it. This problem drove me up the wall a month or two ago and this is how I solved it
#💻┃code-beginner message
thx for all the help, the code is working and i am starting to learn more
Indeed!
I also couldn't get OnCollisionEnter to work at all, which is...weird. But OnCollisionStay indeed fired only on the parent.
And not have a proper SpawnManager for the task
Yes. Debug Log should literally have been the first line of Unity code you ever wrote, and I told you exactly where to put it and what to log
okay? so why does that prevent you from passing the player reference when the objects are spawned?
now i try to build the app and pray that everything works
I assumed that reason was that you thought I was unaware of step offset. A meaningless half-sentence with a questionmark is usually sarcasm. Sorry for that assumption
no problem my bad. I need to communicate better via text
wow, okay. thanks to you and @verbal dome for suggesting invis chars
I guess I 've got to learn to write Debug Log
That I don't have it stored anywhere to pass it
I never do sarcasm when its about learning.
You should not have gotten this far without doing so in the first place
man if only you could change your own code to be able to do that
ok I'll go do that now
OnEnter not working does sound unusual, especially if OnStay worked 🤔
Lesson 1:
- Use Debug.Log when you don't know what's going on. You made an assumption your code was running. Debug.Log would have proved that assumption false for you and gotten you looking into why it wasn't running.
on the unity engine i see the button in the scene, but on the build and the phone i dont see it. i thinl its because i need to set the scene to be the first, but how do i do that?
i will learn how to use it
you can change the scene order in the build settings. but i'm willing to bet that the issue is your canvas scaling
i dont think the problem is canvas scaling
but what about canvas scaler
that doesn't really tell us anything about canvas scaling
that screenshot proves nothing
oh no it was because i didnt put the scene
That was... what I was asking... if I should change it to have a reference of the player stored on a abstract script accesible for everyone instead of searching for it for each object
well might want to check scaler as well, make sure its set to scale with Screen
but now i have the sample scene (the ar one) set as 0, ant the menù set at 1. i need to change the order
You can easily drag them around to change order
and this entire time i've been telling you to store the reference to the player on the object that spawns those other objects so that the reference can be passed to them when they spawn instead of relying on any Find calls or whatever it was you were doing before
thx
now lets test if scaling was right and if boxfriend won the bet
Your canvas scaler is probably still wrong, button Might appear but could be wayyy off then it is in scene view
proper anchoring and canvas scaler set to Screen is a must
lets repair this problem, what do i need to check?
is instantiate real?
Canvas Scaler component on the Canvas
unity is telling me its not
damn thef the hell is wrong with the fing animator? Everythings saved except for the changes I made in animator Im really sick of it. I set run static as layer default state now its idle again and also the animations are just fkin messed up
yup its wrong
you need Scale With Screen and set a base resolution
Constant Pixel Size isn't good option
scale it with screen size? is it better?
Im really sick of unitys animator
use Animancer then
thank you
Configure your !ide so you stop making spelling errors
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 wonder if Animancer uses AnimationClip.SampleAnimation under the hood
I thought conditions resetting was the only issue so i switched to latest again im so stupid
never used an external one gotta check out
thank you, very annoying knowing everything is broken cause i suck at spelling
were you the one who had the Transition conditions Unset itself ?
yes
do we have to manually save the animator exceptionally itself or something?? is saving the project not fkin enough???
Have you tried creating a new animator controller?
Just in case the file itself is somehow messed up
Yeah, it should save without any extra hassle
But the objects that spawns the enemies are separate several objects, storing a reference there doesn't fix anything
that may be the case or my HDD is finally dead or something
it eliminates the need for any of the costly Find methods
on line 103 and 123 it says "cannot convert type 'UnityEngine.Transform' to 'UnityEngine.GameObject' "
https://hastebin.com/share/joyezafoxo.csharp
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
okay, so give all of them a reference to the player
It feels so bad when you made a lot of progression just to see it mess it up itself
Yeah because you wrote:
foreach (GameObject slot in slotList)
but slotList is a List<Transform> not a List<GameObject>
exactly
computer never is wrong
slotList is a list of transforms. You're trying to store one element of it in a variable of type GameObject
These are not the same class
trying this if (Physics.Raycast((transform.position + new Vector3(0, 0, 1), transform.TransformDirection(Vector3.down), 1))) but it's saying to make a struct and add in like 80 lines at the bottom and I'm not sure that's what I want
what's saying to "make a struct"?
oh they've gone and thrown a tuple into the parameters for Raycast
what's a tuple
I would suggest not cramming everything into one line
create a Ray out of the position and direction
Once again, the spawner would still need to Find the player; is no difference having 10 spawners looking for 10 references than having 10 enemies looking for 10 references, in fact is even worse
no, the spawner is given a reference to the player: either by assigning it in the inspector, or by being given to it by whoever instantiates the spawner
why would it need to find the player. something has to be in the scene to spawn things in, right? so just give that thing a reference to the player and let it pass the reference to the things that it spawns
if (Input.GetKeyDown(KeyCode.Space) playerIsOnGround)
{
playerAnimation.SetTrigger("Jump_trig");
}
shouldnt this work or am I losing my mind for real. player is just in his idle state
The player is not prefab, it is not spawned, it is just there
exactly
okay, great, so you can just assign a reference to the player
so just give the spawners the reference
wrong syntax
this wouldnt even compile
you can multi-select all of your spawners and give them all the reference at once
Is a thing on the scene, and I cannot give a reference to object on scene to a prefab
!ide @mortal bridge
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
okay, then whoever creates the spawners is given a reference
I mean there is && but I tried to delete it but forgot the onground part
to make it a simpler code
what is in the scene that spawns those other prefabs? because, like i've been saying this whole time, you give that object the player reference
why are you sending omitted code then
that makes 0 sesnse
So it's in the idle state? This transition goes from Walk, not from Idle
if (Input.GetKeyDown(KeyCode.Space) && playerIsOnGround)
{
playerAnimation.SetTrigger("Jump_trig");
}
here you go
this is copy paste
better
It "starts" as idle
doesnt change at all
is it going into walk first though
I guess I could store a reference there, you are right
then make a transition from Idle to jump?
It isn't not yet implemented so I was not thinking about it sry
why would I. characters supposed to jump while running that would look unnatural
You're the one who says it doesnt go into jumping if its Idle. So I'm confused on your original issue lol
if (Input.GetKeyDown(KeyCode.Space) && playerIsOnGround)
{
Debug.Log("Jumping");
playerAnimation.SetTrigger("Jump_trig");
}``` confirmed this stuff is actually running yet @mortal bridge?
It does. there is no jumping "animation"
So does it change or does it go to walk. Pick one
Vector3 rayStart = transform.position + new Vector3(0, 0, 1);
//raycast direction
Vector3 rayDir = transform.TransformDirection(Vector3.down);
//actual raycast
if (Physics.Raycast(rayStart, rayDir, 1)) ;
{
transform.position = transform.position + Vector3.up;
}```
(this might be too long and need to go into website but I can't really be bothered)
would this work?
Game starts check
player walk animation for 0.5 seconds check
idle forevermore check
you should be using the actual point that you hit
it does
theres just no animation
Also, you put a ; after the if statement, so it's not actually controlling the following block
how do i get that
if (Physics.Raycast(start, dir, out var hit, 1f))
{ ... }
as described on the doc page
good catch!
the third parameter is out RaycastHit hit
an out parameter lets a method assign something into a variable
You can declare a variable as you pass it into the method.
and var can be used in place of RaycastHit, hence why that works
..., out RaycastHit hit, ...
this would also work
everything you can ask for
sorry for the great wall of china.
Im just so sick of this animation stuff
could've just madea thread..
want it sorted out
also #🏃┃animation
Its actually somehow related to code
how so you said the trigger ran ?
SetTriggerSetBoolSetInteger
these 3 is all I have
for animation stuff
oh i missed the so there i thought you asked how it ran
so yeah it runs
no animations
so then its not the code lol
make a video of the Animator during playmode with object selected, it will show whats happening with transitions
I'm rather confused but why does this if (Physics.Raycast(rayStart, rayDir, out stepLocation hit, 1)) have an error (chances are it's because I didn't understand your code due to lack of experience)
what error
plzzzz help
with ?
I dont understand video
rather than the wrong type
Your object doesn't have a Text on it, it has a TMP_Text. Use the correct type in your code.
i cant move diolog text in doiolog box
ill show u the code
then its a TextMeshPro and you have Text
I don'tneed to see it
right, I thought I was putting in a variable
it still stops rendering
I can already see that you used Text instead of the correct TMP_Text
that's hit
jesus
out TypeName variableName
We don't need this
Hey man, I have some scripts attached to a game object, it's a sphere
But now I want to duplicate this GO and make it an empty GO
Is that possible ?
mate we pointed out issue already lol
#💻┃code-beginner message @quartz mural
yep, I understand now
oh mb
well yeah its possible
why not just create a new gameobject then if its gonna be blank
How should I pass variables between scipts on the same object?
Make them public or get; private set?
where?
I did what you said
post it in #🏃┃animation
no no where does it show it
if you slect the object with the Animator during Playmode it shows you the Animator working
then you can inspect the transition
and see whats actually happenign
sorry im a begginer, if i dont use .test then what do i do 😅
Also, in the future either do an actual screenshot or share code as text
.test ?
ok
What?
Already told you the answer, and it has nothing to do with ".test" or ".text"
TMP_Text
now how can I turn that into a vector3 to move player there
thank u
In Animator window?
well yeah...
but when I pause and play game again view is set to the scene again
I cant track it due to it
But the components you know ?
There're a lot of them attached to the old object.
It might be confusing ...
you made it worse lol
Not sure then. Praetor did mention the bounds of the renderer, but I'm not sure if you can edit the bounds of a LineRenderer
Text is the old type you have to change to TMP_Text
You can edit the bounds of any Renderer @random totem
through the .bounds property
are those lines supposed to turn blue?
blue?
how do i do that
By changing the type from the one it is not to the one that it is
well I actually dont know how to track it and nothing changes in the animator windows to be honest I checked everywhere
You select the object with the animator at runtime, not diffcult
😭
It is selected but nothing changes here
ohhhh
pay attention to what was said earlier
i thnk i got it
Im in play mode here
did you select the player or whatever has this animator?
also why the hell is it semi-transparent
yes yes. I even had special moments with the gizmo to make sure
The thing you changed is called the "Type"
So now in the future if someone says to change the type, you know what they meant
damn actually nevermind. I think animation is not my field
Yeah something fishy here
Make sure to let them know that it might be bugged
I just never seen it semi-transparent
Try one thing. Reset your layout. Might be an Unity UI bug 🤔
Because yeah those are definitely supposed to not be transparent
Does your animator have layers
Good question
my animation has a blue rectangle is there a way to get rid of it
I fail to see a blue rectangle here
original sprites
Ah, slightly blue tinted red
nothing changed
Try disabling compression
Try turning off the compression or using higher quality
why are those not suppoesd to be transparent?
how do i turn off compression
on the import settings for the image
ok
I just wanan relax myself by thinking that its not my fault but unitys fault
fixed thanks dudes
So, the layers could absolutely explain why the animations aren't working properly, depending on your settings for them. I don't really do anything involved enough with the animators to ever need more than one, and I don't know what the "M" means. This might be a question for #🏃┃animation
avatar mask
Oh, M means that it's using an AvatarMask
Maybe it has a mask with nothing selected
But yeah, more suitable for the animation channel
can you come there?
Well I can take a look, but i'm no animation expert either
As I said I dunno animation I just know enough to know that when layers get involved everything I know is off the table
And there might be cases when a layer doesn't update at all if layers after it completely override it
Anyway moving to anim channel
how can I refer to forwards relative to the player
Sorry to be this guy, but you really should google simple questions like this
"unity get forward direction of object" would be a good search
player.forward assuming player is the player's Transform
hi, is there anyone to help me please ? I don't know how to open a file .unitypackage
thanks a lot
i'm trying to instance a prefab but for some reason it's invisible? 8it's in italian if you ned i can provid translation)
Well you never selected one in the video so we couldn't see it.
But presumably it's just not in view of the camera
most likely a Z axis position problem
You also really need to watch out for that because you're using Vector3.Distance which is also going to include the z axis distance
mousePosOra.z = 0; after ScreenToWorldPoint is probably all you need
ok it works thanks <3
you're basically doing this whola game for me hahah
I have a List of Edges and have a function that takes a List of Vertecies. Is there a lambda I can use to convert the List<Edge> into a List<Vertex>? or do I need to make a separate function for that?
Hi! I'm trying to make a Play again button for my game. I am using SceneManager.LoadScene(SceneManager.GetActiveScene().name);
to load the scene again, and it seems to work, but on the restart things start to behave differently and it throws this error MissingReferenceException: The object of type 'InGameUIManager' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object.
Do you have DontDestroyOnLoad objects
I don't think so
What's the default for that?
Show a screenshot of your scene before and after restarting
Oooh
You have a DDOL object that references something in the scene
When the scene reloads that object no longer exists
How do I create it for the scene again?
Create what
If your DDOL references something in the scene, either that thing also needs to be DDOL or the thing referencing it should no longer be one
Or, you could re-acquire the reference in code using a scene loaded callback:
https://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager-sceneLoaded.html
trying to recreate character controller step-going-up and this script makes me fall through the floor, not sure why. ``` //trying to make steps work
//raycast start
Vector3 playerFeet = transform.position += new Vector3 (0,-1,0);
Vector3 rayStart = playerFeet += (transform.forward * 0.5f);
//raycast direction
Vector3 rayDir = transform.TransformDirection(new Vector3(0,-0.75f,0));
//actual raycast
if (Physics.Raycast(rayStart, rayDir, out RaycastHit stepLocation, 0.99f))
{
//make bottom of player teleport to point
Vector3 stepLocation2 = stepLocation.point + new Vector3(0, 1, 0);
transform.position = stepLocation2;
}```
Okok
If you're falling through the floor, you likely are being teleported into the floor. Your raycast which is starting inside the floor, will not detect the floor. Thus you fall
Apparently it's something with the "Rendering.DebugUpdater", I'll look into it
Thank you!
my dear freinds
is there any form to add a motion to a object which has been hit by a bullet raycast?
like motion to the direction of the ray
I'm no professional but could you have the raycast go a bit further then calculate the vector between the hit object and where the end of the raycast is? can't guarantee it will work at all but it's an idea
What part do you struggle with specifically? You can pass a value to some knockback method for what direction the bullet was going
that's probably better
{
if (hit.collider.attachedRigidbody)
{
hit.collider.attachedRigidbody.AddForce(ray.direction * 0.1f);
}```
is there a way to add a field in the inspector where you choose a component that is a script and choose a function from that script? What I mean is, can I make my field function specific?
well UnityEvents let you do this, and inspectors are fully customizable... what are you trying to do?
I want to make a lever that can interact with scripts
public UnityEvent onLeverPull;```
then to call it:
onLevelPull.Invoke();```
What about the receiving end?
it doesnt works 😭
what doesn't work about it?
Consider impulse if this is from the bullet and only a single instance of force should be applied.
Why this values arent shown in Unity fields?
They are properties
Unity only serialized fields
Those are properties
you could add:
[field: SerializeField]``` to serialize the backing fields.
Maybe use field: SerializeField. Ah blue beat me to it.
you're already targeting the backing field with the Header attribute 🤔
Those are just debug values so I can see them ingame
Issue is they are get; private set
that's called a property as was already pointed out.
you knew to target the Header attribute with field:, did you not think to try that with the SerializeField attributes?
funny enough im not sure what field does 🙂
I dont remember even from where I got it
Gpt?
it targets the attribute at the backing field. as we've been saying
Im pretty sure compiler reccomended it
Im running on my last braincells. It takes a while before I even get what you mean xD
then take a break and come back to it with a fresh mind
don't force everyone to do your thinking for you just because you are too stubborn to take a break when you need to
I mean I literally going to sleep in like half an hour
programming when you are tired isn't a good idea
Omg its alive
Its always "just want to do one thing". Tomorrow it will just be another thing
Take a break unless you are a slave at blizzard
When I was playing factorio I had same "gonnado this and go rest"
that thing took 5 hours
Get off the damn computer and take a break
You'll learn much more effectively that way.
it is get only
as I though
can still set it in the inspector though i believe
incorrect. get only properties generate a readonly backing field which cannot be serialized by unity
ahh
Hi, i am currently programming a evolution simulation 2d and i have problems programming the Raycast part of it
Code: https://gdl.space/zecinireyu.cs
The code runs in FixedUpdate
The problem is that even though (form what i can see with the DrawLines) they never turn green and even if they hit their target they sometimes if you wiggle them a lot maybe somtimes they see them. I have tried many youtube videos and asked also gemini but they couldn't help me
Thanks 🙏
can sopmeone with codoing experience help me
im having trouble with my code
i cant find anything online to help
Are you sure it's not hitting the creature/agent itself?
whats your quwstion?
me?
dont ask to ask
if i would shouldn't the rays turn green?
if i am hitting how could i change it so i don't? should i add the the position maybe half of its scale?
it is in playerinput but its not working
show us the code
Put it on a different layer and use a layer mask in the Raycast method
make sure that your !IDE is configured so that it will suggest properties that actually exist while typing the code
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
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
is onfootactions a... type?
why are you declaring a variable of type onfootactions?
hold on
also you need to configure your ide
i have more code
they've probably spelled the name wrong or not saved their input action asset
yea i dont know how to do that
@calm dust
we don't need more code. configure your IDE
🤦♂️
oh wait
i think they need to start with some c# basics tbh
we need some reading basics tbh
Does On(Dis/En)able apply to the object a script is attached to, or the script itself?
Yes
and yes, it would be a type (provided it is spelled correctly and they are using the correct PlayerInput type)
Both
thought so
Is there a way to specifically disable a script while leaving the object alone?
There isn't a check box next to scripts in the inspector
you can enable or disable a component using that components enabled property
set the enabled property to false
then that component does not define anything that is affected by being enabled/disabled (so no Update, OnEnable, etc)
There is if that script contains anything that can be affected by being disabled
Okay, thanks.
ok, i configured it
do you see red underlines in your code now
yes
yay
can you show the problematic code now
great! now remove line 4
ok done
has the error gone away?
no, another one came up
care to share? remember nobody here can see your screen
sure, hold on
why would removing the importation of the inputsystem fix the error?
they are following a tutorial that generates a class called PlayerInput from their InputActionAsset. they want to use that class not the InputSystem.PlayerInput class
ahhh I gotcha
rip
lemme double check
keep in mind that spelling matters, including capitalization
Hey guys, what kind of timers do you prefer in unity?
C# Timers (System.Timers), a simple Coroutine, C# Async?
Wanna set a timer that destroys an object if it doesn't hit anything in a specific time
Is this that tutorial from Dave something (Dave Makes Games?). That one has caused so much confusion for people
probably the most annoying thing about that tutorial. most issues i've seen come from that tutorial are specifically because of the naming of that class
Does Unity has its own Timer implementation?
Definitely not system timers
Why?
Either accruing deltaTime, tracking differences in Time.time or a coroutine
just call Destroy in that object's Awake or Start method and pass the desired time as the second parameter
i followed it exactly
Because it runs on the system time which varies from game time
show the input actions and the inspector for the input action asset
Can I cancel that operation before time's up?
no but you never specified that 🤷♂️
If you want cancellable, I would cache a coroutine and stop it with StopCoroutine if needed, or accrue deltaTime and halt it if needed
could invokes work?
invokes are cancellable
invoke is gross because it uses reflection, but yeah it would technically work
reflection?
Yeah, just wanted to clarify if I extend my use case 🙂
@slender nymph
and the inspector when you've selected the input action asset
i dont know what that means, im sorry
That's not named PlayerInput
you know the thing you double clicked to open that window? click that thing once and look at the inspector window
nor is their action map "onFoot"
the C# class's name is defined in the inspector, the name of the asset is irrelevant
But it defaults to the file name of the asset, and since they literally do not know what the inspector is, it's unlikely to have been changed
so you remember how i said spelling including capitalization matters?
you need to fix the class name either right there or in your code. then you need to spell the action name correctly in your code too
i did that but the error is still there
Which of the two things did you do?
in the code
What did you change it to? Exactly
Playerinpu
did you make a typo or is it actually without a t in your code
typo
ok
Well if you put this much care into typing your code as you put into Discord I can see where your problems are coming from
funny
what's the error say now @calm dust
And you did NOT change the asset here?
#💻┃code-beginner message
that too
Change the type, not variable name
And readvalue is not a thing
Remember that capitalization matters
they just have a whole bunch of spelling mistakes
Basically, instead of having us spell check everything for you one thing at a time, configure your !ide and go retype it all properly this time
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
they did configure it
they just don't know how to use that
😔
Then autocomplete should be catching these
they claimed to have configured it. we have no proof thtat they did
true
well, i did what the website said. the website that the bot linked
screenshot your code
took the words out of my mouth
just so you know, i did what @summer stump told me toi do and changed the other onej
if i had a dollar every time..
let's not play the blame game
show your codeeee
What did I say to do?
it looks different and im just telling u why
it is configured at least
Yeah, I said change the type
You did not do that clearly
Because in four places the type is still PlayerInput
😮💨
I will give you one though. You changed ONE of the five places
its back down to 2
second fix your variables
which 2
your first variable still has no name
and you didn't even do what we said 😭
Still not all the Playerinputs have been changed
dudeeee
it's not that it has not name, they just changed the variable's name to the type's name
EVERY place it says PlayerInput needs to be Playerinput
no the variable is literally
Playerinput = new Playerinput();
ok
it has no name
ok
And the variable name is playerinput
because they put the type name there instead of their variable. they don't need a local variable there, they need to assign to their existing field of that type
ohhhh you're right my bad
This damn tutorial man. This happens every time
I don't know why this particular tutorial is the one people who can't spell gravitate towards most
Seems like at least twice a week we have someone who doesn't name their assets right
pretty sure it's a super short one that just shows you how to do the stuff instead of explaining how and why you are doing the things
bad but appealing
i dont know what i should rename my variable too
How about input
ok
Literally anything you want
Call it Kermit for all it matters
you don't need to rename any variables. you need to be using your existing variable
As long as you aren't using the same name for your variable as your class you're fine
Which you had but then you changed because you didn't know what a type was
your code here is correct except for the spelling of the types and the spelling of the ReadValue method (which you have already fixed). You went and changed the type names and replaced the variable being used inside of Awake with the type name
should i just restart?
ok
You need to learn the difference between a variable's type and a variable's name
Then you'll stop using one where you need the other
A variable is defined by two things:
- The type of the variable is what it holds.
int,float,MyComponent,GameObject - The name of the variable is what it's called.
counter,damage,targetComponent,myObject
A variable is declared by writing both the type and the name of the new variable:
SomeType someName = ...
On the other hand, this is not a declaration:
someName = ...
honestly i think they could benefit from some short-ish but fairly intensive c# practice. like go do leetcode easy or exercism.io or something.
ok, i changes the variable to input, changed hoppefully the right ones to input, but now theres 2 problems
you'll have to show us what you actually did
rather see the actual code than screenshots of the error messages
You changed the type to input. That was just for the name
Read what fen wrote earlier very slowly and thoroughly a few times
#💻┃code-beginner message
At this point it's clear you simply do not know enough C# to even receive answers. Hambones was right, you should learn enough C# to at least understand the explanations you're being given. Consider one of the things suggested by them or linked in the pins.
#💻┃code-beginner message
so should i change the code to Playerinput input = new Playerinput
No
That would make a local variable
I'm confused as to why this method requires a [Serializable] attribute on the class https://docs.unity3d.com/2020.1/Documentation/ScriptReference/JsonUtility.FromJson.html
Correct. You can't just keep making random changes until it works.
I highly doubt they know what that is
Internally, this method uses the Unity serializer
That's why.
input = new Playerinput
The Unity serializer only cares about things that are [System.Serializable]
as far as I've read, "Serializable" means I'm saving something as a file, which I'm not doing
To serialize is to turn an object into data.
That is not what it means
It does not mean to write that data to a file.
You do frequently write that data to a file, of course
but serialization is also used for things like sending data over a network
but I'm not sending data over a network either
I'm actually receiving JSON
You don't just directly copy a blob of memory over the network; you turn your object into data, send that data, and then have the other party unpack that data back into a C# object
shouldn't it be deserialization...?
I am just giving examples of what serialization is.
And yes, you're deserializing data back into an object.
The type must have the [System.Serializable] attribute.
is there away to ask what scene to load? something like a pubblic variable?
consider making LoadScene take a single string argument
In order for something to be de serialized, it must be serializable in the first place
Have your function take a parameter
I believe you can then specify a string in the OnClick entry
Pass the int scene index or string scene name
Edit: oh, I see what you mean now
pubblic class SceneName;
something like this?
how
how did you get that from what we said
i create the parameter
that's a small blob of invalid syntax
this is not a parameter. a parameter is part of a method's declaration.
using UnityEngine;
using UnityEngine.SceneManagement;
public class Button : MonoBehaviour
public str SceneName;
{
public void LoadScene()
{
SceneManager.LoadScene(SceneName);
}
}```
like this?
public void DoThing(string something) { ... }
lol
No
this is very mangled
guesswork
Mr. Madison, what you've just said is one of the most insanely idiotic things I have ever heard. At no point in your rambling, incoherent response were you even close to anything that could be considered a rational thought. Everyone in this room is now dumber for having listened to it. I award you no points, and may God have mercy on your soul.
aeugh
c# courses pinned
my luck was not at my side
dont just throw code in random places
i remember i did it once, i just dont remember what i did ahha
then look it up again
oh yeah now i remember
using UnityEngine;
using UnityEngine.SceneManagement;
public class Button : MonoBehaviour
{
public string SceneName;
public void LoadScene()
{
SceneManager.LoadScene(SceneName);
}
}```
like this?
No
no? this this time i didnt try to guess
Sorta closer, but misunderstanding the absolute most basics of programming
lol
Please direct attention to the previous Billy Madison quote
there are beginner c# courses pinned in this channel. you should stop what you are doing and go through them all so you have a basic understanding of how to use the language
Do methods go INSIDE a class or OUTSIDE
This places a method outside of a class or struct, which is forbidden. You've also tried to declare a field inside of a method, which is also forbidden. LoadScene tries to use a variable that doesn't exist.
Hey, that's a lot closer
inside the class now
That is one of the four major errors I saw.
Now, what are parameters? And where do they go?
