#💻┃code-beginner
1 messages · Page 627 of 1
alr
Anyway the SoundController.Jump thing would have to do with the SoundController script, not this one
the problem is , u can have local function, but u never make names thats related to monobehaviour
like i will never use Awake,Update,Start as my function name
no the issue is he has an update function in an update function
this is clearly not an intentional local function though
this is some kind of copying error
sad
i got rid of it but the issues still there
ill show it again this time
show SoundController the problem is also there
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
What calls jump()?
im supposed to put jump into something like this
itl show a slot for me to insert the code and it detects if the player jumps with a vector thats on the player
so itl look like this
Okay, so... what calls jump()?
The holy spirit
Did you not write that code?
yeah no im trying to like mash 2 and 2 together and jump is the only thing thats missing
both examples work
Make sure you understand the code before copying it into your project.
alright
sorry for confusing you guys
ill try to rewrite it from scratch so its less of a pain
to read
That's not the problem. The problem is that you probably missed some important parts when copying the code. Make sure you understand how/where/when this code is called/executed from.
🥲 I'll try your code and see how I get on! Thanks
more correct architecture should be something like: soundController.PlaySound(PlayerSounds.Jump);
thanks for the formatting tips
not a formatting thing xD it's architecture -- has continuation on its way
and SoundController should be kinda like:
public class PlayerSoundController : MonoBehaviour {
[SerializeField] List<PlayerSoundPair> soundPairs;
[SerializeField] AudioSource source;
public void PlaySound(PlayerSounds soundToPlay) {
var pair = soundPairs.Find(x => x.soundID == soundToPlay);
source.clip = pair.clip;
source.Play();
}
[System.Serializable]
class PlayerSoundPair {
public PlayerSounds soundID;
public AudioClip clip;
}
}
public enum PlayerSounds { Jump, Talk, GetHit, SwingSword, ShootBoomerang, .. }
(or even AudioSource.PlayOneShot(pair.clip) if you don't wanna make setups)
this is a little much for someone new
I opt to disagree. I think this is EXACTLY what someone new should get into
you think someone who is a complete beginner should dive into non-behaviour classes and linq?
[System.Serializable] classes configurable via the inspector definitely
Linq not so much but can't help it 😛 Also Find is not part of linq
I think that's more likely. With a couple of sentences these are the high level differences:
- Formatting is how your code looks spatially (like how many empty spaces/lines you have, etc)
- Architecture is how your code is accessed (like which class accesses which, what methods it calls, etc)
ic
thanks 4 the clarification
i tend to know what im doing when it comes to reading code somewhat but actually knowing what to put and where is alot more annoying for me
i havent even scratched the surface of enums on the language i primarily use
Yeah no rush. Unity has a nice learning curve but you gotta follow it yourself to climb it
that's because Unity allows you to pretty much brute-force your way through everything
like nothing stops you from adding a SoundManager with 1000 sound references and 1000 PlaySound methods, but that's not efficient when you wanna do it again
I kinda have a like a logic problem that I am not sure if I am gonna be able to express it properly... Let's see if someone could help.... I got all the entities stored on a singleton script with some lists. Now I want to give the entities a chance to be able to assign priority to these entities. Each entity having a reference to how much of a priority each entity is FOR THEM SPECIFICALLY. I was using dictionaries to have the entity as key and int as value inside the each entity, but I am now seeing that that might not be optimal? Cause one important thing is I don't want each different entity to have a priority value, but rather the TYPE of entity. Like for example, if the enemy is composed by 3 archers and 2 wolves; all archers would be priority 3 and all wolves would be like 8. I dunno, maybe I am superoverthinking this
It's mostly cause maybe having a list of all entities and them a dictionary that basically copies the list and add to it a value is kinda.... redundant??
What makes more sense to me is for the dictionary to store the reference of how much priority THE TYPE of enemy is worth rather than every single entity, but not really sure how to do that....
So every archer instance will have its own priority value? Keep it local to that instance then
Unless you need to order the priorities so quickly look them up, then keep a sorted list on a manager
Oh read over that. If it's by a instance type, then it should be on the SO of that instance type then, and similarly same idea with the sorted list
This is the script I am using for like basically all entity/characters as a base. The name would be basically the type. So the player is meant to give commands to a bunch of player characters and I want for example one of them to have all enemies with the name as "archer" for example as priority 3. All archers would be stored on the list that holds all entities, but I find kinda unnecessary to duplicate data on the dictionary of aggro script when all entities of the same type are gonna share a value
Yeah, keep it on the SO, unless you mean to change that priority at runtime, then you need some dictionary where key is the enemy instance type and value is the priority
or make a bidirectional dictionary and make one where priority is the key ;p (assuming priority values are unique)
Well, the idea is the player will have to assign to her character what are they meant to be focusing, FOR EACH
so what's the idea, you get into range of a bunch of enemies and want to find the greatest priority threat?
So maybe rogue has archers at priority 3, but maybe a mage has them as 8. They are not meant to be changed once the combat has started, but all those things have to be modified on runtime on a UI menu
so grab all the enemies in range, run through each of their SOs (or check the manager dictionaries if the priority changes at runtime) and then resolve it
Depends of what they have assigned. Still VERY work in progress, but I would like to apply these types of target choice logic for now
Yeah, it's just a bunch of iterating and then caching the highest/lowest values as you go through every enemy
then once you're done you have your final value or values you can work with to find that answer
Yeah, it's just very abstract cause I am still not sure how I even want the UI to look like
But the idea is: Scene has 2-3 enemy types. Prebattle you assign what logic your dudes are gonna follow and the priority order of the enemy types. Then they act without your control
You can assign it to all characters, to ranged/melee, tank/healer/dps or specific to that one character and they would follow whatever command is the most specific
So that's A LOT of steps
Not sure how to handle it
Can't you just have a Type, int dictionary?
I guess I could, the type being a string
I also need them to do the same for allies though, that being slightly different cause in that case it would indeed need to hold them all, since they are all meant to be distinct, even if they are both the same class
Why string?
Are these not separate classes?
If they are the same class, how do you make a distinction between them?
They are all GeneralBehaviurManagers
Then they have stuff that tells them apart
On that same script they do have a name to tell them apart
Then they all also have a AbilityManager, which is a superclass where you would use more specific stuff, like a rogue has a specific AbilityManager to use abilities from a rogue
But for enemies, the basic ones pretty much just attack automatically, so they do not really need one
So I cannot really tell them apart for a type of script if that's what you mean
where is the sprite for the character icon defined?
On one of the object children. Why does it matter?
Might make more sense to pull some of that info into some shared scriptableobject that you could also use to reference rather than a type
(think that's what Mao was suggesting initially)
So what would be the difference between referencing a string and SO WITH a string + a bunch of other info I don't really need?
its telling you why it doesnt work, look at TurnManager.onTurnChanged. it expects the method to accept an int in the parameters
getting an error every time i run my code "Please open a folder with a solution to debug"
I'd run an antivirus scan
Because onTurnChanged is an event that raises with an int as parameter.
It's common to use methods like void MyCallback(int _) as subscribers.
Yeah, I am like pretty convinced doing all this heavy ordering each frame on several different entities is not a great idea....
Unless you've thousands it's not the biggest problem. Throw it in fixed update though cause no reason you do need to do it based on framerate, or make your own cooldown timer
proly tweak it a little bit, so only look for the nearest if they're visible on screen or inside your custom bounds for your character/enemies/whatever
also not following prev convs above
Hey guys, what's up...? I just have a quick question about Parallax Scrolling
I followed a video guide on YouTube by Dani and the Parallax Scrolling works perfectly fine
But for some reason...when I try to adjust my character's Z-index, the entire background moves with my character
The code works fine, it's just I'm having layering problems...
Well, you have the background child* to your character, so they offset relative to them
Something that isn't parented respects the world space such that z+ forward x+ right, but when you child a transform then its parent that determines the space that it behaves in.
And meaning that this parent is now considered the vector.zero of that space relative to the child
Ok nice thank you, I'll double check the hierarchy
That does make sense though, I just have to seperate the background and my character into different nodes...
!docs
do you guys have a tutorial on animator ? i'm trying to animate a character in 2D, and to call animation left / right when i press D or A but it can't seem to work somehow
This is my hierarchy...and just in case I seperated the background in it's own sorting layer called background
My character is in the default sorting layer, and my character is seperate from my Camera, where my background is a child of that node (Morning Background)
Sid Marhsall is my main character, but somehow I think I did something that connected the background
One of the background layers is animated...does that affect anything...?
Ah, sorry had mistaken background checker as background
No you're good...the layering is confusing me, for some reason
Well, what I see on your scene too is that you're using cinemachine. Take a look at your camera coordinates and move your character, does the camera now update coordinates?
Because if your camera is moving, then so are those backgrounds. I assume this is part of the tutorial though which is why it's set up like that
Yes I think the coordinates update as I move my character
But for some reason when I move my character the entire background moves with it
Any reason you're moving the character on the z anyway?
Eh I thought maybe I could put my character all the way in the front on the same Z-index as the tilesets...
Would layering/sort groups not solve all that? Usually that's recommended over z-sort
So I should make some sorting layers and group all the layers into those layers...?
Or I guess can I just use Order in Layer...?
Yeah the order on layer stuff. Otherwise you need to tell cinemachine to not follow your character's z coordinates which I'm not too sure how to go about that, but there's probably a way though not a module I play with too much.
Ok nice that might be easier, I'm going to see if that works, thank you
It seems like everything else is fine except for the part where the background moves with my character...
Even though the character and backgrounds aren't parent/child of each other
Yeah, but the camera is moving on the z, which is moving those backgrounds ;p
Oh ok that makes sense...then I have to figure out the Cinemachine...
There's probably some z constraint property if you can find one
Oh nice, to lock the camera on a specific Z-layer...?
Yeah that's a good idea, I'll see if I can find one if I can, thank you I appreciate you
If not, you can try using one of these
https://docs.unity3d.com/Manual/class-PositionConstraint.html
Basically make a parent transform and add that onto it and point it at the player or camera, lock the z axis then add thebackgrounds as children to this new transform
Nice thank you, I'll try it out. Hopefully it works, never knew that something as simple as layers can be complicated (well...at least for me)
Hi, I am working with the Timeline.
I would like to change the properties of an Audio Track via script but can't figure out how to access its properties.
They appear in the inspector, as can be seen in the first screenshot, but I can't get them via script.
I managed to find this on some random post on forums:
audioTrack.CreateCurves("nameOfAnimationClip");
audioTrack.curves.SetCurve(string.Empty, typeof(AudioTrack), "volume", AnimationCurve.Linear(0,0,1,1));
audioTrack.curves.SetCurve(string.Empty, typeof(AudioTrack), "stereoPan", AnimationCurve.Linear(0,-1,1,1));
audioTrack.curves.SetCurve(string.Empty, typeof(AudioTrack), "spatialBlend", AnimationCurve.Linear(0,0,1,1));
But I can't figure out why the first line is needed, or whether it's even correct in the first place, and also, do I need to call that first line every time I wanna change the values or what?
This has to be some of the weirdest, most undocumented api I've ever seen, makes 0 sense why it's not built in...
They won't even add an event for when the timeline has reached the end (finished or looped)
there is something for reaching the end but it doesnt work properly
With unitask i had to do a wait until for the time reaching very close to the end
using UnityEngine;
public class PlayerCamera : MonoBehaviour
{
public float sensX;
public float sensY;
public Transform orientation;
float xRotation;
float yRotation;
private void Start(){
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
private void Update(){
float mouseX = Input.GetAxisRaw("Mouse X") * Time.deltaTime * sensX;
float mouseY = Input.GetAxisRaw("Mouse Y") * Time.deltaTime * sensY;
yRotation += mouseX;
xRotation -= mouseY;
xRotation = Mathf.Clamp(xRotation, -90, 90f);
transform.rotation = Quaternion.Euler(xRotation, yRotation, 0);
orientation.rotation = Quaternion.Euler(0, yRotation, 0);
}
}
ok idk why it looks so weird but anyone know why my camera starts by looking down at the ground when i press play?
all rotations in unity are set to 0
It looks weird because you put 2 backticks instead of 3
Are you sure it just doesn't look down because you move your mouse down, after pressing the play button above?
^That probably amplifies your problem because the game lags when you start it up and you get a large delta time
thanks
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
[Header("Movement")]
public float moveSpeed;
public float groundDrag;
public float jumpForce;
public float jumpCooldown;
public float airMultiplier;
bool readyToJump;
[Header("Keybindsa")]
public KeyCode jumpKey = KeyCode.Space;
[Header("Ground Check")]
public float playerHeight;
public LayerMask whatIsGround;
bool grounded;
public Transform orientation;
float horizontalInput;
float verticalInput;
Vector3 moveDirection;
Rigidbody rb;
private void Start(){
rb = GetComponent<Rigidbody>();
rb.freezeRotation = true;
}
private void Update(){
grounded = Physics.Raycast(transform.position, Vector3.down, playerHeight * 0.5f + 0.2f, whatIsGround);
MyInput();
SpeedControl();
if(grounded){
rb.linearDamping = groundDrag;
}
else{
rb.linearDamping = 0;
}
}
private void FixedUpdate(){
MovePlayer();
}
private void MyInput(){
horizontalInput = Input.GetAxisRaw("Horizontal");
verticalInput = Input.GetAxisRaw("Vertical");
//when to jump
if(Input.GetKey(jumpKey) && readyToJump && grounded){
readyToJump = false;
Jump();
Invoke(nameof(ResetJump), jumpCooldown);
}
}
private void MovePlayer(){
//calculate move direction
moveDirection = orientation.forward * verticalInput + orientation.right * horizontalInput;
if(grounded){
rb.AddForce(moveDirection.normalized * moveSpeed * 10f, ForceMode.Force);
}
else if(!grounded){
rb.AddForce(moveDirection.normalized * moveSpeed * 10f * airMultiplier, ForceMode.Force);
}
}
private void SpeedControl(){
Vector3 flatVel = new Vector3(rb.linearVelocity.x, 0f, rb.linearVelocity.z);
//limits velocity if needed
if(flatVel.magnitude > moveSpeed){
Vector3 limitedVel = flatVel.normalized * moveSpeed;
rb.linearVelocity = new Vector3(limitedVel.x, rb.linearVelocity.y, limitedVel.z);
}
}
private void Jump(){
// reset y velocity
rb.velocity = new Vector3(rb.velocity.x, 0f, rb.velocity.z);
rb.AddForce(transform.up * jumpForce, ForceMode.Impulse);
}
private void ResetJump(){
readyToJump = true;
}
}
when i press space it wont jump
yes my ground has the layer attached
Debug.Log the values of readyToJump and grounded when you press the jump key
And make sure that jumpKey is actually set to Space in the inspector
and yes its set to space in the inspector
is this a code problem cuz my invisible barrier aint working
Did this help you realize the issue?
do i just set the bool to true by default?
also get vs code configured 👇 !IDE
If your IDE is not autocompleting code
or underlining errors, please configure it.
Select one:
•
Visual Studio (Installed via Unity Hub)
•
Visual Studio (Installed manually)
•
VS Code
•
JetBrains Rider
• :question: Other/None
Sure, or set it to true when you hit the ground
If it's true by default then the only downside is that you can jump at the start of the game if you start in the air
i need to set the mc to is trigger as for the dialogue
I thought that was what the invoke function would do
How can I change color v with the script?
I want the coin to blink before it despawns
get the color, convert to HSV, modify the V then convert back to RGB
using UnityEngine;
public class npc_movement : MonoBehaviour
{
Animator anim;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
anim = GetComponent<Animator>();
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.A))
{
anim.SetBool("walkleft", true);
Debug.Log("WalkLeft");
}
if (Input.GetKeyDown(KeyCode.D))
{
anim.SetBool("walkright", true);
Debug.Log("WalkRight");
}
}
}```
i got this very basic script, could someone tell me why my Booleans in my animator won't change please ? I've been struggling for hours now
make sure the animator parameters names are spelled correctly (and there's no extra whitespace in their names in the animator). also do the logs print?
the logs print and i legit copy pasted the variables names
click them to edit them and make sure there is no extra whitespace
then congratulations! the animator parameters are being set by that code
How do you know they are not changing?
Make sure you have the animated object selected when looking at the animator in playmode
because when i launch my game, i have my animator to the side and i can see the status not changing and my character animation not changing
excuse me ?
You need to select an object so it knows which animator to draw in the animator window
If you have nothing selected then you just see the default values
can someone point me in the direction for a channel that helps with unity not unity scripting?
guys im trying to make a button for mobile game and it says it needs canvas i dont understand canvas can someone explaine me please
oh oops didnt see that
UI objects live on a canvas. see the documentation pinned in #📲┃ui-ux to learn how to use UI
ok thanks, but my problem is that my character isn't getting animated somehow ?
then the issue is likely in your animator setup
You don't have a transition from idle to anything
The transitions are one-directional as you can see from the arrows
Ah you haver Any staate
basically the entry is connected to the idle, and the any state is getting the "backright" or "fromright" depending if walkleft ou walkright is true
and when walkleft or walkright is false, then it comeback to idle position
I don't see you setting either bool to false, so maybe both transitions keep triggering all the time
Also your transition duration is 1.5 seconds?
i manually did this because otherwise my animations are getting cut ?
i feel very weird about using the animator feature
i might have situated the problem, in the screen i have my GameObject "NPC" and in it a GameObject called "state" the npc is the hitbox and the script is connected to this, so i have to click on "npc" to get, but the animations aren't showing because the animator is connected to "state"
so if i'm not wrong i should just move the script to state and not NPC
guys how do i make the vector3 movement again?
what do you mean by "the vector3 movement"
with the implemented axis from unity
and have you bothered going through the beginner pathways on the unity learn site like you've been advised?
what does that even mean
thanks @slender nymph & @verbal dome for the help mate, made me find my mistakes
Vector3 is a data type. It's probably gonna be used somewhere in any movement system
when i try to open the animator only animation is opening why is it like that i want animator not animation
Then you should open the Animator window, not the Animation window
Guys this may be a dumb question but why do I have to make both floats static if I want to reference it in a Vector?
private static float x;
private static float y;
private Vector2 someVector = new Vector2(x, y);
you cannot use non-static fields inside of a field initializer. if you want to use the value of the fields then construct the vector3 in a method using those fields
When initializing a field you cant use values from other member fields
With member i mean non static
Not sure if static fields are called members
I guess they are
So it'd just be easier to do something like
[SerializeField] private Vector2 someVector = new Vector2(0f, 0f);
If I want to modify values in the inspector directly rather than have 2 separate static variables?
does a stack of several else if statements stops reading each one if one is true?
Yes
yes, obvs
figured
code generally runs from left to right, top to bottom
what does it do essentially?
gets the X and Y of your canvas instead of using numbers which could be anywhere. You coded it as -611, and then you see buttons off screen, well that's -611. There can be a lot of difference between absolute position in editor and what the resulting pixel ends up being
oh ok
float scaledStartX = 194 * _rectTransform.lossyScale.x;
float scaledStartY = 634 * _rectTransform.lossyScale.y;
This is an example from my own code but my UI graphic starts at 194,634 so I use this and then it works regardless of what you scale the canvas to
ok so lossyY is the Y center and lossyX is the X center
according to what you said and the code you provided me
ok thanks for clarifying
np
hey guys uhm im programming with cours rn from unity and we are programming space invaders. We programmed the movement the animation everything but with the movement i got the problem that my charecter is moveing a little bit further when i stop pressing the button how can i fix that
sounds like you're using GetAxis rather than GetAxisRaw. GetAxis applies input smoothing which would cause that gradual slowdown after releasing the key
thanls
Hi how do i get help in this server please is there a certain chat?
You are in the channel for help regarding beginner concepts of coding
If this does not apply to your question, use #🔎┃find-a-channel to find the correct channel. Otherwise ask in #💻┃unity-talk and people might or might not point you to the correct channel.
Ok thank you
i bought a game kit and an art set, expecting to use them together. the problem is, the kit wants Sprites, and the art set is Tiles. Is there a way to make a sprite out of tiles, or do I actually have to go manually materialize these tile layouts to individual images?
i thought full rect / tiled was what i wanted but possibly not
not a code question, and tiles are made from sprites, so just use the sprites?
well that's what i'm trying to do, but, when i set the sprite to the relevant sprite sheet, set the width and height as appropriate, set it to tiled, set it to full rect, i get the upper left hand corner six times
sorry, it's 2 tiles wide by 3 high, is where that number comes from
i have a problem with the editor what channel should i ask in
none of the channels are fit for my problem
if only there were a channel specifically for when there are no other channels that your question relates to
what channel
maybe if you'd actually read #🔎┃find-a-channel you'd find out 😉
why is this code not running? i thought as long as i pass the parameters into the coroutine before calling Destroy on the object, it will still work since its separate from the object?
the first debug goes through, and then its not instantiating anything or logging that application is quitting
is it this object that is being destroyed? because if so, then naturally any coroutines started on this object will not continue running
i thought thats specifically how it didnt work
idk why
i thought coroutines were completely separate once theyre running
that is specifically how it does work. Coroutines are tied to the lifetime of the object that starts them, that is why disabling a gameobject also stops its coroutines
I am raycasting from the camera and I want to apply a spread to it but my current method spreads in a square pattern instead of a circular one. Does anyone know how do it instead?
Vector3 direction = currentCamera.transform.forward;
Vector3 right = currentCamera.transform.right;
Vector3 up = currentCamera.transform.up;
Quaternion spreadX = Quaternion.AngleAxis(UnityEngine.Random.Range(-currentAngle, currentAngle), up);
Quaternion spreadY = Quaternion.AngleAxis(UnityEngine.Random.Range(-currentAngle, currentAngle), right);
Vector3 spreadDirection = spreadX * spreadY * direction;
I'm trying to use the object a script is being applied to as a variable in a function within the script, assuming i would use the this variable, but that hasnt worked and im not sure what the correct method is. Tried searching it up, but just got stuff about people asking how to use stuff from other scripts in a script 😭
be more specific about what you are trying to accomplish
because this refers to this instance of this object, in other words, if will refer to the instance of your component so if there is something else you are trying to get, you need to be specific
Hmm try with right and then forward, instead of up -> right
Right axis would rotate it up/down and then forward axis would "twist" it around in a circle
The forward angle should be 0...360 (or -180...180)
ive got a function that finds the closest object to the object the script is on, from a list of objects. For the function to work, I need to pass the object the script is on, as a game object, and also the list of objects. I can pass the list of objects but idk what to use to pass the object the script is on, and assumed it was this but apparently not
correct, this would not be appropriate to pass there because it does not refer to a gameObject, it refers to this instance of this component. have you tried looking at the MonoBehaviour documentation to see if there is a useful property you could use?
@surreal minnow Oh and try both ways when combining the quaternions, i forget which one should come first
No, will do, thanks
found the answer, turns out its just gameObject which in hindsight shouldve been obvious
heya! i'm new here so please correct me if this isn't the right channel. 🙏 i'm having a really hard getting this to work for my college assignment. I have 3 scenes, 1 for gameplay, 1 for Win and another for game over. the game over screen has TMP Text with the button component with it, that triggers LoadGame() in the Level script.
however, when the game over screen is loaded, it keeps telling me that Level is inactive, where in reality it isn't. i tried doing a DontDestroyOnLoad to no avail.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour
{
private GameSession gameSession;
private AudioSource audio;
private Animator animator;
private SpriteRenderer spriterenderer;
private Level level;
public Transform spriteTransform;
public int health = 20;
public bool frozen;
public bool isDead;
[SerializeField] List<AudioClip> sounds = new List<AudioClip>();
void Start()
{
gameSession = FindObjectOfType<GameSession>();
level = FindObjectOfType<Level>();
animator = GetComponent<Animator>();
audio = GetComponent<AudioSource>();
spriterenderer = GetComponent<SpriteRenderer>();
}
void Update()
{
if (frozen)
{
return;
}
else
{
float delta = Input.GetAxis("Horizontal") * Time.deltaTime * 5;
transform.position = new Vector2(transform.position.x + delta, transform.position.y);
animator.SetFloat("Speed", Mathf.Abs(delta));
if (delta != 0 && spriteTransform != null)
{
Vector3 newScale = spriteTransform.localScale;
newScale.x = Mathf.Abs(newScale.x) * (delta > 0 ? 1 : -1);
spriteTransform.localScale = newScale;
}
}
KeepPlayerInView();
}
void KeepPlayerInView()
{
Camera viewport = Camera.main;
Vector2 minBounds = viewport.ViewportToWorldPoint(new Vector2(0.1f, 0));
Vector2 maxBounds = viewport.ViewportToWorldPoint(new Vector2(0.9f, 0));
transform.position = new Vector2(
Mathf.Clamp(transform.position.x, minBounds.x, maxBounds.x),
Mathf.Clamp(transform.position.y, minBounds.y, 0)
);
}
void OnTriggerEnter2D(Collider2D collision)
{
if (collision.CompareTag("Collectable"))
{
audio.PlayOneShot(sounds[0]);
gameSession.AddScore(10);
}
else if (collision.CompareTag("Obstacle"))
{
if (health > 1)
{
audio.PlayOneShot(sounds[1]);
health--;
StartCoroutine(DamageColor());
}
else
{
health--;
frozen = true;
isDead = true;
GetComponent<Collider2D>().enabled = false;
GameObject.Find("GameCanvas").gameObject.SetActive(false);
level.LoadGameOver();
}
}
Destroy(collision.gameObject);
}
IEnumerator DamageColor()
{
spriterenderer.color = new Color32(255, 100, 100, 255);
yield return new WaitForSeconds(0.25f);
spriterenderer.color = new Color32(255, 255, 255, 255);
}
public List<AudioClip> GetSounds()
{
return sounds;
}
public int GetHealth()
{
return health;
}
}
You've got an error
that's the one i was referring to, couldn't start because it was inactive. sorry i thought it got captured!
When an error occurs you can expect things to not work properly
i'm aware, that's why i came here for help 😅
Check the details pane and see where the error is occurring
you're starting on the player ?
Which object has the StartCoroutine code on it?
public void LoadGame()
{
StartCoroutine(GameplayScene());
}
it leads me to this
which the GameplayScene coroutine is:
IEnumerator GameplayScene()
{
fader = FindObjectOfType<Fader>();
fader.GetCanvas().GetComponent<Canvas>().sortingOrder = 1000;
music.Stop();
music.PlayOneShot(restartGameSound);
fader.Transition("Black", "Out", 1f);
yield return new WaitForSeconds(2f);
SceneManager.LoadScene("Gameplay");
FindObjectOfType<GameSession>().ResetGameSession();
fader.Transition("Black", "In", 1f);
}
What object runs LoadGame and where do you call it?
LoadGame is called by the 'try again' button (a TMP text with a button component)
The error suggests that when you attempted to start the coroutine, the object was (still?) inactive. Have you set the object active/inactive anywhere?
Can you show the inspector for that button event
no i haven't. I even tried before switching the scenes to "re-activate" the script to no avail (essentially setting it to active again)
sure thing!
might be trying to run as the gameobject is being destroyed/disabled for scene switch
but why would it be destroying if I did a DontDestroyOnLoad prior?
on Level not Player.cs no?
yee
First off - probably don't set it to "Editor", this should be runtime only.
Second, did you drag in the Level object from the scene into that box?
Or did you drag in a prefab
oh i was instructed to do editor. let me try runtime too.
as for the second question, i used the prefab for the button to use
are you running the script in the player prefab maybe ?
So, then the button is attempting to run the prefab's coroutine
the prefab that doesn't exist
Which is why it says it doesn't exist
uhh no Level is only in the Level object
I have tried the scene prior which doesn't seem to have worked. let me try it again to confirm
But you're calling it on the prefab
not the one in the scene
Those are two different Level objects
One that exists, and one that does not
huh okay.. i've been instructed that way so i guess that really didn't cross my mind 😅
let me give it a shot
You were instructed wrong
The button calls the function on the object you drag in
If you drag in a prefab, it's gonna run the function on the prefab
So find whoever told you that you needed to drag in a prefab and slap em at least twice
i don't think i would want to do that to my lecturer but i'll definitely keep that in mind haha
They're getting paid for this? Three slaps.
okay! it's no longer erroring but now it doesn't seem to be doing anything...?
i'll try a quick debug.log
nada. no errors but it's not doing anything
Well, that's good. If it did nothing before you wouldn't have been able to tell because it errored first anyway
in a way yes but it's not performing anything inside the Coroutine
not even a Debug.Log
i do appreciate y'all taking me a step closer though, thanks :)
using UnityEngine;
using TMPro;
using UnityEngine.SceneManagement;
public class GameManager : MonoBehaviour
{
public static GameManager Instance { get; private set; }
public TextMeshProUGUI scoreText;
private float score = 0f;
private void Awake()
{
if (Instance == null)
{
Instance = this;
DontDestroyOnLoad(gameObject);
}
else
{
Destroy(gameObject);
return;
}
}
void Update()
{
score += Time.deltaTime * 10;
if (scoreText != null)
{
scoreText.text = "Score: " + Mathf.FloorToInt(score);
}
}
public int GetScore()
{
return Mathf.FloorToInt(score);
}
public void ResetGame()
{
score = 0f;
Time.timeScale = 1;
SceneManager.LoadScene("Play Game");
}
}
So go one step out - log before you call StartCoroutine
OH i found the culprit I think..
and where is this script placed, when you call ResetGame
my function inside the button got unassigned. let me try testing the game as a whole now
endscreenmanger
public void RestartGame()
{
GameManager.Instance.ResetGame();
}
}
this mb
in the scene not the script..
okayy so if I run the code from the Gameplay scene, and then it switches to Gameover, for some reason the script becomes missing in the button component?
So the object you assigned in the inspector is no longer around. Are either of these objects on a DDOL?
ok so where is the script, you still didnt show it in the scene.
this cropped photo doesnt help
Level is on DDOL (assuming Dont Destroy On Load?), which does include the Level script that it's trying to access
like on wich button?
Are you starting the game on this scene, or changing into it from a different one?
No i'm starting from Gameplay (different to what i've shown from the 'try again' screen) which then switches over to Gameover
I assume that Level is a singleton then, and it does something to destroy extra copies of it as you load a new scene, right?
score += Time.deltaTime * 10;
if (scoreText != null)
{
scoreText.text = "Score: " + Mathf.FloorToInt(score);
}
Yes let me find the quick snippet..
only on this
void SetupSingleton()
{
if (FindObjectsOfType<Level>().Length == 1)
{
DontDestroyOnLoad(gameObject);
}
else
{
Destroy(gameObject);
}
}
Yeah, so the button is referring to an instance of Level that hit the else block
I have no idea why you keep showing these unreleated things I never asked though
so it no longer exists
so GameManager, where, which object is this script placed on.
only on that text that is it
Is this the line throwing your exception
wdym " only on that text"
oh! so, what do I do then? do i remove the Level instance from the hierarchy in the Gameover screen? (not during runtime)
Or do i just remove that code fully?
new text in the pic
GameManager.Instance.ResetGame();
You'll need to use the singleton reference to start your coroutine, instead of dragging in an instance
text ? why are we talking about text
I dont see GameManager
So GameManager.Instance is null
where GameManager component..
correct
So make it not be that
I been asking for this the pat 15 mins and u still showing / telling unrelated things
using UnityEngine;
using TMPro;
using UnityEngine.SceneManagement;
public class GameManager : MonoBehaviour
{
public static GameManager Instance { get; private set; }
public TextMeshProUGUI scoreText;
private float score = 0f;
private void Awake()
{
if (Instance == null)
{
Instance = this;
DontDestroyOnLoad(gameObject);
}
else
{
Destroy(gameObject);
return;
}
}
void Update()
{
score += Time.deltaTime * 10;
if (scoreText != null)
{
scoreText.text = "Score: " + Mathf.FloorToInt(score);
}
}
public int GetScore()
{
return Mathf.FloorToInt(score);
}
public void ResetGame()
{
score = 0f;
Time.timeScale = 1;
SceneManager.LoadScene("Play Game");
}
}
i'm not quite sure i understood.. sorry 😅
that is the only thing from gamemanager implemented that works rn?
pay attention for 5 minutes and you will solve your problem..
showing this script is useless
WHERE in the SCENE is this
Which Gameobject is it on?
The entire point of a singleton is to be able to access an instance through a static variable. So get the reference to the Level with that instead of trying to drag a specific Level instance
Okay, show the inspector of this object
that is the only thing it is on right now
why are you showing me the textbox then and not the inspector of the gameobject its on?
i don t know what is important to see 😅
Okay so when you said this was the object the game manager component was on you just straight up fuckin lied?
I been telling you for the past 20 mins bro
We can't really do much to help if you're blatantly lying
it says the score?
the SCRIPT on the GAMEOBJECT
the component
idk how else I should explain it
I dont see GameManager placed on any GameObjects..
What.
Object.
Has.
The.
GameManager.
Component.
could none be a possible answer?
If so, then that's your entire problem
if its none, why are you surpised the Instance is null
What fuckin game manager are you trying to reference then
it just needs to call it from another script?
You do not have a GameManager
you want to access a component thats not even in the scene..
this what happens when you randomly paste scripts without any idea what they do...
you can't call functions on the concept of nothingness
i know what the code does don t understand unity
then learn it..
Components go on gameobjects to do anything
This isn't a unity question. This isn't even a code question. This is object permanence
im trying lol
are you though
If you want something to do a thing, and that something does not exist, it can't do the thing
we had this problem last time
you have to know what a component is by now..
what you need for a component to do anything
also references are not a unity problem..
but to what should i assign it then just create an empty one?
its not that diffcult to slap it on a gameobject thats GameManager
in ue5 it works pretty different with bps and cpp child classes
stop saying UE5
we're in unity now
all that is irrelevant
Unity works on Components, they need to be on gameobjects to exist
Every programming language will require an instance exist before you can run code on it
wait the pic was useful already have it
If you do not have a game manager, then you cannot run code from a game manager
i can call the game manger normally and don t need a ui object for that in a game engine 🤔
Jesus fuckin christ, get your ducks in a row before you keep sending people down wild goose chases because you can't be assed to answer a question about your own setup
this isnt even the same scene you were erroring on
At no point did anyone say anything about UI Objects
what then you wanted to see the game manager?
I wanted to see game manager inside the EndGame Scene
oh don t have it there
Again, to call functions on a object, it must exist
yes but according to your code it should persist with a DDOL if you started already in this scene you showed it existed in
im hella confused
if its not carrying over then you never ran this scene prior to endScreen scene
At the time you are getting the error, while the game is running, is there an object in the scene with the GameManager component on it
We keep asking questions, getting outright lies as answers, and have no way to know they are lies, so we start answering assuming you've told us what the actual state of the scene is, and since you lied on the first answer you have no idea what we're talking about
im doing my best ok im only a creature from earth 🙂
guess i will look into it tommorow almost midnight now
I mean at the very least you could've reviewed the material I said to check out the pinned items , especially one that has the Scripts as Behaviour Components video..which explains a lot of what you should know
you just skipped into another thing until you get stuck then come here rather than learning the reasons behind the issue
im really sorry to bother again, but i have updated the script to something like this where it assigns the level instance to the button during runtime. everything works except the part where it's actually meant to assign the level instance, because it doesn't actually assign anything.. :/
btw , use links for large !code blocks
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
oh sorry! i will take note
A tool for sharing your source code with the world!
made it a link
So, Instance gets assigned as soon as any object with this script on it exists and is active in a scene.
which would be the Level instance?
The first one that ever exists when you start the game
OH okay I thought it was when a scene changed
how do you compared 2 euler angels?
depends on what you want to compare
you can't compare an euler angle representation of a rotation to single number
right
you may want to convert that transform rotation to angle-axis representation
eulerAngles is a Vector3
Which angle do you want to compare to 210
oh my goodness after hours of working endlessly, thanks digi i figured that out at last
Remember to pay forward those slaps
Checking if a vector is "greater" than another one doesn't really make sense
you should really read that angle-axis documentation link
maybe you actually dont even want to use angles
if this is about a clock, you could calculate the angle between the noon direction and the direction the hand is pointing in: Vector3.SignedAngle(noon, hand) > 150f
dw about that now, magnitude would've just given you a single number that can actually be compared with > < not saying its correct but vector3 > vector3 doesnt make sense
if this is a clock you should only be using Z angle anyway no? why compare the entire V3
okkk i spoke too soon. 🥲
https://paste.mod.gg/lqwiaxwvmwhq/0
if i die once, everything goes well. gameover works fine, all dandy. buut when it comes to Debug.Log("Found"); in the GameObject.Find("TryAgain"){}, it prints TWICE and doesn't apply the level instance to the button.
A tool for sharing your source code with the world!
-# i am slowly getting a headache. it's past midnight and i need sleep but i'm not going to rest well knowing that i still am having issues
Z angle ain't worth it
It returns a value between -1 and 1
And the value is mirrored, so it doesn't work
wdym normally its -180 to 180
Calling Destroy on an object won't end the current function. The "new" instance will still try to call that section after it self-terminates. You should return after destroying
that's not eulerAngles
that's rotation
well thats a quaternion
which is not in degrees
What do you mean it's a quaternion?!
They mean it's a quaternion
because that's what it is
rotation is a quaternion
max value is 1
I thought if I just ran transform.rotation.z, then Id get z, not a quaternion
rotation is a four-dimensional normalized complex vector
yes the Z of the quaternion
not euler angles
You do get Z. Z being the third element of the four-dimensional vector representing the orientation
If you want the eulerAngles, use eulerAngles
you've been using them in the code you've shown
Quaternion doesnt use angles , would defeat the point of unity using it to store rotations
so you already know that
it doesn't seem to have worked, the issue remains
if (Instance == null)
{
Instance = this;
DontDestroyOnLoad(gameObject);
}
else
{
Destroy(gameObject);
return;
}
you're referring to this right?
Please read what we've been saying
if you did transform.rotation.eulerAngles.z then yes thats a euler from -180 to 180
I've mentioned it like twelve fucking times
I thought they were different entities!
yes, that will prevent it from reaching that Find section and logging again. Are you still getting double calls to that log function?
They are. One of them is the Quaternion representing the object's orientation, and the other is the angles about each axis of rotation
Also, instead of using the Find at all, you should put a function on something on the GameOver scene that calls Level.Instance.LoadGame and have your button call that
No but it didn't set the level instance inside the button
i'll give it a shot tomorrow then, i'm having a hard time concentrating. thanks again for the help, i will note it :)
can someone tell me why no matter what sprite i drag into the sprite section of this image component the sprite wont change? these inventory slots have a prefab and once the game starts it spawns them in and u can scroll to change the sprite from a slot to a selected slot but when i manuall try to change it in the editor it wont change, what could possibly be the cause?
an editor script maybe?
Perhaps there's a child object that hides this Image.
the game is paused tho, so not scripts are running then?
nope the childrens image components were disabled
there are still scripts that can run
Editor scripts are specifically designed to run when the game isn't running
things like OnValidate etc
oh i see, do they come from packages u downlaod or?
Can you expand the children and show that they are disabled? Also, perhaps changing a sprite wouldn't have an immediate effect when the game is paused.
i tried enabling and disabling "icon" image component and it made no difference, its sprite is en empty png image though so understandable that it made no difference
also
perhaps changing a sprite wouldn't have an immediate effect when the game is paused.
is that a UI thing only? like for image components, cuz for sprite renderer it works even when paused
we did download a few packages but other than that, we didnt explicitly go out of our way to use Editor scripts
It might not be a thing at all. Just a guess.
What I'd do is:
- Confirm that the sprite in the image slot is what you expect to be.
- Switch to scene view, click the object in the scene several times to make sure only the object you're interested in is selected
So far I don't see any issues in your screenshots. The image seems to render the sprite that is assigned to it. Does it not let you assign a different sprite or something?
it does, it says the name of the sprite, it just doesnt change, never seen something like this befpre
Does it change if you press step(the button to the right of pause)?
time to reset the image component (3 lil dots) and try again
it changes it back to what it was, but that is cuz of the script that should only run when the game is active, why does it not change when the game isnt active is what im wondering
what calls this? does it check Application.IsPlaying ?
still doesnt display the correct image
i dunno what this component is but why are you doing GetComponent soo often when you can serialize vars and get once
its called by update() but as far as i know if the game is paused then so is it, no?
man idk this is the first time i ever made an inventory script and i tried my best
oh this is paused in play mode?
Id recommend making scripts for each component of the UI, e.g. "InventoryBar" and "InventorySlot" to better manage functionality and state
i could probably create a list and add the slots to it and manage them that way, probably cleaner but im sort of i nthe mentality of if its not broken dont fix it
im in the mentality of do it the non shit way that you can maintain in future
should be, right?
you tell me
its either in edit mode (not playing), play mode or play mode paused.
true, maybe ill try to improve it after i solve this
where do i go if i want to learn how to like implement a wave structure
im a beginner scripter
oh, i misread your quesiton, yes the game is in play mode, and is paused
i see no good reason to figure this out then
When you press the step button, it would run the game logic for one frame, so it makes sense that your script would update.
well, i was trying to add code that changes the slot sprite depending on its positioning (far left, far right, middle ones) and the script didnt change anything and i was wondering why, so my first though to debug this was to try to manually set a sprite and see what happens so i think figuring this out would help me find the root cause
but setting a sprite manually doesnt really help you. It should be simple to do anyway. index 0 gets far left, index count - 1 gets far right, rest get middle sprite.
presuming your list of slots is sorted correctly (and having 1 list of inventory slot components greatly helps with preventing mistakes with something like this)
i have it so the inventory size can change dynamically during playtime, which adds a layer of difficulty
so index of far right changes
thats fine, easy to spawn a new slot and insert at the end
or you insert 1 before to avoid needing to auto do this bg changing
hmm thats true i suppose, id have to limit inventory decrease to 2 slots then i think, so i always have left and right, or if 1, then add far right otherwise add middle
you have options but id try to improve the design and if there are issues in normal use then hopefully you can correct em.
If i was to do this id either have 3 prefabs (2 variants) to have the alt designs for the start and end, or set the bgs from the managing script when the inv size changes.
so... i added a switch case instead of the last line which checks if its last or first etc and now it works correctly
it really was that simple appearantly, still dont get why i cant change it when the game is paused but i guess it doesnt matter now
i see, this is how i did it in case u wanna know
using TMPro;
using UnityEngine;
public class Actions : MonoBehaviour
{
public GameObject actionButton;
public GameObject actionHierarchy;
public TextMeshProUGUI DialogText;
public float TextWriteSpeedDelay = 1;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
AddActionButton(3);
WriteDialog("hiiiiii, I'm literally John Pork and I'm edging my mogging streak rn.");
}
// Update is called once per frame
void Update()
{
}
public void AddActionButton(int numberOfButtons)
{
if (numberOfButtons > 4)
{
numberOfButtons = 4;
}
int buttonY = 330;
int[] buttonX = new int[4];
buttonX[0] = 276;
buttonX[1] = 718;
buttonX[2] = 1170;
buttonX[3] = 1636;
for (int i = 0; i < numberOfButtons; i++)
{
GameObject newActionButton = Instantiate(actionButton);
newActionButton.transform.position = new Vector2(buttonX[i], buttonY);
newActionButton.transform.SetParent(actionHierarchy.transform, true);
}
}
public void WriteDialog(string message)
{
Console.WriteLine(message);
DialogText.text = "";
float timer = 0f;
for (int i = 0; i > message.Length; i++)
{
if (timer >= TextWriteSpeedDelay)
{
DialogText.text += "" + message[i];
timer = 0f;
}
else
{
timer += Time.deltaTime;
}
}
}
}```
I'm wondering how I'd go about doing this, because it doesn't work
I'm trying to make text progressively appear in a dialog box, but nothing shows up at all.
only look at the last function and start()
the rest doesn't matter to what I need help with
make a coroutine instead
a what
I'll google it
oh ok
I'll look into doing that
oh my god it's so simple
❤️
ok it works
I apply 0 motor torque to my wheel colliders but they don't stop for a good 1-2 seconds, any clue?
Oh my god I'm an idiot
A motor torque of 0 is just an energy of 0
Not that it moves at 0....
public class OverlayManager : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
{
private AreaOverlayManager _areaOverlayManager;
private GameObject _pressedObject;
private bool _isHolding;
public DeckManager deckManager;
public DiscardManager discardManager;
private bool _isAreaOverlayOpen = false;
private bool _isOverlayOpen = false;
private void Awake()
{
_areaOverlayManager = GetComponent<AreaOverlayManager>();
}
public void OnPointerDown(PointerEventData eventData)
{
if (eventData.button == PointerEventData.InputButton.Right)
{
_pressedObject = gameObject;
_isHolding = true;
if (!_isOverlayOpen)
{
StartCoroutine(HoldCheck());
}
}
}
public void OnPointerUp(PointerEventData eventData)
{
if (eventData.button == PointerEventData.InputButton.Right)
{
if (_isOverlayOpen)
{
CardOverlayManager.Instance.CloseOverlay();
_isOverlayOpen = false;
return;
}
if (_isAreaOverlayOpen && !gameObject.CompareTag("Card"))
{
_areaOverlayManager.CloseDeckOverlay();
_isAreaOverlayOpen = false;
return;
}
if (_isHolding)
{
_isHolding = false;
if (_pressedObject == gameObject)
{
OpenOverlay();
}
}
}
}
private IEnumerator HoldCheck()
{
yield return new WaitForSeconds(1f);
_isHolding = false;
_pressedObject = null;
}
private void OpenOverlay()
{
switch (gameObject.tag)
{
case "Card":
CardOverlayManager.Instance.OpenOverlay(gameObject);
_isOverlayOpen = true;
break;
case "Deck":
_areaOverlayManager.OpenDeckOverlay(deckManager.GetContent());
_isAreaOverlayOpen = true;
break;
}
}
I have this really simple Code snipet
For some reason.... _isOverlayOpen gets changed to false
I basicly want to press Right Click on an Object and open an Overlay that shows the Card
and when i press right click again i want it to close the overlay
There are some special cases when a DeckOverlay is open but that doesnt matter rn cause im fully focussed on the "Card" Tag
When i click again the Overlay doesnt close
I tested a bunch of stuff, including setting _isOverlayOpen public
My log basicly tells me, that it gets changed to true and after a single frame it gets changed to false
I honestly dont understand the problem at all
I'm not sure if that's a good way to go about checking if the player has held the pointer down over a duration. I'd just make a timer and place it in update to check if the player has held long enough when the pointer is pressed down, otherwise stop the timer and reset it to 0.
Otherwise you would probably want to cancel the coroutine if they do remove that input.
Looks like it is being called from a worker thread, not the main thread
Did you put that in a constructor or something?
[CreateAssetMenu(menuName = "Item/Item")]
public class ItemSO : ScriptableObject
{
[ShowSprite] public Sprite sprite;
public string ItemName;
/// <summary>
/// Used by the Crafting System
/// </summary>
[Tooltip("Used by the Crafting System")]
public int id = 0;
#if UNITY_EDITOR
void OnEnable()
{
FixAllID();
Debug.Log("OOsOO", this);
}```
seems like it's getting called by all of my item each time an item is made
interesting. Didn't know the directives for the editor worked on another thread
How are you making the item?
just duplicate
Oh in the editor
oh yes
Does that class have the ExecuteAlways/ExecuteInEditMode attribute?
it's not
What's the method?
I'm just not sure why it keeps spamming Awake and onenables
If it's an editor only method, then that makes more sense
I want something that will only happen automatically when I duplicated this SO
What does FixAllID do?
You probably want to be using instantiate or create instance then if this isn't for editor purposes
I mean I get what you're trying to do but does FixAllID use Resources.Load or something?
OnEnable gets called when the SO is loaded into memory for the first time
I just want to make sure no item have same id, but OnValidate is trash
Ah, ok I see. Use the ISerliazation instead then
OnValidate falls into similar editor problems with SOs
How would that work?
Check every other asset for duplicate ids when it gets serialized/deserialized?
It should be called when it's duplicated I believe
and similar to OnValidate, it will invoke when you do make edits
it's just as spammy as OnValidate
I mean, OnEnable should work fine here though if it's a one-time operation
just next time you load the editor it'll do it again ;p
OnEnable keeps getting called on all Items everytime im making a new item
That's why Im asking what happens in that FixAllID method
that's why it was using the other threads lol
public void FixAllID()
{
existingIDs = new();
RepeatingID = new();
foreach (string sss in AssetDatabase.FindAssets("t:ItemSO"))
{
ItemSO asset = AssetDatabase.LoadAssetAtPath<ItemSO>(AssetDatabase.GUIDToAssetPath(sss));
if (asset != null)
{
if(existingIDs.Contains(asset.id))
{
RepeatingID.Add(asset);
}
existingIDs.Add(asset.id);
}
int newID = existingIDs.Max();
foreach(var item in RepeatingID)
{
while(existingIDs.Contains(newID))
{
newID++;
}
item.id = newID;
newID++;
}
}
existingIDs = null;
RepeatingID = null;
}```
oh
So yeah you are loading all of them again
Could always just flag the asset to not run the logic, even if it gets loaded ;p
it's inside the folder anyways
That will still trigger the OnEnable for all of the SO assets, at least for the first time after recompile etc
So you need some kinda flag like Mao suggested
Otherwise make a constructor that you call when you duplicate it
and set the ID once and forget the unity methods
yes
they're both part of initialization not guaranteed one will run before the other
https://docs.unity3d.com/Manual/execution-order.html
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
private void Start()
{
InputManager.Instance.playerInput.Ingame.Togglemap.performed += Toggle;
InputManager.Instance.playerInput.Ingame.Togglemap.Enable();
}
private void OnDisable()
{
InputManager.Instance.playerInput.Ingame.Togglemap.performed -= Toggle;
InputManager.Instance.playerInput.Ingame.Togglemap.Disable();
}
hope using start() instead of onenable() doesnt break the input system
why would it break?
the only issue without using OnEnable though if you disable this and re-enable the inputs will stop working
idk imo this wouldnt but all tutorial would recommend using onenable to register the input.enble and disable() vice versa
yea
you could potentially mess with script execution order and make one script always initialize first guaranteed
i could yea, but that would mean all other input script would need tinkering
what about this lol:
private void Start()
{
OnEnable();
}
private void OnEnable()
{
InputManager.Instance.playerInput.Ingame.Togglemap.performed += Toggle;
InputManager.Instance.playerInput.Ingame.Togglemap.Enable();
}
private void OnDisable()
{
InputManager.Instance.playerInput.Ingame.Togglemap.performed -= Toggle;
InputManager.Instance.playerInput.Ingame.Togglemap.Disable();
the start for that singleton inputmanager instantiated first
enable and disable for the UI gameobject enable/disable
you mean manually enabling the gameobject? not sure I understand
I would just fix the input manager exec order
managers should setup their singleton before all other scripts should sub their events anyway
ah yea move the singleton before default time
yeah after all those are managers / special cases (singletons)
you wouldn't touch others
my ass was thinking moving all the input scripts
yeah that would be bad.
a few scripts that usually in charge of initializing others is reasonable
anw thanks gamer
VS is giving me the green squiggly so i wanted to vibe check, Is this kind of partial implementation/backporting of an abstract generic function allowed?
public abstract class BaseClass
{
public abstract void PartialGeneric<T>(T content) where T : MonoBehaviour;
}
public class DerivedGenericClass<T> : BaseClass where T : MonoBehaviour
{
public override void PartialGeneric<T>(T content)
{
}
}
(but removing this means it fails to match the function 1:1 and screams)
(i think the answer is no)
anyone knows why this is happening 😢
im in the prefab itself
i cant edit my collider
it randomly appeared back nevermind
Looks like it happens when you have multiple inspectors open. Maybe the "Scene" tab and the "Prefab" tab count as separate inspectors?
i have this soundtester script in my game attached to a gameobject but whenever i run my game the checkmark goes away which means my audio doesnt work does anybody know why this would happen
Hey guys, since
!leearn have coding tutorials on it and it doesn't explain well how the codes work, let's say I wanna learn how those lines of codes work by researching, what and where should I do the research?
Which lines in particular?
Why isn't the base class generic?
public abstract class BaseClass<T> : BaseClass where T : MonoBehaviour
{
public abstract void PartialGeneric(T content)
}
public class DerivedGenericClass<T> : BaseClass<T> where T : MonoBehaviour
{
public override void PartialGeneric(T content)
{
}
}```
By having a generic function inside of a generic class you're doing this:
public class DerivedGenericClass<T0> where T0 : MonoBehaviour
{
public void PartialGeneric<T1>(T1 content) where T1 : MonoBehaviour
{
}
}```
Definitely lines that I couldn't read
This one, for example, let's say I wanna know how this script work
There's some usecases where I want to handle the base class without the generic. It might not be best practice but I'm just experimentating a little with how i want to handle some stuff and feeling it all out
Which exact lines? Can you link the tutorial that you're following from learn and the specific line?
I mean, my point is, I wanna learn how the whole script work including the future scripts that I'd encounter. Because when I see a script that I can't understand, I would like to do a research about it, the words inside that script, how they work and more.
Now I wanna know where I do the research for them.
So guys... Where and how do you recommend to learn c#?
Im looking to create a platformer, and developing enemy AI... To detect holes and jump across them, if target goes to higher grounds then follow player trails and jump to get to higher grounds (like breadcrumbs), and adding waypoints to the map so that the enemy when there's no target they randomly move though neighbors waypoints through the map.
I have a newb question about resizing the box for a TextMeshPro. I think I may be close, but searching hasn't given me a straight answer if I'm on the right track. I have a TextMeshPro that I have set to my default size. I want to be able to make it wider or smaller based on some code. Really all I want to change is the width by a scale to be a multiple of the default.
Based on the UI, I guessed that I need to grab the **RectTransform **- rt = Text.gameObject.GetComponent<RectTransform>(); -, then would I use rt.rect.width to get the current width?
After that, how do I correctly set the new width? **SetSizeWithCurrentAnchors ** looks promising. Can I just use rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, originalWidth * scale)?
There are pins in the channel which has links for learning
i think you just trying to learn c#? to fully understand the how the codes works theres c# docs as base, and unity docs for unity stuff
I have an issue with debug.log where it would output two variables. One of the variables is equal to the other variable. However, they report different values.
boardTileName is a string. Can anyone help?
If they're printing different things they have different values
But they equal the same value
Also boardTileName is clearly an int not a string
Clearly not
Or at least an array of ints
boardTileName is a string
I see you're looking at one character from a string
why are you looking at a single character from the string?
What's with all the magic numbers here? This code is sketchy
What are you trying to do
Anyway the int is 48 because 48 is the ASCII code for the 0 character
boardTile is a gameObject array which contains tiles in the format "x, y". I'm iterating through a part of the array to add into another array.
A complete list of all ASCII codes, characters, symbols and signs included in the 7-bit ASCII table and the extended ASCII table according to the Windows-1252 character set, which is a superset of ISO 8859-1 in terms of printable characters.
This is what's going on
No it's not a GameObject array it's an array of some kind of tile object
Why are you showing me this
it shows what the values go into
This code is atrocious. If you want to get the number from the string you need to parse it
how do i parse it?
Simply casting it to an int gets you the ASCII code
int.Parse for example but using strings like this is a bad idea. You should just put the number in your tile object
Directly
If your IDE is not autocompleting code
or underlining errors, please configure it.
Select one:
•
Visual Studio (Installed via Unity Hub)
•
Visual Studio (Installed manually)
•
VS Code
•
JetBrains Rider
• :question: Other/None
does anyone have a fancy linq way to check if two lists are holding the exact same contents
was expecting google to give me some perfect function but getting a lot of varying more handcrafted solutions
SequenceEqual
😲
How does SceneManager.GetActiveScene work when I have multiple scenes loaded?
I suppose ActiveScene is misleading, it is not just a scene that is loaded and enabled but rather the “main scene” where new game objects get created and the lighting and occlusion settings come from. There can only be one active scene at a time
Yeah I read that in the docs, but how does Unity choose which of the loaded scenes is "active / the main scene"?
I would be loading several scenes to move my player through them without any loading screens
Either the first one that loaded or what ever scene you set as the active one
You can also manually set the active scene if needed
so ive been using godot before and now i switched here cause it supports C# better but is there like a unity version to the godot event system where you can use a master object with all the methods and then just connect them to the system? cause it kinda feels unoptimized to add the script to the object and then reference that same object in the event trigger,i want a single object to hold all the methods and reference that object to the event trigger of others all in the same scene
kinda hard to explain since each engine handles events very differently
might help to provide an example
Does Unity have a build in way to reference scenes in the inspector? Or do I need to use strings?
That just sounds like an event bus or something
https://github.com/starikcetin/Eflatun.SceneReference this repo will change your life
yeah I've seen that, so there's no built in way?
No but just use this package
I just need the scene names, not sure if this library will be compatible with my game (using fishnet)
Has nothing to do with fishnet
It’s just a way to serialize a scene asset in the inspector
this is on godot,the blue arrow is where the script is,there are like 3 methods for each button you see,the yellow shows the event and that event is just attached to that master script,in unity i usually just add the script to the button and reference the button inside an event trigger
Under the hood it’s the same you can use build index or name or what ever
I don't understand how that's different from the button UnityEvent in unity.
cause in unity i have to reference the same button inside the event trigger
i tried referencing another object but my methods dont show up
i dont want to create 1000 new scripts for each button that has only a single method,that would get very cramped and confusing fast
actually i dont really need to make more scripts but i would still need to add the script to the object
essentially i just dont want every object to have a script
Are these public methods? Are you referencing script instances?
Do they have parameters?
they are public but for script instances im not sure? how do i reference script instances?
also no they dont have parameters
Script instances are attached to gameObjects. So you need to drag in a GameObject with the script.
Were you assigning the script asset or something?
Oh then yeah I did that
No,I didn't even know you could do that until a min ago when I tried lol
Script assets are just text files. They are not related to the actual script instances.
the unity event ui isnt that difficult to use... drag in the object, select the component and function
or sub in code, do whatever
Might want to brush up your understanding of types/classes and their instances/objects in C#. I'm sure it's an important concept in Godot too
So I just have to get used to the different way I assign events
There are many differences. Might want to go over the beginner pathways on unity !learn to make sure you're not misunderstanding something based on a different engine.
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
In Godot events could be either private or public,the engine didn't really care so yeah I might need to revisit C# a bit,hiatus got me messed up
Even though unity could make it work with private functions, they chose not to which was wise. If you want a private function to work then subscribe in code:
[SerializeField]
Button button;
//Somewhere
button.onClick.AddListener(MyPrivateFunction);
if there isnt something like that you can make it yourself
unity is pretty versatile when it comes to creating your own systems
keep in mind this new listener wont show on the inspector during runtime
took me an hour to figure this one out...
well yea they are separate, one is pre configured to be done via reflection, one is a delegate subbed in code
yeah i noticed that which is nice since godot was so simple it backfires so much and makes stuff extremely hard to fix
yea i tried godot once was completely lost
unity is more like a sandbox game (minecraft)
also i have another question,can i check for 2 events of the event trigger? i have a menu which makes each button turn red when hovered or selected thru navigation keys and i ran into a glitch where if you hover a button and then use directional keys then the previous button stays red and i wanted to check for the Select and PointerEnter events so the method wont run twice
easy, pointer enter -> set "hover" to true, pointer exit -> set "hover" to false. Check bool when select is invoked.
oh yeah i guess that would work
my first idea was to make the entire event trigger inside the code and make an if statement but this seems much easier with the same effect
ui buttons already have functionality for changing stuff when hover or selection state changes though.
You can do whatever in code though, events just report that a thing happened or changed so you can do what you want after.
you can also receive the events in monobehaviours directly without a event trigger:
public class MyMono : MonoBehaviour, IPointerClickHandler
{
public void OnPointerClick(PointerEventData eventData)
{
Debug.Log("I was clicked!", this);
}
}
oh damn thats very cool
godot had something similar but never used cause they use a very bad camel case naming convention which made me go insane
hey i've been struggling a lot using animator, is there a documentation somewhere because i've been looking but can't manage to documentate myself, thanks
thanks mate
hi im making a space invaders rip-off from a udemy unity cours and it spawns these bullets but its not spawning infinit bullets it only spawn 4 what is the problem
thats the code
there are no errors
Where did you look?
My guess is that you are instantiating an object in the scene instead of a prefab
And your object in the scene is being destroyed
Hence the error
Fix it by using a prefab instead
whats the problem i followed the cours
im using a prefab
No you're not
You assigned the field to an object in the scene
Assign it to the prefab
Drag the prefab from your project window into the slot in the inspector
um using it like in the tut
Doesn't seem like it based on your error
Again, drag the prefab from the _project window _ into the bullet slot of the inspector of the spawner.
This shows you definitely did it wrong
BulletPlayer is an object in the scene
Delete it from the scene
Instead you must drag the PREFAB into the slot
The prefab is in the project window not in the scene
None of the bullets should be in the scene at all
Delete them from the scene
They should only be in the project window/assets folder
the guy from the cours said it like that
Doubtful
But regardless
It's wrong
Are you here for advice or to stick to what isn't working?
You also need to look at your full error message and make sure you're even looking at the right script
Then slap them
now nothing works
Doubtful
what is the problem now can you @wintry quarry please explain it again to me would be very nice
We don't know what the problem is now
You say what problem is, we say why problem is
Maybe not beginner
Im currently working on a 2D roguelike, and made a prototype for handling active-use items - but before I move on, I wanna check if there's a more efficient way to go about this
I basically made an Item class, and from there I made a TNTItem script so I could make a scriptable object and use that? But it seems off because this would gradually be cluttered
You should probably have TNT be an instance of generic item, rather than a different class
How do I go about that? I think I know what you mean, but I was confused since I have the use item functionality in the TNT class/script so I wasn't sure where to put it
"Now nothing works" is meaningless. Explain what's happening, what errors you're getting and how you have set things up now.
I explained above what you should be doing.
You'd need to write the item script as generic as possible, so that it can handle all of the functionality of the TNT object. For the most part, you want your ScriptableObjects to do as little as possible, and serve as containers of data. You might want whatever thing uses these SOs handle the differences. At some point, there will be a MonoBehaviour referencing the SO, so you can have that behaviour be the one that handles deciding whether the item explodes or not.
If your SO is for something like an inventory, you don't actually need functionality, just a name, icon, stack size, etc. that all items will share, and maybe a prefab that it spawns when you use it in the world. You'd have the TNT object spawn in that TNT prefab, and that handles the exploding.
Hi, my smooth brush wont change size, any fix?
you havent set the bullet as any gameobject or such
It means exactly what it says. The error states that you have not assigned the variable named bullet on the SpawnBulletController script, and that you should probably assign it . . .
its assinged
It means the variable bullet of SpawnBulletController has not been assigned. You probably need to assign the bullet variable of the SpawnBulletController script in the inspector.
Do you have any duplicate scripts in the editor?
Have you looked at every SpawnBulletController in your scene
You have to place the script on a GameObject. Check if you have more than one of those scripts on a GameObject in your scene . . .
when using 2D objects, how is it handled which objects can interact with eachother?
Like, if I place a gameobject with a sprite and 2d collider at 0 10 0 with a rotation of 0 0 0, will it be affected by another one at 0 9 0 with the same rotation if i'm trying to create a parralax effect by using the different positions?
or will they be handled independently as different physical "layers?"
Similar to 3D, objects interact with each other based on their colliders . . .
i like this sever
You can setup your collision matrix to determine which layers interact or ignore each other . . .
Thanks for the info, I wasn't sure if the influence would have extended with how the 2D objects work. It my original unity class we always just offset everything to prevent Z-fighting and used axis-locked 3D colliders and physics, trying to move away from that practice
You've learned a valuable lesson: Errors never lie. If it ever seems like an error is telling you to do something you already did, you gotta really think about what assumptions you've made that were wrong because it's definitely the human's fault in those cases. In this situation it was the assumption that the error was about the one that did have the assignment, and that you didn't have any extra copies.
Programs are very precise, notice it didn't say all SpawnBulletControllers were broken, just that a SpawnBulletController was. Keep this in mind for future errors
This sounds like sorting layers, which 2D also has. You can place sprites in a sorting layer, like: BG, Environment, Character, FX, Foreground, etc., and even sort them within those layers . . .
This will determine which sprite(s) display in front of or behind another . . .
using System;
using System.Collections;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Serialization;
public class OverlayManager : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
{
private CardOverlayManager _cardOverlayManager;
[Header("Rechtsklick Handler")]
private GameObject _pressedObject;
[Header("Managers")]
public DeckManager deckManager;
public DiscardManager discardManager;
private bool _isOverlayOpen = false;
private void Awake()
{
_cardOverlayManager = GetComponent<CardOverlayManager>();
}
public void OnPointerDown(PointerEventData eventData)
{
if (eventData.button == PointerEventData.InputButton.Right)
{
Debug.LogWarning("Rechtsklick gedrückt!"+ _isOverlayOpen.GetHashCode());
_pressedObject = gameObject;
}
}
public void OnPointerUp(PointerEventData eventData)
{
if (eventData.button == PointerEventData.InputButton.Right)
{
if (_isAreaOverlayOpen && !gameObject.CompareTag("Card"))
{
_areaOverlayManager.CloseDeckOverlay();
_isAreaOverlayOpen = false;
return;
}
if (_pressedObject == gameObject)
{
OpenOverlay();
}
}
}
private void OpenOverlay()
{
switch (gameObject.tag)
{
case "Card":
CardOverlayManager.Instance.OpenOverlay(gameObject);
_isOverlayOpen = true;
Debug.LogWarning("Öffne das KartenOverlay Und änder Zustand zu true!" + _isOverlayOpen.GetHashCode());
Debug.Break();
break;
default:
Debug.Log("Kein bekanntes Overlay vorhanden");
break;
}
}
My Private bool: "_isOverlayOpen" gets changed to false after a single frame
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
Yes, i get a true in the log
Nothing here changes it to false ever. It's created as false, and is only ever changed to true.
yes if i log it in here like that
i get false
public void OnPointerUp(PointerEventData eventData)
{
if (eventData.button == PointerEventData.InputButton.Right)
{
Debug.LogWarning("Rechtsklick losgelassen"+ _isOverlayOpen);
if (_isOverlayOpen)
{
Debug.LogWarning("Schließe Overlay! Und änder Zustand zu false!"+ _isOverlayOpen.GetHashCode());
_cardOverlayManager.CloseOverlay();
_isOverlayOpen = false;
return;
}
The code you posted had a different variable there
what i expect: First click on a "Card" Tagged Object:
- Open an Overlay/set "_isOverlayOpen" gets set to true
- Second Click close the overlay > because _isOverlayOpen is true
i know, that was an error, but not the error
The Code gets set to true but its instanly false again
I tried calling it with an Update
An got a single "true"
You can create a separate method that only changes the boolean value when you click on a card and test that
Post the !code of the script where this is actually happening, since the one you had before apparently was unrelated. And use a bin site
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
If it still persists, something else is changing it outside that script
A tool for sharing your source code with the world!
Like this?
But its private? Shouldnt that be impossible
Oh you’re right, I didn’t catch that
But you can still try explicitly changing it though just as a test
Okay, and this is the object you logged the value in update?
Looks like the only things that ever set _isOverlayOpen to false are when this object is created, and when you right click. If you're not right clicking, you're probably getting logs from two different OverlayManagers, one where it's true, and one where it's false
Im pretty sure thats not the reason
But how would i test if i had multiple Scripts with the same name open?
Search for them in the hierarchy during play mode
t: OverlayManager in the search bar on the hierarchy
Jesus Christ😂
That seemed to be part of the Problem, i accidently attached it to my card prefab...
But im pretty sure there is still something wrong with the bool, gimme a min
I think im beginning to Understand my Problem
The OverlayManager never worked to begin with
can someone explain me // new
The new keyword in C#?
yes just explain what it does and why its there
Why it's where? Show context
Usually it is used with a constructor to create a new instance of an object
Like a struct or a class
perhaps start by learning the basics of c#, there are some excellent beginner c# courses pinned in this channel
im doing a cours rn but i dont understand it realy
You're not supposed to take your first learning steps on this server
you're doing a unity course without understanding c#. don't skip steps just because you don't want to start with the absolute basics
i understand im just askin for it what is your fcking problem bro im just asking what it means because i understand it better from a person that speaks to me then a person that is doing a video
you've been doing this for days where you just want "this one thing explained" instead of going and actually learning everything as a cohesive unit. since you refuse to actually learn the basics i'm just going to block you, and don't be surprised when others do the same
im learning rn and im nearly finished with my first game but i dont understand the meaning of new
ive written so many lines of code
again, this is because you have skipped learning the actual fundamentals of the language you are using. just because you've copied a bunch of code from tutorials does not mean you've actually learned anything. this is clearly demonstrated by your constant need for explanations of absolutely basic concepts
no
new is one of the basic concepts for sure
look at that it german because im german dont look at 3 thats all stuff i already know like how to open inspector and stuff but look at all other they are all finished
clearly that is either a bad course that doesn't actually teach all of the basics or you didn't pay attention to it.
as i've pointed out there are beginner c# courses pinned in this channel, including ones that can be easily translated to german (specifically the microsoft ones can be set to german) and actually teach you the important topics you need to understand
I dont want to be disrespectfull but you realy piss me a bit of only because you probably know c# better then you family it dosent mean your something better i just want to be treaten right by you i just asked a question
i don't give a shit that i piss you off a bit, because all i've done is give advice that you should take because you are trying to get ahead of yourself. you currently do not have the skillset required to understand all of what you are doing and you are instead making other people supplement that for you instead of just learning the basics so that you understand it yourself instead of needing to come in here to ask about basic stuff 5 times a day
ok if you think your so smart give me the course you used to learn c# and we will see if i get so "GOOD" like you
and if my question pisses you off then just dont watch them and ignore it
if only i had mentioned multiple times where you can find beginner c# courses that cover the absolute basics that you need to know
where? send me a link
ok i will start with beginner scripting
start with intro to c# since you clearly want to learn in a language other than english. because that is the microsoft course that can actually have its language changed properly
im sorry for insulting you
why is this never reaching pass the 'wait until', even when jumping becomes false?
i am running it in a coruntine btw
do u call StopCoroutine() anywhere when jump becomes false?
u could try it w/ a regular while loop
i feel like that would cause alot of lag no?
my idea of how it should work is
Jump function runs
animEvent causes jumping to become false (this works)
waituntil triggers
rest of function
yield return null is basically the same as WaitUntil performance-wise i believe..
and while will check each frame..
alright, ill test it out, ty
while (jumping)
{
Debug.Log("Inside while loop, jumping = " + jumping + ", frame: " + Time.frameCount);
yield return null;
}```
just to compare it to ur yield return new WaitUntil(() => jumping == false);
this is what i tried but am still having issues
and im very confused by this, why is jumping considered false out of the loop but true inside? (the "false" print is from the point where the function is called, and will only run the function if jumping is false)
keep in mind that the yield is only evaluated at a specific part of the frame, if the bool is not false at that part of the frame then nothing about the coroutine changes. if that one False log is printing when you change it to false, then you are either getting a log from the wrong object or you change it back to true before the coroutine resumes execution
oh so it might be like
- jumping is false so it runs function
- function sets jumping to true
- anim event sets jumping event to false
- jump function reruns before the yield can detect jumping as false, setting it back to true
- repeat
?
yes
https://docs.unity3d.com/6000.0/Documentation/Manual/execution-order.html
notice how most of the yield stuff happens after update but before animation updates, that is the point in the frame that your coroutine will resume checking the bool
waituntil and waitwhile are basically while loops
hey uhm im trying to make a mobil button rn but it doesen work it always gives me error cs0246 because a button isnt assinged but i dont know why its not assinged
@slender nymph please dont judge i need to make this and im learning but this is very important to make for me
Why do you keep pinging him 😆
You don't need to bother people. You need to include the using UnityEngine.UI; namespace.
omg thank you
