#š»ācode-beginner
1 messages Ā· Page 569 of 1
I remember seeing a 100 robux game would give me 10 robux in profits
WOW
This isn't a Roblox server, keep this channel on topic please.
scary man appears D:
I knew this would happen

so how do I script the code to make an mmo
alright so my unity question that I had written somewhere else
(Something rest of the owl)
omg it's too long
HOLY SHIT DEACTIVATING A OBJECT MAKES THE SCRIPT NOT RUN ITS A FUCKING CHRISTMAS MIREACLE
Ok back to my slave shift on programming
That is literally the definition of deactivating yes
The callback methods are disabled, yes.
for like an hour thanks for the yap and talk and help
Which script to deactivate to make an mmo
system32
Another symptom of the object itself not actually running the code
Just to make it clear, it only stops unity messages/callbacks. Code that you call manually on the script will still run(obviously).
Oh really?
kk
Will a method finish executing if a script sets its game object to inactive in the middle of the method?
woah thats insane it stops everything when you disable a object unity is so fucking cool
Reminder that setting an object inactive and disabling a component are two different things.
Yes. You can't stop method execution from outside the method.
I meant the entire object
Both which may share behaviors though
Huh. Good to know
Once a method is called, it will run to completion until it hits a return statement or an error. Nothing else in the entire project can happen until one of those things occurs
You canāt kill a entire thread?
Unityās got so many quirks to navigate
You can, but since Unity is single-threaded, killing the thread will kill the entire program
Huh weird
That functionality was within my old engine and it was also single threaded
I don't think there's such a thing as "kill a thread". You can join threads, but the thread needs to stop it's execution. You can kill a process, but that's a different thing entirely.
You can do thread pooling still tho right?
Maybe I meant process
Like native c# multi threading tools work the way Iād expect?
Yes, but you can't run any UnityEngine functions outside the main thread
And that was my next question. Ic
So itās only useful for background logic jobs or async asset loading?
So Iām confused within my old engine I was able to create virtual threads then kill them is that not a thing for unity?
Basically.
As I said, you can still write multithreaded code, but UnityEngine functions are only available on the main thread
But Unity does provide Coroutines for psuedo-asynchronous code
It's not actually multithreaded, it just pretends to be
What was the actual implementation? Share the code.
I could make a background data logger that sends http requests to a remote server tho yea?
I mean of the "thread killing" functionality.
Like I guess youād have to read all the game data in the engine and pass it off to the background remote logger job or something
Unity is not "single threaded" purely but the core update cycle logic is single threaded and ofc most user code will be too
Is that a thing on unity
Ok
Coroutines š
async š
Killing virtual threads
So what about InstantiateAsync is there a practical use for that?
It might be a totally different thing if it's a different engine and even more so if it's different language. But it doesn't sound like a feature built in into the language, so the "thread killing" probably has some more complexity to it than you understand.
last time i tried instantiate async it was half broken š
Idk docs just says it suspends the thread I assume thats killing it no?
I couldnāt find any perceivable difference besides it taking like .01 Ms to finish
That's actually not possible because no other code would be running during a method.
and you cannot disable a component outside the main thread
It could. But that doesn't mean it would stop right in the middle of the method execution. It's likely gonna suspend when it returns to the thread root and would be joined with the main thread.
Ah I meant something else with that and mainly just a curiosity
!code
š Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
š Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
You actually cannot just "kill" a thread in new .net anymore, now you need to use cancellaton tokens:
https://learn.microsoft.com/en-us/dotnet/standard/threading/destroying-threads
It does if I have a yield in it but that could be because the yield is part of the dane library idk
Or I donāt understand that in-depth of code idfk
Was just curious tho thanks
public void DoSomething() {
this.someComponent.DoAnotherThing();
this.gameObject.SetActive(false);
this.someComponent.DoYetAnotherThing(); //does this happen?
}
yes
enable state controls if some functions like Update() are called and thats about it for monos
ofc for say a renderer, it wont render anymore
Up to you to check the enabled state if you want it to be used!
There's probably some system moving behind the scenes that actually handles the thread correctly, but for a user of the API it just seems like the thread is "killed".
yes
Iām sure lol theres no way to see behind the scenes on that platform so I have no idea
Yep, absolutely. Code will always run to completion unless there's an exception
Yeah thatās what I was asking š
But yeah thanks!
Cool
Disabling an object only prevents Unity from calling a function. If you do it manually it works. Otherwise, you'd never be able to activate it
Though I donāt see a practical reason to structure code in a way it could step on its own toes but good to know
Active/enabled is really about if Unity engine is going to run your code. It's basically meaningless outside of that from a code perspective
Awake() is always called even if disabled and ofc user code can do whatever
Well, I mean it clearly is intended to be an easy way to strike objects from a scene without destroying them
Awake doesn't run on disabled scripts actually until they get enabled for the first time
that should be start no?
Nope, both of them
Whatās the Diff between awake and start?
Ah active object vs disabled component yeah
Script != Gameobject
A disabled component of an active game object
Enabled != Acitve
yea i mean the components disable state
If the object is disabled, the scripts don't run awake
I kinda wish that wasnt the case myself but yes
I think we've been kind of loosey goosey with the words "enabled" and "active" this whole conversation
because there is a very important difference
Also Iām assuming trying to access components in a constructor is not gonna work right
Weird question
nah it moans at you usually for being too early
Generally you shouldn't have a constructor if it's a MonoBehaviour at all
You shouldn't have a constructor for any sort of component at all
You should use awake
If it's a regular C# class then you can do whatever you like in the constructor
Iāve only been using constructor to instantiate things like lists
With a : base() just in case
Use awake or the field initializer
Not a constructor
if it's a monobehaviour, you should not use constructors. They won't run
If this is a MonoBehaviour
Chances are you have serialized the lists so they're created by the inspector and you've never noticed those functions don't run at all
Yeah, I mean it does work but I was only making sure the list isnāt null at runtime
Nothing more complicated than that. But probably better get out of that habit for unity
Sorry for weird questions still getting my head around how unity thinks in general
You should initialize your fields with field initializers or in awake in MonoBehaviours
So awake is like unityās pipeline constructor? What differs between that and Start()?
img i sent before, awake is called even if the component is not enabled
Oh thanks didnāt see it
start gets called first time it is enabled (usually the case)
You can see the whole lifecycle of a MonoBehaviour here:
https://docs.unity3d.com/6000.0/Documentation/Manual/execution-order.html
Constructor is reserved by unity and is called somewhere before this.
Neat
i need that image as a poster
Awake runs immediately. Start runs before the first Update loop an object exists for
If you spawn an object in code, that object's Awake method will run before Instantiate returns. Start will run after the current Update frame is done
Dunno if common but 99% of what I write has manual Init() functions that we use (usually also to pass some dependencies too)
That's not an uncommon pattern. Sometimes you need something that runs between Awake and Start (like if you're instantiating multiple things and need them to reference each other)
I've moved more and more towards this
especially for objects with an obvious owner
can you make custom properties in a object without like making a script?
Like I wanna some how just have a refrence to another object in the object
but do I really need a whole script to do that
yes
you need a script for that
You could also have another script that stores a dictionary that holds the data but... that's a script
yeah just having a refrence is easier
It's really not a big deal to have a script
ik
beginners often use way too few scripts
What would you even do with a reference without having a script to do anything with it?
I just need to tell the game what item in my character thats inactive to activate when I pick up an item
so I legit just need to get that refrence and activate the object then destroy the object on the ground
sounds like a perfect little single-purpose script
Yeah! I was just being sure there wasn't a different way
really this is one script on the player - the interaction script
and one script on the object - that has the info about which item to activate on the player.
Really it could be a prefab reference to instantiate too
there are many ways to do everything and anything
I know I'm just coming from a different engine so I'm trying to figure out the traditional way to do things before I make my own ways
like the way I would do it in the other engine is the heiarchy is a big ass dictionary table so I'd just grab the name and get the child with the name lol but I think with unity its a big ass array
or list idk
You could do the same in Unity but really that's a very inefficient way to do things
unity has much more efficient ways
ye thats why I asked
And you should never tie functionality to names. If you decide later you wanna capitalize something suddenly all your inventory system stops working
like I said I didn't have a choice in the previous engine so I kinda had too I'm mindsetted in one engine and now I'm trying to swap my mindset to a new engine
its why I'm asking questions that might sounds dumb lol
So I am working on exporting my project thorugh WebGL, but when I run the game outside of the editor, the screen zooms in a wierd manner, and the button for changing the scene does not work. Can anyone help?
{
ClosePhidgets();
SceneManager.LoadScene("Scene1");
StartCoroutine(WaitForSceneLoad(SceneManager.GetSceneByName("Scene1")));
}
public IEnumerator WaitForSceneLoad(Scene scene)
{
while (!scene.isLoaded)
{
yield return null;
}
Debug.Log("Setting active scene..");
SceneManager.SetActiveScene(scene);
}
private void ClosePhidgets()
{
redButton.OnApplicationQuit();
ui.OnApplicationQuit();
}```
ps. I know start is not capitalised, it is the name of a button
As for the scene button not working - check the browser console window for errors
Also make sure the button is responding to mouseover.
there is a browser console? where is that?
sorry...
For chrome
I take it you don't know anything about web development then
Thje size of the game window is determined by the HTML/CSS on the page
definetly not, this is my first ever coding project outside of block code
specifically of the html canvas element the game is being drawn in
this is strictly a web development concern
there's nothing Unity can do to control this
you control this with your HTML/CSS/Javascript on the web page
Note that by making a webgl game you are essentially committing to making a small, simple web page as well.
is there a better alternative? my goal is to get it to run on a raspberry pi
the unity build will give you basically a barebones sample web page
but you can and should customize it
Why build for webgl then and not as a linux desktop app?
If it's webgl, it runs in a web browser
how should I do that? I am running unity on a windows computer, so I assumed I would not be able to interact with unity
How do you do what? Make a linux build?
yes
ty ā¤ļø
I wonder if raspberry pi is a compatible device at all.
what do you mean? for WebGL?
Though I guess if it runs in the browser, it should be fine as a standalone build too.
In general.
how big would a linux build be? I have 8 gb and I am curious if it takes more (it is a decently small project with 2 scenes)
It depends heavily on the content of the game. The number of scenes is not that important. Usually the biggest driver of the build size is the multimedia assets like textures and sounds.
The minimum build size with a completely empty project and basically all assets and packages removed is probably around 5MB
which linux module should I use? I saw these three and I am not sure of the distance
Mono or il2cpp
Or both just in case you want to test both builds
is one of them better than the other? I have limited storage and processing power, so I do not want to waste space
the first one generally
Hey folks, over the years I've periodically had issues with Unity Editor Run performance while running my games. This past month it has gotten really bad, where things will freeze up for seconds on a 7800X3D w/ 4080 super just running a simple 2D game. The profiler is showing long waits like this. I've been messing with Gsync and other settings to no avail. Compiling/running my game gets 200+ fps without any issues, so this all appears editor related. Any thoughts on what it might be?
Hey guys, Iām transforming a player model during update, rotating it during late update (because of animation priority), and setting a gun modelās transform and rotation to the player models hand during late update. Iām having an issue where the gun models position is not synced up with the player at all.
Why is it red?
you're missing the closing brace for the Update method
looks like maybe the one for the class as well
You are the goat, thank you
Does the moving code go in the blueprint or is it applied after it spawns?
What moving code?
Assuming youāre doing the flappy bird tutorial, moving code should go in the Pipe object
Yeah, i made a sprite, then the tutorial said to make an asset with a top and bottom pipe, do i add the move script directly to the asset?
if you're following a tutorial, follow the tutorial ?
I'm trying š
I.e. Blueprint. The thing you clicked and dragged into the folder
If you put it on the prefab, it will be attached to all the objects that spawn. If you put it on an object in the hiearchy (the window where your objects are), it will only be attached to that one
Does it work?
It's spawning 1, then a second later thousands
Did you put the spawner script on the pipe object?
Lemme check
Cause then each pipe will spawn more pipes lol
What do i need to screenshot?
The window you attached the script to
Tada
Youāve attached a Pipe object, but youāre looking at a PipeSpawn object
That looks like a prefab that contains more child objects
I want to see what components you have in the child objects (you should have an upper or lower pipe?)
The sprite itself? I just ctrl c > ctrl v'd and flipped it
That's what the tutorial said to do
But you should have an object containing the sprite renderer
This?
Lemme check the video
You need to set the timer back to 0 in the spawnPipe method
Timer = 0;
Cause now, it will just keep spawning a pipe every frame once the timer is up
if(...)
{
...
}
else
{
spawnPipe();
Timer = 0f;
}```
Very nice!
I feel like a toddler learning the alphabet
I'm sure it was just as magnificent prior to fixing the cooldown timer š
Hardcore mode
Also, I noticed it takes a solid 10 seconds for the game to run, is there a way to make it go faster?
go to your project settings > editor and change the reload domain setting to reload scene only
void Move()
{
float x = Input.GetAxis("Horizontal");
float z = Input.GetAxis("Vertical");
Vector3 move = transform.right * x + transform.forward * z;
controller.Move(move * speed * Time.deltaTime);
isGrounded = controller.isGrounded;
if (isGrounded && velocity.y < 0)
{
velocity.y = groundedGravity;
}
else
{
velocity.y += gravity * Time.deltaTime;
}
controller.Move(velocity * Time.deltaTime);
}
void Look()
{
float mouseX = Input.GetAxis("Mouse X") * lookSpeed;
float mouseY = Input.GetAxis("Mouse Y") * lookSpeed;
xRotation -= mouseY;
xRotation = Mathf.Clamp(xRotation, -90f, 90f);
playerCamera.transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
transform.Rotate(Vector3.up * mouseX);
}```
Just need some advice on this, thoughts? Anything I can clean up or improve? Is this acceptable?
Thanks pookie
I added a box collider to the prefab and now the bird is flying backwards
When it flies into a pipe?
No it instantly goes offscreen to the left
Maybe the birdie is bumping into something in the scene.. for instance, the background 
Sounds like the collider pushes the bird away
Did you attach the collider to the bird itself
I.e. The same object that has the rigidbody2D component?
It shouldnāt
The bird has a rigid body and a circle collider
Then what did you put the box collider on?
Colliders donāt automatically adjust their size and location to the object, so it might have spawned at the center of the screen
You have to adjust it manually
Oh, that makes sense
That would be best to do inside the prefab.. when you press the cube inside the asset folder
No. But you can record a video instead.
True
Then on the box collider component, there should be a button with a bunch of lines and circles on it (i think). Click that so you can see the collider
Then you can easily adjust the borders of the collider by pressing and dragging on the x and y on the scale input
Yes
Then just fit the size to the pipe
You might need another box collider for the top pipe
The reason i couldn't find it is because i didn't have the actual pipe on the scene lmao
Can i delete it now?
I'm still flying backwards but faster now
Even when not near the pipe?
@sweet mica Please create a thread.
Oops, sorry
The best flappybird game ever
I canāt watch that on my phone
I'll fix it, its going in the thread now
How to jump with new input system but with using Transform.Translate and custom gravity? how do u do that
Those are two separate unrelated things.
You just want to find out how to detect a key/button press with the new input system -> do basic tutorials (probably found in the pinned msg's on #š±ļøāinput-system )
Once you've learnt that, all you do is call a method with it, in which you put whatever you need -> google unity how to jump
i know how to use input system. What i was asking is how to implement custom gravity without using rigidbody
You can create your own system which constantly adjusts assets based on gravity. You don't have to be tied to the build in system
With 2d games I generally just make it myself and a FixedUpdate method constantly pulls down objects based on the configured gravity
got it
Is there documentation for global-metadata.dat anywhere?
This smells like you want to reverse engineer someone else's game.
Why would you want documentation for something you can't change? Do you have a specific use case for this?
It seems like a fun project to learn. That's all
Well the #šācode-of-conduct states that decompilation and modding is not a topic that's allowed on this server.
Okay. What does that have to do with learning about file formats?
Because why else would you want to learn about the file?
Curiosity?
There's already tools to dump the data from the file.. I was just interested in the file format
So yeah, this is about decompilation.
In what way?
I'm not going to argue semantics with you, good luck with it.
I already found it. I was just looking for official documentation
Doesn't unity generate that file
A built project typically contains those, yes
oh i'd reckon that this would be the place for asking about that stuff
Wow. I was about to reply to the person asking why I would want to learn and they deleted their message v.v
!code
š Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
š Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
ok
here is a code: https://paste.mod.gg/vifwubmpmdhd/0
A tool for sharing your source code with the world!
so, why when i have Horizontal axis = -1, player rotates x rotation?
i didn't wanted to
can describe a code: rotator1 is a rotator in front of player, rotator2 is a rotator behind player. They use rays for checking collision with ground and getting the collision point. I find an angle between these 2 points.
code should rotate only z and y rotation, but not x. it didn't suppose to do it.
is anyone here?
do you have any other components that change the rotation? try debugging what the rotation is actually set to when going left
cus if thats all that sets rotation it must be it. working with eulers only can cause issues like this
no, i don't have other components that rotates player
like, lookrotation?
i dont follow
Hi quick question. i need add (0 ,0 ,0) and spawn my player here after destroy. i try my self but i cant do that
public GameObject Prefab;
public GameObject gracz;
void OnTriggerEnter(Collider other)
{
if (other.CompareTag("wood1ded"))
{
Destroy(gracz);
}
log before/after to see what the rotation changes to or attach a debugger and see what happens @echo copper
urm... i have never done this...
time to learn! Debug.Log() is easy to start with and using a debugger is a powerful way to see what code is doing
https://docs.unity3d.com/6000.0/Documentation/ScriptReference/Debug.Log.html
https://docs.unity3d.com/6000.0/Documentation/Manual/managed-code-debugging.html
I decided I didn't care enough
š¤
Just FYI, you can get the same EulerAngle rotation by doing other rotations.
So your the value that you actually set with ANGLE on the Z axis and -180 on the Y is the same rotation as -180 0 -45.
So even if you don't set the X, Unity can simplify it to that itself.
i don't know... should i use cos and sin?
anyone?
maaaaaan...
that is not what @fossil drum said
well, maybe i didn't understand him, sorry
what is not to understand? -180 0 -45. is not 180 0 -45.
for a debug...
im a fool.
what should i do... i am really sorry if i am too annoying, but how to fix directions?
how do I put the scale of an object into the code?
Id just rotate the main character parent for the slope angle and flip the model child separately via scale or rotation
or you do it in a different order.
Quaternion.Identity -> rotate y for left/right dir -> do slope x/z rotation
Change the localScale of a transform
After destroying player just instantiate it and there is field for position, put vector3.zero into it. To instantiate you need player to be prefab. If you don't know what those things mean go to unity learn website do basic lessons.
how do I do this? im making it so that the if statement activates when the scale is that
this doesnt work, i just found out
localScale is a Vector3, so you need to directly compare it as such, *
transform.localScale == new Vector3(1, 1, 1))
Alternatively, you can use Vector3.one, which is a shorthand
I get an error when I do that
you're doing an inline assignment
what is that and what should I do?
They gave you the hint already
Comparison is ==
Single = is an assignment
Assignments: =
Comparisons: ==
I wonder why that is throwing an error anyway. Does that not work in c#
oh, did not notice, alr thanks
It's in an if statement
I believe inline assignments work as long as it returns the expected type
But that was not the intention here obviously
And if it did, it would have to return a boolean somehow
any idea why a script component might disable itself at runtime, despite there being no code telling it to?
https://paste.mod.gg/gboifliizloq/0 here is the code in question
A tool for sharing your source code with the world!
What about enabled?
is that in my script somewhere?
No, I mean you look for the keyword enabled
Because setting this disables components
You rather should look into other scripts that probably do something GetComponentInChildren or so and enable/disable them
If your packages aren't in separate solutions you can also ctrl + shift + f and search your entire solution
the thing is i dont think ive added anything that enables/disables yet
those are the only instances of "enabled" in the entire solution
Do you have errors in the console perhaps? When it disabled
yes i was about to ask if that could cause it
It could be. Errors in Awake would disable the script for example.
Always pay attention to the errors in the console. They would often be the cause of whatever issues you might have or at least be related to them.
can i... ask the same question again..? like... WHY IM TRYING TO ROTATE Y ROTATION, BUT IT ROTATES X ROTATION, IDK WHY
like. if i rotate: transform.rotation = Quaternion.Euler(new Vector3(0, 180, 0)); it rotates y rotation
Share !code
š Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
š Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
sry
A tool for sharing your source code with the world!
if ANGLE = 0, he rotates x rotation, not y as it not supposed to be
A tool for sharing your source code with the world!
but here, he rotates y rotation as it supposed to be
You don't ever rotate around Y axis. Well aside from setting it to 180 degrees in the first snippet.
ow... urm... and... how to rotate it right way?
I suggest you check some tutorials and go over the beginner pathways on unity !learn:
:teacher: Unity Learn ā
Over 750 hours of free live and on-demand learning content for all levels of experience!
Because it sounds like you're missing some basics.
maybe, i am started to use unity clearly two month ago...
Well, then you didn't learn properly. You should be able to rotate an object after a week or 2.
Assuming you learn properly
i have big problem because he everytime switch this to this after destroy : /
any idea why this never gets to the last line? no error, application still working I'm super confused
it does the if statement clearly because I get the "Number of words" debug
but then just ignores the last line
Your question is very unclear so nobody is going to help you most likely. Please try to explain in better detail what the question is and make sure it's coding related.
Which of the Number of words do you see in the console?
Okay, then what makes you think that it doesn't execute the last line?
i also added a debug after the last line and that didnt go through either
Code doesn't just stop working for no reason. Your code most likely did reach the end, but you didn't notice it happening
I suggest you put a log above PopulateTrie to verify
Are you sure you don't have errors? Take a screenshot of your whole console.
when my block spawn he change player form file to hierarchy
Did you save and compile?
and i cant spawn 3rd time
yes
What calls LoadWordList? Is it an asynchronous method?
my player stuck
And also, share PopulateTrie please
they're just called like this based on what is needed, but those are then called like this
Try restarting the IDE, or even the editor too. Sometimes code changes are not registered.
didnt work sadly
1 sec
The editor doesn't freeze, right?
https://paste.mod.gg/atyuimxnxzex/0 thats the whole script with the PopulateTrie
A tool for sharing your source code with the world!
no it just keeps working
That's very weird. There should either be an error or a freeze(if it's stuck in that last line method).
It doesn't seem like threads are involved either
Did you confirm that the code is up to date after restarting the ide/editor?
yes
Namely, the last Debug.Log that you added.
Well, at these point use the debugger and step through the code.
also putting a debug before it doesnt work
just out of interest, in which language is Tree spelt Trie ?
really weird
in the UK ig..?
no it is not
pretty sure Trie is just another name for a Prefix Tree at least thats what we were taught
Can you share this script as well?
A tool for sharing your source code with the world!
there are different tabs on here, first one is the WordLoader
second WordSearchManager
and then the Trie
You have several LoadWordList methods with mostly the same logs. Make sure you add different logs so that you know which one is being called.
im only using one at the moment
Out of curiosity, Where were you taught that? How do you even pronounce that
but good idea
idk like a french person saying tree
or eastern european actually not french
Both of them could qualify for the call, as int can be converted implicitely to string.
Make up your mind bro
That's probably what's going on. And I recommend starting using the debugger, as that would make such issues solvable in a minute.
added it in, it does use the index one
What did you add?
Ah, well then the issue is solved I guess?
wdym
My advice: learn to use the debugger.
yes that was the issue š
thanks for the help, I actually can't believe that's what it was
Well, as long as you understand that code doesn't magically stop
Either it blocks, blocks in a multithreaded context, threw an exception or never compiled to begin with
Most can be spotted quite easily since something will visibly break
please don't tell me you just copy/pasted the whole method instead of making the processing a seperate method called by both
is that not how you use method overloading?
no
Well, technically it is, it's just not a very good implementation.
DRY and all that
well, yes, that is an overload.. the signatures are correct.
However, you shouldnt have duplicate code inside the methods
guys my unity just crashed, and stupidly me, i forcely closed it, n i lost 24h+ of progress. anyone knows if theres anyway i can get a recovery from that?
what is there to force close if the app crashed?
They lost 24h+ of work, no need to interrogate them on the circumstances when it's irrelevant
š
What progress is it exactly? Scene changes?
It's actually very relevant
how do you go 24hr on a single scene without ever saving
Well, true in a sense. I've a hard time imagining someone not at least saving the scene
also how do you get unity to crash and then force close it
24+ hours? Time to download Git
well, more like not responding
how do I achieve this effect of climbing stairs?
Can we get a "Time to download Git" sticker in this server? Seems more and more relevant each day
but ty anyway! i found 0.bak in temp folder
so not a crash, a hang, quite different
right ok that's not a crash, that's typically called freezing or hanging
yea it went like 20mins so i forced close it


As your experience grows you'll learn to save every minute which will prevent these issues
And as you reach this point additional experience will teach you to save twice, three times in a row just in case the first one didn't work well enough
my laptop is so slow tht it takes 5 sec to save my project
so yea, i should still do that tho š
the bottleneck would probably be with the disk specifically
I highly recommend Fork, the fast and friendly git client
https://git-fork.com
help, my Jump animation wont transition into onwall when im on the right side of a wall
someone who doesn' save their work for 24+ hours is hardly likely to do both saving and a git commit
hey guys! i was looking to make a platformer, i was wondering how would i be able to tell in which ground my player would be stepping in? as i want to make a special effect depending on what the player is stepping on
should i make a script and apply to every ground, then use a onCollisionEnter to check if the ground's tag or name is something in specific? or is there a better way?
You're not wrong, but doesn't hurt putting it out there š
$59.99? Outrageous
And pointless. Github Desktop is free and works perfectly
fork is available free.. it doesnt force you to pay, though you're supposed to after evaluating
i mean isn't that what winrar is
free trial for a period of 1 eternity
Sure
GHD is a v.basic client, the type youd give to artists/ beginners
fork is for devs who need to do more than push/ pull
i mean don't ides kinda have good integration already
What exactly is there to Fork that would make Github Desktop the worse option then?
I also think calling it something for beginners is silly. I have been using it since it got released
more advanced options for whatever you need to do with git
dont take offence at that.. it wasnt an insult to you personally
No I get that. It's just that I am looking for actual differences but Google doesn't list that many
If Git-fork isn't paywalled then I obviously take it back. It just seemed to have that or a trial version
Deifnitely looks a lot better than Github Desktop
they're not going to advertise on their site that you can use it indefinitely without paying
Ive used it for... 5 or 6 years without paying.. pops up occasionally to buy it
Learned about it because of vertx mentioning it - and tbh I should prob pay for it, used it for so long
I'm definitely going to give it a look
Do you really think 6 years is enough to evaluate a software? Give it 10 at least
Same here, it's also well worth the price.
Hey, I'm still evaluating Windows 3.1, you know it might take off
I'm instantiating a bunch of objects with
Vector3 position = new Vector3((x * gapSize) + 0.5f, (y * gapSize) + 0.5f, 0);
GameObject tile = Instantiate(prefabTile, position, quaternion.identity);
tile.name = $"tile_{x}_{y}";
tile.transform.parent = TileHolder.transform;```
and it only runs for the first tile, and not any following tiles, because of a nullreference exception
private bool onWall()
{
RaycastHit2D raycastHit = Physics2D.BoxCast(boxCollider.bounds.center, boxCollider.bounds.size, 0, new Vector2(transform.localScale.x, 0), 0.1f, wallLayer);
return raycastHit.collider != null;
}
my Raycaster wont activate when Im on the right side of the wall for my animation script, but does work for my movement script
Fix the null reference exception then
would help if you could specivy where exactly that nullreference exception is
care to give us a clue?
also, shouldn't it be Quaternion.identity
thats Unity.Mathematics
also would help to show the looping part of the code so all the context is included
tile.transform.parent = TileHolder.transform;```
is the line with the issue
for (int x = 0; x < objectWidth; x++)
{
for (int y = 0; y < objectHeight; y++)
{
Vector3 position = new Vector3((x * gapSize) + 0.5f, (y * gapSize) + 0.5f, 0);
GameObject tile = Instantiate(prefabTile, position, quaternion.identity);
tile.name = $"tile_{x}_{y}";
tile.transform.parent = TileHolder.transform;
}
}```
so, tile holder is null
TileHolder is a GameObject i have assigned in the inspector
bet?
wouldn't Instantiate take a UnityEngine.Quaternion anyways?
there's implicit conversion to Quaternion
ah ok
according to the docs it's a capital Q
That's what I thought, but UnityEngine.Quaterion should be still used if mathematics are not in use
of course it would be better to use the Quaternion already, but at least there's nothing wrong there š¤·āāļø
there's another one that's a lowercase q
it wouldn't even be compiling if what's there now wasn't ok
okay nevermind my bad, thank you. It seemed to work for the first tile I was instantiating but not past that, I just changed it from assigning in the inspector to actually specifying the object in the script, works fine.
problem is sorted, and quaternion.identity works fine for the purpose i want it to
It works but it should be Quaternion with capital Q
are you intentionally using Unity.Mathematics? if not, then you should use the UnityEngine one instead, Quaternion
Can anyone share some knowledge on how gameObj.find works and why it's so inefficient? I imagine that it doesn't use a simple for loop because I've never heard of for loops being inefficient but I can't think of what else it could do to achieve this result
I was intentionally using the Unity.Mathematics one but I'm not sure if that's a good thing lol. I'll just change it to the UnityEngine one instead then.
Help please...
I've spent the whole day on this... š¦
not a code question, this a code channel.
Just have colliders on each step, and a player that's smaller than the step so it hits each one
it's inefficient compared to other things
probably most notably, the string comparison
Can you explain this in a bit more detail? Why is string comparison so bad?
The method expects UnityEngine.Quaternion so if you used the Mathematics one, it would get automatically converted to UnityEngine.Quaternion but you don't need that conversion if you use the right one to begin with. Afaik Mathematics is mostly used for ECS/DOTS/Burst whatever
would you like to see an inefficient for loop?
How to make this?
for (int i = 0; i < 100000000; ++i) {
Debug.Log("AAAAAAAAAAA");
}
Linearly searching the entire scene instead of having a fast lookup structure like a dictionary is slow
I would actually not worry much about the slowness of Find, tbh
it's not super bad, it's bad in comparison to other stuff
For loops are slow when they go over a lot of items.
It has much worse correctness problems
In fact, this is almost always true
GetComponentInChildren is really nasty because it's sensitive to adding and removing components in your hierarchy
And when you use Find everywhere and your scene grows, you will quickly get to the N^2 territory which might start being a performance issue too
It is also a bit slow, possibly
But the main problem is that it can wind up finding the completely wrong component
rename an object? you're fucked
typo the object name in the hierarchy/inspector? you're fucked
typo the object name in Find? you're fucked
the above, for any object in the hierarchy of the target? you're fucked
(Clone) (Clone) (Clone) (Clone)
I die a bit when I see someone doing GameObject.Find("Foo (Clone)")
IMO, names should exist solely to make it easier for you, the human being, to identify things
Names (and, more generally, paths) can change
to summarize the performance concern; it's not egregious, computers are fast, but it could be so, so much faster with other methods
it searches and does string comparison, both relatively expensive steps for the given task
direct references remove both steps, and they're generally clearer and provide a direct semantic/mental link, so they're generally the much better option
Yet the animation system relies on it, doesn't it?
If I ever see this code pushed to one of our repos Im getting the stick out
Well, that's kind of unavoidable
AnimatorParameter references when š
i mean probably not too hard to do actually
oh, I'm thinking about the paths in animation clips
how do I fix this code?
ive been trying for a while, nothings happening
oh hm yeah that too i guess
Names are a very...flexible(?) option
though that's not really part of the interface is it
how's that different?
oh yeah -- @swift elbow you were asking about string comparisons a bit earlier, right?
Several places in Unity let you turn a string into some other kind of identifier
By several places I think it's animators and shaders
Animator.StringToHash, for example, or Shader.PropertyToID
gotta make that code GC free
NameToLayer I believe is a thing to
Unity doesn't tend to use the full names of things internally -- they get turned into some fixed-sized piece of data
Are string comparisons really that bad in general though (for logic sure, but for performance)? Most strings will differ on the couple few characters anyways
yes, in comparison to other stuff
Part of the problem is that the string has to be shipped off to Native Code Land
Heap allocation stuff iirc
That is one problem with strings in general but I don't think comparisons have to allocate anything themself
String comparisons are pretty performant to be honest
Yeah, I would be less concerned if this was a simple string comparison in C#-land
It also depends on your use case. Maybe you want to compare another way (i.e. hashcode)
anyone?
But don't for-loops linearly search in the specified bounds? I don't see how it's that different
Yeah but how does this relate to my original question? I'm a bit confused on the correlation
looping through a scene directly would be linear, indexing a dictionary is not
hey guys! i was looking to make a platformer, i was wondering how would i be able to tell in which ground my player would be stepping in? as i want to make a special effect depending on what the player is stepping on
should i make a script and apply to every ground, then use a onCollisionEnter to check if the ground's tag or name is something in specific? or is there a better way?
I was pointing out how you can sometimes avoid looking things up by name. It is a tangent,y es
If your "raycaster won't activate" then onWall() isn't being called when you're in that pos
It also sounds like you've got this code in multiple places ?
Yes, that's the point
Linear time can be awful
singleton is the better solution to any find
I love singletons š I use 20 at once if I need to
But, again -- I have much bigger correctness problems with using Find
The performance is a secondary concern
I read this a long time ago so I'm not sure if it's still relevant
https://discussions.unity.com/t/is-comparetag-better-than-gameobject-tag-performance-wise/33954/5
The key difference between tag and compareTag is that compareTag does not result in a heap allocation. In Unity, retrieving strings from game Objects will create a duplicate of the string, which will need to be garbage collected.
The source I found reports a ~27% increase in performance of compareTag(aString) vs. using gameObject.tag == āaStringā;
Source:
Unity 5 Game Optimization by Chris Dickinson
I was always told that it's too expensive so that's what I rolled with
that's the easy explanation, I suppose
it's relatively expensive, i guess, but that's generally not the cinch
it's generally better to avoid strings if you can, they're kinda fragile
unless you're doing something where strings can be typed like an enum, like in ts
Yeah, it's still relevant
Might be out of context as well. I was assuming they're attempting to access the tag property for comparison - I wasn't here for the whole discussion.
(the original question was about Find)
But that's more of an issue with how most Unity properties result in a call into native code, which has to allocate memory to give you the result
using literals is usually the best way about it but lot of features with unity still require that string comparison unfortunately
using literals? strings can also be literals wdym
whoops I mean variables
perhaps you mean using things like Animator.StringToHash
godot people were saying that a lot of the string comparison is relatively fast
a lot of its features do use a lot of string comparisons
I generally just like the more type-safe nature and having the compiler know beforehand
What the biggest issue is, is up to debate. The bottom line is that the Find methods are bad and there's always better ways to achieve what you were trying to achieve with it
yeah, but idk why it isnt being called
also I have that code on my animation and movement script file
There are faster ways to look things up than a linear search. A dictionary/hashtable allows for O(1) lookups
Often Find is even used for things that could be directly referenced otherwise (even drag and drop to a field in editor, singleton or something else)
or instead of finding that object, let the object itself do some callback/subscribe when it is created
Things like FindObjectsOfTypeAll in editor scripts I would say is totally acceptable but if the game logic relies on Finds, it is indicative of bad design choises
If i load a scene that has a main manager class ill use FindObjectOfType() to get it initially but that's about it.
An alternative is to search the scene root objects for the component.
Wouldn't even simple singleton do the same?
If performance isn't an issue, such as in Awake etc, I think it's perfectly acceptable using FindObjectByType. We've all got games to make, after all.
It could but we wouldnt access or use it via this singleton static ref anyway
For the games that do this its only 1 call when the scene is loaded in additively and thats it
Why cant you just use a static reference if there's a single manager? I don't see the issue
There's very little reason to use Findtype methods, if at all
When potentially many people can work on a game its better to avoid stuff that can be miss used down the road
it might be more advisable not to work with people who are likely to miss use anything
In this case I wouldn't really worry
This is so true.
its not my choice who works on a project i just work on what im told by the PM
Miss stuff? Seems pretty clear that a single instance manager might have a singleton pattern applied to it. Using a Find method sounds like a solution for people that didn't even bother looking for the correct approach
heck, I'm even miss using my own code 
Always assume someone is going to see your code, try to understand it, and build upon it, and then design it in a way that makes your intent abundantly clear and doesn't invite to misuse.
š ha this chat
If I want to use a manager, the first thing I'd probably do is check if there's an Instance property on it
Which is pretty common in .NET for default single instances btw
ill end with this: i dont want the static field to exist so its not miss used when a pre existing system/design exists for other components to access said manager š
That is generally a sign that you are not actually designing anything, just making it up as you go along
Fully agree š
I have no idea what issue you're referring to here
no need to worry
Sounds easier to me that you can access a singleton instance through a static property instead of having a badly coupled system using smelly Find methods
if you're using DI extensively there's no need for singletons basically
neither Find methods
Also that, a proper DI system should essentially replace everything in the end, and it will be easier to replace a singleton than a Find method
https://www.youtube.com/watch?v=hKtbGYQVw08
I cant find any info on this, and I'm trying to make AI for my zombies. I want them to walk around obstacles using ray casting - how could i get something like the result in the video?
I do not wanna use the Unity AI system, because it seems like overkill, for just simple zombies in my case.
The main objective of this code sample is to explain how to write an AI for enemy player to detect and avoid obstacle easily using Physics.RayCast. You can find the tutorial here :
Best case scenario there's a single provider providing registered instances based on the context. Either through a factory or as-is
Singletons aren't truely static though which is why it's more preferable to use them if you're worried about misusing globals
to be clear, 1 single find is used and all the rest is manually passed dependencies + inits without any finds.
its purely to "connect" the newly loaded scene to the loading service
That's definitely a lot better than what I thought you had, yeah
blah blah other stuff
I have refactored code by others in such games to remove Finds as i accept they are not reliable or good to use.
i got it!
my mistake was in other thing
Keeping the game manager as the only singleton and doing service locator pattern is also another great idea if you don't want to bloat up a project static types
Reason you donāt make your classes accessible by default is so that junior programmers will come to you asking how they can access it, and you tell them āYou donāt. What exactly is it youāre wanting to do?ā
So they resort to just using a Find method to access a random instance which might not even be a singleton?
Heh, well ideally not. But that's part of this whole discussion right, of knowing when FindObjectOfType should be used and when it shouldn't.
If you're using it to access a class that you didn't write- you probably shouldn't be accessing it.
Guys, how can I change object's position according to its parent's position?
Whereas if it is a singleton or has a static reference, it invites you to access it
transform has a localposition, but in general anything specified as local means it's relative to the parent
Okay, i will try it
There are faster ways to look things up than a linear search. A dictionary/hashtable allows for O(1) lookups
Binary search trees allow for O(logn) lookups
im kinda familiar with what O notation is and how it works but im having trouble visualizing how much of a difference this is. can you give a factor by how much slower O(logn) is to O(1)?
O(1) is 1 operation
O(logn) divides n until you're left with 1; however many times you divide is how many operations, what you divide by depends on the data type (but usually log_2 in the context of computing)
O(n) is n operations
that doesnt sound so bad...
this isn't how it plays out exactly, since big-O describes how fast it scales, so it leaves out constants and lesser-degree terms
iterating over a list once or twice are both O(n)
an example might make more sense actually
In general it's not but you should try to get as cose to O(1) as possible
Especially when code performs often these things matter
If the list is 1,000,000 elements long then:
O(n) is 1,000,000 operations
O(logn) is like 20 operations
O(1) is 1 operation
So with a list that long, O(1) is 1,000,000 times faster theoretically
it all depends on the list length
in practice you probably have 100 or 200 GameObjects in the scene
I've like 100k trees in one of my scenes
suppose 2 lists, one with 8 elements, another with 64 elements
an O(1) algorithm will take the same time for both (getting the length)
an O(logn) algorithm will take twice as long to do 64 than 8 (n-element binary tree)
an O(n) algorithm will take 8 times as long to do 64 than 8 (n-element list)
an O(n^2) algorithm will take 64 times as long (nxn grid/combinations)
an O(2^n) algorithm will take 72057594037927936 times as long (0-1 knapsack)
an O(n!) algorithm will take 3146997326038793752565312235495076408801228079725823219216316824782110720000000000000 times as long (permutation)
brother where did that factorial come from
or is this just an example for example's sake?
it's an example
you can do a factorial it if you set your mind to it
O(n!) algorithms do exist, like permutations
i can't think of anything that isn't just a permutation in more words
Some naively written algorithms have factorial running time
oh yeah, there's an algorithm to find the determinant of a matrix that's in factorial time
you must have been looking at mine...
so im trying to make a pong copy, just to test my knowledge, and ive encountered one issue, im not changing the y axis, they are set through the rigid body, to give a more natural feeling, however, once it hits the ground, the y velocity is set to 0, is it possible to just invert it? so +8 becomes -8, and vice versa
uhh i don't think pong should have a "ground"
watch a pong video
thats entirely possible, yeah. depends on your setup
im not changing the y axis
Of what?
however, once it hits the ground, the y velocity is set to 0
Once what hits the ground?
maybe set your physics materials to 1 bounce
i think they mean the walls
-
the ball
-
the ball
no, the walls don't have collision, once the player touches the wall, the game is over
the floor is a floor
and so is the ceiling
im confused now
there's like, 5 different y axes for a gameobject with a rigidbody
In OnCollisionEnter use collision.relativeVelocity and Vector2.Reflect to calculate the new velocity
ok this is starting to not sound like pong
have you never seen pong
yes
you bounce off the floor and ceiling
no, the ball does that
ok im just gonna crash out
you control a paddle, not the ball
i never said you control the ball
ok this is clearly just a case of you guys using different terminology for walls and floors
when did we start talking about table tennis wtf
you said, once the player touches the wall, the game is over? so the player is the ball?
idk chris mentioned paddles
pong has paddles
oh my god its called common sense
table tennis has paddles
obviously when im talking about pong and something moving on the x and y axis, its referring to the ball
maybe i misspoke but its still common sense
ok no the problem is people come here way too often talking about stuff with the wrong words so im not automatically assuming you're referring to that lol
saying the ball is the player makes it really confusing what you're actually talking about
well now we know 
are you saying the walls as in, the right/left edges of the screen, and floor/ceiling as the top/bottom edges of the screen
yeah so if you're doing physics i think you could just make everything bouncy without any friction or drag
My recommendation: #š»ācode-beginner message
the physics engine is not designed to give perfect elastic collisions etc, and won't.
so this is my game im working on and i have a question on how i could improve the note hitting feedback in regards to the animations on the monster.
whenever i successfully attack, miss an attack, or dodge an attack, an animation is played corresponding to that on the monster. the issue is that it seems a bit jittery and doesnt always do the right animation when the gameplay starts to get faster.
ideally, attacking the enemy will cause it to scale down and being attacked will cause it to scale up but will always scale from its current scale so it doesnt look jittery. another thing is that once it is finished scaling, it needs to slowly return back to the original/normals scale. does this make sense and is there an easy way to do this?
how do I make a 2d object clickable? I've searched in yt and most of the tutorials are for 3d and the 2d ones are just some mumbo jumbo or free assets that dont actually explain anything
Basically the same as 3D just with 2D colliders instead of 3D colliders and PhysicsRaycaster2D instead of 3d
what kind of 2d object is it?
what i do personally is have a child with an image and turn down the opacity since an image has a raycast on it already
but maybe not the best way
You need:
- Event System in the scene
- Physics Raycaster2D on your camera
- Collider2D on the object
- Script that implements IPointerDownHandler on the object (alternatively you could use the EventTrigger component, but I don't recommend that)
This is the best way
i want something like a button but its part of the map instead of an ui button
by part of the map, do you mean like a minimap, a physical map in game, or something else?
i mean part of the place where you walk in
the environment
yea
Praetor has given you the answer
the one praetor is definitely an option, but i'm checking if there's a simpler method
There are simpler ways, but the one I shared is the best because it will automatically give you appropriate interaction with UI elements and other objects that cover it
ok then, ty
As well as giving you the option to easily implement other interactions like OnPointerEnter, OnPointerExit, OnPointerUp, etc.
IPointerClick handler
- add a physics raycaster to the camera and an event system to the scene
Yes those were mentioned #š»ācode-beginner message
I just read the small reply bit š
We need more threads
imo every question should be a thread
I guess that would be the forum style discord channel though.
another way to ask this is:
is there a way to increase scale to 2 over the course of 1 second no matter what the original scale was? and then after it reaches 2, bring it back to 1. I know this is possible with lerping in a script but setting up all the different interactions would be annoying so im hoping theres a more automatic way
what different interactions? This is literally 1 coroutine for all cases
possibly silly question, but is it possible to just make this a ui canvas gameobject in the world instead of the screen space? then just utilize the button gameobject as that ui canvas' child?
float targetScale = 2;
float animationDuration = 1;
float scaleDifference = targetScale - currentScale;
float speed = scaleDifference / animationDuration;
Then use Mathf.MoveTowards each frame with:
float currentScale = Mathf.MoveTowards(currentScale, targetScale, speed * Time.deltaTime);```
There are no UI elements involved in what I'm talking about.
Is it possible to make world space UI elements? Yeah of course but it's not necessary here
and it means a whole separate set of objects.
ah right he asked for making any 2d object clickable
I hope someone can help because I have absolutly no clue how to work on this problem.
i guess i can do something like this or the coroutine as steve said, thanks. Will just need to make sure to wait a second and bring the scale back to the original after each hit
i was gonna possible change the position as well as scale but its probably not needed anyway
could use the same logic
Hello
hello
I think you are asking in the wrong channel, remove from here and try #šāart-asset-workflow
Aight, thank you!
I got told to post this here, but can someone help me with this issue
you were also told how to post code which you have conviently ignored
you were also shown how to share code, that wasn't one of the ways
Dude Idk how to do this, Im illiterate
tough
That's ChatGPT code innit
Idk, I learned it from yt?
surely you know whether you copied it from ChatGPT - all those comments scream "generated by AI"
you mean copy/pasted, not learned
Learned tyvm
ok so what does it do?
What is the point of this arguing
It allows you to lean?
It all started because I didn't know what to do?
how to make children object not to follow parent object?
either move it in the opposite direction of the parents movement, or unparent it
Don't make them parent/children if you want that.
I agree with Steve's general sentiment, but I think we can probably try to help you First before going into why ChatGPT & Co are usually a waste of time š
Maybe you can describe what it is you're trying to accomplish?
Is it Mouse Look?
So with that code it allows me to lean left to right kinda like Rainbow 6, But I tried everything connected to that and it still does the jitter, but yes its something with the mouse look
I don't see the point in helping somebody that didn't bother to make their own code. I suggest you take lessons in Unity to get familiar with how to write code yourself, and then come back with actual code so that we can help you solve any possible issues
its nothing with the code
If it's not the code, then what is?
Is it obvious why getting your code from AI gives you very little knowledge on what it actually does? And now you end up with a bug that you are unable to solve yourself
It's very clearly from AI
//(You don't have to use the mouse buttons if you don't want to, you can do "Input.GetKey(KeyCode.Q)" for example)
Who are you talking to here?
Is using fixedupdate for movement updates similar to multiplying motion by time.delta in regular update calls?
not really no
they both have their own deltaTime
Maybe we can pretend @placid ferry came on here just asking a very broad question, how to.. "implement leaning like in Rainbow 6"?
And we workshop it from there?
But both methods would make consistent movement independent of frame rate?
fixedupdate and update don't run on second intervals, if you need to convert per-time stuff to be used per frame/physics tick, the deltaTime converts from the per-second value to the per-frame/tick value
do be fair those don't look AI comments.
Typically you use
//Gets Input For X Input.GetKey
I think they mentioned it was from a youtube tutorial. Linking to it might be a good start too.
there is too much thought in the comments to be AI
you could, but there's more to it than just update vs fixedupdate
Generally that's exactly what AI does
Well Iām not using physics too much in this game
update is a change per frame
fixedupdate is a change per physics tick
then there's not much use for fixedupdate
just use deltaTime
Icic thanks
It was yes and thats why there is comments In the video he coded the WHOLE thing right infront of me, but do you want me to link it or? mb I misunderstood
AI comments are more like stating the obvious like
// Jumps the Character void Jump
also inconsistent capitalizing, AI Is more predictable
post code with links as per š
also send the video
š Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
š Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
The best way to write comments for yourself is to write comments as if you had an audience
Because the you in a week is a different person from the you now
So if I understand it correctly,
in the video, you're trying to lean by pressing the lean key, but after it finishes leaning, it snaps back to center?
Yes
and do I just link the code thing or is it a download
paste the code on the website , save and send link. Its difficult to view code how you sent it on mobile
Sounds like your animator might have a transition back to your idle state that doesn't have its transition rule properly configured (so any time the lean animation finishes it automatically goes back to idle, when it should be waiting for you to release the lean key).
A tool for sharing your source code with the world!
the think is it does it either way.
when leaning and on idle
if ur free I can call and show you
wait no you were right
Im super sorry abt that
Fantastic :D So you think you're able to figure it out?
I'll try anything and if I can't do you mind if I DM you if I can't figure it out?
I'd rather you didn't š But if it's animator setup stuff, we have #šāanimation and the people lurking there are probably a lot better at that stuff than I am.
Thank you sm
this server exists, utilize it
ok, mb
To be fair, after the response they got initially I can see why they'd shy away š
inventoryManager = transform.root.GetComponent<InventoryManager>();
inventoryManager.weaponName.text = gameObject.name;
inventoryManager.ammoDisplayList.gameObject.SetActive(false);
handAnimations = inventoryManager.handAnimations;
print(handAnimations.isActiveAndEnabled) ;
handAnimations.runtimeAnimatorController = animator;
Cannot update the runtime controller while the Animator is being evaluated.
UnityEngine.Animator:set_runtimeAnimatorController (UnityEngine.RuntimeAnimatorController)
Tablet:OnEnable () (at Assets/Code/Player/Controller/Items/Tablet/Tablet.cs:79) -> "handAnimations.runtimeAnimatorController = animator;"
Im making a weapon switch, works with all items, having same on enable code in them, yet this one tends to not work
Based on the error I'd guess you need to disable the Animator before trying to change the animator controller.
hi i've got these 2 lines
unspawnedMatch.transform.SetParent(null);```
but neither do anything? unspawnedmatch has a rigid body, a parent, and a reference, the code is running, i've debugged all this already. but iskinematic is true, and the parent is not null after running this. how come?
how exactly did you debug them?
make sure that unspawnedMatch gameobject is the correct object?
are you looking at the right object?
can u show the full script instead of just this snippet?
make sure the code is actually running
make sure there are no errors (at runtime)
make sure there isn't other code undoing it
yes, every match that spawns is kept as a parent, there is no other objects it could be with the name that's being debugged
show us the full code including the debug lines and what gets printed in the console
i don't have any code that sets it to true
you haven't shared enough context yet for us to help
Hey everyone, I am not sure if this is the right place to ask or not but did anyone ever experience the player skipping through the terrain and looking this?
I am basically using ThirdPersonController starter asset and I've changed the prefab the main issue here is that most of the times its working perfectly fine with all animations hence that is why I am very confused why this issue is occuring. Thank you
private void Start()
{
drawer = transform.Find("MatchBoxDrawer");
spawnPositon = drawer.transform.Find("MatchstickSpawner");
SpawnMatch();
}
private void SpawnMatch()
{
if (unspawnedMatch != null)
Destroy(unspawnedMatch);
unspawnedMatch = Instantiate(matchPrefab, spawnPositon);
unspawnedMatch.GetComponent<XRGrabInteractable>().selectEntered.AddListener(OnMatchGrabbed);
unspawnedMatch.transform.SetParent(drawer);
Debug.Log("Match spawned");
}
private void OnMatchGrabbed(SelectEnterEventArgs args)
{
Debug.Log("Match grabbed detected");
Debug.Log(unspawnedMatch.name);
unspawnedMatch.GetComponent<Rigidbody>().isKinematic = false;
unspawnedMatch.transform.SetParent(null);
unspawnedMatch.layer = LayerMask.NameToLayer("Default");
unspawnedMatch.GetComponent<XRGrabInteractable>().selectEntered.RemoveListener(OnMatchGrabbed);
Debug.Log("QLJHKDFWSNLKJHFESR");
Debug.Log(unspawnedMatch.GetComponent<Rigidbody>());
unspawnedMatch = null;
SpawnMatch();
}
Debug.Log("Is kinematic after?:" + unspawnedMatch.GetComponent<Rigidbody>().isKinematic);
Debug.Log("Parent after?:" + unspawnedMatch.transform.parent);```
put these where you have the QKJDLKFJLEKJR thing
wait not in editor
99% chance you're simply looking at the wrong object
Which object are you looking at?
The prefab?
is match grab getting detected?
like is OnMatchGrabbed getting called ?
have u checked?
well yes cus all the debug logs are running
there is 0 other objects with the same name in the hiearchy
time to start showing some screenshots
show - e.g. - the full unity editor with the object selected and the inspector with rigidbody showing kinematic true and the log in the console saying it is false
what u wanna se?
I think I made it very clear what I want to see
this is literally gonna show what i told u mate
Show it
One screenshot, full unity window. Object selected, console visible
literally why, is this a "i dont trust you" thing?
Yes
i don't think it's that unreasonable to not wanna show my entire project mate
This isn't what I wnted to see
I wante4d to see the full unity editor window
if you don't know how to help then don't act like you can no need to act like im just lying
Then we will not be able to assist you.
Because 99% of the time, things are not as people say they are, and simply showing the screenshot reveals that
i have showed you what you asked to see
No, we have no idea which object that is the inspector for
Also, combine the logs into one:
Debug.Log($"{unspawnedMatch.name}'s rigidbody is {unspawnedMatch.GetComponent<Rigidbody>()?.isKinematic}", unspawnedMatch);
the whole point is I think you are looking at the inspector for the wrong object
It is
also, add the gameobject to the log so you can actually check the object directly
You have not
not really? people making private games is very common
Debug.Log($"{unspawnedMatch.name}'s rigidbody is {unspawnedMatch.GetComponent<Rigidbody>()?.isKinematic}", unspawnedMatch);
You are not in possession of nation-state secrets
Good call, updated
If you are unwilling to show us the information we need to help you, then we cannot help you.
you don't know what im in possession of
if you were you wouldn't be asking here š
Feel free to redact any classified documents after running it through your authorized classifier
mhm indie game devs making a game is impossible
that's not what we're talking about at all
I literally do have state secrets in my projects. I literally do 3D simulations for the department of energy. I can still send screenshots of an inspector with a game object name
So send it
got any nukes I can borrow
asking for a friend

Yes, turns out we've dropped like fifty of them over the past century that we literally have never found.