#š»ācode-beginner
1 messages Ā· Page 604 of 1
but i think i will get @rich adder 's Suggestion
playerPrefabs
show the inspector
ooh wait
Not sure what this means, but you're just suppose to use the channel that fits your issue or query . . .
unless you put it on a DDOL
ik just every single channel doesn't only help with programing
and thats theonly thing i need
so also at the charachter selection scen and select level scene?
If you only need programming help, then use the programming (scripting) channel(s) . . .
if you dont want to put GameManager in every scene and fill every scene with the same prefabs, you'd need GameManager filled and then use DontDestoyOnLoad on it so it stays between scene changes
Alright but i gonna do oldskool way just put it on every scene way easier for me
ok
hmm @rich adder ?
you're showing me a video without any context
what do you expect here
they double spawn
I see that
but wanted to only get one
so make it get one?
nowp only 1
so then look careful whats happening
You see whats already in the scene vs whats being spawned by line 22?
yea this line :
GameObject player = Instantiate(playerPrefabs[CharachterIndex], lastCheckPointPos, Quaternion.identity);
its normal the mean intention to spawn 1 so thats good enough
yes that would be the spawning line
exactly its doing what you coded it to do
now it doesnt error so its working
yep but how come their are 2?
you didn't notice whats inside the scene before you hit play?
:oo waitt
ty for remind to check that i was focussing on the console
but how do i add the function DDOL
where to?
to charachter Selection? or?
why do you want to add DDOL now? thought you wanted to keep a manager on each scene
cause the selection menu is not working yet
yea but thing is if i add manager each scene they spawn also and that is not the intention
look wait
i gonna show what i mean
so why dont u just remove the player on each scene since they are spawned by Player Manager
game manager being DDOL make no difference in your current issue
is that possible?
whats possible?
what did you do ?
but the thing is on that menu their no players only the charachters
nothing
so ? who cares.. you're only saving the index
Where do I ask if I want to join someone on a project or smthn
as long as the index matches selection to the one saved in PlayerPrefab
Okayy
the Player Manager just needs to have the same list order / amount. The only difference now is Player is Spawned in, so anything in the scene doesnt have direct reference to the player that was in the scene when it started.
You'd need to inject or FindByTag or Component or singleton
website š
:loudspeaker: Collaborating and Job Posting
We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
⢠Collaboration & Jobs
Aight let me try
nowp
what did you do..
also you should provide that info without me having to ask.. its kinda of. waste of time having to extract info eevery time
The errors are just screen overlays i dont have rn, but the charachter selection dont work like you see
I have returned! After changing my grid over to a set of images I'm trying to get the specific image hit to put my card object into. This is the snippit of code that I'm using for PointerUp
public void OnPointerUp(PointerEventData eventData)
{
if (currentState == 2)
{
GameObject hit = eventData.pointerCurrentRaycast.gameObject;
GridCell cell = hit.GetComponent<GridCell>();
if (cell != null)
{
Vector2 targetPos = cell.gridIndex;
if (gridManager.AddObjectToGrid(gameObject, targetPos))
{
if (handManager != null)
{
handManager.cardsInHand.Remove(gameObject);
handManager.UpdateHandVisuals();
}
else
{
Debug.LogWarning("HandManager not found!");
}
Destroy(gameObject);
}
}
else
{
Debug.LogWarning("GridCell not found on the hit object or its parents!");
}
// Transition to state 0
TransitionToState0();
}
}
```and it's throwing this error (image 1) however the grid cell script is attached to my box prefab (image 2)
no shit.. But without you saying what you did or didn't do this just a waste of time
I just added the player Manager to everyscene. but yea like you see no works
why did you add it to character selection scene?
obviously you spawning a player on awake in the character selection sceene makes no sense
so there is absolutely no reason to even have player manager there
maybe it would work but it doesnt & now i know why bcs it doesnt have to be there, but yea the button need to select the charachter but the thing is it doesnt
start by Debugging hit.name
do i need to add it to : https://paste.mod.gg/lbogjzllcgqg/1 | https://paste.mod.gg/spxvattwwguz/2
A tool for sharing your source code with the world!
A tool for sharing your source code with the world!
things don't start working just cause.. thats not how it works
agree
you can't just guess your way through things, you have to be deliberate in what you do..
you sent the same exact code twice
not really but i know what i do, it just these tiny things that doesnt work like i wanted to, or if im struggle with o wait https://paste.mod.gg/spxvattwwguz/1
A tool for sharing your source code with the world!
have no idea why you keep sending the same script over and over
huh
I get it they're in different tabs
indeed
no idea how those relate to what the issue is
do you even know what half your code is doing?
yep
well if you did how come you don't know where the problem is ?
thats just the problem, everything is alright in my codes but when i press play it doesnt work
"it doesnt work"
what does that even mean
if you think everything is alright in the code, why do you keep insiting its the code and sending me code?
the game etc does work only the character selection menu doesnt oh maybe here i have to look
im gonna say this one more time... if the Value of the skin / character is just a index. Why are you putting Player Mnagaer in the character selection screen?
nvm i will look it out of my own, player manager is not anymore in it
very simple :
- either player manager can exist in all scenes but not spawn player in AWAKE but use an explicit method, possibly listening for scene changes / reading specific scene name
- Playermanager only exists in play scenes and nothing more.
ok
so what is gameobject Image in your scene hierarchy
by name alone, nothing
however what I'm trying to hit is an image, it doesn't have the name image though
ope
wait
show your hierarchy of canvas rq
Do you have an image as a cursor ? it could be hitting itself
found it, and the problem does make sense
let me try something real quick
ok figured it out, now to find the solution. I'm trying to drag and drop an image onto another image (probably stupid I know) and it's hitting the upper image, the card
is the best solution just turn off raycast target on all of my card images?
you have to disable the raycast target while grabbing the image
i find easier to also just use Canvas group for that as well
I actually am using multiple canvases
canvas group is just used to group elements
but also helps easily disable raycast target on it and its children
hmm so do I put that in a script on the canvas?
and then just call it when I pick up the card?
because I do have on hovers
each card have their own canvas?
yup
whys that
at the time it seemed like the simplest way to handle everything, and also what a tutorial recommended
so if you spawn 50 cards you have 50 canvases , thats a lot of canvases
I'm quite new so I don't know everything possible
most at one time would be 10 most likely
I would keep a Card canvas but not have one nested in each prefab
actually I guess 21 canvases would be the max possible, forgot about player 2
each canvas per card might complicate what you're doing even further
UI is very picky
I figured that out lol, my last post here was to figure out how to interact with non-ui elements and had to recode a bunch of stuff
@rich adder see now its working well it was just something with a spellingmistake
what? which spelling mistake
can you elaborate on this a little when you get the chance?
like just keep the Card Canvas in the scene itself, then all cards can just be spawned as child of that canvas
btw dylan you're misspelling character
are you talking about the PlayerPrefes key?
it's hurting my soul lol
yea at the line of:
CharachterIndex = PlayerPrefs.GetInt("Selected Charachter", 0);instead of thisCharachterIndex = PlayerPrefs.GetInt("SelectedCharacter", 0);that was the mistake
hmm it should still return 0 if the key isnt found
it would not throw a null reference
video you showed, you still had error on line 22 because the one on char selection screen didnt have its fields populated like the other scene
but also in charachter script was it this : PlayerPrefs.SetInt("SelectedCharacter", selectedCharachter); instead of PlayerPrefs.SetInt("SelectedCharacter", selectedCharachter); so yeah idk something small i guess but found it thats important
also another reason not to use string like this and use a const / static key
small update before I inevitably come back later: got the canvasgroup to work to disable the raycast blocking, now the cards at least attempt to go to the right spot (numbers are wrong, gotta fix those) and all I have to do is turn the raycast blocking back on after I drop it down and it doesn't go in the right spot
how can i make so that if parent has different scale than (1,1,1) the children with rigidbody act normal?
because when they fall and rotate they kinda become bigger/smaller?
dont
By not having parent with non uniform scale
so what do i do
im making a text system and i want to be able to scale the parent and it scales the whole text
im gonna have to recalculate letter positions and all?? šµ
Why would your text system involve rigidbody
cause its nice to have rigidbody for all letters
What

That doesnāt explain anything
And they are going to interact with physics?
yes
they already do, and it works well
Then youād do this
but once u scale the parent, it all breaks down
so there is no other way?
im incredibly confused by what you're doing. but, try one of these
Well you are dealing with physics, and your letters gonna have own rigidbody, so give them good individual location
And scale
maybe it would be possible to first instantiate in the parent, and then unparent it, so that it already keeps all the scale, rotations?
im making a text system from scratch
That sounds eww but if it works for you
š i mean, it would be easier so i dont have to calculate since i already have 3 variables for each letter like width, and offset x/y
okay i will try and see if i could scale up each individual letter instead of the parent, and calculate it so its all together centered
why does the var on the left hand side not get garbage collected if monobehaviour is destroyed? I thought gc takes care of this
Or is this a renderTexture only kind of thing
Because RenderTexture is a UnityEngine.Object, which means it exists as a native Unity object as well. When the C# class gets garbage collected, which it will, the native object will not. Not until Resources.UnloadUnusedAssets is called, which happens automatically on scene loads.
Are unityEngine.Object classes not considered C# classes?
Maybe I'm confusing the meaning
You can see that finally block manually releases the resource, and the problem is that part is being called or not
Afaik it should be called if enumerator is properly disposed
I dont understand this. What if you stop the coroutine, will the object not be garbage colelcted?
This is my confusion as well
Does unity not check for unused dependencies when these objects are destroyed
This is from https://www.youtube.com/watch?v=7eKi6NKri6I
Before async was introduced in Unity 2017, asynchronous routines were implemented using coroutines and/or callbacks. This video covers the benefits of async over coroutines. You'll see how one example problem ā building an asynchronous prompt popup ā can be solved using async vs coroutines.
Speaker:
Johannes Ahvenniemi - Seriously Digital Enter...
Its native resource may remain since Release is not called
Classes that inherit UnityEngine.Object have two representations, managed and native. Both reference each other. The native object can be destroyed without the managed class being garbage collected, like when you keep a reference to a game object even though it's destroyed. Similarly, the managed class instance can be garbage collected, but the native object still exists in memory.
Is that intended? It's not like the texture exists on the scene, so how else would you actually reference it?
So when I have a nullreference exception due to destroyed gameObject, it actually is keeping a reference to the "managed class" so to speak?
Also where can I learn more about this type of quirks, or do I have to trip and fall before encountering them
The managed class instance will be garbage collected, but Unity doesn't automatically destroy the native object when this happens. It defers checking for unused assets for later because it's an expensive operation. You can force it by calling Resources.UnloadUnusedAssets(), which Unity will also call when you load a new scene.
Yes you have reference to the managed object in that case. Unity just treat it as null, but thatās fake null.
Yes, Unity is faking a NullReferenceException in that scenario. You're still referencing a valid C# object, because it's not possible to "destroy" a C# object that is still referenced. That's just not something the runtime is capable of. So Unity does the next best thing and throws a NullReferenceException if you attempt to access anything on a GameObject class reference which has been destroyed.
wow that's actually shocking new info for me

Unity is also overriding the obj == null check to return true for destroyed instances, because again, C# objects that are still referenced somewhere cannot be destroyed.
I was really baffled by that for a while
I guess this is more of a special case too because of having to release the texture so ok it does make sense. I wouldn't be creating them inside of the coroutine anyway
The screenshot you shared isn't really talking about this, btw. It's referring to the fact that a finally block in a coroutine will not be called if the coroutine is stopped early. So even though the coroutine attempts to do the right thing and release the texture, it will be unable to.
Itād be kinda same thing if it was a game object that you wanted destroy when coroutine ends
Yeah, the async operation is actually way different in that it still runs which is a behaviour you usually don't want from gameobject routines
I see!
the speaker said that this was one of the reasons to use Coroutines over async because of the unmanaged stopping time
and this is because stopping a coroutine early is as simple as...stopping!
you just stop calling MoveNext() on the enumerator object
I was reading some of the unity forums about when to use Coroutines, and one of the answers I found was that "if you have to stop a coroutine you don't need one", and now I'm slightly more confused about when to even use async
Disposing IEnumerator should call whatever in finally I believe, but Unity might just not doing that 
I mean, I always stop coroutine/tweens when I want to stop it mid-way from lerping to its location
You can cancel async task, but it can be bit more tedious
Oh, interesting, I didn't know that.
Hello, I would like to ask if there is a better way to find a collision between a CharacterController and a Sphere Collider, because this won't work when I test it out!
Also had an animator component specific question: I wanted to check for animation completion after playing an animation in a coroutine, but I think that the animator only starts playing on the next frame(from what I've tested so far), so I can't sequentially do
_animator.Play(animation);
// My working solution is to yield return null to wait a frame before checking but that seems hacky
if (_animator is playing) {
check animCompletion // I have to check specifically what animation is being played or else this does not work
}
I usually just rely on the statemachine I make and not what the animator is currently doing
CC has separate event for it since it doesnāt really ācollideā https://docs.unity3d.com/6000.0/Documentation/ScriptReference/CharacterController.OnControllerColliderHit.html
You put rigidbody for whatever dynamic physics body
is there way to make trigger happen without an active Move() being called?
Maybe look into StateMachineBehavior because itās useful when you want to do something bound to specific mecanim state
https://docs.unity3d.com/6000.0/Documentation/Manual/StateMachineBehaviours.html
You can also use trigger events instead of collision
But in what case you canāt call Move
i just mean if the character is falling onto it
wait ig theres auto gravity move being called so
yeah ig it works i just dont want it to be buggy
Would the script have to be on the characterController or on the sphere if i were to detect a hit?
I think it needs to be with CC but you can test
Thank you! Will do
Is it more common to use git or the build in unity vc?
Im trying to create my own game through unity itd be like a 2d platformer basically a cheaper version of undertale with a different theme Ive never used unity how cooked am I
have you made flabby birb yet
If you need a specific ratio number, you'll need to research on your own. Both are being used.
I need to swap parent of my weapons between a few different bones on my characters rig.
Is it true that the only way to find these bones is a runtime search?
I read that i cannot serialize Transforms
hello everyone, i have some code here:
float scroll = Input.GetAxis("Mouse ScrollWheel");
if (scroll != 0)
{
Debug.Log("scrolled");
Vector3 scrollPos = transform.position;
scrollPos.y -= scroll * scrollSpeed * 100f * Time.deltaTime;
scrollPos.y = Mathf.Clamp(scrollPos.y, minY, maxY);
transform.position = scrollPos;
}
which should move the camera up and down when scrolled, however there is zero change, the debug log is printed and the scrollSpeed is set to 300 but it still doesnt work, anyone know why?
Are structs just PODs?
Of course you can. You can serialize references to unity objects, and transform is a unity object.
Parent Of the Day?
Depends on what you mean by that.
Either you reset the position elsewhere, or clamping is preventing it from going any further.
If statements. I suggest going over the C# basics. There are plenty of resources online.
i know the f statement i meant from script to script sry.
Hash table of key-value pairs and nothing else at all
Reference the other script and make the bool a property where you'd call a method from the other script when the value changes
Go over the basics from !learn
:teacher: Unity Learn ā
Over 750 hours of free live and on-demand learning content for all levels of experience!
ok
That's a very weird comparison. Structs are almost the same as classes, aside from a few limitations, like missing inheritance and such, due to being value types as opposed to reference types.
Structs can have methods and properties if that's what you're asking.
How can POD mean Dictionary
I guess what they meant is "plain old data" or something
How is that different to a hash table mapping keys to values?
If I can only write
MyStruct.LogHi()
int X = MyStruct.MyConstant
Then that's literally just a dictionary
What can a struct do that a dictionary can't or vice versa?
struct is how you define a value type object. dictionaries are collections of key value pairs, they really aren't the same at all
Nothing is being hashed there
Ok, then according to your logic, a class is also a dictionary, no? I really don't get the question
Let me guess, Python
A class is a dictionary ||with additional functionality like inheritance and allowing instances to be created||
Then it's just a key value mapping?
I don't see any difference, what can a struct do that a dictionary can't?
You say they aren't the same so can you give an example of how they differ?
Structs also have instances.
So according to you, everything is a dictionary?š
a struct is not a dictionary in exactly the same way that a class is not a dictionary. class is just how you define a reference type, struct is how you define a value type and dictionary is a specific class that contains a collection of key value pairs
what am i reading
If you refer to a dictionary as a collection of variables, then basically everything in programming is a dictionary
No hash, value type, can have different types of fields, not dynamically sized
And much more
Actually everything is in lua
But are you saying a struct is just a dictionary that can be instantiated/deep cloned with new?
lua is a silly language where everything is a table for no reason. c# is not the same at all
okay it was Lua, not Python
Thanks for this, but what do you mean by value type? Can dictionaries not be typed in c#?
Value type basically means it is copied when you assigned to different variable, while reference type variables refers to same instance
int is value type for starter
No. I'm saying that they are completely different data types.
There's an actual physical difference in how they are laid out in memory. Structs are defined at compile time. You can't add new members to the struct at runtime, because it's a contiguous block of memory. Dictionaries are not a contiguous block of memory. I don't know how exactly they work under the hood, but it's probably 2 arrays with keys and values. So they are potentially placed randomly in memory. You can add elements to the dictionary at runtime.
Oh I see, is string value type then? If so, would that mean assigning it to another variable and mutating one wouldn't cause a mutation in the other?
strings are reference types but they are immutable
You can't add new members to the struct at runtime
This is what I was looking for at the start
String is immutable reference type. Itās not copied but you cannot mutate it
You get the idea though.. but thanks for actually explaining the differences in the end
Ok, then you should've asked that instead of something confusing like "how are they different from dictionaries"
Vector3 is value type if that helps
okay I guess its just Scriptable objects wont allow transforms. I was hoping that I could just set the target bone
Transform activeBone;
Transform sheathedBone;
but Ill have to do that in a factory design pattern instead.
Here's a tip on when learning a new language: go through it's basics in the documentation. Don't try to apply what you know wbout Lua to other languages. Especially, if you don't know how Lua works under the hood.
It's not like SOs don't allow it. You just can't reference objects in the scene(or in a prefab) from outside the scene. SOs exist outside the scene.
You can assign a transform of a prefab root to a scriptable object. It's not gonna help in your case though.
Would any one have a tutorial on any chance about how to do enemy pathfinding and player detection for a 2d platformer? Most gudies im watching arent that good or are top down.
a platfomer would be pretty easy i think
Im pretty new to unity and C# so im learning things as im going. Im trying to do my first enemy and the last things Im missing are:
-
Pathfinding where I can draw a custom path for them to follow left and right.
-
Player detection where if the player gets in range they will attack.
-
The attack of my enemy is long range so I have to figure out how to do the projectile and put the animation on the projectile n stuff.
you can use a grid like the one you would use for your tiles and move according to those tiles
never heard of that. Im currently trying to use something called A* pathfinder
that might be more complex than neccessary
can your enemies go up or jump or anything
I have it set in my code that if an enemy comes across a wall (and its jump force allows it), they will jump and continue walking.
I just havent figured out so how to draw my left and right custom paths for each enemy that I want
idk how it works but have a range that if the enemy is in it will take the neccessary steps to get to the player
yea i thought about keeping them stationnary until they see the player but i kinda want them to have "patrol paths" where they just go back n forth in
well if they chase your character to a different area would those paths work
or would they go back
I would it set so that as soon as they see an enemy, they leave theri path and 100% focus the enemy and chase him
like it will override their paths
yeah will they chase forever or when you get out of range will they stop? or go back?
forever
Yes
idk how it A* works is it manual drawing
idk i guess set 2 points maybe with in a range and then have it set to go to point a and when it reaches go to point b and so forth when not in chase
Do you use microsoft for coding or is that the noobie platform or does it matter
And also what languages are valid in unity
True
can i make static indexer property
Depends on what you mean by that
or perhaps i show off issue i want to deal with
this is what i tend to use for most classes i use now if i do array stuff in them thing is serializing it duplicates names, both for dictionary and thing it holds inside, that why i wanted make my sub class accessible by indexer so i wont have need for dictionary
{
public static Dictionary<string, class2> easyaccesstoclass2;
public class class2
{
public string name;
}
void add(string name)
{
easyaccesstoclass2.Add(name, new class2 { name = name });
}
}```
remember to put cs after the ``` when posting !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.
It's really hard to understand your message without any punctuation. Not sure what you're trying to say.
Also not sure what the purpose of this code is.
Well, the only other way to do that is reflection. But either way, I wouldn't do that.
Yeah, no, there is no static indexer
guys i have this muzzle flash and all and when i turn my player around the muzzle keeps facing the exact same rotation idk how to fix ik it looks bad but im still testing
https://paste.mod.gg/sqbtwyajmaew/0 heres the code
A tool for sharing your source code with the world!
i think simulation space supposed to be World
still dosent work
i did this same script on another script and it worked well but this time i rotated my gun 180 degrees to it faces away from the cam and had to rotate the gun tip so it dosent shoot bullets at me u think that might be the problem?
another project*
check gunTip rotation is probably wrong
its 180 but when i change it it starts shooting bullets straight back at me instead of away
whats it look like in the scene gizmo though in local space mode?
Why you using rotation for one but localRotation for the other
idk im trying to fix it it dosent wanna work
I would love some people's suggestion on the issues I am encountering for my enemy script.
-
I cant for the life of me figure out how to make it so that my enemy goes back and forth for his path. He goes in the direction of the point but when he reaches it, he just continues walking in that direction and not go back to the original path.
-
My sprite isnt flipping for the direction my enemy is walking along is path.
-
I want to make it so that, if the enemy is going along his path, it will play their walking animation, the problem is that it spams the walking animation non-stop.
A tool for sharing your source code with the world!
if (moveDirection.x > 0 && !isFacingRight || moveDirection.x < 0 && isFacingRight) 2 facing rights?
huh, maybe i did do 2 lefts. let me try to fix that
uhh so i changed my line too:
and my enemy is just freaking out going left and right while walking to the right
which Ig is an upgrade from jsut consistenly looking left
well in patrol or whatever wouldnt you only flip when it swaps objective
and in chase subtract player position from enemy position and if its negative or whatever go a certain way
idk how the map on unity works tho
hmm maybe that is true. But the problem is that, in the picture you can see, the first point is the left one and the second one is the final one. Its moving to the second one while looking to the left. Also, the issue is that it doesnt go back to the first one, it just keeps going right.
I have these 2 problems to fix and its killing me
inverse your code and it should work
sure let me try
if its facing the wrong way
WAIT IM DUMB AF
I KNOW WHY ITS INVERSED
i set the isFacingRight = true as the base value
when my sprite is originally facing left.
god im dumb
welp that only leaves my not going back n forth issue
yes 3
- for the first leve
- for the transition level
- for the final level with the boss
is it possible the walk code still runs if theres no objective
well if hes not chasing the player or patrolling why would he
that is very true ig i didnt test that.
huh?
well has it been following the path at all
it seems not, it just seems to walk to the right infinetly
or just going right on start
let me try with no path
with no point, he just stands still
as soon as I assign a point, he just starts walking right
no matter what
well you need to compare the enemys position to the objective point
i think you just start run and it keeps running
Yea ill have to try that. ill do that now.
Mornin' all,
Having something of an issue which is confusing the p*ss out of me.
I'm trying to grab something from an object pool, but for some reason it just won't grab the object and I can't see why (this exact same script works absolutely fine in another project I was playing with just yesterday). So I'm at a bit of a loss as to what I'm missing.
using UnityEngine;
public class TunnelManager : MonoBehaviour
{
float tunnelOffset;
[SerializeField] ObjectPoolManager tunnelObjectPoolManager;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
tunnelOffset = 20;
GameObject newTunnelSection = tunnelObjectPoolManager.GetPooledObject();
newTunnelSection.transform.position = new Vector3(0, 0, tunnelOffset);
}
}
This is what's calling the object.
And this is the object pool script.
https://hastebin.com/share/laracojibi.csharp
And here is everything populated as it should be.
So I'm very confused. (Probably missing something really obvious, but could someone take a look and point me in the right direction please?
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
why do you need to get the object
Okay, now I'm really confused, the debug here is saying the count for PooledObjectList is 0, but in the inspector is fully populated. Absolutely baffled. lol.
isnt it set to 0
Because the obejcts need to spawn/despawn constantly
i thought you enabled and disabled them in an object pool
like you create a set number and then disable them all and enable and disable when you need to
Yes you do, that's the idea, but for some reason it's not finding anything in the list in the object pool object.
The 0 that you can see in the console is a Debug for "pooledObjectList.count" but it's returning 0 (saying there are no entries in the list. But on the right in the inspector, the list has 15 entires as it should.
yeah im not sure i can help you maybe set it in the inspector
or is it idk
It all gets setup on start. It's really confusing because like I said I was using the exact script/system yesterday. I literally copied/pasted the script into this project. lol.
hmm are you creating an instance of them on start
Yeah, they get created (look at the pic, left side hierarchy, they're all there), then they get added to the list.
can you get an instance of a disabled object?
thats all ive got i dont know if you can like compare this project and your other one
That's why they get put in the list. Reference the list, tell it to turn on that object. I know it works, I was using it for bullets yesterday.
Either script execution order or youāre referencing something else
How are you ensuring which Start is called first
I'm using Awake on the script that calls the GetPooledObject() method.
Also tried OnEnable
That would make thing definitely fail
Youād want pool managerās initialization to be called first not the other way
Pool manager uses Start(), the 'spawning' script uses Awake
Honestly I thought Start was called first. lol.
But I have tried with OnEnable too (for the spawning script) and still failed.
OnEnable is called earlier than Start too
Okay, well yeah, that fixed it. silly spud.
Good to read through https://docs.unity3d.com/6000.0/Documentation/Manual/execution-order.html
Yeah, for some reason I'd got it in my head that Start() was first, even though I do (or did) actually know otherwise. lol.
Sooooo, another teeny issue that's bugging me.
private void Update()
{
curveChangeCountDown -= Time.deltaTime;
if (curveChangeCountDown <= 0)
{
currentXBend = tunnelCurveMaterial.GetFloat("_xStrength");
currentYBend = tunnelCurveMaterial.GetFloat("_yStrength");
currentXBend = Mathf.MoveTowards(currentXBend, xBend, lerpSpeed * Time.deltaTime);
tunnelCurveMaterial.SetFloat("_xStrength", currentXBend);
currentYBend = Mathf.MoveTowards(currentYBend, yBend, lerpSpeed * Time.deltaTime);
tunnelCurveMaterial.SetFloat("_yStrength", currentYBend);
xBend = UnityEngine.Random.Range(-3f, 3f);
yBend = UnityEngine.Random.Range(-3f, 3f);
Debug.Log(xBend);
Debug.Log(yBend);
timeToChangeCurve = UnityEngine.Random.Range(3f, 5f);
curveChangeCountDown = timeToChangeCurve;
}
}
Would someone be able to give me a clue as to why my MoveTowards operations aren't moving smoothly and just 'snapping' to their new positions please? š
I am confused on how to fix this, also, I am pretty sure I got the multiplication part wrong
There is a dot (.) between EnemyAi and sightange. Is this supposed to be a method or are you trying to access the sightRange field of EnemyAi?
The error states that sightRange does not exist. Did you create the field (You have to define it before you can use it?
I did that because the sightRange is located in my EnemyAI file
But you're accessing it like a method, and it seems like you're trying to use it as a method at the same time. This is very confusing. You need to explain what you are trying to do . . .
Are you doing this inside of another method?
I want to make it so the EnemyAi's sightRange, a circle around the Enemy, becomes half of its original size when you press Left Ctrl.
You need to:
- Check for input
- If correct input, call a method that halves the size . . .
Typically, input is checked in Update. I'd start from there . . .
I have this, but I am confused on how to add the sightrange from my EnemyAI
You need an instance of (reference to) EnemyAi in order to access its sightRange field . . .
You make a reference to the EnemyAI first, use the reference.method (if it returns a float) if you want to make a float
Also, I would increase/decrease its size by half instead of subtracting 0.5. What if some have a range of 2, 3, or 4?
I believe I got it to connect to the original variable from my seperate script but I cant figure out how to multiply it
Dot instead of arrow to access references
Even so, it's suppose to be an assignment; so it's still a bit confusing . . .
Quick scroll through http://rbwhitaker.wikidot.com/c-sharp-tutorials would really help
It seems you're having trouble with syntax and basic understanding of C#. I would look at a tutorial first . . .
Are you trying to change the sight range of an enemy AI here?
As in, does the EnemyAI class contain a sightRange float?
Then you'd access it like this for example
public EnemyAI enemyAI;
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.LeftControl))
{
enemyAI.sightRange = .5f;
}
}```
Just curious, is there any way to get the normal force that occured during collisions between two colliders?
Think I got it working, thx
You can if using an OnCollisionXXX method . . .
Couldn't find it directly, but i did find ContactPoint(2D).normalImpulse.
Just look at Collision from the docs. It has impulse and relativeVelocity . . .
One is the total impulse. The other is the (size) velocity of the collision. You can normalize either to get the direction (you may need to invert it to get the outgoing normal . . .
I haven't tested either myself . . .
Interesting that Collsion2D doesn't have that. It still has relativeVelocity though. I was focusing on 2D, and looking through Collider2D if there's another way other than the message.
Oh, 2D always has different stuff than 3D . . .
Facts . . .
Box2D vs Nividia physx
You really need to go learn C# basics. You're "inventing" non existent syntax...
any1 know how to make it so when the player starts moving the walk animation starts and the moment he stops the idle one, i keep having the issue of the player still being in the walk animation for 0.2s after i stop moving and more or less the same for the idle animation when walking
#šāanimation
but it just sounds like you've got exit time on your animation when you don't want any
nope, its something code related from what i see
then show relevant code
but 10 times out of 10 that description points to an issue with your animator controller setup
hmmmm, ima double check and see if i can do some fixes there then rq
oh yeah i forgot to reduce transition times lol thx for the help
why does it jiggle like this when i click, i dont see anything in my code that could be causing it.
public class RotationTransform : MonoBehaviour, IPointerDownHandler
{
private bool _dragging;
private Vector3 _original;
private Quaternion _originalRotation;
private Camera _mainCamera;
private Transform _effectedObject;
private void Start()
{
_effectedObject = transform.parent.parent;
}
private void Update()
{
if (Input.GetMouseButtonUp(0) && _dragging) _dragging = false;
if (!_dragging) return;
var mousePosition = _mainCamera.ScreenToWorldPoint(Input.mousePosition);
_effectedObject.rotation = Quaternion.Euler(0, 0, _originalRotation.eulerAngles.z + Vector2.Angle(_original - transform.parent.position, mousePosition - transform.parent.position));
transform.parent.rotation = Quaternion.Euler(0, 0, -_effectedObject.rotation.z);
}
private void Awake()
{
_mainCamera = Camera.main;
}
public void OnPointerDown(PointerEventData eventData)
{
_dragging = true;
_original = _mainCamera.ScreenToWorldPoint(Input.mousePosition);
_originalRotation = _effectedObject.rotation;
}
}```
oh wait
its getting replaced
completely
thats weird
maybe thats the issue
i have indeed fixed it now
NVM its not fixed T-T
i just thought it was
thats painful
the jiggle issue its fixed but now it just doesnt work while rotating
ok i fixed it and i dont know how
hi, in my game, i have a list of all of the upgrades the player has bought. im currently trying to make a save sytem that saves this list and also the levels for each of the upgrades. i have tried but have failed because i don't think json can save monobehaviours (boughtupgrades list is a list of monobehaviour classes) how would i go on about saving the boughtupgrades list?
https://hastebin.skyra.pw/pixolibese.pgsql
Save simple data. If you have a limited number of upgrades you can even represent(identify) them with an enum or int.
You don't want to save all the data of a monobehaviour(if that was even possible). You'll waste a lot of storage on stuff that doesn't matter(doesn't need to be saved) at all.
sorry, i don't really understand this. how would i save the upgrades as simple data? should i just make an array of ints with the upgrade levels and just use that?
make a regular struct / class that contains the values
hiya, having some issues with highlighting for unity classes in vscode. yes, i've looked online. yes, i've seen https://code.visualstudio.com/docs/other/unity . i've reinstalled vscode, updated .NET, nothing is working
i've used unity a few times before, but this is a new device. never had this happen before.
close VSC regen project files. open script again
just do it, then open VSC and show the Output window in VSC
can you show the bottom bar
yeah something is missing.. it Should at least say Projects: .. Show you have all the appropriate stuff installed
see how mine says Projects: Assembly-CSharp
Lets say im trying to make a game, what is the best way to learn? ive tried following the unity tutorials but stopped halfway through cause i wasnt learning the features i want. Let say i want to make a door open and close with an interaction, where and how would i learn that?
You break it down to all the small moving parts you can learn separately, then put them back together as you want them
most features share the same base knowledge
if you know how to break down interactions, it doesn't matter if its a door or picking up an object
making a door, if you think about the smaller parts needed.. First thing would come to mind for me is, tracking the state of the door itself first with isOpen bool or similar.
build up your objects from their very basic functionalities
That makes sense
yeah most problems are just compounded smaller problems
is there a good way i can learn the diffrent bools and functions?
well most of that isn't even related to Unity, I would suggest you learn that way
like plain c# (check out pins in this channel its a good start)
sorry, was dealing with a roommate
by appropriate stuff installed, do you mean extensions?
vsc extensions, unity packages, external tool page in unity
#1253440741322133545 message check out sebastian league's playlist
alright thanks
if ur just wanting to know what functiosn and stuff to use where and when
that just comes with tme and experience..
best to look up stuff from google and finde the link leading to the documetatiopn
i found the .net documentation, maybe ill follow a tutorial off of youtube then break down every function
hi, im trying to save a dictionary in my game using json. i made a list of a class that holds a string key and a value pair. when saving, i stitch these values to the dictionary and when im loading i overwrite the dictionary with the saved values. however it's not getting written to the json file. why is this?
https://hastebin.skyra.pw/hibolalayi.csharp
you only shown us part of the whole picture..
also unity cant serialize dictionaries
here's the playerdata and KeyValue class
https://hastebin.skyra.pw/uriwasujes.pgsql
hmm go back to VSC again and select c# devkit under the Output tab
is it just the list that isn't being included in the json? because if so, that's due to KeyValue not being marked as serializable
KeyValue is not serializable
quite a few failures here
try deleting all the .sln and .proj in your root project (close VSC while at it)
then go back to unity, only check the top two checkboxes in External Tools
Regen project files again and open script from unity
still nothing unfortunately, same output for the devkit
I would try
- A new different project for test
- Use Visual Studio / Rider and see if those work
is it possible permissions/firewall issues?
im confused why its trying to use dotnet 8.0.13 but they showed they have .net sdk 9.0
can u go in and manually uninstall the 8?
8 isn't installed afaik, i haven't done so myself
fresh windows install from around two days ago
dont mind me.. im just brainstorm/spitballin
You can do
dotnet --info in command line
it will show everything installed related to .net
no problem at all
also i cnat remember if beign signed in matters at all
you got a lot of earlier version of .net I wonder if its causing conflicts
oh im behind
does .net persist through a new windows installation? through the windows reset that is
9.0 gang!
depends if you did Upgrade it did
same happened in a new project btw
yeah Ima guess/suspect something borked going on with your runtimes causing conflicts
all else fails i'll work with visual studio for now but i'm gonna have to hold in the vomit
thanks for trying to help though man
that works too
np. If you feel up to it, do a clean wipe of all .NET then just install 9
Hello for some reason unknow to me i cannot apply this image to my background panel.
Sprite Mode Multiple
also not a code question
oops
Wrong thing
https://hastebin.com/share/nopotakoqu.csharp
In the following code, in the Update function, I'm using a Vector2.Lerp to smoothly move the position marker object into the targetPosition. The problem is it always goes a little bit further than it should. I tested that by setting it's position to the targetPosition, and it worked perfectly. Does someone know how a lerp can overshoot? How do I prevent
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
Applying lerp so that it produces smooth, imperfect movement towards a target value.
idk about overshoot tho...if anything it should never reach full val.
either way lerp is still done wrong
Evenin' all,
I was just wondering if anyone knew if the following was possible (and where to look to help figure out how to do it if it is)
Player is controlling a turret and doing pew pew things. I'm using image 'planes' for my environment with textures applied (see pic for context).
in the image there are some buildings and at the moment, my bullet impacts are pretty much all the same size etc. I was just wondering if it would be possible to sort of sample a depth map (I have one for the image) and adjust the size of the bullet impacts accordingly (ie, brighter the sampled pixel is, the larger the bullet impact?
Also for further context, short video
The whoile thing is one image?
but yeah - absokutely not a problem - you can read the pixels of the texture and do whatever you'd like with it
ngl thought that plane was a 3d model lol
It's a single image, mapped to 3 'plane' objects and sorry @rich adder the plane is a model. It's just the environment that's an image.
Would you happen to have any suggestions of resources to look at, or what to search for? š
What part are you struggling with?
I actually think I have some code that reads the pixels in an image from an old level generation script and throws them into a Vector2 array, so that shouldn';t be in issue.
At the moment, I'm not sure how to read the pixel value and then apply that to the scale of the impact object. (Mainly how to 'normalise' the value because it would read as an rgba?)
normalizing a float would just be value / maxPossibleValue
You can also use a remap function here: https://discussions.unity.com/t/re-map-a-number-from-one-range-to-another/465623
to essentially map the depth from the texture into the hole size you want
Yeah, but what I'm struggling to get my head around is taking a Color32 (or color) and converting that (I think) into a 0-1 value. Not sure if I'm making sense.
again use a remap function or just do the simple division mentioned above to "normalize" it
the depth would be stored in one of the color channels
Oh wait, as it's greyscale I'd only need to read one of the rgb values and normalise that.
Thank you. Sorry. lol. saying/typing it out loud helps so much. lol.
I'm getting this error when I need to call GameStateManager, I check the hierarchy and for some reason upon loading my project the GameState object (containing the GameStateManager) is being destroyed despite nothing in the code doing that, what could be happening?
show code
all of it? it doesn't specify from where it's coming from
anything that is trying to access GameStateManager
does GameStateManager have any scripts on it?
this is in my title screen's code which is where I get the error, this is all I do to interact with it
you might be able to just put a log inside the OnDestroy and it should show who called it through stack
my object is called GameState and the script is GameStateManager
try this #š»ācode-beginner message
how would I check who called it?
most likely though if you have Level switching, its probably being destroyed for scene change and something else is still trying to access it still
I do have level switching, but it gets destroyed even without me trying it
it's destroyed as soon as I click play
thats how scene switching works
the call stack
I'll be honest I have no idea what that is
the other thing I noticed is that it disappears from my DontDestroyOnLoad in the hierarchy now, when previously it didn't
but src (for sound source) still is there
show more of the setup
just shows who originally calls a method
I have this script attached to both GameState and src
thats why
you literally coded the second object to destroy itself if it has the same script
so src sees that there is another object in DontDestroyOnLoad (which would be gamestate) and deletes it?
I think I get it, I had this script before where src was the only object which had this script
its the second object saying
"Oh there is already an Instance of this class , delete my entire gameobject"
since its the same script and not different class singleton/instance
how should I go about coding it then? my guess is to check for a gameobject of the same name as the one the script is attached to, and only destroy that
got a question that i was looking for some context to.
so i see a simple coroutine but it's using while(true) and i have no idea what is "true" in this context
here's the example code
[SerializeField] private float delay;
private void Start()
{
StartCoroutine(Routine);
}
private IEnumerator Routine()
{
while(true)
{
yield return new WaitForSeconds(delay);
DoSomething();
}
}
can anyone tell me what is "true" in this case? is it the coroutine running or is it the game object being enabled or? im usually specific about these kind of things, but this is the first time i noticed this one, so it's bothering me that i dont know š
true is just true
it's the literal value true
it's simply the value "true", it's a loop that runs forever
yeah but... what is true in this case?
nothing is true
you're asking like if I typed 1 and you said "but what is 1?"
1 is a value
true is a value
while loops run if the condition is true, until it isn't true anymore, it's just like saying "the condition is true, so keep running"
AAH! ok i see. yeah, i just wanted to know what was determining the condition. so i this case, the corutine is running so that's the "true" here.
coding what ?
the DontDestroy script
so that it only destroys duplicates of the game object it's attached to
DontDestroy desnt do anything but not destroy an object and its children through scene changes
it has nothing to do with actually destroying objects
that is your singleton pattern Instance check doing that
the condition is you wrote true. so its always true..
I'm finally understanding why I shouldn't copy code that I don't understand what it does
very true
fixed it now, thanks for the sage advice
ah. ok i think i understand now
not using a variable basically means keep this loop running without any exiting conditions (assuming you don't stop the actual coroutine in this context)
if you used a variable, then you could control how long the loop runs, if it runs at all (condition being false and loop is skipped)
yeah, im just going to put a bool to it. i was hoping i can get by without doing much and giving it a stop function. but i'll just add a bool and a coroutine variable because i need a way to start and stop it
If you have a coroutine variable you don't really need a bool
unless you have more code before/after, and want the while loop to be skipped/done according to a condition
actually, i was just instantiating some sparkles at a frequency and just letting them destroy themself after a duration.
but... now that i think about it... can't i just use the special effects thing(forgot the name of it) to spawn the sprite?
the particle System or VFX Graph
particle system
yeah it pretty much what its for
yeah... i'll use this time to play with it
you can do a lot with it
not the most performant compared to the new VFX graph, but the upside is its simple to use in comparison and can also interact with unity physics colliders
hmm.. well i would like to go after whatever is more performant
so i'll look at the VFX graph and see what that's about
but coroutines are pretty easy to understand though
Its usually a non-issue unless you're spawning literally thousands of effects a second
ah, i dont think i'll have a case where i go near 200
VFX graph is a really good thing to learn regardless
yeah, im going to look and see what it's about
is there a way to like, breakpoint a y position
i have a ui thing thats like moving down very fast and i dont know why
i have no idea whats moving it
start disabling objects / scripts and see which one stops it from doing that
lul
i dont even remember ever adding that
UI should never have colliders or rigidbodies
probably did that on accident
ye i know
that makes no sense
lmao
it had gravity hahaha
nicee
whats this btw
i sometimes get it
no idea what it means
i get it whenever i start the game
check the stack trace maybe?
idk how to see that in unity
select the error it should show you at the bottom
oh
there is nothing more
only the line that shows in the error itself
there isnt like an actual stack trace
could be a bug in some asset or unity itself
i could try restarting unity i guess
thats the first step yes
if it doesnt work you can try deleting library folder and do a full refresh
I think artifact might have something to do with it
Does anyone here make fps games and Iām not asking to make one Iām just asking for help
!ask
:thinking: Asking Questions
:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #šāfind-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.
-# For more posting guidelines, go to #854851968446365696
!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.
a photo of what?
I know how
and code posting guidelines are here: #š»ācode-beginner message
i refuse to even attempt to read your shitty photos of your screen
This isnāt helping so not tryna be a toxic Karen but I will speak to mod for not helping or even trying
oh of course. in that case here's how you can fix it
we've already been over not making "you" problems other people's problems
IM JUST NOT RN CAUSE DISCORD TAKE TO LONG O. THE COMP
don't make it difficult to help you or else nobody will want to help you. i've given you information on how to correctly share your code to follow the guidelines of this server so you should maybe consider following those guidelines if you want help in this server
Bro you can see the words stop lying itās only some pixels and plus your mot even trying to help you can see the words your just choosing not to help
And your being a dick about it
you're absolutely correct that i'm choosing not to help, and that is purely because you refuse to share your code or errors in any form that makes it easy to read. i'm not going to read your shitty phone photos
great, then if you don't intend to share them correctly you can wait for someone who has the patience to deal with reading your shitty photographs
Bro stop being a dick about it I just want help
Iām sorry I donāt have a iPhone 16
And my comp is slow
or you could share the information following the guidelines of this server which have been provided to you and maybe you'll have better luck getting help
I canāt fix that in two secs
Wtv
Your a dick
Anyone please help I canāt send an Ss on computer rn so please understand my circumstances
Click on the photos to see full image
if you cant send a screen shot, why dont you just send the !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.
wait till you learn that before you can even get help here you have to configure your !IDE lmao
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
If you can't even send a code from your computer. How are you manage to make a game on it.
so you didn't even bother reading the information about posting code correclty then if you think screenshots of code are how to share it
!screenshots
No
Be mindful, if someone requests your code as text, don't send a screenshot!
"plz help me with my code you can hardly read in this shit photo"
Provide us with the info in a decent format so we can help you properly
Iām new
ta ta š
I donāt have a good computer
if you send the code AS TEXT i can read it pleasently and even test it out!
I just started
Ion even wanna work on the game anymore
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Gun : MonoBehaviour {
[Header("References")]
[SerializeField] GunData gunData;
float timeSinceLastShot;[]
private void Start()
{
PlayerShoot.shootInput += Shoot;
}
private bool CanShoot() => !gunData.reloading && timeSinceLastShot > 1f / (gunData.fireRate / 60f);
private void Shoot()
{
if (gunData.currentAmmo > 0) {
{
if (CanShoot())
{
if (Physics.Raycast(transform,position, transform.forward, out RaycastHit hitInfo, gunData.maxDistance))
{
Debug.Log(hitInfo.transform.name);
}
gunData.currentAmmo--;
timeSinceLastShot = 0;
OnGunShot();
}
}
}
private void Update(){
timeSinceLastShot += Time.deltaTime
;
throw new NotImplementedException();
}
}
}
Happy
š 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.

JUST COPY THE DAMN TEXT
at this point this has to be a troll..
either way. blocked , Im moving on
goodluck guys
how about instead of throwing a fit like a toddler, you take a step back. calm down. then come back and read the information presented to you so that you can share your code correctly.
I did what yall told me and I was wrong
no you didn't
man if only you had been pointed out how to share code correctly like 5 different times
It just gives a https
Give me a damn minute
A tool for sharing your source code with the world!
this statement cant get any more true by the minute xD
i sure can't wait for them to post code just to not receive help because they don't have a configured IDE

Yes that is a website you could use
Ok
Just making sure
A tool for sharing your source code with the world!
Thatās the code
For my coding app
great, now go configure your !IDE like you've already been told since that is a prerequisite for getting hlep
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

I use VS Code
float timeSinceLastShot;[]

So is there a reason you've literally just told the code to throw an exception in update
huh
that's not even the error they are trying to fix at the moment lol
Yeah the more I look at it the worse it is
oh mb let me send the error
This needs a configured !ide to fix all of the problems
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
If this isn't lit up in red underlines like a christmas tree you need to set up your IDE
Everybody knows your error and how to fix it, just configure the IDE first.
I use VS Code
I use notepad
in that case
#š»ācode-beginner message
We know
follow these instructions to set it up correctly as it should give you help but its not rn:
https://on.unity.com/vscode
configure it using the linked instructions
then look at what's underlined in red and fix it
Iām sorry Iām new and Iām trying my best with tuts
But there is no new tuts
Anymore
the link they sent is literally the tutorial
thats okay but please do as we say and correct your vs code so it can help you out more
How do I whatās the error yall seen
Idk
configure your IDE before receiving help. it is a requirement
I'm starting to think he doing this on purpose yall
It is configured
Iām not
Which means you absolutely, 100%, need to configure your IDE. If you aren't getting autocomplete, syntax highlighting, and error underlining, you will not learn anything
ya think?
Idk
99.9% sure yea
Okay, so what's the first thing in your script that's underlined in red

There aināt nothing spelled wrong? Or is it just code wrong?
What's the first thing in your script that's underlined in red
start there
Ion see nthng
did you follow EVERY step in the set-up guide
Doing it now
š
Then you have not configured your IDE
And it would be best to stop pretending you have
follow the instructions
get the syntax highlighting
I didnāt know
Iām not pretending
Then, and only then, can you solve your problems
look they dont know any better so we had to tell them (but they didnt trust us)
So will it underline wrong code?
YES
Ok
red squiggle like in word or g docs
Nice I used chat gpt but for this code I did it myself
In the past
Before I tried learning
Yeah I didnāt for this one
we all saw the errors in your code cus we have been doing this for years but you will learn that too
we also all rely on our IDE to help us out which is why its good to get it working
Ok question
close vs code then re open it by double clicking a script file in the unity editor. Hopefully this time it opens correctly
In the package manager if it says āUnlockā āRemoveā and on the image it just shows remove do I click āUnlockā
I did it
š„
If your IDE isn't providing autocomplete suggestions or underlining errors in red, then it needs to be configured.
Thanks
Guys itās talking about there not being a net sdk do I install it
If it's not there, but it's talking about it; you prolly need it . . .
Ok
why is this lamp not here
its here in game mode not in scene
collider and everything works
i can touch it
It's probably not in view of the camera
but sprite is not rendering
Or it's behind other stuff
i have it on a higher layer
Check Z
and where must i ask it?
how big of a mistake from me to accidentally ask unity ??? question in the unity CODING channel
i hope the big unity gods out there save my soul
truly i am sorry
my sins shall be never forgotten
i shall bear them and stand strong
thank you mr.PraetorBlue for pointing my sin out
You aren't in trouble or anything
Keeping channels focused on their own topic is for everyones benefit
Hello, I have this script that auto scrolls since im using keyboard to scroll. I dont want the auto scroll to happen on the last button going onto the next off screen but the button before the last one, so it starts auto scrolls on the one before last . Ive been trying for awhile
https://pastecode.io/s/rtt44h96
I been following a tutorial and i noticed the words on my side weren't highlighted in color is that ok or no?
!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
It means your ide isnāt configured, follow the instructions above
That's a very very heavy script to read, it's going to be real tough for anyone to figure out what part deals with what, especially with how unfocused it is
The problem sounds like you just need to ignore the first and last iteration in a for loop
for(int i = 1; i < foo.count - 1; i++) something like this
heyyy guysss i need some simple help so If I wanted to change the position of a game object but didn't know how to get the name in order to change the game objects position what would you tell me
learn how to correctly get a reference to the object instead of relying on its name
oh how do I do that
did you know that blue text indicates a link
For something called a hyperlink, it sure doesn't move around a whole lot
how'd you do that?
it's a markdown link
quite handy
Yes are yiu still here? Like the split model visibly looks split but together like small cracks are visible
Iām (itās almost 4 am here so Iāll go get some sleep now). Generally you would keep two versions of the model, one with only one mesh and the second one made of parts. Only when you want the model to crumble apart/explode/whatever you would switch to the multi part model.
I want to make a bool toggle in editor that will show other variable, ex: "IsCutAble" bool will show things to be filled, like energy needed, cut wood prefab, yield amount etc.
I made one, but essentially unused because i only have 1 processing activity. now that i look into it, search result shows codes using editor or gui but there's none in my script.
you mean something like this?
also, anything that involves the editor typically goes in #āļøāeditor-extensions 
i do remember making it myself with simple lines, perhaps i do use 3rd party tool but not editor extension
but yes i found what i want in the github, ill use it for now. ill stumble upon my own code eventually, it should be here somewhere
If I use GetComponent and there are a bunch of the component I am looking for, it does always return the same one or one random?
It's not a guaranteed thing I don't think?
isn't it the top one first?
oh nvm.
according to a random guy on stack overflow its the top one first
although according to the docs
Note: GetComponent returns only the first matching component found on the GameObject on which it is called, and the order that the components are checked is not defined. Therefore, if there are more than one of the specified type that could match, and you need to find a specific one, you should use Component.GetComponents and check the list of components returned to identify the one you want.
was this advice for me?
I want to do a thing where characters get a typical absorb shield that takes X amount of damage before breaking, but they also can stack. Like... shield 1 for 100 for 5 secs and then shield 2 for 150 for 3 secs for example. These are managed by a status effect script that attaches to the object for each shield and basically says "while this is on the char it has +X shield, when expires, remove -X from shield if possible and remove this script". So I have to have a reference to who casted the shield (to attribute to them the damage mitigation) and when the shield takes damage I have to know which one did (which I think should be either the top one or the one with less time remaining, not sure) so I don't remove shield value comming from another shield
Use an actual Stack. Don't rely on the hierarchy in Unity
Or List or whatever
I could have a List of all current shield type scripts on the target on the health manager, yeah
And whenever the shield takes damage attribute that damage to whichever shield on the list has the less time reamaining, I think it makes sense
Maybe even better use a Dictionary
Is this gonna do the thing that I expect it to do or did I mess it up?
I am not quite sure I understood the example and it's kinda messy to check for myself
You can a small script to check if it works . . .
- create a MonoBehaviour script
- create a c# class with a
Durationfield (on the same script) - add a list of the c# class to the MonoBehaviour script
- add a
CompareTomethod to the c# class (this will compare the duration) - implement
IComparable<InsertClassName>on c# class - from the inspector (of the MonoBehaviour script), add 3-4 items (instances) to the list
- set random duration for each instance: 1, 2, 3, 4 (out of order)
- call
List.SortinStartof MonoBehaviour script - check the list from the inspector to see if the order correctly changed
anyone here familiar with gm2 and unity? I need to transform a gms2 script to c#
It's all there in steps. you can search it to see an example of what to do . . .
Which part are yuo stuck on?
Why even add the IComparable? Isn't that basically creating 4 objects with a test script and see if they get ordered right with that?
No, instead of creating a custom sort delegate (like your image above), you create a CompareTo method inside the class you want to sort . . .
It's easier to have your compare (Sort) method in the class in case it changes and to have more control over it . . .
It looks to me like Daleo wants to pick 1 item that has the less of x. Seems like you don't need to sort the list, instead use Where() to locate the correct one
Unless there's a meaning to actually sorting the list
They want to order the list from least to greatest . . .
Just show me what you have so far (from the steps I listed above) . . .
Give me a sec, I am setting some other thing
I need a way to add an objects vector3 position to a list/array when it is created, then after it moves somewhere else and is destroyed, that specific vector3 value is removed from the list/array. Basically I don't want a new object being spawned in the same spot as another object has until that first object is destroyed.
When the object is instantiated, add its position to the list. When it is destroyed, remove it from the list. The script that manages the object instantiation can have access to this list or use events to add/remove position when created and destroyed . . .
so I have a general "enemy" script attached to every enemy object that is instantiated, how do I keep track of which specific spawn position is tied to which specific instantiated enemy object since the enemies current position when destroyed will be different
Why donāt you just make the spawn position into a member variable of the enemy then? And add each enemy to a list on instantiation. When instantiating a new enemy, it first checks the active enemiesā āSpawn Positionā property and is prohibited from spawning at the same position as one held by an existing enemy
Otherwise you could use a dictionary to have a key/value pair (enemy, spawn position), or create a custom struct or class to wrap the two together.
Or use tuples
In any case, you either make the spawn position a member variable or you couple it together in some sort of other wrapper.
Member variable would probably be easiest, because then you can have the enemy register itself (and its spawn position) either to a static dictionary or to some other mediator class, and then also unregister itself.
for some reason when i go to right click it only works with E but i dont see anyway to fix https://pastebin.com/AzsFmiit
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
When you say "member variable" do you just mean a general variable declared outside of a function? How would I store each instantiated enemies vector3 coordinates if its not an array/list?
i'm having a small problem with entity spawning
i have an entity prefab and i Instantiate it in this way
but i get an expected behavior which the new entity appears at the location specified in the prefab before it transports to the new location i set down there
i expected this but have no idea how to fix it now
` Entity newUnit = state.EntityManager.Instantiate(currentItem.UnitPrefab);
RefRW<GameEntity> gameEntity = SystemAPI.GetComponentRW<GameEntity>(newUnit);
gameEntity.ValueRW.Team = factoryGameEntity.ValueRO.Team;
gameEntity.ValueRW.Owner = factoryGameEntity.ValueRO.Owner;
var position = factoryData.ValueRO.UnitSpawnPositionTransform;
state.EntityManager.SetComponentData(
newUnit,
LocalTransform.FromPosition(
localTransform.ValueRO.TransformPoint(position)));`
i tried changing the prefab's LocalTransform to the new location before Instantiating it using SystemAPI and state.EntityManager
i also tried using a command buffer and using playback but it still the same problem
SystemAPI.GetComponentRW<LocalTransform>(currentItem.UnitPrefab).ValueRW = LocalTransform.FromPosition( localTransform.ValueRO.TransformPoint(factoryData.ValueRO.UnitSpawnPositionTransform));
is it possible to move your camera (not the POV in the game) to a object?
Wdym by "not the POV"?
Huh? Can you clarify? Do you mean how to move the actual camera position or what the camera is pointing at?
I mean the camera that is used to edit the game, like this one
Is this ECS related? Maybe ask in #1062393052863414313 then.
Press F when selected?
thx
Im having an issue with my movement system, I created a public float for the speed, but in the void update parameter it says its doesn't exist
!code !screenshots typo
š 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.
guh, never get this command right
Thanks
Thanks so much, didn't realise there was a typo and spent 20 minutes trying to fix it
its a very common error lol
if you get that error, make sure to double check your spelling
Will do thanks again