#π»βcode-beginner
1 messages Β· Page 828 of 1
this question needs more context to be of any value
GetComponentInChildren() is a good way to find a component in children
Or you can do other things to check all children for some match
or just drag the reference into a serialized field
I would but my gameobject is a prefab so I can't just drag it into a field in the scene view
it also has multiple children, hence this question ^^
Idea: component IN the prefab that references all this stuff for you
Then you can GetComponent and DoStuff()
π€―
you still have yet to actually describe what you are actually trying to accomplish here so we can really only guess at solutions
papa prefab knows about kid prefab
whatever is in scene speaks to papa prefab if it wants to know about kid prefab
jesus christ
i haven't slept was it that bad π
thing.Find("Cube (Clone").GetChild(0).SendMessage("fuck")
"Guys is there a better way to do this"
.\
@balmy vortex haven't you been told about this multiple times
can some answer?
"a specific child" is extremely unspecific
what makes it specific?
like you can literally copy/paste that exact question into google and the first result will be the answer
Whatever spawning the prefab could set those sort of scene references.
ya I realised when rob mentioned it mb
My go to would always be a component to manage the prefab and its objects once spawned
Having trouble with "new" input system
I dont understand how to get the same input as
[Keyboard.current.spaceKey.IsPressed()]
Using the player input component
You're mixing two different ways
Ignore them being in the same method
I just mean
how can i get
If("holding space bar")
Using the player input instead of just checking keyboard
there are multiple ways to do it. Events or polling
polling is basically what you have in the second if statement but in Update
if you want to use polling but make it also compatible with other devices in chosen inputaction map you can use InputActionReference
Could i poll using Player input component?
context would still be called if i changed the input from space to F key.
while i would have to change the code itself to "Keyboard.current.FKey.IsPressed()" using bottom if method
You dont need PlayerInput
you can just poll it from a InputActionReference that you dragged the reference into
or use the code generated accessors from the input system
InputActionReference you can put in a serialized field
InputActionReference jumpAction;
...
Update(){
if(jumpAction.action.triggered){
//do something
Okay its clear I'm misunderstanding fundamentally.
I thought i need that component (The player input component) to use the [Input Actions Editor] for convinent mappings
Image is what im talking about
you can use the ActionMap without using the PlayerInput component
oh thank god...
PlayerInput is just there if you want to use (link events) through inspector or use the Broadcast messages mode
notice your Player_Actions asset has sub assets, for each action those are what you can drag into InputActionReferences
the player input component really just adds complexity that is not needed unless you are doing like local multiplayer
These?
so in a monobehaviour you can do a [SerializeField] InputActionReference interactAction;
drag it in
hey guys so im not so sure if this is the right channel for this buttt
im having an issue with my game , in he unity scene editor you can see that the player model (whichh is just a sphere) is moving around (not spinning) whenever i turn the camera , this isnt toooooo much of a problem but it looks weird and im trying to figure out why its doing that 
imso chopped at c# and its saur hard but im learning
anyhorse
wait how do you even paste code
hold on
Okay i have that working
so much more convienent
however now back to my original question how to determine if i pressed key or if im holding it.
if (Interact.action.triggered)
in the update method still only calls the initial click.
which i want, but i also want to check if im still holding it
if (Interact.action.inprogress) ?
You'd have to show what you set your action type as
thought it just had a IsPressed method on it
though not at my work computer right now so cant test
also if nothing is happeing at all you might have to call enable first on the action
Action type: Button
Yes it def worked with if (Interact.action.inprogress)
Just checked there absoultely is
Ill use that
not sure the difference between the two
it has a few ways of doing things notice that even GetValue is generic as well
its like this since a Action needs to be able to work and do things when the input could be anything
not just a button/key
ohh I see.. thats why, but yeah you can just use IsPressed() and should work fine
!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/
π 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.
Im having trouble with my code
Im making a 2D RPG
I want it so depending on where the character is facing a RayCast is gonna come out,
not wanting to write for a RayCast to come out 4 times I thought having a function
get the Direction, then returning it to tell one RayCast where to go
but hovering over 'FindInteractDirection' just says "not all code Paths returns a value"
what happens if that outer if statement is false? and then what if it is true, but the inner if statement is false? what are you expecting to return in those scenarios?
don't spoon feed
yes sir π«‘
Try this fix I worked out I dont know if it will work but here"
https://paste.ofcode.org/zkMWuiVfH5QttaB7BXrDTq
box what?
why is the word B.R.O blockd
consider reading things when they are presented to you
i cant read
and this is literally spoon feeding
so? he needed help π
what value does dropping an untested/unverified solution with 0 explanation offer?
mi bado
While It Does help
I wanna know How
earlier it gave me issues for doing
'Return New Vector' :')
start by answering this βοΈ
told it simple terms but I dont think it knows what simple is π
#πβcode-of-conduct
don't post AI answers to people's questions
it says :β’ Posting unverified AI-generated responses or failing to mark AI-generated content as such. It doesnt say dont post them it just says that they can't be unverified which its not
and did you verify that ai generated response?
yes
bullshit
ill try to offer an answer:
your method has a return type (vector3), it means when the method runs it has to return a value of that type. the code you have written can go several ways, but looking at the first if statement, what happens when that if statement returns false and you dont run that block i nthe middle? there is nothing more, there is no value for the method to return
also why are you defining vector3 left as a public field? you could do vector3.left yknow
the outer is for checking which direction is dominant
Left and Right or Up and Down
If positive,its moving Horizaontally
if negative, its moving Vertically
if thats true then it checks Horizontal if the value is more or less than Zero
if positive, its going Right
if negative, its going Left
rn the rest isnt written cause of the return issue and me wanting to fix that before writing the rest
the return issue is because the rest isn't written
is it a top down game?
yee
like the error is literally just telling you that you don't have a return in those other scenarios i mentioned
box is so tuff π₯Ή
hi guys
I also have this issue which is very confusing:')
presumably this is something you're passing to a method, so you're missing the closing ) for the method call
remember every ( will have a corresponding )
ty ty
:')
Im having troubles with a script being read as null by another.
ControllerScript is always read as null when I try to reference it in the savingSystem
https://paste.ofcode.org/utHiXJwAzpXpAGMPRZvmkY
I tried different ways to define the ControllerScript but everytime it's read as Null. Im not really sure what im doing wrong, and if its something outside of the script or not
https://paste.ofcode.org/FKwZ47grM7SNzcLu8Z5jck
This has me really stuck so any help would be appreciated
Is it on your scene
Both are singleton monos, they exist when loaded on the scene otherwise null
I think so
CountControl is the ControllerScript by the way
When the game starts both go into DontDestroyOnLoad would that break anything
Looks fine. Not really seeing anything so unless it is editor side. I'd debug it more. Throw some logging inside of awake to make sure that's happening.
Awake is happening normally, The controller script doesn't print as null or anything. For some reason CatF is null in the ControllerScript, i dont know how that happened
it was probably while I was trying to fix the script. I might just rewrite the 2 scripts in a different way so this stops happening
Not sure why a value type would be null here
You are setting the instance to null in the Debug.log!
This is one reason to not have a public field or setter for a variable like that
Oh yeah what a wild assignment
Ohhh
I didn't realize you could set stuff in debug logs that's mb
I fixed the debug log and now the main script isn't null
The CatF is still breaking though, I'm not too sure why.
Would it make sense to use a SpriteShapeRenderer, and updating its spline based on the player's location every update, or would t hat absolutely kill performance?
you can set stuff anywhere, because a = b is also an expression
it has the value of b
it's useful sometimes when you want to set multiple things to the same value
So this is a really weird question but I feel like I'm going mad
Image pointerImg = pointer.GetComponent<Image>();
pointImg.enabled = false;```
This should get the image component of a game object (that is being set correctly) and disable just the image part to hide the visual element but keep the gameobject itself active. Right?
So it's invisible but still active
Yes
Do remember that Graphics (including Image) are what make ui elements "clickable" too
If nothing in a button can recieve raycasts then it cannot be interacted with
@fleet ivy
Aye, its just an image that moves to the selected object for controller, but need to hide it when the mouse is used.
I have that code for when the game detects a click.... But the image is staying active. This is the only part of the code even grabbing the image component
Debugged it using logs or a debugger yet? How is the click subscription set up?
Or are you using IPointerClickHandler?
The click is working, all the other code i'n the onclick function is working perfectly. Debug log between the 2 lines I put above shows it's grabbing the pointer image correctly
If you can enable/disable this Image in the inspector manually in play mode then you must have a ref to a different game object OR have multiple Image components on it.
Does doing .SetActive() on a gameobject set all the components active too?
That's the only thing I can think of what's happening
No its only for the gameobject. Make extra sure then you have the correct game object and its doing as you intend
I already checked that
Remember that Animators can override things like this if defaults are recorded
Good old write defaults on animator states will mean those suddenly set shit you didnt want it to π
Disabling it will fix this but means you need to manually "animate" changing values back in that state (e.g. turning something back on/off)
Ok completely different questions
I have 3 bools. If statement like this if (x && (y || z))
Have I confused myself on what this resolves to?
Or should I just make a second if inside the first
How are we meant to know if you're confused as to the result?
It should be if X is true and either y or z is also true?
Yes
Yo guys, does anyone here know how to get a transparent window on macos? I'm trying to make a game that works as a wallpaper, though I'm struggling a little on mac
From a script on an object with which the player interacts, i'm trying to target the camera on the player object so that i can disable it and enable a second camera.
[SerializeField]
private Camera puzzleCam;
private Camera PlayerCamera;
public void Start()
{
puzzleCam.enabled = false;
}
void switchCam()
{
PlayerCamera.enabled = false;
puzzleCam.enabled = true;
}
}
i already can interact with it (removed that code for a clearer view). I just need to find out how to target the player camera
What do you mean by
find out how to target the player camera
You'd reference the camera..
let me clarify a bit more. The player will switch scenes a couple of times and otherwise i need to assign the player to each seperate interactable object, so i want the object to look for the playercamera using tag (which i didn't get to work) or some other method which looks for the player and targets the camera of the player.
You would need to either search the hierarchy using Find or use some sort of manager and have the player register itself on Start.
i'll take a look if i can use find in that case. i might have used it wrong before. i was looking for a camera with the tag 'playercamera' which didn't work.
update: i used an interface.
i passed the camera through the interface, and then accessed it in all the scripts which needed the camera switch.
on the window at the bottom, there are several tabs. one says terminal
that's the integrated terminal window
ohhhh
ohh thanks so much
Any terminal really would do but that's probably the easiest to get the path right
oh why is it that if i copy paste the code it works but if i type the same exact code it doesnt
Once you are at the tutorials folder which cd tutorials (cd = change directory) does, you don't need to do that again, you can just do dotnet hello-world.cs which is the part that actually runs the script
This here tells in which directory you are currently. Since the hello-world.cs file is within that tutorials folder, the dotnet command has direct access to it
You could always do dotnet C:\Users\...\tutorials\hello-world.cs which would work no matter where you are, but it's much easier when you are inside the folder already and can use the relative path (the file name only)
ohh
oh i get it now
thanks
yeah it works
Anyways, this is a discord server specifically for unity related stuff. If you have general C# questions, C# also seems to have their own discord server. Don't know how strict people here are about the distinction but your problem so far don't seem unity code related so the general C# spaces might be more appropriate
okay thanks
Was following this tutorial and everything was going well, the only thing was that I had to upgrade my unity in the middle of this project. Now when I want to publish this project its 24gb instead of the 16.7mb the tutorial is showing. Why is my game so much bigger when I copied the assets the tutorial was using?
actually I think I found the solution I have to export the project in a folder... Why does that effect the storage of projects?
it.. looks like you're trying to publish the entirety of your downloads folder in that first screenshot
wow π€¦ββοΈ
hey im making a viewmodel but it doesnt have the same lighting as my main camera
why would it ? the world geometry shadows are not in the culling mask of the viewmodel
also yes wrong channel
how do i disable copilot github in visual studio community
at the bottom right theres a little icon for copilot
you can pause it for 5 minutes or just disable it
I have an enemy Ai script that's supposed to be able to allow the enemy to locate the player and attack them, but for some reason if I use the enemy with procederally generated terrain (I have a script that bakes the navmesh surface at the start so that isn't the problem) Here is the code: https://paste.ofcode.org/wkDHAq7uYVXfKjKrz732vK
what steps have you taken to debug this
I've double checked most of things I might've forgotten (Ie making sure that everything generated has the correct layers and making sure the navmeshsurface is set to bake the correct stuff.) I've been looking through the code but I can't seem to find the issue
I forgot to also put the navmesh code so here it is: ```using UnityEngine;
using Unity.AI;
using Unity.AI.Navigation;
using System.Collections;
public class NavMeshBuilder : MonoBehaviour
{
public float WaitTime;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
NavMeshSurface surface = GameObject.Find("NavMesh").GetComponent<NavMeshSurface>();
surface.AddData();
surface.BuildNavMesh();
}
private void Update()
{
StartCoroutine(CreateNavMesh());
}
private IEnumerator CreateNavMesh()
{
while (true)
{
yield return new WaitForSeconds(WaitTime);
NavMeshSurface surface = GetComponent<NavMeshSurface>();
surface.AddData();
surface.BuildNavMesh();
}
}
}```
what about Logs? and the Console
There's errors for a different script that I've been trying to clean up so I could see if there's any errors.
logs are basic but one of the most overlooked important steps.
You need to verify where your code is going and what is being called
breakpoints are better but logs should work fine too
also the navmesh baked before calling any move code?
Is the agent actually close enough the navmesh
etc.
Yeah I forgot about that tbh
Yeah im using logs rn and for some reason the NavMesh isn't being created
also the fact you're doing this every frame is frightening
private void Update()
{
StartCoroutine(CreateNavMesh());
}```
aside from all the Fragile Find methods you have
I have the coroutine set to wait a bit before creating the NavMesh.
you creating a new coroutine every frame..
Oh I didn't know that
is there a reason is timed? just run it when you need it
I wasn't the person who created the procederal generation, so I don't know at what point in the code is the new terrain is being generated, but I need there to be a navmesh ready every time new terrain is generated for the ai to work.
should be pretty easy to find , if the code was actually well written with some decency it should fire and event when done
The only problem is that there are many different codes each generating a different object and I don't can't really understand them.
Oh crap my unity crashed
and it isnt opening anymore...
hit it with a hammer
is it an asset? there should be documentation
Atleast I know why the enemies aren't working anymore π
Oh crap it isn't letting me open it anymore
Ill try turning my pc on and off.
Do you need to use a Coroutine in the Update?
And why are you using a While (true) is not necessary
{
yield return new WaitForSeconds(WaitTime);
NavMeshSurface surface = GetComponent<NavMeshSurface>();
surface.AddData();
surface.BuildNavMesh();
}```
I already changed those
Is it working the way you want now?
No, those weren't the issues
What's the problem?
The navmesh isn't baking because there are too many items spawned in
When you get that error, could you show some of the code or console output?
dont believe thats how navmeshes work
The navmesh isn't baking at all so I would assume that's the reason
i don't understand the thinking there but ok
there's no kind of object limit or anything for them
Are you still using a coroutine in the Update?
no
its not likely anything to do with the amount of items.
you create a button or context menu and run the Baking after the level is generated, then see what happens
make an actual method that just bakes , no timers or anything
doesn't the component already have a button?
I believe so
you can use that too
I can't use that because the terrain is being generated upon the play button being called.
You can't. The button doesn't work upon play mode being called.
Have you tried changing the Object Collection?
just make a quick
[ContextMenu("Bake it")]
void Bake(){
navmeshSurface.BuildNavMesh();```
they should try baking at runtime after everything is spawned before changing stuff
I was able to get the enemy ai to work now. But for some reason until finding the player he just drifts up into the sky
so is the navmesh problem solved
yeah
What was the problem?
But for some reason until finding the player he just drifts up into the sky
With this information alone nobody is going to be able to help you
You also have my entire enemyai code along with the navmesh code.
the navmesh code is not relevent and the link to your enemy code does not work
generally new problem = new context
if you don't debug it and tell us what you tried how we supposed to know...
like we somehow see into your computer or somethin
https://paste.ofcode.org/UqfrisKGz2Gfyh5sYWAWmy does this work?
I played around with the layers for a bit until it suddenly worked.
what components are on the enemy object ?
have you checked the scene view after the bake happened to see if the mesh is correct ?
Yeah might be a Rigidbody or Animator component fighting with the agent
heya I needed some help
π
:thinking: Asking Questions
:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #πβfind-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.
-# For more posting guidelines, go to #π±βstart-here
is there pros and cons to get variables like player transform or component in void Start rather than doing it manually
if its on one self it should always be through inspector
Hi im using unity 6 multiplayer I have a function that calls for every client when a new player joins the code on the left runs on the player client sided and when the host and player 2 joins it works fine but everytime the third player joins it gives a object reference not set to instance of object error
i really dont get why its doin this is it cuz its being called to fast? or is the instantiate just not properly set
its supposed to make a object in the clients ui
crikey
can you explain what do you mean by one self?
if the component you want is on the object the script is on there is no real reason to use Start to get it
so then when i need the component, i just use transform.Get Component is that correct?
no you serialize it in the inspector assign with drag n drop
does anyone have some actually good tutorials or tips for ui and multiplayer code
ah i see, thx
So guys I have a simple problem. Two colliders on different objects trigger on the same time when my player is touching both of them. How do I make only on trigger?
What game mechanic are you making exactly?
You can probably just set some condition to true in the first OnTriggerEnter, and skip the second one when that condition is true
anyone here use blender to make models and put them inside unity?
cuz i need help
my textures dont import when i import my model
you're in a code channel
you can ask in #πβart-asset-workflow probably or just blender server
can u answer my questin in it tho?
Ask questions and discuss anything related to beginner coding concepts in Unity
Their both the same game object and use the same mechanic. Its a planting game object.
hello i want to ask about implementing enemy abilities, i have 1 script (entities) for enemy and player, right now i have 2 types of enemies, ranged and melee ( using script enemy and enemy 2) , and now i want to add another melee enemies but with an ability, should i make another script ( enemy 3 ) or make a seperate enemy ability script?
how can I link blender
what are you trying to do there?
you could have a subclass for the mele and implement whatever you wish
I watched a yt tut apparently I need to recalculate outside then make it fdx
you can save your blend file inside your unity project, if you make changes inside blender it will affect it inside unity too, no need to export and import constantly
yes
for this it was easy leys say i have a rlly big project with multiple objects how do I make it so i dont need to recalcultate insdie outside
i dont know what you mean by recalculate
hey
: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**
okayy
I imported it with the copy option as well as with these setings but in unity it doesnt let me aplly a material
doesnt have much to do with coding so #1390346776804069396
there is a reason why someone decided to make sections on this server
Does anyone here know how necessary those "Dijsktra" or "flow fields" programming concepts are in RTS games. Like bro its just a tile game and sending like 10 units to a tile causes big lag spikes when they arrive.
i thought flow fields and that sort of things were for like starcraft 2 swarms, not tile games.
Hey so I followed a tutorial on YT about making a third person character and the only issue I'm facing is that when my character jumps there's so much delay it's actually nauseating.
I used cinemachine and have been tweaking the settings but honestly I don't know what setting makes it so that when you jump the cinemachine stays in place rather than does the slow move.
Could y'all tell me where that setting is? I already tried changing dampening and it made no difference or very little difference.
Also, everytime I boot Unity I have to duplicate the main player and delete the original or else the player movement script doesn't work
So the delay is in the cinemachine camera following along?
Yeah
I want like 0 Delay, no dmapening lagging behind whatever the correct word is
Should be the dampening settings then as that is what makes it move over time instead of being instant
But Idk which setting to switch off
This one?
How is aiming done?
Aiming?
Like aiming at the character?
Quick question - im doing room generation, and I'm trying to make sure rooms dont collide with eachother. Is there a way to quickly find the size of a prefab in a script, or even better the space it occupies?
if you have something with .bounds, you could use that (eg meshes, colliders, renderers)
im following the Microsoft C# tutorial and its not showing whats meant to be showed in the tutorial (AsciiArt succeeded) whys that and what the fuck is going on
Are you using the correct version of .net as specified earlier in the tutorial?
top level statements are a newer feature
yeah i downloaded
the Net version given
Although looks like it's working here
why isnt it showing this
what am i doing wrong
oh yeah
I wouldn't be overly concerned by this. It's just a notice that the build completed
if you saw the build completing and your program is running, move on.
this isn't an important part of the tutorial
oh ok
yo for some reason code i use does not work with Text- TextMeshPro but works with Text(Legacy) only is there way for me to fix that
Are you using Text Mesh Pro Text? If so, it's type is not Text . . .
what should i use for it to recognize it
Use TMP_Text instead (this works for 2d and 3d text) . . .
Text is for their old UI system . . .
Just check the text component you have in the scene. The component will tell you what type it is . . .
ye works ty very much
Hey how might i get a random number from 0 to 100
(Like Random.Range(0,101)
but instead it becomes more and more unlikely to get a higher number
0 to 30 is much more likely then 30 to 100
The specifics of the distribution you are looking for will matter - but can you explain the use case?
So im taking away money from a random character every set interval.
When i take money away i want to do so with a random amount
it could be $5 or it could be $100.
Random.Range(5, 101) would techically work.
but its toooo random
$89 being taken is just as likely as $7
I want the chance of a number being picked to corralate to how big its value is.
Lets say having $100 taken is 10x less likely then $5 (arbitrary)
Every value is less and less likely then the number before it.
I just have no idea how to start with such a system
A very simple system would be (Random.value * Random.value) * 100 which favors lower values
I mean the basic idea is generating a uniform random number and then you fed teh random number through a math function
edited, messed up which way it goes
I think you'd want to do:
float val = Random.value;
float result = (val * val) * 100;```
rather than generating two numbers
but idk hjow much that matters to the result tbh
My instinction tells the correct formula for propability proportional to the scale of the number would have to do with exponentials though I don't know how to work out how exactly
Logarithmic function?
something like f(x) = 100 * (1 - (x^1/5)) will give you a decent distribution. The higher the root, the flatter the curve
or in C#:
float GetVal() {
float normal = Random.value;
float root = 5;
return 100 * (1 - (Mathf.Pow(normal, 1f / root)));
}```
Another quick & dirty method I've used a lot is Mathf.Min(Random.Range(0, 101), Random.Range(0, 101)) which essentially rolls twice and picks the smaller value
ArgumentException: Input Button Slide is not setup.
To change the input settings use: Edit -> Project Settings... -> Input Manager
UnityEngine.Internal.InputUnsafeUtility.GetButtonDown (System.String buttonName) (at <0a95d216b82544b7954b7f0b10bfaf86>:0)
UnityEngine.Input.GetButtonDown (System.String buttonName) (at <0a95d216b82544b7954b7f0b10bfaf86>:0)
PlayerMovement.Update () (at Assets/Scripts/PlayerMovement.cs:173)
get this error from this line:
if (Input.GetButtonDown("Slide"))
BeginSlide();
it worked in the same script when "Slide" was "Jump" instead -- which they don't differ in the input system
you haven't defined an axis or button called "Slide" in the input manager
To change the input settings use: Edit -> Project Settings... -> Input Manager
I have! I genuinely have.
is there any easy way of storing the length of an object as a float? I've tried just doing varName = transform.localScale.x but that doesn't really seem to work
you could use the colliders size if that helps you
size β scale is a pretty crucial distinction to internalize
oh well like how? 
google will tell you how
Two options: collider size OR mesh renderer bounds size
Both have differing pros and cons
Scale is not viable unless you have a 1x1x1 cube/square
Hey guys can i get help with this?
Im converting any time in seconds into a custom Year/Month format
However in game when it hits "1 year" it will continue to say "13 months" instead of stepping back down to 1
modulo operator
id just use DateTime/TimeSpan myself
or i guess remainder, in c#
but yeah using actual date/time utilities is probably much easier
float is also a poor choice for such things
When i store or work with time as a number I always use unix ms via long
DateTimeOffset offers functions to work with unix time too
I dont think i understand from the link you sent how that would apply here
How would i do that?
DateTime? Is that a plugin?
DateTime, DateTimeOffset and TimeSpan are all types in the core .net library
le google will tell you all
13 % 12 -> 1
Ohhh i see i was lookingin wrong section
Id still use TimeSpan for this kind of work: https://learn.microsoft.com/en-us/dotnet/api/system.timespan?view=net-10.0#properties
How would you use the Grid shader URP Triplanar from Starter Asset Pack , as a grid shader to show the exact world cell size to grid ? (For basebuilding system)
From the sounds of it, is it not done for you already?
otherwise grab some square texture, throw it into triplanar shader, and tile by 1,1
can anyone help me with a first person controller (i don't wanna use Unity's)
!ask π
:thinking: Asking Questions
:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #πβfind-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.
-# For more posting guidelines, go to #π±βstart-here
what?
!ask can anyone help me with a first person controller (i don't wanna use Unity's)
:thinking: Asking Questions
:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #πβfind-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.
-# For more posting guidelines, go to #π±βstart-here
brother have you tried actually reading what it says instead of parroting the command ?
particularly the last line ?
are you new to reading ?
:thinking: Asking Questions
:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #πβfind-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.
-# For more posting guidelines, go to #π±βstart-here
can anyone help me with a first person controller (i don't wanna use Unity's)
noone can help you if you don't say what exactly you need help with
(that's what the bot message is trying to tell you)
yea this gonna take all day and pull teeth... Goodluck chris xD
im going to sleep sloon probably lol
make it
you would need to write it
no one is gonna write the code for you bud
ok
!learn
:teacher: Unity Learn β
Over 750 hours of free live and on-demand learning content for all levels of experience!
if you have specific question or need troubleshooting on code you already wrote then its one thing
this isn't the place to ask someone to code shit for 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/
π 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.
send it properly please, see the "large code blocks" section
and what issue do you have
`using UnityEngine;
public class PlayerMove : MonoBehaviour
{
public float speed = 5f;
public float jumpHeight = 2f;
public float gravity =-9.81f;
private CharacterController controller;
private Vector3 velocity;
void Start()
{
controller = GetComponent<CharacterController>();
}
// Update is called once per frame
void Update()
{
Vector3 move = transform.right * Input.GetAxis("Horizontal") + transform.forward * Input.GetAxis("Vertical");
controller.Move(move * speed * Time.deltaTime);
}
if (controller.isGrounded && velocity.y < 0)
{
velocity.y = -2f;
}
}
`
why does my if statement red out like error
it's not in a method
consider learning c# basics, there are resources pinned in this channel
private void Function()
{
if (controller.isGrounded && velocity.y < 0)
{
velocity.y = -2f;
}
}
Huh, void is a return type. I'm not sure what you mean . . .
they're called methods
not the issue
you should at very least attempt to explain where OP went wrong.. Spoonfeeding code doesn't help anything they will just be back with more basic issues
the problem wasnt forgetting a function but the code underlined was NOT in a function
if statements belong in functions
yes but thats why it was a good suggestion to go over the basics found pinned in this channel
it will help you in the long run to at least know the building blocks so you can write and debug your code
Hi, I'm having an issue with my script variables not updating and I'm not sure why, I deleted the speed variable but it still shows up and remove component doesn't work it just keeps showing up in the inspector
you should have the console tab where its visible so you can see for sure if you have compile errors
you've also cut off the bottom bar where errors would show up out of the screenshot
UnityEngine namespace being grayed out is a bit concerning
but also who knows if your IDE is even configured...doesn't seem to be
that'll do it
Sorry lol I didn't realize I cropped it that tight
compile errors = your new code cannot compile
I have vs code set up with it
Console
scroll to the very top
first errors are usually indicates issue
considering the first screenshot has a serialized Speed field in player_controller and the code does not, either the script is not saved or there is definitely a compiler error
Top is the same just another missing component exception
did you actually save the script ?
try triggering a manual refresh (add some comments to file + save or right click assets folder and do "Reimport")
That fixed it π π I feel so silly it's been actual years since I've even opened unity
I had saved it but not refreshed
Thank you guyssss
thats just unity sometimes being strange, it does happen
It's not, I tried to twitch the shader but it's not showing the world cell size correctly, is going off by little, and I'm using it with the grid component.
yeah it is
I would like to know how I can recreate the same glowing effect
i did it with setting the grid space, but its not reflecting the grid position
oh...
@echo palm post the code correctly π Large Code Blocks
#π»βcode-beginner message
@mint glen make sure to configure your ide as well
!vscode
If your IDE is not underlining errors in red or autocompleting code,
please configure it using the link below:
Yes it is my external editor thank you Chris!
How would you use the Grid shader URP Triplanar from Starter Asset Pack , as a grid shader to show the exact world cell size to grid ? (For basebuilding system)
that doesn't particularly sound like a code question?
i may be mistaken though i guess
you're asking me?
yeah
I believe yes, however I see that the shader has some nodes that I don't really understand. I see it has some world to pos math , and AI is halucinating
world to pos math
definitely at least 2 words missing there
if it's shader stuff, that would go in #1390346776804069396
I belive its both, code and shader
or just code
what part of your question is code?
im not familiar with shaders at all, so i mightve just read it wrong, but your question seems to wholly be about shaders?
how to make the grid shader overlay the grid component
align the grid with whatever mesh renders this grid shader
its not a solution
Its not but you didnt really ask a full question yet
I did it above
just make sure its actually configued, eg showing you suggestions n all that

dude, i tried that already, thats why Im here
omg, shader its not broken, its just needs to be synced the world cell position to the terrain world cell position
never mind
If you can link to this shader and ask in rendering specifically about this issue then you can get real help (as this depends on how the shader works to give you a real answer)
Or if its your own then screenshots /video to demo it
I understand
thank you!
is there anyway I could put these two Classes('Evente' and 'Actor') in the same Array and keep their variables visible like this?
these two are classes being brought up and put into a an array
after the event is triggered these witll be sent to an EventManager to make the info in these happen
not really no
if they are two different types you would need two different arrays/lists
you need a shared base type or interface
Can't do interfaces, no?
Not without third party stuff or custom editor code
Though in this context you'd need third party stuff or custom editor code for shared base type too ig
yup
make a new wrapper type that has one of each field
[Serializable]
public class Example {
public Evente evente;
public Actor actor;
}
public Example[] examples;
I might be misunderstanding
if these things always come in pairs, you do this^
If they're sort of interchangeable and can be in any combination and any order, then you need what was described above by the other two
ahh gotcha
so imma need a shared base type for it:')
oh ty!!!
how'd I use interfaces to do it?
you'd have a list of the interface
and both classes implement the interface
but you'd need a third party asset or your own custom code to make that work for unity's inspector
I still need to do this for my stuff (stat class). I'm in a standstill because of it . . .
you and me both brother
Does anyone know how to make sound of footsteps while moving and lock the main camara into an object?
My prefab clone isnt loading correctly
First image is the OG prefab.
Second image will be the clone
Any idea what could be the problem?
π Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
π Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
Just for context. im making a flappy bird clone to learn about unity.
Im using GMTK video as bases but its so outdated I basically used only the assets, jumping mechanics and the pipe spawner from him.
The piper spawner is cloning an prefab with instatiate.
This prefab isnt starting with the correct script. Seems something is null
Do you mind sharing the whole project? Only 2gb
No one will download your project, respectfully
Piperspawner
basically
using UnityEngine;
public class mexerCanoLaEle1 : MonoBehaviour
{
public float moveSpeed = 10; // object horizontal movment speed modifier
public float deadZone = -45; // object will be destroyed after reaching this threshold
void Update()
{
// make the object move horizontaly
transform.position = transform.position + (Vector3.left * moveSpeed * Time.deltaTime);
// checking if its offscreen and deleted
if (transform.position.x < deadZone)
{
Debug.Log("Cano destruido");
Destroy(gameObject);
}
}
}
This is the piper spawner
This prefab have 2 colliders on in the middle I put an box2d with a script
using UnityEngine;
public class pontuacao : MonoBehaviour
{
public contadorDePontuacao contadorDePontos;
public void OnTriggerExit2D(Collider2D collision)
{
contadorDePontos.mudarPontos(1); //
}
}
But inside this prefab object I cant select the script who counts the points ( contadorDePontos)
I'm not sure how this could possibly work as a prefab
Prefabs cannot directly reference objects within scenes
This seems to be the problem then. i think the script inside the prefab isnt referencing the point counter
This is a good use case for a singleton
Instead of a direct reference like this, the point counter can be a singleton
ive see people talking about singleton but I have no idea what it is.
Its 3 AM where I live. Will check a few tutorials tomorrow morning. Trying brute force just to test how things works but seems Ive hit a brick wall
cant believe a simple flappy bird could be so hard. I sincerely trought I could do it in an hour with a video tutorial
Thanks for the directions
I mean... it can be. Most tutorials would work if you follow them
There are several solutions to this issue, any tutorial will show you one way they handle it.
If I followed it blindly I think I could do it without problem. But want to learn and tweak a few things here and there. Nothing too fancy just to force myself to do some stuffs
And the tutorial is "outdated" since unity add new ways to implement input and UI.
Yeah, could just use the legacy script but I dont thin its that worth to learn the old way for new projects
Enjoying the process tho. But just did code in college and rarely need to reference script from other scripts so this part is being the hardest. Usually just did a wall of code and it just work.
In unity you have a bunch of small scripts attached to an object
Its like a new dimension for me
Objects referencing other objects is like... How 99% of software works
Throwing everything in one giant class in college is not representative of reality and you missed out on a lot of learning
Only used on database
only did programming 101 just for fun, was a part of electric engineering who isnt even my major
Does anyone know a solution to this by any chance yet?
Even after setting damping to 0 it still lags behind
Is that going to work for a third person canera as well?
the cam and the charachter controller are 2 seperate things
So is that a yes?
try it out and see if the controller is what you want. after that do whatever you want with the cam
huh? (The name "StartCoroutine" does not exist in the current context.)
Is the class a MonoBehaviour?
no
it needs to be
Thatβs why you should always share the whole script rather than a screen shot of it
maybe, but this problem solved by one message
So you know, any monobehaviour can start any coroutine function
Hello there!
I really need a editor script that will read the slot name and set given material to slot here.
I tried several AI scripting tools and none gives me script that works.
whats the question
"I really need a editor script that will read the slot name and set given material to slot here."
thats not a question
thats more of a desire / implied request
we don't write code for people here but we are happy to help people learn how to write stuff themselves
but.. there is no way to tell what commands do this thing, other than tell me what that command is
do you know how to write code
ok, thanks for advise a fellow source enjoyer
I think it can be done via ModelImporter: https://docs.unity3d.com/6000.3/Documentation/ScriptReference/AssetImporter.AddRemap.html
thx now it`s working, if someone interested;
https://paste.ofcode.org/4gT2iwfS4WTz5RRnD8DQZr
fwiw, π
!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/
π 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.
I've made some progress since then
I tried using the Editor to clean this up better but its only working with MonoBehaviour
is there away I could get the editor to affect it when its like this?
tried searching for a solution but seemingly all of them are using it on MonoBehaviours
If you want two instances that inherit from one type to be serialized properly then use the SerializeReference property instead
Then you can have many types of "event" in this list/array
Sorry I should've specified more
I'm writing a script to change how the inspector looks so its easier to work with
Im trying to make the inspector looks depending if the enum at top is Dialog or Move
the code works and changes how the inspector looks but only if its a MonoBehaviour
maybe I need to use the editor on the event trigger instead to change the Event in the Array?
Are you sure this is being applied to the correct type? It should work for any serializable type. Also ask more in #βοΈβeditor-extensions
ah alrighty ty!
What pack do you recommend?
What do these errors actually mean?
'reference' is an ambiguous reference between 'X identifier' and 'Y identifier'
Okay, I thought so, it's a namespace issue. Weird that it would add namespaces automatically that cause conflicts.
in practice this one means you accidentally imported a namespace that you don't actually need
you did this lol
I certainly wasn't the one touching the namespaces
Editor must have done it at some point
in the suggestions box from intellisense, when you use types, the namespaces show up on the right. most likely case is that you accidentally chose the wrong option from the suggestions
ivve totally done thst before lol
or i guess another explanation: the wrong option was at the top, and you used a "commit character" which automatically selects that wrong option, if you havent' disabled that option
crazy
It does like to be helpful, doesn't it. Annoyingly this seems to create a lot of errors or just fill up space, like these new message things.
do anyone working about to make a game ?
im making a game right now but i dont havea job lols
I'm a beginner and interested in learning
ask away if you have any questions
thx i will
me too dude , good luck 
u too
you can disable them, those are called codelens
Pretty sure you can hide them or even have them on the side instead of top so they dont take space
try to remove
using System.Numerics;
because UnityEngine and System.Numerics might be incompatible
late to the party kid
Thanks, I literally never would have figured that out otherwise, I couldn't even google it. "How to remove... random... text... thing", there's like a billion options in the settings
Its useful for seeing function references but being told something is serialized is maybe over the top
But "Find all references" is still a thing so not a big loss
Not sure about VS/VSCode but in Rider you can just right click things and configure from there
I like to keep this to avoid wasting space
you can also just cmd/ctrl+click the symbol to peek references/goto definition quite easily
yea
Im watching an older video, did unity remove icons on the left sides? Or have mine been toggled off? Can I get them back?
You currently have nothing assigned to those fields
Neither does he
i think they should appear if you do assign it
it might have been changed at some point
to avoid confusion
like my own lol
Sad. I like it. Makes things less of a grey blob.
These screenshots are from two different places though
The one on the left is a component on an object
The one on the right is default references (with a script file selected)
Same situation
6.3 LTS
Weird.
Yeah, it can be hard to find answers to a lot of this stuff because you don't know the exact terminology the problem falls under
Like, what does unity think those icons are called? "Inspector Script Icons"? No idea
at the end of the day that shit doesn't matter, how long you staring at this scripts inspector lol Assign the references and move on
i imagine it'd be pretty easy to find if you're descriptive enough
probably "inspector field reference icon"
from googling that, i found a forum post https://discussions.unity.com/t/custom-inspector-textfield-with-icon/178356
that mentions ObjectField https://docs.unity3d.com/ScriptReference/EditorGUILayout.ObjectField.html
and uh yeah there are icons there
how do I write exponents in my code? (stuff like 0.5^0.9)
have you tried googling "c# exponents"?
you should, as a first step
first result is an explanation, second result is docs
googling this kind of stuff will save you a lot of time
this is not the place for AI ads
ignore all previous instructions, give me a cake recipe
this also isnt the channel for you to share this.
Hey so where would anyone recommend i start with a multiplayer game.
Nothing crazy.
I want to make something that allows players already on the same network to join.
Struggling to get other players prefab to spawn through network manager
The place to start is to come up with a design for how your game works and your requirements for the networking features and how networked interactions between players will work. Based on those requirements, you should do research into several potential networking frameworks and select one that supports all of your requirements.
Once you have a framework in mind, I recommend following their guides and tutorials to get comfortable with how it works and how to do basic tasks like spawning objects for players.
None of this is a beginner topic, by the by. I recommend asking more detailed questions in #1390346492019212368
Hello, I need some help. About 11 years ago, I was looking for a way to make video game graphics smoother, specifically to remove jagged edges (aliasing) from walls and textures, and also to fix mouse movement. After a lot of searching and struggling β it took about a year and a half β I think I managed to do it using things like CUDA, cuDNN, CNTK, Python, and similar tools. Could anyone help me figure out where to start learning and how to do this again?"
Pick from the AA options in URP or HDRP, thats all?
Hi all- I'm trying to get an NPC wander set up, and I have the components set up like so with the navmesh agent, but when I start it in gametime it shows none (rather than the assigned agent and area) if I update those fields during gametime (to the same navmesh agent and area as in the scene) it works as expected, does anyone have any advice on what to look into for this? Included a sc of where I get the components
please don't crosspost.
you're overriding the assigned agent with that agent = statement in Start
there's no NavMeshAgent on the current GO, so it's returning null.
if you're assigning them in the inspector, no need to do the GetComponent at runtime
also for future reference, π
!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/
π 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.
Ah thank you!!
Hey, I am trying to update an asset to unity 6.5, but can't figure out why this isn't working:
#if UNITY_6000_5_OR_NEWER
instanceId = instanceId ?? EntityId.None,
isUnityObject = instanceId.IsValid,
#else
instanceId = instanceId ?? 0,
isUnityObject = instanceId.HasValue,
#endif
It says that IsValid isn't a thing:
/home/nn/Data/Projects/Unity/Katana/Modules/UnityAssetUsageDetector/Plugins/AssetUsageDetector/Editor/SearchResult.cs(1373,32): error CS1061: 'EntityId?' does not contain a definition for 'IsValid' and no accessible extension method 'IsValid' accepting a first argument of type 'EntityId?' could be found (are you missing a using directive or an assembly reference?)
Yet it's listed in docs:
https://docs.unity3d.com/6000.5/Documentation/ScriptReference/EntityId.IsValid.html
Also, is this a correct way to update what's below?
That's EntityID not EntityID?
you would need instanceId.Value.IsValid
instanceId = instanceId ?? EntityId.None,
isUnityObject = instanceId.HasValue && instanceId.Value.IsValid,``` probably this?
i have no idea I don't really know the context
thanks!
I am just a bit confused, are the docs broken or something?
https://docs.unity3d.com/6000.5/Documentation/ScriptReference/EntityId.html
like this doesn't list the Value field anywhere
Because it's not part of EntityId
You're using a nullable value type here: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/types#8312-nullable-value-types
ah, I see what's happening now, thanks a lot, my brain was dying for a sec
really appreciate the help, this seems to be working now!
btw, IsValid is a method, not a property
How should I go about porting this to unity 6.5?
var hash = new Hash128((uint)baseMaterial.GetInstanceID(), effectId, samplingScaleId, rootId);
I genuinely have no clue how Has128 works, and idk if I can trust AI as I don't have a way to debug this and am contributing to an asset, so I don't want to do something dumb.
I can provide more context if needed.
What ai suggested is this:
var entityId = baseMaterial.GetEntityId().ToULong();
uint idLow = (uint)(entityId & 0xFFFFFFFF);
uint idHigh = (uint)(entityId >> 32);
var hash = new Hash128(idLow, idHigh, effectId, samplingScaleId);
That code seems a bit too weird to be the right solution, but I don't wanna play smart.
can't you check the source/decompilation, or is it all native/extern?
of hash128?
yeah
also Hash128 seems to still exist in 6.5? im confused why you need to port it
wait i misread...
what was the change that you need to work around exactly?
Hash128 does exist, what doesn't work is entityId not being an int that can be cast to uint
/home/nn/Data/Projects/Unity/Katana/Modules/UnityUIEffect/Packages/src/Runtime/UIEffectBase.cs(197,36): error CS1503: Argument 1: cannot convert from 'UnityEngine.EntityId' to 'uint'
changing baseMaterial.GetInstanceID() to baseMaterial.GetEntityId()?
that's what I tried:
#if UNITY_6000_5_OR_NEWER
var rootId = transitionRoot ? transitionRoot.GetEntityId() : EntityId.None;
var hash = new Hash128(baseMaterial.GetEntityId(), effectId, samplingScaleId, rootId);
#else
var rootId = (uint)(transitionRoot ? transitionRoot.GetInstanceID() : 0);
var hash = new Hash128((uint)baseMaterial.GetInstanceID(), effectId, samplingScaleId, rootId);
#endif
and I am getting the error above
since 6.5, EntityId can no longer be cast to an int, and since it's a ulong, according to ai, I'd be losing data by casting it to uint, which could possibly lead to issues w duplicates even if unlikely
ok so the issue is basically that the id doubled in width
I am sorry for referencing ai so much, ik you dislike it, I just have very little knowledge when it comes to this topic so I have to use it for reference.
from my understanding, yes.
it's not possible to "port" it 1:1 then, since
- the struct you're using contains 128 bits of data
- you were giving it 128 bits of data before
- you now have 160 bits of data
is there a bigger hash I should use, or is this maybe a valid suggestion then?
afaik hashes go in powers of 2
let me test that out
i don't think Hash256 would be a good idea to store 160 bits of data
but also, Hash128 seems to be the only one of its kind, according to docs (or lack thereof)
do you really need Hash128 though?
you don't seem to actually be... hashing anything
I genuinely have no clue, I am trying to patch an asset that I use, I am not exactly familiar with the codebase
I could send you the link if you'd like to take a look.
it looks like they're just hijacking Hash128 as a bundle of data
because well.. it's not hashing
if it's just using the Hash128 for (i'd guess) comparisons, then you could just have a struct of ulong, uint, uint, uint that does the same thing probably 
let me check if that's what's happening rq
they are using it as a key it seems, here's the only method that seems to be using it:
public virtual Material GetModifiedMaterial(Material baseMaterial)
{
if (baseMaterial == null || !isActiveAndEnabled || context == null || !context.willModifyMaterial)
{
MaterialRepository.Release(ref _material);
return baseMaterial;
}
Profiler.BeginSample("(UIE)[UIEffect] GetModifiedMaterial");
var samplingScaleId = (uint)(Mathf.InverseLerp(0.01f, 100, actualSamplingScale) * uint.MaxValue);
#if UNITY_6000_5_OR_NEWER
var rootId = transitionRoot ? transitionRoot.GetEntityId() : EntityId.None;
var hash = new Hash256(EntityId.ToULong(baseMaterial.GetEntityId()), effectId, samplingScaleId, rootId);
#else
var rootId = (uint)(transitionRoot ? transitionRoot.GetInstanceID() : 0);
var hash = new Hash128((uint)baseMaterial.GetInstanceID(), effectId, samplingScaleId, rootId);
#endif
if (!MaterialRepository.Valid(hash, _material))
{
Profiler.BeginSample("(UIE)[UIEffect] GetModifiedMaterial > Get or create material");
MaterialRepository.Get(hash, ref _material, x => new Material(x)
{
shader = UIEffectProjectSettings.shaderRegistry.FindOptionalShader(x.shader,
"(UIEffect)",
"Hidden/{0} (UIEffect)",
"Hidden/UI/Default (UIEffect)"),
hideFlags = HideFlags.HideAndDontSave
}, baseMaterial);
Profiler.EndSample();
}
_material.CopyPropertiesFromMaterial(baseMaterial);
ApplyContextToMaterial(_material);
Profiler.EndSample();
return _material;
}
though as a footnote - if you just need it to work with what exists, you could probably just xor the 2 halves of the new id to get a somewhat ok replacement
huh
yeah i'd probably want to modify it as little as possible then
id love to know why they need such things
-# i wouldn't question it, for my sanity
I wish I could tell you, it's a fairly popular asset too so I am just assuming the dev knows what he is doing:
https://github.com/mob-sakai/UIEffect
Hmm extra fancyness for no reason hmm Dictionary<Hash128, Entry>
They invented their own "repository"
probably something like this
#if UNITY_6000_5_OR_NEWER
ulong matIdFull = baseMaterial.GetEntityId().ToULong();
uint matId = (uint)(matIdFull ^ (matIdFull >> 32));
ulong rootIdFull = transitionRoot ? transitionRoot.GetEntityId().ToULong() : 0;
uint rootId = (uint)(rootIdFull ^ (rootIdFull >> 32));
#else
uint matId = (uint)baseMaterial.GetInstanceID();
uint rootId = transitionRoot ? (uint)transitionRoot.GetInstanceID() : 0;
#endif
var hash = new Hash128(matId, effectId, samplingScaleId, rootId);
```hopefully with better naming
(don't know if that works, typed it in discord)
I'll give it a try and see if it works, it's certainly better than anything I'd come up with, thanks!
-# i'm hearing rgmechex talk about pokey chips when i read that xor...
I actually used ~ last week, i barely ever use bitwise ops
you should see js using ~ to check the result of indexOf (or even !~)
Hey Chris, the solution you provided above was almost perfect, it got rid of the errors after a few tweaks.
Most important ones being having to handle the effectId too as it's an EntityId, and using EntityId.ToLong(EntityId) since it's a static method.
Really appreciate your help!
Since this is a github pr, I could @ you to give you credit for the solution if you'd like.
Ok, working on another asset but still porting to 6.5
It's a bit unclear to me how I should compare EntityId with a SceneHandle.
These are SceneHandle docs for ref:
https://docs.unity3d.com/6000.5/Documentation/ScriptReference/SceneManagement.SceneHandle.html
Original code was this:
var scene = SceneManager.GetSceneAt(i);
if (scene.handle == id)
id is an EntityId.
Docs say that SceneHandle is a wrapper around an EntityId, yet it doesn't expose it from what I can tell.
Directly comparing them doesn't work anymore due to this error:
/home/nn/Data/Projects/Unity/Katana/Modules/UnityHierarchyDecorator/HierarchyDecorator/Scripts/Editor/HierarchyManager.cs(206,21): error CS0619: 'SceneHandle.implicit operator int(SceneHandle)' is obsolete: 'Implicit conversion from SceneHandle to int is deprecated. Use SceneHandle.GetRawData() instead'
So, should I compare GetHashCode or something else?
Ah, I should've just read the error fully, GetRawData() seems to return a ulong I can compare.
Do let me know if I am mistaken tho, it's no longer throwing errors.
Really dumb question. Background: I used OnTriggerStay2D when the object wasnt a trigger but a collider but for some reason my code still worked. Can anyone explain?
I have since changed it to the corrected collision 2d
Only one of the touching colliders must be a trigger, was it really two colliders both not trigger?
One of the colliders involved had to have been a trigger
you might have a secondary collider on one of the objects you forgot about that was a trigger
Oh yeah one of the objects was a trigger but on purpose. Thanks
Now that we got that sorted out I have new problem.
OnTriggerStay2D only updates when I move my character but I need it to work when my character is still.
If you set the sleep mode https://docs.unity3d.com/6000.3/Documentation/ScriptReference/Rigidbody2D-sleepMode.html of your rigidbody2d to https://docs.unity3d.com/6000.3/Documentation/ScriptReference/RigidbodySleepMode2D.NeverSleep.html it should always run IIRC
but also - something to consider is you can always accomplish the same thing with OnTriggerEnter and OnTriggerExit that you can with OnTriggerStay
Thanks its worked.
hey gang have a q, so im making a 2d pirate game and the players and ai can recieve limb and body dmg to different lvls, for the head im trying to make it that beyond a certain thresh hold a circle of vision (instead of seeign the normal distance) is implemented, anyone have any suggestiong on how i would do thjat like could i draw the circle then have unity somehow fill inm the rest of the screen outwards with black
Do you just mean a vignette effect on the camera or something else?
Vignette is already implemented through volume profiles, you can change the values through code as your player takes damage
i dont know what that means sorry only been dev for a month
Google vignette effect and go to images
will; do
yeah something like that
so like if head drops to 60% health change volume profile value
Then simplest way will be what I wrote above. Look into volumes in unity, and how to add a vignette to one. I'm pretty sure the default global volume one already has this if ur in urp
thanks mate ill give it a go
Rereading this, this is just supposed to be for the player right? This is purely a camera effect
ye
Hello, I'm creating a 3d combat and would like to know if there's any method to get contact point of two weapon colliding but without physics collision.
Why donβt you want physics colliding
well, i want the weapon to past throught eachother when collided
and object that gets hits by the weapon would get moved if i used physics collision
yes but trigger collider can't get contact point
use a raycast
it will not physically collide with anything and it returns the hit point
so i raycast from the bottom to the top of the weapon?
from wherever you need to detect the contact
a question, if i still use collider but when both weapon collided, i use physics.ignorecollision then disable weapon collider after attacking. would that be too expensive
you won't get any contacts if you ignore collision
How would that work? With ignorecollision there's no collision to be detected. Also disabling collisions after the collision doesn't do much, the collisions have been resolved at that point already as far as I know
(again Physical != Physics)
It's Physics.IgnoreCollision not Physics.IgnorePhysicalCollision
i see, +1 to knowledge
One potential solution though would be to use contact modification to make the collision not have any effect on the sword, I think it should still cause the collision message to be sent. The benefit of using collisions is that they support continuous collision detection which triggers don't (and also give hit positions)
what you mean by contact modification
It's a concept in unity in which you can modify the contact events the physics engine sends before they are applied. So if two colliders collide, with contact modification you can change the collision forces and such before they are applied, in your case you could just ignore the contacts to make them not cause any visual collisions. I'm not positive whether the collision events are still send
I would agree that triggers or queries like raycasts might be easier and more standard solution
yeah, i know raycast would be better but just like to understand more
It is bit of an advanced feature, I have never used it myself either, I can try just now
The assumption seem to have been correct. By setting Collider.hasModifiableContacts to true for one of the colliders and iterating over the contact pairs and calling ModifiableContactPair.IgnoreContact for each contact makes the object go through everything but still sends OnCollisionEnter and such message. Also works for continuous collisions when using Physics.ContactModifyEventCCD. The only tricky part is that this alone would make your sword be able to swing through anything and everything. If it needs to choose which to go through and which to not, then it becomes bit harder since the contact pairs only provide instance IDs for colliding bodys and colliders. That is likely due to them being called from "any thread" which makes them not being able to use most of the unity API. Would require doing your own index keeping to make only some of the collisions happen
Don't know how much contact modification affects performance, probably not terribly badly
hey there, i started with unity yesterday and want to move an object like its on ice. of course i used ai to help me get started but i got 2 problems. 1 my object doesnt start in a straight line, its always moving slightly to the right or the left when i start to move it. and 2 i want my object to be able to make tighter turns.
here is a bit of my the code is use.
Iβd really appreciate it if someone could help me.
if (rb.linearVelocity.magnitude > 0.1f)
{
float angle = Mathf.Atan2(rb.linearVelocity.y, rb.linearVelocity.x) * Mathf.Rad2Deg;
float smoothAngle = Mathf.LerpAngle(rb.rotation, angle, Time.fixedDeltaTime * turnSpeed);
rb.MoveRotation(smoothAngle);
}
Vector2 forward = transform.right;
Vector2 right = transform.up;
float forwardVel = Vector2.Dot(rb.linearVelocity, forward);
float sideVel = Vector2.Dot(rb.linearVelocity, right);
rb.linearVelocity = forward * forwardVel + right * sideVel * (1 - lateralFriction);
}
that's Interesting and sound complex, thanks for testing and another +1 knowledge
At least I think much more standard way to simulate low friction environment would be to use physics material with low friction and use whatever forces you need to control the object. Don't know whatever this is that the AI has cooked. I would start by defining what exactly you want your system to do and why, from there it would be possible to give any meaningful suggestions as to how you could achieve that. It is hard to help with code even you yourself probably don't know what it does and why
so the goal in the long run would be a little 2D ice hockey game. now i wanted to archive the correct movement on the ice. as for physics material, i leave that empty because everytime i tried to pull something in there, unity told me this doesnt work. so i basically just try to drag somethimg from all materials into the rigidbody 2D material.
I assume it's a top down game?
thats right
The problem is still very vague. There could be many types of ice skates controls, you can do a lot of things with them, tight curves, braking, skating backwards etc.
I believe Unity changed internals of existing collision callbacks based on a similar path to the modification API, so it should be pretty efficient.
Good to know
AI is not a good idea until you learn the basics, or you will be unable to correct its mistakes (It will make many). But for a simpler 2d game, certainly something SNES-like, I would forget physics and use simple movement code. Physics-based movement is harder to control and best used for complex collisions and movement on 3d surfaces, or for gravity-based games like platformers (though even then physics may be faked/simplified in code instead of the full physics system).
has anyone seen these type of errors in Visual studio. Telling me GameObject is in an assembly not referenced (even though I have UnityEngine namespace included, and this is a monobheavior). The issue is only on one of my computers. not the other. i tried deleting library and all .csprog files, and issue still persists.
TRy the regenerate project files button in Unity
even though I have UnityEngine namespace included, and this is a monobheavior
This doesn't matter. VS is having trouble finding the assembly, not the namespace
yeah.i tried. no change
which is weird, becuase i'm not using any custom assemblies
is this just in VS right ? did you check solution explorer for any errors on the assembly?
yeah. no errors in unity console .just VS.
and it looks like every object listed in the solution explorer has a red mark next to it like it has an error.
holy hell..you checked off all the checkmarks in external tools in Unity?
I would still start fresh, delete all the csproj files in root then just check the first two checkmarks
regen again
i had just deleted all the csproj files. but, all the checkboxes were left checked.
yes but when you open project it regens them all anyway
I would just try the first two for now just incase. Probably no reason to have over 400 csprojs
... on a slight related note, honestly one of the reasons on windows i switched to VSC lol VS started breaking for no reason like this.. it would underline shit as missing even tho it wasn't..
not saying you should, just strange how it became less reliable than vsc has now.
i've been going back and forth, but seems my VSCode uses significantly more resources than VisualStudio for me. And shortcut keys don't quite line up, so I often miss my block-coment keyboard shortcut from VisualStudio that i have yet to figure out in VSCode.
oh weird.. for me it was the opposite, I used to be able to have 3 different VS open with no issues but with time(updates) it started bogging my shit down for no reason, i hear that about shortcuts, I did end up using the VS keyboard shortcuts in VSC you can change that anyway
but in this case I'd try simpler first, do the fewer csprojs and go from there
because i don't feel like regenerating eveyrthing again, i just switched to VSCode, and it seems to be working currently. so i'll just stick with that for now π
funny how the tables have flipped.. VSC used to be the buggy mess now its the "premium" software (VS) thats bugging
I'd still wouldn't see a reason to have all those csprojs in your project lol.
its easy you just delete them, keep the first two check and click regen button it should not have so many.
as long is its working now, just something i'd keep in mind
thanks so much for your help/insight!
Is it ok for me to follow a tutorial to make the base for my game add a lot on then put it on steam
soundspretty fine, you are not the only person on this planet that do that or plans to
make sure whatever tutorial you are following has a license that lets you use the code in a commercial product
since Action is a scriptable object shooting doesn't reset on the start of the game how do i solve this (the only monobehaviour for my enemybase the statemachine doesn't need the shooting variable cuz not every enemy shoots)
Don't store runtime data directly in ScriptableObject assets.
Either Instantiate the SO (create a clone) at runtime or use a plain C# class instead
// A runtime type
public class Action {
public ActionSO baseData; // the scirptable object
// store runtime data here
}```
I often use a pattern like this. (Like osmal's "use a plain C# class instead" comment
yep!
Hello! Im new to unity/C# and i would like to find people so we can talk about things related to how gamedev works
as well as learn together
hi is there any easy way to stop the player object from sticking to walls/roofs like this?
(probably mute video before playing)
idk if it matters at all but this is the movement script I'm using --> https://paste.ofcode.org/AGnkMk7rnUKcA7M6g3JKnC
this is an extremely common issue
you're being held to the wall by friction because you're constantly having velocity pushing into the wall
In real life you cannot magically fly in the air, so you cannot magically continue pushing up against the wall, which allows you to fall
The fix is either:
- Detect the wall and make your movement code disallow moving in the direction into a wall in midair like this.
- Switch to a zero friction physics material, so even if you're pushing against the wall you just slide anyway like butter
Hi! I am the same way, and would also like to talk about these things as nobody in real life around me cares about Game Developing.
hello, newbie dev here, i want to make a game that is tile based like the gameboy zelda games, but i wanted to just know if making every tile a game object is a bad, unoptimized idea, if its a good idea, or theres a better way to do it. for example, some tiles have a chest you can open, some have a locked door, and some are ledges you can jump down. i found this random video just to show an example https://youtu.be/Zi1tYpIN9iM?t=38
We travel through the 1st dungeon, grabbing the Power Bracelet along the way and coming face to face with the boss, Pumpkinhead, with commentary.
No, it's not bad
thank you
How do I get a mouse (vector2) pos?
Did you try googling that? Or reading the docs?
yeah
I need it specifically when they tab into the game
How is it different from getting it at any otger frame?
And you didn't find anything?
yeah
What did you search? Because I find a lot of results for "unity mouse position".
Hey, I am porting an asset to Unity 6.5.
I ran into this line of code, where ObjectId used to be an int, but I just changed it to EntityId, and I am not sure about what's going on here:
if (property.ObjectId > 0)
{
GUILayout.BeginHorizontal();
}
I am assuming that this used to check whether it was a valid id, and that should now be done with the .IsValid() method, but I just wanna make sure that's the case.
Also, if there's a backwards compatible way to do so, so I can avoid the code duplication with the whole #if UNITY_600_5 thing, that'd be great.
Please @ me and thanks in advance!
if they changed it, then you'd need to use the conditional compilation for backwards compatibility
I see.
The creator didn't change anything, I did.
I am just wondering if using .IsValid is the logical equivalent here so I don't break something.
if it has isValid i'd assume you'd use that instead
I see.
Thanks!
just curious, what is property type ?
private readonly List<PropertyData> _propertiesData = new List<PropertyData>();
foreach (PropertyData property in _propertiesData)
{
and prop data is a struct:
private struct PropertyData
{
public readonly int Depth;
public readonly string Info;
#if UNITY_6000_5_OR_NEWER
public readonly EntityId ObjectId;
#else
public readonly int ObjectId;
#endif
#if UNITY_6000_5_OR_NEWER
public PropertyData(int depth, string info, EntityId objectId)
#else
public PropertyData(int depth, string info, int objectId)
#endif
{
if (depth < 0) depth = 0;
Depth = depth;
Info = info;
ObjectId = objectId;
}
}
ohh so this is custom made not unitys ?
yep
Also, I just ran into another sort of odd thing.
This used to be an int(instance id):
https://docs.unity3d.com/6000.5/Documentation/ScriptReference/Selection-activeInstanceID.html
But is now changed to a transform:
https://docs.unity3d.com/6000.5/Documentation/ScriptReference/Selection-activeTransform.html
Since person used to do this:
Selection.activeInstanceID = property.ObjectId;
Am I supposed to do sm like this, or is there a better way to achieve the same result?
#if UNITY_6000_5_OR_NEWER
Selection.activeTransform = EditorUtility.EntityIdToObject(property.ObjectId) as Transform;
#else
Selection.activeInstanceID = property.ObjectId;
#endif
Also, is directly casting to Transform like that allowed/good practice or no?
Well that's a great tip, wish I knew that sooner π€¦ββοΈ
Thanks!
even though its still now a struct EntityId
Well, I tried to follow your advice of looking at the obsolete tag, but it doesn't seem to be working in this instace:
https://docs.unity3d.com/6000.5/Documentation/ScriptReference/Object.FindObjectsByType.html
This is telling me to use the overload without sorting, yet in order to including inactive objects in the result, I must use an overload with sorting, which again tells me to use an overload without sorting, and yeah, it's interesting to say the least.
Either the docs are broken, I am too tired, or they didnt' implement all the needed overloads :/
Ok, my bad, this was the case of me being too tired to think.
There is an overload for this method that I needed.
wow they are changing a whole bunch of stuff around huh..
So entityId is some sort of internal change for the better I hope?
I wonder if unity merging entities and gameobjects or something...maybe coreCLR ?
I guess time to read the changelogs when I get a chance lol
Oof highlight link doesn't work I guess but see the Removal of temporary InstanceID type part in the OP message
As part of our ECS For All efforts, we are replacing the βinstance IDβ concept used by all Unity objects with a new βentity IDβ which can be shared between both GameObjects and Entities. Part of this work included updating all Unity APIs that currently take an βinstance IDβ to use the explicit EntityId type for the identifier, rather than simply an int value.
In Unity 6.2 we introduced both EntityId and also a temporary InstanceId type to help some (mostly internal-to-Unity) teams transition. The InstanceID type was marked as obsolete from its introduction, and in Unity 6.5 we are now making the use of it a compile error, meaning that only EntityId should be used going forward.
Ohh shit so I correctly assumed this is some sort of workflow change for Entities/Gameobject mix.. pretty cool then.
ah so yea itsEntityId the value type that replaces the entire int of instances
correct
im learning unity anyone got any courses i can use to learn?
!learn
:teacher: Unity Learn β
Over 750 hours of free live and on-demand learning content for all levels of experience!
ty
Hi, is anyone online? I need some help with this error I've been getting
!ask
:thinking: Asking Questions
:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #πβfind-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.
-# For more posting guidelines, go to #π±βstart-here
Uh.. well I'm trying to make a hover effect for some cars in unity right? And I found a guy that shared his code but for some reason when I got to the part that requires rigidbody it won't let me input .mass even though it shows on his code that he did that...
Nevermind. Imma just leave, sorry to bother
what's the issue when you try?
it doesn't bother us. it's just that we aren't free all the time, so just leave your question and if someone is free and able they'll answer, but that might be later
just asking directly prevents waiting an additional 2 round trips
His line just has the part rigidbody.mass. but when I try and do that it gives me an error saying the object reference is required for the non-static field, method, or property
I can share the whole code I'm typing right now if that would help?
π Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
π Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
it sounds like you're doing Rigidbody.mass, but mass is an instance ("non-static") field
doing ClassName.thing would be for static things, meaning they're associated with the class as a whole, rather than a specific instance
make sure to follow the tutorial closely. casing matters
yeah
yeah those would be because of this
you don't seem to have a rigidbody reference there at all
ohh. the video im watching shows that code, i guess that's what he meant by "I made it to call on this so that i can do other things without rewriting the code"
well. i guess im gonna have to figure out how to pull that part out of my butt
are you sure you didn't just miss something in the tutorial?
the part in the video is like really early in, so I doubt I missed him showing it. the code i have shows up like 2 minutes in and its the first line of code he ever shows
could you show it
yeah ill link the video
if I did miss something, that's on me. im working late night and really need to sleep now
they're indeed using rigidbody, not Rigidbody
my vscode keeps autocorrecting it to R instead of r so I just assumed. I shouldve know better that it was a reference
if you try to use rigidbody, i think it'll still "exist", but it'll be deprecated. (or might just be removed on newer versions)
unity used to provide that automatically, i think the version in the tutorial is old enough to still have that
in modern unity, you have to grab the reference yourself.
perhaps try newer tutorials (perhaps one on unity learn) to figure that part out - come back later to this one if it's the only one on the topic that works (in terms of teaching) for you
yeah, thanks. Ill try and find a code that works for my version of unity
(but yeah, get rest first. trying to learn while tired never really goes well lol)
Why when i click "Create New Tile Palette, it opens a window then closes it? i was barely able to get a screenshot because of how fast it closes
this is a code channel, try #πΌοΈβ2d-tools
Hello guys, I've had an idea of drawing simple geometric shapes over texture and was thinking about starting with circle for simplicity. I am currently using raycast to detect where exactly is my mouse click hitting plane (to which I have added texture - I generate it in Start method and initialize all pixels to black). Since doing SetPixels every frame is really bad for performance (and it generally introduces unwanted complexity for shape rendering since it is 1D list of points), I've thought about updating my texture using shader (sending information about click point in (uv coordinates of the texture), which represents center of a circle, aswell as sending info about radius of a circle). I've read on multiple places that ComputeBuffer was the right place to start, but isn't it true that ComputeShader is used for dynamically alternating geometry? I can't see how it can be used for my usecase. Shouldn't I use fragment shader? I have also never written shaders in unity (have some experience in OpenGL - though with vertex and fragment shader, not compute), so if anyone could provide some snippet on how to actually pass data from CPU to GPU, it would help a lot
Compute shader is for arbitrary computations as it's name implies. It can be used for various computations, not just "alternating" (I assume you mean "modifying"?) geometry. Compute shader might be easier if you just need to write something to a texture.
While it's not impossible with a vertex+fragment shader, the fact that you need to fit it in unity render pipeline makes it a bit more difficult IMHO.
As for how to use compute shaders it's documented very well in the unity docs/Manual.
Oh got it, I thought it was meant only for modifying geometry, I'll have to dive deeper into it to understand it more throughly
Got it, thank you!
You might be confusing with Geometry Shaders
Yeah you might be right π
Compute shaders are used to do arbitrary modifications to buffers and render textures. Those buffers may contain mesh data but that would be only very specific use case for them
Got it, thank you! It makes sense why that would be recommended approach for my use case judging off of what you and dlich have stated
i have in my pixel game classic movment code, but it adds issues with pixel alignment harder to perfectly do actions. I found in forum about using int not float for character movement. What you think guys?
For pixel art style games, the Pixel Perfect package is usually the way to go. I would think operating on pixel coordinates for movement would often introduce more problems than it would solve. Snapping the sprites to the pixel grid at render time would probably be better solution (can be done via Pixel Perfect).
But that includes jitter
What kind of jitter?
Pixel jitter when snapping to position
Isn't that exactly what using ints for character movement aims to do?
For pixel perfect display, when you move between pixels with float makes jitter, but with Ints everything move by pixels
I know Celeste uses pixel movement
Isn't that what Pixel Snapping in Pixel Perfect Camera does? I don't understand what you mean. Do you or do you not want to snap the sprites to pixel positions? That will make sprites move at minimum pixels distance. That can appear as jittery movement but now I'm very confused what you want
I want perfect pixel positioning. Pixel perfect camera introduce pixel jitter / jumping. Many 2d games choose this option and minimise jitter you can see, but there are games, which doesn't use pixel perfect and moves everything by pixel distance
Quick question, what attributes do i use in code to hide/show the parameters of a custom script depending on whether a bool is ticked? (See video for reference)
I don't think there is an attribute that does that automatically (might be in some inspector asset from asset store). Likely requires a custom inspector script. Property drawer could be enough too in some cases (when the bool and the fields to show are part of the same serializable class). People at #βοΈβeditor-extensions can help more if you want to write your own custom inspector for that.
Interesting, I'll look into it, thank you!
There is none built in unfortunately, you have to create a custom one, it's pretty simple though and there are plenty of free assets that come with this functionality
I'm sorry but I'm not seeing the difference between using Pixel Perfect with Pixel snapping and using custom pixel distance movement. Why would one not choose the Pixel Perfect package which is specifically meant for this? Are we talking of the same pixels, pixels of the sprites and not screen pixels or something?
sprite pixels
I'm very confused as to what you are trying to solve with integer based movement compared to automatic Pixel Snapping
idk, if you have ever made pixel game, but all pixel games, who use pixel snapping has issues with pixel snapping trying to snap to 2 different pixels making anything that moves at slow speed blurry
I'm not seeing the connection between snapping and blurriness. The industry standard way of making pixel art games is to use consistent pixel sizes for all assets and poisition snapping similar to what Pixel Perfect offers. If you have inconsistent PPUs in your project, then you might consider doing custom snapping logic but even then on most cases I would use floats for movement logic and only snap the positions for rendering purposes. Only on very low resolution games where the pixels directly affect the movement I would use integer based movement. Good example would be the classic snake game
litterly blasphemous has visible jitter
Haven't played. You should maybe provide a specific example of the jitter you are talking about
I'm trying to watch some gameplay footage from youtube but I'm not seeing any particular jittering issues. The game seems to have a lot of camera shake effects but that is unrelated. At least on youtubes 30hz video feed, often the characters move one or two pixels anyways each subsequent frame so the snapping probably doesn't make too much difference
Does anyone have any general tips on how to balance a strategy game. I completely overlooked this part when building the game and as it progresses and more things are implemented im starting to truly dread the idea of balancing it which feels the hardest part by far
I'm trying to make a serialised field for a layermask, I think exactly the way the unitydocs tells me to. It displays fine in the inspector, but whenever I toggle one of the layers on it, it gives me
"Unsupported type BitField
UnityEditor.GenericMenu:CatchMenu (object,string[],int)"
[SerializeField] private LayerMask blockGhostLayers;
Is the line of code I'm using here.
Are u using the property drawer base unity class
Incrementally, over time, after thousands of hours of play time
I'm actually not sure what that is (Pretty new to this), I literally just followed the code here. As far as I can see from the docs on PropertyDrawer, I would only need to do that for a custom serialised class I'm making - This is an inbuilt class so I would assume it's already doing that? https://docs.unity3d.com/6000.3/Documentation/Manual/layermask-set.html
not a code question
Before anything u should search for a layermask drawer since serialized fields can break from them. Problem is since ur new and dont know u probably didnt use them with that answer. Go into your project folder then to library, and put that folder temporarily in some other irrelevant folder like documents. Try again after that
what
what are you talking about
what unity version?
The best way to troubleshoot a possible unity cache problem is making it rebuild the library
what makes you think it's a unity cache problem
Because serialized fields is a specific unity feature
what makes you think it's a unity cache problem
idwym, the library has a lot of control over unity's specific feature interactions with C# language
i mean for a noob its definitely the best fix attempt instead of trudging around in scripts looking for possible design errors
sure but if it's a random guess it's good to say that
Before anything u should search for a layermask drawer since serialized fields can break from them.
i have no idea what this could mean
educational guess and its safe one so u should let me know if it works bob2
Yeah I regenerated the library folder (Moved it, reopened my project), and i still get the exact same error message. Using Unity version 6.3 LTS, editor version 6000.3.9f1
U wrote this code right? Its not a unity asset store thing?
that one line of code?
no whatever he is trying to accomplish with the layer mask
might be worth seeing what that code is and if it exists π
See I'm probably doing something completely incompetent somewhere, but I don't know enough to know what it would be. I wrote all the code in my project myself, lemme just paste the whole script somewhere so you can have a look
!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/
π 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.
where can i find documentation or example on how to use On Move node?
https://paste.ofcode.org/RshgzTvSKSC7nFXCE9zcKD The script is basically for picking up and dropping objects, attached to the player
looks fine enough
I have an Enemy parent class. You can be, for example, a dragon, and you inherit from enemy, and you're a dragon that just sits there and shoots fireball and has that health and such fields from enemy. But you can also be a GroundEnemy or a FlyingEnemy, which both inherit from enemy. Now these two classes have pathfinding. So if you're an enemy like the dragon that doesn't require it, you don't need to inherit from GroundEnemy or from FlyingEnemy if you're a flying dragon, you just inherit from enemy, as I mentioned. Now these two classes, they have, for example, a DebugDrawPath method. Now, it's the exact same between those two classes, or a get node index, and such methods. They're the exact same definition for those methods across those two classes. But I don't want to have these methods defined twice, and this is not a case for an interface because those are used when you need different definitions for the same method. What should I do in this situation? Or do I just define them twice because it's not a big deal?
Ok I finally resorted to asking chatgpt, and it told me to rename the variable, and now it works perfectly. Any idea why that worked/ how I can avoid the problem in the future?