#💻┃code-beginner
1 messages · Page 503 of 1
not objects
just the camera view
like lets suppose
okay, so let's say you set the rect H to 0.5
You still want the camera to take up the entire view?
i put the width and height of the camera viewport rect as 0.5 and 0.5
now whenever the size of the display changes like from 1920x1080 to 1200 x 600
i want the rect to change its size to match the change in display
much like how UI does it
only want 1 camera to take the entire view
and other to take a small space in the view
so, if I have a 1080p screen, but set the res to 720p, you want the width and height to become smaller?
yes
now you got it
thanks god
this should be really easy with some simple math no?
Let's presume 1920x1080
we then go to
1200 x 600
Let's presume 0x0 would mean 0 width and 0 height.
Let's also presume 1920x1080 is the max resolution.
We just take
height = 1200 / 1920 = 0.625
width = 600 / 1080 = 0.555...
We then get the ratio of the new resolution.
This should scale it accordingly.
ur a genius
thanks for help
i failed in maths
hahah, alrighty. Good luck with your stuff.
also one more crucial stuff to ask
the width reduces itself to the left and the height reduces itself to the bottom
so whenever i will reduce the width and height it will be reduced towards the down left corner of the screen
you want to centre it?
is there a way to do it in the centre
yes
yeah, sure. I messed around with it now and found:
(1 - (multiplier))/2
you would need to move whatever you want centered by a certain amount every time you upscale or downscale
yes
but calculation is what i suck at
sadly i failed in maths

basically, if we take the example from before, to centre we would:
height = 1200 / 1920 = 0.625
width = 600 / 1080 = 0.555...
x = (1 - 0.555)/2
y = (1 - 0.625)/2
Just take whatever ratio.
how do you know all this?
hahah
school

well - doing lots of small math stuff in Unity.
sweet
You'll start getting this pretty soon too, no problem I'm sure :)
thanks
Uhh anybody know the best place to get started with C#?
I have unity installed and everything
there are many
tho learning C# in itself is way more easier than C++
but if you wanna learn Unity API then it might take you some time to get there
you can learn C# in many ways, either by using documentation or using a Csharp learning site like
https://dotnet.microsoft.com/en-us/learn/csharp
and if you want to learn unity best you !learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
Ok thanks!
me, personally. I suggest starting a project for something you really want to make. As soon as you don't know how to do something, look at a tutorial to learn how to do it. Continue this process and you'll learn.
you'll also learn that there are many different ways to achieve something, and many tutorials are different in their approach. You'll learn your preferred approach, it's drawbacks and when not to use it.
TLDR; if you have something you want to make, start making it.
@chilly vigil "right" for what?
what's your desired behaviour?
https://hatebin.com/uhvmlkkdyn is this code right
did you write this code?
yeah following an photon battle roayale course
i got 7 errors from it.
and what were those errors
"Assets\Scripts\DeathCamera.cs(54,43): error CS0117: 'Transform' does not contain a definition for 'Right'
Assets\Scripts\DeathCamera.cs(54,51): error CS0103: The name 'x' does not exist in the current context
Assets\Scripts\DeathCamera.cs(54,55): error CS0120: An object reference is required for the non-static field, method, or property 'Transform.up'
Assets\Scripts\DeathCamera.cs(54,70): error CS0103: The name 'y' does not exist in the current context
Assets\Scripts\DeathCamera.cs(54,84): error CS0117: 'Transform' does not contain a definition for 'Forward'
Assets\Scripts\DeathCamera.cs(54,104): error CS0117: 'Transform' does not contain a definition for 'Position'
Assets\Scripts\DeathCamera.cs(45,19): warning CS0219: The variable 'Y' is assigned but its value is never used
Assets\Scripts\DeathCamera.cs(54,116): error CS0165: Use of unassigned local variable 'Direction' " these i forget to refine some stuff
well you are not using X Z or Y, you need to use them and assign them at the top of your script, so your script can actually see it
and you capitilized the T in transform
you should configure your !ide
If your IDE is not autocompleting code
or underlining errors, please configure it.
Select one:
•
Visual Studio (Installed via Unity Hub)
•
Visual Studio (Installed manually)
•
VS Code
•
JetBrains Rider
• :question: Other/None
Hey everyone!
I’m having a problem with my Unity3D game. The game view shows up completely white before I click "Play." Also, I can’t set up the UI properly since everything appears white in the editor too.
Does anyone know how to fix this? Thanks!
All UI prefabs are white.
A UI element might be covering the entirety of the viewport here
Make sure you positioned them correctly (the Canvas is huge compared to your world objects - 1 unit = 1 pixel)
All of my UI prefabs are white, but they render correctly only after I click 'Play.
Disable all objects except the Camera and play. Then, enable them one by one until your view goes white again. The object you just enabled is the one causing it
Thanks for the help!
hey! ive got a quick question whats the easiest way to make something change when we increase the float ex. position
so when we increase the float the position is changed by 1
Make the float a property, and in the setter, change whatever else you need to change
https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/properties
thanks ill check it out
Quick question for a scrollview - I have a bunch of objects inside a scroll view, and it works with the mask np, but as soon as I add an on click event to the objects, it no longer scrolls. What is the way to allow for interaction with the objects, but with the scrollview still working?
ive got it to work and i can imagine it being rlly usefull in the future thx again!
This is a known issue. Idr the solution but if you google it you should find some discussion threads and a solution
I had to remove the event trigger entirely and use:
public void OnPointerClick(PointerEventData eventData)
{
// Handle click event
Debug.Log("Clicked on object");
var ProfileController = GetComponent<ProfileController>();
ProfileController.ClickAvatar();
}
I NEED HELP when i code on like the text tht sould have collors dont have and its just text
!ide, this could also be from you just opening the script and you needing to wait for it to do its thing
If your IDE is not autocompleting code
or underlining errors, please configure it.
Select one:
•
Visual Studio (Installed via Unity Hub)
•
Visual Studio (Installed manually)
•
VS Code
•
JetBrains Rider
• :question: Other/None
if your ide is not autocompleting or underlining errors, configure it
we would need more context but this is what im suggesting from what you are saying
Guys i need help, i'm making a mobile game but the Drag Controller doesn't work really fine, it does what it's supposed to do (so aiming) but it's ambiguous. Can someone help me solve my problem if i share a clip and the code?
ima try ty mate
why didnt you include code and video when you asked?
we would need that to help
Yes u right but sometimes no one response even if i submit a video and code
I send you the vid
you need to submit code and anything else to help us understand your issue, people dont answer either because they dont know or because they are doing something else
wait i think i got it
you didnt say anything about visual scripting and im not sure that link would fix it, it might but have no idea
when i instaled i didnt choose the unit stuff
This is the game, basically what i want the "drag-line" to do, is that: 1. Stay stick in the player view without going out the scene when the player's moving, 2. The movement of the player while aiming doesn't affect the aiming direction of the drag-line
I hope i've been claire
It's been a while that i'm trying to fix this now i send the PlayerController script
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
ITS WORKINGGGGGGGGGGGGGGG
YESSSSSSSSS
NOW I JUST NEED TO WATCH THIS 8H TUTORIAL OF PROGRAM
you just need to have the point from which you start pressing be based on screen-position, not world position.
Ok now i try
all i would do is add the players position as an offset to the drag line so the "drag-line" can stick with the player, and im not sure what you mean by your second point
Vector3 MousePosition { get { Vector3 pos = mainCamera.**ScreenToWorldPoint**(Input.mousePosition); pos.z = 0; return pos; } }
I need to change ScreenToWorldPoint?
Ok thank you now i try this
With the second point it's more complicate to explain what the problem is, but basically i don't want that the player movement affects the modifiyng of the drag line points position
from what im seeing in the video, I dont see that happening it looks normal to me
what chat to do i go to for unity cloud help? I don't want to accidentally speak in the wrong chat
Btw with that you mean i need to make 2 variables that store a Vector3, one from the distance of the startPoint and one from the lastPoint, so (playerPosition - startP/lastP) and then add them to the SetPosition function of the lineR?
This doesn't work but i will try the other method
It will work if you want it to only be based on your finger movement, ignoring the movement of the player in the game.
you just get your position where you place the linerenderer and add it to your players position, and put that in Update() so it moves while the player is moving
OK 👍
this is the link for the code: https://hastebin.com/share/ozorizijeh.csharp so I added the appear and move and disappear thing (picture).. But I think it might have gone wrong there because I tried to change it, but still nothing😭 @hexed terrace
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
how can i make Time.timeScale = 0; run instantly
cause it runs after the next frame
It does run instantly. Time.deltaTime has already been computed
Could you not just check if the timescale is 0 in that coroutine?
And use WaitUntil
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
my problem is that when my inventory is open and i press escape
it closes the inventory and opens the pause menu straight away
the CloseInventory sets the isOpen = false;
how do i make it so that the menu doesnt open straight away?
that would be the script execution order right?
u can see at the end when i have my inventory open and press escape to close it
the pause menu opens straight after closing the inventory
i guess the pause menu script runs after the inventory manager
Is there a way to get which object triggered a function through an event wrapper?
you would have to pass the gameobject as an event parameter or create a struct to hold event-related information (which would include the gameobject reference) and pass that
Sometimes you just need to go back to an older version and rebuild what you were trying to do. Still I'm a bit frustrated coming back to a project and still somehow struggling with a state machine. This being despite a lot of research on getting it to work.
Like I'm wondering if I just build it from scratch? The state machine itself hasn't been the problem but rather implementing it with the player script I have.
No questions for now mostly just blabbing.
rebuilding features from scratch is a large part of learning quickly
Can you make gravity go around a certain point? Like a ring but while walking around the edge you're pulled down by the same amount.
Yeah if you mean the EventTrigger component, that makes sense because that component subscribes to all the events automatically
You can do anything you want with the rug code
Gravity is just AddForce but down. If you gravity to be in a direction other than "down" you can disable the built-in gravity and addforce in your chosen direction instead
i switched from GetAxisRaw to having each key for different direction
the GetAxisRaw was canceling the input if both keys were pressed
Does anyone know why "Pluto_Hit" isn't transitioning back to "Pluto_Idle" immediately after finishing? It doesn't play through the animation either it just continuously replays it as long as the bool "IsHit" is active and I don't know how to change that since making it false would immediately set it to "Pluto_Idle"
for example if u were walking left and right
it would be 0
but with how i did it it doesnt do that, any way to make it cancel each other out?
hey guys!
can someone tell me why my vehicle seemingly casts an enormous round shadow? and why its topside is not lit?
even a cube is casting this shadow
Hard to tell what's going on from these screenshots
i mean it works
but im not sure this is the most efficient way of doing this
just add the numbers instead of manually checking each combination
y = 0f;
if (upPressed)
y += 1f;
if (downPressed)
y -= 1f;
if both are pressed, they will cancel out
alright
when my inventory is open, and i press escape it closes the inventory and immediately opens the pause menu
Inventory.cs if(Input.GetKeyDown(KeyCode.Escape) && isOpen) { isOpen = false; }
Menu.cs if(Input.GetKeyDown(KeyCode.Escape) && !Inventory.Instance.isOpen) { gamePaused = true }
is that because of the order of execution?
the menu script running after inventory
put it as an else if
then put it in the same script
im not gonna put the menu logic in my inventory script
that doesnt make any sense
its already over 800 lines
jumbling more shit together will fix it but complicate everything further
in the video u can see i had my inventory open and then pressed escape
and it closed the inventory and opened the pause menu straight away
which isnt what i want
just that one line
not the whole menu logic
yes
should i change it in the project settings?
some people told me the order of execution should be the last thing to do
you can if you want, the pause menu would need to run first
yeah generally people don't like it because it's not obvious
if you put these two in the same script with a reference your problem is gone
im not mixing these two
its gonna get too confusing later on
you should probably instead make a new script that manages the opening and closing of GUI, or create a system for handling how your inputs are received. For example, Unity does something for their GUI where they "consume" events. So, you could do something similar and have an "escape pressed" boolean somewhere in a script that gets set to true when you press escape, then when the inventory closing checks that boolean and decides to close, it would "consume" the event and set the boolean to false so that the pause menu can't use it
and this is old code dont ask why im checking else if(isOpen)
cause it doesnt make sense lmao
no I'm saying set isOpen and gamePaused in the same script
i just slapped it there
in the long run i will probably look into it
making a seperate script to handle it
but for now it works
How do i learn things? Im gettting to a point where I dont know what I dont know how do I learn things? Also whats the best way to refrence a component on a prefab in a script on the same prefab
getcomponent can do such, and for the learning part. what dont you know?
whats hard about learning?
Regarding learning, this is a very vague question. But if you have all the basics covered, you just learn from experience and research whatever you need on the go.
As for the latter, serialized field is the preferable option imho.
oh if you mean like assigning a variable that being a script or a rigidbody, then use [SerializedField] 💯
i mean getcomponent can do that but i wouldnt for something as simple as such
Also avoid cross posting...
does anything like Toint exist in C#? im making another variable for vector3.distance every time i want to convert it's float to an int, unless thats the only way
Mathf has various methods to do that but why are you converting the distance to an int?
for an A* algorithm, but mathf has things like that?
A* doesn't require conversion to int.
I assume you mean for the heuristic function?
The heuristic score can be a float
But are you sure you want to use the "as the crow flies" distance for a*?
You should probably be using Manhattan distance
Depending on how your thing moves
If it can't move diagonally, you want Manhattan distance
Anyone knows why GetMouseButtonDown(1) wont work when i press right click? When i try it with (0) it does with the left one
its in 3d which is a little harder
And you should be using a Vector2Int for the coordinates anyway
Not really it's basically all the same. Is it a 3D grid?
Just use Vector3Int coordinates
i would use manhattan distance but i dont currently have a procedural grid 😅
And 3D Manhattan distance
Is it grid based or not
yes
So then you have a grid
And should be using grid coordinates
As for conversion to/from world space position, use Unity's built in Grid component
It has everything you need
what function is this in?
void OnMouseDown()
0 is indeed left click
1 is right click
put it in update dirctly and see what happens
You could use IPointerDownHandler. It includes the mouse button that was used in the parameter instead of doing extra update checks
unitys grid component you say? ill check it out. im guessing i need to get the distance between 2 points using that?
instead of just measuring distance using vector3.distance
No you just use it to convert between world space and grid space coordinates
You get the distance between two grid coordinates using Manhattan distance
Taxicab geometry or Manhattan geometry is geometry where the familiar Euclidean distance is ignored, and the distance between two points is instead defined to be the sum of the absolute differences of their respective Cartesian coordinates, a distance function (or metric) called the taxicab distance, Manhattan distance, or city block distance. T...
Thats the problem I dont know what I dont know so I cant learn. Is there somewhere I can go to learn new these for certain usecases
the documentation, and us and the internet
depends on what you need to learn, imo it looks like you are burnt out
been there done that
I think what Im missing is proper resources to research with. Any recomendations?
ah okay thanks brother! 😁
Lol that should work
Unity docs help me a lot with stuff I know thats good and I try not to ask too much in here just when Im completely stuck
if you need help, dont feel like you cant ask
Google these use cases and see how people handle them. Or ask here. There's not much more to it.
thats literally why we are here
to help people
I try not to depend on you guys kinda like tutorial hell. Asking nice people on discord hell lol.
i wouldnt say your relying on us, what i would say is you gaining more knowledge and wisdom for coding than you would by yourself
this is exactly why teachers exist, to teach others so they can be comfortable and know the current subject
and so that their students can pass on that wisdom to others, and so on and so fourth
{
/*foreach (Scene S in destroyQueue)
{
SceneManager.UnloadSceneAsync(S);
}
destroyQueue.Clear();*/
SceneManager.UnloadSceneAsync(SceneManager.GetSceneAt(player.GetComponent<CharacterMovement>().currentScene - 1));
GH.Solidify();
}```
ignore the commented code but im using this function to unload loaded scenes however when i get to the 2nd scene and unload the first one it works good but then when i get to the 3rd scene and try to unload the 2nd it doesnt work because it tries to unload scene 1 and not scene 0 however in my build manager that scene is set at scene 1 so I dont really understand why that wouldnt work
Did you actually debug the values?
yeah i was watching the variable in editor it was 2 when the function was called so with - 1 it should equals 1 however it was destroying the scene that is labled as 2 in the build profile
so unless it works as the number relative to how many scenes are actually loaded
but i feel like it shouldnt
It is. Did you read the docs?
so then whats the point of the number in build profile
public static AsyncOperation UnloadSceneAsync(int sceneBuildIndex);
yeah look this says it shod be
oh wait
its cause im using get scene at
isnt it
Yes
I want to make a helper class. It would contain data structures and functions I find myself using a lot in the project. However, these data structures and functions use some of Unity's own data structures and functions that come from monobehaviour. If I make the class extend monobehaviour, don't I need this helper class be a component on a game object in order for it to do anything? I'd rather not have it like that. I'd rather it act more more like how a public static class that doesn't extend monobehaviour acts, in that you don't need it to be a component on anything. Any ideas?
Just dont make its class a monobehaviour and make it static if you want. It's not really clear what the problem is here
you have many functions in unity that are static, they can be used outside of MBs
as long as they are kept on the main thread
Hmmm. There might not be actually lol.
I think I'm misremembering the last time I did something like this. iirc, I tried using start and update functions within a public static class that didn't extend monobehaviour.
All I want to do though is add some of my own data structures and associated functions, so yeah, nevermind XD
start and update are functions called on your components by unity. they arent a c# feature
start and update are literally MB functions
https://paste.ofcode.org/QzG9GLSp2KQf3cdPsyKsr7
This is the greatest thing ive ever written
these are inherited from MB? or Using systems or collections ?
none of those. using systems or collections in your code wouldnt call any methods in your code, and i said "they arent a c# feature". its not inherited either, unity calls it via reflection
I made a custom grid, however I want the grid to automatically be created/updated in a similar vein as the built in unity grid. So, in other words, as values are changed, I want to create the grid and draw the gizmos needed to represent the grid, all in editor. Do I use OnValidate for that or something else?
{
comboNum = 1;
} else
{
comboNum++;
comboResetTime = Time.deltaTime + 2.5f / 3f;
}```
Hey I wrote this code for a combo system for pretty much if too much time has passed itll reset the combo number back to 1 or if its at 5 hit already but im actually really confused on how it works if smb can explain in like simple terms 😭
Code runs top to bottom, one line at a time. An if statement checks if the thing inside of it evaluates to true. If it does, it runs the code inside the condition. Otherwise, it runs the code inside the else condition.
|| means OR. It will return true if either side is true. So, if Time.time - comboResetTime > nextAttackTime, or if comboNum is 5, it will set comboNum to 1. Otherwise, it'll add one to comboNum and set comboResetTime to a new value. Time.deltaTime is the amount of time in seconds since the last frame ran (it is basically "Seconds per frame"), plus the constant 2.5 / 3 (which is roughly 0.8333.
Doesn't Time.time get higher and higher over time so eventually itll outgrow the -comboResetTime correct? Theres nothing stopping it from resetting afterward
Time.time is the amount of time in seconds since the game began
hello guys im doing roll a ball tutorial rn to familarize myself with unity. im on the part where you add the enemy to chase player using nav mesh but for some reason, the enemy player just circles around the player and has some irregular movement, and only moves when the player moves
So eventually no matter how big comboResetTime is wont time always be bigger than nextAttackTime After a certain point?
You are checking if the current game clock, minus comboResetTime is greater than nextAttackTime
Nothing here changes nextAttackTime, and there's no information as to what that is
so that's all I can say about it
You probably want to check the elapsed time instead cs var current = Time.time - previous; if (current > reset) { ... previous = Time.time; }
nextAttackTIme is hardcapped at 3 it doesnt change so if the game is 15 seconds in with time.time = 15, next attack time is 3 how is comboResetTime bringing time.time down below 3
I apologize it does work for sure Im just very confused on how combo resettime works as time.deltatime is able to generate such a high number thats able to bring down time.time below it when its clicked right after another
If it's always 3, then after about 4 seconds, Time.time - comboResetTime is always going to be greater than nextAttackTime. Unless your framerate is really really bad
Thats what Im saying but somehow I even waited a full minute before checking again and it was still able to reset back to one if the pause was tooo long
Try logging all of the relevant values
Time.time, comboResetTime, and nextAttackTime
Oh, edited the message. Previous should be the current time stamp.
comboResetTime = Time.deltaTime + 2.5f / 3f doesn't feel right as it's some tiny delta whereas Time.time would be the total play time thereon and subtracting it by the reset time would just yield an infinitely growing value.
Alright so I figured it out after logging their was code later in the function that was for something else that added the delay that made nextAttackTime == time.time but + 1 pretty much so everytime it checked it made sure you waited 1 extra second before resetting the comboNum = 1
Yeah its the extra part that pretty much says nextAttackTime = Time.time + 1f/3f that way when comboResetTime checks by subtracting it takes off more time that it gained which allows it to be under the nextAttackTime
I'd throw in a few more Debugs, like an Awake Done to make sure that Awake is not finishing. It Should be finishing before the other stages (unless i got my order confused) -- Oh, i see what you are saying now.. Ok, i will leave it to those who know more than me
may I ask, since im planning to make an array that lists all the detected viruses. I am planning to make a sorter for the tower that makes them choose between the viruses, like the one with the lowest health, the nearest, the one with the highest health and the furthest away.
since this only list one virus/enemy, it's not really efficient as a player to only target one virus
Which version of the engine are you on?
shoot. so not some odd 6 bug.
Why don't you share your code again here, so others can see. (this is beyond my understanding as to why)
Cool., that should be enough for someone who understands it to help
Hey
Anyone knows how do i get a variable value from script A to script B through an event?
public static event Action<string> OnAxisClicked;
// Start is called before the first frame update
public string gameObjectName;
private void Awake()
{
gameObjectName = gameObject.name;
}
public void SelectAxis()
{
OnAxisClicked?.Invoke(gameObjectName);
}
}
^ i have this code on what i want to trigger the event
private void Awake()
{
PositionAxisHandle.OnAxisClicked += SelectAxis();
}
private void SelectAxis()
{
Debug.Log("CLICKED THIS BULLSHIT:" + gameObjectNameShouldGoHere);
}
}
and this on the object i want to print the name from
but i don't know how i'd go about sending gameObjectName from the first script to the second
Select axis should take an argument of type string?
private void SelectAxis(string gameObjectNameShouldGoHere)
{
Debug.Log("CLICKED THIS BULLSHIT:" + gameObjectNameShouldGoHere);
}```
That works
Just so i understand
That mean that when i call a method through an event
That method's arguments are going to be automatically taken from the event dispatcher?
What if i have, let's say, one string argument and one int argument on the event but the function i'm trying to trigger only takes a string argument?
Your action expects a function with a parameter of type string event Action<string> OnAxisClicked thus your function should have a parameter of type string void SelectAxis(string gameObjectNameShouldGoHere)
(str, _) => SelectAxis(str)
While on the topic of events,
Is there an event listener of some kind?
Let's say i wanna figure out what's triggering and being triggered from a specific script
is there a way to do that besides going through god knows how many scripts?
Events are pretty nasty when it come to debugging tbh
Place breakpoints and see the callstack when they're triggered.
Begin with reading and understanding the code.
At least the relevant one to your issue.
bump on this, the enemy still just circles around my player object when i move and never moves on its own
hey, sorry im quite new to unity so...
i downloaded Assets from the unity Store but when the show up in my Projekt they are just pink
this isnt a coding question + lookup pink materials unity on google
sorry my bad
Is there a way for the game to differentiate a tap and a hold on the ui canvas? I am using 2022.3.37 and i was thinking abot checking duration to do it but its not working in this version. Is there an easier way I overlooked?
If you still look for help, you should share more info.
I'm raycasting a ui canvas into a 3d space in order to basically do fruit ninja with an orthographic camera. It all works fine. But a tap and a slash is indistinguishable
You'll need to implement it yourself.
I'm trying to I'm just not great with unity. Can you point me in the right direction of the documentation. I do have the new input system working with the game as well
In terms of unity API all you need is just checking the touch input.
The logic of the tap vs hold is up to you.
Is it true in Version 2022.3 that the duration function is iffy
What duration function?
*Method btw. In C# it's it's methods, not functions.
is my x positive on the right or the left here?
the right is X+, no? it's odd.. in blender I have the arrow point to X+ but in unity it's inverted appearently?
and also, I'm absolutely freaking out with the controls in this.. when I hold RMB to fly around the scene, the X control is inverted but Y is not.. can I change this? I always look the wrong direction, it's frying my brain
someone has a project that when you click a button it will play an ad?
based on this, you're upside down. which i think would explain the inversion on your controls as well
daaamn, you're right! thanks so much! :D
np!
I have another question: out of curiosity I wanted to look at visual scripting and now it's giving me errors and I think I enabled something I don't really need. can I completely turn that off?
yes, remove the visual scripting package
how do I do that?
yeah, just Window>Package Manager and you can remove it. it's outdated/abandoned more or less, depending on which version you use (not that it was ever really great in the first place honestly)
like you would remove any package. The package manager
im new so I didn't know how to do it
thanks to both of you though, I removed it
someone?
Debug.DrawRay(ray.origin, ray.direction * 100, Color.red);
why can't I see this one?
no one is really going to have a project that you can just download that has that functionality only, you're better off just learning how to do it on your own (this is a channel for coding concepts, which isn't really something that'd cover a goal as vague as that, i think)
every time i try to make this project it show me this error Assets\NewBehaviourScript.cs(5,106): error CS0535: 'NewBehaviourScript' does not implement interface member 'IUnityAdsShowListener.OnUnityAdsShowClick(string)'
try checking the "gizmos" button in the top right of the scene viewport, that's usually the culprit. if it's not that, not sure
hm.. does it even work in play mode?
it should work in both modes, as long as the gizmos view is enabled
ah, it's a different button when play is active, now I see it, thanks!
np! also i checked the docs since it had been a while, if you're not doing that every frame (inside Update or FixedUpdate) then you may have to set the duration. it's set to draw only for one frame by default, so that may be why it isn't showing up in play mode if you're only calling it one time
👍
hi! could anyone tell me what Debug.log() is used for?
it's used so you can debug your code
Not without your !code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
Your syntax is wrong, that's all that can be said
those mean you have syntax errors in your code. your ide should be highlighting them if not configure it using !ide
If your IDE is not autocompleting code
or underlining errors, please configure it.
Select one:
•
Visual Studio (Installed via Unity Hub)
•
Visual Studio (Installed manually)
•
VS Code
•
JetBrains Rider
• :question: Other/None
you do not even have a solution open there
Hey guys! What's going on?
Where can I ask about textures for materials?
it depends on what kind of question, but probably #🔀┃art-asset-workflow
Maybe #🔀┃art-asset-workflow
I am trying to make a simple unity ads project and i keep getting this error Assets\AdManager.cs(5,41): error CS0246: The type or namespace name 'IUnityAdsListener' could not be found (are you missing a using directive or an assembly reference?)
I bought a pack in the asset store.
I have HDRP rendering.
There was a problem: Materials for houses flew off. However, this can still be fixed.
Another thing is the grass that goes through the "Terrain" and how to put the material, I do not know
we do not provide support for 3rd party assets, contact the asset publisher
how to compile c# code in vsc ?
you mean using it for other than Unity?
like to compile and run standalone c#?
If you have a question, just ask it. Don't ping a specific person
https://dotnet.microsoft.com/en-us/learn/dotnet/hello-world-tutorial/install found this website..
sorry, he was the one who recommended me the code so I figured it would be the best to ask from him too
can I make the target an array instead of a single value and the turrets to have a sorter to differentiate which target to shoot first
you can do anything u can imagine
absolutely..
using for loops to loop thru and do comparisons or w/e
yeah, that's normal . . .
You guys watch me take three days to read the documentation and come back here asking again HAHAHAHAHAHA
anyways thanks guys
Generally everybody here is experienced enough to answer your question
Hello, currently working on an inventory system for my game. The approach I am thinking about going for is having an object the item data of a some container (for example a chest) aswell as the size of the inventory grid. What I am not sure is how to go about generating the actual UI. As I heard that working with UI is pretty slow. My idea was to generate the grid and the items inside the container whenever the player opened the chest. But I was also thinking if I should rather make a prefab for the UI that is just spawned and then the items are added. (this would mean I dont have to generate the grid each time I open the container)
for ur own good kinda thing
this is a good method imo.. have ur prefab w/ everything set up.. a placeholder icon, placeholder text or w/e
then when u instantiate ur actual object.. use its data (via a scriptable object or however u decide) and populate those variables
since I'm planning to use this same block of codes, how can I apply it to instantiated game objects?
use a function that takes in the gameobject or w/e script they have that ur trying to modify
public void SpawnAlpha()
{
currentTank = Instantiate(typeAlpha[Random.Range(0, typeAlpha.Length)], transform.position, Quaternion.identity).GetComponent<Tank>();
DoSomethingToPrefab(currentTank); // <-- like here
}
void DoSomethingToPrefab(Tank tankToUse)
{
tankToUse.DoSomething();
}```
unless im confusing what ur trying to do
which i probably am.. as i dont have much details to go off of (haven't been following the conversation)
i mean whats wrong with this?
Where can I share my screen lol
not in this server unfortunately..
oof
record a video short
okay i'll try
you should create the materials yourself and assign the textures to them. you also should've checked if the asset supports HDRP
sorry i fell asleep
idk one of my programmers said that the duration method of differentiating is iffy in the unity version
needs to be embeded
nvm
that works
Amigos
Haven't unityied in like a year until recently out of being forced. (School) only unreal. Question regarding unity asset creation. In unreal for "prefabs" I can make my c++ class (essentially game object class or component), and then create BP (prefab) from class, which automatically sets up all the components of the prefab, etc to expedite the creation. What I've seen so far is in unity you don't use constructors, have to make a game object in world, set it up manually, and then create prefab. Is that true?
Tldr lol
That's the typical workflow, yep
I'm not sure it's faster not to be able to visually see what you're setting up before creating a prefab. 🤷♂️
Let code do it for me.
you can add components using code but thats more labor then just setting it up
i see no issue with setting it up manually
What's your actual usecase in Unity?
Oh it was just for setting up objects. Was curious of workflow. Like I said. Unreal I do this
So before I even get in client everything is setup lol
Right, I suppose that's one way to do it
And can adjust base class
Does none of unity use constructors? Or just monobehaviors
Well.. I guess mono is main world object lmak
Monobehaviours don't use constructors no. Only plain C# scripts.
Ahh
Okay so tldr is, unity is setup object manually.
Minus script that can add vars/affect components
Unless you want to do it all at runtime, but then you lose the benefit of actually visualizing your work / quick tweaking in editor.
Which still needs script machine manually added
Ah so that just creates it in world?
Not actual prefab asset
Yep
If you want to create a class that creates an object, dresses it up and initializes it, kind of what you're doing in your Unreal example.
But that's going to not be any faster, that's for sure.
That doesn't make much sense.
can anyone help me fix my code?
!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 #854851968446365696
Ok Im trying to make it so when you click left mouse button your ability will shoot the way your facing. Then go on cooldown for how ever much attack speed is, which at base is 3. I got everything working except cooldown How do i fix it!
When you shoot, record the time with Time.time and add your cooldown seconds, into a variable. Then add a condition to that outer if statement that checks that Time.time > _timeAfterCooldown
or you can invoke a function or use a coroutine
ok so how could i do that. give an example.
I tried.
where?
I removed it because it did not work.
Coroutines are more complex and would require a bunch of changes in your current code
Adding a variable and a condition is better in your context
As soon as you shoot, so in there yes
new WaitForSeconds() does nothing if not in a coroutine
ok
i wouldnt say corountines are more complex, its not to hard to make them
so i would do Time.time = attackspeed?
and or use them
In their current code there's more drawbacks than advantages. Again, it requires moving more code around
No, scroll up and check out my examples
You cannot assign a value to Time.time, it's read-only. It gives you the time in seconds since the game started
so I make a float. like, publice float timeaftercooldown = 3f; ?
Yes but you don't store 3 in it. That field represents the time at which you'll be able to shoot again
Put the actual cooldown delay in another variable
private float _timeAfterCooldown;
public float _cooldown; // set to 3 in the Inspector
When you shoot put the result of Time.time + _cooldown inside _timeAfterCooldown
like this? _timeaftercd = Time.time + _cooldown;
Correct
and it should work?
Not until you add the part in the if statement that actually compares the variable with Time.time again, to check whether time has moved on enough for it to be greater than your variable
well how would i do that?
I told you, in text form
Translate to code
You can combine two conditions in the if statement with && to make the if statement run only if both conditions are truthy
Which one is a better idea: changing the sprite of an image or having image childrens and setting them active/inactive? (For only 2 sprites, therefore only 2 children)
I would put the conditions at the end of the shoot
No in the if at the top
which one?
"If I left click AND that time has advanced enough for me to shoot"
I'd use the former, since all references would be grouped into a single script. That way, no need to expand the object's children and select them to change the image
so like this?
The script can be made more versatile by using an array instead of multiple fields
You ignored the &&, but that works
Do i need to add &&
if (... && Time.time > _timeAftercd)
Its saying error
Post said error
you need to revise this code and put {} properly
it has error lines on the dots and &&
You're taking things way too literally lol
The dots mean "the left mouse input detection that was there before"
sorry
when modeling something for unity in blender, how do I work this x/y/z thing?
should I model it so that X is the front of my tank for example?
then how do I export/import it so that it fits in unity?
It works!
Not a code question
Model as is in Blender (ie Z-up), you can change the axes in the export settings so they fit Unity's setup
where should I ask and what do I set in the export setting exactly?
#💻┃unity-talk, Google has plenty of resources available
on that same code.. I have it so the abilty clones the game object that is the ablity. but I want them to despawn after 3 seconds. how could I do that?
Is there a way to access an event parameter within the AddListener function?
int MyInt;
UnityEvent MyEvent;
MyEvent.AddListener(delegate { MyInt = [intValueHere?]; });
or to much to ask for?
Use Destroy(obj, delayInSeconds) to schedule an object for destruction
and to not take literal the delayinseconds I would put how many seconds till destroy so like 3?
Use UnityEvent<int> and a lambda expression instead of that old delegate syntax and you'll be able to access it: myEvent.AddListener(val => MyInt = val);
You'll be able to set the integer you want to pass from the Inspector.
Or, when invoking it from code!
Yup correct
You also need the object to destroy in a variable (denoted by the obj here)
yea i did
Do not give it skillg! It's the original. Get the clone from Instantiate:
GameObject clone = Instantiate(skillg, ...);
Instantiate returns the object it just created
ok
Excellent, thank you!
Hi i am trying to make a simple unity ads project and i keep getting this error Assets\AdManager.cs(5,41): error CS0246: The type or namespace name 'IUnityAdsListener' could not be found (are you missing a using directive or an assembly reference?)
Have you imported the package and added the required using directives at the top?
are you missing a using directive or an assembly reference?
i dont know
Head to the Package Manager to find out!
what now?
Ensure that the ads package is installed
is it ok if i send a video of what is happening?
i have Advertisement Legacy installd
That might not be the correct one. I think it's named just "Advertisement"
Legacy denotes an older package that's probably deprecated
where i can find the Advertisement package?
i dont see it
If it's not listed, click the "In Project" dropdown at the top and switch to the "Repository" section
i dont have it
i still dont find the Advertisement
Which Unity version are you on?
2022.3.11f1
That might be why. Keep the legacy one and make sure you have using UnityEngine.Advertisements; at the top of the script you need to import the ads stuff
i have using UnityEngine.Advertisements; in my script
What issue?
when the code clones when I click the sprite is not there. It enabled and on the clonede object
it's Z pos is a minus, it's probably behind everything. Don't give it a minus Z pos.
how?
unity doesn't have a global Y kill plane, right? I must check the Y of the object during Update? 🤔
What is skill1g.transform.position .. as that is where it's getting the position from. Either change that position in the inspector, or set the Z pos to 0 in code before instantiation
ok
when i tried clone.transform.position.z = -1; it showed the error line
@short hazel
so read the error, understand it, do the fix.
Unavailable, someone else will take the lead
OK
unhelpfull
It will not work i tried moving the object, and tried clone.transform.position.z = -1; but it does not work what do i do
could someone help me?
I'm just relaying. We are all kinda new with unity. We mostly know unreal. Also most of our code is visual scripting
What is "The duration method of differentiating". That doesn't really mean anything
If you're just relaying someone's question, maybe they should come ask it so they can actually provide context
Unless you actually say what the error is, no one can give you any further information than that
when i use Debug.Log it doesnt log anything to the console is there away to fix this?
Either you've hidden messages in the console or that line isn't actually running
does i have to drag the C# Script somewhere?
If you want the code to run it does need to exist
i have it made just nothing pops up in the console
What function is the log in
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
Debug.Log("Jump");
}
}
}
Okay, is the object this script is on active in the scene, and are you hitting space?
Hi, really need help with my project. Im trying to get an objec to collide with the ground but when trying to add a "Ground" layer to my platforms, I am given an empty window. I cannot add a layer
yes i have the Player as a Circile and i press Space
Show the inspector of the player object
Something's gone wrong with the internal editor code.
First step, try window -> reset layout. If that doesn't work, restart unity. If that doesn't work, close unity, delete your Library folder and re-open. If that doesn'twork, reinstall this version of Unity.
I tried restarting unity and resetting layout already
Ill try deleting the library folder
You don't seem to have instantiated the Player object within the code that is responsible for collision
im sorry im new i dont really understand
Regardless, this should definitely have stuff in that window
What does this mean? this is my first time programming objects like this
That or you're just referencing the object oddly
Deleting the library folder did not work either
Okay, so the player script is attached. Hit play, press space, show a screenshot of your console
The errors in the console are in Unity's internal code and have nothing to do with the scripts in this project
It's some sort of editor corruption if the library clear didn't fix it. Might need to reinstall
i press space about 6times
It gives me that error every time I try to add a layer
This is a C# coding error
My object moves, it just falls right through my platform since I havent added a grounded layer which I cant do
The compiler is not happy with what you wrote
Show the full !code of the player script
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
Do you want me to show you my code?
No, it isn't
and no, it's not
- It's not a compile error
- It's not in any of the code they wrote, it's in Unity's rendering script
My code runs fine for the record - as I said, it falls through my platforms as I cant add a ground layer. I have no compiler issues
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
Debug.Log("Jump");
}
}
}
You can ignore the other guy, he doesn't seem to actually be reading the source of the error. It has nothing to do with your code, unless you've written a function with this name:
Okay, so it's not a nested function or anything. Try putting a log in Start
Here is my code just in case ive done something wrong.
Im just adding basic player movement
The only thing that is wrong to my knowledge is just letting me add a ground layer
I just get an empty window
Yeah, runtime code wouldn't affect the rendering of any editor windows. Unless you've written editor scripts that override this function, or have a plugin/asset that does, it's probably a corrupt install
Hmm okay, Ive restarted, deleted the library folder, and reset my windows
I suppose all thats left is reinstalling unity?
If you don't want to reinstall yet, make a new project with nothing in it and see if you can add a layer there
Sure ill give that a shot
If it's working there, then you might have a plugin or asset causing problems
if it's still broken, reinstall would probably be the fix
I havent imported any assets or plugins. Ive only used built in functions and 2d objects like squares
Yes it works on another plugin
very strange
so it logged
{
Debug.Log("Start was called.");
}
just not spacebar
You're looking at the wrong snippet
Another project, I meant
This is the important bit
It worked on another unity project
That's literally the same snippet
Adding a layer, I mean
what algorithm does the Unity auto sprite slicer use?
Unless they wrote that GetMaxRenderingLayersFromSettings function in the UnityEditor.Rendering.RenderPipelineEditorUtility, this has nothing to do with their code
A null reference does not come from a corrupt unity install
Yes, it can
and it does
when it is in Unity's code
It just worked on another project in the same unity install, so I dont think my install is corrupt
Somethings wrong with this specific project
I have no idea what
Does anyone know how to fix tools window not pooping up when i add my editor script 😭
I've used this before multiple times and now it just doesn't pop up
Maybe a project configurations thing? The error is in RenderPipelineEditorUtility, are you using URP or built in?
Cross reference your project to see how the object shows up
or configs
- Did you add the menu attribute to the script? Make sure you didn't accidentally name it something else
- Do you have any compile errors, even in other scripts? It won't compile any editor code if anything's failing to compile
What do you mean?
That error only shows up when I click the "Add Layer" button for the record
Pretty sure they're still assuming the problem is in your code somewhere
i get this error when i add it
but it really isn't. The error is unambiguously clear about that.
It's either that or incorrect settings
My code is here if youd like to read it
Nah, that's just a warning, that wouldn't stop it.
Show the !code where you're defining the toolbar and the function to run
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
So what can I do to fix it? As I stated earlier I tested the add layer function on a different project and it worked
Are you using URP or built-in?
If it's URP, maybe you need to update the render pipeline package, or remove and re-add it
Yes, unless you've specifically changed it, it'd be which template you started with
A built-in is what comes out of the box with unity
Okay, so URP (Universal Render Pipeline)
Window -> Packages, find your URP package, and update it if it has one, otherwise remove and reinstall it
Where do I find the package?
I'm unfamiliar with the template names, thought it was called "2D URP"
Check under "In Project", find something with a name along the line of "rendering" or "universal"
Theres nothing under Update, and under In Project I just have Multiplayer Center and 2D Sprite
I found Universal RP under Unity Registry, should I install that?
yeah now its just Universal on the hub 🙄
It's not already installed? That's odd.
I haven't actually installed Unity 6 yet, but I'd assume the template named "Universal" came with URP
Give it a shot, if things break you can always remove it
Sure thing
Im not sure how to remove it but ill cross that bridge when I come to it
Yup that did it
Same button you used to install it. It becomes a remove button once it's already installed
How strange. I wouldve assumed that would come preinstalled with the template
Fixed the problem?
Yes, im able to add a layer now
Thank you very much
Confused how that wasnt already there, but nevertheless glad its fixed
Okay cool.
Gonna chalk that up to pre release quirks
Most likely
normally does, are you sure you didn't click BIRP
Yeah. Seems like a kind of important package to have in the template
Not sure what BIRP stands for, but Im 99% sure I clicked the "2D Universal" template
BuiltInRendererPipeline
Ah, no, I didnt use that one
but yeah if you clicked Universal must be something they def need to fix lol
I think it may be a release issue, I definitely used 2d universal
yeah might be that specific version of the template maybe
My PC still falls through my platforms unfortunately.. not sure whats wrong there
your pc falls through ?
Yeah it doesnt collide with my platforms
you have colliders on both?
Player character presumably. Computers don't tend to phase through desks 
Believe so
also how are you moving the said object
Yes PC is player character, sorry
What do you mean how?
oh lol yeah are you moving transforms maybe
where do i even find that 😭
which component are you moving it by
Wherever you put it.
Okay yeah it colldies now but doesnt move left to right
going to have to at least send code / show setup
Code is here
What else do you need me to show?
ye but what do you want me to send lol
oh okay, I'd first put log inside check if its even running
!ide
If your IDE is not autocompleting code
or underlining errors, please configure it.
Select one:
•
Visual Studio (Installed via Unity Hub)
•
Visual Studio (Installed manually)
•
VS Code
•
JetBrains Rider
• :question: Other/None
How do I do that?
also did you change your speed variable inside inpsector
Debug.Log(horizontal)
Ahh well its initialized with 0
therefore its 0 unless it was changed in inspector / code
Which component is that under
Ah in my code, right
expose it in the inspector to change it there with
[SerializeField] attribute (exposes private fields in the inspector)
Add that line?
if you want to change it via inspector yes you need that attribute for private fields
only public fields are serialized by default in the inspector
I got a compiler error, it says invalid token 'void' in class, record, struct, or interface member declaration
when I added that
where did you add it ?
Under the other seralizefields
the attribute goes above or beside the field declared
So I should put it in front of my privte float = speed line?
Sorry, im really new to this
before private correct
Like this?
why did you write "attribute"
You said [SerializeField] attribute
but I only put the inline code on the attribute 😉
Oh perhaps I took it too literally
so the line should be: [SerializeField] private float speed = 6f;
i have 2 tile maps children of a grid. one is for the background the other is for on top of it. then i change the palette on one it also changes the other is that normal?
thats how you wrote the others, yes 🙂 @river garnet
also your IDE does not look configured
it should've underlined red what you wrote before
How do I configure it properly?
#🖼️┃2d-tools not a code question
I dont see it showing up in the inspector either, the speed variable I mean
did you save ? and make sure you hae no compile errors
follow guide on !ide ⏬
If your IDE is not autocompleting code
or underlining errors, please configure it.
Select one:
•
Visual Studio (Installed via Unity Hub)
•
Visual Studio (Installed manually)
•
VS Code
•
JetBrains Rider
• :question: Other/None
Yeah no compiler errors and saved
show new code you updated
Okay yeah I have all the IDE stuff right
Its at the top
Is it in the wrong spot
looks fine where its at
make sure UNITY console doesn't have compile errors
Nope no compiler issues
Just something about Render Graph API, but its not an error
are your errors collapsed maybe
screenshot console window
try adding the script onto the gameobject again
ahh gotta love unity 6 bugs
now ive lost my jump function hahaha
make sure the layers are correct for the IsGrounded method
I fixed it
also do get your IDE configured
It is
its not
Well I followed that link and I have everything it does
it should not look like that, and it should say Assembly-CSharp at the top
instead of Miscellaneous
when you wrote [SerializeField] attribute private . should've underlined red
I have the Game Development with Unity installed in VS
and my preferences tools have VS as my external script editor
close VS , click Regen Project Files
Where do I find that
supp can anyone help pls? looks like unity dont want to find my serializefield or smthing
preferences external tools
I only see Reset Argument
how can we help without the issue being shown and code shared?
then its not configured correctly lol
wait
was screenshoting mbmb
Hmm okay, Ill reread that article
yes if you already installed via HUB click that link etc
should be only a few steps
Installed VS through unity hub? I didnt do that
I installed VS manually and installed unity hub seperate
oh okay in that case you might need to install the Unity Workload in VS Installer
make sure you do that part via Visual Studio Installer
I dont see that option on the installer, just the game dev with unity
which I already have installed
this one is installed already for your version of VS ?
yup
okay go back to unity Preferences External tools, click the dropdown, show all the options
make sure you see the Visual Studio with the version number
yeah the one that shows up is Microsoft Visual Studio 2022 (internal)
it should not say internal
I think it shows the actual version
Well then how do I fix it?
check real quick inside unity packages In Project
make sure Visual Studio Editor package is there
Hey @river garnet , just a quick recommendation, it's just my opinion so you don't have to comply ,I strongly recommend you to learn c# without unity first , just learn the basics and stuff , once you get the hang of core functionality, it's going to be super easy for you to learn unity API. If you need some resources do let us (or me ) know.
Id love to take my time, however I have to make a functioning game for university within the next 20 weeks so I kinda have to learn through trial and error like this in unity
thats a problem then
you need the Visual Studio Editor package installed
Im normally a level designer
Got it. I found it under unity registry
I installed it
normally it comes with the template idk what hapened there
Well same reason I didnt have the URP either I assume
yeah something went funky with your manifest.json lol
woo!
I thought something was amiss cause it was white code instead of coloured
usually everything has a colour
yeah usually thats a tell tale sign
oh i apologize i was severely sleep deprived ill reword it and get back later. sorry
Understandable, I guess gotta face it then, you'll get the hang of it just keep hammering around, that's a valid path depending on the context actually.
And of course there's still the " but " factor
Yeah I dont mind learning like this. I enjoy coding enough that im willing to do it this way
One other thing you can do is have a complete goal of what type of game do you want to make, once you have a clear vision of requirement, learn specific things you need for it , and again only if you are limited by time.
Its a bit trail by fire but I dont have much of a choice
Yeah thats what im doing, Im going basic 2d platformer for now, so I was trying to get player WASD controls and basic jump functions
Which are working now, so thats nice
True considering 20 weeks time , you'd just rush unintentionally even if you try not to , so do it the way you are more comfortable
Thank you for your offer though, I will 100% be back in here asking for help
Great to hear that.
Asking people live like this is much more healthy sure
Definitely. I tried finding everything on google but my errors were a bit hyperspecific and I didnt really understand
So this is a great resource
Especially considering my universal packages werent installed for whatever reason
Happens to best of us
im sorry i know its not as effective, since its not my question and im merely relaying, "Idk I was trying to make it check how long it's being held down using hold duration but when calling the input using On Input System Event and click Hold on the drop down it fires instantly. I'm not sure how to check the duration or make it wait the duration before registering. Right now it counts as held down instantly, even though the hold duration is set to 1 second by default."
he said this, for context, we are just truggling through unity and dont know the best way to do things, so this methodology might seem convoluted and overly complicated. idk what to do. all we are trying to do is differentiate bwtween a press and drag, and a tap
if you're having trouble with the input system, then check out the documentation pinned in #🖱️┃input-system to learn how it works
Does anyone know how I get text to display on screen in my scene? I have made a timer and im trying to put it in the top right corner
Or how to move it to the right spot rather
your text object should be a child of a canvas, then it's just a simple matter of moving it and anchoring it to the correct position
google how to make a canvas ui
I have this
so, no canvas
this is not a code question. but you can clearly see that it is in the bottom left of the canvas
My bad then ill just google it
consider looking at the documentation pinned in #📲┃ui-ux to learn how the canvas and your ui objects work
but this is literally just a matter of "move it to the top right of the canvas instead of the bottom left"
How can I make CharacterController.SimpleMove() move relative to the Self space instead of World?
It's for a first person controller
pass the direction to Transform.TransformDirection and use the return value of that
Yeah I get that but its like this so thats why im confused
Its okay, wrong channel anyway so its my fault. Ill keep searching
that's not even on the canvas now
The canvas is kinda confusing
you see that big white rectangle that your text object originally started in the center of and now has its bottom left corner near the center of your screenshot? that is the canvas
Are you watching a youtube tutorial? I feel like this is better if you see how it's done
Will these topics help me understand the concept before entering Unity?https://www.youtube.com/watch?v=MDh6wX9T0Ow&list=PL82C6-O4XrHcblXkHA4dLcnb_ipVkKHch
C# Tutorial For Beginners 2024 - 1. Install
Github repo for course: https://github.com/teddysmithdev/CSharpBeginnerCourse2024
Twitter: https://twitter.com/teddysmithdev
Github: https://github.com/teddysmithdev
Linkedin: https://www.linkedin.com/in/teddy-smith-015ba61a3
Yeah I am
I just dont really get it, when they put in the text on the tutorial it immediately just appears on screen
mine isnt doing that
double click the canvas in your hierarchy so you can see it. that represents the entire screen view for the UI
because you do not have your canvas object selected and focused in the scene view
wdym, Unity should just automatically know what I am doing and what I want to do
Alright no need for the condescending remarks, it was just a question. Ill figure it out
from the playlist, yes.. all that stuff
no clue what Records are.. but all that other stuff yea
thank you
that worked thanks. got a bit confused there and tried to call from the Transform class lol
Is there a consensus on how you should move a 2d rigidbody player ?
Should I use AddForce, MovePosition with a kinetic body, velocity, position ?
MovePosition was meant for Kinematics sure, but its weird because the 2D engine gives velocity to kinematic so you can potentially use .velocity too
Hello everyone! I'm an absolute beginner to C# in Unity and I'm following a tutorial by a YouTube Channel named Zigurous on how to make a Flappy Bird. For some reason, I can't get my prefab for the pipes to actually create new pipes despite having the code written and done without no errors. Can somebody help me? (Btw, timestamp for the tutorial is 37:04 if you need any reference)
okay now show the code that creates new pipes
VS is saying that the code that is crossed out is obsolete, does it have to do with that?
The tutorial is kinda old, it's using Unity 2019
why did you mark the Spawn method as obsolete?
VS marked it on its own 😭
no it didn't
How do I unmark it then? I closed the editor, reopened the script and I just saw it like that
read your code
it says "System.Obsolete"
Where and what do I do with it?
You should probably remove the attribute, if you don't want the method to be obsolete
Oh okay
It still doesn't work, the spawning of the pipes I mean
In my case, they're the stalagmites
I deleted the system obsolete btw
show the spawner object
and what enables it
you mean the script?
yes
If you put a debug statement in it, does it work
Also show where the script is attached
no nothing works in void update
did you actually put a log inside of Update?
yes it got called but nothing else works
so update does work, what do you mean by nothing else works, have you tried debugging?
i tryed logging keypresses like spacebar and none of it gets loggedf
show your updated !code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
dont you need an eventsystem in your project for things to work?
im pretty sure you do iirc
only for canvas
ah okay thanks
do you have the old input system or both enabled?
what do you mean?
exactly that
i dont get what you mean sorry
mine doesnt look like that
make sure you are not in preferences
