#💻┃code-beginner
1 messages · Page 622 of 1
wait you replaced all Quads with Planes?
okay I think the problem is its too small
and the minimum region area is probably too big
just noticed you scaled the floor at 0.1
okay so ill try to just add in a big plane somewhere and see if that bakes
yeah try that first
it is baked but very wierdly
its above the plane
why is this happening first of all, and also if we get the offset fixed, i might just add in a plane that is inline with the small planes, and just not bake the small ones
i know its ineffcient but idc im very timepressured for this
hmm yeah something is odd
welp I locked myself out of both of them
wdym ?
im actually going to crash out why is this so complicated to do
if (Input.GetMouseButtonDown(1) && notWonYet) // right click
{
if (hourHandCol == Physics2D.OverlapPoint(mousePos, 3, -0.5f))```
i swear baking should be straightforward
normally it is lol
layer 3 is the hourhand layer
do you have any clues on what to do next?
trying to think on what it could be , normally works fine out the box lol
like the button on nav surface that says Bake
so i assing a nav surface to the plane and bake?
mines not even baking regular cubes now
wtf is happening
either that or my gizmos aint showing lol
you dont need to assign anything
all the collection is done according to the Object Collection dropdown
oh
whateever this is
yes please! one baked prism on a plane!
btw its generally a bad idea to configure things with the Center mode on the gizmos
what does that mean
especially child objects
with Center mode you're not seeing the true orgin of the object but a Center version of it.. So it may not always reflect where the exact pivot is
how do i turn that off
shouldnt that still work ?
thats why the hour hand is working when the minute hand doesnt
you don't "turn it off" , just switch it to Pivot mode
but if you already made all your tiles to match Center than you probably want to keep it for that or switch it as you go
i think ill keep it, im really not trying to touch anything unecessary im scared everything will brake atp
i actually have no clue what to do
ohhh ok
even with the normal baking random triangles are popping up that stop my enemy from moving
wdym random triangles
it is.
hmm . you can control which objects get baked / wich area
actually now I think of it, it could be other layers
you see that lighter coloured blue right?
that is going up and its like a really big 3d triangle
yeah because it baked something at a higher plane
so its trying to connect with a slope
yeah but there isnt anything there though
try putting the Use Geometry to Colliders
still bakes wierdly
whats over there ? by that slope
thats the "target"
my bad i didnt know it was there because the "enemy" stood on it completely
over here is there something? maybe invisible collider?
ahh..shit..I gotta run out for like an hour or so' ill be back a bit later.
nope dont think so
no please :(((((
thank you so much though
oh damn alr ill try that
i think i found the most DUMBEST way to solve it
change the position of the sprites
whenever I left click
ok, so if anyone else could help with this i would highly appreciate it, how does one bake walls into navmesh that spawn after runtime?
i am generating a maze, and i need zombies walking around, and i have done the floor, so they do go towards the target, however they still go straight at the tarbet thrgouh walls
yet how would everyone think when they play it?
normally in the bake walls get carved out from the bake
Yeah but i tried implementing a script similiar to the one at the start, and they did not bake
like the floor(plane) is baked because i baked it before runtime but the walls no
if its not baking its somehow not detecting the walls
yeah because even doing this is wrong
they're supposed to bake them together
the walls. / obstacle provide the "negative" space to be subtracted from the NavMesh
hold on lets make a thread so we don't flood
i'm making a top down roguelike
so far i have a player character that moves and can attack an enemy and kill it
but the attack can't turn
how do i make it turn to the direction of the mouse?
ill leave that up to you idk how to make a thread
dir = (mousePos - origin).normalized
this means nothing to my brain
right click message and do create Thread
to get a direction you can always substract the origin and targetpos
i am generating a maze, and i need
but where do i place that
well everytime you want to get the direction
usually every frame
Update
ok thanks
ez; MouseUp and MouseDown
Vector3 mousePos = myCam.ViewportToWorldPoint(Input.mousePosition);
if (Input.GetMouseButtonDown(0))
{
transform.position = new Vector3(transform.position.x, transform.position.y, -1);
}
if (Input.GetMouseButtonUp(0))
{
transform.position = new Vector3(transform.position.x, transform.position.y, 0);
}```
why
once I figured out the z position of the images were whats causing the override
why not just put them in seperate layers then each one gets their own raycast + filter of that layer
I thought — just made it clear what it is you're moving
and make it move closer to the cam whenever you move it
and it functions, which is the most importaint bit
yeah this goes beack to being a depth issue
nav btw i added in a few things into the thread if you want to read it
ok
do you know what example code is ?
nope
means dont blindly copy verbatim
well the word example is pretty common even outside of code
never heard of it
@mortal ginkgo Beginners vary, assuming you know how to declare a variable wasn't unreasonable
english is not my first language
so where is the new thread
@mortal ginkgo Have you studied cartesian planes?
what
https://docs.unity3d.com/Manual/scripting-vectors.html @mortal ginkgo
@mortal ginkgo If you don't know what cartesian planes are, I don't think anyone's going to be able to provide you with a basis for understanding the operation. So maybe just memorize that normalizing the output of (vector b - vector a) will give you a direction from a to b
what
i just wanna know how to make my attack turn to my cursor 😭
you need a very basic understanding on how vector math works if you want to make a game
I showed you
@mortal ginkgo Look up cartesian planes, do you remember that from high school?
i'm IN highschool and have not learned that
especially in a different language
for example transform.right = (b-a).normalized will turn towards that direction
no just give me the code so i learn by example please
I already gave you code
Oof
there is not much more to it
it does not teach you anything by copy and paste, you should at very least undserstand what you're copying on How it works the way it does..
learn that after seeing it
how do i get the mouse position
if you dont know how to create / declare variables, then you're doing too much already and take a step back
funny thing happens when you type that same exact thing into google as its a dead horse thats been beaten to a pulp at this point
magic 💫
probably shouldn't be sarcastic when talking to a dum dum
anyone know how to import blender files into unity with textures? i tried it out and it wont work. screenshots and video below
its not sarcasm its actually amazing
I wish I had these tools growing up
note how most will show two, MousePosition which is only a screen point, and MOUSE WORLD position which is in the world
i am using it i'm talking about just telling me straight
Guys, just got a quick question when it comes to an inventory system in 3D
Should you be instantiating a selected item from your inventory every time you select it and destroy it after selecting another or should you turn it off until you select it again, basically making it invisible
both are valid. Id prefer deactivation over instantiation
could you explain why?
Dectivation only consumes resource when you create the item, after that its pretty much loaded in memory
the other one you need to create space in memory, then destroy releasing memory then create space in memory and so on
those computations arent free
they're pretty tiny though its probably being over the top
not a code problem. you can apply your texture in unity easily or use something like gltf to export with the texture + material packed together.
the gltf doesnt render into unity
Add the gltf package to make them work: https://docs.unity3d.com/Packages/com.unity.cloud.gltfast@6.10/manual/index.html
if your blender mat does more more complex stuff than just use the principled node then it wont export the mat properly
Is there a better place for resources for smoother animations between my character states? All my animation fire correctly but it is really choppy. Maybe because they are just place holder animations from Mixamo but wondering if anyone has found some really good tutorials?
this is a code channel
Sorry I assumed it has to do with how the code triggered the animations
Hey yall, having some trouble figuring out how to exactly do something.
Currently attempting to figure out dictionaries, and one of things I wanted to have is whenever a button is pressed, itll move onto the next dictionary log (theyre ints, each moving upwards.)
Basically:
public void TimemakerTutorialDialogues()
{
sentencesaying = TimemakerDialoguePreGame[1];
}
Then on button click, sentencesaying would equal TimemakerDialoguePreGame[2].
Is that possible?
Please @ me if you respond, thanks!
Yes anything is possible but the way you're describing this it sounds more like you just want a list or array not a Dictionary
why not just a List
Dictionary doesn't make a lot of sense if your keys are just a consecutive series of integers - that's just an array/list
with any of these - you would just have a variable like int currentDialogueIndex; and do currentDialogueIndex++ when you want to move to the next one
and access the text with MyDialogues[currentDialogueIndex]
Ohh that would be a lot better, Ill try that out. Thank yall!
its difficult to say thats the case, you havent shared the code or more context to the setup lol
maybe a video of issue wouldn't hurt
mmmm
is that good way to get data from script that are not MonoBehaviour?
nothing is getting data here
but thats how you instatiate it to be accessed sure
nothing here is getting data from anything. YOu're creating a few objects
I thought I was getting data from namespace
Thank you yall
namespaces are just parts of the names of your types
they don't contain any data
Good to know
basically its like "Categories" that those classes belong to , so they can be separated (so classes with same name dont cause Already Defined error)
Code folders
NullReferenceException: Object reference not set to an instance of an object
UnityEditor.Graphs.Edge.WakeUp () (at <e6407ce49b2b4392b94de9c9c789a955>:0)
UnityEditor.Graphs.Graph.DoWakeUpEdges (System.Collections.Generic.List1[T] inEdges, System.Collections.Generic.List1[T] ok, System.Collections.Generic.List`1[T] error, System.Boolean inEdgesUsedToBeValid) (at <e6407ce49b2b4392b94de9c9c789a955>:0)
UnityEditor.Graphs.Graph.WakeUpEdges (System.Boolean clearSlotEdges) (at <e6407ce49b2b4392b94de9c9c789a955>:0)
UnityEditor.Graphs.Graph.WakeUp (System.Boolean force) (at <e6407ce49b2b4392b94de9c9c789a955>:0)
UnityEditor.Graphs.Graph.WakeUp () (at <e6407ce49b2b4392b94de9c9c789a955>:0)
UnityEditor.Graphs.Graph.OnEnable () (at <e6407ce49b2b4392b94de9c9c789a955>:0)
help please!
this is usually the editor taking a 💩
restart Unity, usually fixes it
some window, layout , tab got messed up drawing
and could that make my game scenes not pass to each other?
normally this should not affect anything in the runtime
UnityEditor isnt a thing during Build
this error is probably as old as unity lol
I usued to get it a lot with having the animator docked with other windows but that was back in 2019
if it keeps happening after you restart unity, you can try Resetting your layout or, perhaps delete library folder and rebuild all cache
can someone help me on the first screen shot i get a error telling me to use "IXRSelectInteractable" so i switch XRBaseInteractable with "IXRSelectInteractable". but then i get a error telling me that "IXRSelectInteractable" Does not contain a definition for "CompareTag." Im using the new XR Interaction Toolkit and Unity 6.
Can you share the exact error for the first one?
'XRBaseInteractor.CanSelect(XRBaseInteractable)' is obsolete: 'CanSelect(XRBaseInteractable) has been deprecated. Use CanSelect(IXRSelectInteractable) instead.'
alright well since the latter is an interface there's no guarantee it's a Component with CompareTag
so you can do something like:
return base.CanSelect(interactable) && interactable is Component c && c.CompareTag(TargetTag)```
how should i start learning unity (2d) other than "! learn"
nothing wrong with learn
this has seem to fix the error. Thank you!
!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.
https://paste.myst.rs/n6ckbbzm when trying to split asteroids should i try to do it in the bullet script or the asteroid script im not sure how to go about this right now. from what i see it could possibly make more sense in the asteroid script but im not 100 percent sure
a powerful website for storing and sharing text and code snippets. completely free and open source.
asteroid one
both, basically.
The bullet script should do something like call a function on the asteroid script. That function would split the asteroid
You could also read through the !docs and figure it out on your own
ohh ok thank you i was wondering if i should have seperate prefabs for each of the smaller asteroids i want to spawn with 3 different scriptable objects because im kinda not sure about this
Hey guys, for some reason this code i got off of a youtube video is not working for me at all(i cant move and i can only move my camera up and down). Is this something wrong on my end pr is the code just outdated? https://pastebin.com/RXZ1dXgw
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Show the inspector of this object
Also your console window when you're running the game
Almost certainly you made a mistake.
so I'm getting this error TransientArtifactProvider::IsTransientArtifact call is not allowed when transient artifacts are getting updated
And i searched it up and i saw that it may just be a bug in unity 6
I assumed that was the case for me as well, since everything in my project seems to be working fine
I was just wondering how I could remove this error from appearing? because its kind of annoying
this is the inspector of the capsule, also there is nothing in terminal
right
ignore everything
turns out its meant to be assigned to the parent object not the capsule
anyways im falling through the ground why is that?
either ground doesnt have collider or your player is already starting inside / below ground collider
the floor has a mesh collider and my character is a few feet above the ground
it seems to be a different problem sorry
either my character teleports into the ground, or onto the roof when it is played, depending on how high or low i put him
do you have any other scripts besides the Player one
nope, well not on the object
i tried lowering the size of the character controller radius as it was quite big, and now i just teleport to being stuck to the roof
uncollapse this capsule collider
anyway you should not have any other collider for the body besides CC
CC is already a collider
is cc capsule collider or character controller
Character Controller , sorry
btw for event Character Controller can detect triggers for OnTriggerEnter
but if you need to detect another collider touching the CC (maybe pushing rigidbody boxes) use https://docs.unity3d.com/6000.0/Documentation/ScriptReference/CharacterController.OnControllerColliderHit.html
OnCollisionEnter doesnt work for CC
Quick question? How do I add these things for my scripted code?
fields ?
wdym "these things"
what things?
still what? Use your words.
I'm gonna take a wild shot in the dark and assume your PlayerMovement or another script has some sort of compile error and cannot finish compiling so those fields won't show up yet
other than that you haven't given us much info to work with lol
My player can see through walls, i.e, player camera is clipping through the walls. How can i fix this?
looks like this (im looking into a corner and those are walls on the left and right
hat need some help on this deal
NotConfiguredClientException: Unity VCS client is not correctly configured for the current user: Client config file C:\Users\Monke\AppData\Local\plastic4\client.conf not found. Please execute 'cm configure' to perform a text mode configuration or 'plastic --configure' for graphical mode.
not a code question, check the camera's clipping settings
sorry guys for using the wrong channel, changed it o 0.1 and works, thanks!
what does this mean?
tell your friend to take a screenshot like a normal person
do you know what this means though?
NotConfiguredClientException: Unity VCS client is not correctly configured for the current user: Client config file C:\Users\Monke\AppData\Local\plastic4\client.conf not found. Please execute 'cm configure' to perform a text mode configuration or 'plastic --configure' for graphical mode.
this is different from what you shown above
yeah, i’m here for 2 errors.
nope.
so remove the package
remove that.
yes
OperationResponse 230: ReturnCode: 32767 (ApplicationNotFound) Parameters 0 Server: NameServer Address bs.photonengine.io:5058 Unity.Engine.Debug:LogError (object)
sounds like an issue with photon
what’s next?
I dont work with photon so i havent a clue
well. Version Control is still there ?
mhm. so delete that version control menu)
delete that version control dropdown?
its a package not a dropdown
you can remove it
where can I find support for photon?
https://forum.photonengine.com/discussion/19264/urgent-help-operationresponse-230-returncode-32767-regions-mismatch
check under the Please note
When I try to connect Photon Network today, this message returns. OperationResponse 230: ReturnCode: 32767 (Regions mismatch). The game works until ye
I think he deleted it. was that all?
should be...Unless you have some asset somehow trying to access UVC for whatever reason
cool think you.
thank
you can edit discord messages 😉
how would I be able to create a directory to store and read files from? Would I create a filepath as a string and then use Directory to create a directory?
And then if that is correct how would I create a new .json file? Like what would be the best way to go about this if I want my game to store player-created grid-maps
didnt I send this info already ?
It's less about the code and more about how I should go about this? Should I store this stuff in the game itself or should I make a folder outside the game to holde json files free for the player to observe?
oh, I only read the code stuff and kinda overlooked the other text, lol
this is where we normally store files at
System.IO again to create Directory inside
okay I got it able to create it, but can you not convert a dict to a json and write it to a file? it comes out empty
ahhhhhhhhh I used the wrong json
but you shouldn't just be saving a dictionary alone
you ideally want a SaveData object (struct or class)
mark it as System.Serializable
if you want to display Dictionary values in the inspector too you'd need a custom dictionary asset or use 2 structs
Does the SerializedDict from the rendering package show up in inspector somewhat nicely or is it just for data serialisation
Does it? I haven't tried it but can give it a try
No clue!
how do I invoke JsonConvert? I have added the package, do I have to use a 'using' at the top of the file?
I’ve always used ayellowpaper’s solution on the asset store
you need the namespace ofc
is it just newtonsoft?
ok I got it working
well I got it working but I have a new error now that seems odd. Is that a memory value?
are you trying to use .velocity somewhere ?
wait are you using rigidbody property in MB ?
in MB?
MonoBehaviour
I either can't view monobehavior or it doesn't have it
idk Im just guessing because you haven't provided much info
check the stack trace of the error
it's trying to get rigibody from the gameobject tile, but I never gave the tile prefab a rigidbody
What's "it"?
Share the error details.
the "it" in question is a SerializedJson string serializedJson = JsonConvert.SerializeObject(tileStorage, Formatting.Indented, new JsonSerializerSettings() { ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore });
https://paste.mod.gg/diycteubrioi/0 this is the full stack trace error
A tool for sharing your source code with the world!
Are you trying to serialize a MonoBehaviour?
I don't think so, a monobehavior is a component, so it would be visible on the gameobject on the editor, right?
What are you trying to serialize?
Share the GridManager.saveExportGrid code.
ok
Or rather the whole script.
gotcha
A tool for sharing your source code with the world!
I'm trying to serialize a dict whose key match pair is a vector2d of it's x,y location and a game obj
tileStorage is the Dictionary i think..oh wait thats another script nvm..
Yes. It's not just the amount of data but where and how it's stored.
I just want to know to get a better understanding of unity
mostly the problem is you don't have a way to serialize it properly
also yes it's not clear which bits you actually want to serialize
for example stuff like instance IDs are useless to be serialized.
btw this is why i suggest having a wrapper class
public class SomeSaveData {
public Dictionary<T,T> whatever;
//more stuff```
would it be better to just have an enum property that describes each obj and store that in the dict instead?
so would having it as a class be better for saving it all?
or would it help readability or does it help the serializer serialize it?
in the long run it will benefit you to have it all in one spot imo
that makes sense, having it split would probably be for the better instead of hiding away in the grid manager
Is there a way for a script to reference another script without having to have a SerializedField Script of it?
SerializedField is an attribute not really directly related to referencing
it just exposes private variables in the inspector, same as public would
so you mean Inspector refrences vs something else
generally at runtime you use GetComponent,or another form of DI instead of inspector
Sorry, referencing was the wrong word, I think. I want to call methods from another script, but I feel like SerializeField-ing the script in a script would start making things messy
referencing is correct
SerializeField doesnt control references though just want to make it clear.
it just helps you assign it inside the inspector
linking in the inspector is a like form of Dependency Injection in its own right
assigning a reference is just
MyCoolScript coolScript =
accessing is
coolScript.Whatever
someone explain to me how the hell i get 2/3 = 0.....
int division ?
havent looked yet hold on
so using [SerializeField] is just an easier way to make sure the script is accessing the correct version of the script in the gameObject that it's in, but you can just assigning it with script name name = script?
2/3 is 0 with a remainder of 2
so your computer is 100% correct
you can't store .666 in an integer variable
honeycomb is an int not a float
yup int division
honeycombAmount
ohh becuase both are int, it gets an int value back
bro... im gonna crash out
thanks..
so i assume i just float(x/y)
well you CAN but you won't get you want
putting the x/y in parenthesis makes the division happen first, THEN cast to float
yeah you'll just get 0 again that way
PEMDAS or something
ngl i spent way too long on this 💔
same
happens to the best of us
I think I've made 3 stupid mistakes that were just "this thing isn't enabled bozo"
and this has only been less than a week into development
Script name has nothing to do with anything. If you don't want to use serialized fields, your only other option is to either provide the reference from another script, or use one of the Find methods and GetComponent.
"so 2/3 could NOT POSSIBLY be 0...." didnt know int devision was a thing
ah, got it
yeah INT doesn't store decimals, it WILL truncate and remove everything past the .
it doesnt round it truncates the part past .
Also, what you're referring to as "the correct version of the script" is what we call "instance of a script/class/struct" in programming.
if you got 1.6 then its going to be 1 not 2
Instances/types/classes is a core aspect of object oriented programming, so you probably should make sure you understand it correctly before proceeding.
I do, I just completely forgot about that concept
i have the weirdest problem.
somehow the children of an empty object are changing the pivot OF THE PARENT
how? how you tested I mean
press Z
wait a second wtf
ahh Center Pivot strikes again
you need to be in pivot mode if you want to see the actual pivot location
Center mode takes the average of all the children
Very good for rotating all the objects together, almost useless for everything else.
Thanks for setting it as default unity 
yeah It's super annoying that Center is the default
thanks
i have a question how hard is it to do inverse kinematics?
"to do" like implement from scratch? Or use existing solutions in your project?
well, i do not want to use any kind of assests and atm i'm just trying to do IK on a box with 4 legs to see how it works and whatnot. so from scratch ig
That depends on how familiar you are with the math and how good you are at writing code.
There are solutions provided by unity. It doesn't have to be a third party asset.
But yeah, implementing from scratch can be quite difficult
well main point is i wanna learn. and second i do not want to use assests beacause if i do that why not make the entire game with assets and not learn anything
well not much is why i asked here but ig it will take time fro me to learn
I mean, do you manufacture a drill from scratch when you put up shelves?
Are you making a game or are you making an IK system?
while thats true there is always a time where you just need something that works, plus you still need to learn a bit on how it works
i see
If your goal is to learn,then sure, go ahead. If it's to make a game, then it's probably better to not reinvent the wheel.
There's a difference between using tools and doing asset flips
so you're referring to a tool within unity that helps make them?
Yes. There some support in Mecanim. And there's even more support in the Animation rigging package. Or whatever it's called.
Animator already has some of it built in, the Animation Rigging package extends that and has neat features
i see i'll take a look at my options from scratch and that as well. if i'm able to get a grasp of what is going on when doing it from start might as well learn if not i'll use those thanks
certain assets can be an ideal jumping off point, especially for things you know will end up being replaced/worked on later on, or at least if needed. if all you want is ik, there isnt much harm in using an existing ik solution, you'll get what you want/need right now, and if it sucks you can always work on your own solution
in my own project, ive grabbed a number of free assets, knowing they are temporary. but its been enough to instantly make the game start to feel more like a real game
Hi, I am not sure what I did but after updating some packages my unity game log is now being filled with this error message:```
(Filename: currently not available on il2cpp Line: -1)
NullReferenceException: Object reference not set to an instance of an object.
(Filename: currently not available on il2cpp Line: -1)
NullReferenceException: Object reference not set to an instance of an object.
(Filename: currently not available on il2cpp Line: -1)
NullReferenceException: Object reference not set to an instance of an object.
(Filename: currently not available on il2cpp Line: -1)
NullReferenceException: Object reference not set to an instance of an object.
This only happens with release builds, not debug builds.
Must be some code that is not supported in il2cpp. Or some stripped code(seeing how it doesn't provide file path and code line).
Odd. How do I figure out where that code is?
Can I get a stacktrace?
Good question
Heh... if at least this would happen in debug builds
Is there no option to output debug symbols in a release build?🤔
I have a .pdb so yes there are debug symbols.
But apparently that's not enough for a stacktrace
Ok, then try attaching the debugger to the process.
Ohhhhh
Yeahhh sooooo... the debugger halts for a first chance exception but only shows the top frame where the exception occurs. It's not able to generate a stacktrace either apparently... 🥲🤦♂️
And even that top frame only shows up by address, no source information.
Does it not show what module it's from?
Can you take a screenshot?
hey all, im following this tutorial
https://www.youtube.com/watch?v=l0emsAHIBjU&list=PLcRSafycjWFepsLiAHxxi8D_5GGvu6arf
and get this weird bug when I try to run it, ive fully resterted the project and did the steps from scratch, any ideas on what the problem is?
the code I am using is from https://github.com/SunnyValleyStudio/Grid-Placement-System-Unity-2022
In this Unity 3D tutorial start creating a Grid Building System. First we will use Grid component to calculate a cell position for our mouse pointer position to use it in our placement system. Next we will expend the system with a custom grid shader and an object placement and removal system. At the end of this tutorial you will have a grid plac...
Looks like the preview object you're placing is itself blocking the raycast
I have not looked at your code or your tutorial but that's a super common pitfall people have with this kind of system and it results in exactly this kind of behavior
its just weird that I followed the tutorial step by step and get this and he doesnt
He did something different
with the collider on the preview object
or its layer
and the layermask if applicable
just make sure your ray is ignoring the placed object
and don't forget basic debugging skills like Debug.Log to print which object your raycast is hitting
Is the preview object even supposed to have a collider?
u a smart man
this has taken me like a week
it was bc i was using a box collider
i think
on my prefab object
So it says i have a "Assets\birdJump.cs(6,37): error CS1002: ; expected" but i put a semicolon on the exact line of code
it isnt but im trying to figure out a way to click on the object and then do stuff to it like rotate and someone said to use a box collider
You need to get out of restricted mode in VSCode, and make sure it's fully configured
right now it's not showing you your errors
(and yes you have a very obvious error that should be highlighted here)
Thank u sm for ur help
Ok but how does a box collider on the preview object help with that?
Don't just do random stuff you don't understand
im planning on making a cutscene on my 3d game similar to genshin where the camera pans around, and when it comes to the dialogue the player would have to press a key or click something to skip, how should i approach that? should i use a timeline?
for some reason when i click my leave room btn it opens a lobby panel and i dont want it to do that i want it to keep it hidden idk what to do ive tried several methods but it just breaks my code https://pastebin.com/Mau5V8yr
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Protip make sure you understand the REASON why a solution will (or won’t) work — more important than making something work in early career.
—plus many people here just recommend random stuff due to misunderstanding the question or just wanting to help even with missing knowledge.
thank you so much
If you think all cutscenes will be simple enough, I recommend writing your custom cutscene code — for one reason only — it’s fun!
But if you’re not up for that a timeline and some input management will do.
That’s almost 500 lines of code…
double check the inspector for your leave room button
make sure it doesn't have any extra listeners
Also make sure you assigned the correct button to the startGameButton variable in the inspector
is creating custom cutscene code generally better for interactive cutscenes?
Sprite[] cards = { p_card1.GetComponent<Image>().sprite....};```
if i change cards[0] , it will change the actual instance referred right?
yes because Sprite is a class, which is a reference type
nice
because previously the code was something like
p_card1.GetComponent<Image>().sprite = ....;
p_card2.GetComponent<Image>().sprite = ....;
p_card3.GetComponent<Image>().sprite = ....;```
i couldnt stand it
thanks 🙏🏼
you should get rid of p_card1 etc
any time you have "numbered" variables, you should be using an array or a list instead
just do:
public Image[] cardImages;``` directly
It’s more fun and very educational.
But other than that it gives you more control over everything, so yeah.
The downside is that it’s not exactly a walk in the park to do it.
can you provide me a baseline on how should i do it, like what scripts should i make, some general functions that would be needed and etc. i have a hard time figuring out how to start it so this would be a tremendous help!
Well first decide on how much of the built in tools you’ll keep.
If you want to keep standard “Animation” assets, you’ll need a “CutsceneManager” and a “Cutscene : ScriptableObject”
For absolute control, assuming you’re indeed a beginner, I recommend to just make “Cutscene” a MonoBehaviour that completely takes over the scene’s behaviour, and can reference anything that’s needed
the situation is worse than i thought, all aspects, functions, classes was written in card1,card2,card3...etc
Even if you go with timeline, CutsceneManager should normally have “Start/EndCutscene(Cutscene)” that’d lock input and begin behaviour related to the cutscene, and potentially other methods that enable conditional input controls or behaviours.
-> before
element[0].get("c1");
element[1].get("c2");
element[2].get("c3");
....```
-> after
```cs
Sprite[] sprites =
{
c_Holdem[0].GetComponent<Image>().sprite,
c_Holdem[1].GetComponent<Image>().sprite,
c_Holdem[2].GetComponent<Image>().sprite,
c_Holdem[3].GetComponent<Image>().sprite,
c_Holdem[4].GetComponent<Image>().sprite
};
for (int i = 0; i < 5; i++)
{
sprites[i] = cardSprites.GetCard($"c{i++}");
}```
this is just perfect thank you!
that c_Holdem[0] and all those could also be changed to a loop just like you have below..
nvm on my last part
for (int i = 0; i < 5; i++)
{
c_Holdem[i].GetComponent<Image>().sprite = cardSprites.GetCard($"c{i++}");
}```
i do really question why you need to pass a string$"c{i++}" instead of an int
You might wanna sleep xD
u know poker got 4 suits 13 cards each right?
also yea that i++ is gonna mess up the index, this will skip over values
the data of "which poker" we get is "C1 , S2 ,SA , H2.... etc"
Issue is you’re increasing “I” which is used by the for loop
only data that will parse from server
so everytime when we receive the info, we need to do conversion
no matter what system you're making, you dont need to use strings. could you not just pass 2 ints in that case?
or use an enum, just something representing whatever C, S, H is and then the number
too late, the game is near production and all codebase is set, it is what it is now
so, instead of letting server team rewrite the parsing, i gonna do the conversion in a better manner
hold on
if u wanna see the hellish conversion before
after i rewrite the whole thing
this is what i do after i rewrite the whole thing
instead of making 52 items list, i gonna do serialized object
well im suddenly happier that I dont have to work with any of those codes
theres way too much occasion where u cant uproot those code cuz they burrowed to deep
then u gotta think of a way to bandaid it
at least make it looks nicer
parsing faulty datatype is another thing, they even reference static utility objects with dynamic approach
which i need to rewrite also
like cards, 4 suits 13 cards each right? it wont change, its constant
they made an empty object on manager class, stored references of all the tokens, cards thats immutable, and load them all into managers during initialization
and ignore that object after its loaded, just let it stay there
im not too sure what level of skill you're working with, naturally i assume its a job whenever people mention working in groups but I have a feeling (and hope) that this is more school work/friend group. In which case 🤷♂️ if it works it works
in a more professional setting, these kind of things should be planned so a bad solution isnt planted so deep in the first place
this is a legit company that made apps based on client request
yeah, normal unity app dev team
the "normal" is very subjective here🤓 ☝️
welp im at a loss. if it works it works i guess, the outcome of producing quantity over quality
in fact , they spent 9 yrs working on single project, and still havent gone to production
however, because the boss , or the client is nice as hell, they still willing to sponsor us and give us money to sustain
thats why we dont have any products but still able to live for decades
kyubey your code still has a bug
AllCards cards = CommonHeaderController.Instance.g_HistoryCardSprites;
for (int i = 0; i < 3; i++)
{
int j = i++;
c_ThreePokerCard.c_CardFrame[i].GetComponent<Image>().sprite = cards.GetCard($"c{j}");
}```
ty 👍
I dont know if this does what you think, maybe print out the values of i and j.
or just run this code https://dotnetfiddle.net/C44Dwq
a++ essentially means increment a after this line runs
b is assigned to 0, a increases by 1
frame[0] , query is "c1"
frame[1] , query is "c2"....etc
so c{i++} while frame[i]
wut
what you have is backwards then, look at the code link i sent above
but really just dont use ++, its confusing here for anyone. just do j = i+1
ok 😭
Try going for simple code instead of edgy lol
For example even your variable naming is edgy
Some are prepended with c while others with g
i didnt name those object they are previous curses
😭
i will never name something with prefixes
private int _number, m_number //nope
private GameObject c_xxxxx , a_xxxx, m_xxxx //nope```
```cs
private int number //yes
private GameObject xxxxx , <class/system>_xxxxx //yes```
Is it true that unity does not have code stripping?
No
If I build my project, does Unity automatically filter out all the Debug.Log messages?
Or do I have to manually remove all of them for production?
Debug.Log calls stay in builds
i'm making a top down roguelike. so far i have a character that moves and attacks (melee) in one direction and enemies that die
how do i make the attack follow the direction of the player?
Wait, does trigger inside another trigger work? Suprisingly, google gives 0 results
for 2 on trigger stays
there's a lot of tutorials on this on YT
Im guessing its a 2d project and you dont rotate the player based on his last input (just like 3d games do)? Would be great if you sent the code for the melee though
Off the top of my head id create an enum and set it to whatever the last input was (if the player pressed "W" then the enum would be forward for example) and then put the attack direction based on whatever the enum is, but i bet theres a better solution then that
well the debug messages aren't going to be seen in a production build
so they won't really have an affect
if you're worried (for some reason..) you can always use #if UNITY_EDITOR
i want to have half static field for my poker card objects , mostly references to gameobjects
i know SO can do that , but the problem is 3 out of 54 cards (4 suits 13 cards + 2 joker cards) will be changed during runtime, on initialization stage
is SO still fine for that? cuz u shouldnt change content inside it?
This is basically a singleton pattern, and imho SOs are not the appropriate place for these fields.
aight , ty 👍
For a 2d top-down game with 4 (8) directional movement, if I set up my player GO with a Dynamic RigidBody2D and my monsters also with a Dynamic RigidBody2D but select IsTrigger on the Collider2D.
This should prevent my player & monster from ever pushing eachother?
But I can still use forces to move them manually? For example some monsters might push the player back. Sword swings will knock some monsters back, ...
How flexible and future proof is this setup?
Or is there a setup that offer much more flexiblity? I'm ok with doing some up-front work to get everything working, I'm looking for long term performance and flexibility. It's a multiplayer game.
How can I split a mesh along a plane? Trying to find examples online but I can't find what I am looking for
Just GameAssembly.dll
Sure I'll do it when I am back on my PC
Then you probably didn't load the pdb.
It is loaded, if I set a breakpoint in known code and it halts, stuff shows up as expected
Then that's not the module where you said it threw an exception.
Hi, I have been working on instant games facebook. Does someone has experience with it. I want to know how if there is sdk for it as there is a documentation for it but I am not able to find a way to instan it.
is there a way to get which ui button has been pressed? I'm struggling to word what I want, but when I press a button I want that button that has been pressed to be used in a script. Right now, I have about 6 different buttons which all do (roughly) the same thing, but in a different way. I can't pass through parameters into a method using an OnClick() event, so I need another way to get that button in the code.
Nevermind, I think I have figured it out
@teal viper I have decided to try another debugger, and indeed this one tells me more:cs Thread 1 "014c" received signal SIGABRT, Aborted. 0x00006fffff3fcfc7 in RaiseException () from kernelbase.dll gdb> bt #0 0x00006fffff3fcfc7 in RaiseException () from kernelbase.dll #1 0x00006ffff4429bfc in WriteZStream () from GameAssembly.dll gdb> Now the question is, what is WriteZStream?
Yes I have searched Google, but didn't find a real answer
Apparently it is a somewhat common problem though but none of the solutions I could find really matches
public void DestroyTree(TreeData treeData)
{
var treeInstancesToRemove = new List<TreeInstance>(terrainData.treeInstances);
Debug.Log(treeInstancesToRemove.Count);
treeInstancesToRemove.RemoveAt(treeData.index);
Debug.Log(treeInstancesToRemove.Count);
terrainData.SetTreeInstances(treeInstancesToRemove.ToArray(), false);
Vector3 tempCoord = treeData.position;
float[,] heights = terrainData.GetHeights((int) tempCoord.x, (int)tempCoord.x, 1, 1);
terrainData.SetHeights((int)tempCoord.x, (int)tempCoord.y, heights);
}
trying to remove tree but not working
Do the logs say that the list count goes down?
Yep
I have found the problem. There was an outdated native plugin that didn't match the rest of the package somehow.
I don't see why it wouldn't work then. Just to test, try terrainData.treeInstances = ... instead of terrainData.SetTreeInstances(...)
Also make sure you are referencing the correct terraindata
Take a screenshot of what it looks like in VS
#💻┃code-beginner message that was the solution, all working perfectly now 😄
why would you move a non-code question to a code channel?
cuz u guys are busy with AI sht talking
right, so move to an art channel? don't just shove it in somewhere it doesn't belong
just ask in #🖼️┃2d-tools , the channel police here is real 😒
or there ☝️
people would rather tell you to go ask in another channel than actually help 😅
couldnt find anything in the docu
so thought maybe here someone knows
I came to the channel to help.. can't because know nothing about the tool.. so sending him to the correct place.
That's the whole point of the channels.. ask in the correct place where people with the knowledge can congregate.
This is a coding channel. Consider #facts 
!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.
There is any way to destroy or update tree Collider in terrain except turning off/on terraincollider after destroying trees in runtime
i'm making a top down roguelike. so far i have a character that moves and attacks (melee) in one direction and enemies that die
how do i make the attack follow the direction of the player?
Transform.Forward is the player's current forward direction relative to the parent brain fart, it's always converted to a world direction
oh thanks
but i'm still a beginner, can you show me how it would be used?
So basically the whole terrain is built of one collider, ground and trees included. Destroying the trees requires a complete rebuild of the mesh collider, so the idea is you destroy as much trees in that frame then tell the terrain to rebuild. This could be somewhat taxing if you aren't chunking the terrain that much, but otherwise you could just populate it without the brushes. Oh, I think painting with detailed meshes would work too
You can simple just say projectile.transform.rotation = player.transform.rotation as well
or attack or whatever choice of weapon
ok thanks
how do i get the player into the attack script?
Check out the Course: https://bit.ly/3i7lLtH
Learn 5 different ways you can connect your gameobjects in Unity. Ranging from direct references & singletons to scriptableobjects and injection.
More Info: https://unity3d.college - (and where you can submit your own questions)
Join the group: http://unity3d.group
thanks
Relevant: https://unity.huh.how/references
Choose the best way to reference other variables.
@mortal ginkgo
just a minor correction, because it matters and a beginner will probably be stumped..
transform.forward lowercase t
It might also be .right or .up if it's 2D
oh yeah true. I never consider 2D :)
so uuh
i feel dumb but i feel proud cuz i tried
it's a weird feeling
// using UnityEditor.Experimental.GraphView;
using UnityEngine;
public class PlayerAttack1 : MonoBehaviour
{
[SerializeField] private Animator anim;
[SerializeField] private float meleeSpeed;
[SerializeField] private float damage;
[SerializeField] private Rigidbody2D Player; // <--- added this
float timeUntilMelee;
private void Update()
{
if (timeUntilMelee <= 0f)
{
if (Input.GetMouseButtonDown(0))
{
anim.SetTrigger("Attack1");
timeUntilMelee = meleeSpeed;
}
}
else
{
timeUntilMelee -= Time.deltaTime;
}
anim.transform.rotation = Player.transform.rotation; // <--- and added this
}
private void OnTriggerEnter2D(Collider2D other)
{
if (other.tag == "Enemy")
{
other.GetComponent<EnemyScript>().TakeDamage(damage);
Debug.Log("Enemy hit");
}
}
}
heeeelp meee i feel so dumbbb but i shouldn't cuz i know i'm completely new
you should first !learn the basics, otherwise you're never going to be able to progress with this
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
this is not a question of being dumb, you're totally capable of learning 👍
but it doesn't help to come here every few hours asking for someone to fix your issue
but it's sooo boooring
we're more than happy to help, but you must also put some effort
Maybe find a hobby that you don't think is boring
i need more stimulation and idk why that is
today's world of instant gratification in small bite sized content
i just need to also be asking
also i don't want this as a hobby i want this to be my job
there is literally nothing else i'm interested in
Then you should really be starting with courses you've been recommended already not random tutorials.
i tried !learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
Did you finish the pathways?
What does "I tried" means?
couldn't
Because?
Pathways course is on rails. You just have to watch/read lessons and follow interactive parts. It's impossible to fail that. "I tried" here means literally "I was too lazy to follow basic instructions"
i just couldn't get myslef to finish it
it's like something is phisically pulling me back and my chest tightens
i WANT to
it's just painful
You don't even have to remember everything, the point of courses is to make you aware of information, so you know what is possible. Programming does not require you to learn everything right away. Just to know how to use learning resources and know where to lookup stuff.
It will be pretty hard for you to turn this into a job if you can't even finish a single course.
It's interactive, no one tells you to read 400 pages of documents to learn anything straight away, it's one of the best things a beginner can have. You watch a video and follow along, learning basic info about the engine, how to use it, where to find more. I struggle to find anything painful about it.
the script on the dragonfly object. why wont it register collision?
no i mean getting myself to do it is painful
i WANT to do it
i KNOW i can do it
my body is telling me NO
Just sit down, focus, and learn, there is no other way, complaining won't fix anything
You command your body
my body says your chest is now tight and hurts now
The best way to get yourself into doing something is.. to just do it. Your brain will quite quickly focus at the task at hand once you focus and start spending some time on it.
Yesterday in a discussion, @mortal ginkgo mentioned being in high school. There's the reality that they might not currently have a very strong base to link new concepts to, making some of the learn stuff overwhelming. We've all done that at some point, tried to learn something interesting only to realize we were missing too many pieces to currently understand it.
The only problem here carbs is that people believe you're not meeting them halfway. Saying you don't want to put in the work whilst expecting others to do it for you feels disrespectful to the community and the time that people have spent learning.
im very tired. I rewrote my PlayerMovement and im getting these, I dont understand why. I dont have a duplicate script, I only have 2 scripts, PlayerMovement and ThirdPersonCamera
Assets\Script\PlayerMovement.cs(5,14): error CS0101: The namespace '<global namespace>' already contains a definition for 'PlayerMovement'
Assets\Script\PlayerMovement.cs(22,18): error CS0111: Type 'PlayerMovement' already defines a member called 'Update' with the same parameter types
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
[Header("Movement")]
public float moveSpeed;
public Transform orientation;
float horizontalInput;
float verticalInput;
Vector3 moveDirection;
Rigidbody rb;
private void Start()
{
rb = GetComponent<Rigidbody>();
rb.freezeRotation = true;
}
private void Update()
{
MyInput();
}
private void FixedUpdate()
{
MovePlayer();
}
private void MyInput()
{
horizontalInput = Input.GetAxisRaw("Horizontal");
verticalInput = Input.GetAxisRaw("Vertical");
}
private void MovePlayer()
{
// callculate movement direction
moveDirection = orientation.forward * verticalInput + orientation.right * horizontalInput;
rb.AddForce(moveDirection.normalized * moveSpeed * 10f, ForceMode.Force);
}
}
why this doesnt work?
anyone who knows a little more about collision than i do could give me a pointer here
cause Set() doesn't accept a vector3
you might have two copies of the same playerMovement script on an object, or you might have another copy on another object somewhere in the scene
think for a second what that means
script is not attached to any object yet. it wont attach because compile error 😮
@prime lodge Look at the signature in your IDE
Even if you put the correct arguments into Set, it won't work here
You are modifying a property (eulerAngles) of a property (rotation) as a copy
If you don't figure out how to get into "work" mode, you'll have much more problems later.
Generally you don't overexert yourself, do plenty of breaks to not create negative feedback. Some people use music to get into work mode. Keeping routine with specific time helps a lot. Switching off external distractions like socials, including discord.
and it makes me wanna cry when someone says "have you tried trying?" when my chest feels like it's about to explode
the script on the dragonfly object. why wont it register collision?
oh yes i know this feeling exactly, even now I'm currently trying to study for a C++ exam lol
you have to figure out some way to make working feel good, you might just have been overstimulated from outside sources so it's hard to get working
no you literally have two of the code files
nothing worth having comes easy. i find game dev, especially when youre shooting for concepts that are at parity with what inspired you to attempt to create in the first place, will lead you down a path that will be full of obstacles that you must get through by paying pain. what does pain look like? usually frustration and wasting time. the objects relent, iteration demands perfection, but your cost is staying with it even when you want to tear your own head off
check the assets folder
yea script files can be a bit sneaky
because that has to be some kind of duplicate file or instance somewhere
it can be in any of those folders
ive dug around, its a brand new project, how can i hvae two? I entertained that it could exist, but im not finding it
It can also be in the ThirdPersonController script
like you might have just defined the class in that script as well
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ThirdPersonCamera : MonoBehaviour
{
[Header("References")]
public Transform orientation;
public Transform player;
public Transform playerObject;
public Rigidbody rb;
public float rotationSpeed;
private void Start()
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
private void Update()
{
//rotation orientation
Vector3 viewDir = player.position - new Vector3(transform.position.x, player.position.y, player.position.z);
orientation.forward = viewDir.normalized;
// rotate player object
float horizontalInput = Input.GetAxis("Horizontal");
float verticalInput = Input.GetAxis("Vertical");
Vector3 inputDir = orientation.forward * verticalInput + orientation.right * horizontalInput;
if (inputDir != Vector3.zero)
playerObject.forward = Vector3.Slerp(playerObject.forward, inputDir.normalized, Time.deltaTime * rotationSpeed);
}
}
Just serach for PlayerMovement in your IDE
stupid question, but you've tried restarting unity too right? sometimes the compiler thinks multiple instances are running at the same time
i tried restarting, reimporting the entire project
._.
ok this is quite weird
fuck i found it
theres a script for movement in this asset pack
die die die, i will kill
anyone?
ohh lmaooo
thank you everyone, love you @keen cargo @wintry quarry
debug it
debug what
though also i wouldn't call collisions off of object names
it's better to do it off of tags or layers even
i know but im looking for a specific singular object here so
dont wanna make a tag for just this one object, makes it harder in the end
Put a debug.log in the ontriggerenter method to see if it even runs in the first place
my best advice is to sub to GPT and feed your code to the o3-mini-high model for your particular problem. it's not great at creating its own code but it is pretty good at spotting errors in logic
as long as i rename every pinecone i spawn to exactly "pinecone", which takes just one line of code, i should be fine
use deepseek instead
i tried that, didnt do me good
whichever you prefer, yeah
basic GPT or the reasoning model? the result difference is vast
i tried with the bing ai, im feeding it chatgpt plus rn... lets see
Btw I would replace the second if-statement with cs if(collision.gameObject.TryGetComponent(out PineCone p))
usually it just asks me "hey have you made sure u attached the right tags or layers" as if the image doesnt clearly show that yes, i did
but why it doesnt work now
that doesn't do anything
you want trasnform.rotation = Quaternion.Euler(0, 50, 0);
its a pinecone object, its guaranteed to have pinecone script, no need to check if its null or not
you're calling Set on a copy of the quaternion. Also that's not how quaternions work even if that syntax was correct.
then what it is for
You're misusing a function and using it incorrectly
Set works this way:
Quaternion x;
x.Set(0, 0, 0, 1);
transform.rotation = x;```
Set modifies a Quaternion in-place. You're calling it on a copy of the object's rotation which then gets discarded.
So your code does nothing
okay thanks for help
The whole point is to check if it is a pinecone object with TryGetComponent instead of name and layer checks and whatnot
CompareTag is another decent option to identify it
You also are trying to plug euler angle rotations into a Quaternion's xyzw fields which is not how they work
oh smart
so liek this?
That looks less smelly to me, yeah
You can always go on a break, play some music, relax, keep a routine of daily 30-60 minutes of learning with frequent breaks, completing the course step by step. Gamedev is something a lot of people go into because they like it, so in most cases learning something new should be a fun experience or challenge... not something that makes your chest explode. So try and make it enjoyable. Learning about the source of why exactly it's so 'painful' could also help.
but yea detection still wotn work
So did you confirm that ontriggerenter is even getting called?
put a debug in the beginning of the ontriggerenter function
if something doesnt work then your first instinct should be to log it to the console
The method might not trigger if you are moving the object(s) via transform instead of via rigidbody
Or messed with the physics2D layer matrix
another thing is that the object may have an infinitely small collider, so you may want to check that the colliders add up too
it does, cuz the if statement above works
Log the object you are colliding with
Debug.Log("Trigger entered: " + collision.gameObject.name, collision.gameObject);```
This logs the name and also lets you highlight the object when you click on the log once (second argument)
i think its becuase of this:
only one of them has the script, but idk why it would only specifically ignroe the one im going for
im tryna get the parent
Was gonna ask if any children are involved
maybe i should do a get parent
What components does the parent have and what does the child have?
child is trigger col, parent normal col + pinecone script + rb
and parent has items layer, child doesnt
its so player can walk through an item when they have full inv, and pick it up otherwise, thats why i needed the trig col
collision.gameObject might reference the child because it has the collider. I forget how exactly it works in 2D with trigger colliders
but also needed a normal col to collide with the ground
yea i mean there is no other possible case here, it has to be referencing the child
i guess, ill just have to get parent
You would know if you just... logged it
hi, i have a question. How i can chance the string of a Text Mesh Pro to a int?
I gotta ask, why do you want to do this?
You aren't storing a score in a text mesh pro are you?
Or is it an input field?
no, is for the player, to put the size of the map he want
Probably int.TryParse
i use it, but it return to me 0
Show your !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.
Is hirong people from this server against tos?
!collab
:loudspeaker: Collaborating and Job Posting
We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
• Collaboration & Jobs
Huh?
It's a bot command. Read what the bot said
A tool for sharing your source code with the world!
the problem are in the line 26 -33
yes
ok, i will try
There's a case where the text object has an extra invisible symbol at the end, this might be causing the issue
Is there any way to turn off/manipulate all lights in a scene using scripts? I want to periodically flicker and then turn all lights off in the scene
maintain a list of them, then iterate the list to modify the lights
is there not any way to find them in code? i,e, if i tag them all as a light, or something like that?
Sure, but you might as well add a component to them and avoid the FindX methods.
you can use FindObjectByType , but thats too slow for calls in Update()
@last radish Can also have an event driven approach. Make a custom component for your lights. Make a power class with OnPowerOn OnPowerOff events and let lights handle themselves
Ok, it works, tnahkyou
was it continuous that was more effecient in detecting? like even if thigns are going fast etc
It's not more efficient
it's more accurate
it's less efficient.
ye thats what i meant
but welp, either way collision didnt wanna work
i give up
unless i pause the game and place the object inside the other one myself, it doesnt want to detect the collision
anyone able to help with using Resources.LoadAll<Texture2D>(cardsPath);
its not loading the textures in the path the cardsPath is "Assets/Resources/Sprites/Cards/Faces"
and in the script its set too " public string cardsPath = "Sprites/Cards/Faces";"
all objects in the folder are texture2d set to sprite2d and ui
i have also tryedResources.LoadAll<Sprite>(cardsPath);
show movement code
show full script
Nvm i gave up and just assigned via inspector
can anyone help w this? i have no idea what to do
!ide
If your IDE is not autocompleting code
or underlining errors, please configure it.
Select one:
•
Visual Studio (Installed via Unity Hub)
•
Visual Studio (Installed manually)
•
VS Code
•
JetBrains Rider
• :question: Other/None
the projectile movement code
doesnt seem its moving too fast
also that flip chain is crazy...
the items are quite small tho
oh yeah that might be an issue..
i know i know... i could probably reference it when the item is picked up rather than this but
it works so
it works but its pretty flimsy , wouldnt GetComponentInParent do fine ?
its on the parents parent
it can reach up there
unless there was another in the child of that parent
GetComponentInParent / GetComponentInChildren just does recursion up/down
so gameObject.transform.parent.GetComponentInParent<SpriteFlip>() ?
oh so just the GetComponentInParent by itself?
even gameObject.GetComponentInParent would do
it stops once it hits one if any component
so goes up a parent, checks, goes up a parent again, checks again, etc
yup thats recursion
well i keep it mind
but before i change any scripts i wanna solve the two issues i got
oh .5 should not be too bad..
the rectangular gizmo is the typical camera size when u starta a new project
I thought it was something like 0.06.
your current size afaik shouldn't be issue
what are you using to detect collision ?
or you mean just in general, not code
im more worried about a different issue. i changed items to be picked on on ontriggerstay2d instead of on enter, and it picks up items as soon as there is free inventory in space, unlike before u had to exit col then enter again, which is what i want.
btu then when i disabled the items layers from interacting with each other, somehow i have to exit collision before entering again for me to be able to pick up items
ontriggerenter2d
You mean like OnExit doesnt get called when you disable collisions .
no i mean Stay started acting like Enter
well not really like enter, but i have to move for it to activate
ohh so its not detecting if you stay in the trigger?
yes, but i have to stand still too for it to not detect
but i want it to detect even if im standing still
You know what I would do tbh. Forget all this trigger stuff and just use an Overlap
that always works reliably
that could work for the firts issue, but for item pick ups i need the range to be exacty the size of the trigger collider i have rn
thats a non-issue. What shape is the collder
you can still use a collider for sizing purposes
eg Collider2D hit = Physics2D.OverlapCircle(pos, circleCollider.radius, layerMask );
if(hit.TryGetComponent(out SomeComponent comp))
comp.Stuff
this didnt change anything :(
you didn't do it correctly then.
and what is "this" thats pretty vague
I am doing a boolean operation to subtract a mesh from another mesh. The issue is if I use two meshes that already exist in the game, the inside faces are fine. But if I use prefabs then the inside faces are gone:
Anyone that might know why?
where's the code question ?
the guide
visual studio manually
rectangle
so did you check the Unity Workload is installed and the editor is set in the Preferences?
yes
show it
It is too large/spread out to be easily presentable but I don't think the issue is the method so I am not sure what to do
I looked around and someone said it could be because of backface culling
well then are we supposed to guess by this screenshot alone ?
It could also be that it is all done in one frame (right after the cube is Instantiated)
Educated guess
no idea then sry
Do you know how I can disable backface culling?
the MeshRenderer i think has two render modes
^Either that, or your material has double sided enabled
Or the mesh actually has triangles on both sides
If I look inside the mesh I dont see the face
Yup
Picture on the left is what I want
Dynamic occlusion?
So much details missing. What are you using to do a boolean operation? What does "use prefabs" or "use meshes that exist" mean in this context?
I am using the method from ProBuilder and what I mean is that it works if the meshes are already in the scene before the game runs
and the prefabs are instantiated during runtime and those have the missing faces
Does not really seem code related, #🛠️┃probuilder probably knows
All I can say is look for errors/warning in the console when you do the operation
I think they are using the API in probuilder to do the Boolean function
Better show some code in that case
are you using code or just the probuilder window?
What API are you talking about?
I know it has some functions you can do at runtime but honestly dont know if boolean is one of them lol
There is no API, i just forked some CSG script from probuilder. I will show what I am doing
oww
ah the api doesnt even have boolean in it.
I only remember using the basic combine mesh tools
It is under some experimental testing section
ohh yea I know where it is , I meant if there was anything in the API of it
ya send that
are the meshes ur doing Unity primitives or are they also probuilder meshes?
They are the default unity cubes
cube1 is just a default unity cube that "helps" perform the boolean operation so I just move it in the place where I want it to cut off from CurrentCube
CurrentCube.transform.position = new Vector3(x, CurrentLevel, 0);
cube1.transform.position = new Vector3(0, CurrentLevel, 0);
cubeCutter.PerformCutting(cube1, CurrentCube);
public void PerformCutting(GameObject cube1, GameObject cube2)
{
Model resultModel = UnityEngine.ProBuilder.Csg.CSG.Perform(UnityEngine.ProBuilder.Csg.CSG.BooleanOp.Subtraction, cube1, cube2);
Mesh resultMesh = (Mesh)resultModel;
GameObject resultObject = new GameObject("ResultMesh");
MeshFilter meshFilter = resultObject.AddComponent<MeshFilter>();
meshFilter.mesh = resultMesh;
MeshRenderer meshRenderer = resultObject.AddComponent<MeshRenderer>();
meshRenderer.material = new Material(Shader.Find("Standard"));
}
The only difference are the things I mentioned earlier. The broken ones are instantiated prefabs (same ones as the working one) and it all happens the same frame
¯_(ツ)_/¯
Why does Unity automatically switch to a newly created camera, even though there is another camera tagged MainCamera 🗿
Does setting UnityEngine.AudioSource.resource automatically set UnityEngine.AudioSource.clip?
can anyone solve this issue for me pls?
Hello, what is the easiest way to stop clicks from going through UI?
Handle all of your clicking with the event system
Don't do adhoc Raycasts
You can put IPointerDownHandler on your game world objects too, so long as they have colliders and you have a Physics Raycaster in the scene
hey.
So i’m so confused on which one i should choose for voice chat.
anyone got tips?
u use voice chat for voice chat
and u use chat for normal text chat, and also u can do stuff like inviting people to rooms and stuff like that
Awesome. Just found this crap again.
OperationResponse 230: ReturnCode: 32767 (ApplicationNotFound) Parameters 0 Server: NameServer Address bs.photonengine.io:5058 Unity.Engine.Debug:LogError (object)
never seen that, go to photon server not in unity
hi, i been trying to harness the methods of my enemy using animation events...But i feel like i did something really wrong
!paste
i mean cuz the enemy just patrols, and then when sights the player it stops...and stays like that...like a dork
A tool for sharing your source code with the world!
guys i need help plz
so im doing this silly main menu for design class in school ive done it smooth and all and its just works fantastic with mouse. but now im trying to implement controller support and it just keeps highlighting the buttons when i start the game like that and i do not understand why, im going insane 😭 ive asked deepseek and even that gave up so you guys are my last resort. i have put the play button as first selected in the event system and i script too. (also yeah the scripts are really ai generated ill admit just because im too lazy to write them in this project and want to get it over with and we arent gonna get graded for it anyway, dont judge lol)
are you using custom animations for the button states?
no im using unitys generated ones
manual or custom navigation stuff? weird that it cycles through the buttons like that
I am telling this guy that his next NavMeshAgent position is its current one, it's normal that the squares are showing it wants to move down or should I be using something else????
ive set up the navigation for every button manually
if like thats what you mean
yea. all i can think of is the animator is miss configured so its going through states 🤔
hm okay, ill take a better look
i guess also check your controller is not going wacko, windows and i think steam has a tester
i actually dont even have it connected atm, im using the arrow keys :(
new input system? you want input to be key down not key held for navigation
i think it already like that tho. im moving using the arrow keys here. also i know the animations arent playing correctly atm
then you must have done something else wrong. use a prefab instead for your buttons to keep them a consistent size. is the animation using scale to change size?
i presume the issue is the play button staying large?
yeah the animation is using scale is to change size and rotation. but the play button is supposed to be bigger, that is its normal state
then im not actually sure what your problem is then, the buttons not staying large once highlighted?
if is this then you should observe the animator (select in inspector and open animator window) on a button in playmode to see what its doing different between mouse and keyboard/controller.
no, its when i start the game, the buttons keep being selected and navigating down until i press something. my goal is that when i start the game only the play button is highlighted until yeah i navigate down or something. its like when i press start the down arrow key is getting spammed until i interact basically
When the game starts, each button is highlighted in a downward pattern (one after the other) as if the down key is being held . . .
hello can i get help with this code ?
for some reason it entered confirm func even tho im not pressing click
You placed it in Update, so it'll run every frame . . .
yea cuz im checking if players select there characters
Okay, but that's why it's constantly being called. Update runs every frame . . .
