#💻┃code-beginner
1 messages · Page 591 of 1
I have a question, on this list/array i noticed it added a _0 at the end of both of them. does this have any effect on their position in the list?
No that's your sprite name
i'm having a bunch of trouble with this on click event and cant seem to solve it, been googling for 12 hours. just trying to find whats wrong.
@void thicket ive changed the name of my sprite and it still seems to show the wrong name also, thats why im trying to figure that out. thanks for your timely response
Your sprite name is different from your texture file name
Which you can edit in sprite editor instead
Though I don't think that'd affect onClick, at all
yea, i dont think so. on the click im trying to have it where i click appropriate button, and the sprite changes to the appropriate race. nothing i do seems to work as intended and im shocked that i couldnt find any information on it despite it being so common. havent slept lol
How did you set up your button
man, ive done a bunch of different ways to try so many different angles. at the moment i created a child of the canvas as a text button, then I enabled the onclick() and created a script called racemanager
first i tried making it add to an integer and have the sprite go up the list as i clicked one of the buttons and down the list as i clicked another (this isnt what i want but i was trying to get something to work)
and that failed
at this moment, the last thing i tried to do was make a bool for the race i want to select, and if it was true to change the sprite into the appropriate one by telling the .sprite = list[value]
public class RaceManager : MonoBehaviour
{
public SpriteRenderer sr;
public List<Sprite> race = new List<Sprite>();
public bool dwarfpick = false;
private int selectedRace = 0;
public GameObject playerrace;
public void dwarfOption()
{
if (dwarfpick == true)
{
sr.sprite = race[1];
}
}
this is where im embarassingly sitting at now lol
one second ill show you where i started
How I might go about doing this would be to have the button have a reference to the Sprite you want to use, then you click the button and it passes that reference to whatever thing draws the sprite
So, you'd have a RaceManager, but rather than keeping a list of all possible sprites, it's just receptive to having something else tell it to change, then your buttons can send it a sprite and some sort of enum or whatever you use to keep track in code
public class RaceManager : MonoBehaviour
{
public SpriteRenderer sr;
public List<Sprite> race = new List<Sprite>();
public bool dwarfpick = false;
private int selectedRace = 0;
public GameObject playerrace;
public void dwarfOption()
{
selectedRace = selectedRace + 1;
if (selectedRace == race.Count)
{
selectedRace = 0;
}
sr.sprite = race[selectedRace];
}
Makes it easier to add new ones
this is what i had at first
digiholic could you give an example?
the second one i sent i was just trying to get it to go up in the list
And how does get "failed"
lol even i did it wrong (what you did is fine)
Does the callback get called?
[SerializeField] private RaceManager raceManager;
[SerializeField] private Sprite chosenSprite;
public void ChooseRace()
{
raceManager.SetSprite(chosenSprite);
}
And then call ChooseRace in your UI button
nothing seems to happen when i do it, honestly i dont know how to check whats happening on the backside
Show the button component
Debug Logs usually
will try something like this in a bit thanks, one moment
er whats that visual scripting thing
i tried with it off and on
the check mark lol
i ahve no idea what that is nor do i know what visual scripting is
Is that "racemanager" reference same as the one on the scene?
What gets highlighted if you click that racemanager reference
haha no you tell us if thats the correct object
And what about sr reference
Ok let's log first
In the dwarfOption add some Debug.Log so you can see if it is called at all
Good, and can you show your RaceManager component in inspector?
What does it highlight if you click selectedRace reference in sr
oops.
i dragged the object from view port into the slot
when i first did it
and also tried from the hierarchy
i need help with GetComponent, GetComponent("string name of my script") works, but GetComponent<name of my script> doesnt, so i cant access the values within the script
What component are you trying to get
Show where you're calling it
as in the folder or?
- what do you mean by "doesn't work"? there's a lot of things that could be going wrong
- show the exact code that has the issue
returns a null value
do i just screenshot it
So it is correct reference it seems then. Still don't see sprite changing? (Also.. save your scene)
In the code
Show the !code, and how you're determining what it's returning
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
its too long it says
did you read the "Large Code " part
Now if only someone had called up a bot message that has a section about posting large code blocks
darn if only such a thing existed
😉
Just copy the line in question

I'm looking for context, I need more than just the line
A tool for sharing your source code with the world!
@void thicket yea, sprites not changing at all
Okay. There are no GetComponents in there
btw [SerializeField] on public fields is redundant
its meant for exposing private fields, publics are already exposed
this is the class i inherit tohttps://paste.mod.gg/neghxyxalzoo/0
A tool for sharing your source code with the world!
(unrelated to your issue)
and here is where i call it from
Make sure that's same sprite you are looking at- does it have any change in scene view, while play mode?
A tool for sharing your source code with the world!
specifically ive had trouble in line 130 of that last part
ive tried everything i found i nthe forums and absolutely nothing worked
Well, first off, if things like truehandR are always supposed to have takeaim component, why is the variable not just of that type instead of GameObject
because its an object within the game
So what?
Make the variable the type you actually want
im sorry im not following. if i am understanding what youre asking, its the same sprite as i dragged it from the scene to the appropriate slot
If your truehandR is always supposed to have a takeaim component, then truehandR should be of type takeaim. Same goes for every other variable of type GameObject you are using. You should basically never have public variables of type GameObject, use the type you actually want
I mean click the play button, and select the object from hierarchy, click the button and see if anything changes in inspector
performance issues otherwise right?
Add this line before the if:
Debug.Log($"Collided with {masterhit.collider.gameObject.name}. String GetComponent: {masterhit.collider.gameObject.GetComponent("Compatiblecontrollingchar")}, Correct GetComponent: {masterhit.collider.gameObject.GetComponent<Compatiblecontrollingchar>()}");
Yes but also easier and significantly less messy to write
Also.. is there other logic that is relevant? Visual scripting stuff possibely?
Collided with droidtrooper. String GetComponent: droidtrooper (DroidControls), Correct GetComponent:
thats what it says
Can you show the inspector of droidtrooper?
Yes
havent dont any visual scripting
Well, one thing that could cause this, is if you have multiple scripts named Compatiblecontrollingchar. The string version will look for things that match that name, regardless of what namespace they're in. The typed version will look for that implementation of Compatiblecontrollingchar, whichever class it references
D: is there a way to search if i have multiple of those other than by hand?
@void thicket yea its not even switching the bool to true on click
i noticed when i turned it off and played again im not getting the debug
In the GetComponent with the type parameter, click on the Compatiblecontrollingchar and go to the definition (F12 if you're in Visual Studio. No idea the hotkey in VSC or Rider), and do the same for the one in the type declaration of DroidControls. See if they take you to the same file
i think i found the little scoundrel
fingers crossed
i think it worked, ill try getting one of the component variables
i think the main mistake was trying to use the sample folder directly on the project
like the prefabs from it probably messed with things
😦 now i gotta redo 3 days of work
Well, while you're redoing it, you can refactor the code to use more precise typings as you go, which will make it much faster to get back to where you were
You can still drag in the whole object into a variable of a component type
It just means you don't need to GetComponent it
@polar acorn i think i did try making it into a type but i had a similar problem to this and evaded it somehow by using a game objecrt
maybe cause its a cloudgaming game with webrtc and im using instancing that i can get away with things like that, i dont remember exactly what my reasoning was
Were you editing things in play mode?
Try check the references again 
i was definately not lol
my first time i did that and it deleted everything i never do that again lol
Hello, I have two cameras in my project, one that I use for my character and another that I use to make a drone view in the sky. How do I get the second camera to have a custom frame rate, such as 10 fps?
you can probably make some type of timer with fps and then manually call Render()
might need to use render texture instead for display though
ok, I'll have a look, thanks for your help!
If you're completely switching cameras, you could also just turn down the target framerate while using the drone camera
but that would make things like menus feel gross
and it's not appropriate if it's a picture-in-picture situation
it would also mean that each Update loop covers a very long period of time
...this is a bad idea
speaking of which, seems to be working
i love you.... give me a kiss... omfg
wow you really make this that fast ?!?
at least I know what I shouldn't do 😅
hehe its pretty simple
I had a bit of free time while waiting for my 🍵
https://paste.mod.gg/dedovtlpoqkp/0
A tool for sharing your source code with the world!
I made this script that seams to be quit similar but it don't work at all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LowFpsCamera : MonoBehaviour
{
public Camera targetCamera;
public float frameRate = 1f;
private float nextRenderTime = 0f;
void LateUpdate()
{
if (Time.time >= nextRenderTime)
{
targetCamera.Render();
nextRenderTime = Time.time + (1f / frameRate);
}
}
}
I think I've understand what's my problem
you have to disable the camera first
did you make sure your camera was disabled?
I don't understand, why I should disable the camera ?!
if you dont Render is being called every frame automagically
disable the camera component not the gameobject
just to be clear
the point of manually calling Render is you telling it when to render instead of being called how it is normally every frame
you can't call Render from an active (currently rendering) camera because it's being controlled during the render order . . .
note that being disabled doesn't mean the camera can no longer work
disabling a component actually does..basically nothing
it just means that it won't have a few messages send to it
That was an important thing I learned in my earlier years with Unity
ok I think i've understand, so basically, I have to use a render texture on my drone camera. I also have to completly disable my character camera and to just disable my camera component on my drone camera ?
you can just swap between gameobject being active for camera 1 and camera 2
but yeah you can just disable component too, but the drone camera should stay disabled even while being used
Render texture can be Fullscreened as UI(Raw Image component) or a texture on a quad. up to you
ahhhhh ok I get it, I just need to use a render texture that I put in the background of a canvas, so I won't have a real camera, but some kind of video displayed on a canvas
well the camera is there is just outputting to a texture not directly on screen
ok I see
you can also put a camera infront of a quad with the texture, it does more or less the same effect
the benefit of UI is scales a bit easier with diff resolutions or you can easier overlay UI indicators
it sound like a bad DIY solution 😂
well it depends on the look you're going for tbh. In my game the player holds a tablet so it just goes onto a texture while shows player holding the device
oh ok I see
I love the fact that I wanted to have a bad resolution camera and I'm not sure why, but it's actually really bad
Is it possible, with a render texture , to adapt it to the proportion of the screen? Because even if I want poor quality, I don't want a stretched image.
what resolution did you set the texture at?
default value is 256 by 256 thats pretty low rez
I left the default proportion at 256 x 256.
well that explains the low quality lol
yes, ok, it's true that it's rather logical, but is there anything I can do so that the image takes up the whole screen and is never stretched?
to take the whole screen set the mode to stretch on uI?
did you make resolution bigger?
yes, but when I do that I have a square image (in something like 1024x1024) that trying to fit a rectangular screen, so the image is stretch
why did you make it square then lol
use the resolution of your game
yes, but maybe my screen is in 16:9, but someone will have a screen in 4:3, 5:4 or 21:9... So okay the image wont be stretch for me but for other people the image will be stretched
well there are compromises in life we have to make.. this is for you to decide how you will approach
everything in development has a tradeoff
So there's no other solution? if I want to have a low frame rate on a camera, I have to use a method that produces a bad stretched image?! I can't believe I have to make this compromise.
did you set resolution to at least 1080p or something and yes, ofc its gonna start stretching on UI
if you dont want stretching you might consider using a quad
Does anyone know why it attacks the camera lol ?
I have no clue how to code but have decided to learn c# to make a game, this will go well
we all gotta start somewhere
because you coded it that way?
you're literally telling the object to go to hit.point every time something is hit with ray
think carefully whats happening
Your Raycast is hitting the box itself
oh spoiler alert
oh damn
Removed the collider🦤 🫡
Nvm, i made it so it only cares about the ground, so i can have an collider on the player and other objects
You can use layers btw
idk if you used that before
once the cube is picked up you can switch collider to layer the raycast no longer want to pickup
disabling collider works too (but might cause other unwanted issues)
hello guys, i am having a problem making my game, can anyone help me, send me a mesage if so
!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
Would this be a proper method of checking to see if an objects rotation is withing -2 and +2 of a float? ``` if ((transform.rotation.y <= ClosedROT + 2) && (transform.rotation.y >= ClosedROT - 2)
{
}```
Rotation is a quaternion. The Y value is not what you think it is
no
What you should do is use Vector3.Angle and compare the object's forward direction with the direction you want to compare it to.
Okay thank you.
Like this: ``` Quaternion closedRotation = Quaternion.Euler(0, ClosedROT, 0);
float angleDifference = Quaternion.Angle(transform.rotation, closedRotation);``` ?
well yeah that's one way too
Okay.
that's not exactly what I described above, but that's definitely a decent way to do it
Helllo guys, I'm following a Youtube video, and they create a new material and make it green
When I do literally the same, choose green as Base Map but it appears purple.. Why that? I didn't have the Shader Universal Render Pipeline / Lift from the options, so I installed it, but still remain Purple
You are using a shader that is incompatible with your current render pipeline
If I choose HDRP / Lit (which I think I did HDRP at that point), now appears yellow
I mean better then purple but still don't understand that 🤣
that means you have HDRP installed in your project, not URP
show what actual render pipeline you are using
project settings => graphics
Rmeembner this is a lit shader, it is subject to the lighting in your scene.
If you are a Unity beginner I highly recommend using URP not HDRP
yes that's HDRP
Also I don't use HDRP but it's possible they have a different color space than built-in and URP use, so the "Green" channel might not map directly to the texture
It's not the first time I'm having issues there, considering that I'm learning I think I'm just gonna start again with URP
Start with URP, HDRP is a lot more advanced.
Do I have to start again the project from scratch or can I 'convert' this one to URP?
I mean not that there is that much I have done, but if there's a fast way to convert i'd just do that
You should be able to just convert.
Thanks! I'll try to convert that to URP then
bit of a random question but whats the best way to store data/lists etc to call into scripts? for example I want to store a list of names and randomly generate them with a script
probably just a static array kept in the relevant script
A ScriptableObject is good
Theny ou could edit it in the inspector and/or have different such lists for different purposes.
Thank you, will take a look at ScriptableObjects
hi, im making an incremental game with upgrades in it. here is my shopitem script that is attatched to every shop item that you can buy. is there any way to make this script more efficient? a lot of the code in the last 3 methods is very similar and idk if its a good idea to have this script on every shop item. i had tried using an interface system to base different upgrades off of but im not quite sure thats what i want/need for my game so i tried this approach instead
https://hastebin.skyra.pw/gasokuhiba.pgsql
I think you should be clear about what you mean by "efficiency" here, because this doesn't seem to be a performance question
This seems to be a code organization question
It seems like you have put the functionality of all different items onto this one script?
yes sorry the performance of the game is fine as it is but the way my code is structured right now is a bit clunky
One option is to use polymorphism
e.g. make an abstract Upgrade method on this base class and then have different child classes which implement it differently
Quaternion roll = Quaternion.AngleAxis(-rollDirection * multiplier, Vector3.forward);
transform.localRotation *= roll;
what's the best way to go about smoothing out this roll, so it isn't an instantaneous start stop, but rather a quick acceleration/deceleration to and from the target speed?
okay, i'll try that, thank you
Do it in a coroutine with an easing function or Animation Curve and Slerp
or use a Tween library
For the coroutine approach I'm not sure how i would cleanly deal with stopping rotation/changing direction, mind explaning me the process in a bit more detail?
https://unity.huh.how/lerp/coroutines
but replace it with Slerp
Im doing my movement right now by doing this though:
Quaternion yaw = Quaternion.AngleAxis(mouseDelta.x * multiplier, Vector3.up);
Quaternion pitch = Quaternion.AngleAxis(-mouseDelta.y * multiplier, Vector3.right);
Quaternion roll = Quaternion.AngleAxis(-rollDirection * multiplier, Vector3.forward);
transform.localRotation *= yaw * pitch * roll;```
im not sure how id implement the slerp into that
StartCoroutine from the current value to the desired value, store coroutine inside a variable so if you need to spin the other way you can stop that coroutine and assign this new coroutine and so on
gotcha, thanks
why cant i drag and drop my ClickAdder script onto this "Upgrade" field?
What type is Upgrade
is it on a gameobject?
no it isn't on a gameobject and Upgrade is of type Upgrade which is a class that ClickAdder derives from
Oh wait, nevermind, they're both misspelled. I noticed the inspector said "Uprade" but no that's what the class extends as well
Is Uprade a MonoBehaviour?
yes
it needs to be on a gameobject then
So then it does not exist unless it's on an object
what youre trying to drag in is a TextAsset , that wont work for your type
put Uprade on a gameobject, then drag gameobject in the slot
components are created when they are on a gameobject, right now its just a text file
I believe you mean Uprade
ah yes my mistake
ohh okay i see now thank you
Even when I set the Rigidbody velocity to zero on my code, the character slides very shortly. Why?
playerCamera.Rotate(Vector3.right * -lookVector.y);
Vector3 camRotation = playerCamera.eulerAngles;
camRotation.x = Mathf.Clamp(camRotation.x, -85, 85);
playerCamera.rotation = Quaternion.Euler(camRotation);
why does this cause the transform to rotate very strangely? im not sure how to describe it, but i cannot look upwards and i can somehow look upside down behind me, but not always?
just started getting into unity and needed some help with my player input. my left and right movement are good, but the w and s key move my player vertically (instead of forward and backward). feel like this is an easy fix but not sure how to do it. anyone know how to fix this?
so im trying to make it where when i select one gameobject the others are disabled but idk if this is nearly close
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ColourRed : MonoBehaviour
{
public void WhenButtonRedClicked()
public void GameObject RedTex;
public void GameObject OrangeTex;
public void GameObject YellowTex;
public void GameObject GreenTex;
public void GameObject LBlueTex;
public void GameObject DBlueTex;
public void GameObject PurpleTex;
public void GameObject PinkTex;
{
if (RedTex.activeInHierachy == true)
DBlue.SetActive(false);
PinkTex.SetActive(false);
PurpleTex.SetActive(false);
LBlueTex.SetActive(false);
GreenTex.SetActive(false);
OrangeTex.SetActive(false);
YellowTex.SetActive(false);
}
}
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
this doesnt depend on the input but on the code you used, can you show what code you use to move your player?
Learn to use arrays instead of this mess
arrays
ok
appreciate the help!!
The code is inside a weapon recoil script attached to pivot point, and when not enabled the gun position is fine but when enabled is not and I copied all values from the other gun that works
y coordinate is vertical (up and down) in unity
Not home atm to send the code
i switched it to z but that didnt work :/
did you switch both moveDirection.y and input.y to z?
and does your IDE give you an error under both of those?
or only one?
input.y should control moveDirection.z
one of them is a Vector2 and another is Vector3
ok dope. appreciate the help. probably would have taken me an hour to figure that out
anyone see where my mistakes are?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ColourRed : MonoBehaviour
{
public gameObject RedTex;
{
public void Trigger()
if (RedTex.activeInHierachy == false){
{
RedTex.SetActive(true);
}
else
{
RedTex.SetActive(false);
}
}
}
playerCamera.Rotate(Vector3.right * -lookVector.y);
Vector3 camRotation = playerCamera.eulerAngles;
camRotation.x = Mathf.Clamp(camRotation.x, -85, 85);
playerCamera.rotation = Quaternion.Euler(camRotation);
dont entirely understand what im doing wrong here
for some reason when the x rotation goes to 85, it snaps back to 0 instead of -85 (among other confusing issues)? i assume this could be because there is no -85 rotation and it's 275 instead? then how would i properly clamp it?
You still aren't posting your !code properly
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
how am i suppose to
read this message
Instead of clamping between -85 and 85, add 360 to it and clamp it between 275 and 445
Wait, I think my math is a bit off there I think there should be a modlus somewhere
Did you look at the bot message labeled "Posting code" that comes up every time someone replies to you
yea i dont rlly get it
yeah it's the exact same for some reason
a modulus would make sense, but im not sure how to do it
Okay, it's ((angle + 360) % 360) - 360 to get it in the form of -180 to 180 while accounting for values that might already be within that range, or beyond 360
Might want to make a helper function for that
and would just plugging that into euler angle rotation work or would i need to undo this
It should, it handles negatives and post-360s just fine
it's just that the value you set it to and the value you get when you read it won't always be the same
transform.eulerAngles = new Vector3(0, 400, 0);
Debug.Log(transform.eulerAngles);
Will most likely log 0, 40, 0
somehow this is just the opposite of what happened - i cant look down and i can look up behind me
and also for some reason the y and z of the euler angles are also somehow changing? am i using something wrong
the camera is a child of the player rigidbody (and that rigidbody has x and z rotation frozen)
Yeah, that's the other thing. Setting an euler rotation on one axis can also be expressed as a rotation on the other two and there's no way to control which way it decides to express it
this is why rotations are stored as a Quaternion internally, by the way. One orientation = one Quaternion. No ambiguity there.
The only real solution is to either always write or always read from euler angles, never both. You can try to keep track of your angle internally and use that instead of getting playerCamera.eulerAngles
i just dont understand why stackoverflow has solutions that just dont work for me
this is also happening in fixedupdate but im not sure if that'd change anything
Because sometimes it will return the value you expect, and sometimes it won't
This person just happens to be oriented in a way that it always decides to use the right way to express the angle
alright, this ended up working
im not entirely sure why but, hell yeah
thx for telling me to keep track of the angle internally :D
Clamping angles is always miserable
Can you explain why you said that about clamping angles? I have a problem with my setup. My character rotates weirdly when I clamp my target rotation to my upper and lower look limit. Then when I dont clamp. It works fine.
Scroll up a bit, basically, euler angles are particularly annoying because they loop and you can exprfess the same orientation multiple ways
you should be clamping a separate value that you then pass to Q.Euler
never clamp your eulers directly
Ah all right. Thanks.
Oh yeah sorry I did not see that part. Thanks!
Show the inspector of MushroomSpawnScript
tbh they took you literally lol
Hello, I'm a beginner and I just installed unity 6 and then I created a new project but after the project was created I received errors like:
error CS0246: The type or namespace name 'DebugUIHandlerIndirectFloatField' could not be found
I put the whole error message in the attached file.
that IS technically the inspector for the script not the component 
no. Select the Mushroom Spawner object and show the inspector
If you don't have any objects with the script on it then it's not running
Okay, so the timer is properly set. If you're getting more than one mushroom in start you probably have more than one MushroomSpawnScript in the scene
Components are on objects. Objects are in scenes.
MushroomSpawnScript is the name of a component
If multiple mushrooms are spawning at start, then you probably have multiple ones in the scene
you type t:MushroomSpawnScript in the hierarchy exactly like that
it will show al the objects with that script
Okay, so there's just the one. Maybe it is actually spawning them properly it just takes more than 6 seconds to load?
sounds like you might have a corrupt installation / packages
You're spawning them every 3 seconds
if your game takes 6 seconds to load from when you hit play, two more spawns occur
wdym "own text system" ?
thats very vague
Maybe try adding in a debug log where you call it in the timer and see if that's happening?
Don't
a 3d text, which updates based on a string
but i need it, im making a level editor
Just use 3D TextMesh ?
TextMeshPro
i need collision
so put mesh collider
Just use 3D TextMesh ?
Log something different, so you can tell them apart
Okay good just making sure to mention it
no its pretty flat tbh
but you can probably use the vert points and extrude it further
I'm surprised there isn't a Probuilder 3D text type thing
yeah but what if i want so each letter has different rigidbody? or i could just combine them together
also texturing would be possible?
like it would just be a normal mesh
You would have to do it like this then, grab the verts and create your own mesh from them
or maybe create a whole new gameobject for each letter and put them together
it will still be flat though
i mean after i extrude
oh right those wold be as individual letters yes
make a dictionary so you can just do a lookup table for each letter for storing their vert
could i ask, how do i get verts, is there a function for it or a library i should know?
I think the TextMeshPro stores it as verts, if its quads ur fucked there and need to manually do it lol
oh my
maybe i could store each letter in a blender prefab?
it would be kinda a lot of work writing them all right now 😭
you can but they will be fixed no? unless you then grab that and manipulate it
wdym
it would work i think
i will try
see you, and thanks
you'd only need to create it once 😉
yeah but if user wants different fonts?
and complexity
I mean you can grab the verts from the mesh and modify them
but yeah you're limited to the font you rendered with
So, while the game is running, repeat that search for mushroom spawn scripts
Where did you put those logs? Can you share the updated script with the logs in place so I can see where they're being called?
Put Initial Mushroom Spawned in start, and put something like Timer Mushroom Spawned where that one currently is
Or just post it here, I might be off in Factorio land
I have a problem where my bullets destroy themselves when not even hitting anything
This happens only when i walk in the same direction as the bullet and shoot
show bullet code
sounds like they are hitting your player or each other
yeah you should print what it hits
Debug.Log(collisionobject.name)
yea i thought that aswell but i turned off the collider for the player and it sitll did it
give this a read then: https://docs.unity3d.com/Manual/LayerBasedCollision.html
hey, i tried to make a gizmo for my meele attack but it doesnt show up...why?
{
Collider2D hitEnemy = Physics2D.OverlapCircle(transform.position, attackRange, demons);
if (hitEnemy != null)
{
if (hitEnemy.TryGetComponent(out EnemyBase enemy))
{
enemy.TakeDamage(meleeDamage);
}
}
}
void OnDrawGizmos()
{
Gizmos.color = Color.red;
Gizmos.DrawWireSphere(transform.position, attackRange);
}
}```
do you have gizmos enabled
also double check that attackRange isn't 0
wat, how do i enable them
holy wow, thanks
hello
thank you so much
Hi, you can set timer in unity in Update() method, repeating one in Start(), the best way to learn is researching the answer, you can get help from chat AI and ...
!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
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
hello anyone have teenpattie game ?
Easiest and cleanest way to do it is : creating a SpwanManager or GameManager that controls spawning object, the score and ... . This experience will help you clean your code more than as it was.
Is it possible to rotate a skybox vertically? Does anyone know how?
I've done that but I can't recall my methods. Probably just copying one of unity's skybox shaders and adding onto it
reading some other methods and people just make a skybox camera and rotate that instead, and by not rendering the skybox in the primary camera
Lastly, you can make an inward sphere and render onto that with a panorama
if you're referring to the method by Duster_2015 here: https://discussions.unity.com/t/how-to-rotate-a-skybox-on-the-z-or-x-axes/138394/4, I tried following it but unity 6 doesnt have clear flags or depth as settings on the camera anymore. Is there an alternative way to do it for unity 6?
is there something i'm doing wrong here? i have the exact same code as in the tutorial but this script does not appear in "dontdestroyonload"
was i supposed to place this script anywhere??
presumably one of the previous steps told you to put the component on a GameObject in the scene
ah yeah that's probably the case
yeah, it's step 3 of section 4. you should make sure you actually follow all of the instructions when going through a course
very true, i have a habit of skimming over the tutorials, especially since they are no longer in video form from now on
hii, anyone could help me?, changed the spawnPoint of a bullet from a 2d object to a 3d and now it doesnt appears in game, it creates the object but i dont see the image
it only shows when i activate the prefab O.o
dw i found a solution thx ❤️
guys why does the oxygen decrementor has no serialize field and the healing item has a serialize field
save the file...
If the variable doesn't need to be public (accessible by other classes) you should instead do:
[SerializeField]
float blah;
where do I begin(I'm completely new to coding)
does anyone how do i make my character not turning when shooting?? Its a 2d Sprite i just want him to face the camera
I personally would just learn the basics of C# outside of Unity first.
https://learn.microsoft.com/en-us/dotnet/csharp/tour-of-csharp/tutorials/
Why is it turned in the first place?
i made him shoot to mouse position and it turns when i shoot in x directions
Share your code
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
If this is 2D, you should probably be using a RigidBody2D instead
Also is the collider on the bullet controller set to be a trigger?
public abstract class Upgrade : MonoBehaviour
{
new public string name;
public string description;
public int cost;
public abstract void Apply();
}
public class UpgradesGeneral : MonoBehaviour
{
[HideInInspector] public int tokensWater;
public List<Upgrade> upgradeList;
void Start()
{
//Add to list
upgradeList = new List<Upgrade>(GetComponents<Upgrade>());
}
}
public class UpgradeFireRate : Upgrade
{
new public string name = "Fire Rate";
public string description = "Decreases fire rate by 25 percent";
public int cost = 20;
public override void Apply()
{
PlayerShooting.playerShootCooldown *= 0.75f;
}
}
public class UpgradeDamage : Upgrade
{
new public string name = "Damage";
public string description = "Increases damage by 1";
public int cost = 30;
public override void Apply()
{
PlayerShooting.playerDamage += 1;
}
}
I have no idea what I'm doing, is this the right way to do an upgrade system?
@rapid laurel Bullet colliders are usually set to triggers so they do not actually apply forces when hit
SAJDKFAS
thats it yeah...
and me trying to code lines for nothing to make him not turn
thanks so much men
Note that you should now be using OnTriggerEnter now instead
Hi, i'm currently trying to flip a sprite based on it's angle relative to the character(left or right). Basically i just want to check if the transform.foward is facing the left side or the right side of my screen. I've tried using eulerangles, transform.forward and dot product but my methods of implementing it just suck. Any help?
If you saw the last message, no you didn't. Overnight coding had me asking the silliest things 😔
super random jump in conversation but same
why doesnt this server have just 1 offtopic channel 😔
I sent a screenshot saying oh my godddddd why isn't my public variable showing up in the inspector
It was.
I just didnt see it but it was right on my face
LMFAO
if (transform.forward == Vector3.left)
it does not register and i don't get the logs either, any idea whats wrong with my code
void Update()
{
transform.position = _player.transform.position;
transform.right = _cursor.transform.position - transform.position;
if (transform.forward == Vector3.left)
{
Debug.Log("flip left");
flip = true;
}
if (transform.forward == Vector3.right)
{
Debug.Log("flip right");
flip = false;
}
Flip();
}
private void Flip()
{
if (flip == false)
{
transform.localScale = new Vector3(transform.localScale.x, transform.localScale.y, transform.localScale.z);
}
else if (flip == true)
{
transform.localScale = new Vector3(-transform.localScale.x, transform.localScale.y, transform.localScale.z);
}
}
In 2D, I don't think you should be using transform.forward
I think you should be using transform.right
yes i've tried replacing it with that
it doesnt work either
transform.right does work when i use it to rotate the weapon though
Give me a few minutes and I can experiment
tysm
I mainly work in 3D so I don't want to give you the wrong answer
how can i make so an object doesnt overlap with others? so like it renders first
i have an interface that player can see through camera, and obviously it overlaps with other objects when too close
because it doesn't deal with Unity, it detracts people from learning, and generally, leads to ppl getting in trouble . . .
Guys I have another problem with my game, I made it shoot where I have my cursor, but the bullet doesn't go exactly there, but close.
Can it be a camera thing?
This should be what you want, I'm not sure what you were trying to do with the cursor position. You might need to flip the directions depending on how your character is oriented in the sprite. Let me know if you have any questions.
void Update()
{
Vector2 playerPos = _player.transform.position;
Vector2 myPos = transform.position;
// set the y component to match the players so
// calculations are done at the same height
myPos.y = playerPos.y;
Vector2 horizontalDirToPlayer = playerPos - myPos;
// normalize so length is 1
dirToPlayer.Normalize();
Flip(horizontalDirToPlayer);
}
private void Flip(Vector2 flipDir)
{
Vector3 tempScale = transform.localScale;
// assume positive
tempScale.x = Mathf.Abs(tempScale.x);
if (flipDir == Vector2.right)
{
tempScale.x = -tempScale.x;
}
transform.localScale = tempScale;
}
Hello, how i can do for wait 1 second between the actions of my code, thanks
With a coroutine or awaitable
ok, i will search information about that
I personally would go with Awaitable, but it slightly more complex imo. Worth it though.
I want it to destroy an item when pass x seconds
Thank you, i'll take a look into it
I literally forgot .abs existed and was crazy trying to fix -(variable) constantly switching around inside the update loop
Destroy(gameObject, seconds in float);
my cat stepped on my keyboard and sent this to a gc
so i decided to make it my username
private async void DestroyAfterOneSecond()
{
await Awaitable.WaitForSecondsAsync(1f);
Destroy(obj);
}
Lol I didn't know Destroy has a time overload
just use that
just my character doesnt shoot exactly on my mouse position idk, it goes near it
ok, thanks its goes
Post your code where you are moving the bullet
and now how i can recover this item some seconds later?
Well you can't you destroyed it
but if i destroy a prefab of this item i can instantiate another, no?
You could, not sure what you are trying to do though. If you need the exact same instance, don't destroy it. Just disable it and enable it again
I want to do a dungeon when the walls can appear and disappear
I think i've dealt with this before, if Camera.main.ScreenToWorldPoint is used it usually mess up if the camera is in perspective mode or the Z values are mismatched
So the velocity change also counts the Z axis in
Yeah I wouldn't destroy, I would disable and enable
ok
I guess activate and deactivate are the more appropriate terms when referring to game objects
a powerful website for storing and sharing text and code snippets. completely free and open source.
changed the Camera.main for raycast before to test if it works
I would just enable/disable the renderer component or activate/deactivate the GameObject. Especially, if the wall can reappear . . .
My biggest concern is that if this for 2D, you are doing a lot of 3D calculations
And how i can do this? I'm new and I know practically nothing
my character is a 2D sprite, but i wanted to move in all directions
and shoot in all directions too
You'll have to use coroutines or awaitables for this
I sould copy this, but changing things, no?
you technically could do it in update with bool flags and timers, but it could get ugly
yes
Something like this could work.
private async void DisableAndReEnableWall(GameObject wallObject, float deactivateDelay, float reactivateDelay)
{
await Awaitable.WaitForSecondsAsync(deactivateDelay);
wallObject.SetActive(false);
await Awaitable.WaitForSecondsAsync(reactivateDelay);
wallObject.SetActive(true);
}
In 3D space (x,y,z) or 2D space (x,y)?
i need to import something?
Which Unity version are you using?
2022.3.27f1
Awaitables were introduced in Unity 2023, so if you are stuck on 2022 then you'll have to use Coroutines
you can also use a 3rd party library UniTask which are better than Awaitable and behave very similar
yes
Hey so I want to learn more about C# mostly for 3D game development I know how to use unity editor itself but coding wise I have no clue. I want to learn about the basics of player movement, input, physics etc. The videos I find either don't really explain it well. Any advice on how I can build up my C# knowledge?
Player movement, input, and physics are all part of the Unity engine. If you want to learn C# basics, then follow many of the C# websites or tutorials. For Unity related content, checkout Unity !learn . . .
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
If you don't know anything about coding, I personally recommend learning regular C# basics outside of Unity first.
You can get non Unity cs help in the !csds
Join the C# Discord server, a programming server aimed at coders discussing everything related to C# (CSharp) and .NET. https://discord.com/invite/csharp
For C# information, take a look at this link . . .
If you like video tutorials, I think this tutorial series is pretty informative and straightforward.
https://youtube.com/playlist?list=PL4LFuHwItvKbneXxSutjeyz6i1w32K6di&si=vy_LQul7WXVMzTAq
Thank you I will be checking them out !!!!
Hello, I am following a tutorial for unity, and am stuck on a part. Basically what I am making is a flappy bird type of game and I basically used the same line of script as the tutor, but it doesn't work the same for me.
transform.position = transform.position + (Vector3.left * MoveSpeed) * Time.deltaTime;
This is supposed to be the line of script for the pipes moving past the bird. I looked up what ''Time.deltaTime'' does, since that was supposed to fix the exact problem i am facing currently. Can anyone help me? Oh and the problem basically is that the pipe moves to the left way too quick. Apperantly the extra "Time.deltaTime" was supposed to fix it.
If it's too fast, then change your speed. MoveSpeed determines how fast the object moves . . .
Oh so it isn't a scripting mistake? Glad to hear.
Okay wait its this small of a number and the pipes aren't even visible are the pipes just gone?
could it it be that the pipes fall out of the scene even before the whole scene plays?
Press pause and see where the pipes are in your scene view
they moved slightly
maybe the pipes are behindthe blue screen
yup it
is
how can i move where the blue screen is?
cuz it is im front of the pipes
nvm
i fixed it
Well, yeah, you should be able to know what that line of code does. If an object moves too fast, you slow it down, and vice-versa. It's just a logic question . . .
yea i understand the code but the pipes just werent appearing on screen so i kept on wondering where they were
finally figured it out so yea
are there any techniques to simulate softbodies in a computationally cheap way?
What defines "cheap"? Do you need dozens/hundreds of those running at once?
The easiest way to fake a softbody is to put physics joints and colliders in the bones of the skinned mesh
PhysX has no soft body physics built in tho
i have a single egg running in a mobile game
thinking of supporting as many mobile devices as i can
Hi, well, i have a problem, the meele collision have to be in fron of the player...But is on its middle...what i have to do for make it work on the right, or left if the character is facing left?
{
Collider2D hitEnemy = Physics2D.OverlapCircle(transform.position, attackRange, demons);
if (hitEnemy != null)
{
if (hitEnemy.TryGetComponent(out EnemyBase enemy))
{
enemy.TakeDamage(meleeDamage);
}
}
You can make an empty transform and use its position instead
If you use localScale.x to flip the character, this transform will flip with it
As long as it's a child
oh, thanks :3
i think i did something wrong, i made the public gameobject and i added the script to the overlap, but it remains in the same character pos
{
Collider2D hitEnemy = Physics2D.OverlapCircle(machetepos.transform.position, attackRange, demons);
if (hitEnemy != null)
{
if (hitEnemy.TryGetComponent(out EnemyBase enemy))
{
enemy.TakeDamage(meleeDamage);
}
}```
I don't know where machetepos is but that's where it overlaps
hi, i have a robot that im moving along currently. how do i move it along the following grid like this? (imagine the lines i drew were straight)
https://hastebin.skyra.pw/edokuyoqiv.pgsql
something like:
- move forward until you hit a wall.
- turn left
- move forward 1
- turn left
- move forward until you hit a wall
- turn right
- move forward 1
- turn right
- repeat from teh beginning
mmmm, then idk what im doing wrong
What is the red wire sphere showing?
the location of the meele
it should be in the front of the player
How do you draw it
wat
like this
{
Gizmos.color = Color.red;
Gizmos.DrawWireSphere(transform.position, attackRange);
}
}```
wait
And what is transform
oh, you mean it should say
{
Gizmos.color = Color.red;
Gizmos.DrawWireSphere(machetepos.transform.position, attackRange);
}
}```
i suposse the location
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
now it works
thanks
pls?
wdym, do you want the objects to be above the text? not sure I understand
i want the text to not overlap with other objects
i want the text to be above all the object
which objects? they're all objects
texts are objects too
is this a screen space canvas? it should already be drawn above everything else by default
its not its just textmeshpro
do i set that up?
if you don't need the text to be in the physical world and just overlay the camera then use a canvas / textmesh pro UI version
oh ok thanks!
next time put in #💻┃unity-talk or #📲┃ui-ux this is code channel btw
the "Panel" object is just a game object with an Image component on it
You can disable the Image component or deactivate the entire game object
The latter will cause all of its children to be deactivated
I want to active it withing settings.SetActive(true); will that be correct?
But I can't find out how to deactivate it by default
in spectator
you can deactivate game objects in the inspector
the checkmark next to the name
e.g. it's the checkbox here
Thanks a lot
You have to capitalize it correctly.
Your code editor should be showing you an error right now. If it's not doing that and not providing any completions, see !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
your VSCode is not configured properly
Hi
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
does anybody know why my turrets arent spawning properly in my game when i stop playing it and i try to replay it'
what does "not spawning properly" mean
whats happening vs what do you expect to happen
it shows up as invisble like the first 3 show up properly but then the rest are invisble
Yo can someone help with the scene manager i'm starting to tweak
FYI this does nothing cs turretinst.transform.Rotate(0f, 0f, 0f);
Rotate adds to the rotation, it doesn't set it
wdym by invisible
Are they showing in the inspector?
maybe try asking a specific question
it shows up in the scene and inspector
then it's just not in view of your camera
or it's behind another object
sopmething along those lines
or mightve been culled
Whenever I press my button it doesn't go to the desired scene even if I made a dedicated main cam
thank you ill try and look into that and see if i can adjust my camera and objects to see if i can try and get it to work
did you put a log to see if the function / button is working at all
You're also rotating them 90 degrees on the Y axis. Isn't this a 2D game?
GameObject turretinst = GameObject.Instantiate(turretPrefab, spawnArea.position, Quaternion.identity);
turretinst.transform.Rotate(0f, 90f, 0f);```
You're probably "paper mario"ing them
Yeah it says it's pressed in the log
show code
The log or my code?
the code
intresting ill try removing that little bit and seeing whats up
- Make sure you save your code
- Make sure you don't have any compile errors in your console.
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
not only a photo but a side angle
Ah my b holdon
what about Unity ?
Like i said, check your Unity console
your code editor is probably not set up properly
Show screenshots
of the full unity window, with console, with the script selected too
https://screenshot.help
just gonna leave this here
console window is not being shown here
win shift s >
ah they're hidden
You have two compile errors
make sure you press that button so you can actually see your errors
you have them hidden
you will have a script that allows you to move with an azerty keyboard ??
Should probably get around to fixing them 😉
I think Input class lets you switch around but i dunnow, now I use new input system
Well we can't help you if you don't share with the class
i have like 15 in here, but only some spawn for some reason
@rich adder ```cs
using UnityEngine;
using UnityEngine.SceneManagement;
public class SceneSwitcher : MonoBehaviour
{
public void LoadMainScreen()
{
SceneManager.LoadScene("Mainscreen");
}
public void LoadCameraScreen()
{
SceneManager.LoadScene("CameraScreen");
}
public void LoadSettingsScreen()
{
SceneManager.LoadScene("SettingsScreen");
}
}
Like this?
did you check z positions?
If the're in hierarchy, they have spawned
and again if they're not visible, it's because they're not in view of your camera, or they're rotated weirdly
a bit better sure. Ok so where is the logs you said were there?
do you have a script to make a character move? that's the question
Very simple you're trying to use some class called PlayerCam which doesn't exist in your project.
so where have you defined PlayerCam?
Either create such a class or get rid of those parts where you're using it
use one of the Player Starter Assets unity provides
i think it might be because of rotation any suggestions on how to fix that bit
stop rotating them on the y axis for no reason?
how do we do that?
You have a GameObject named PlayerCam. Your code is talking about a class named PlayerCam, which you don't have
classes are anything that are declared like class X
ill try that thank you
thanks
A class is anything you define with the class keyword. e.g. public class MyClass {}
I forgot to add it there but i'm 100% sure the button works when I run the game it doesn't just switch the scene
put a log in that method and show me it in the console
You're kinda just guessing it sounds like.
If you're following a tutorial, you should just follow the tutorial exactly
The point of a tutorial is to learn the concepts they are teaching
gonna suggest this again @runic mesa this will probably benefit you over whatever overconvoluted tutorial you're doing with your skill level
https://learn.unity.com/pathway/unity-essentials
https://learn.unity.com/learn/pathway/junior-programmer
hi, i'm currently trying to make a robot move in a zig zag pattern in a grid but then this happens whenever it gets to the top. why is this happening?
https://gyazo.com/723f4c642cba40e78410ccabf36b4659
https://hastebin.skyra.pw/okarefeneg.csharp
so the scene is Loaded?
Yeah I think so but I made a canvas but the main cam doesn't show that
I already scaled the canvas to screen size
where is the canvas supposed to be ? show it in the camera screen
>= height - 1 is off by one
using >= instead of > makes the condition true one row earlier
as does subtracting 1 from height
Do I have to show the scaler?
thank you so much! it works now but now when it reaches the last tile it keeps going up, how can i make it so that when it reachest that last tile, the robot retraces it stpes back to the 0,0 tile?
as long as you show where you expect canvas is supposed to appear
It's supposed to scale with the phone screen
I find it odd because it works with my main menu but not the other scene's
Omg i'm so dumb
I set my camera sceen to display 2
turn around and go again, and make sure to set the parity correctly
sorry, what is a parity?
question, how do i find this script from another? I tried:
public GameObject birdScript;
birdscript = GameObject.FindGameObjectWithTag("Bird").GetComponent<BirdScript>();
Please help.
OMG
WAIT
nvm
still need help
i put the tag on bird now but it still doesnt work the way i need it to
error:
Your variable is of the wrong type. It's a GameObject but GetComponent gives you a BirdScript here
If your code editor is not highlighting these errors for you, or that it's not showing suggestions as you type, you need to configure it before doing anything else
!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
do u also know how i can get those suggestions
Read bot message above
Right-click where it says "unloaded" on the right, and select "Reload with dependencies"
If it does not work, follow the guide and skip the steps you've already done
where does it say unloaded
Solution Explorer on the right of this very screenshot
On the Assembly-CSharp project
so this correct?
What did you click?
reload project with dependencies
Okay so you don't have the Unity workoad installed
Scroll up and follow the install guide for the "Visual Studio - Installed manually"
Your VS install is not complete enough to open Unity projects
HEY i am in really big trouble and i cant understand
my character cant move when its paralel with world z axis
forget i saw.... v2 insted of v3...
sry
alr well I followed it, turns out i was actually missing unity. I really do remember me downloading it but somehow it wasnt downloaded
Okay so how do I start 😭 I started with the Microsoft Learn tutorial which had me re-learning the most BASIC of concepts but they use completely different syntax in C# (This is coming from someone who uses Python but not at a high level) and then eventually it just got long and confusing so I stepped back
okay so do i need to press this?
alright well i did
wow it shows red highlights
never thought how much i missed them
guys i need help, every time i open anything it says "failed to resolve project template: failed to descompress"
Ask in #💻┃unity-talk as this most likely not coming from your own code
so is the "Bird" part incorrect?
Then wait for an answer over there, you should not post the same question to multiple channels
No it's the birdScript variable that has the wrong type
You can, by changing the type of the variable
It will find a BirdScript just fine, C# just refuses right now because you're trying to put a square block (BirdScript) into a round hole (GameObject)
the flaw wasnt in the line we are talkign about
Yes that is correct
basically i had
public GameObject birdScript;
for some odd reason
This isn't beginner stuff. #archived-networking
ohh ty
anyone know how to fix
error CS0006: Metadata file 'Library/PackageCache/com.unity.collab-proxy@2.6.0/Lib/Editor/PlasticSCM/log4netPlastic.dll' could not be found
error CS0006: Metadata file 'Library/PackageCache/com.unity.collab-proxy@2.6.0/Lib/Editor/PlasticSCM/Unity.Plastic.Antlr3.Runtime.dll' could not be found
error CS0006: Metadata file 'Library/PackageCache/com.unity.collab-proxy@2.6.0/Lib/Editor/PlasticSCM/Unity.Plastic.Newtonsoft.Json.dll' could not be found
i been watching over hours of tutorials for the fix and theres nothing
did you remove a package like unity collab?
try closing unity, going to your project folder, deleting the Library/PackageCache folder then re open unity.
Can also just remove the library folder as a whole. Unity regenerates it.
yea true but that will be slower for em to reimport everything
THANK YOU
SO MUCH
How do i refer to an audioclip within an audio source in unity
does anyone here have a lot of experience with coding procedural generation
I tried to understand the explanation but i still dont understand how to play a sound btw if it is important my project is in 2D
Playing a sound isn't what your question was
oh yea true
i copied what they were doing and well for me it errors
there are beginner c# courses pinned in this channel, you should probably start there
https://docs.unity3d.com/6000.0/Documentation/ScriptReference/AudioSource.Play.html
i copied stuff from this link
read the example more carefully. if you think you wrote valid c# then you need to learn the basics
What you wrote there is by no means a copy of what's in the document you linked.
i didnt think that i dont assume anything as valid c# since i just started about yesterday
then learn the basics
i have been doing that
found a really nice tutorial which i completed
then continue that instead of what you are currently doing
continue? i finished it and now the dude told me to do some things on my own to finish the game even more. i made it so that if the flappy bird goes off screen that its gameover and that if you die you cant get more points. Now the next thing he challenged me is adding sounds.
you clearly did not learn the actual fundamentals of c# if you think what you wrote is valid in any way
never said that i said i copied stuff so ig that means 1 line
and if you cannot recognize why it is invalid then you need to go learn the actual fundamentals of the language
didnt think that
then why did you write it if you did not think it was valid?
cuz it was an official thing doc
you literally did say you copied it from the docs
#💻┃code-beginner message
yes but not the whole thing
So, did you get the line from the documentation or did you not?
Because the documentation has a correct line. The issue is, you did not
thats what im tryna say
The things you've changed are the things that are wrong
i wrote literally this line
no, you literally didn';t
Okay, so did you get an error on that one?
[unity 3D]
what can i do to make the player not slide off the edge of for example a cube
im currently using capsule collider for the player and i cant really use the cube collider because of no round edges and there is no collider that i can really use
the collider i would want would have a spherical top and flat bottom with rounded edges on the sides as in capsule collider but there is nothing like that unfortunately
You can use a combination of a box collider and a capsule collider
but how?
Place the capsule collider like normal and place the box collider on the lower half
they can overlap each other
but then the bottom will be a square and not round
Isn't that what you want?
wait a sec
i need to make a very professional representation of it in paint
the other way is to create a mesh of the shape you want and use a mesh collider
defenseSquares[i].button.onClick.AddListener(OnDefense);
So this works fine but how would I pass i to the OnDefense function without using anonymous functions (need to keep a reference to remove this listener at some point)
You can store the delegate for unsubscription later,
i tried and unity doesnt support custom collider meshes when using rigidbody
Store it how?
have a new component that has its own event so it can pass i
public event Action<int> myCoolEvent;
I 99% of the time do this even for just button clicks as i dont think its good design to expose the button publicly
Action onDefense = () =>
{
// do something with i
};
defenseSquares[i].button.onClick.AddListener(onDefense);
// sometime later
defenseSquares[i].button.onClick.RemoveListener(onDefense);
plz no 😆
Yeah that would work but I'd end up duplicating references in the class. Might as well have a dictionary to store those references... Is it possible to pass the int value through the unity inspector? It's actually meant to be an enum of direction (left, center, right)
Would a cylinder mesh collider work that is set to convex?
covex? what is it
public class DefenseSquare : MonoBehaviour
{
public event Action<int> OnClick;
public int index {get; set;}
[SerializeField]
Button button;
private void Awake()
{
button.onClick.AddListener(() => OnClick?.Invoke(index));
}
}
do the event yourself and store the index. Or the click event can pass itself as an arg via this so you dont even need the index to access it later:
public event Action<DefenseSquare> OnClick;
//elsewhere...
button.onClick.AddListener(() => OnClick?.Invoke(this));
sorry, im not an english speaker, i know what it is now but dont know where to enable it
I'm talking about providing the logic directly in the class for the OnClick when setting it up. If it's not convenient to do so the next best option might be to just have dedicated method for each attack and direction (attackLeft, attackCenter) etc. Was hoping I could make use of the direction enum (left, center, right) to iteratively set each one and then unset each one. It's all looking like "voodoo" however so the direct methods might be my best bet.
i dont really understand what you mean, your event can have many args including some enum? can you give more info?
ok, that should work for now, also i didnt realize its only in mesh collider
trying to show you though you can make life easier by having your own events with your own data between a button click event.
yes and convex mesh collider should work with rigidbody
it works fortunately
also is it possible to bind a key to minimalize the window?
for example use the KeyCode.LeftMeta
Not built in, it's also going to require platform specific code
anyone know how to fix my character falling through the map when i play
you can put your character higher above the ground
ok i will try
it doesnt work
i keep falling
does the ground and player have collider?
you'll need to provide some more info
so i put the guy like very high
when i do that its not on the platform fully
but if i do it a little high or medium i just fall
Like wickend said, does the player and platform have a collider?
where do find that?
i started today and it worked fine
but now it keeps making me fall
On the player and platform objects, there should be a collider component on both
y'know, considering the channel is called "code-beginner", it might be a good idea to send the !code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
qui parle francais??
hi, im want to make a circle move along a grid in a pattern like the ones below. i have made it so that the the circle moves along the grid like the red arrow just fine. however, after it's done moving and reaches the top right corner, i'd like to make it retrace its steps and move along the grid similar to the blue arrow. how can i achieve this?
https://hastebin.skyra.pw/axigevikef.csharp
go backwards? however you walk along you should add something so you can reverse the direction.
Iterate through the tiles in reverse?
anyone know how to fix my character falling through the map when i play
yes i was thinking of having a list of all the grid tiles and then iterating through them normally then in reverse but im unsure how to put them into a list for my desired order
read above
the collider thing doesnt help

how can I make this climable ?
how so
depends on how you're currently moving your character. are you using a rigidbody? character controller? transform.translate?
player controller
if using a for loop you can go backwards doing for(int i = list.Count - 1; i >= 0; i--)
I'm unsure if this is more of a math question but, i have a directional vector and a point. How would I select a random point on a circle (plane), perpendicular to that directional vector?
just add a trigger to the ladder. in the code check if the player has entered a ladder trigger and then have them move up. there's a lot of ways of doing ladders and it compeltely depends on how you're movement works
How did you achieve the path in the forward direction?
amen
How can a point be "perpendicular" to direction
the circle/plane is perpendicular to the direction
i linked my script in my original statement but basically i made the circle go right until it reached the right border of the grid. if it did, i made it go up by one tile then set the movement direction to left. it then goes all the way left until it reaches the left border, then it goes up by one and sets the movement direction to right and it repeats until it reaches the end
i add the moveDirection to it's starting position every turn and lerp its position to that for it to actually move
Do you mean a point *along * the vector?
And that would have to be a ray, not just a directional vector. I.e. we would need to know the starting point at the beginning of that arrow in addition to the direction.
So can you not just to the opposite? Move to the left until it hits the border, then go down one tile and reverse?
Eh pick random point within circle then transform it to space you want?
oh that would make sense, thank you
yes but thats what im a bit confused on, because i already have logic to check if the circle is at the left border and if it is, it goes up. how do i use this same logic to make it go down when its going in reverse?
Have a bool IsReversed that you use to determine if you should go up or down when you're at the border.
Hi. Im new to unity and should i learn all of c# or no?
You'll need to learn C#
All of it?
do you think christians memorise the bible?
All of C# just doesn't make sense
Can someone give a tutorial just so i know?
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
sorry to interrupt, but im having an issue on one part of my hw-
I cant get the input part to show up- and im a bit stumped on how to make it appear
What are you seeing on your end
Show your Touch Raycaster code
one sec
Do you have any compile errors
does it show up with debug?
only that it's similar to another one, but my hw told me to copy it from that to this new one, and just change some debug words around
Let's check the easy stuff first before going that far
using UnityEngine;
public class LevelInputTester : MonoBehaviour
{
[SerializeField] private InputHandler _input;
private void OnEnable()
{
_input.TouchStarted += OnTouchStarted;
_input.TouchEnded += OnTouchEnded;
}
private void OnDisable()
{
_input.TouchStarted -= OnTouchStarted;
_input.TouchEnded -= OnTouchEnded;
}
private void OnTouchStarted(Vector2 position)
{
Debug.Log("TouchRaycast: Started: " + position);
}
private void OnTouchEnded(Vector2 position)
{
Debug.Log("TouchRaycast: Ended: " + position);
}
}
If you have any compile errors, you have to fix them
debug isn't that complex, it just shows the private variables in the inspector
i don't think it was a compiling error , just a warning
This is not Touch Raycaster
Show your console
Your class name
... im an idiot- let me swap that rq
Unless it's Unity 6, in which case that's no longer necessary
it is in fact unity 6-
yep that did it, ty
Huh, that's supposed to have been fixed in 6. Guess not
anyonebody knows how to fix going through the map after spawning
That's not something that normally happens, so you'd have to share details about your setup.
presumably you need to double check your physics setup
and make sure you're not spawning below the map
i am not
i am on the map for like a second and then i just fall down to the abbys
it didnt happenn last time when i played
but now it does
You need to share details
can i show video?
Sure but it would also be more valuable to share the details of how your physics are set up and your movement script
