#💻┃code-beginner
1 messages · Page 9 of 1
okay and is the enemy object's collider a trigger collider?
the enemies have thier own layer called "enemy"
the enemy itself is, yeah but not the "groundCheck" child object
and what layer is the groundCheck object on?
and those layers can collide in the Physics2D settings?
I thought it would have, how would I check? its falling through the platforms so possibly not? it's got a dynamic rigidbody 2d
in the Physics2D settings
everythings on by default
then there's some information that you aren't providing 🤷♂️
your mail slot screenshots where we only see very specific info aren't really providing all of the necessary context
i'm happy to share more, just not sure what else I can share?
show the entire setup. full inspector/hierarchy
ok i've figured it out, the Box Collider 2D, has the "is trigger" ticked. when i untick it, it doesnt fall through
but i'd like to use that box collider as a trigger for combat actions, eg when the player character melee attacks the enemy
well by the sound of it, your ground check collider isn't actually a child of the rigidbody2d
which is why i wanted to see more of the setup
I can send you a full screenshot if thats what you're after?
yes, that's what boxfriend is after.
and the GroundCheck object
A trigger collider overlapping a non-trigger collider can produce trigger messages.
enemy only has a single, box collider 2d on it though?
it doesn't have a collider. so it's no wonder it isn't acting as a solid collider for collisions. the way you described it before you made it seem like it had a non-trigger collider
so the ground check needs its own box collider?
if you intend for that to be how it collides with the ground, yes. otherwise you need to make the enemy's collider not a trigger
currently, the GroundCheck game object does absolutely nothing
the rigidbody needs at least one non-trigger collider in order to be able to actually collide with stuff
I see. on my player character the box collider has no "is trigger" and the respective players "groundcheck" is also empty, as it was for the enemy
right so that player's own collider is the non-trigger collider used for collisions
ok brilliant, thank you, thats fixed the problem. I thought I was being dense
the thing is, I'm not sure what to use here. if I do col.Lerp(x,y, currentHeat), it won't lerp in relation to the current float/heat value. i.e if the max value of heat can be 10, then at 5 it should be a colour between white and red.
I'm coming back to a Unity 2D Platformer project I had to stop working on in May. When I left it, I had some very annoying trouble dropping down through platforms with the character. I'm still having those problems, and I can't work out what's going on with it. Can anybody help? I'm happy to send you the entire project, if that would be best. https://forum.unity.com/threads/why-is-my-2d-character-getting-pushed-down-0-544207-in-y-when-uncrouching-below-a-passable-platform.1439920/
Huh
read it
holy cow the formatting in that code is something else. but it seems like the issue is just that the rigidbody is depenetrating from the colliders it overlaps when it "stands up". which is kind of expected behavior with rigidbodies
I for some reason am able to double jump infinitly
and don't dont how to fix it
looked it up andf everything
Yeah, that's somewhat aligned with what I was thinking, but I'm really not sure where to go from here. I spent forever trying to solve the issue in May, and I'm still confused now. =/ Rrrgh.
you're not doing any sort of ground checking and you aren't even moving in a physics friendly way either
My bad wrong script
!code
📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.
Btw,
holy cow the formatting in that code is something else
Is that good or bad? =)
not good lol
Righto. I'm self-taught, so I'll take whatever advice you can give.
As I say, I'm happy to provide the project to anyone who can help. I'm reasonably experienced, I thought, but this has confuzzled me almost totally.
try to watch a vid https://www.youtube.com/watch?v=CFRhGnuXG-4 on how to solve all that nesting bro u gonna spend way too much time on any bugs with that 
lmao accident 
What's the nesting you have an issue with? The deepest if level I have is 4. I'll take a look at the video, but I'm unsure how else I'd handle this specific situation.
getting a strange math issue, not sure of the right term but im making an equation to "cyclically clamp" a number between 0 and 2, where once it gets past 2, instead of clamping to 2, it 'cycles' back to 0, and when it goes to -1, it cycles back to 2, my equation ends up being num % 3, which does exactly as described on a calculator, however it seems to calculate -1 % 3 as -1 instead of 2
Can anybody help me track down my issue with dropping down through the 'thin' floors?
So, I've watched this video, and I'm aligned with most of the values expressed within. I'm doing a 4-if nest for a specific, considered purpose, so that's in line with those guidelines.
ill refactor one method of urs into what I mean
That's kind of you, I appreciate it.
Ayoo guys!! I wanna make my own realistic arcade car system in Unity, but I have a question, do I need to rig the car to make the car?
Im beginner on Unity
You'll need to rig it, but mostly within Unity. There's probably a good simple car tutorial in Unity - I'll have a look...
In Unity? I thought I had to do the rig in Blender, I saw this in a car tutorial when I was trying to do it in Unreal
you can just add 3 if the result is negative after the % operator, in c# its a remainder operator not mod so its not guaranteed to be posiitve
Yikes. One sec!
Crikey, why didn't that URL work first time? Anyhow. Yeah, you'll do most of your rigging in Blender, then trigger those animations in Unity. However, in getting the car moving, you'll want to setup wheel colliders etc. in Unity - and it may be easier to setup wheel turning etc. in Unity.
But load up the Unity Learn project and poke around with how the car is setup - that's a good starting point.
Again, if anybody can help fix the platforming in my project, I'd be very appreciative!
https://hatebin.com/eqbcoywibq couldnt get that much juice out of it tbh but im sure someone can improve it further
I split ur methods into 3 according to velocity with self explaining names u dont need comments for them now, way nicer to collapse whole method as well got rid of few else with guard clauses etc and if you keep adding functionality u wont end up with gigachad super method
how do you go about adding a custom extension/button to a pre-existing tool like transform? I want to create a "reset position/rotation/scale" type button using custom code
This option is already available from the menu top-right
Write a custom inspector for the Transform type
But yes, it is
I appreciate your efforts, but as you say, not much more juice there. I think I'll focus on trying to solve my platforming issues before going back and cleaning up my code.
I think if you looked at my project, you'd approve of at least 90% of what I have there. Cheers, though!
what is the default transform api? looks like its exposed now but i dont want it to look like that. im just trying to tack on a custom button
when im holding an ak for example, and i switch to another slot with an ak, it doesnt switch to the other one
https://hastebin.skyra.pw/binefajevi.csharp
its line 83 im pretty sure
else if(currentItem != itemsDictionary[selectedCell.item.itemData])
u can see when i equip the first ak which only has 10 ammo, and then straight away switch to an ak with 30 ammo
the Switch method doesnt get called
this works
i have an array that goes from 0 to 19 and im using this to pull from it and got an out of index error, did i miss something cuz im feeling kinda sick and i might just be making basic mistakes
here is the full code https://gdl.space/ugaxawovuk.cpp
If you want to roll a random index in a collection, use that collections size instead of a hard coded outer bound
would 0, 20 not achieve the same result?
That is why int randoms are max exclusive, solely so you can plug the length directly into that second parameter
Er, better yet, how can I get "this.transform" from the editor extension?
if (GUILayout.Button("Reset All"))
{
//// stuff here
}
unsure on how to access transform/rotation/scale
Only if your list has exactly 20 things in it
can someone help me, i have a sprite for a wood plank (2d game), and i want to resize it to be the floor of my game, however i dont want to stretch it out, i want to repeat it until its the correct size, the first image is the one that i want to change to be repeated to make it look like the second image
Okay that shows that you have at least one list with 20 things in it, but nothing shows that this is the list you're getting the error on
its the only list, the error was for line 49 from the code i sent
Have you tried logging the length of the list before you access it
so this
plrease help 🥺
how would i go about doing that?
Log the length of the array the line before the error
im pasting like an idiot, the line within the ChangeSprite()
wouldn't the length of the array be 100% 20 if its public in the script and 20 in the inspector tho?
Stop guessing and log it
there is a chance that the roll++; line might somehow be messing with it
idk how to log it
Debug log should literally have been the first line of code you ever wrote in unity
i know how to do Debug.Log but idk how to apply it the way you want me to
Debug.Log(arr.Length); shh dont tell I told
Log the length of the array
Put the length inside the log
Don't suppose you have any ideas based on this? I meant to follow your point up earlier, but I got a little side-tracked.
Okay, now try logging roll as well
roll already getting logged, it is 1 lower than the number on the dice (since the 1 dice is 0 in the array) so i did roll++ after the array code
but there is a chance i missed something where it goes out of index after a few tries
So, log roll before you use it
before the error
roll is greater than the length of the list, which is your error
the list's length seems correct
so now check what roll is when it errors
guessing i change the random range to like 18, 20 so i can actually test for the error
since the error seems to happen when you roll above the index
otherwise id be here all day
also i got this and i forgot how to turn it off
whats the keybind again?
insert
thank you
yeah idk the error doesn't seem to happen
even after rolling 2 20s in a row
code got scared of debugging
ahh i recreated it
seems to happen when i spam click the dice
so its something to do with the coroutines prob
So, is that logging the value of roll inside of the function throwing the error?
i dont deactivate the dice
If so, then a value of 20 is too high
The list has 20 elements in it, meaning 19 is the highest value
yeah but Random.Range is maxExclusive no?
Yes but you aren't using the result of the range are you, you're adding one to it
ohhh i get what youre saying now
i mean normally i use the result of the roll and then after it was used i add 1 to it
but i think i forgot to disable the dice after it starts rolling
therefore if you spam it, it keeps doing roll++
Sorry to repeat this issue, but I really am bamboozled by it...
I'm coming back to a Unity 2D Platformer project I had to stop working on in May. When I left it, I had some very annoying trouble dropping down through platforms with the character. I'm still having those problems, and I can't work out what's going on with it. Can anybody help? I'm happy to send you the entire project, if that would be best. https://forum.unity.com/threads/why-is-my-2d-character-getting-pushed-down-0-544207-in-y-when-uncrouching-below-a-passable-platform.1439920/
!vs
If your IDE is not underlining errors in red or autocompleting code,
please configure it using the link below:
• Visual Studio (Installed via Unity Hub)
• Visual Studio (Installed manually)
the docs should contain everything basic right? like movement and hitboxes?
The docs contain information for all aspects of Unity. It doesn't cover how to make a game.
ah
they do cover things you can use for movement (rigidbody, character controller) and hitboxes (rigidbody again, colliders)
@lone mist If you're looking for good guides on how to make basic games with Unity, consider checking the Unity resource: https://learn.unity.com/
indeed
thanks
guh
maybe someone knows whats up with this I cant rename classes it goes right back to what it was
actually tested with 2 random other classes just in case im being oblivious about something again and got one to rename but changing it back is yet again impossible lol
I think thats because it connects to what you named the script in unity
maybe changing it in unity first
yea that solved thanks now that I look at the class which renamed itself the way I tried its name changed in editor as well
no consistency?! 
That's not how this server works
You can show your attempts and get assistance for issues.
we don't hand out code but can help with any issues or errors you have in yours. send your !code (attempts) when available . . .
📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.
how can I get all the children of a gameobject as a list?
You can iterate over a Transform's children
foreach (Transform child in someTransform)
it's a little awkward because it's not an IEnumerable<Transform> -- just IEnumerable -- so I don't think you could easily do
new List<Transform>(someTransform);
ah okay thank you
hence why you can't do foreach (var child in someTransform)
you'll just get objects
(which you could cast to Transform, sure, but it's annoying)
smells like very very old engine code :p
So im trying to learn Unity for the first time (I know what a time to start) and I've started with a kind of flappy bird clone, but right now I have a trigger to increase my score when I go through the pipes but I gave my Player entity two Box Colliders so the trigger is going off twice, what would be the best way to fix this and avoid it in the future?
I would add a component to the game object with the score collider on it
can I assume all awakes on prefab are already ran just below instantiate line or it happens sometime later
That component would have a bool. It would be set to true when you hit the zone
Every Awake message will be sent before the Instantiate call returns
nice ty
so, maybe, in the OnTriggerEnter method on your ship:
void OnTriggerEnter2D(Collider other) {
var zone = other.GetComponent<ScoreZone>();
if (zone && !zone.hit)
{
zone.hit = true;
// add a point
}
}
where ScoreZone is a really tiny monobehaviour
public class ScoreZone : MonoBehaviour {
public bool hit = false;
}
If the score code is on the pipes, not the player, it'd be even simpler
you'd just add that "hit" field to the component that gives you a point
and only give a point if it hasn't been set to true yet
@swift crag I have the trigger in the prefab with the "pipe" colliders. My problem is it registers both of my players colliders but I only want it to register them as one
Okay, so "Middle Script" is what gives you a point?
yeah
add a bool field to that component, so that it can remember if it has touched the player yet
when you give the player a point, set it to true (and skip the points entirely if it's already been set)
(by "field" I mean a variable that is in the definition of the class, like this, in case you haven't seen that term yet)
logic in your "Middle Script" component is a field
like this?
Yep.
So, right now, you unconditionally run Logic.addScore() in the trigger enter method
You want to make it so that you only do that if hit is false
Hey, I have two 3d objects (flattened cubes) that are on the same Layer (SliceLayer), and I have changed the Physics so they cannot collide with each other in the Project settings.
So now I can lay these two 3d objects ontop of each other in the game, but there is a Z layer fighting going on. Is there a way to have 2 3d objects ontop/inside each other and then still show one instead of having Z fight?
simplest thing to do is to give one a tiny position offset
I think you could also write a custom shader that adds a bit of offset
...but that sounds like a pain in the ass
sorry im very new to this how would you type that out? if hit = false Logic.addScore(); or something?
Have you written any if statements yet?
oh, I missed the "if" in there
yeah, that's the idea
if (!hit) {
// do stuff
}
you can just use ! to negate it
instead of doing if (hit == false)
so like that then?
Close, but you're missing something to set hit to be true afterwards
otherwise, hit is going to stay false every time you enter the trigger collider
You could put that in the if statement, or just do it separately. same outcome.
(just don't do it before the if statement, of course, or it'll never succeed)
Anyone know of any good ways to graph a animation curve in UI? I just need to copy it over into a UI form to act like a car dyno sheet
hm, not sure how I'd draw a nice smooth curve
the first thing that came to mind was to just sample a bunch of points and draw dots on a texture
Yea, I watched the code monkey line graph thing and just figured I’d spam points from the curve with a for loop lol
i think that's how a TI-84 does it
any help?
sorry again but how do you change the false to true? Ive never really done if statements before
this has nothing to do with the if statement
just set hit = true;
That will work.
This will:
- If
hitis false, callLogic.addScore(); - Set
hitto true
you could also do
if (!hit) {
Logic.addScore();
hit = true;
}
This will behave the same (it just avoids setting hit to true more than once)
Doesn't matter at all.
okay thank you I think I understand how that works logically
hey, what's a good way to set the collider to the raycasts hit distance?
I want the box collider to rescale itself from the rays root, out to the current hit point. though it seems like the debugger ray isnt stopping on contact with objects
IEnumerator LaserStream()
{
while (isSpinning)
{
Ray rayLaser = new Ray(offset.position, transform.forward * rayDist);
if (Physics.Raycast(rayLaser, out hit, rayDist, layerMask))
{
}
colliderZ = rayDist;
colliderVolume.size = new Vector3(colliderX, colliderY, colliderZ);
colliderVolume.center = new Vector3(0, offset.position.y, rayDist / 2);
Debug.DrawRay(offset.position, transform.forward * rayDist, Color.blue);
yield return new WaitForSeconds(.15f);
}
}
DrawRay just draws a line
in my current example, itll draw it out based on the ray, but the ray itself isnt resizing on contact. does debug ray resize automaticaly?
it doesn't do any physics
is there a way to make the box resize on hit? Like say the laser hits a rock in front of the player, the collider should stop at that point, not pass through
when I do it like that I get a red ~ why does it do that/ do I need to worry about that?
Yes, that is an error.
Notice that you added an opening {, but have no corresponding closing }
This will cause an error as soon as the lexer (which chops your source code up into pieces the compiler can understand) finds something that doesn't make sense
like have the ray stop here, then pass that info the collider and divide it by 2 for the center
Where that actually is can vary.
this really confuses the compiler
notice how the error squiggles show up...earlier
in this case, it's because the missing } makes everything part of the What function
and then, at the very end, we get an error because we hit the end of the file without closing all of the curly braces
hence...
oh okay I had to add one } for the void trigger and then another for the public bool. I see how that works
that works wonderflully thank you so much
Right. Every opening { must be balanced by a closing }
The outer pair opens and closes the class definition. The inner pair opens and closes the method definiton.
And then the innermost pair is just a "block statement"
{
statement1
statement2
statement3
}
my math isn't too great but something to do with hit distance. trying to figure out "From origin, to hit distance". I imagine the offset -> hit distance = the length of the ray
Ray rayLaser = new Ray(offset.position, transform.forward * rayDist);
if (Physics.Raycast(rayLaser, out hit, rayDist, layerMask))
{
}
var hitDist = hit.distance - offset.position.x;
colliderVolume.size = new Vector3(colliderX, colliderY, hitDist);
colliderVolume.center = new Vector3(0, offset.position.y, hitDist / 2);
Debug.DrawRay(offset.position, transform.forward * rayDist, Color.blue);
yield return new WaitForSeconds(.15f);
}
Thanks, will look into it!
note that messing with sorting priority won't help -- that just changes the order that materials are rendering in
one already renders before the other; it's the z-fighting that's the problem
One option IS to make both materials Transparent, rather than Opaque.
how can I get the text data of a txt file hosted on github
Whichever one gets drawn second will completely clobber the first one
getting some XY Problem vibes here
what are you trying to do
Transparent shaders don't affect the depth buffer, so you can't possible get Z-fighting
well im trying to make a ui list that has content based off the github text. if that makes sense
for a message-of-the-day, or something similar?
something that you have to go on the internet to retrieve every time you use it
aye figured it out i believe. unless ya'll got a better suggestion for "resize box collider to raycast length"
IEnumerator LaserStream()
{
while (isSpinning)
{
Ray rayLaser = new Ray(offset.position, transform.forward * rayDist);
Physics.Raycast(rayLaser, out hit, rayDist, layerMask);
var hitDist = hit.distance;
if (hit.distance <= 0)
hitDist = rayDist;
colliderVolume.size = new Vector3(colliderX, colliderY, hitDist);
colliderVolume.center = new Vector3(0, offset.position.y, hitDist / 2);
Debug.DrawRay(offset.position, transform.forward * rayDist, Color.blue);
yield return null;
}
}
kinda. itll show ios shortcuts and it will take the name, description, link etc
the data will be like this
name
description
link
version
icon (base64)
name
description
link
version
icon (base64)
etc...
i also want to split them by each 5 lines so I can each piece of data per shortcut
@swift crag any updates?
you can use https://docs.unity3d.com/Manual/UnityWebRequest.html to fetch data
i would suggest just storing your data as JSON and then using something like Json.NET to deserialize it
alright thanks
how would i carry over variables between scenes?
i have a game manager in one scene (where you choose your stats) and a game manager with the same script attached in the next scene where I would want to keep storing those stats so that I can use them within the actual game
you can put it in DontDestroyOnLoad (DDOL)
the object that has the script
how would i do that?
DontDestroyOnLoad(gameObject);
https://docs.unity3d.com/ScriptReference/Object.DontDestroyOnLoad.html
why is this guy not showing up
so like this on the script?
Are you instantiating it? Show the code
If it's supposed to be in the scene, show its inspector
Don't need this, but yes
i was actually going to ask what "this" is for cuz i know gameObject refers to the object thats holding the script right?
Refers to the instance of the script, and yes
i see, thank you 🙂
ah and now that i did this will i be able to call onto that original game manager, so i dont need a second one in the next scene right?
why is my little guy not showing up 😭 can anyone help me?
Sorry if this is a simple fix but my code for my character to jump up with the spacebar won't work. What is the problem?
is coding the same for a vr project and a 3D project
i havent coded anything im just setting things up
Set the z to 0
2d in unity is 3d still. Z is just used more like "distance from camera" in unity 2d
Guys, how can I rig a car? I intend to create my own car system, would it be possible for me to invent my own car rig?
is there a system in unity for missions for your game
like kill [bad guy] and steal [key] to open [the big bad mafia room]
Possible, yes. How to do it, i dunno
Not afaik. It's entirely up to you to create. May be an asset for that though.
Perfect, ty!!
I see this:
https://assetstore.unity.com/packages/templates/systems/mission-system-135406
Edit: hmmm, don't think that's what you're looking for actually
if I buy this can you explain how this will work dose it like teach me how to add missions or will add a system for me?
Usually assets have instructions. I dunno how it works or how to implement it
And it looks real weak.
Here is perhaps a better one:
https://assetstore.unity.com/packages/tools/game-toolkits/quick-simple-missions-75462
But generally, these assets are still just a framework, you will need to implement them and tie them in with the rest of your game. Gonna have to write some code somewhere, and it won't add the system for you
I've been following a yt video on a working survival system for a hunger system but I cant get the food eating function to work... Please help
For one, it looks like your !ide isn't configured
Also, can you show the SurvivalHunger script?
Last, what are _hungerToReplenish and _thirstToReplenish set to?
If your IDE is not autocompleting code
or underlining errors, please configure it:
• Visual Studio (Installed via Unity Hub)
• Visual Studio (Installed manually)
• VS Code*
• JetBrains Rider
• Other/None
*VS Code's debugger plugin is unsupported.
We recommend using VS or Rider instead.
I would put some Debug.Log calls into the OnTriggerEnter too, to see if it's getting past the if conditions
Hello I'm a super beginners
and im wondering why my script isnt working when i folllowed the the tutorial to a tea.
Did i do something wrong in my unity
Or did I do something wrong in my visual studio
How do I do that? I'm very new still..
Is there a reason you are in debug mode?
Look at the docs for it, there are good examples
https://docs.unity3d.com/ScriptReference/Debug.Log.html
just wanted to see if could clue me into why its not working
You'll need to provide more details, if you need help. Start from explaining what you mean by "not working".
but i dont see the error
i thought it would show at the bottom
help, the tutorial im following for sprites shows the lines of code colored but mine dont, what am i doing wrong?
where can I detect the error>?
!ide @vague sage , look at the bot too
If your IDE is not autocompleting code
or underlining errors, please configure it:
• Visual Studio (Installed via Unity Hub)
• Visual Studio (Installed manually)
• VS Code*
• JetBrains Rider
• Other/None
*VS Code's debugger plugin is unsupported.
We recommend using VS or Rider instead.
Open the console tab. That's where the errors should be.
thank you it solved it 🙏
this?
oh
wait one second
Are you using vs code? Because that is for vs code. But yes that would be it
I am
also your thing didnt work
or i cant see Preferences when I open edit
What did you do exactly. You got that extension, and what else
i dont have the extension
should i get it?
Did you... read the bot? Yes of course you need it
Preferences you want is in UNITY not vs code
To see the errors in the ide
this makes no sense to me
im struggling with figuring out how to grab values from a script thats DDOL'd but in a different scene as it isnt letting me assign it in inspector
could someone help me out please
VehicleController
You write Debug.Log("found player"); after the first check or something
What doesn't make sense?
@summer stump
ok the collider is working It says found player when I walk into the sphere collider
Ok, do something similar with the next check
Ok so It didn't show up when I moved it here
That dotnet error worries me. The unity extension should have installed any dependencies you needed..
But yeah you can code whenever. Do you have any compiler errors?
not at the moemnt.
Does the player HAVE the SurvivalManager attached?
Ok perfect!
game runs
yeah
time to put the cod ein and see if it will finally move
It could be that my refrence is my PlayerCam and no the PlayerObj
Where did you put the debug the first time? It passed the tag check, right?
yeah
and the second line
I feel like the player input should be the player object not the playercam
but it wont let me put any other item in the slot
Ok... try doing this:
Replace the getcomponent line and null check with this line:
if (!other.gameObject.TryGetComponent(out SurvivalManager survivalManager)) return;
The reference thing shouldn't affect this at all
Dunno if you even need to go through gameObject actually
Ok, that was just a check. I thought there was something weird with is null but I can't remember what exactly
Wait.. THIS
#💻┃code-beginner message
Object has a collider, right?
ok so im following a tutorial but idk what im doing
im just copying and pasting
but i really want to know what im copying and pasting
do i look up that in unity docs??
Type. Not copy paste. And google. Yes look up things
i google each thing or the entire code?
i have no idea what im doing
Things you don't understand
how would you even google the entire code?
i dont know 😭
im just confused 😭
If you don't understand any of it, it's time to go learn the C# basics.
where do i learn that
anywhere. have you heard of or tried google?
I added a collider and I started flying lmaooo
Hello, im new to unity and coding (Besides Lua) in general, May I ask what language unity uses?
Collisions messages (like OnTriggerEnter) require a collider 🤷♂️
C#
Thank you!
WHY AM I FLYING
unity confuses me
What does that mean?
Is your rigidbody dynamic or kinematic? And how do you move?
very long tutorial on an fps character
rigidbody is not kinematic
Ok im stupid asf I fixed the flying thing
Is this to ambitious for a first game?
Horror game!
2D
Story:
A man wonders into a hotel and finds its been taken over by zombies, with the exit locked from the outside by a mysterious force/person, with the FBI on its way to land on its roof he needs to find a way up and out.
Main Character:
David Lemmings
Hotel:
Hotel Cliton
What i will learn:
Coding, bug fixes, level design, dialouge, basic music making, basic movement, basic teleport points.
idk man, i struggle to create space invaders
that might just be a skill issue
Anything other than roll-a-ball or something is too ambitious for a first game imo
First game should be about learning the api
hard to tell. this can have simple to advanced mechanics. start with simple clone games: flappy bird, space invaders, galaga, asteroid, brick breaker, single 2d mario/side-scroller level . . .
@summer stump I added the collider and still nothing...
yes i will most likely be doing this before starting on it just so i can get a feel for coding and such, also side note i believe this should be a 10 to 15 minute game (Playthrough) .
Show the current inspector
It does't have the survival script on it
Not a rigidbody?
Wait what?
You added it to the camera?
The collider isn't on the right object
I have my collider on a child od the player
The collider HAS to be on the same object as the script. Not a parent or child
ahhhh
I mean, I guess you can get it from the parent of the transform... but why?
Is this a brackey's tutorial? Why is the sensitivity so high on that camera? You aren't multiplying mouse input by deltaTime are you?
FIRST PERSON MOVEMENT in 10 MINUTES - Unity Tutorial
In this video I'm going to show you how to code full first person rigidbody movement. You can use this character controller as final movement for your game or build things like dashing, wallrunning or sliding on top of it.
If this tutorial has helped you in any way, I would really appreciate...
this ^
Its a bit odd how he did it all but its working so idkk
The name ive came up with is "Hotel Zombie"
its a variation of his tutorial.. even has the same mouse input * with deltaTime issue afaik
Ah, yeah I think I saw that tutorial before actually, and thought "hmmmm, that DOES look awfully familiar" haha
Well its working now so ty so much I spent like 5 hours trying to figure it out already
No prob! Glad it's working
Since I can't reference a scene object in my prefab, I'm trying to reference it once the prefab clone enters the scene. So how can I set the object and function of this unity event from a script?
doesn't anyone know how to make the fire effect like in the gmod explosive barrels? Here is the code that does not work for me, everything related to the bool isInFire private void Start() { isInFire = false; random = Random.RandomRange(minimunHitsToDestroy, maximalHitsToDestroy); rb = GetComponent<Rigidbody>(); } void Update() { if (hitsReceived >= random) { Instantiate(explosionParticlesPrefab, gameObject.transform.position, Quaternion.identity); Destroy(gameObject); Vector3 position = gameObject.transform.position; Quaternion rotation = gameObject.transform.rotation; GameObject sherds = Instantiate(toiletSherds, position, rotation); } if (isInFire && particleInstance == null) { particleInstance = Instantiate(fireParticles, transform.position, Quaternion.identity, transform); var v = particleInstance.GetComponent<DestroyInRandomTime>(); if (!v.isActiveAndEnabled) { hitsReceived = maximalHitsToDestroy; } } }
can you format or use !code to post a link. will be much easier to read and/or copy/paste . . .
📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.
also, what exactly does not work and can you describe how the gmod explosive barrels are supposed to act?
can someone explain to me what this means? For some reference I had a trigger that increased my score when I went through it but now it doesn't and I get this, not sure what I did 
well its refering to this but im really not sure what I did or how to fix it?
Show the inspector. Is the scoreText actually in the field?
Because that is the only thing that could be null on that line (and int cannot be, it just defaults to 0)
Make sure the script isnt on another GO as well because if it is it could have a NRE
the inspector for the UI score or the trigger?
Also im not sure what GO or NRE is ive only just started a few hours ago sorry.
The one with the script you just showed (which you should not call Script... but that isn't important now)
I think this (I know Script is a bad Script name but it was making issues to change it)
You see how it says none on text
Ur not refering to anything so the Compiler says (Null: Meaning nothing ) Reference Exception
U just need to fill in the Text field
https://unity.huh.how/programming/references
This is a good site for understanding references. You are wanting a serialized reference.
Simply drag the object with the text on it into that box
Use [SerializeField] for something if no other code is referencing it
Nah, we all start somewhere
If u want something to just show in the Inspector use [SerializeField] theres no reason to make something public if you just want to modify the value from the inspector
just SerializedField or SerializedField void?
To make all of them public yes
I know ur still new
So alot of this might go over ur head and thats fine (not trying to be rude)
if a barrel explode next to another the other sets on fire (and later explodes) but if the barrel is already on fire its explodes directly
But unless another Script/ Class is reading or writing to the values of that script then dont make it public
srry for late response
You could have another class accidently modify the fields of that script if its public
Yeah ofc brother
Its better to have everything private by default
This is common practice btw 🙂
I did see private void instead of public how is private and SerializedField different?
Void is a return type and not relevant to variables
Methods can return something, or nothing (void)
Yeah That method should be private
But i think ur confused lol
Void is a return type
so why SerializedField over private
Private public are access modifiers
It is WITH private, not instead of
U dont do [SerializeField] on methods
If you don't see the public or protected then it's implied private. Accessors are required for members of a class.
But variables DEFAULT to private, so if you don't specify, it is private
You do that on fields / properties
oh okay
Ok so remember how private means nothing else can see it?
so different tools for different tasks basicly (im sure those are bad words to use as an exaple)
That means even Unity cant see it. (This isnt entirely true but...)
So u want a way for unity TO see it.
"[SerializeField]" Does that for u without having to make it to where anyone can modify the fields / properties
I think I understand? Im sure it'll bite my butt one day and then ill understand fully
Like i said ur still new
So most of it will go over ur head but as long ur doing research and actually trying like u are! You'll do great!
Ive mostly been fallowing YouTube and step by step guides but If I wanna branch out a little wheres the best place to get general guides or a place to learn what the code means so I can kinda "kit bash" things together. I hope that makes sense sorry if it doesn't im pretty tired and just wanted to finish this project before I pass out
Yeah best practices arent learned overnight. So give urself time to understand the concepts. Ur doing really good so far tho
Thanks man. and thanks for the help, im sure ill darken your doorstep some other time but only time will tell.
when a barrel explodes, have it check for other barrels within range and raise an event or call a method. that method (on the barrel) will check if it's on fire and act accordingly: explode, or set itself on fire . . .
Yeah 😭
can I use lerp in order to change my rigidbody's velocity? i want it to de-accelerate until it reaches 0 within a timeframe
Sure.
I have a gameobject with script and collider. How do I get Collider component using the script? The collider could be anything. It could be sphere, it could be box, but there will always only one.
GetComponent<Collider>() or GetComponent<Collider2D>()
oh this works! thank you.
How to make a joystick?
I want to make the R joystick move the character and the other L joystick move the camera
is FixedUpdate completely independant from FPS? like, even if I have 30 fps, fixedupdate will always be 50?
yes
Yeah it will do multiple FixedUpdate's in a frame then to catch up. Which can also cause the FPS to drop lower again.
https://docs.unity3d.com/ScriptReference/MonoBehaviour.FixedUpdate.html
If the application runs at 25 frames per second (fps), Unity calls it approximately twice per frame, Alternatively, 100 fps causes approximately two rendering frames with one FixedUpdate. Control the required frame rate and Fixed Timestep rate from Time settings. Use Application.targetFrameRate to set the frame rate.
thats fine, my issue is - Im doing sort of an endless runner where I need to generate "blocks" of th environment procedurally and when I do it frame-dependantly, there are small spaces between the blocks when change rapidly, Im hoping to solve this by doing all this login in fixed frames instead
It will, but you could also do the math to fix it in Update, but that will be a bit more tricky. FixedUpdate will be an easy fix to your problem.
seems to have done the job, yeah
new to unity, any good places to learn? or is youtube my 1 place to go ? XD
!learn
🧑🏫 Unity Learn can offer you over 750 hours of free live and on-demand learning content for all levels of experience! Make sure to check it out at https://learn.unity.com/
ah ok thanks
anyone knows a good way to play videos in unity?
the default Video Player is lagging freezing or skipping frames
Must be using it incorrectly.
What do you mean by that?
That you are not using it correctly.
The default video player works properly for most people. If it doesn't work for you, there's something with your setup or code.🤷♂️
Or way too high resolution/bitrate.
Hey im trying to implement accelerating and deccelerating in my movement code but i dont understand why this isn't working:
rb.velocity = new Vector3(input_x * move_speed,0,0);```
"move_speed" just gets instantly set to "max_move_speed"... am i using MoveTowards incorrectly or what?
also input_x is just the "horizontal" built in axis
Log acceleration. If anything, you may need to have it be relative to delta time.
acc * Time.deltaTime
acc is constant so the log always says 1
if i multiply by deltatime i just move very slowly instead which i dont understand. Shouldn't it move towards max_move_speed?
It starts the movement from 0 every time
it should be move_speed = Mathf.MoveTowards(move_speed, max_move_speed, acc);
yeah i just realized
Some quick rundown of different protection levels. 
Public - Anything can see it.
Internal - Only the current assembly the class belongs to can see it.
Private - Only the class/struct/interface it belongs to can see it.
Protected - Same as private but any classes that inherit from the class it belongs to can also see it.
Some more niche protection levels.
Protected Internal - Internal OR protected.
Private Protected - Internal AND protected.
If you aren't running it in fixed update and do not want it frame bound, make sure to multiply the acceleration by delta time.
yeah yeah thx
Hello, I have a problem with my pickup function (pick and drop weapon system) . When I pick a weapon from the ground the position of the weapon remains the same even if I change it in the script. The weapon container is to parent and unparent weapons to it, it's an empty obj. pls help 😦
Is your weapon container under the camera?
why is VS telling me that i need to close a bracket when i have 14 brackets in total
im so confused
nvm it didnt like the public
yeah you cannot declare a public variable inside a method
makes sense
i was trying to figure out the syntax for the array
cuz i completely forgot
i got it now tho
Any idea how to fix the following build error in IL2CPP?
Build completed with a result of 'Failed' in 365 seconds (364613 ms)
C:\Program Files\Unity\Hub\Editor\2022.3.5f1\Editor\Data\il2cpp\build\deploy\il2cpp.exe @Library\Bee\artifacts\rsp\10085445761055836420.rsp
Error: IL2CPP error (no further information about what managed code was being converted is available)
System.InvalidOperationException: Sequence contains no matching element
at System.Linq.ThrowHelper.ThrowNoMatchException()
at Unity.IL2CPP.TableWriters.WriteIl2CppTypeDefinitions.WriteDeclarationsFor(SourceWritingContext context, IGeneratedCodeStream writer, IEnumerable`1 groups, Func`2 skip)
at Unity.IL2CPP.TableWriters.WriteIl2CppTypeDefinitions.WriteDeclarationsPart1(SourceWritingContext context, IGeneratedCodeStream writer, ReadOnlyCollection`1 allItems)
at Unity.IL2CPP.TableWriters.ScheduledTableWriterBaseChunkedDualDeclarations`2.ChunkWorker(WorkItemData`3 data)
at Unity.IL2CPP.Contexts.Scheduling.PhaseWorkScheduler`1.ContinueWithResultsWorkItem`4.InvokeWorker(Object context, Int32 uniqueId)
at Unity.IL2CPP.Contexts.Scheduling.PhaseWorkScheduler`1.BaseContinueWorkItem`2.Invoke(Object context, Int32 uniqueId)
at Unity.IL2CPP.Contexts.Scheduling.PhaseWorkScheduler`1.WorkerLoop(Object data)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
https://gdl.space/dosijiqupa.cs any idea why line 46 is giving me this error?
excuse the terribly messy code
textbox.text = Scenario[0]; is the line.
So 0 is out of range.
That can only mean that Scenario is an array with length 0
i.e. your array is empty
how?
string[] Scenario = {"You wake up in the middle of the street. You have no recollection of who you are apart from your name. The only people you see out are a group of people drinking. Do you talk to them? (A = Yes, B = No)", "", "" };?
This?
yes
This is completely unrelated
you simply declared a local variable here also named Scenario
this will not affect the Scenario member variable
If you wanted to assign the member variable you need to omit the type
just do Scenario = {"whatever"};
Dirty solution: guard statements
well a guard statement would stop the errors but won't fix the script (won't make it do the right thing)
ohh, i was confused cuz whenever i would delete the string[] part it would start giving me a bunch of formatting errors
such as?
because you have string[] inexplicably on the line above?
you're also possibly missing semicolons on those lines
oh i didnt see that
deleting that gave more errors tho
keep going
they are probably real errors.
Live 79 and 80, remove the type unless you're wanting to declare new types in that scope specifically
If you continue to get errors, you're probably using them before assigning them
you appear to me missing semicolons? Can't say without seing the code
Scenario = new string[] {"You wake up in the middle of the street. You have no recollection of who you are apart from your name. The only people you see out are a group of people drinking. Do you talk to them? (A = Yes, B = No)", "", "" };
you can only use the syntax without the new part if you're declaring and assigning in the same line
that worked
oh i see
is that for arrays specifically or?
only arrays have the ability to do the special syntax without new afaik
oh, neat
would it go to the else on the first time this is run?
the way I understood it was that if the IF goes through, the ELSE doesn't and vice versa
correct
in general, in a chain of if / else if / else, the first one that succeeds is run
everything else is skipped
else always succeeds
it seems to be doing both though
doing both what?
as in doing the IF and then doing the ELSE in 1 run of the code
and why do you think that's the case?
have you, for example, added some log statements to see which path is being taken?
perhaps the code is just running twice
because the ChoiceMadeA thing changes the text in the textbox, and it switches to it instantly
hmm maybe
only does one debug thats right below it tho
how to move an UI object toward's mouse position if the mouse is on the edhge of the screen?
private void Update()
{
Vector3 mousePosition = Input.mousePosition;
bool mouseOnEdge = mousePosition.x <= edgeMargin ||
mousePosition.x >= Screen.width - edgeMargin ||
mousePosition.y <= edgeMargin ||
mousePosition.y >= Screen.height - edgeMargin;
if (!mouseOnEdge) return;
Vector3 worldMousePosition = Camera.main.ScreenToWorldPoint(mousePosition);
Vector3 moveDirection = (worldMousePosition - map.position).normalized;
map.Translate(moveDirection * mapSpeed * Time.deltaTime);
clouds.Translate(Vector3.left * cloudsSpeed * Time.deltaTime);
}
doesn't work, always moves to the same direction (left bottom cornet idk why)
https://gdl.space/kizetunelo.cpp this is the code, i dont think it should be running twice
and is gamescreen.choicemade starting out false?
Anyone know a proper way to code VFX particle animations with trigger?
that's very vague
are you trying to play a Visual Effect when a trigger collider is entered?
Actually I want to play a visual effect when I press a button, while the visual effect which is a slash is coded to damage enemies when it comes contact into them
via trigger collider
Do i use the particle trigger or do I use another way?
yeah yeah
https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnParticleTrigger.html This does sound like what you want
It looks like OnParticleTrigger is run when any particles from a ParticleSystem on the same game object enter or exit a collider
you have to ask the system for a list of particles that just entered or just exited
Is it worth using the particlesystem trigger though? Because I've seen some people say that they just prefer to use collider to do damage to enemies in games
like using collider around effects
Sooo do I just attach a collider to the visual effect and code it that way?
If your IDE is not autocompleting code
or underlining errors, please configure it:
• Visual Studio (Installed via Unity Hub)
• Visual Studio (Installed manually)
• VS Code*
• JetBrains Rider
• Other/None
*VS Code's debugger plugin is unsupported.
We recommend using VS or Rider instead.
the errors were in my IDE
it wasn't telling me what the issue was
since the issue wasn't semicolons, it was me messing up syntax for arrays
(IDE already configured)
you'd just attach it to the same object as a particle system or visual effect, yes
Syntax errors can cause very confusing errors.
Add component mesh collider?
When I SLOWLY left click to play my punching animation while both running and idle everything works. I'm able to move again. Except when I start spamming left click to punch while idle then suddenly my moveSpeed doesn't reset correctly back to 6f and I'm stuck frozen. Anyone know how to solve this? https://gdl.space/origofezut.cpp for the code
Could it be a bad Input.?
Whatever collider shape you need. I would expect this to be a primitive collider
@thick goblet When you start punching, it stores your current move speed in a temporary variable and then sets it to 0. After a delay, it returns it to the stores variable. If you press the button while the coroutine is already running, it will store 0 (the current speed) and set it to 0. The first coroutine finished and sets it to its stored value of 6, then the second one finishes and sets it's stored value of 0
since you're just showing some particles, not drawing a mesh
I think I understand digiholic. I will try to solve it now
Thank you (Might not be able to though)
I think the cube would be best for a slash VFX collider?
basically float originalMoveSpeed = moveSpeed; don't do this in the coroutine. Save the original move speed in Start for example. You only need to do it once.
A box is a classic hitbox shape, yes
Is there anyway I can hook into a "On Selected" aspect of a UI Component via code? I have a slider I want something to happen on selected/deselected with. I know I could do Animation Events, but, yeah.
It seems I can't hook into this event?
along with spheres and capsules
Yeah i think a lot of games actually use box as a hitbox shape to be more efficient if i remember seeing one gamedev behind the scenes
That solved it perfectly. Thanks a lot I spent like 2 - 3 hours for this system to work.
Thanks a lot @swift crag , you're response was a real eye-opener!
no prob (:
Oh yeah, one other thing to consider: you could use a mesh for the collision and as a source for the particles
you don't need an actual mesh renderer
(you could just turn it off after dragging the model into the scene)
oh, wait, the particle system's "Mesh Renderer" emission shape...explicitly needs the renderer
Still works fine if the renderer is off
It does have a "mesh" mode as well, but you will need a Mesh Filter component on the object anyway so that the Mesh Collider works
so at that point it's probably just easier to turn off the renderer on a model you dragged in
two of the same object; the one on the left has its renderer off and a particle system with an Emission shape of "mesh renderer"
mmmm error shader
Yep.
This will emit particles from each vertex
so, for example, you could make a half-torus mesh and use that as the hitbox
and also emit particles from it
Ah I see super helpful for more complex and detailed game projects
thanks for the heplful insights and information

What is the use of [System.Serializable] ?
the Serializable attribute lets certain serializers know that the type can be serialized
By default, types won't be serialized, since you might not have intended for them to be saved and loaded
and if your next question is "what is serialization" it's basically converting an object into a format that can then be saved/written to disk
So I have this preset slash vfx that uses particle system, do I have to use the animator or a different way to make it so the slash vfx gets triggered upon mouse click?
Thanks 
also, [System.NonSerialized] is used on fields to say "don't serialize this"
I like using this for classes that need to store some runtime information
for example...
[System.Serializable]
public class BlendshapeInfo {
public string blendshape;
[System.NonSerialized] public int index;
public float value;
}
I ask the skinned mesh renderer's shared mesh for which index that blendshape name corresponds to at startup
so that I don't have to do that every time I update the blendshape
The index should not be serialized because there's just no point -- the value will only be known at runtime
Where are particle effects usually put into a scene?
or are they just called from the assets to play?
i have set the numeric values for both the spheres resembling their appearance and they are assigned properly while introduced into scene , but as soon as they collide numeric values of both the spheres turns to zero unexpectedly even though i have no modifications to the numeric values (except the image here).
please provide help this is like my 5th time asking.
If you're using the old ParticleSystem, then everything is configured on the ParticleSystem component
The new Visual Effect Graph package has you attach VisualEffect components to things to actually play the effects
but the definitions are stored in assets
because I have this game object with a the particle system that generates the attack VFX, and I attached it to my character, is that optimal or no?
because the cube collider
or box collider hits the enemies and damages them without the vfx playing
is there a way to synchronize the hitbox appearance with the particle system vfx?
I added a transform rotation to flip my player along with it's child objects so that the x faces the directions it's moving. I'm planning to implement fighting systems etc. Is this method a problem or is there a better way to do it?
you would want to turn the collider off when the particle system isn't playing
or just ignore the messages
is there a code to turn collider on and off?
wassup with -360 lol
why not just 0 / 180
Lol uh because it looks cool
can someone help me please , i have been stuck on this for 2 days
📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.
Your jpg quality is bad
.
here
debug logs are not present in that one but i can assure the numeric value sets to zero right after collision is executed
yo guys something is up with my line renderer
this is the code
and the ShootHitScan(); is being called in the animator
the wrong thing is
as u see
lr.SetPosition
is being set incorrectly
this is the debug
of the pos
this is the actual result
any idea?
from what I have tested there is a big delay
it saves an old pos
but I have no idea why
You're setting the line renderer positions of the prefab
Which means it gets applied to the next trail
Each one is showing the line of the previous shot
Also, why is SniperTrail of type GameObject when literally the first thing you do is get a component from it? Make the variable of type LineRenderer and save the getcomponent call
@calm coral sorry for ping , here are the scripts
if you wish to see debug logs in runtime
Fine but that's a lot of scripts I can't spend that much time to analyze it. And I'm experienced in 3D not 2D
can I still use instantiate on a line renderer?
Yes
alright no problem , thanks for showing interest tho
you want for player sphere to collide with npc one and smaller number sphere should disappear and reduce bigger sphere number?
yes precisely, and it happens through numeric value assigned to them which reset to zero for some reasons when they collide
Would running While(True) be the same as While(enabled)?
no
Your current setup is messed up bro u gonna need to go bald im afraid 
not u dilly mb for not pinging

mine? 
script?
here
alright gimme a minute
copy
which one is the collision script
like this part
last one (numericsphere)
is SpawnerNumericValue? this what sets to 0 ?
actually both SpawnerNumericValue and launcherNumericValue gets set to zero
Would you be willing to expand a little?
so this
?
int SpawnerNumericValue = randomizedValues[randomIndex];
i dont see it being set anywhere else
unless im blind
oh wait this setting a local one..
ur aware of that yes? just checking.
while(true) will run forever.
while(enabled) will only run if and while enabled is true
adding int in method makes it a local variable, so you're not changing the original SpawnerNumericValue
@sly bolt
yes that i used to spawn spheres with random value
where tho?
i dont know it did seem to set the numeric value in debug logs , i could be wrong tho
u got 50 sprites to display numbers btw?
as in the scene or scripts?
yes , after the operation because largest possible number that can be obtained is 49
this
where is this happening
because numbers are starting from 2
theres 3d text or something u could look into and just set its text to a number of sphere instead of that many prefabs
in the scene i have this (sphere_spawner) script attached to empty gameobject
and if u mean where the randomising is happening then its in the bottom block of code in the same script
void shuffle
i thought you need 3d objects for that
idk not sure
there's nothing really "special" about 3D and 2D
you can slap a TextMeshPro component onto an object to have text appear on it
I suppose I should have expanded my question more... I am writing a behavior designer node (rather converting an existing script I had into a node), and in that script is an IEnumorator with a while(enabled) loop (enabled is a part of monobehavior // not defined in my script). When making a node you have to change the parent class / interface for the class so I cant use monobehavior items like enabled. Would a While(true) loop be an acceptable replacement?
ive already made the necessary prefabs so it would be unnecessary at this point
unless they are creating a problem
i did read about textmeshpro but i thought it was only for 3d objects so went with this approach
but u instantiate whole ass new sphere when u need to change the number
yes that is my mistake due to the misunderstanding
i will take a look into how it works and rework the project , but i dont understand why the collision is resetting the value
I still think thats still the most valid option rn to go with now you know what mistakes u need to avoid rewriting the logic
I just wasnt seeing where the number was being passed on
only seen NumericSphere script has such an assignement of numbers
but idk the value because thats set inside the inspector ?
I suppose since the loop is supposed to be a part of a coroutine for a main task, I can just use the TaskStatus bool to toggle the loop, since while wouldn't necessairly stop running when the node is "turned off"...
no its not set inside the inspector , the launchernumeric value is based on input and spawnernumeric is basically any value randomly between (10-99) i believe i made them public because of access issues
wtf is node is that godot I smell 
the only place I seee SpawnerNumericValue being changed is a local variable in SphereSpawner
I don't see where else this is modified besides
Initialize
which is being passed in the same SpawnerNumericValue of whatever this script is on
It depends what you expect it to do
and in the numericsphere script inside collision code block to carry out the operation
It is a method that syncs root motion animations with nav mesh agent movement, so it needs to run alongside another movement script
yeah but where is SpawnerNumericValue being changed exactly? Unless I'm blind / missing something
right but it depends how you want the loop to behave. If you want it to be tied to the enabled state of some MonoBehaviour, true will not replicated that
its changing after colliding with launcher_sphere (one being launched by user)
changing to zero , even though it shouldn't
this ?
SpawnerNumericValue /= launcherNumericValue;
you tried debugging both values before the operatioon and result ?
Can anyone help me with this? My buttons are not working even though there is an event system. It all started ever since I try to load scene additively
no actually its changing right after collision (before this line is even compiled) concluded from debug logs
instantly after collision
watch this clip
select your event system and watch the preview window while you mouse over the button.
It will tell you which object is blocking it
if (SpawnerNumericValue % launcherNumericValue == 0)
{
Debug.Log($"SpawnerNumericValue is: {SpawnerNumericValue} & launcherNumericValue is : {launcherNumericValue}");
SpawnerNumericValue /= launcherNumericValue;
Debug.Log($"SpawnerNumericValue is: {SpawnerNumericValue} ");
SetSpriteBasedOnNumericValue();
}```
@sly bolt
Okay, Im gonna do that, thanks!
do you want me to make these changes?
yes lets see what the results are in the code
1 sec
launcherNumericValue is likely 0 like it says
it doesn't show up here
yes initially its not zero but after collision it turns to zero along with spawnernumericvalue
I also tried to put my event system in hometown scene itself but still doesn't work
and yes as i anticipated the code changes didnt affect anything because the value getting to zero happens instantaneously after collision so other part of script wont execute because value is zero and i get the error "attempt to divide by zero"
yes because its 0 when it hits the %
that modulus operator is giga random afaik lol
you cant do % 0
yep thats the exact problem
well i assumed it wasnt because its public so thought it was set in inspector or somehting
the numeric values are completely fine until they collide and get set to zero for some reasons
no iirc i just set them public to get access in other scripts
launcherNumericValue isn't being set anywhere
so if its 0 in the inspector by default, it wont be changed
its the input (2-9)
first script, in the for loop
.
SphereLauncher ?
yup
I dont see launcherNumericValue being set
https://hastebin.com/share/goqinafadu.csharp hey friends, in my 2d platformer, i've changed my player characters dashing ability (as per the screenshot) to be based on the direction the character is currently traveling (as per the code). if the character is going left or right, the dash goes the expected distance, left or right. if the character dashes up or diagonally up, it goes FLYING. now, i'm wondering if I would have had better success going back to my original dashing function but changing the code to allow for a direction based dash (as it is in the screenshot. the screenshot is from before my update, the haste bin is after my update).
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
you're never changing that variable though
you're just doing int index = launcherNumericValue - 2; // Subtract 2 because the array is 0-based.
I cross checked if launched spheres have desired numeric values after launched and they do so i can assure their value is not zero initially
Getting started with the Unity game development, mainly 3D, any ideas where to start for free?
!learn
🧑🏫 Unity Learn can offer you over 750 hours of free live and on-demand learning content for all levels of experience! Make sure to check it out at https://learn.unity.com/
in the function
void launchsphere(launcherNumericValue)
its taking value of value
launcherNumericValue is just a parameter name for that method
where are you changing the launcherNumericValue variable that you later use for division
no im not changing it im basically getting input from user and storing it in variable value in first script and then taking that variable in the function
void Launchsphere (int launcherNumericValue)
ur instantiating it without a value or am i missing something
GameObject newBubble = Instantiate(bubblePrefabs[index], transform.position, Quaternion.identity);
value types default to 0 when not assigned
so probably is 0 when u spawn it
`public class NumericSphere : MonoBehaviour
{
private Rigidbody2D rb;
public float movementSpeed = 20f;
public int launcherNumericValue;
public int SpawnerNumericValue;
`
launcherNumericValue
isnt assigned but then its 0
it has the index value which is declared as launcherNumericValue - 2
we're talking about the instantiated ball no?
NumericSphere
public void Initialize(int value)
{
SpawnerNumericValue = value;
Debug.Log("Numeric Value: " + SpawnerNumericValue);
}
where is launcherNumericValue
cause if its not assigned anywhere else, explains the 0..
i am getting the value of it in the inspector (whatever i input from keyboard)
I can write skeleton of what u exactly need to do with the spheres not much progress is being made here lmfao
the code says the value is 0, i trust the compiler
this is one of those examples maybe splitting the code so early into different scripts can do more harm than good
what i meant here is the launcher_sphere and spawner_sphere both have their respective values set which is not zero but both values change to zero after both of them collide with each other
thats why am askign where it being set at all, let alone 0
you might just be looking at the defaulted / spawned one that might have 0 value 🤷
you can get idea of what im trying to say in this clip , read the debug logs
but the spawned one does have none zero value
initially before collision
values don't typically change themselves, so somewhere its being set to 0 and if its not you're looking at the wrong object
no i wasnt looking at object but the debug log
newBubble.tag = "LauncherSphere";
Debug.Log("launcher Numeric Value: " + launcherNumericValue);```
i set the log after launcher sphere is spawned and the value is indeed non zero
this isnt the value on the spawned bubble tho..
u can watch the clip or i can record new one
then which one
SphereSpawner
SphereSpawner may have the correct value but the new object probably does not
because i dont see it being passed anywhere
if you did newBubble.SpawnerNumericValue = SpawnerNumericValue
it would make sense because inside the NewBubble(NumericSphere)
is where you're doing division
hold on let me record and show the scene
how do i reset my main camera position if it exits a certain x/y position?
let's say if the camera's position is >= 1080, it transforms back to x = 0, y = 0
assign it the position you want
if(camera.transform.x > myXLimit || camera.transform.y > myYLimit) camera.transform = Vector2.zero;
etc
ooo
instead of recording video after video, why don't you trace the path the data takes?
you should be able to easily follow that number through your code
it would help if you did Debug.Log(name + valueOrWhatever) but I assume you're just debugging the values on spawner 🤷 like I said, the spawned object that does the division still spawns with a 0 value, why dont u click one of the balls and view the inspector for the current values
its really not a hard problem I think there is just misunderstanding
maybe let me see
Why!??
anything after-2021 doesn't have learning project templates
Huh, so no microgames?
not for that version
So should I downgrade? I'm a beginner.
its not degrading but it probably is better to use a version that closely matches the tutorials/videos learning
downgrade, not degrade :p
Okay, damn should've known before installing it, thanks.
Oop, my bad.
but yeah, the 2022 LTS is missing the project templates
i dunno what the deal is with that
the 2021 LTS will work just fine
You can proabbly still open the projects if they are hosted on the website
but use 2021 as its less buggy anyway
I literally already made 3 bug reports on 2022
idk why it was so shotty
well, we are (relatively) close to the LTS's release
Oh yeah, I reinstalled Unity just to get rid of the package manager problems, it just kept loading the packages, I couldn't use any assets.
an LTS is just a version that's going to get patches for longer than usual
So the problem is with the version, imma just install the 2021 now.
true but 3 patches already and they still havent fixed the pink fonts on my macos xD
where's the "works on my machine" sticker
what version of macOS are you running?
i'm one update behind, I think
im way old
last time I updated on a whim I got slammed by that awful GC bug for months


