#💻┃code-beginner
1 messages · Page 643 of 1
Parent the gameobjects right?
Yes. What else can you parent?
Heya, was following https://www.youtube.com/watch?v=NsSk58un8E0 tutorial and got stuck on making the character move, I probably did something stupid but when i debug test if i have the correct directional input it does show the correct direction (timestamp starts @ 9:10)
This one is a bit different than the last couple devlogs. I thought it would be fun to share a longer video where I actually make a thing. Might be super boring? Idk!
Links:
https://www.rorydriscoll.com/2016/03/07/frame-rate-independent-damping-using-lerp/
https://youtu.be/7daTGyVZ60I
https://youtu.be/tYc1yUt0IeA
https://github.com/TheAllenChou...
hi i am new visual effect graph . How can i play only system (6) IMPACT FLIP in my scene
Update, seems like the problem is bigger than i though, my player character itself is not rotating
which is a huge issue
hi
how can I make camera waypoint in unity
like chase mission.
Hi I'm using unity version 2023 and I'm quite near a project deadline, how can I get the old navmesh ?
In most cases, a "waypoint" can be represented as Vector3 type, so you could store a list of Transforms and use their .position to know where to move your camera, then you could use Update or a coroutine or something similar to handle moving your cameras transform to each waypoint at some rate
👋
I'm dragging and dropping a material onto a terrain but it doesn't work. How can I use a material on a terrain?
This is how my material looks like
You should keep your question to one channel instead of crossposting, you may not get a response right away but itll be less confusing for anyone who is able to help with your question later on
I don't know for sure so this may not be helpful, but you could try downgrading by installing a lower version through package manager, but again, I don't know for sure so I'm just pointing out what I think has a chance to work.
if it's code related, I don't see why not, we don't have a specific channel for testing anyway
This is super basic
But I'm having some trouble instantiating a prefab at a parent's location
I have to create a speech bubble on an enemy but I can't figure out how to spawn it at their location
👋
I want to draw a white dot crosshair circle. I think I should do this by code because sprite would be pixelated in small sizes. However when I tried to do it by code, it also turned out to be pixelated. How can I draw a white dot crosshair circle in the center of the screen?
you can get the center of the screen with Screen.width * 0.5f and Screen.height * 0.5f.
not sure how you're drawing the sprite but https://docs.unity3d.com/ScriptReference/Graphics.DrawTexture.html to draw the sprite
it would be much easier to do this with unity's UI though, not sure what you mean by the sprite being pixelated in small sizes
is there a way to lock the camera rotation of a player when the cursor is visible?(i tried using an if, but that did not work)
is there any way to create a coroutine that returns a type?
for example a coroutine that returns a string
Use an async function instead as these can return something
for some reason the camera can rotate even with the cursor unlocked
even though i specifically requested it to not work while the cursor is unlocked
figured it out, at least temporarily
👋
welp i did not figure it out
When I crouch walk to left my camera seems fine, but when I crouch walk to right I have this issue. Is this related to my animation or my player controller (which handles camera movement)?
anyone know why the code does not set my walkspeed to 0?
void Moving()
{
if (Input.GetKeyDown(KeyCode.Escape) && moveSpeed == 0.125f)
{
moveSpeed = 0;
}
else
{
moveSpeed = 0.125f;
float currentSpeed = Input.GetKey(KeyCode.LeftShift) ? sprintSpeed : moveSpeed;
float moveForward = Input.GetAxis("Vertical") * currentSpeed;
float strafe = Input.GetAxis("Horizontal") * currentSpeed;
Vector3 move = transform.forward * moveForward + transform.right * strafe;
if (move.magnitude > 0)
{
rb.MovePosition(rb.position + move * moveSpeed);
}
onGround = Physics.Raycast(transform.position, Vector3.down, groundCheck, groundLayer);
if (Input.GetButtonDown("Jump") && onGround)
{
rb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
}
}
Are you using a mobile phone to create your game
No, why?
The picture is not like that of a pc
Yoooo I've tried to delay a function inside another script with this code:
StartCoroutine(respawnScript.RespawnPlayer("p1"), 0.7f);
but the console gives me an error
I thought you were replying to this, my bad
"error CS1503: Argument 1: cannot convert from 'void' to 'string'"
Try a different key (escape causes the application to lose focus in the Unity Editor.
What does your respawn script look like?
Place some logs to see if the lines of code are being executed
{
if (player == "p1")
{
p1clone.spawnedP1Go.transform.position = respawnPoint.position;
}
if (player == "p2")
{
p2clone.spawnedP2Go.transform.position = respawnPoint.position;
}
if (player == "p3")
{
p3clone.spawnedP3Go.transform.position = respawnPoint.position;
}
if (player == "p4")
{
p4clone.spawnedP4Go.transform.position = respawnPoint.position;
}
}```
this is the RespawnScript that has the function I want to call
switched to C and something is causing the stuff to spam
Do I have to put "IEnumerator" instead of "void"? ??
finally i managed to get the camera stopping to work
uhh, why does my & open a call stack instead of typing &
if you want it to be a coroutine, sure, but that doesnt' really make sense
the thing calling it should be a coroutine instead, and it would yield return new WaitForSeconds(0.7f); before calling the respawn component
also, perhaps each player should be able to respawn separately instead of it being a central thing
I've been stuck in an issue for an hour now with the
Transform.lookAt function.
It automatically adds 90 to y axis rotation and I have no clue why
I can showcase the script in a minute
Hey
What's the best way to check if a player is grounded?
It should work even for mountain slopes
varies from person to person. I would go with a cast, like ray,box etc.
A raycast?
thats a cast sure, it may be too thin but does the job
hey guys, its me again lmao. Im tryna make a button on the pause menu which respawns the player. The button is set to interactable but the function i want it to do doesnt show as an option. I also then tried coding the button and come across the same. i will attach code to the manual button and the respawn cs and also the proof that the function doesnt show on my options
show code + inspector for the button
the function is private
why do you expect it to showup in the dropdown if its private
which sorry
what kinda button is this , are you talking about the Button class?
show the inspector for the button requested
if you are trying to use MBsOnMouseUp that only works on colliders / physics
ok. You should not name the function OnMouseUp cause its already a unity function
https://docs.unity3d.com/6000.0/Documentation/ScriptReference/MonoBehaviour.OnMouseUp.html
anyway regardless, its private so its not gonna show up in dropdown
i made it public it still isnt there
show what you dragged in the slot
so did you do this.
if its public then it will show up. Also name the function something else to remove confusion with unitys MB
and Save.
let me see what the dropdown shows
i cant take an ss of it it disspeaers can i use my phone?
sure in this case..
doesnt seem you dragged the script from the inspector but from the Project window..
i don't understand sorry, can you re-word?
You need to drag in an object with the script on it not the text file containing the code
Also, https://screenshot.help/
it was ok in this case cause it was closing their context menu
I can take an ss, but it's a system pop up and that's blocked to be screenshotted on my cpu
there you go
now you dragged the gameobject / instance of the script
makes me question your "Yes" here #💻┃code-beginner message
I thought you were asking if I put the script in the box
script is just a text file. The one on the gameobject is the actual Instance of that component (script)
lovely how you cropped the error
well take a look at this image carefully
the print works because it is before the line error
what have i done wrong?
it should run a function, that fucntion should respawn the player no?
aha i see
it wont let me put the player in that box to respawn them though now lmao
it will now, and now i have loads of errors
well you might need to take the basics again then
Null Reference Exception is the most common thing you will be encountering and should learn how to debug / dissect it
Null reference means it tries to access something on a Null object
yeah
ok so line 16 complains about Respawn.RespawnP();
how can you access RespawnP() if Respawn doesn't exist to be accessed
it does exist, that is a section of code
no that just tells the computer you want to use template like a, Class of type Respawn
(this class / object has these specific functions you can use)
the computer has NO IDEA which ONE specifically you want to run those on
thats why we do Assignment
respawn is class, a type and in this case a component (monobehavior)
the computer doesnt care about the textfile itsellf
You have to tell it which specific Respawn you want , aka an INSTANCE of an object
as mentioned earlier, an instance doesnt exist unless you create one. In Unity COMPONENTS are INSTANCES that get created when the script is put on the gameobject
ive done this
but you didnt tell it which Respawn Component , the instance you want to use
idk what exactly ur showing here. you linked it but your error says you didn't so you either using the wrong prefab or you have a copy
im unsure
dont show the prefab, show the actual one thats in the scene
it send and recives
complain no object given
when i gave it one
i included the game screen to show i clicked the button
i might be being stupid... im trying to rotate to make a text sign face the player, however i dont want it to tilt up and down. so im using the quaternion face command to get the right angle and i want to turn that into a euler angle to then clamp the downwards tilt out.
if there is a A face B command in euler that would solve the issue, or if i could convert the quaternion to euler angles? anyone got any ideas
quaternions aren't euler angles
eulerAngles is a Vector3, but target is a Quaternion variable
try Quaternion.EulerAngles()
it's not that you cannot convert to eulerAngles, it's that you cannot store a Vector3 value in a Quaternion variable
yes
oh im used to python with non explicit typing where u can just reuse variables like that lol
its like trying to cram a cube into a circle hole
working on a vr game menu idk whats wrong with the code https://paste.mod.gg/vvcagfgirgwh/0
A tool for sharing your source code with the world!
welcome to strict typing where things actually matter and make sense
and not everything goes into the square hole
do you want the errors it gives me or nah
I assume public;ic is an error
yea i look in my console and its says ; is an error
it tells me its expected twice and the other error is invalid token
its better with explicit typing bcs it does actually like... make sense once ur used to it, and it means u dont do weird shit like
"**input **= (string)
**input **= list(**input **split into characters for each entry)" if ur messing around with text manipulation. perfectly fine in python
yeah python is an outlier in that
js has dynamic typing too and doesn't really do that
in fact most advice says to default to const in js, and avoid let if possible
when data scientist make a language 🥵
i don't think lua really does that either, but i haven't done much lua yet.
Thanks! It was that i didnt even see it lol
your !ide shouldve told you
👇
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
just got a new pc, havent added it yet
having a configured IDE is required to get help here
How does kinematic movement work, i cant find a guide
I have a 3d game but it is purely left and right movement
its been asked before https://www.google.com/search?q=kinematic+movement+unity
Huh
save your code because the error is different than what you actually have
hmm lemme check
c# is case sensitive
ye ye ik
im a beginner
never programmed b4 so im just following tuts rn
also if you are still using sublime then stop and use a supported IDE that you actually configure. because as i just pointed out to someone else, having a configured !IDE is required to get help here
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
mono hasn't been supported for years
oh rlly
hright
i just like how sublime looks
bruh please make your message 1 instead of a bunch of vertical
sry
ok so how do i reference the other aspect that isnt camera.main.aspect like the height
which height are you talking about here ? the screen ? the frustum ?
screen
you meanScreen.height?
did you google it
then you didn't google it
or you just skimmed the results
i did but whatever u say
You didn't, and please stop wasting time.
right i didnt search that
is there a channel for 3d modellers
How did you not search the _literal question you used in discord _?
Even after saying you did. Again, waste less time. Thanks.
no but i wasnt thinking and said liek how to get the second aspect ratio or smth
the second aspect ratio.... what even
right guys
an aspect ratio is the ratio between the width and the height
cameras aren't 2.5d in unity
idk
Mr President the second aspect ratio has been searched
yeah
we have all the time in the world
you'll just waste more time if you can't think straight or communicate clearly
right well im sry
This is my movement script currently
How do i let that if statement at the end check if IsGrounded == False, cause currently it says that error
you need to get your !IDE configured 👇
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
methods need ()
() where
configure IDE it will show you where
also, stuff about the screen and stuff about the camera are different things
the code here is for world-space (unity units) width, but the height of a screen would usually be in screen space (pixels), as Screen.height gives
the height of the camera in world-space units is Camera#orthographicSize * 2.
yeah thanks
I have a jump system and I have my jump animation's root transform position (Y) baked into pose. However when I jump, my character collider almost doesn't go above at all. It does, but it's very small. It's not aligned to the jump animation at all. What should I do to fix this case?
This is my player controller: https://pastes.dev/qqeukmOmF2
If I don't bake root transform position (Y) into the pose the capsule collider somehow works, but my falling animation plays twice.
i set that up i think, but it didnt do anything?
i got the VS code plug in
and i went to the package manager and enabled it
because Youre not actually jumping in the code, you're just using animation
I'm applying force here, this is called in Jump animation's events
at no point do you actually call the JumpAddForce method
why is that in the animation event?
Because that's where the character in the animation stops touching the ground
well the guide thing says "You are now ready to start editing with Visual Studio Code"
read this entire page: https://unity.huh.how/ide-configuration/visual-studio-code
did you put the actual correct animation clip that has this? and are you sure there arent transition skipping it?
Do you mean the Jump animation?
wahetevr clip has the animation event
If so, yeah, also I can assure you that function is getting called, I have did a Debug
If I don't tick "Bake Into Pose" here (Jump animation), the capsule collider moves correctly as shown in the video, but Landing plays twice as you can see in the Animator tab
this all seems more like an #🏃┃animation issue rather than a code issue
is this .NET SDK?
do you have Root Motion enabled
ah of course, you already posted it there and decided you should crosspost
It might be something in the code, that's why I wrote here, I also wrote there and got no response so I tried to see if it might be related to code
don't crosspost
Mentioned why I did that in the message above
I do
no
no, that is an extension that can install the sdk. did you even fucking read the page i linked?
crossposting is still against the rules
actually the page has the link here https://unity.huh.how/ide-configuration/visual-studio-code#if-you-are-experiencing-issues
If your IDE isn't providing autocomplete suggestions or underlining errors in red, then it needs to be configured.
I did. and i looked at vs code and it says i have a thing that Installs and manages SDK. its pretty fucking reasonable to assume that means i have it
that overrides code movement iirc
as it uses transforms moving in animation to move it
it's not particularly reasonable to see "install tool" and assume that's the sdk
If I disable it the character somehow teleports out the earth, it bugs out
Thats reasonable to assume for me since i have never done this before
install tool is the thing that installs and manages sdk
and i see a thing that says it Intalls SDK, thats fair to assuem i have installed SDK
sdk isn't an installer
i bet you didn't even bother looking at vs code's output tab which also likely gives a nice red icon when there's an error
I DONT KNOW WHAT THAT IS?
I AM NEW TO THIS
that doesn't mean that thing itself is the sdk lol
THIS IS THE BEGGINER CHAT
well try removing the code/disbaling and narrowing down if the issue is the code
screenshot your entire vs code window
As in my code? the extensions tab? what?
the entire vs code window
do you know what a window is
the entire window mate they literally said it
on your pc
this is like computer usage nothing to do with code
yeah which fucking window
VS CODE
the vscode window
And vs code has different pages in it?
these are tabs, not windows. you said it yourself
which page do you need a screenshot of
no those are tabs
red means error
those are tabs
window means what Windows defines as window, the entire frikken app
well sorry im new to this and asking questions
you guys are hear to help, not here to be assholes to someone trying to learn
mate we get you're new but there is a bit of brain work needed on your end
this is Game Development after all...something already complex in itself
ok so if you don't know something, ask instead of assuming
i do realize that's kinda hypocritical since you asked if the install tool was the sdk, but.. it's an install tool
Install tool, that installs sdk. i was asking if that means i have the sdk
if a specific view within vs code was required then it would have been requested. learn to follow instructions and think for yourself.
learn how to not be a dick, and when someone asks you to specify, just specify instead of repeating yourself
cool, that wasn't what you wrote, so we didn't know that that's what you meant. glad we could clear that up.
i did specify what i needed. i needed the entire vs code window because you clearly would not have known what i meant by the status bar. now go look at the output tab, install the .net sdk which you do not have, and fuck off
dont tell me to fuck off when im just trying to learn
christ chill
if you dont feel like teaching then leave this chat?
not the vibe, apparently
@sudden quiver where other people I helped with the same exact issue and we dont repeat ourselves
https://discord.com/channels/489222168727519232/1358142843629207622
https://discord.com/channels/489222168727519232/1358591416728682601
Check these threads might clear up further confusion
anyways !ask 👇 and https://nohello.net
: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 i have the .net whatever and its highlighting my code that has an error red
show that
it should show the error message if you hover, and in the Problems tab
which is where?
press ctrl+`, it should be beside the terminal tab
this is just giving me the same error that unity gave?
now this is a straight up c# issue.
using Method vs a methodgroup / delegate when you omit the ()
yes, but it's actually telling you directly in the source code
this lets a tool tell you where exactly the error is instead of us having to translate the error for you
granted we might still have to translate error messages if you're unfamiliar, but this should help simple mistakes
im not sure how to refrence bullet script on line 26 so it will fire
here is bullet script
flashbangjesus
good lord
!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.
I think I'm blinded
ya
that is a screenshot of visual studio not vs code, they are completely separate programs
https://unity.huh.how/references/serializing-component-references
check step 3
3. Access the member you care about
here
anyway, you need to use the variable you have not the class
wym by the variable i have though
or use GetComponent on other if you need to get the instance that was collided with
i mean read your code and look at the available variables you have already declared
yeah
if you don't know what a variable is, then stop what you are doing and go through the beginner c# courses pinned in this channel
private SomeScript someVariableForSaidScript
[AccessModifier] [Type] [AssignedVariable]
i do know what a variable is
then its time to do c# beginner courses
great! then surely you've looked at the variables you actually have and use the one that exists, right?
variable is where we can to store something that holds values etc.
If you want to call Shooting, you should call it on the variable that holds a reference to your PlayerProjectile object, not on the PlayerProjectile class itself
This is my movement code and it like works but its like laggy? and you cant jump if you are moving (you get like stuck in the floor and it doesnt let you off the ground)
!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.
No
Be mindful, if someone requests your code as text, don't send a screenshot!
Yoooo I want to make a CineMachine camera with TargetGroup (2D) and I want that by script add a new target to the group using a prefab's transform but it doesn't work
A tool for sharing your source code with the world!
void Start()
{
cam = GameObject.FindWithTag("Cinemachine");
cam.GetComponent<CinemachineTargetGroup.Target>();
List<CinemachineTargetGroup.Target> targets = new List<CinemachineTargetGroup.Target>();
targets.Add(new CinemachineTargetGroup.Target {trans, 0.8f, 1f});
{```
and it gives me this error:
Cannot initialize type 'CinemachineTargetGroup.Target' with a collection initializer because it does not implement 'System.Collections.IEnumerable'\
why are you manually changing positions instead just using a rigidbody or character controller
i was talking to someone last night and said i had rigid body movement but it felt super like floaty and bad and they reccomended i use Kinematic
even if you used kinematic you're not moving the actual rigidbody
wdym
does anyone knows how to solve this??
i found a youtube guide and it said this was kinematic, is it not?
youtube guide was shit then
Would character controller be better than kinematic?
you have a public Rigidbody rb; and you're not even using it
yeah that was from my previous code that i deleted
its similiar to kinematic and easier to use sure
there is no "better" in terms of use. Some fit for certain cases and some dont
well im wanting to make a fighting game so like movement is pretty important to feel snappy and good, what would you recommend?
both can be coded to be "snappy"
its all about doing it correctly lol
there are also premade controllers that already solved certain issues like KCC etc.
what does Kinematic like mean? i just know its a setting for rigidbodys
kcc?
kinematic meaning not affected by external forces
gravity included, they can't be pushed by a dynamic rigidbody etc.
cause rigidbody uses unitys physics which is why it feels weird and floaty?
somewhat
they are tuned to be close to realistic, games are not meant to be realistic so things need to be tuned
(Unity didnt make the physics)
how would i make rigidbody not feel floaty?
or would it be better to just use character controller or kinematic
idk what you mean "floaty"
increase gravity, give mroe force on jumps etc
how do i increase gravity?
ah, my game is 2d though so i dont think that would work
well its not 2d
its 3d, but locked to 2d
not a code question. and that's just a gizmo, you can disable gizmos to hide them
thanks
note that gizmos will also only ever be drawn in the editor as they are just for debugging purposes
ty, i basically doubled gravity and it feels alot better
Grats!
now i have a problem is i get stuck to walls when i like jump
welcome to the most common thing that happens in unity
not on the walls
remove the players friction?
if you look "stuck in wall when moving rigidbody" you see plenty of different solutions
the dirty quickfix is having no friction on player collider physics material
its like if i jump and contiune to hold into the wall i get suspended
well i only have 2 walls
oh wait i also want to disable airmovement anyways so maybe thatll fix
ill do that first
putting on walls isnt very scalable in the long run
@sudden quiver You should get in the habit of googling your issue first and if you can't find any results or are still confused, ask for help.
Being able to google your issues is a skill in itself and a large part of any development
wdym? my game will only ever have 2 walls so like it should be fine shouldnt it?
well me disabling airmovement worked fine for now, ill roll with this till i have more problems
thats why its specific from project to project
if that doesnt change its one thing, but if ever did something extra to track
Why the curly braces
Wym??
I think the error is because youve got an incorrect type for the listList<CinemachineTargetGroup.Target>
https://docs.unity3d.com/Packages/com.unity.cinemachine@2.3/manual/CinemachineTargetGroup.html would be nice if the documentation for this was a bit more clear
the compiler thinks that they are trying to create Target as a Collection rather than the struct it is
because they put { } instead of ( )
but even still doesn't seem the Target have constructor with 3 params anyway
On the line your error is. Why curly braces
it's a class not a struct, and they appear to be attempting to use object initializer syntax
surely the curly braces is a secondary issue, Cannot initialize type 'CinemachineTargetGroup.Target' with a collection initializer to me sounds like the actual list hasnt initialised, meaning the incorrect .add with the curly braces isnt an error that the compiler has managed to reach yet
sounds like the actual list hasnt initialised
that is incorrect. it seems the compiler thinks they are using a collection initializer syntax rather than object initializer syntax,though they are mostly identical in appearance so idk why it would think that
unless this isn't even where the actual error is
i'm still not convinced they are using a configured IDE
Assets\FIrst Person\Scripts\InputManager.cs(7,25): error CS0426: The type name 'onFootActions' does not exist in the type 'PlayerInput'
i cant figure out this error im following a vid if anyone wants to have the link pls how to fix?
No, it's because they're trying to use a collection initializer syntax for something that isn't a collection. Like, how you would create a new list with things in it? That syntax only works if the thing is actually a list
!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
what?
read the bot message
Configure your IDE so you get autocomplete and syntax highlighting
having a configured IDE is a requirement for receiving help here
i dont know what that stuff is
Yes, that works, if you specify a variable name and value. But new Thing {a, b, c} is a list initializer
new Thing() {foo=a, bar=b, baz=c} would work
right but you specifically pointed out the curly brackets instead of the missing field names
Because most likely they are copying from a tutorial and put the wrong character down and I'm trying to subtly hint to go take another look at that line
visual studio is the IDE, you havent configured it, which makes it far harder to work
holy hell that targetgroup thing is wild
not even a constructor for that with 3 vars ?
Boy they don't make anything convenient to set in code do they
https://github.com/Unity-Technologies/com.unity.cinemachine/blob/5a505b2fbaf79a1bec6d2b36f4171b69eb76636f/com.unity.cinemachine/Runtime/Behaviours/CinemachineTargetGroup.cs#L249
hmm this creates the Target for you and adds it
If there's one problem with Cinemachine it's that they seem to be really averse to you doing things in code without the inspector
at least it is getting better, with cinemachine 3 they finally exposed the option for multiplying your input by deltaTime so you don't have to manually divide it by deltaTime or write your own input processor for it
ya, i'll usually code my containers to do all the stuff i need and tracking and w/e.. cinemachine usuallly just sits at the lowest level of my hierachy..
^ speaking of...
anyone know how to contend w. this error.. lol all im changing is the FOV
extra clicks in resentment
do you have the "Save During play" on ?
in the component?
cinemachine yea
um let me check 👀
iirc that was a thing on virtual camera
doesn't seem like an error, more of a confirmation that you do want to keep the settings you've manually changed while in play mode due to the Save During Play option enabled
ohhh im an idiot
thank you nav
yup, box that was it
i didn't even notice that was a thing
is that a new thing with cm3.. ❔ .. i just dont remmber it
its always been there
i don't think so, i think the confirmation might be new but i'm not super sure about that. i know the save during play attribute has existed for a while
I guess 3.0 gives you that in editor warning
tbh I never left Save During Play on 2.0 to notice if it did or not
yea, i dont recall.. tbh i upgraded cm3 without looking a whole lot at the new editor setups
i jsut figured out how to assemble the cams and stuff and went on my way lol
I saw body Transposer and all this stuff got split into other components immediately panicked and switched back to 2.x
I couldnt find the usual things easy
priorities and toggling cams transition like they used to, im sold
rofl.. cmon now
red cinemachine cam scares me now
my project blows up
I just need to check the docs again fro 2.x to 3.x transition, idk what happened to some components got renamed too
yeah at first glance cm 3 seems more complicated because everything has been split up more, but it's honestly a lot more intuitive now that things are actual components
Yeah this is what it is, just at glance, once i read the docs again it will probably be better
iirc there is a video guide on Unity Talk in the past i need to revist
I usually do but since those projects were old this sentiment hit home now especially lol ..
While it is possible to upgrade an existing project from CM 2.X, you should think carefully about whether you are willing to put in the work. It might be better in many cases just to stick with CM 2.X, which will continue to be supported for a while in parallel with CM 3.X. If you do choose to consider upgrading your project, this guide will give you some pointers to make the process smoother.
https://youtu.be/h7gpymxdLrQ?t=68 what i havent managed to figure out is how you'd create a third person camera, with the newest version of cinemachine, where you can actually tilt the camera up and down via the vertical arm length
In this video, we'll show you how to create a third-person follow camera in Unity using Cinemachine. You'll learn how to handle camera control with mouse input, and solve common issues like the camera going behind walls or obstacles. We'll guide you through setting up camera transitions and camera shake with step-by-step instructions and practic...
all its ever done for me is have the camera point directly to the arm length, and moves up and down with it, so the camera never actually tilts up and down
the actual target the camera points at has to be rotated for the third person camera to also rotate
yo im trying to make dark fantasy game. and i need help. im new and i wanna make small but great game so if yall can help dm me
if you need specific code help , otherwise collab post goes in !collab 👇
:loudspeaker: Collaborating and Job Posting
We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
• Collaboration & Jobs
i wanna work with other people but if i do im not gonna do anything cuz im new and i dont know 95% of the unity
i just wanna do test game. for the future
so you want others to do the work for your benefit only ?
i just wanna do test game. so i can learn
not serious game
to release or smth
i wanna learn from this mini games
realistically no one is going to do that for you unless there is incentive to do so
if you want to learn then just learn
noo. im saying that i dont want to.
thats the problem idk where to learn from
start here on !learn pathways
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
its a starrt. You're not going to make your dream game right away but you can get to it.
ik how to put textures and make cahr and camera and like that for now
im gonna try to learn more
well that has everything you need for the most part
code included
there are also more resources in the 📌
yo i got 1 more question
how to i make my game look 2000s style . blury and choppy .
or is that just from textures
start by learning how to make a game first before choosing a specific art style
ik how to make char map and that already
like basic things
textures and staff
way to ignore what was said
🫥
which 2000s is blurry and choppy ?
Little strong here
2000s I think Ps2 / gamecube / xbox which looked really good
like old tv style. like shrek game
or lunacid
or dread delusion
its not old but it has same style
its just the quality of the texture that usually give it a certain look, and how the poly are stylized
people were also a lot creative back then because of hardware limitations
i got old blocky textures and im gonna try to make something rn.
yo how do i create water in my game
not code question
if ur making swim / buoyancy then yes code would be relevant
they meant not a code question because this is a code channel. but you should stop worrying so much about specific features of your game and start with learning the fundamentals as has been pointed out to you multiple times.
nah js for looks. like big mountain with sea around . u cant go in water
yea you're jumping way ahead w the looks before even learning the editor / baics
ohhhhhhhh
then where the fk do i ask
for now i wanna create map and than palyer codes
the " targets.Add(new CinemachineTargetGroup.Target (trans, 0.8f, 1f)); " ???
I put it like that bcause I saw a website that did that too
btw, here I corrected it
but now the error is:
CinemachineTargetGroup.Target' does not contain a constructor that takes 3 arguments
that's still incorrect. show the website you had copied the original code from because i'm 100% certain you missed some important stuff
does anyone knows how to solve this?
https://discussions.unity.com/t/control-targetgroup-via-script/686473/4
I copied the last response
yes, notice how that has extra stuff you didn't copy
when using object intializer sytax you need to include the field/property names
wait, if Target isnt a struct, why have they written
targets.Add(new CinemachineTargetGroup.Target { target = theTransform[0], radius = 0.8f, weight = 1f });
instead of writing
targets.Add(new CinemachineTargetGroup.Target() { target = theTransform[0], radius = 0.8f, weight = 1f });
that's the same thing
you can initiailise a new class without () ?
or construct, proper terminology eludes me 😆
don't think so
if it has no constructor or a parameterless one, yes you can omit that when using object initializer syntax
i might have done that in a few occasions without ever realizing, instinctively, i think its something id always do (using () that is)
here is an example of both working. where the () is included when initializing a class that has no ctor and where it is excluded when initializing one that has a parameterless one
https://dotnetfiddle.net/aEerWM
it is not optional when the object only has parameterized ctors though
i think what it is for me is that ive always associated () with a class, but structs i dont tend to use constructors in
seeing var y = new Test2 { x = 1}; my brain goes "thats a struct"
funny how pattern recognition works
Hi, i did this code for a parallax for each image of the background to move, but for an strange reason is jittery and flickering, why?
using UnityEngine;
public class NewMonoBehaviourScript : MonoBehaviour
{
private float startPos, lenght;
public GameObject cam;
public float parallaxEffect;
void Start()
{
startPos = transform.position.x;
lenght = GetComponent<SpriteRenderer>().bounds.size.x;
}
// Update is called once per frame
void Update()
{
float distance = cam.transform.position.x * parallaxEffect;
float movement = cam.transform.position.x * (1 - parallaxEffect);
transform.position = new Vector3(startPos + distance, transform.position.y, transform.position.z);
if (movement > startPos + lenght)
{
startPos += lenght;
}
else if (movement < startPos + lenght)
{
startPos -= lenght;
}
}
}```
Is this script what the background/parallax image is on?
I'd start debugging the values to make sure they aren't erratic first off, and if the values seem fine then try sticking it in late update perhaps
yeah this could be an issue of the object updating before the camera does, and since it relies on the camera's position it may appear jittery as it is updating a frame too late to be correctly in line with the camera's updates
usually I see this stuff with lerp too so the cut between directions isn't too instant which helps bring down some of the jerkyness
yeah could smoothdamp or lerp the position so it doesn't appear jittery
oh, but how do i do so?
by either using Vector3.Lerp or Vector3.SmoothDamp
it says Vector3 doesnt have a type called Lerp or SmoothDamp
what is the exact error message
what i said, without the or
"the name of type "Lerp" doesnt exist in the type "Vector3"
they are methods, not types. you do not new them
huh?
look at the documentation, there are examples
i discovered that the
else if (movement < startPos + lenght) was actually
else if (movement < startPos - lenght)
and the jittery leave, but now i have another issue, the screen doesnt reset propely, i mean, when i get out of bounds it should reset due it being infinite, but instead the background glitches
why
well you have an error you have hidden, have you confirmed it isn't related to that
i dont even know what they mean
editor bugging out
can someone help me? ive followed a tutorial on how to make crops and it keeps deleting itself after it fully grows, please dm me
no one is going to DM. Post the code and relevant video you are following. Either you copied wrong, video is bad or both
hey
i need some help on unity
im trying to get this in unity, but need a mono file. I used visual studio 2022, how can I get this to work?
How to properly post large or inline !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.
@hallow rock you put emojis in your comments?
how do you put the emojis in there?
im not sure, jusr helping my friend.
no it isnt
and helping him do it.
ight, im tryna add haptic feedback to my vr fps game and its giving me two errors, my scripting software isnt pointing it out to me any help? https://paste.mod.gg/srxwdqlarfmr/0
A tool for sharing your source code with the world!
asking for help with ai code isnt allowed here
these are the two errors
mainly because most of the time its broken beyond repair, the person posting it has no way of ever understanding what it actually is doing
its all around not worth the time
I dont think its ai
with a trained eye, its very easy to spot
what do you even need help with
how to get my code onto a mono file?
yeah its creating a ton of not needed strings
by making a .cs file?
arleady did
so what is not working
that wont help me
nevermind it fixed
u are making a gtag game?
all of them are the same, they all add horror, anyways this is not a place to chat, its for coding help, so i guess goodluck
btw if the link in the code you sent was a real url, you might have compromised yourself
that looks like some kind of token
bruh it is
generally when posting code for any kind of bot youre writing, anything that uses an api. you want to omit any private data
id take a look at the channel, i wonder if somebody could be able to post using your bot
I've got a basic script for picking up and moving objects that I mostly got through a tutorial but I want the object to turn to face the camera when they're first picked up while still doing it via rigidbody to make it get blocked if there's something in the way.
TLDR; is there a way to make a rigidbody quicky spin to match a rotation without overshooting that rotation?
MoveRotation
i dont know api stuff too well, but i know that i shouldnt be able to know the name of the channel your bot has access too 😆
make a new api key / webhook
although this is really meant for kinematic bodies which aren't stopped by other objects
Is MoveRotation worldspace or localspace?
world, just like pretty much everything else on the rigidbody
For some reason it isn't working. It'll just not rotate it unless I just don't move my mouse or anything around for like a 5-10 seconds (sometimes longer) then it snaps into place.
where the logs at
I'm finding some conflicting info on AddForce, I thought with ForceMode.Force and ForceMode.Acceleration you did need to use fixedDeltaTime but I just read a couple of forum posts saying that AddForce already handles that.
Is this true?
you should not be multiplying your forces by deltaTime, all physics should be handled in FixedUpdate which is already on a fixed timestep and those forcemodes mentioned do include time in them as well
Hello where i ask my question on unity ?
Ah nvm I think the kinematic thing kinda makes it not work.
Is there a way to make the object ONLY rotate with torque? Because with torque I can't freeze it, but also without being frozen it justs spinning all over the place.
i have no idea what you are asking with that last bit because it doesn't make a whole lot of sense
If the rotation is frozen I can't rotate things using torque, but if there's no torque if it gets impacted in the right way it just starts spinning around in the air.
why are you trying to rotate using torque if you want it to attempt to rotate to a specific rotation?
or do you plan to calculate the exact amount of torque needed to do that factoring in things like drag/friction?
I want it to get blocked if there's anything in the way. So if like reaching the desired rotation would cause it to clip through the floor/walls/other props it gets blocked.
And just using rotation causes it to clip into stuff
well yes, just assigning the rotation does not move it in a way that would respect other colliders
Oh well I gave up and used and it works. I'll just try and figure out everything it did to learn.
hey everyone,
when i'm itterating over all keyValue pairs in a dictionary, how do i remove an element without causing a error during the itteration foreach loop?
Well you usually shouldnt be iterating over a dictionary but in a list you can either do it in reverse, or store which elements to remove then do it after iterating
Reverse for loop is the common way
the problem is my dictionary has random keys so i can't use an incrimentor to get the values...
storing the keys during itteration adn then removing them after will work for me..
but you said i shouldnt be itterating over a dictionary? how should i do it if i need to store a gameobject along with a key to keep track of it?
Dictionaries arent ordered, I mean you can definitely iterate through it but it's just odd to do if you arent using it purely for what a dictionary is.
A list with a class containing the object and key should be fine
I don't know what the random keys or "incrimentor" really mean here or why this stops you from using a list
i have alot of items that are stored by Vector2Int locations. i use this dictionary to see if one already exists in that location already to prevent duplicating items in my game. however, i am trying to also check to see if that gameobject has existed for a period of time and if it has, i want to delete it and make it a new possible location for a new gameobject to be instantiated at the users will. whats a better soluton ?
Put the locations in a SortedList by their insertion time. use that to quicklly find the oldest one(s)
here is an example of my code that creates the plant and stores it's location.
var offset = new Vector2(0.5f, 0.5f);
if(_plants.ContainsKey(position)) return;
PlantObject plant = Instantiate(plantPrefab, position + offset, Quaternion.identity, transform);
plant.SetCount(0);
_plants.Add(position, plant);
}```
I guess a dictionary in this wouldnt be bad. Maybe the plant itself could keep track of that time and suddenly you dont need to iterate
the plant does keep track of the time.. should each plant have their own update method to find out when it dies naturally (dying is controlled by a decay timer)?
Either way works, if the plant already uses update for something else then theres no downside
The only thing is youd need some event or the plant would have to store a reference to the code that holds the dictionary, to do whatever logic you want
private Vector3 StartHeadBob()
{
Vector3 pos = Vector3.zero;
pos.y += Mathf.Lerp(pos.y, Mathf.Sin(Time.time * Frequency) * Amount * 1.4f, Smooth * Time.deltaTime);
pos.x += Mathf.Lerp(pos.x, Mathf.Sin(Time.time * Frequency / 2f) * Amount * 1.6f, Smooth * Time.deltaTime);
playerCam.localPosition += pos;
return pos;
}
How would I make the bob relative to where the player is facing? So when I turn to the side it bobs side to side instead of forward and backward, because it isn't relative to the player with this
We can't really know iwthout understanding your hierarchy
if playerCam is a child object of your player, this would make it relative to the player.
sort of at least.
Your math here in general is pretty weird and flawed
Like - you're starting with Vector3.0 every frame...
Then you're doling a Lerp towards some Sin wave, with deltaTime as T, which is not a correct lerp in many, many ways.
Then you're adding that to the cam's localPosition. It's just really odd and not going to result in an actual consistent sine wave if you're looking for a sine wave.
how would I fix the Vector 3.0 and the sin wave? Sorry I'm really new to all this
get rid of the Lerp part entirely, it makes no sense here. You would just assign the localPosition directly to the result of the sin calculation. not add it
Also you didn't really answer about how the hierarchy is set up
This is the main part of the hierarchy, I use void update to set the camera position to the CameraPos under player, because I was following a tutorial
If you cant tell I'm really new to Unity
Ok... and the code you shared isreferring to which object as playerCam?
It seems like the player camera is not a child of the player so yeah sedtting its local position isn't going to be a local position inside the PLayer's coordinate space.
in that case you should be setting hte position based on the player's Transform.
using. e.g. Transform.TransformPoint to get a world position relative to the player.
i.e. playerCam.position = playerTransform.TransformPoint(pos); that kind of thing - treating pos like a local position in the player object
how do i make a basic interaction system?
aka press f and do something to an object in front of player
with raycasts
and either an interface or a single component that reports being interacted with through events
what would such an interface look like and how would i use it with the raycast?
just an Interact or Use function
you would have the raycaster call that function when you press the button
this is what happens when I do git status on a project that I cloned from my friend's repo (and I didn't edit anything yet other than open the project), is this normal? or something wrong with the .gitignore or whatever
just lots of deletions
of what looks like temp files
library files should be ignored
https://github.com/github/gitignore/blob/main/Unity.gitignore
i forgot exactly how this part works but you might still have to delete them since they're currently tracked
this is in the gitignore, so I think it should be ignoring them
alright, I'll just commit the delete and see if it comes back
the Library folder is automatically generated by unity so it will be regenerated the next time you launch the editor which is part of why it should be ignored, the other reason is that the library folder gets huge
whoever set this up, did they add the git ignore after their initial commit? once a file is tracked, its in the repo. I think you might want to use the git rm command
rarely ever needed to do this myself so im unsure if theres a difference between pushing that commit and using the command
This looks like you set up the git repo in the parent folder, so instead of being at Library and being excluded, it's at SyntyJam2025/Library which is not excluded
oh you might be right I'll let him know
Guys quick question if possible, im working on a unity project with given instructions, and in them it says to create an abstract method called "PerformAction" in the parent class Character, which will be inherithed by Player and Enemy, homever the instructions say that it should be implemented in Player to Attack and Interact and in Enemy to damage the player(not the attack action), and my question is, wouldnt it be easier to just add individual methods for Player and Enemy instead of a generic one? Also, can an abstract method can be implemented multiple times in a child class?
the point of an abstract method, is to allow different classes to perform different code within the method and for any classes calling that class.method to not care about what happens. If you do two indvidiual methods for player/ enemy, then whatever is calling PerfromAction() now needs to know what it's talking to and to call the correct method when it doesn't need to
You cannot have more than one method with the same name and parameters
To clarify, abstract functions work the same as virtual ones but MUST be implemented by child classes.
Virtual ones can optionally be overwritten.
What even is a method? I just installed unity yesterday 😭😭
As Carwash pointed out it let's you write loosely coupled code.
You can Google "Polymorphism" for more info
Unity is a game engine and C# is the programming language it uses
Don't worry. Asking question is a channel for asking questions is very okay
Oh so I need to learn how to write c# first, then I learn how to make my first game right?
Unity has free courses to teach both at the same time on learn.unity.com
Personally, I think it's easier to learn them separately.
Take the courses unless you have a couple thousand to drop on hiring me
Wish I had
I'll take curses then.
I'll learn c# from the link you gave. Then I learn unity.
I suggest you learn C# without Unity being part of it at all.
https://learn.microsoft.com/en-us/dotnet/csharp/
Learning C# with Unity means you learn two things at once, which is just going to confuse you. Not to mention C# in Unity is VERY different syntax wise and it will require you to understand that while some things are possible, you should not use them.
I'll take your advice then. Thanks.
if you wanna learn the c# basics you should try this course from datacamp inclusive certificate just for fun... https://www.freecodecamp.org/learn/foundational-c-sharp-with-microsoft/
is there anyway to download my unity game onto my iphone for free without using xcode or renting any mac replictors or smth
No cus apple.
You need xcode to actually build the game so if you dont have access to you one you need to use a third party service or unity cloud builds.
Android builds don't have this problem, can be build fully on mac or win or linux (i think?) and installed on any phone
i probably copied it wrong but i kept checking over and couldn’t find what im missing, unless im being stupid but i don’t think it is the video albeit it isn’t the best tutorial. When im on my pc ill screenshot it all and show you but this is my first actual project and first time coding
Hey guys, im looking into modding Schedule I. So far i've been able to decompile the game but the methods dont have anything in their bodies. Anyone have good resources I can look at?
There's no modding discussions here. #📖┃code-of-conduct
Oops mbad then
Hello. Right now i’m making an rpg game. Let’s say if i want to implement a passive skill system to the game, what would be the best way to do it? Especially if let’s say there’s a lot of different passive skill and each of them have different effect (reduce damage, lifesteal, atk up, etc). I’m not asking about the exact code, but more like, the logic of doing it. Should each passive have their own script and callable function? Or should i make it so that everytime i get damaged, i check if the skill exist, or what? Keep in mind the plan is that there will be a lot of passive
I’m not posting any code because rn I’m prioritizing on learning the general logic behind it first (and mostly because i don’t know how to approach it, i don’t know where to start so i don’t have any code)
Both approaches are viable and can even be used together. It depends on your project needs and on the specific passive skill mechanic.
The way the passive works in this project is like the player itself are able switch around the passive, so the triggers changes a lot. Hmm, what if i make an array of every triggers (on hit, on attack, etc) and everytime the player changes the passive, the list of passive inside the array changes. So everytime there’s a trigger it will check it’s corresponding array and trigger the passive inside them
Would that logic work
Thinking about this gave me headache lol
The easiest, and probably the most robust way, would be to create a script per passive if you intent to have a lot of variety.
Hmm, how would i check for the trigger
If passive in player.passive_list and stuff_trigger then do x?
You would simply have a "Initialize" and "Dispose" function that would handle registering to the appropriate system.
Some of your passive might want to have an "Update" function as well.
You need to take some pen and paper and make a draft of your system design.
Of how you want it to work. When and how to apply bonuses. Should they modify the stats? Or just provide multipliers and added bonuses? Should you have separate lists for different types? Or iterate all the passives when looking for certain types? Etc, etc...
Ugh yea, doing everything in head gives me migraine. If i do come back and show you guys, pinky promise not to laugh at my diagram. I have no experience in professional coding, only self taught
We don't laugh. But we can send you to do some basics learning.
i figured it out after 15 second of drawing
i'll just write the logic that i use so if anyone search maybe it'll help someone. There's a lot of passive in my game, and a many triggers too, but the player can only equip like 6 passive skill. So i figured out maybe it's okay to just send the type of trigger (and the values) to the equipped passive everytime any trigger triggers and let the function inside the passive script check the trigger, and if it pass the check it'll do the effect
if the passive is a stat boost or anything simple, just modify stat on battle begins maybe
idk why i overcomplicate stuff. thanks guys
i followed atutorial on how to make a tree grow and it does it in stages but when it reaches its final stage it deletes itself can somebody help? im very new to game dev
In this video you will learn how to create a plant growing system. This is an easy tutorial for unity beginners! Enjoy! :)
________ My equipment ________
My keyboard*: https://amzn.to/3H2TXWp
My mouse*: https://amzn.to/47jGPXq
My graphic card*: https://amzn.to/48gG1nL
My microphone*: https://amzn.to/48fyDJm
My USB interface*: https://amzn.to/41...
ill post code now
you forgot a few lines in the CheckPlant method
if you go to 7:30 in the video he deletes the part i think your talking about
oh you're right
yeah so idk what ive done wrong and i cant figure it out but i think its got something to do with the unregister plant stuff
are you getting any errors in the console when ur plant disappears?
yes
should have started with showing those then 😄
Why does this grid look so off?
i forgot about it my bad lol, ill send it now
because it is
are u using ur own hexagon tile image?
I don't fully understand this component
It's the one from default 2d assets
im not that great at swizzle but i can try to help
just checking that first..
sometimes u try to use ur own and u dont always get the perfect dimensions the first time
I can scale it in the x-axis by 20% to make it fit together
I have no idea why 1,1,1 scale looks so bad
show ur tile
I mean just this
its a gameobject right?
yea that
ur scale of that needs to be 1
why is the X 1.2?
Then it looks like this
ohh so thats the scaling doing that
With 1 scale it doesn't fit
ahh gotcha
ive never used the grid component ive always made my own manager style script
can you show the scriptable object?
like this??
can you you show the entire hierarchy with the grid gameobject selected?
i think i found the problem? try replacing "currentStage" with "currentStage - 1" on line 25
okay ill try now
Well there's nothing else xd
Just setting that cell-x size to a random value like 0.87 seems to work
I have absolutely no idea what's the math behind that
doesnt seem right.. hang on im building a mock one real quick
I did my own hexagon grid cus the offset did not match what i wanted ✊
Mine had a configurable "offset multiple" and ratio
you're gonna need to show your code
let me take screenshots really quick
!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.
The exact value is 0.8659766
It's an irrational number actually
Checked the maths
So in this case sqrt(3)/2 for the cell size
heres the code of the script i want to access gameobject from dontdestroyonload
public class PauseMenu : MonoBehaviour
{
public GameObject pauseMenu;
public static bool isPaused;
public GameObject setting;
// public GameObject[] rootsFromDontDestroyOnLoad;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
setting = GameObject.Find("Optionss");
pauseMenu.SetActive(false);
// rootsFromDontDestroyOnLoad = DontdestroyOnLoadAccessor.Instance.GetAllRootsOfDontDestroyOnLoad();
// setting = rootsFromDontDestroyOnLoad[2];
}
// Update is called once per frame
void Update()
{
if(Input.GetKeyDown(KeyCode.Escape)){
if(isPaused)
{
ResumeGame();
}
else
{
PauseGame();
}
}
}
public void PauseGame()
{
pauseMenu.SetActive(true);
Time.timeScale = 0f;
isPaused = true;
}
public void ResumeGame()
{
pauseMenu.SetActive(false);
Time.timeScale = 1f;
isPaused = false;
}
public void Settings()
{
Time.timeScale = 0f;
setting.SetActive(true);
}
public void QuitGame()
{
Application.Quit();
}
}
im trying to access this gameobject when in ddol from the PauseManager
Don't use GameObject.Find
It's inefficient
Its public already so already assignable in inspector 🤦♂️
Oh that too
Yeah just remove this
setting = GameObject.Find("Optionss");
You can drag and drop the gameobject to your PauseMenu script in the inspector
i cant tho because its in another scene? sorry im new to unity, cramming this for a school project
I think you need a singleton pattern in that case?
im gonna go look that up
Basically it's something like this
Then you can access the singleton class from anywhere using class.Instance
its just hexagon grid bullcrap
u have to take into account the staggered rows in order to have correct spacing
i don't quite get how to implement this
it presumes you have a custom monobehaviour to add this code to. I presume your UI has a monobehaviour to do stuff right?
yeah i have a monobehaviour to do stuff are u refering to the one in scene 1 where the object is instantiated or scene 2?, cause i have different ui that calls the object in both scenes
We mean your "options" gameobject as that is the one you are using Find() to get.
Ideally you would do something like OptionsUI.instance.SetPauseMenuVisible(true);
@sharp bloom the best i can figure out is to use a vector2 for ur spacing calculations
so u can fine tune the X and Y
it doesnt have a monobehaviour script cause its just volume sliders in there should i create one
Up to you but however you do it, to use the static reference you need a monobehaviour on that UI to then control the pause menu
seems to do the trick
i made a monobehaviour on the settings menu and pasted a singleton script i found online
Yeah that works too
hexagonal tessellation be a pita
i ended up scaling my tile too
made it match the square unity sprite so i could use 1 as my base number
now to make 3d Orthographical grids since im this far 😈
I figured it out and got it working thanks !
what job would be best for mesh generation? i see a bunch of jobs like IJobParallelForTransform, is there one for mesh gen?
Destroy(WeaponsSpawn.transform.GetChild(0));
GameObject Instance = InvSlot[0];
Instantiate(InvSlot, transform.position, transform.rotation);
Can someone tell me why GameObject Instance = InvSlot[0]; this part is not working im trying to make a varible that contains the first gameobject of this array
You're going to have to be more specific about "is not working"
what's going wrong with it
My guess would be that this line is actually the one with the error:
Instantiate(InvSlot, transform.position, transform.rotation);```
If InvSlot is an array that makes no sense
Make sure you carefully read your error messages
they will tell you exactly what line the problem is on
it says cannot apply indexing[] to an expression type
it is
📃 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.
I've never seen this before
unless you've written some editor code, that isn't related to your code. it's an editor error
If I want to do rotations in my game, should I try to understand quaternions, or should I continue to convert them to euler and back?
with all of the helper functions, there's really no need to actually understand how quaternions work. you can just work with the euler angles you are already familiar
I would say don't try to understand the math behind them, just understand the concept of gimbal lock when you doing some conversion
I have multiple NPC's that use the same script. A script on one NPC is affecting all the other enemies. How can I prevent this?
For example, I have a script so that once you interact with an NPC, you can't interact with them again. Problem is, if I interact with 1 NPC, I can't interact with any anymore
are you using static variables or something
It's impossible for us to say without seeing your code. There are several ways that could happen
Most likely stemming from you not understanding something fundamental about variables or scripts
!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.
I don't think so
ok and where's the variable or whatever that's supposed to track if the NPC has been interacted with already?
And what code is checking it?
HasPickedUpBefore?
Which object is this script attached to?
Yeah
The NPC
HasPickedUpBefore so that you can't pick up the same NPC again, but you should be able to pick up other NPC's
Do you have any errors in your console? It looks like this script requires you to have set a reference to the player object directly in the inspector beforehand
Has that been done for every NPC in the scene? Also are there NPCs that are spawned in and not in the scene at the start?
Every NPC that has this script and no, all of them there from the start
No
you should start debugging your code
add Debug.Log statements in the places where you expect code to run. Like in OnTriggerEnter2D before the if statement. And make sure the data is as you expect at that point.
Hi, could anyone please help me?
I'm currently making a twin-stick shooter, but my missiles don't collide with the enemy.
Both have colliders, but I don't know if there is more, for it to collide
does anyone know a site where i can learn c#?
At least one of the two objects in the collision needs a rigidbody attached too.
do you know java?
i'm asking that because of your name
oh no its just something i came up with
oh alright
i just know to put ; at the end of lines and what the start and update things are and thats abt it
Murado linked the most official starting point out there a couple messages up (accidentally replied to me about something unrelated).
oh lol sry. ment to reply to Jawa
https://learn.microsoft.com/en-us/dotnet/csharp/ you can use this to learn some basic concepts of it
if you have programmed before you just need to search up C# examples of what you already know
ok thanks
no problem
trying to maek a bloxy fps
cool
I have
keep in mind too a lot of people give overcomplicated answers to some really simple questions
for instance a couple years ago someone asked what a vector3 was and some guy wrote down the actual google definition of a math vector
really all you need to know is it's a structure that holds x y and z
@thin dew if u need anything animation or 3d related feel free to ask
oh thanks but i use unity for 2d
@whole osprey
should I share screen?
i know how to make 3d games i just find making 2d stuff more enjoyable
even out of unity
i prefer drawing over modeling any day
Sorry, I don't have time for that right now. Just seemed like a fix based on what you wrote.
i actually work for ppl who use UE but i switched to unity bc i want a challenge
interesting
i don't know much about ue
tbh
i know you can use c++ or their visual scripting interface
it got broing really fast and i was using ue4
i hate visual scripting
its around 20 GB
its super broing
you also have to install the epic games launcher
i have never played anything made by them for over 10 mins
including fortnite
and ue5 is 100GB
you have to install that one launcher to install an engine that's 5 times bigger
really?
yeah
wow
yes and thats just the core UE5
https://unity.huh.how/physics-messages
go through the page to see common reasons why u might not be getting a physics message
unity 6 is only 16gb for me
yeah its small
@cinder wind @thin dew theres no offtopic in the channels #📖┃code-of-conduct, this is for unity code questions
oh yeah sorry just got carried away
henlo
can someone help me with a pause code?
ya see, when i press up, the character jumps with a impulse, pretty simple
but when the game is paused, if i mash up key, the character launches to the air when i unpause
it stacks the impulse
code is like this
Well for one that implies you are running the jump code in Update
which is a bad idea for several reasons
but if you MUST do it
then you should make sure the game is not paused before you run that code.
why is it bad?
great part of the code belongs to the update 💀
this problem is one reason why
¯_(ツ)_/¯
i get it
aaa, thats why the left and right key is in the update
i get it now
your options are:
- move the AddForce to FixedUpdate
- Check if the game is paused before runing any of this code
FixedUpdate will not run at all when you have set time scale to 0
because the character jumps... weird