#💻┃code-beginner
1 messages · Page 698 of 1
alr thanks, is there a tutorial i can watch to install this
install it via the website...
once you have you can click "Open in Unity"
it'll launch the package manager and already be navigated to the asset..
click Install -> follow prompts..
open Demo scene
you install it the same way you install any unity package. from the package manager
alright,
so the one unity provides is like just a basic moveset for yourself
if they made you change it to none whats the point of them not having it preset to none in the first place
its there so you have a nice starting base-line..
its pretty generic and can fit lots of games right out the gate..
you also have the option to not even use the new input system..
but its there if u need..
They didn't make you change it
The fact that your tutorial predates the switch made you change it
If you were using a different tutorial, you wouldn't have had to
no im not watching the same thing i was just watching a video regarding unitys new input system
his was already set the none and he just made a whole new inputset for himself
The Input System provides tons of ways to go about the same result, not everything is going to be used by every game
ic
thats probably just so he can step thru the process, explain things a bit more.. and not just rely on people knowing what they're doing
and yea.. theres sooo many ways to use the new input system 😅 its a bit overwhelming
it is
it'll get easier the more u use it
im gonna try making a 3rd person dude move around tmrw
and see if i can use the input system correctly
you'll also find ways that you like doing inputs and ways you dont.. if u experiment enough
unity just gives u hella options..
and even more 👀 .. lol i haven't even gotten around to using the Input Module.. or the Player Input component
did the asset yall sent earlier already have a input system
the 3rd person one
if it does i think id rather try making one from scratch
and just use a bean
ill just make one myself i suppose
thats what the StarterAssets.inputactions is
both assets have the inputsystem and action mapsincluded
is there a way to play an animation based off of a number going from 0 to 1 like in a blend tree?
this first person thing does not work bro
i dragged nestedparentunpack into scene and deleted ui joystick thing and added floor but still nothing
wouldn't see why not
you can set the .normalizedTime of an Animation
that might help. I'll try that and if not make a post in the code general forum thing
use this one ^
or open the Demo scene and rob that one..
but yea, even the nested one works TLDR: it does too, bro
even if it is sorta all off-center
i have a editor plugin and in it there's a button using GUILayout.Button
i don't know how to load a texture from it's package folder tho
doesn't seem to work with relative paths Assets is not ProjectName/Assets but ProjectName/Packages/mypackage/Assets
if (
GUILayout.Button(
image: AssetDatabase.LoadAssetAtPath<Texture>(
"../Assets/Discord-Symbol-White.png"
)
)
)
{
Application.OpenURL("https://discord.com/invite/********");
}
why would the image not load without error?
try removing the prefixing ..
Packages/mypackage/Assets/Discord-Symbol-White.png
that's what's making it relative or at least it's what i would think so coming from python, the thing is i tried that as well
for the second option i don't think i can use that as it could easlily break if the user adds it to the assets instead of the packages
the reason why u dont get error is b/c it just returns null.
ah oops, i thought the button would throw an error if the texture passed to it was null
just a silent kinda whoopsie 😄
i remember from doing my editor windows. and sometimes it'd just not draw a texture at all..
would break all my formatting and everything.. but no error.. no whitespace with a little X.. nothing to let u know lol
i updated my project to unity 6 and cinemachine 3 and now i have some problems:
StarterAssetsDeployMenu.cs(6,7): error CS0246: The type or namespace name 'Cinemachine' could not be found (are you missing a using directive or an assembly reference?)
how do i fix that? thanks!
first step not working
regenerate project files
also you can get rid of the line directly above that one if you also remove the first line. you aren't using anything from the System namespace anyway and removing that line will make the using alias for the Object type redundant
how do i do that?
let me check
the Regenerate project files button
i press it and nothing happens
nothing visible happens. restart your code editor and that error should be gone. you'll still need to fix any other errors
ah, so this isn't even in your own code. this is in an asset. the asset likely uses an asmdef and would probably need the reference to cinemachine's assembly
its FEEL asset, any idea?
the asset likely uses an asmdef and would probably need the reference to cinemachine's assembly
idk how to do that
actually this would likely be more useful: https://docs.unity3d.com/Manual/assembly-definitions-referencing.html
hello
howdy.
Not a 'Social Chatroom', so, "hi" and "hello" generally go unanswered.
If you have a Unity question, feel free to !ask
:thinking: Asking Questions
:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #🔎┃find-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.
-# For more posting guidelines, go to #🌱┃start-here
it doesnt work
whats happening now ? this looks a little sketch
Anyone knows why when i press play the gun aims at the camera instead of staying to the right, been stuck on this for hours
it should follow the mouse while rotating on the z axis which it does but it rotates it 90 degrees on the y axis and snaps it towards the camera
Because you're setting the rotation to a rotation that points at the camera
In the first screenshot you have it rotated -90 degrees on the Y axis.
Your code then sets the y rotation to 0, pointing it at the camera
Rather than explicitly setting an Euler rotation like that, why not just do like cs transform.rotation = Quaternion.LookRotation(direction);
i tried changing this line to this:
transform.localRotation = Quaternion.Euler(0f, -90f, angle + 90f + rotationOffset);
i will try that too
Euler angles are cancer, just throw them out imo
Say no to eulers
Does anyone know programming, it's for this game called mindshow it's abandoned but it would be cool if YOU could make a whole new server, because the servers shut down
hmmm what do u need
A new server for mindshow
It used to be popular but now it's shut down
omg it worked!! this is so much better too because it changes directions for right and left sides thank you!!
This isn't the place for that
And if you want to make a custom server, you can always pick up some books and do it yourself
3 damn hours im never using Euler's again😭
wait i jsut got this new pc ion got steam yet
K tell me when you get it
Yes
WELL THAT LOOKES COOL
they're fine with two axis, but they create problems if you're rotating around more than one axis
lookes like it had a community
i want to paint a map in a top down unity game, for instance, a grass path with a dirt road going through it. what's a good way to do this? i don't like how angular the tile map is
did u buy the game?
can you guys take this to DMs. this is very off-topic
mb
You've the option of just using a texture across a large quad
paint it in some 3D program like blender
the texture would be massive
Actually any painting software cause the uvs arent hard to map anyway
i specialize in 3d first so it wouldn't be hard, but i don't think the method would work
well, if you're painting something big then you do a splatmap which is basically a small precision texture that maps your real texture when generating the mesh
How much are you paying
fr we wouldn't even make revenue from the game selling if it did get revived and take back off
have you guys created pseudo code for what you want to happen in a game?
Sometimes.
I sometimes start with a mix of pseudo code and natural language explanations of the implementation in comments.
if i need to pass a reference to a component to a prefab that gets instantiated how would i do that?
i need a reference to the player's transform
and it wont let me assign it in the inspector since it's a prefab
instantiate returns the instantiated object , you can do a simple DI through method to pass it
the spawner usually is already in the scene , should already have the reference to the scene component you want
what is DI?😅
[serializefield] SomeComponent someComp;
void Spawn(){
var obj = Instantiate(prefab)
obj.SetSomeComponent(someComp)```
Dependency Injection
oh no it's a gun that instantiate a bullet on mouse down, and when it hits something i want the player to teleport to that location
but i need the player's transform so i can change it to the colission location
but the bullet is a prefab
make the bullet reference the player so when it hits you can teleport it from bullet or subscribe to that event from player to bullet so bullet doesnt care about player
ooo ill try that thank you
i usually dont although it's more of a personal preference thing. if im really knee deep in spaghetti then i'll take a moment to step back and write some pseudo code. worst case scenario i'll even make a flow chart 
it worked! i got player = GameObject.Find("Player").transform; on start
nope
pretty much do not use Find ever
if you need help with what nav was explaining feel free to ask
oh wait is that not what he meant by making a reference to the player?
it was not no
then i need more context😅
what is spawning the bullets? that should already have reference to the player most likely
Your correct in that is a way to get a reference but Find is really bad since it looks through every single gameobject loaded looking for a matching name which is awful for performance, doing stuff via strings/names is also unideal since it's easy to mess up
Ideally you would have your player referenced somewhere via a [SerializeField] public inspector reference, either directly on the Spawner or on something the spawner can access
the gun, these are all the references it has
so basically i need to reference the player through the gun because the gun can also recieve the bullet as reference?
isnt the gun part of the player ?
it's a child of it in the hierarchy
hmm but all the teleport logic is on a seperate script🥲 like i made a script for the gun a script for the red bullet and a script for the blue bullet, the gun only spawns them while all the bullet logic is in their respective script
i have it set up so it calls a teleport function onDestroy
so when the blue bullet gets destroyed it will teleport the player
unless you are able to use scripts in other scripts maybe
ill have to watch a video on that
give me a sec im writing up a nice response for you 😄
In general with these kinds of problems t's more-so thinking about the chain of command here, I like to reference how a business or even like a supermarket/costco type place might operate
The Bullet's job is to teleport the Player when it hits something.
In order for the Bullet to do it's job, it needs to speak to the Player
The Bullet is managed (I say managed as in like a supermarket like job) by the Gun that shot it
The Gun's job is to shoot Bullet's when the Player asks it to shoot
The Gun is managed by the Player that's wielding it
There-for if the Bullet needs to talk to the Player, It should ask the Gun so it goes up the chain of command.
In practice I would suggest the Gun's having a reference to the Player wielding them, and the Bullet's having a reference to the Gun shooting them. This can partially be done via just [SerializeField] references but you can also set up your code to communicate this like
(Now I'll preface this code isn't perfect and some people will probably suggest doing slightly different things once your comfortable with it but for now it's fine)
Here's a quick example of what you could do
public class ExamplePlayer : MonoBehaviour
{
public ExampleGun CurrentGun;
public void EquipGun(ExampleGun newlySelectedGun)
{
CurrentGun = newlySelectedGun;
CurrentGun.OnEquipped(this);
}
}
public class ExampleGun : MonoBehaviour
{
public ExamplePlayer Player;
public ExampleBullet BulletPrefab;
public void OnEquipped(ExamplePlayer owner)
{
Player = owner;
}
public void ShootBullet()
{
ExampleBullet bullet = Instantiate(BulletPrefab);
bullet.SetOwner(this);
}
}
public class ExampleBullet : MonoBehaviour
{
public ExampleGun Gun;
public void SetOwner(ExampleGun gun)
{
Gun = gun;
}
public void OnHitWallDoTheTelportThing()
{
Gun.Player.etc
}
}
@nova kite let me know if you need anything elaborated
wowww that's so cool! and thank you for putting it in perspective with that analogy that makes it so much clearer, so bascially you make a function that set's the data you need and call that function from the "manager" passing it the data that's so clever
More or less yeah, it's very unspecific to this example so you can apply the idea of kinda going up and down the chain to a majority of code/systems 😄
that's sick thank you so much i will try it now
heyo, decided to transfer from unity version control to github, and im not very familiar with the process. i downloaded github desktop, and made a repository. then i cut all my project files to the repository folder, and when i try to commit i get this. Any tips on how to move forward ? is the recommended git lfs the way to go ? am i doing something wrong ? any tips would be appreciated : )
- Make sure you're using the unity .gitignore
- Set up git lfs
yep, i did use unity gitignore. so i am guessing it is the way to go with git lfs
thanks : )
Vector3.Dot breaks my brain i should've listened in math lessons😭
it's just the sum of component wise multiplication
it can represent how much the vectors align
i'm trying to pass it the normal from a collision point and compare it to a vector3.up from example to see which direction i should offset the player after a teleport to prevent clipping with solids
yes but it does something with cosine i read and for it to click in my brain i need to understand the math XD
i wish there was a visual representation of it haha
ohhh i found the formula it's actually pretty straight forward
Vector3.Dot(A, B) = (A.x * B.x) + (A.y * B.y) + (A.z * B.z)
There literally are if you Google dot product visualization
omg there is! xd thank you!
"damn there should be X" -> there probably is X, go google it
this is.. what i just said lol
the other representation is a.b = ||a|| ||b|| cosθ
Sadly some assets like textures, audio files and models can be large, if you CAN find ways of not having to push those and can store them some other way then that could help, otherwise as boxfriend mentioned, LFS is usually how you would handle that, though AFAIK even that has limited space for those kinds of files (for free anyway)
yeah, currently treading thru the mud rn.. reminded me why i hated git in the first place 😭 i swear id never use git if i didn't have to... and yeah, git lfs has a 5 gb limit afaik, but i think i managed it with lfs track in git bash and should be good for now
Git does take time to learn, and a lot of trial and error for sure, im sure youll get used to it and maybe even enjoy using it in the future, the nice thing is you can learn its features "as you need it" instead of trying to understand everything all at once
even with git lfs I believe you still need to follow the 100 mb file rule
also don't push like 10gbs at once, chop it up
yeah i get that, i mean, git wouldn't be popular if it was actually bad. i just never disliked learning a similar topic more than git lol
i dont think so ? yet, im still workin thru it
ill update my revelations
There is some limitation I know for sure cause if I do try to cram everything in a single commit it'll drop it
This has kept happening btw, not really sure if I should worry about it, but doesn't seem to prevent anything from working anyways, so dunno
How are you removing the element? In an editor script or something like OnValidate?
sounds like the post limit thing, a client side option
apparently that's only applicable to HTTP/1.0 connections
I am removing it directly on runtime
Like on a method that sorts the inventory and what is being equipped
SerializedProperty is more of an editor thing to draw those properties on the editor so it's either Unity being Unity or you're somehow modifying the non-runtime instance as you run the game.
There's one other scenario I can think of and is editing the prefab instance at the runtime, which shouldnt affect the editor instance but potentially can throw some fake warnings like that
yep, i tried twice to push, and its giving a "remote disconnected, check internet" error.. im guessing its the size limit but like gahh damnnnn
I don't think anything of that is being done, no
Like this is the kind of list I am modifying, but I don't think I am doing anything weird like that tbh
And you're sure you're instantiating the prefab and not editing the prefab instance you referenced?
I am not using any prefab on this logic, yet
This is meant to run on InventoryItems as prefab, but as of now, I am only testing it with on scene items
So.... I don't know how I could even be doing that
If it's already on the scene then it would be a unique instance so that wouldn't be a problem
so I'm going to go with Unity is just being Unity and reset the editor.
Yeah, like this was happening last night too, so, that why I am asking again
I surely must be doing something weird
are you able to replicate a minimal test case where this happens? this is where i try to start. for example, replicate that same structure with SortedList<GearRarity, List<int>> and 2 lists to try to see if you can get the same error. It's more likely a unity bug tbh
Mmmm, I mean, the specific case is kinda complex tbh, I'll have a hard time replicating it
Like it's like referencing a item inside a different item and kinda adding and removing itmes from a bunch of list simultanenously, so....
Could it have anything to do with deactivating the gameObject?
thats why you make a minimal test case. to avoid all the complex logic that could be completely unrelated to your setup. Start with a SortedList<GearRarity, List<int>> and do similar operations adding to the list and see what exactly causes it. If you have no clue what line of code causes it, you need to figure that out
I mean, I did that, I was implementing the very basic stuff first and seemed to work
then add more to your minimal test case until you can replicate the bug
it could be a unity bug related to how you're using the lists. it could be due to the gameObject being inactive. The way you remove uncertainty here is by testing. You dont just stare at the code to fix things
If you feel you cant fix it and theres nothing strange you're doing, then submit a bug report
Mmmm, yeah, I have a hard time even replicating it now, like it happens SOMETIMES
Like for no apparent reason
I'll keep note of when exactly happens when it shows
even for a bug report you typically wouldnt want to wait for them to fix it though. if you're on a old unity version too then maybe it was already fixed in a later version
I do see some similar posts online related to your error but most just link to a unity bug tracker at the end, fixing stuff in the 2021/2022 version
I think I am on the 22 currently actually
So it should be fixed if that's like the same thing
I'm really bad with math😭😭
dk how i passed calc 2
Ok, so how tf, is passing me variable not assigned on the console when I can call it's name on awake, I know it's there and I am checking the freaking inspector and it is indeeda assigned???
without code and/or pics no one can help
is that the inspector of the one throwing
I was checking if it I was just coincidentally using one that was not assigned
But it happens on everyone even tho they are all assigned
when is this code running
Can someone help me?
so my unity wont download versions and I don't know why and it happens with every version.
On click, basically, it's a button
debug pause when the selectedicon is null and look in the inspector
Are there any tickets I can get this sorted out in the server?
Oh, ah, wait, I think it's cause I tried to change what method was called with the button with the multiselect, and it's trying to call a method from a different one
Mmmm, letting apart that setting it manually is kinda annoying, that still should work I think
Can someone please help me??? @frigid sequoia?
fine
Yeah, it keeps returning it null, although it is assigned on the time it's being called
Ok, so this is what I am calling with the button. That print does show without miss ref
At this point it calls it a missing ref
What line throws the nre?
This does nothing at all with that parameter, and checked that it is still showing on the inspector, even after the call
The last one on the second image
So selected icon was null?
It was null there, but on the print that looks for its parent seems to be alright
does the SETSELECTEDSLOT change anythhing?
It's a gameObject btw, not sure if that's relevant
Should do nothing with the icon other than call the rest of icons to not show
The print whatever likely isn't related to this referenced variable that's throwing null. You need to figure out when you're assigning the variable and how it isn't being assigned a valid reference
But not change the reference at all
The variable is assigned on the editor and it's shotting missing ref when I am not removing it at any point
this statement cannot be true
After the what? The null reference?
Yeah, I know lol
am i seeing this wrong ? it seems like for NRE in the print you are using the transform parent while the rest of the code seems to not use it.
The parent might be null
You very likely are removing or destroying it at some point.
You need to comply with the error and figure out when/where you're removing/destroying it.
No, no, the parent is to tell them apart cause they all have the same child name. I am just trying to check if the object is not null with that call
Yeah but like... It's not being removed? Like, it's there. How?
It's likely referring to a different instance
When your inspector doesn't match the error, it likely is referring to different instances (or race conditions).
Mmmm, makes sense, but there is no other instance that could be created that I know of
your debugging, your too smart to rely on a "that i know of" 😛
Can I get like the id of the object to be 100% sure?
you should use Debug.Log instead, it lets you send a 2nd parameter for the unity object to highlight. when you press the log in console, it will highlight which game object sent this log
Debug.Log(..., this);
Before the error line.. log this: cs Debug.Log($"Click this message prior to the error message to highlight the object yellow.", this);
Oh, so that's just like an overcharge of Debug.Log?
Is that a thing?
That's very usefull
Basic debugging 101.
I was just seding prints with the names lol
https://docs.unity3d.com/6000.1/Documentation/ScriptReference/Debug.Log.html
yes an overload, not overcharge
Which object is highlighted yellow?
Check the inspector for that object and figure out why the field was null when the line had executed.
OOOOH, I see, it was actually happening on the second loop where it just dissables all other icons throught an event
There was an old version of the script I missed to delete lost between objects
remember
making mistakes: natural
making assumptions: sinful
😄
Ok, that thing of the Debug is very usefull, thxs
i forgot about the physics materials and spent 7 hours creating a whole bounce method oh my god💀
i learned a lot at least😭 trying to debug why it slides up the wall when i shoot it at a 90 degrees angle i saw on google someone mentioning the bounce material and i felt so dumb hahahah
hii can someone help me? i dont know how to make my character "rotate"
[RequireComponent(typeof(Rigidbody))]
public class PlayerMovement : MonoBehaviour
{
public float walkSpeed = 3f;
public float runSpeed = 6f;
public float blendSpeed = 5f; // for smooth interpolation
Rigidbody rb;
Animator anim;
Vector3 input;
float targetSpeed = 0f;
float currentSpeed = 0f;
void Awake()
{
rb = GetComponent<Rigidbody>();
anim = GetComponent<Animator>();
}
void Update()
{
input = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical")).normalized;
// Determine target speed
if (input.magnitude > 0f)
targetSpeed = Input.GetKey(KeyCode.LeftShift) ? runSpeed : walkSpeed;
else
targetSpeed = 0f;
// Smooth blend between speeds
currentSpeed = Mathf.Lerp(currentSpeed, targetSpeed, blendSpeed * Time.deltaTime);
// Update Animator parameter
float speedNorm = currentSpeed / runSpeed; // normalized 0 to 1
anim.SetFloat("Speed", speedNorm);
}
void FixedUpdate()
{
Vector3 movement = input * currentSpeed;
rb.MovePosition(rb.position + movement * Time.fixedDeltaTime);
}
}```
Hmm are you going for a first person or third person mode?
third person mode
Have you tried
? There ought to be some sort of tutorial that can help you with your particular type game.
yes
Did they not work for you?
no
How so? Where did you get stuck?
A third person controller requires a good amount of setting up that it makes it hard to teach it to you over discord. you should look at a tutorial for making a third person controller.
it just says "error"
Maybe you ought to show the error?
So do you see what it says after the colon(:)?
it gives me differents error for every scripts
yes
You'd fix the first error in the console window from top to bottom if possible
how?
So do you see why it's upset with that line?
member names cannot be the same as their enclosing type
Meaning the name of a member in the class cannot be the same as the name of the class.
okayy
using UnityEngine;
[RequireComponent(typeof(Rigidbody))]
public class PlayerMovement : MonoBehaviour
{
public float walkSpeed = 3f;
public float runSpeed = 6f;
public float blendSpeed = 5f; // for smooth interpolation
Rigidbody rb;
Animator anim;
Vector3 input;
float targetSpeed = 0f;
float currentSpeed = 0f;
void Awake()
{
rb = GetComponent<Rigidbody>();
anim = GetComponent<Animator>();
}
void Update()
{
input = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical")).normalized;
// Determine target speed
if (input.magnitude > 0f)
targetSpeed = Input.GetKey(KeyCode.LeftShift) ? runSpeed : walkSpeed;
else
targetSpeed = 0f;
// Smooth blend between speeds
currentSpeed = Mathf.Lerp(currentSpeed, targetSpeed, blendSpeed * Time.deltaTime);
// Update Animator parameter
float speedNorm = currentSpeed / runSpeed; // normalized 0 to 1
anim.SetFloat("Speed", speedNorm);
}
void FixedUpdate()
{
Vector3 movement = input * currentSpeed;
rb.MovePosition(rb.position + movement * Time.fixedDeltaTime);
}
public class PlayerMovement : MonoBehaviour {
public float forceAmount = 10f;
private Rigidbody rb;
void Start() {
rb = GetComponent<Rigidbody>();
}
void FixedUpdate() {
float x = Input.GetAxis("Horizontal");
float z = Input.GetAxis("Vertical");
Vector3 force = new Vector3(x, 0f, z) * forceAmount;
rb.AddForce(force);
}
}
}
so what do i change?(im stupid)
Well... look at the error again and see what the name of the script and line is first: (error shown here) #💻┃code-beginner message
|| Character script. Line 47. Character 18.||
How to post !code btw so folks can properly help you ought. I won't be here much longer.
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 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.
Anything more than a couple of lines should be posted using the Large Code Blocks instruction rather than the inline with respects to others and the server channel.
mhm ok thank u
so do I delete it?
Folks will need to see the character script to properly be able to help you.
The player movement script above isn't where the error is present.
i deleted it but theres another error
ok im tired my character doesnt need to rotate
question to everyone on here, where did you learn level design? not the actual sprites but like coming up with the ideas for the level
this is the hardest part XD
This is a code channel. Create a thread in #💻┃unity-talk if you want to discuss that.
@rough sluice This is a code channel, and don't cross-post, please.
Ok, I will take care next time. Do I post that in ui-ux channel?
You've already posted it
Yes, I was just confirminng
Hi
Now I used unreal engine
I meant to say goodbye because I was using Unity now I'm using Unreal Engine
it's not an airport, your departure does not need announcing - no one cares
You're not forced to use just one tool either. I can use multiple engines as the need arises.
Not completeley programming related, but I have a shader that can be used to fade an object out that should be used by every entity (for example, when spawning I want entities to fade in)
It has an albedo texture, metallic texture, etc as inputs to basically act like a normal material
However, setting these in the editor changes all objects that use the material
As far as I know my 2 options are to duplicate the material or to create a script to assign the material properties at runtime
My 2 questions are which option is better, and if it's possible for this script to also run once in the editor so I can see how my entities look without having to enter play mode
Thanks
hey, i recently updated my project from unity 2022 to unity 6 and Cinemachine 2 to 3, and my third person asset (from unity asset store) is giving an error. In the documentation of cinemachine, they said that you have to change "using Cinemachine" to "using Unity.Cinemachine". But as you can see, it doesnt work. Do you have any idea to fix that issue? This is the link of the asset : https://assetstore.unity.com/packages/essentials/starter-assets-thirdperson-updates-in-new-charactercontroller-pa-196526 . Thanks!
Delete the asset from your PC (c:/users/<user>/appdata/roaming/unity/assetstore-5.x/<publisher>/<asset>) and then redownload it.
Assuming you haven't already downloaded this asset with Unity 6, the version you already have on your PC is from pre-Unity 6 and not the package for Unity 6. Hopefully doing this just has the asset setup correctly
okay im gonna try it, thanks
i tried installing this version: https://assetstore.unity.com/packages/essentials/starter-assets-character-controllers-urp-267961#reviews
and now it works
that's a different asset
but now it works xd
any idea why this looks like that?
with that horizontal line
you'll have an idea why it does that if you put your cursor over it and read the tooltip
it says to chane "CinemachineVirtualCamera " to "CinemachineCamera" but idk if that will give an error or someting else
why not just 
ctrl+z is always a thing
Cinemachine 3 doesn't call them virtual cameras. That's why it's telling you that.
i think i will let it just "CinemachineVirtualCamera" instead of change aaaaalllll of the declarations
is not giving any error so...
😄
You can refactor to just change all occurences
I mean you can do that but then you should probably be on Cinemachine 2.
Probably better to do than use a deprecated definition that may later introduce issues
you should be using version control ..
Quick bump
You would need to duplicate the material via code as well(or rather, it would be done automatically if you access the material property). So there's no going around it.
30gb project, my git is tired
i have a copy safe so chill
Can potentially use https://docs.unity3d.com/6000.1/Documentation/ScriptReference/MaterialPropertyBlock.html ?
Oh right, I see
From a disk space perspective I'm not too bothered (I'm deploying to WebGL) but for performance reasons is it essentially the same to just duplicate my material in the assets menu?
essentially i want to add a developer console to my game and intialize any variables everytime my game runs from any scene.
i thought the method OnRuntimeMethodLoad() would work fine. and it does, for my variables. however, i cant actually instansiate anything in that method since it is static. what should i be doing instead?
Would also add some extra customisability to certain materials, but most materials just need standard PBR maps so I'm just curious
Yes. Using a material property block might be better. But I'm not very accustomed to them, so can't say what pitfalls await you if you use them.
Oh right, I saw this is usable as well
I saw an example of how to do this at runtime but is it possible to have this in the editor as well so I can preview how my game looks?
I used shadergraph to make the fade material, which essentially just adds some alpha and changes the alpha clip threshold with accordance to a "_Fade" parameter
I mean it should work with an editor script
Is that the right approach?
The material property block I mean
Right let me search how that works
Oh yeah this looks perfect, tysm
It does essentially say this is the right way to inherit from a base material and alter certain properties
i do be forgetting they exist lol
Can someone tell me that why "Player" object is not moving when holding moving buttons?:
using UnityEngine;
public class PlayerConntrolsFunctioning : MonoBehaviour
{
public float speed = 5f;
private bool moveLeft, moveRight, moveUp, moveDown;
void Update()
{
Vector3 movement = Vector3.zero;
if (moveLeft) movement.x -= 1;
if (moveRight) movement.x += 1;
if (moveUp) movement.y += 1;
if (moveDown) movement.y -= 1;
transform.Translate(movement.normalized * speed * Time.deltaTime);
}
public void OnLeftButtonDown() => moveLeft = true;
public void OnLeftButtonUp() => moveLeft = false;
public void OnRightButtonDown() => moveRight = true;
public void OnRightButtonUp() => moveRight = false;
public void OnUpButtonDown() => moveUp = true;
public void OnUpButtonUp() => moveUp = false;
public void OnDownButtonDown() => moveDown = true;
public void OnDownButtonUp() => moveDown = false;
}
Found it because currently I am new and trying to learn
can someone confirm that this is bad practise?
I'd never do it this way
So what should I do?
the bools are the same thing as having numbered variables
are those even magic methods that work?
just use a merged structure, specifically a vector2 in this case
(i would guess the buttons are hooked up with unity events)
oh wait that wouldn't work with the release
welp 🤷
That might be partly why it's not working.. nothing is calling those methods? 😄
take a look at the new input system and implement that instead
#🖱️┃input-system if you have any questions.
shader questions go in #1390346776804069396 - pls delete and post there
(and actually say what's wrong)
Thanks
How can I check if an object reference is None?
== null
Hmm that's what I've been trying
It appears this is not null, even though it doesn't reference an object
Either you're doing something wrong or checking the wrong object
Hmm, okay thanks
Is this a transform or a vector3 cause vectors can't be null they go to 0
it is a FightPosition (or perhaps fightPosition) as indicated by the type in the parens
No clue wtf a Fight Position is
it's a custom type
it is specific to their project or perhaps some asset used in the project
Fair
How Can I build a drag limb system like in mount your friends?
The problem is that I couldnt think how can I solve the drag and I can only select the front point others cannot be selected as you can see while I hover.I want to stick and move in walls with that mechanic.
Could someone here actually teach me how to make something nice or atleast working in unity right now I'm being just fed answer and I don't know what the stuff even means
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
learning kinda starts with you though
if you don't understand something, start googling or asking, instead of just accepting it blindly
Problem with like tutorials and unity learn is if I need to know more about something it isn't gonna answer me it's only teaching what it has or smth like that
And it's very hard for me to learn like that for some reason I just need someone to actually teach me or have someone that I can ask questions while reading let's say Unity learn
well, if you need to know more about something then you should research it
Unity Learn will provide you the basics to start, it's up to you to continue
you can always ask questions here in the Discord server, having a private tutor is a different thing though
Do Unity 6.1 and Unity 6.0 Have a big difference?
not that much .. also this is a code channel, not a general chat about Unity -> #💻┃unity-talk
I'm trying to learn about how to code in unity and similar stuff but I use Unity 6.1 and my tutorial is in 6.0 so I do think it's more relevant to code than just talk.
"zero" difference in code between the two
You'd be better using the same version as the tutorial you're following. 6.0 is also LTS, which means it is long term support, 6.1 is going to lose support at some point this year when 6.2 comes out
Hey guys, im following this tutorial series: https://www.youtube.com/watch?v=lGxXQzE5Vu8&t=463s
and using this asset: https://assetstore.unity.com/packages/essentials/starter-assets-character-controllers-urp-267961
The problem is that the second player (the one in the right) is controlled by gamepad but it takes the camera of the first player (keyboard and mouse) to move. Its quite hard to explain but with this asset, the player moves with the camera, depending where do you look you move in the direction. Im doing exactly the same as the tutorial ones, but it doesnt work correctly, any idea to solve that? thanks!
Yep this 🙂
Got it working now, thanks for the support
We're all still text on a screen. What difference does it make if you read it here or in the documentation?
A fightPosition is an object which can contain a player who's fighting. It's for creating formations. And yes, it's custom 🙂
Hey guys, I'm just a bit confused about rotation, I have this line on an Update loop, but it seems to be setting the rotation rather than constantly rotating the object
transform.rotation = Quaternion.Euler(0, 0, transform.rotation.z + rotationSpeed);
I'll multiply rotationSpeed by Time.deltaTime, don't worry
transform.rotation is a Quaternion
I have this issue where when I press R twice it enables the ball controller script which I don't want any ideas why its doing this? https://paste.ofcode.org/Ptt85JJMwdvgcVQCEJb4jC
unless you have a degree in math you probably don't want to access quaternion components
it seems like you were looking for eulerRotation.z
or whatever the name is i forget what exactly
Use transform.Rotate instead of calculating the rotation yourself
Oh thank you
Yeah, probably
can some1 take a look of this pls?
Do you have a camera object?
oh my bad
lemme read
i send the video
Okay so, you have two players. Player1 moves with keyboard and mouse while Player2 moves with the gamepad. The problem is that Player2 is using Player1's camera?
Hold on, I'm actually not sure if I understand the problem
does any on know how to do athenication in unity like liogin/ Sign up
On the video it seems pretty normal?
Could you describe it a bit more detailedly?
in my video you can see that the player2 moves when i move the player1 camera
i mean moves in that direction
oh
oh it actually physically moves when you just move your mouse?
yes
i mean
i can move it withou moving the mouse
and the joystick moves the camera
but the direction to moves depends in the mouse (camera of player1)
oooh
Okay so
The camera rotation of Player1 influences the direction (though not the camera!) of Player2
ye
look first video
and check when i move the camera of player1( left) the player2 rotates while moving
and if i move the camera of player2, it ignores it
I think, maybe check the ThirdPersonController script
there must be some place where the direction of the player is influenced by the direction of the camera
there is probably something wrong with that
yes
but this is the default script from unity xd
and i thinks its the asset they use in the video
so there is no sense
I FIX IT!!!!!!!!!!
i just assigned the camera by serializablefield
not finding the main camera object bc we have 2 main cameras
lmao nice
Can anyone tell me if i should learn C# in general first or learn it directly with unity? (Code Monkey's channel)
I personally would say it's better to learn fundamental computer science
Because then, every tutorial feels easier
and more understandable
i thought learning by doing would be best
I personally would recommend the CS50 course, which is free on EdX and features problem sets for you to solve
Depends on the person, I'd say
Actually doing stuff can be very very good at teaching you things, and that's why I love game jams
But you can't just join a painting competition to learn how to hold your brush
You might learn new styles or new techniques, but if you don't even know how to make a stroke on the canvas, then it might not be for you just yet
Does that make sense?
👍 thx for the help, lemme check what's CS50
Awesome, I'm glad to have helped you
you would be learning by doing either way, you would just be doing c# first. Theres resources pinned in the channel
Does anyone have any idea's why this is happening? I can't seem to figure it out
What does pressing R do?
to switch camera's
Presumably, because R is bound to this action: switcherAction.action.WasPerformedThisFrame()
I know that my issue is when I change cameras to the cube and I press R really quickly it disables the cubecontroller like in the video shown
Well, lazy solution might be to not let the R do anything until the camera is fully switched?
I'm not too sure how your project works
That's the opposite of what you said in the original message.
Anyways, pressing the key toggles between enabled and disabled state, so it makes sense.
To understand more, add logs or breakpoints.
what if I add a check in SetMainCameraActive(true) to only enable BallController if it was the active object meaning only if the camera is currently following the ball.
I'm going to try this to see if it stops the issue
I'm scrolled up, but I don't if see the correct term has been said .eulerAngles
It worked!
i dont get how does multiplying float by Vector3 works
somewhere that you don't see, it'll probably automatically do x * float, y * float, z * float - which would be tedious to have to type out every time
finally it works, thanks to all of that ppl that helped me! Apreciate your time!
Overloaded operator, looks like this:
public static Vector3 operator*(float d, Vector3 a) { return new Vector3(a.x * d, a.y * d, a.z * d); }
https://github.com/Unity-Technologies/UnityCsReference/blob/master/Runtime/Export/Math/Vector3.cs
oh thank you
The scripting api also includes the operator overloads https://docs.unity3d.com/6000.1/Documentation/ScriptReference/Vector3-operator_multiply.html
Note that there are two overloads, one for each direction to allow both float * Vector3 and Vector3 * float
i upgrated cinemachine 2 to 3 and now gives this error:
Can someone told me what i have to put there? thanks
What's the IDE say?
Well there you go
so i put Cinemachinecamera right?
The CinemachineFreeLook component no longer exists. It's part of CinemachineCamera now
Sounds like you want to change something related to one of the input axes. Which component on the object might you look at for information about an input axis
idk, im new using CM3 and idk how to change the velocity of the Vertical Axes
i know i can change the accel time there but idk how to change the speed
Check the Input Actions you have defined for these inputs
I was wondering how I can make it so when I change to the cube and I leave the zone the isinsidetrigger should be false. any ideas? PlayerSwitcher script = https://paste.ofcode.org/UJ2BFfSJCJmnXYXx8RkHuQ
Ontriggerscript = https://paste.ofcode.org/s8fa9jaASHAfKGY5ubb34F
Looks like the log in your OnTriggerExit isn't running which means one of those two conditions isn't being met. Maybe try logging before the if statements to see what those values are
Wait im dumb I just placed the isinsidetrigger outside of the ifcamremove statement now it works
got it to work now, dw ty for the help
one more question tho, i installed the cinemachine package and followed a guide
all the guides seem to have some virtual camera component where u can drag an object onto the follow section
but i think those guides are a bit outdated cuz they had a cinemachine version 2
and rn its 3.14
How do I include logic inside of a UI Document that would be a part of it and belong to that specific instance of UI Document when I place it somewhere even if there are multiple instances of it in the same document. This logic should be able to call events and affect UI Document
Does anyone know why this is happening?
- I created a ImportPreset (First Image)
- I set in as the default importer and set the filter (Second Image)
- I deleted the files I had imported before. And imported the files again.
- Every file is correctly configured in the inspector, and correctly sliced in the Sprite Editor. But every Slice has the same name as the sprite that was used in the ImportPreset. (Image 3 and 4)
How do you implement a switch, where it takes input as cases? (quick event related stuff)
I be throwing it at Update and its all spaghetti
gonna need some more context, what are you trying to achieve with the switch/case?
not a code question, #💻┃unity-talk or #🔀┃art-asset-workflow
Is there a line of code to pause the game for debugging purposes? Similar to clicking the pause button in the unity editor?
Time.TimeScale = 0; i think
no, that's not very similar
https://docs.unity3d.com/6000.1/Documentation/ScriptReference/Debug.Break.html is apparently a thing
also timeScale was the right casing
Yeah timeScale was correct, but it works awesome, thanks @rough granite
Fair i guess it only stops a few stuff huh
timeScale does not prevent updating. it just factors into deltaTimeand fixedDeltaTime every frame/tick
you are still updating every frame (which isn't great if you want to actually freeze stuff to check values)
if you want to actually pause, that's an editor/debug thing
also of course,timeScale does not affect unscaledDeltaTime/unscaledTime
and it messes with whatever other stuff you might be using timeScale for
Got any tips on how to do this from code?
yeah, google gave this
wow, now this is exactly what I was after, thanks a lot
i assume it acts like a breakpoint rather than pausing, but a much closer effect than setting time scale
(though i haven't used breakpoints, maybe they just work via pausing lol)
Can't you debug and put breakpoints in your ide?
I need to debug variables set at an exact time, so Debug.Break(); works exactly like I need it to
breakpoints would also work for the same purpose
I'll look it up, thanks
nvm I don't seem to understand the process yet 🫠
what are you trying to achieve in general?
I'm trying to make a "input the correct arrow key"
basically go through a few rounds of input left or right arrow, and score tells you how well you did
my attempt so far
(yes switch cases isn't my only problem lol)
Hur går man in i servern
this is an english-only server
yeah switch cases probably won't really help you here
ooooof
think about the logic flow
what's the best approach for this?
there's no best
might be something like this (spoilered in case you want to figure it out first)
||quicktimeevent(correct, time): while (elapsedTime < time) if input correct [correct answer] else if input other [incorrect answer] [timeout](where the [correct answer]/[incorrect answer] might return, so they wouldn't hit the timeout branch, or you could have extra logic to make sure timeout doesn't happen after one of the others as it breaks)||
Can someone help me learn to use unity and visual studio code
we can help you with your questions
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
Once you read up a bit and start using it, there are very skilled people here who can help you when you run into trouble
revert to 2.x or read the changes from 2.x to 3.x
https://docs.unity3d.com/Packages/com.unity.cinemachine@3.0/manual/CinemachineUpgradeFrom2.html
Thanks
(sorry had to go somewhere real quick when you posted this )
I have not learnt this yet, I was think if statements will be enough, but inputs are still a tricky one to work with, buttons maybe would've been easier
I'll learn this quick time event thing
Thanks ✨ 🙏
can anyone help?, im trying to make a cloud system using a particle system
for a cloud sprite i have
but i have no idea how to make the cloud sprite the particles
so i can move it across the screen
how is that a coding question?
Is there a code system built into unity
Define "built into unity"
And, actually, also define "Code system"
Do you have to install something completely different to put code into the game or can you code the game in unity
Unity doesn't ship with an embedded code editor (though it offers to install Visual Studio by default), but handles building the code itself.
I'm trying to read from arduino serial port any idea why this isnt working
using UnityEngine;
using System.IO.Ports;
using System.Collections;
public class SerialLatestLine : MonoBehaviour
{
SerialPort serialPort;
public string portName = "COM4";
public int baudRate = 19200;
string receivedString;
void Start()
{
serialPort = new SerialPort(portName, baudRate);
serialPort.Open();
//serialPort.ReadTimeout = 50;
}
void Update()
{
receivedString = serialPort.ReadLine();
Debug.Log("Received: " + receivedString);
}
/*void OnApplicationQuit()
{
if (serialPort != null && serialPort.IsOpen)
{
serialPort.Close();
}
}*/
}
arduino script if anyone's intersted:
#include <Arduino.h>
const int trigPin = 9;
const int echoPin = 10;
const int buttonPin = 2;
void setup() {
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(buttonPin, INPUT_PULLUP);
Serial.begin(19200);
}
void loop() {
if (digitalRead(buttonPin) == LOW) {
long duration, distance;
// Send trigger pulse
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Read echo
duration = pulseIn(echoPin, HIGH);
distance = duration * 0.034 / 2;
// Send to PC
Serial.println(distance);
delay(200);
}
}
how would i add text to an existing TMPro object? for example, i want it to keep the text that's already there and just add an exclamation mark
You can add strings with +, but you need to add it to a string. Right now you're adding "!" to nothing
yeee i know this is wrong, how do i access the string data that the object is currently holding?
.text
I'm really scratching my head here. I know I'm not providing a lot of context here and I apologise, but I'll figure it out on my own if it's not obvious to anyone else. but can anyone see why this wouldn't ever execute past "yield return new WaitForSeconds(1);". everything up until that is executing, and then it stops at the yield check, and never resumes. nothing is externally deleting the object this script is on or anything like that either
{
int previewBoxesActive = peoplePage.transform.childCount;
for (int i = 0; i < previewBoxesActive; i++)
{
Destroy(peoplePage.transform.GetChild(i).gameObject);
}
journalManager.tabAnimationPlaying = true;
yield return new WaitForSeconds(1);
Debug.Log("peoplemanager finished");
Destroy(gameObject);
}```
Is the object that is running this coroutine ever disabled, or do you ever change Time.timeScale
so itemsHUDText.text = itemsHUDText.text + "!";?
it's code i can't explicitly test rn
is there a way to check if a tmpro text already contains a specific character?
.Contains
nope, timescale is 1 and the object is never disabled. I'm stumped. I've changed the yield return back to
yield return new WaitUntil (() => journalManager.tabAnimationPlaying = false);
as it is intended to be and this still just won't ever trigger, even though I can see visibly that it has not turned off
What does any of this mean
thank youuu
Huh this makes no sence
I don’t understand it
Put it back to the WaitForSeconds, add this line right before it:
Debug.Log($"{gameObject.name} is starting a pause. Timescale is {Time.timeScale}", this);
Also add this to that script:
void OnDisable(){
Debug.Log($"{gameObject.name} is being disabled.", this);
}
(If the script already has an OnDisable function, instead add that log to it instead of making a new one)
thanks v much for the help on this, this debug appears and then nothing else
When you click on it, it should highlight an object in the hierarchy. Does it?
nah, it doesn't, but none of my debug messages do that. it just opens up the script in visualstudio
Single click not double
Click on it once, it should highlight something because I added the , this as the second parameter
ah right, didn't realise adding 'this' would do that. it doesn't highlight it, no
If nothing highlights, then the object printing that log does not exist in the scene
Which would be the reason the yield isn't working
Where is the coroutine actually being started from?
actually, it does highlight the object. my apologies, I just didn't realise it only seems to do it on the first click
if the object that the coroutine is being started on is deleted, does that kill the coroutine then?
well, suspend it
Yes, whatever MonoBehaviour you call StartCoroutine on will be the one it's lifetime is attached to
you'll have to click off it (refocus) for it to highlight again..
o h my go DDDDDDDDDDDDDD well now I know why it isn't working 😭
yup, monobehaviour is required to run the routine...
its the one that calls it as box mentioned
the object that starts it is being killed right here
Then why did you specifically say you weren't
thank you all very much for the help and learning moment @slender nymph @polar acorn @rocky canyon
the script isn't on the object that's being deleted, what's being deleted is the object that calls this coroutine, externally
👍 i just noticed ur doing embedded work..
PlatformIO in VSCode is the IDE i use for that.. (easier for me to toggle back and forth from each type of project)
just my personal opinion tho
try using
serialPort.DtrEnable = true;
serialPort.RtsEnable = true; ```
you might also need to set read/write timeout
should I just put it in setup
in start
where you create a new SerialPort object
btw idrk how this stuff works I kinda just got the timeout from chatgpt
any idea how to implement that?
its just the ms time when it will timeout with data read/write . Always best to check the documentation it explains it a bit more and some examples
https://learn.microsoft.com/en-us/dotnet/api/system.io.ports.serialport.readtimeout?view=net-9.0-pp
also my project glitched out and it no longer enters run mode (loads infinitely) should I delete the library file and try again
if you mean when you press play it freeze its probably some infinite loop happening
here is my new code and I'm continuosly getting an operator timeout error
using UnityEngine;
using System.IO.Ports;
using System.Collections;
public class SerialLatestLine : MonoBehaviour
{
SerialPort serialPort;
public string portName = "COM4";
public int baudRate = 9600;
string receivedString;
void Start()
{
serialPort = new SerialPort(portName, baudRate);
serialPort.DtrEnable = true;
serialPort.RtsEnable = true;
serialPort.Open();
serialPort.ReadTimeout = 500;
serialPort.WriteTimeout = 500;
}
void Update()
{
receivedString = serialPort.ReadLine();
Debug.Log("Received: " + receivedString);
}
/*void OnApplicationQuit()
{
if (serialPort != null && serialPort.IsOpen)
{
serialPort.Close();
}
}*/
}
error:
TimeoutException: The operation has timed out.
System.IO.Ports.WinSerialStream.Read (System.Byte[] buffer, System.Int32 offset, System.Int32 count) (at <ccc5c248f714451b8d635b2be267cc2e>:0)
System.IO.Ports.SerialPort.read_byte () (at <ccc5c248f714451b8d635b2be267cc2e>:0)
System.IO.Ports.SerialPort.ReadTo (System.String value) (at <ccc5c248f714451b8d635b2be267cc2e>:0)
System.IO.Ports.SerialPort.ReadLine () (at <ccc5c248f714451b8d635b2be267cc2e>:0)
(wrapper remoting-invoke-with-check) System.IO.Ports.SerialPort.ReadLine()
SerialLatestLine.Update () (at Assets/Scripts/SerialLatestLine.cs:24)
What is this????
I see your useing C#
I think
oh nvm that was on me for not starting the serial logger thx for your time @rich adder
yes
your solution worked
is working now ? btw you should add some extra check
Can I get a bit of help some time you look like your good at coding
yeah its good. one final thing when I'm not inputting something I keep getting the timeout exception logged but everything works should I put it in a try statement and catch the error
I can try but I'm not bery good @rich adder is much better
you should probably be checking if there is data to read first
if(serialPort.bytesToRead > 0) or something like that
I just need help getting started
so maybe if(serialport.BytesToRead)
oh ok thx
👇 !learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
check the pins as well
I recommend the junior programmer pathway
this isn't a server for tutoring
I don’t even know how to use the console
thats what learning is for
it teaches you everything in this one https://learn.unity.com/pathway/junior-programmer
Free tutorials, courses, and guided pathways for mastering real-time 3D development skills to make video games, VR, AR, and more.
okay so what do you want. Do it when you get to a computer
and you don't have to be obnoxiously spamming the channel 🙂
I am not, I just need a little help
please read the #📖┃code-of-conduct and don't be posting reaction images. Mods wont appreciate that as well
Hey so um I'm kinda losing my mind atm over this...
When I load into a scene it for some reason is in the state that it was when I switched off it
Is there a way to reset it?
So
Scene 1 > Scene 2 > Scene 1 again but it is as it was left off before switching to scene 2
If you're not at a computer to do Unity Learn then you definitely aren't at a computer to be using Unity.
Also this channel is called code beginner
So, learn it when you are
I am not on unity
mhm exactly. so when you have an actual coding question, you may post, accordingly following the server rules
Anyone?
I tried unloading it with UnloadSceneAsync
But it doesn't do anything
SceneManager.UnloadSceneAsync("SampleScene");
SceneManager.LoadScene("MainMenu", LoadSceneMode.Single);```
wdym "is in the state that it was when I switched off it"
Now that shouldn't be happening unless you're using additive scene loading, or you've put all your data into ScriptableObjects or Prefabs to store all your data
its just as i left it
it doesnt revert to its original state
are you loading them through code or just double clicking
code
Can you take a screenshot of your Unity editor after loading the scene for the second time? Whole window, and with the console visible
why?
So I can check a whole bunch of stuff at once
it doesnt show anything about it thats the thing
Faster than asking for a screenshot of the console and the hierarchy and the inspector and all of the things individually
Showing nothing of interest also means that it eliminates possibilities as well
A null result is still a result
This isn't what I asked for
the console is just flooded with errors
love when people just ignore your help when they are the ones that ask for it 🤣
errors are still errors and should be fixed they affect everything wether you want them to or not
I cant show the editor
why
they can still be relevant depending where code is called
they are caused because of this scene thing
for some reason all the gameobjects in my game manager get deleted
when i open the scene for a second time
you realize we don't know your exact setup this is why ALL context is relevant ?
not mind readers..
you are giving the bare minimum for help (minna)
I just need to know how to properly unload a scene/load a brand new scene
Google hasnt helped
What did Google say?
unloading a scene is only relevant if they are being loaded Additive
pretty much what nav just said
when you do LoadScene they automatically unload previous scene
thats the thing, it doesnt
this would do just that scenes shouldn't save unless you got all of it in DontDestroyOnLoad
So, show the whole window after loading the scene
and i dont understand why
So we can check
What isn't getting unloaded?
I don't know what is or is not relevant. Even if I find nothing, that eliminates possibilities and therefore makes debugging easier
so send a screenshot
some random points i instanciate
the only scenes that don't get unloaded by design is DontDestoyOnLoad and anything in it
What are "points" exactly?
With... Scripts?
ill check if they are somehow instanciated in donotdestroyonload
does the read/write flag in import settings cause any overhead if I call UploadMeshData after making changes? Like does just having the option of mesh data on the cpu cause overhead?
no just glowing spheres
why are you so secretive
Or.... you could provide the screenshot which would show if anything's in DDOL
we aren't here to steal your game
There is a bit of overhead if it's read/write enabled because it needs to keep it somewhere accessible. If the engine knows it's never going to change, it can cache the data and not have to go check for changes periodically. It's not a huge drain, but it's worth keeping disabled unless you need it
Most structs used for math in unity are partial structs. In this case, make another partial struct called Vector3 in a separate file (in the same asm) then add this in it ofcourse you need to adjust it, the float here just an example
public static Vector3 operator *(float a, Vector3 b) => new Vector3(a * b.x, a * b.y, a * b.z);
okay yeah their parent is in donotdestroyonload
for some reason
oh its a static instance
Cool something I would have spotted immediately if you had provided the screenshot when I asked for it like 20 minutes ago
is there any way to basically make some changes once at the start and then treat it like read/write is off? I need to dynamically adjust some UVs but I dont want read/write for most gameobjects in the scene for obvious reasons.
Nah, by then it's too late. It's related to where in the build the asset goes. It's not a huge drain, if you have to edit it then you have to edit it
a static instance and DDOL aren't necessarily related.. something ends up in DDOL if you explicitly tell it to in code
Or Instantiate it with a DDOL object as a parent, which seems to be what happened
uh I haven't...
ill check if someone else has since its a collab project
its easy to find.. search all scripts that have method DontDestoyOnLoad
okay yeah i give up
this is after i load back into the scene
Gameobjects are missing for no reason
GameRoot is in DDOL. Anything instantiated with that as the parent are going to be in DDOL as well
is this script in the GameRoot?
yes
Now try it again but spell "Destroy" correctly
well than that's why you need to re-reference any variables like the player if that script is moved from one scene to another and that other object isn't
can you share every component that the GameRoot has and the scripts for them (if they aren't a unity component)?
the only components with scripts in it are just cameras that have this by default
ambianceplayer is just an audiosource
Are you using any scripts that are sub-classes of something other than MonoBehaviour? Those parent classes might call DDOL and it wouldn't actually be in your code base
is the GameRoot there before runtime or is it called on runtime?
did you search entire solution / project btw instead of 1 file
oh dam discord just updated lol there is more..
If you change the search to be the whole solution instead of just the active document does this change?
how do i
oh nvm
Not delete, Destroy
that certainly is a DDOL
yep
i love collab projects!!! so fun!!!
esp when the other person uses chatgpt for all their code
thank you
ive been trying to fix this for so many hours
wasnt really supposed to share anything because weird uni regulations but
whatever
ah makes more sense just gotta hope your uni doesn't stalk these servers
Hi! I hope this is the right place to ask for help
im trying to build a very simpel shooter game as a final project and navmeshes dont want to cooperate
in what sense ? also this is a coding channel
I thought since theres coding involved it would be ok
keep getting this error, even though I though i set everything correcetly
seems your agent isn't on a navmesh
the block in question has a navmesh agent component, and i see the blue nav mesh
and the block is intersecting the blue navmesh
show the exact setup with screenshots
(if there is a better channel, please let me know
does the block has a navmesh agent component?
yes,!
I have the agent size here (its a 'titan', so large)
this here is the actual scene
Are you sure you're calling SetDestination on the object in the scene, and not a prefab?
before calling SetDestination, can you see if the agent snaps onto the surface
(playerpos is specficically the position of the player's rigidbody)
Don't think so, it just kinda floats to the ground due to gravity
are you mixing rigidbody and navmesh agent 🤔
(apologizes for the rampant restore ups)
how do yall learn script cuz the youtube tutorials do not help
well, the destination is set to the position of a rigidbody, yeah. is there something else i should do?
you have to learn the basics and build your knowledge up
i learnt from a single class (well a school semester) on java :)
Im not talking about the destination, I'm talking about the agent thats meant to move
try !learn and always experiment on your own, not just blindly follow tutorials
might wanna look into learning just c# too
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
it does have both... where would I have mixed it up?
generally you should not mix these two.. unless it was frozen / kinematic
i see, well i removed it and it does not snap by any means
no???
ones trying to use physics while the other is snappin onto a plane
fair :/
yeah they are two components fighting for moving the transform, not a good result comes out of it (unless you're frozen constraints / kinematic)
might be cause im using a 2d rigidbody but for my use case it seems to run fine
you're mixing 2D rb with a 3d navmesh ?
yup through an asset i found awhile back on github
oh this is new; i tried baking again and now it treats the guy as terrain?
you have to put the enemy layer out of the included layers of baking for navmesh surface
h-how do i do that?
if its top down probably not noticeable because of depth. 2D rigidbodies are stuck on a specific X/Y plane they dont move back / forward
im assuming im going into areas and making a new thing here?
no on the navmesh surface itself there is the ObjectCollection section, you exclude the enemy layer there. you have to put enemies in a specific Layer on the gameobject
yeah it's a top down space game where the enemies are "floaty" so the physics is wanted and works as intended
I mean its bruteforcing it lol cause if its not locked its still sketch
i dont see that option, maybe its a newer thign? im ysing 2022 unity
do you have a navmesh surface component ?
i see this stuff
do you see where it says include layers here
oof this is the old method
change that to not have the enemy layer, no?
haha yeah, sorry. my prof said auto -10% if we dont use his version
where?
hmm you should still download the AI package so you can get the proper components and get rid of the global bake
do you not have a navigation surface? never used version 2022
I went window ai navigation
then just went over and hit bake
when it opened up a tab next to the inspector
thats the old global bake they retired
odd way to do it, i would do what nav said
its under Object in that case / the dropdown in the navigation static of the gameobject
ahh yes i see it
so I do need to add another layer under Areas?
but then what number do I put? I dont get that whole system the tutorial made it sound easy....
I say you should just get the AI package instead of using the old bake
and use navigation surface component
(btw, if it helps, i can vc anywhere
add package by namecom.unity.ai.navigation unless it shows up in PM already
cause regardless of the bake it still doesnt believe that tgeres ab active agent on the nav mesh
which there is so i dont get that
ok, new question (easier i hope)
i made this titan into a prefab, and I want it to always track the player, but i cant drop the player into the variable when its a prefab
it says Player None but I cant drop the player in the scene in there
if you have an object that spawns the prefab in the scene you can have that hold the reference to the player then pass the reference that way through a method
or its acceptable to do it with FindFirstObjectOfType and find player component in awake, though not as clean as above suggestion
but if im just dragging them into the scene myself, then i just assign the player to all of them individually?
yeah ok ill just do it individually
im too tired to make this work tbh LMAO
You could do that sure if they are already in the scene but you cannot assign scene components to a prefab itself
once they are plopped into a scene they are technically an Instance of that prefab already
gooot it
that doesnt mean you can't mass select them and assign them at once , less tedious at least
oh! perfect!
I just switched from pc renderer in urp to mobile renderer since im porting my game to mobile, but i have one problem: my baked shadows now have terrible quality, like worse than realtime shadows. I tried to change numerous settings, but nothing made them better :( please help
this is a coding channel..
alr sorry
is anyone good at terrain
ya i posted something in #⛰️┃terrain-3d but no one has responded to me
ok then don't crosspost..especially in a channel that has 0 relation to terrain..
asking about a specific asset no less
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
SteamFriends.ActivateGameOverlay("Friends");, anyone got an idea why it opens the steam overlay AND the friends window of the steam application, using steamworks
hi im trying to get a UI button to work?
but the function doesnt pop up ont he button menu
Can you show the object that had the menu script that you've referenced there?
You need to drag the object in the scene with the menu component into that runtime only selection field
I think i got it
let me test
ok it works but now i need scene switching heop
LMFAO my correction for 'help' was blocked
just edit the message instead of sending just 1 message to add a correction
Check with the instruction given in the error.
You need to add it in the scene build scene heirarchy
oh is that it? i thought that only worked if you were ctually building it
damn my teacher did not explain this well
ok ok got it now
thanks, ill prob be back
Okey, I need advice, I have a SceneFade object, an image used for fading the screen when game is started, I cant put I network identity on it since when returning to main menu, the object will be disabled. I also need the sevrer to call clientrpc to fade all connected users screen. How should I do
your Visual Studio does not look configured here..
oh yeah i kept forgetting to do that
get oon it , its pretty useful when coding and will avoid most typo issues
also helps locate functions, properties and components/classes
why would UI ever be a network item 🤔
UI is local client thing
Yes, it's solely for syncing the fading of the screen when host starts the game. I really dont have an idea how do to it otherwise lol
a custom packet with a fade trigger?
make the server do an RPC to tell all clients to fade their screen in
the host starting the game is a networked thing
things that aren't networked can react to that happening
because it will happen for everyone
a majority of stuff in games does not have to be directly networked if they are built in a way where each client does the exact same thing the exact same way, which usually is chaining off more generic networked stuff
Can I use Dynamic rigidbody2d to block sprites from moving through each other (works now), but not doing the physics like pushing each other around?
yeah, its just the only classes inheriting from NetworkBehaviour is the player objects them self right now. Figured it's a little ugly to put it in those scripts
for that yea..it be silly to have a UI fade image be a NetworkBehaviour
Ideally you'd probably have some gamemanager/scenemanager esque networkbehaviour as a singleton that has an event that fires when your loading a new scene (a network "synced" event). then your ui stuff can justl isten to that
the event invoke is synced therefore anything running off it is synced
That would be a decent option
you'll wanna do that kinda thing like everywhere
Though I think it might still cause the same problem for me, unless it's dont destroy on load
how are you moving them ? maybe make sure they have enough mass
For scene related stuff i'd strongly suggest having some "globalmanager" esque thing thats DDOL or in a similar scene yeah
its not bad practice or anything
So you'd suggest a dont destroy on load SceneManager object?
Semi personal preference but yeah I tend to have a GlobalManager or GameManager networkbehaviour singleton that lives in DDOL that handles broad stuff like scene management then something like a RoundManager (or GameManager if i used GlobalManager naming previously) for managing a given level or session
Yeah, GameSession, that's something a was thinking of implementing for managing session-wide stuff, like money or thing like that
one thing to note regarding this kinda advice is what you do want explicitly saved/synced in NetworkBehaviours and NetworkVariables are things you'd want synced when someone joins a ongoing session, if that makes sense
since the big benefit to networkobjects/behavours/variables is by default they auto-sync/create for people joining
yeah, that Im aware of, I'm still fairly new to networking, but I have some understanding of the basic concepts
I named my script to SceneManager, got billions of errors lol, forgot it was already the name of the built in lol
hey, whats the easiest way to get a method from one file into another file?
I just want something to go to the menu upon death and midnight is rapidly approachin
references
https://unity.huh.how/references
Choose the best way to reference other variables.
Serialized usually the preferred way when possible
This is a common misconception for beginners but in programming you don't communicate between "files" or "scripts", you communicate between "instances" of them.
if you need to ask your neighbour for spare sugar you would be walking to the house that's built next door, not the paper blueprint of the house
you could put a static reference to the script "Instance", thats how I access them easily
How you mean?
GOT IT WOO
other than singletons, there is a lot of misuse of static because they don't know how to properly DI between objects
now i hvae an hour and 30 mins to get a pause menu and then im done with this semester
which way did you do it ?
all working