#💻┃code-beginner
1 messages · Page 296 of 1
Ok.
Well i have no idea how data.index is set
its set when you press the arrows on the shop
Ok. Gotcha. Then sure, that sounds good. Makes sense now
Hello. I have a database containing approximately 19,000 data (image, text, sound). 786 lesson objects in Unity as well. I want to pull 19,000 pieces of data into these lesson objects - using MYSQL - and divide them into parts, and print them as text, audio and image to my phone application. How can I do that?
this isn't exactly a Unity question
ask the general c# discord
alright ^^
!cs
Join the C# Discord server, a programming server aimed at coders discussing everything related to C# (CSharp) and .NET. https://discord.com/invite/csharp
Thank you so much
well uhm, anyone?
maybe look at spawn camp's question and answer that first #💻┃code-beginner message
I did answer him #💻┃code-beginner message
super broad; be more specific
you only scale the collider size
Hello, i want to change the height of a box when i grab it, what do you think will be the best to do it, change the vertices coordinate of the box or the scale ?
and how can i make it smooth (seeing the box "growing")
not really grabbing it but only when i select it
lerp scale
it will, but you can always change the camera height so that its different when crouching thru code
are you using character controller,
use this
https://youtu.be/-XNm7dPVVOQ
Welcome to part 4 of this on-going first person controller series, int this episode we're going to be covering how to crouch and stand effectively while also amending our movement speed WHILE we're crouching and also taking into consideration any obstacles above us before we stand back up!
Join me and learn your way through the Unity Game Engin...
ty
but if it is based on the height of the hand is it the same way ?
and no scaling collider, wont be a problem, just follow the vid @queen adder
i have no idea what you mean by this
like only pulling the top of the box based on the height of the hand
how does that correlate with your original problem?
that sounds like something different entirely
oh yeah sorry i didn't explain it well
ok the process is pretty much the same
capsule collider has the same properties as CC with sizing/center
what i want to do is to be able to "pull" the box and make it "grow" from the first screen to the second (sorry if i'm still explaining not very clearly)
This is called Extrusion
You're basically looking at procedural mesh processing or using the ProBuilder library or something.
yeah i created a procedural mesh
so i need to change the vertices coordinates to be able to do that ?
okay ty and for the interacitble part how can i do it ? i tried with the XR simple interactable but idk how to get the hand's height
private void OnSelectEntered(SelectEnterEventArgs interactor)
{
Debug.Log($"position current 3D Rayhit{ray.point}");
}
can i get the hand height from the interactor ?
Chatgpt WAS working correctly (to mean it was creating spam that looks like code but doesn't function)
I'm confused, I see playerprefs stuff, but nothing with JSON
Ok, and so what is the question?
Oh. Ok.
Huh, did they just get banned in a different channel or something? All their messages just vanished at once
chatgpt was his savior and you disrespected the machine 😔
they deleted their messages 1 by 1
I watched it happen one at a time, I think it was them that did it
Musta been quick, I looked away for like a second
I opened the code in a tab and came back and everything was gone
I got pinged for one where they linked to a chatgpt link, then as I was about to respond they removed it all
uhhhh what does this mean
this is in a prefab
Are you trying to drag a scene object into a prefab
im trying to make set it as a script that it can exchange with
but yes, it is from the scene
I have no idea what that means or how it answers my question
can't do that
Prefabs cannot reference objects in the scene
huh
Prefabs exist anywhere. What would those values be if you spawned it in a different scene?
Scene objects only exist when that specific scene is loaded
If you want to reference a scene object on an object you spawn at runtime, you'll need to spawn it first, then set the references
Have you taken a look at !learn yet?
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
omggg, ok
Ive spent an hour on this, now time to delete it all and go back to the drawing board
aka this bitch ass line of code
This seems like a good candidate for a scriptable object
Then you could create instances of it as files
My main problem is that in the original version of the game, (which is text based and written in python)
theres an entire library of things you can buy
This seems like a good candidate for multiple scriptable objects
When making a game you need a good way of storing data. This is where Scriptable Objects come in! In this video we’ll learn how to use them by looking at an example: Making cards for Hearthstone.
● Project on GitHub: https://github.com/Brackeys/Scriptable-Objects
♥ Support Brackeys on Patreon: http://patreon.com/brackeys/
····················...
which, would be selected based on the number you inputted, it would just go to that place in the library and pull the stats from there
I have no clue how it works in c#
I have the number input sorted out, each page in the shop has its own number. The thing is, don't know how to make a library with each object that can have their own individual stats attached
So you need some sort of object that is able to be scripted
if only there were a system someone had just linked a tutorial about
if only
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
Probably in the same manner but if you're wanting to use the Unity features like the inspector and whatnot, you'll need to work with some constraints like the one mentioned above about prefabs not being allowed to reference scene objects.
welp time to take a break because Ive been at this for close to 5 hours
like making the game in general
I've saved your link to my queue, thanks for trying to help
if anyone is free, I'm getting a null reference exception error and I know why, I just don't know how to fix it
Ive done this entirely text based, so that shouldn't be a problem, I can write the whole thing in code, I just need the syntax
welp cya
Look at the line the error is on. Something on that line is null but you're trying to do something to it anyway
i know but I have no other solution
Normally, you'd just post your description of the problem, attempts made and all of the necessary data and people would voluntarily provide suggestions.
Use the thread
i am
Does anyone have a general rule of thumb on how you organise certain script aspects on an objects?
i.e. animation controller script has logic for all animation triggers etc?
I've got a stats script on an object, should I trigger animations on stats from the stats script or should I split it out?
how to know that if an isometric game is in orthographic or perspective camera mode?
if has depth then its propsective
i understand but sometimes i feel it is difficult to observe it for me, cause hades game feels like orthographic but i somehow cant confirm it
I don't think hades is ortho
Or else it is at least faked perspective
You get smaller when you move further away from the camera

i need to open hades again now to see this
brb
wait really?
I think hades is Ortho
i never realized
How do you add a delay in your code
google it
my bad\
e.g
variable1 = VALUE;
[I want to add a delay here]
variable 2 = VALUE;
don't ask things that can be easily googleable
try harder
don't lie
how can i also check the vertical angle?```cs
//Horizontal angle
if(Vector3.Angle(transform.forward, directionToTarget) < horizontalAngle / 2)
{
}```
i tried doing something like this
//Vertical angle
float verticalAngle = Vector3.Dot(Vector3.up, directionToTarget.normalized);
float verticalAngleInDegrees = Mathf.Acos(verticalAngle) * Mathf.Rad2Deg;
if(verticalAngleInDegrees < verticalAngle / 2)
{
}```
imagine that
It's been a while. So i may be misremembering. Let me know!
the items are all same size , its def ortho
this
Gotcha gotcha. Sorry for the misinfo!
no worries we are all learning
Stack overflow made no sense
I didnt understand it
And I couldnt reas properly
how about the Link that literally says how to do it
or watch a yt video of it
I am rn
i lub this website
lube? 🤨

you said delay code
waitforseconds??
u can create a function to delay the values here
Some errors popped up idk how to interpret
there are literally more than one way shown how to make delays
try coroutine
there gotta be some turtorial
brackeys
i lub 🤨 that dude
Come on, I hate reading. And i couldnt find much vids

How is it not what you're looking for
aight ima just block you cause you're being childish
@summer stump why do you not like brackeys
Maybe bc i am a child, but even then what did I do
I apologise
Because I have to fix errors from their terrible code too often. People do their tutorials and come here with all the issues caused by it.
I always consider them the worst youtuber for unity stuff. Very charismatic and fun though
Bro i changed my script editor but still the same glitch https://streamable.com/psqg4x
it isn't working
lmao
Sorry for the background music
Brackeys is a great presenter. Not the best programmer. A lot of his code has problems that don't reveal themselves until you try to expand upon his tutorials, so around here a ton of our time has to be spent trying to de-program bad habits that cause problems further down the line
thats true
i followed his 3d player controller and couldnt do anything after
tried to make grapple hook and quit after 2 days
He's great at presenting topics, and is great for getting an overview of broad topics, like "how to use post processing" and whatnot. But the code itself is the least important part of the tutorials and people tend to just lift it wholesale
any idea why the last velocity is wrong?
but its a good way to start off game dev isnt it?
Idk why this never works
Spelling error
yeah i guess he teaches beginners what each line and thingy does
Well, capitalization error
I would say Brackeys is dangerous to start with. You need to be at the point where you can read documentation and debug your own problems before using Brackeys. I'd call him more of an intermediate level
Whats a RigidBody2D
yeah 🤣 i looked and even highlighted but only took you to say it for me to realise
No. His beginner stuff is by far the worst
His more advanced stuff becomes OK
i see
Seems like you don't have the .NET SDK installed.
Using Visual Studio 2022 would be simpler, as it comes bundled with everything required on install.
🤨
What? It is not a thing
how do i download it?
really? sounds like a real thing
"the worst" is definite overkill. his cube runner tutorial is good for beginners
What? It's not a Unity component so if it's something in their project they'd need to show it
You would be wrong
=> Visual studio 2022 download
"The worst" of Brackeys content is his beginner-focused stuff. Not that Brackeys' beginner content is the worst beginner content
wait a rigidbody 2d is a component
No, Rigidbody2D is. Not RigidBody2D
ah ok
Rigidbody2D is, RigidBody2D is not
But why it works on one of my scripts
but doesn't work on the other one
Oh i thought you meant the entire thing didnt exist not the spelling error
Because it's VS Code doing what it always did, work half the time with Unity
wdym
It's unreliable, that's it
Sometimes the plugins don't load, sometimes it doesn't detect the project, etc.
Bruh i was using JEtBrains rider but i was getting the same error
its gotten better 😦
Switching from Rider to VSC
bruh
sad
I was getting the same error
so how do i fix rider instead?
What "error" are you talking about?
just install .NET sdk dude
Things don't load
its not that diffcult
and the script doesn't work
the one you showed on VSCode is you missing .net sdk
First things first, open a command prompt (outside of VSC) and input dotnet --info and see what it tells you
which is needed for dotnet commands
ok
ah yea missing whitespace
Add a space between dotnet and the --info argument
you can also do dotnet --list-sdks
omg ive been tryna do smt for the past 2 days it finally worked
feels so good
Yep confirmed, it's not installed
yup dotnet is not installed
Nice bro
i'm downloading it
make sure is .NET SDK not runtime
Resart PC is required after
I mean, you can do both.
is it possible to put to oncollisionenter2ds on the same script? i already googled and couldnt really find a good answer
No, you cannot have two functions named the same, with identical parameters
You can put all your code in the same one though. Or call two of your own functions from OnCollisionEnter
ohhhh that makes a lot more sense
sounds like an XY Problem
female?
nope my question was the x problem
its all one problem...
adding two oncollisionenter2d in one script certainly sounds like Y
Wait that's so funny, i do that all the time
i was just trying to change my speed and jumping power with certain platforms in the same script
uh oh
You need individual script on each platform
then you can send a "event" or "message" to the root script
Exactly. XY problem. You asked how to do x when you wanted y
To get y, you don't need x at all
oh wait
actually with this sounds like you only need to check specific Tags
or platform type
You cannot have two tags on one object
i know im saying two in total
oh ok , still confused why you needed two OnCollisionEnter
private void OnCollisionEnter2D(Collision2D other)
{
if (other.gameObject.CompareTag("SpeedPlatform"))
{
maxSpeed = 14f;
}
}
private void OnCollisionExit2D(Collision2D other)
{
if (other.gameObject.CompareTag("SpeedPlatform"))
{
maxSpeed = 9f;
}
}
i was just trying to replicate this but for jumping power
@short hazel @rich adder it's working now ! Tysm 😄
youre welcome! 🙂
ohh just put them inside the same method lol..
i would really recommend you learn more c# first if youre struggling with this 😅
So why would you need another copy of the function
The function runs when you collide with anything. That's why you check for tags
One's Enter, the other is Exit. They're not the same so perfectly valid in this context
I’m so dumb I thought that entire method was one thingy
I’m trying bro but I don’t wanna watch 8 hours of some dude yapping about code I wanna learn from experience
Spending "8 hours" to learn basics is better than spending entire days or weeks trying to figure out basic error etc
Don't worry, you'll have more than enough opportunities to learn from experience once you get past the basics 
i started out the same way, but i would ABSOLUTELY recommend listening to some dude yap for a few hours
that'll save so much more time for the future
unity learn has you do stuff and gives tangible results so try that !learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
Or better than listening to someone yapping for a few hours straight, take a course and practice what you learn
I mean in response to their original question of wanting to add new ones for a different tag
Shush that was stupid I wasn’t thinking
Is this like... too much to have for an start method for each projectile? Cause I plan on adding more and I am kinda worried I should be doing something different
I feel like this all could be encapsulated in a separate class and just save a reference to that instance of that class with all the data
Is it just me or is proyectile a thing
Hardly, you are probably better faking it out yourself
you should just wrap all that projectile data into a class or struct and copy that. It should be a single line. Rather than duplicating all the variables like that.
Also the layermask thing is somewhat inefficient.
How so?
Like... a scriptable object or something like that?
no just a class or struct
POCO
I mean you could you a ScriptableObject too
up to you
but it's not necessary
plain class/struct, serializable if it's set in the inspector
Serializable is something else
Aw 😦
similiar thing though
Hi, I'm on Mac and trying to now build my game for both Mac and Windows. In the Unity Hub, the only windows modules I see are under "WebGL". How to get windows build support?
What does your unity hub modules look like?
Should I select that even though it's under WebGL?
They're not "under" WebGL in the sense you're thinking
I thought it should appear under Platforms
So... I create a script that just holds a struct with all the projectile data? S
Sry I never used that before, I don't quite understand it
WebGL module is simply already installed, hence displayed differently
you create a class or struct that holds the projectile data
@ionic loom did you really mean the middle finger react?
No
I just clicked smt random
Why would i even do that
I dunno. People do weird troll things all the time
"under" would probably be a collapsable arrow
as you see for "Dev Tools" or "Platforms"
Is it safe to update modules in unity hub while you're doing stuff in the editor?
probably best to close the editor
should be fine
seems like it's still running
Oooo conflict
just restart after
why are so many games made just for windows if platforms like Unity can build for both?
performance
Should be fine, but it doesn't cost anything to be extra careful and close it for 5 minutes
I was able to build for mac before adding the IL2CPP module, is there going to be a difference having this module or not?
I'm guessing I'm currently building for Mac mono
And how does that make it simpler to pass the data? I have to still set everything to the playerController stats don't I?
It becomes one line
IL2CPP is needed for IOS iirc
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
myBulletData = payerStats.bulletData;
What does buggy mean?
buggy can mean 10 million things be specific
These are compile errors, not bugs
thats not a bug thats an error
Is your !ide configured?
If your IDE is not autocompleting code
or underlining errors, please configure it.
Select one:
• Visual Studio (Installed via Unity Hub)
• Visual Studio (Installed manually)
• VS Code
• JetBrains Rider
• Other/None
Is there a reason for putting a public float into a. Serialize field
looks like a spelling mistake for the highlighted error
Foe the unassigned ref error, do you destroy the target?
public already makes the field serialized
So I set the struct on the playerController, give it all the relevant data and then pass that to the bullet itseflt and set every stat of it according to the struct data? Isn't that equally ineficient or I am just overthinking it?
MathF < the Unity one is Mathf
When you're messing with your code in the editor and clicking "Play", is it interpreting rather than compiling the C#? (this may be a very stupid question)
So why not make the private serialized float public?
Guys why my health bar script isn't working? https://streamable.com/v3ezwp
script: using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements;
public class UIHandler : MonoBehaviour
{
public float CurrentHealth = 0.5f;
private VisualElement m_healthbar;
public static UIHandler instance { get; private set; }
private void Awake()
{
instance = this;
}
void Start()
{
UIDocument uiDocument = GetComponent<UIDocument>();
m_healthbar = uiDocument.rootVisualElement.Q<VisualElement>("HealthBar");
SetHealthValue(1.0f);
}
public void SetHealthValue(float percentage)
{
m_healthbar.style.width = Length.Percent(100 * percentage);
}
}
I just showed you the entirety of the code to "set every stat of it"
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
It's one line
Because other classes can modify a public variable
Again, mb for the music
You can mute that btw
Makes sense
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements;
public class UIHandler : MonoBehaviour
{
public float CurrentHealth = 0.5f;
private VisualElement m_healthbar;
public static UIHandler instance { get; private set; }
private void Awake()
{
instance = this;
}
void Start()
{
UIDocument uiDocument = GetComponent<UIDocument>();
m_healthbar = uiDocument.rootVisualElement.Q<VisualElement>("HealthBar");
SetHealthValue(1.0f);
}
public void SetHealthValue(float percentage)
{
m_healthbar.style.width = Length.Percent(100 * percentage);
}
}
No, like, what I am refering to, that would give me the data stored for how I make a porjectile, I still need to assign every stat of it manually. Like for example for range I would set it to range = proyectileData.range instead of PlayerController.range
Right?
I have a function which is running later than expected, could this be to do with processing power and the way my function is being obtained? (from another script)
wrong
there's no need to do that at all
when you need it you just do myProjectileData.range
there's no reason to duplicate all the variables
what do you mean by "running later than expected"
code runs immediately when you call it
Nothing to do with processing power.
Why it isn't working?
I tried to do that and its didn’t work because I tried put a script in the serialize field
I have set it so it is called when a countdown (which starts from 2 seconds), is less than 1.5 seconds (so it should run 0.5 seconds after the countdown begins
i will run a debug rq and let you know if it is just the function or the debug that it is affected too.
wdym by "countdown"? You really need to show the code
Oh, so.... I would have to refactor everything then...
The field would have to match the class type
But you can certainly do that
Ok... sure, I guess I will do that
refactoring is a normal process. But yes you would simplify your code.
I know I just found a better method
Ok 🤷♂️
So if I set the struct on the playerController I can use it no problem in any script or...?
Anywhere you want
Hey why the shrug
you have to follow the normal rules of objects and reference management in C#.
Sounds sarcastic somehow
Not really sure what you mean beyond that
Please stop doing that.
But because you pinged me about it and then said nevermind. So i said ok
Wait stop doing what
Acting like that
Same as with all the separate field you had earlier, but instead you'd have a single container for all of them at once
Ok
Like if I pass a projectileData struct from the PlayerController to the projectile, I can use it there no problem, but I cannot use it from a script with no direct reference to the struct itself right?
wdym by "direct reference to the struct itself"?
why it is growing
Like anything else if you need the data you have to access it somehow through a reference or by copying it passing a parameter around, whatever.
I wasnt able to find the issue so here's the code:
https://paste.ofcode.org/UVrCe6YdGKAzesPuEWNpe5
The countdown function is running normally, so i want to know why the trishotskill function is running late? Thanks
woah are those custom sprites?
Like if I create a new script I cannot create a new ProjectileData there if the stuct is declared in other script. I can just use the data from an already passed struct
Is that it?
No, i'm following a tutorial
anyone can get it for free in unity store
You can create a new instance of ProjectileData anywhere you want as long as that type is public if that's what you mean
And you can't pass around private types anyways (outside of the declaring scope)
I feel like you're missing some C# basics
Of course I do, I literally just used whatever I needed for unity until now
I never "needed" a struct
I would literally wouldn't know about it if I didn't ask you guys
Well, it would be good to learn C# basics first or you'll be stuck on non-Unity related issues, like right now
Either learn one thing at a time or make a mess trying to learn both
The only way for me to learn anything usefull is by making it practical
Doing isolated stuff with code practice or stuff like that doesn't work for me whatsoever
I just forget it as soon as I finish it
hi caesar, any chance you could help me?
With what exactly?
Stuct is actually quite complex is the sense that you wouldn't really need it unless you want to do something big enough that the performance might be an issue
this
Precisely the reason why I am doing kinda of bigger thing here, just to force me to learn this stuff
I am trying to run this function 0.5 seconds after the countdown starts
the countdown is tested and working, although the function isn't running when it's called
I was wondering if you could pinpoint what could be preventing this (i couldnt myself)
I wouldn't say complex, performance isn't the first thing to consider whether you need a struct or not
It's just a way to bundle related fields and copy the instance by value rather than by reference
Passing around a struct is just passing a new separate instance, changing the original fields doesn't change the copy
Passing around a class is just passing around a reference to that instance instead of making new copies, changing the fields of the original changes the passed "copies"
Which would only really matter for perfomance... I don't see why I would use a struct rather than just passing the values I need one by one if it wasn't the case
Not only for performance
If I were to instantiate 10 bullets with a struct containing initial speed and rotation and maybe something more, and I'd want to modify these values differently for each bullet over time then passing via struct rather than class would make sense
And passing one by one is just.. wasteful. Why would you want to separately copy every single field. Rather than that if you ever want to change something, just add a new field to your struct and you're already done, no need to modify the method responsible for duplicating data
I just do it at the start, the values don't need to change dinamycally, so each projectile just has their own differetn values anyways
I just add that new field on the PlayerController, which is basically the same that adding it to the struct
ye
line?
I am kinda just using the PlayerController as struct now that I think about it....
It's still more readable and extensible if you just bundle them in a class/struct and pass the instance instead of separate values
It basically holds most of all the data, which is kinda weird
I'll list all the errors here in numerical order in case it's difficult to read📋
-
Assets\Scripts\PlayerController.cs(91,18): error CS1061: 'Movement' does not contain a definition for 'isPrinting' and no accessible extension method 'isPrinting' accepting a first argument of type 'Movement' could be found (are you missing a using directive or an assembly reference?)
-
Assets\Scripts\PlayerController.cs(69,39): error CS0117: 'MathF' does not contain a definition for 'MoveTowards'
-
UnassignedReferenceException: The variable target of CameraManager has not been assigned.
You probably need to assign the target variable of the CameraManager script in the inspector.
UnityEngine.Transform.get_position () (at <17484a9af6b944dea5cd9be4dbb0da2c>:0)
CameraManager.Awake () (at Assets/Scripts/CameraManager.cs:20)
The very moment you'll ever have to use these fields anywhere else than that one single script, you'll get to know why it's better to pass just one bundle instead of a flood of separate values
If it is configured, it should show the other errors directly in your code
I dunno what line the unassigned reference error is talking about, but it should tell you in your console
Hello everyone, literally just joined and was wondering if I could get a bit of help with a final project for school..
if its a compiler error, then I'll try to restart it rn.
Not sure what you mean by configure error
compiler error* sorry
Like, my player needs to pick up stuff that modifies what it does, and most of the changes are attached to how the projectile works, so I would need to pass the reference of all the power ups picked by the player to be attached to the projectile
So my question here is... how would I make the proyectileData struct have a reference to all the power ups that effect the projectile the player has?
I'm not sure if I'm running into an issue with my code, or if I'm not implementing it properly into Unity, but I'm trying to get cakes that are falling from the sky to stick to a tray I've attached to the player by using a spring joint.
What type of effects exactly?
this is what my code looks like
your methods are inside of the Start method. they do not belong in there
Why is void update in ur void start
Still really new, so it's something I didn't notice, I'll change that now thank you
can you take a video of what the game looks like right now without the cakes falling properly from the sky etc etc.? Id be curious to see
using static UnityEditor.Timeline.TimelinePlaybackControls;
For starters, are you sure you need that using in your code?
no but thanks for noticing that that was there, idk what that does but imma remove it right now
use mp4 rather than mkv to embed in discord
got it!
Like so you undestand it better, powerUps shoud hold a list of all the the powerUps currently picked and should be taken in account. In this case, the "hasExplosiveShoots" IS a powerUp but I need to pass it to the projectile for it to do the stuff. "NinjaCloak" for example does other stuff that needs extra parameters that pretty sure should be better stored on a struct. So how the hell do I even organize this?
Assets\Scripts\PlayerController.cs(91,18): error CS1061: 'Movement' does not contain a definition for 'isPrinting' and no accessible extension method 'isPrinting' accepting a first argument of type 'Movement' could be found (are you missing a using directive or an assembly reference?)
Assets\Scripts\PlayerController.cs(69,39): error CS0117: 'MathF' does not contain a definition for 'MoveTowards'
Anyway so here's the new console errors that seem to be only 2 trustable errors after restarting my unity
https://gdl.space/ucudofaset.cs Codezilla here.
One minor thing, you likely want to check the tag of the thing you're colliding with, not your OWN tag
Also use CompareTag
So:
if (tray.gameObject.CompareTag("cake"))
You still didn't remove the line I mentioned
the isPrinting is almost definitely a typo. Does your movement involve printers??
The other one is also a typo. Unity has Mathf. Not MathF
I'll check that out, thank you
Can you show a screenshot of your code editor?
It should tell you how to correct at least the MathF one
Didn't notice that the correct var is isSprinting lol
Should I just past the whole PowerUps struct to the ProjetileDataStuct?
Is that right?
The easy and simple (and probably primitive) way, would be to make classes out of the powerups and add fields for each powerup to ProjectileData
If it's null, there's no powerup of that type
The use of structs here sounds weird but I would consider using inheritance here for what a power up
Otherwise apply powerup
So it's configured properly. How could you not see it suggesting you the correct variable name..?
Ok, and when you hover over the underlined word (movetowards), does it say "quick fixes"
it's not
it was showing me isprinting, it should had been issprinting instead
For the isPrinting I mean. When you were typing it should have showed you the correct option.
What I was doing until now was to create parameters in the PlayerController and keep them "unused" until the bool that indicates that the powerUp is picked is true; which happens when they pick the powerUp, it also sets all the relevant varibales
So you are telling me I should extend the struc on the powerUp itself?
Add powerup class (or nullable struts) fields to the ProjectileData struct
This is all I get
wrap, unwrap and the last one, introduce parameter for 'movement'
How do I do that? Like I can attach new "value slots" to an already existing struct?
Is that what you are saying?
Not here. When you type it...
ok i only get on error now which is this
Assets\Scripts\PlayerController.cs(7,7): error CS0138: A 'using namespace' directive can only be applied to namespaces; 'Mathf' is a type not a namespace. Consider a 'using static' directive instead
it does show recommended keywords but its not always wanted keywords
struct ProjectileData
{
// Some normal data
// ...
public MyCoolPowerup mcp;
public MyOtherPowerup mop;
}
...
if (projectileData.mop != null)
// Powerup active, apply to projectile...
Could also be done via inheritance and an array/list of powerups, with some virtual or abstract apply method
delete that yellow circled line entirely (why did you add that?) and change the other line to use Mathf not MathF as mentioned before.
That's what you should've looked at with movement.
But... my powerUps are not like classes that I can referenced like that I think....
was recommended by Ai
well AI is dumb
Can someone help me fixing this glitch?
stop listening to it
Then make them into classes
now the error wants something like this but still doenst work
I have a function that loads saved settings from PlayerPrefs which runs when the game launches (I know it's running because I can see the Debug.Log in the console) but the settings only apply when I open the settings menu for some reason. I've tried allowing the settings menu to be active for a moment when the game launches but that didn't work either. Does anyone have any idea why this is and how I could fix it?
What ai? Don't use it as a replacement for basic programming understanding.
if you do what I said it will work. Already told you the answer
Oh, no they ARE classes, they just adjust some parameters and then they just are destroyed
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
If it's GitHub copilot, I'd disable it entirely while you're still learning.
For example
oh thanks sorry I didn't see that message, seems i missed this one ok ty
at this point I meant this one #💻┃code-beginner message
Load Saved Settings Function:
{
Debug.Log("Loaded saved settings!");
volumeSlider.value = PlayerPrefs.GetFloat("volume");
musicSlider.value = PlayerPrefs.GetFloat("music");
sfxSlider.value = PlayerPrefs.GetFloat("sfx");
}```
Main Menu Class:
```using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class MainMenu : MonoBehaviour
{
public GameObject settingsMenu;
void Awake()
{
settingsMenu.GetComponent<SettingsMenu>().LoadSavedSettings();
}
public void PlayGame()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
}
public void QuitGame()
{
Debug.Log("Quit!");
Application.Quit();
}
}```
Should I for example create and stuct there and pass that?
Well that explains the issues
You load function only sets the UI sliders. It doesn't actually change the volumes etc.
wow... you're right, i didn't even notice that. i think i watched a crappy tutorial
Or a class, if you plan to store it in ProjectileData and do powerup checks via a null check
ty
Ok so, my player has stopped moving and instead when I press the WASD keys he just rotates around himself... 
https://gdl.space/dayeqabaqo.cs < CharacterController script
https://gdl.space/gazomuwasa.cs < CameraManagement scirpt
You probably need to assign the target variable of the CameraManager script in the inspector.
UnityEngine.Transform.get_position () (at <17484a9af6b944dea5cd9be4dbb0da2c>:0)
CameraManager.Awake () (at Assets/Scripts/CameraManager.cs:22)```
^^^ Not true I did assign it
You didn't assign it
You might have assigned it on ONE copy of the camera manager script
but there's another copy somewhere you didn't assign it
Hello, need a bit of help.
I have this function in my BallBehavior script attached to a gameobject, and i want it to turn around as if it would bounce using it.
public void OnCollisionEnter2D(Collision2D collision)
{
Rigidbody2D rb = this.GetComponent<Rigidbody2D>();
if (collision.gameObject.tag == "Vert Wall")
{
rb.velocity = new Vector2(rb.velocity.x, -rb.velocity.y);
} else if (collision.gameObject.tag == "Hor Wall")
{
rb.velocity = new Vector2(-rb.velocity.x, rb.velocity.y);
}
}
However, the velocity is set to zero before i can flip it. is there any way to counteract this? or am i doing something wrong?
ok true there was one in my Player himself. thanks
aaaaand... I still get the same error lol.
the velocity has already changed by the time you're in OnCollisionEnter2D. You could use collision.relativeVelocity to see what the velocity diff was before th collision if you want.
what is collision.relativeVelocity exactly?
thanks
bump
I deleted the copy in the Player Gameobject and now I still get the issue
Im not sure this will work. My object is colliding with a wall that wont be moving, and so wont the relative velocity be zero?
No
The only way the relative velocity would be 0 is if neither object is moving or they are moving in the same velocity in the same direction (meaning no collision)
then there's one somewhere else too
no in fact that's ideal
Relative velocity of one moving object and a static object is simply the velocity of the moving object
the relative velocity will be whatever the pre-collision velocity of the moving object was
okay, i think i get it now.
so replacing rb.velocity in the new vector2 with collision.relativeVelocity would solve my problem?
sorry if I seem stupid im very new to unity
try it
it still seems to have the problem
have you tried Debug.Logging the relativeVelocity?
it's no where except for where it should be
https://gdl.space/dayeqabaqo.cs < CharacterController script
https://gdl.space/gazomuwasa.cs < CameraManagement scirpt
So I ended up doing something like this. Is this the intended way of using it?
thats really wierd. the relativeVelocity is logging the correct velocity, but it seems that im having trouble changing the velocity to the right thing:
public void OnCollisionEnter2D(Collision2D collision)
{
Vector2 newVelocity = collision.relativeVelocity;
Debug.Log(newVelocity);
Rigidbody2D rb = this.GetComponent<Rigidbody2D>();
if (collision.gameObject.tag == "Vert Wall")
{
rb.velocity = new Vector2(newVelocity.x, -newVelocity.y);
} else if (collision.gameObject.tag == "Hor Wall")
{
rb.velocity = new Vector2(-newVelocity.x, newVelocity.y);
}
}
i should die when the remaining distance is less than 1 but the death object activates before that
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEditor;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Animations;
public class navmesh : MonoBehaviour
{
private NavMeshAgent agent;
public Transform Player;
public Animator anim;
public int Health;
public GameObject PlayerPrefab;
private void Update()
{
agent=GetComponent<NavMeshAgent>();
agent.destination=Player.position;
Debug.Log(agent.remainingDistance);
if (agent.remainingDistance>2)
{
anim.Play("run");
}
if (agent.remainingDistance<0.6){
anim.Play("attack1");
Health = 0;
Debug.Log(Health);
if (Health==0)
{
PlayerPrefab.gameObject.SetActive(true);
}
}
}
}
how do i type the code in the bars like you guys
do triple backtick
and then the language
so like '''cs
but with backticks (left of the 1 on us keyboards)
i can't send it for some reason
Also, I just noticed, struct cannot be modified from the the inspector right? Cause just pressing a bool to tick if some powerUp is active was VERY usefull for testing
Why does my player rotate around himself everytime i press the WASD keys to move the player himself?
https://gdl.space/dayeqabaqo.cs < CharacterController script
https://paste.ofcode.org/KvAHCNW6XANHwqx7nuzQgK < CameraManagement scirpt
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
What does the debug say the remaining distance is?
yes
That is not a response that makes sense
That was not a yes or no question
sry im new i just started like 2 or 3 days ago
So... you don't understand what I asked?
Because usually questions that start with "what" are not yes or no questions.
Why does my player rotate around himself everytime i press the WASD keys to move the player himself back and forth etc he just stays in place and spin like a bayblade?
https://gdl.space/dayeqabaqo.cs < CharacterController script
https://paste.ofcode.org/KvAHCNW6XANHwqx7nuzQgK < CameraManagement scirpt
and doesn't jump either
private Rigidbody2D rb;
void Start()
{
rb = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update()
{
}
public void OnCollisionEnter2D(Collision2D collision)
{
Vector2 newVelocity = collision.relativeVelocity;
Debug.Log(newVelocity);
if (collision.gameObject.tag == "Vert Wall")
{
Debug.Log("Velocity to change to: " + new Vector2(newVelocity.x, -newVelocity.y));
rb.velocity = new Vector2(newVelocity.x, -newVelocity.y);
} else if (collision.gameObject.tag == "Hor Wall")
{
Debug.Log("Velocity to change to: " + new Vector2(-newVelocity.x, newVelocity.y));
rb.velocity = new Vector2(-newVelocity.x, newVelocity.y);
}
}
I cant seem to find problems in this code except setting the rb.velocity. Im not sure what to do
34
Ok, I kinda think the issue is in some other code.
You have PlayerPrefab.gameObject.SetActive(true) (which is kind of concerning, because prefabs do not exist in the scene, and don't have an active state), but it's a ui element that is set active?
first it was player prefab now its the UI prefab i forget to change the name because the setactive thing wasn't working on the player and i got tired
ahh man i think i messed up
Prefabs do not exist in the scene, so this is a gameObject, not prefab
i pasted the wrong code
Ok, I thought so. That code didn't seem to be causing the issue
Why wont this script show up in the tools menu in the editor? https://hastebin.com/share/ijihojiyeq.csharp
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
Ah, should probably ask in #↕️┃editor-extensions
I dunno much about them. My first naive thought is that the attribute should be over the class? But I have no idea
this code is better i think 😢 the Dead UI gameobject should be setactive true when the distance < 0.6 but it activates the moment i start the game
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEditor;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Animations;
public class navmesh : MonoBehaviour{
private NavMeshAgent agent;
public Transform Target;
public Animator anim;
public GameObject UIObject;
private void Update() {
agent=GetComponent<NavMeshAgent>();
agent.destination=Target.position;
Debug.Log(agent.remainingDistance);
if (agent.remainingDistance > 2){
anim.Play("run");
}
if (agent.remainingDistance < 0.6) {
anim.Play("attack1");
UIObject.gameObject.SetActive(true);
}
}
}
it looks like the code doesn't care about remaining distance and just activates
What do you see in the log?
remaining distance
I mean, is it more than 2 on start?
its around 25
Is that what you see in the console?
Take a screenshot of the very first message
what would you call an instance where there is only of them? (documentation reasons)
One instance
thought singleton was right
Singleton is a programming pattern that makes sure that there is always only one instance.
oohh okay
Open the damn console tab, scroll up and take a screenshot...
Yep
but why
Navmesh agent takes time to calculate the path. Before it's ready, it doesn't know the remaining distance
Maybe check if it has a valid path before making the distance check
how do i check ? and where
This is a very noob question but I can't seem to remember. When setting transform.position, does the parent transform affect the output position? Because from the documentation it looks like it shouldn't, yet it seems to do this when set.
It doesn't affect the world position being set but it will certainly affect the local position you end up with
Not sure what you mean exactly by "output position"
the position that is resulted from setting the transform's position
so this line should set the object's transform position to the 'unit' position, reguardless of parent, correct?
gameObject.transform.position = new Vector3(unit.gameObject.transform.position.x, gameObject.transform.position.y, unit.gameObject.transform.position.z);
Will a normal transform having a parent that is a rect transform effect that at all?
for one thing, you can do unit.transform and transform (skipping the gameObject part entirely).
Just as an aside
Have a look at the ba mesh agent documentation for the available methods.
yes I know. I just haven't looked at this code before 10 minutes ago so I haven't had time to fix anything, but looking at it I don't really see a reason for it's behavior to be faltering.
that's what .position does, it sets the world space position
regardless of parentage
for some reason it's getting set to really large numbers of x, y, z instead of the unit's position. Its parent is a rect transform so that has to be it, right? But i thought parents shouldn't affect setting the position value.
This should basically never happen
why do you have that situation?
Because UI elements with RectTransforms live in screen space. Using those as the world space positions for your objects will result in this.
To be clear, you have a non-ui unit with a normal transform as a child of a ui element with a recttransform?
the object is displaying the unit's range which is all UI except for this object.
yes thats how it currently is
that's where you've gone wrong
Yeah, that is really not good
hmm why not? Even where I currently intern they do this. (this is not for intern, personal project)
In Screen Space - Overlay, it results in what you're seeing.
If you use a Screen Space - Camera canvas it will work more or less
okay, interesting. But it's generally fine to have the reverse?
no
it's not ok in general to have UI objects that are parents of world space objects and vice versa
what about when the canvas is in world space? Is that ok?
I have a simple question. How do I set what UI element the mouse focus is on?
what type of thing is time.deltatime
is it an enum?
I need to know for documentation
deltatime is a float
There is real documentation that will tell you all this
thanks
deltaTime is not an enum
Nor is Time
thought so
Wait, when you say for documentation, is this like a school project?
yes, and im thankfully finished as of now
time i could call like an in built class?
or from unity's class library?
this doesnt do anything right?
built my first game 🙂 followed a tutorial and its pretty basic, but still a good notch under the belt
What the heck is this error I am getting?
Something wrong with the trail renderer inspector. If you don't need the changes to the component you could try resetting it and hope it goes away
It does do something
It returns from the whole method if any Image in menus is active
How do i change antialiasing in HDRP during runtime from script?
I've tried google, but none give good explanations.
unity crashed what do i do?
yeah but it goes through regardless no?
I mean I know the code itself does something but I mean effectively, it does nothing?
Nothing changes by that being there I'm assuming
It somehow fixed after resetting, but pretty sure I didn't touch any trail renderers like for a long while
I am now getting this error out of nowhere. I have no compile errors showing anywhere
Probably nothing you did. I had lots of random errors/warnings from stuff like vfx graph in 2021.3 when I wasnt even touching it
Check the file name and the class name, or share the code if it does match
It does match. I just copied one name into the other just to make sure
No
If you had that at the beginning of a method and there was code after it, and one of those was active, the code after would not run
That could have a profound effect
Is there an easy way to take the text in a text object and project it to a text mesh on the canvas?
wdym by "project"?
like I have it set up where I want information on the canvas to be updated based off whats in the text object
I just have to do another restart, seems to work for all these random erros, for some reason; thxs
what's the confusion here?
isn't it just destination.text = source.text?
wait....
any idea why these if statements aren't being entered? i have debugged everything
presumably the name of the object doesn't start with either of those things. Or perhaps it's not even getting to that point
i debugged and it does reach those if statements
then the name doesn't start with those
Debug.Log($"My name is {name} and do I start with RED KING? { (name.StartsWith("RED KING") ? "yes" : "no") }");```
something like this
but yeah
using object names is crazy
as is having scripts named P1_NameInput and P2_NameInput
i know its just barely getting by
name automatically refers to gameObject.name?
you can call name on any component and it will give the GameObject's name yes
then it's entering the if statements
I cant use .txt doesnt allow me to show it in a canvas unless I'm missing something
i have no idea what you mean by that
okay ill double check the code im running
make sure there aren't any exceptions happening or anything. Do you have errors showing in the console?
for some reason the first debug works but not the "game over" debug
no errors
The idea is I click on a seat lets say 1F for right now I then take that seat name and add it to the canvas where it says SEAT:. My issue is that I cant just directly connect the two because the code uses .txt which doesnt work with the textmesh
my question is there some way to have the textmesh read what is on the txt file at real time then display it?
Take a screenshot of your console
oh crap there are errors i just had them closed
this line is the issue
says object reference not set to an instance of the script
@teal viper idk if its fine to @ you
Do you set instance to anything?
It isn't automatic
You have to actually assign it. Usually to "this"
ohh right the {set: getter} thing?
ohh
No, that is for making it a property and is unrelated
YES
as broken as it is
thank you @summer stump youve helped me alot finishing this project
No prob
Yeah I asked you about that lol
yeah mb i had them closed for a long time
If I instantiate a collider just on top of a another one, does that trigger an OnTriggerEnter? It should right?
I tried this before thinking it would work, but sadly it doesn't 😅
If they intersect on instantiation, then no.
I want to instantiate an explosion with a collider and it instantly detecting any enemies inside
pretty sure it works 🤔
Try it and let us know
Why not just use Physics.OverlapSphere?
I have to deactivate the collider for a frame and then activate it?
It doesn't because the colliders never enter, they just exist and are never triggered
but colliders overlapping at the start of a scene trigger it
anyway, it's not the right approach for this problem
Cause, it is not physic based and also I already have all the logic setup up for a "DamagingCollider" script
wdym it's not physics based?
Idk abt existing ones on scene enter, but they were talking about instantiation so I assumed during play
How is it not physics based if you're using colliders?
Colliders, but not rb
that's physics
anyway the fact you don't have a Rigidbody is why it's not working
but really
Physics is not just an rb
No, no, they do
Using a collider for this is insane because you'd have to wait until the physics simulation step to react to the explosion
Then the mention of it not being physics makes even less sense now
Cause all related to damage and collisions is not using any phisics, it just to apply some very minor physic based effects such as knockback
I'm really clueless how it's not related to physics now.
If you want to call detecting collisions by just colliders and not any physic simulation beyond that such as you would do with Raycast, sure, it is physiscs
Or rather, in your understanding what would make it "physics based"?
But this is no different than taking two sprites and see if one is on top of each other
It is different, because you're relying on the physics system to calculate the collision
Not collision, trigger
Silly question, but how would I get the "Focus on Tilemap" option in Scene view?
If anything an overlap query would be "less physics based", although that really doesn't make sense.
Trigger is a type of collision
As far as I know only rb use actual physic based collisions
Ok if you're done arguing semantics, you need to use OverlapSphere
Every thing related to collisions and triggers is going through the physics system. There's no magic telling the object that it entered a trigger. It's the physics system that's doing that.
Yeah, that's to detect THIS particular case, I want this to be modular enough to allow ANY shape, that's why I am using a specific script that uses a collider
Actually, it all goes through me first because I AM the physics system 😁
You want explosions to be of different shapes..?
Why doesn't it let me add a Scene when I click "Add Open Scene" button in build settings?
Not specifically explosion, anything other than bullet basically
They all use that script
Are you currently in the scene you're trying to add? Also not a coding question
Well, then you need some distinction. You can't push abstraction to a point where you use 1 script for every single thing in your game.
Have explosions use overlap sphere. Other cases would implement logic that suits them.
My bad, and I hope I'm understanding you correctly, but I'm currently in SampleScene (the default one) and trying to add a new Scene.
The abstraction in this is: Is meant to be a zone where if either you or an enemy enter, you take damage
Then double click the new scene so that you are in it, and press add open scenes. You can also just drag and drop scenes from the assets folder into the build settings menu to add them
With some extra modularity and configurations
Then abstract the zone part, but implement the exact logic in different types of zones. Explosions would do an overlap.
you can probably swap out different mesh colliders if you want different shapes that arent primitives
no clue how doable that sounds
ty
Why can't I preassign the enemy manager in the prefab for a sentry turret?
if I try to set it to enemyManager, it says there's a type mistmatch, but the handmade turret I'm trying to prefab accepted it fine
prefabs can't reference objects in scenes
is there a way I can give the turret an Awake() to assign it, or should I do it in the blueprintManager that instantiates the turrets?
do it in the thing that instantiates turrets
Or
use the singleton pattern
EnemyManager sounds like something that would be a singleton
yeah. you can reference it directly from the class would be preferable
or via GameManager singleton such that you can dot access it via GameManager.EnemyManager
Having googled singletons, that sounds exactly correct, thank you
Oh, never mind, I am absolutelly drunk, it was not even usign a trigger Collider, how can I be so dumb?
It does work now, I just let a single frame where the colliders don't touch just to be sure
When I click the start button in my main menu, it takes me back to the same main menu, and I'm trying to get it to load the next scene. I've troubleshooted a bit like switching the Scene Load to 0 or 2 to see if the scene was labeled a different number. But it didn't work (Sorry if this sentence doesn't make a lot of sense, I'm very tired lmao)
please show the code for your start button
ive tried for soo long but isk why it is not working, any help?
that's not where you declare variables, you need to declare them inside the class
please look closer
the cheap way is to go into enemyManager, have a public static enemyManager instance, go into enemyManager's Start() and set instance = this
in any of your code you can call enemyManager.instance
which is what was suggested already. a singleton.
depends if you want to put it in game manager or enemy manager
I used to do it in game manager but I realised it's a bit of a hassle if I want to delete something
And it's also not great for multiple people to change the game manager to add their singletons in a collaboration situation
Wdym
do you know what declaring a variable means?
No
then you need to take a step back and watch this video first
What are Variables and Functions, and how do they store and process information for us? This video answers those questions!
Learn more: https://on.unity.com/3gbCR8N
when I started unity I made the mistake of immediately trying to link my code with my game, I feel that it's better to have a strong foundation in coding before starting unity
then compare where you declared your variable versus how they do it in the video
i would highly recommend you learn some basic terms for programming like variables and functions first
!learn has a rather helpful Junior Programmer path.
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
otherwise you can't understand the help that is given
Sorry it took me so long, I was in the shower. Hella short code tho
that's a * 1
very interesting way to do it
that's going to just reload the current scene
did you mean to do + 1?
also show the scene index list in your build settings
Main Menu is 0, SampleScene is 1
you should add your scene to the scene index list
yea
it's not loading the next scene in this case since it's multiplying by 1
yes
ok, so then what do you think SceneManager.GetActiveScene().buildIndex will give you?
if this is running in the MainMenu scene, GetActiveScene will refer to the MainMenu scene, correct?
Yes if I'm correct.
and you said MainMenu's buildIndex is 0
so what is 0 * 1?
0 multiplied by 1
Zero
LoadScene loads the scene yes
yeah, and what does SceneManager.LoadScene(0); mean?
Shouldn't we change it to 1 instead to load the next scene?
exactly
so do you need to pass to SceneManager.LoadScene instead?
in order to load the SampleScene
you already know SampleScene's index is 1
Pardon?
It works yippee
what does the 0 in SceneManager.LoadScene(0); refer to
Loads Scene 0 (Main Menu)
yep
But if we change it to 1 then it loads the actual game.
so to load SampleScene, as i'm sure you've figured out now, you use the scene index of SampleScene, which is 1
Can't this also be applied to a death screen? Like on collision with a certain object with a tag we can load the next scene?
sure
but i dont think you understand where the numbers are assigned to the scenes
please go to File > Build Settings
there should be a window that pops up
I'm there
can you pass me a screenshot of it please?
That's the numbers of the scene yea
yep
I understand that part
okay
so you understand what went wrong with your code?
as in why was it loading Menu instead of SampleScene earlier?
if not, it's okay. I can explain again if you'd like
not only does 0 * 1 = 0 (basic multiplication), but scene 0 is main menu and the actual game is scene 1
yep
now here's something else you can learn
documentation says SceneManager.LoadScene does this
just wanna question if any programmer is Googling too much
you can pass in the scene name instead of the index
Google more
no such thing. if anything, most aren't googling enough
Googling too little if anything..
As a programmer it's important to be able to solve your own problem by searching
I really use it even for player movement
Off topic, but why do you hate Java?
And don't use chatgpt
which means, you can do this SceneManager.LoadScene("SampleScene"); @languid saffron
Thank you kind sir.
of course this is prone to user error if you mistype the name or change the name of your scene in the future
Well use chatgpt responsibly.
So it's like a more direct way of telling the game to load the scene
i'm a ma'am, but you're very welcome. happy to share when others are happy to learn
My bad.
not so much "direct", just a different way
Java 😡
Overly verbose, lacks a lot of language features, expects users to know OOP before even stepping into the language, 2 build systems that split the open source community, users are expected to install the JRE just to run any java program,
Technically this is a more indirect way than using the build index
you can reorder the scenes in the build settings as well, so using the scene index isn't foolproof either
I did try it once. I feel the pain
I'll talk about it another day 😴
What we thinkin about my menu?
let's try to keep things on topic 🙂 this is a code channel
Very avant-garde
i'll head off now. happy developing
Hi today I tried to play around with a new tutorial that teaches you how to use netcode, and the tutorial has me so far open 2 unities, why? because its how you play and test your game to see if the multiplayer actually works and stuff, so i tested it and it worked but now because I have too many windows open, is it okay if i close one? I can still access everything through the hierarchy of one of the unity's windows
not sure how it actually works really
I mean look
I can access the Network Object component through these game objects in the hierarchy
so why do I need to keep 2 Unity windows open at the same time?
because its how you play and test your game to see if the multiplayer actually works and stuff
isn't this why?
yeah but
where is this like saved?
what will happen if I close one of them?
This is what im asking
you can always reopen it right?
how did you open the 2nd unity window the first time?
I'd assume if you close one, it's like the player disconnected
I clicked the clone button or something
soon ill have to go to sleep and continue this project tomorrow
so this is why im asking
i dont want this to get lost or whatever
you dont need to save 2 copies of anything
this is just one unity project isn't it?
and you just opened 2 instances of it, that's all
so if your project is saved, that's fine
ok ty
The new HUB doesn’t allow two Unity open at once. Only separate projects. I use ParrelSync, works nice
Me too, ❤️ it. I'm wondering if the tutorial led them on that path and confused them though
bump
hello every one, I was following the tutorial to create the custom ui line renderer by game dev guide, every thing is working fine but while adding the material the texture of the material is not being applied to it, why? here is a code snippet:
https://paste.ofcode.org/AgP6AvqCDVepQSMy7Zg3SF
Do you not get error on line 18?
your material name is m not material
@fickle plume no there is no error, and here is the attached material
yes, it's m but that must not be a problem right?
what are you assigning then?
I have assined a materail to "m" in the inspector
No, i am just overriding the material of canvasRenderer to m..thats the problem in the tutorial no material with texture is being used
@severe robin If you are using your own material don't switch it on line 18 to something else called "material" in inherited graphic class
I removed the material switching part, but still only the color tint is being applied and no texture is being shown
You are using a custom shader there, there's no guarantee it actually uses the texture.
It is not a custom shader it is built in ui shader, it is being applied correctly to an image but not to custom graphics:
Could be uvs or something
Try changing color on the image component. I'm seeing in 2023.1 it doesn't update texture taken from material unless color changed at least once
might have to trigger refresh for UI to update
bump with update, the item is moving to the player hands last position when the item is interacted with
is there a way to have a drop-down menu for your strings on the editor under the script variables? or does it have to be a seperate window
Im trying to make a drop-down menu for myself to pick from a list of enemy types when making a new enemy
I tried refreshig the ui but is not working
Can you pause after the issue occurs and check where the item is in scene view?
In terms of position and hierarchy
its all parented fine and whatever im experimenting with localmove etc right now and im getting somewhere so ill get back to you if this doesnt solve anything
thank youu!
however, enums inherently have a drop down if you just want to use those
the uv seem to be fine too.https://paste.ofcode.org/35dur7iYhH7sw9YG5Pkwk3Y
Maybe check the frame debugger for clues?
Also try playing with tiling scale
this may be a dumb question but... shouldnt this script make the enemyType variable a drop down menu in the inspector?
I think it should.🤔
Though, I don't see the whole context, so hard to say.
well, it appears as a string...
what other info do you need?
You must be looking at the wrong place, as there's no way for an enum to turn into a string.
The whole script code for starters.
As well as a screenshot of your console tab
still very much a wip btw but, here ya go.
https://paste.ofcode.org/3biaTnkmfSbkEn3My2SgNdT
oh shit I do actually- I hadnt noticed that
these two
..and the first one is still there
...I have a feeling that Im being a dumbass atm
second probably just unity being silly so just deal with the top
It tells you the line number and the issue.
