#💻┃code-beginner
1 messages · Page 790 of 1
you've proven that the Find was successful. not that the variable is not null. based on the fact that the variable is null but Find is returning an object, what do you think that means
prove it
now prove that is the only object in your scene with that name
it's the only one in that slot
well it's transform. so it will be among the children (not scene wide)
ah, right. that was a mistype on my part
either you have more than one object with that name where at least one of them does not have that component on it, or the component is being destroyed. assuming that "it works exactly one time" is actually accurate (the logs you showed before showed it was not)
ok
Guys I have problem TextMeshPro InputField caret shows but typed text not visible like the input is there but the text just does not show can somebody please help me
when i comment out .SetSlot(), it works fine
well yes, you won't get any exceptions if the code that was throwing the exception is simply not called
much like how you won't end up at the grocery store if you never get on the road that leads to the grocery store
Start probably hasn't run yet. I know in my other project I abuse Start on spawns since it runs at the end of the frame (I think another case it is different, idr), while Awake is instant.
you won't get lost in the grocery store if you don't enter the grocery store
you know what imma use the inspector to define it
but yes, as Nomnom pointed out, it is unlikely that Start has been run at this point. if the objects are all part of the same prefab though you should just be assigning the variable in a serialized field instead of relying on Find().GetComponent
wait...
this is absolutely the preferred way to assign something. relying on Find is fragile and you are guaranteed to have the assignment already if you don't rely on code running in Start to find/assign it
ok i changed OnStart to OnAwake and it's working now
why not just assign it in the inspector instead since that's still the better option?
i am instantiating new blocks
but it's using transform.Find which implies that the object is a child object which means it has to be part of the prefab already, no?
i guess each instantiated piece can have a link to it's own thing
that's what i'm saying
can somebody please help me 
was your question a code question?
here is their question
yes i am aware.
oh
So I'm working on an asset and am testing compatibility and going to work through any api issues for older versions. Which Unity LTS versions should I be looking for? I was half expecting to just see 1 LTS version for 2021, 2022, 6000 etc. but instead its many many LTS versions
How do I know which to target for a general audience?
LTS versions are a minor version/stream, not a singular version. you could probably just target the latest patch (though you may also want to consider latest enterprise version vs latest nonenterprise version for older LTS versions)
Thanks. I'll probably just grab latest non-enterpriose and then latest enterprise and see what happens on each for maximum compatibility within reason of sanity since I'm just a solo hobbyist lol
does anyone can help me with some enemy and shooting code?
basically i need rayHit.collider.GetComponent<ShootingAi>().TakeDamage(damage);
and i dont know how to do it and i cant find anything online
its a 3d built in pipeline
if u guys know how to do it pls reach out to me on my dms
ok, and why can't you just do that
not how this place works - community servers exist for a reason, so many people can help, or check other people's answers, or provide alternate solutions
you lose all the benefits of having a community server if you delegate to a private/ephemeral space like DMs or VC
okok
is there a way i can get the asset file path? not the streamingasset file path?
or do i need to put everythign into a streamingasset folder?
for editor only
so i need to do streamingassets folder then?
depends what you want to do..
Streaming assets if for raw files you don't want unity to process but still available in a build
i want to make a default file structure like:
avatars, itemdefs, textures, materials, etc.
I am mainly only needing to use itemdefs to load in, and the rest i need a way to check if the file exists
^ Correct. Asset path is only useful in editor when using AssetDatabase
you can get the asset path for any asset: https://docs.unity3d.com/6000.3/Documentation/ScriptReference/AssetDatabase.GetAssetPath.html
EDITOR ONLY
how do i do game asset path?
like reading a json file
or checking if a texture exists
you do file io with the File class
e.g. File.ReadAllText(Path.Combine(Application.streamingAssetsPath, "stuff", "thing.json"))
You need to create the path dynamically like in the example above. using something like Path.Combine is the best
assetsstreaming means i need to put them in a "Assets/StreamingAssets/" folder, what all goes there?
files you want to access in editor and in builds
a texture you want to use should not go there
I think you may be confused what its for
Unity explain its purpose but its for generic files that are NOT unity assets that we want to access in a safe location
the description here explains it: https://docs.unity3d.com/6000.3/Documentation/ScriptReference/Application-streamingAssetsPath.html
does the json file need to be accessible outside of the game? if no, you can just reference the text asset via the inspector
really just use a TextAsset and drag in the reference to it
or load via addressables if you want to do it via name or path or something
is there a reason they are json files and not scriptable objects? like, are they premade and you're just importing them?
i want to eventually allow people to make their own item defs (moderated of course)
then addressables or streaming assets
addressables?
its a way of bundling game content
it also lets you load stuff via tags or paths as well
also lets you do stuff like downloadable content works for pretty much all asset types by code
oh nice
is a bit of a learning curve though
simpliest way forward is streaming assets folder or textasset and drag it in
addressables would mean players must use the unity editor to modify content
By default everything uses assetbundles
yeah streaming assets will just have the assets in a folder unpacked
this would compile it all to .assetbundles
(can be changed but may be a bit advanced)
bundles or addressables are also a important thing to learn about when you get to larger games and need more control over what is loaded when
which would be better, bundles or addressables?
learn both and see which one suits your situation for now
is there a simplified way of saving objects to a file of any kind? Like saving a gameobject and its components and settings?
serialization
Unity already does it but you should probably make your own Objects
https://docs.unity3d.com/Manual/script-serialization.html
https://docs.unity3d.com/Manual/json-serialization.html
Addressables is a wrapper around the existing AssetBundle system, so you're using 'em either way 😉
is there a programatic way to do textassets?
they are just text files with extensions unity recognises
so you can make files with c# in edit mode to automate things yes
Hello, I have a quick question, in a behaviour tree, should all the childs in a sequence run in the same frame or should the sequence return running after processing each child ?
how about player data? (inventory), how would i make that persist through game sessions?
and serverside data
the answer is always the same, serialization .. Server side only changes where the data is stored
use a VPS of your own or start using free tiers with premade solutions like Unity CloudSave
or dump it into a file
oh i didn't have "System" namespace added
your ide will let you auto add that
you learn with time what namespaces certain things are in
Anyone know how I can generate random points within the green area?
use the relevant method on the Random class to generate a point within the circle/sphere, if it is below the min distance generate again until it isn't
Hi guys. Any idea how people make use of the Unity Game Service in particular the player data save portion?
As it's a key value pair, I simply store all my data in the key core_data and stringify the object as a JSON.
I was able to get it to work however, I'm unsure if that's the convention. (I'm pretty sure if i save it as the value pair such as PlayerCoin:0) That would be more readable right
I think better to write your custom save class to file.
because players will have direct access to json and can play with values
Sorry what do you mean? Isn't saving it on Unity Player Data Save the same as saving it on cloud (Not editable through JSON directly)
I missed you are saving in cloud. It is fine in this case I though you store it on device as json
Think I found a cleaner method.
- Generate a Random.InsideUnitCircle/Sphere
- Normalize
3)Multiply by Random.Range
Gets you points in O(n) time.
why O(n)
this sounds O(1)?
boxfriend's method would also be O(1)
anyways, i don't think you even really need to normalize and get a new random variable
you can basically just map the magnitude, no?
Because it doesn't have to repeat the roll if it's unsatisfactory, it always results in appropriate rolls. N represents the number of points you'd need.
ah, for N points O(N), fair. i thought you meant for 1 point
even with rerolls, it'd be O(N), though.
with this theres still a chance you end up with a zero vector, if you start with 0
Range is (1, 1000), so..
that doesn't matter
0 * 1 = 0
https://docs.unity3d.com/ScriptReference/Vector3.Normalize.html
If the current vector is too small to be normalized, then this function returns the zero vector
Define "too small"
Vector2 p = Random.insideUnitCircle;
p = p * (maxDistance - minDistance) + p * minDistance;
```....this doesn't sound right. `p * (maxDistance - minDistance + minDistance` is obviously not right
Click the link, it defines it in the next sentence
oh wait
The odds that it lands a random roll on 0,0 is stupid low tho
Vector2 p = Random.insideUnitCircle;
p = p * (maxDistance - minDistance) + p.normalized * minDistance;
wouldn't something like this work (aside from the very small magnitude case)
wait no
that's not how magnitudes work...
does that matter? your concern with the initial solution was the possibility of rolling more than once. this has the possibility of giving a wrong result
Cool, so I'll just delete the result and move onto the next roll if its mag is 0.
remaping the magnitude should just be fine as chris said
i'm dumb, it's basically this except you pull the distance from the initial random value lol
Vector2 p = Random.insideUnitCircle;
p = p.normalized * (p.magnitude * (maxDistance - minDistance) + minDistance);
this does obviously still rely on the magnitude/normalized not being 0
shit good point
textmesh.GetPreferredValues(text); and textmesh.GetPreferredValues(text, 500, 30); both say that THIS is the prefferred size, how can I ensure it stays on one line and doesn't split when it's small?
The particle system has some really useful features that makes it really easy to use
So I want to use some of them for my own classes. How would I do that through code?
- these custom modules you can enable and disable
this thing (along with the corresponding variant for floats)apparently it's ParticleSystem.MinMaxCurve and ParticleSystem.MinMaxGradient
its all pretty much here on the docs for how you'd want to interact with each module through code
https://docs.unity3d.com/6000.3/Documentation/ScriptReference/ParticleSystem.html
Hey! So currently I am having trouble with object destruction and instantiating an object. Currently, I have an object that is being instantiated - a bullet - that is already created with a script called "BulletControl." The bullet has a Start() that calls Destroy(gameObject, 6.0f). I wanted the main bullet to stay to continue using it for future instantiating, but it keeps getting destroyed. Is there any alternatives that I can use instead to destroy objects after a certain amount of time that won't affect the first bullet, or maybe creating something where I don't have to have that first bullet already created into the scene.
Code: https://paste.ofcode.org/5rsHyRVcwMAwrYXpnd77c2
Thank you! Please @ me if you respond.
your question doesnt really make sense then, what exactly are you trying to do
if i add for example, a rigidbody component to an object, the inspector displays a Mass field
which is a float field
which is easily recreatable in monobehaviour scripts using 'public float variableName'
if you call destroy on it, itll be destroyed. are you trying to do some sort of object pooling here?
how would i do the same with those objects seen in ParticleSystem?
when you click on the properties in the docs, it takes you to the specific details of each module.
like this one for example https://docs.unity3d.com/6000.3/Documentation/ScriptReference/ParticleSystem-colorBySpeed.html
has a link for the ColorBySpeedModule struct
I believe so? I apologize, I am pretty unfamiliar with pooling. Should I look into it for this kind of thing?
if its what you're trying to do sure, it sounds pretty weird if you're just trying to have a single bullet not get destroyed because its the first one. If you're trying to reuse it, then that would be object pooling
unity has its own ObjectPool class
I’ll definitely look into it! Thank you so much!!! 
yo i updated my unity to the next patch, sicne there was that security update. Now my lights are disappearing when in the corner of the screen, im using Forward+ and 115 shadow max distance, what could it be?
Perhaps tok many point lights? Forward path has a limit on how many can be rendered simultaneously.
No dms
instead of using the first bullet in the scene, you would create a bullet prefab (a GameObject dragged inside your project folder which turns it into an asset). then drag the bullet prefab (asset from the project folder) into the variable slot (from the inspector). this prefab will be used to instantiate a bullet every time you call the method . . .
is it possible to control several objects that have a specific tag using one central script? for example, if I have a cube that deals damage upon contact with the player, and I have multiple cubes, can I give them all a tag, then use a separate script to get all those objects with that tag, and use that script to handle things like collisions?
it's possible sure, but it's not necessarily a good solution
why do you need a centralized system to handle things like collisions?
if I have a cube that deals damage upon contact with the player, and I have multiple cubes
you can just give them all a script to deal damage upon contact with the player
the tag just seems like an extra step here
collisions was just an example, generally speaking if i had a central script that used tags, technically i could use that to control multiple different types of objects (e.g: NPCs with differing behavior), rather than making a new script for each type of said gameobject, so making changes can be done in one script instead of having multiple different ones
is that a good way to organise code or is it not worth the effort and making separate scripts for each object is still better
it sounds like you're trying to recreate inheritance

making changes can be done in one script
you can achieve this with a base NPC class for shared behavior, with derived classes for specific/unique behavior (or alternatively, a similar concept but with composition - that might work better in the case of unity components)
you don't need to make a system to centralize all the logic - that ends up making it harder to read and maintain
you have the right idea in concept here, just sounds like you're missing the existing solution 😅
please do not spam

thanks for the help, i'll look into inheritance to see how i can apply that 👍
i used to do gamedev on roblox, since luau doesn't have OOP what I ended up doing to achieve what I was describing was this built-in service called CollectionService, which relied on tags to manage behavior for multiple objects
just keep in mind that inheritance for components doesn't play super well with unity's own inheritance through prefabs/variants/instances, so consider composition for components instead (still using the same ideas/logic though)
(eg instead of a PlayerController that extends Entity, i have an Entity prefab that has the Entity component, and then an instance of that prefab has PlayerController)
yea but this wasnt a problem before the security patch
It could be that it was either not a forward path, or you had the max point/pixel lights setting modified, and it reverted back for some reason.
yea thats the next thing im checking
fixed
changed from forward+ to defered
lemme see the differences between both paths
what is the best way to get a normal of a navmesh piece an agent currently standing?
If it helps. You can also post this in #🤖┃ai-navigation
My charachter just passby the wall, is there wrong on code?
using UnityEngine;
using UnityEngine.InputSystem;
[RequireComponent(typeof(Rigidbody))]
public class PlayerMovementRB : MonoBehaviour
{
public float moveSpeed = 5f;
private Rigidbody rb;
private Vector2 moveInput;
private bool touchingWall;
void Awake()
{
rb = GetComponent<Rigidbody>();
// Safety settings
rb.useGravity = true;
rb.isKinematic = false;
rb.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
rb.interpolation = RigidbodyInterpolation.Interpolate;
}
void FixedUpdate()
{
// If pushing a wall, still allow gravity
if (touchingWall)
{
rb.linearVelocity = new Vector3(
0,
rb.linearVelocity.y,
0
);
return;
}
Vector3 move =
transform.right * moveInput.x +
transform.forward * moveInput.y;
rb.linearVelocity = new Vector3(
move.x * moveSpeed,
rb.linearVelocity.y,
move.z * moveSpeed
);
}
public void OnMove(InputValue value)
{
moveInput = value.Get<Vector2>();
}
void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.CompareTag("Wall"))
{
touchingWall = true;
}
}
void OnCollisionExit(Collision collision)
{
if (collision.gameObject.CompareTag("Wall"))
{
touchingWall = false;
}
}
}
!code please post code properly so it would be easily readable.
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
https://paste.mod.gg/qcgaehebaqhi/0
why its just giving false for isgrounded?
A tool for sharing your source code with the world!
What have you set as radius, direction and distance? Is the radius small enough that the spherecast doesn't start inside the ground?
A tool for sharing your source code with the world!
Check the actual values in the inspector
Those = 3f and = 4f only apply when you frist add the component
If the actual radius is 3 it sounds like it probably starts inside the ground
how much it should be? i have asked AI and AI is so dumb in this
A bit smaller than the radius of your character's collider
Assuming it has a capsule collider (or sphere)
It also needs to start high enough to not overlap the ground at first
it should be inside my character?
is there any way to learn from somewhere and a better way to do it? or its the best ?
It is a good way to make sure that it does not start inside the ground
Because if it does, it will not register the hit
You can use the physics debug window to see what's going on with the spherecast
This is the standard way of doing it. Just make it work first and then see if you find issues with it
thats the point this is grounded is jus returning false
did you set the ground layer on your platform?
Ik I've made that mistake a few times lol
yea i did
hi, i want to use this material for a disappearing platform. my idea is modify the alpha's platform color, the problem is that when i put it in transparent mode the platform became "too trasparent", i want it to be opaque and modify the alpha value that let it be transparent. how can i do it? https://www.youtube.com/watch?v=M9w9v1CWtzE i'm following this tutorial that simply put hte rendering mode in transparent, but the option of the rendering mode does not appear in my inspector.
In this lesson, I will show you how to code and create a vanishing ghost platform. which are platforms that disappear a few seconds after a player object touches it. Ghost platforms are a very popular game mechanic that can be found in almost every platformer.
To create this game mechanic we will use a 3D cube, a transparent material, an anima...
`you can change the alpha of the basecolor too if you want more control
and the reason why the inspector values look different is because they are using standart shader and you are using urp shader
Hey I need some help coding something can someone DM me personally? It's a FNAF fan game I'm making and need some help
no, ask here if you have a question
No DMs, the point of the server is to get help from everyone here . . .
Oh I'm sorry
Im making a FNAF fan game and need help like coding a camera like the player camera to pan back and forth when the mouse is moved left and right
right, do you have a specific question or issue with that?
if not, then we're just gonna point you to existing resources to save both our times (
)
Well I've used YouTube and they seem to not like really work at all and I just want a panning camera it seems like it's hard to find
is a panning camera just not a normal first person camera locked horizontally?
what am i missing here
sounds like you are searching for some copy paste ready code.
I have zero coding experience, confused on how I got this far of making my game
well if they're going for what fnaf has, it's a free cursor and the camera moves when the cursor is near the edge of the screen
so learn programming and start developing and if you need help come here and ask
perhaps start with going through what the tutorials are giving and make sure you understand them
if you need help understanding something, you can ask here (though take a visit to google first)
if you can't get one to work and you need help, you can ask here, but you'll have to give some more info about how exactly it isn't working
also a fnaf fan game seems kinda ambitious as a first project?
especially since you said you have "zero coding experience"
you need to scope it down a lot more
you should use your time to learn unity and c#
practice more
and then when you have the basics down start working on a project
did bro leave
apparently
Hello!
I've added a text mesh pro and once i did that my scene became all messed up.
I then deleted it but still can't see my player on the scene and keep getting these errors in red.
Any idea?
So frustrating, I just added a new element and then suddently it all breaks..
nop, keeps happening restarted everything
try reverting to a previous commit
its the nuclear option if you cant fix it normally
maybe try a library reset before that
probably yeah clear out the folder and let it rebuild when restarting
very new here haha. i think it could be indeed the mesh pro essentials which i had to install
sound like a camera issue actually
let me google how to do that clear out
unticked all my items and the error still shows
reset your cams
i deleted my scene window and added new one
fixed it
don't know why or what happened but fixed it haha
you have deleted a cam in the hierarchy and that fixed it, you could also have resetted it
don't know how to reset haha but this worked
you select a gameObject from the hierarchy then on the right side you hgave the inspector you can reset the components
ZipFile.CreateFromDirectory(linuxBuildDir, linuxBuildDir + ".zip", System.IO.Compression.CompressionLevel.NoCompression, false);
Why does this compress the zip file anyway?
it doesn't, apparently?
not sure what you're asking
though, i guess technically it could
These values do not correspond to specific compression levels; the object that implements compression determines how to handle them.
It does
NoCompression doesn't actually mean no compression - that's your intent, and ZipFile might treat that as a little compression
It's the exact same as optimal
Anyway is there something analogous to winrar's store?
maybe check out this thread https://stackoverflow.com/questions/48622135/create-uncompressed-zip-in-c-sharp
why cant I access any of the cameras properties through code? im trying to change fov through input but I dont even get the option
ive tried typing it anyway but i just get errors
try lowercase cam
same problem
i dont think that both problem are equal, you can not say same problem
lowercase cam is the same as camera
and i get the same problem of not being able to access stuff like fieldOfView
Camera is a class, the "concept of a camera" does not have a field of view or a size
Show another screenshot where you have started with cam.
only real, existing cameras have those
or the error message you get for cam.fieldOfView
Have you made your own class called Camera
field of view is a property in the camera api
uhh i dont think so
wdym by class
ctrl-click on Camera and see what it opens
i think there should be some restriction by unity if you try to create a class that matches with one from the namespace
in my version there is a small warning message but it only appears once and then it is gone
if i spawn an object with a large trigger collider, will the trigger collider automatically call ontriggerenter for those objects, or will the trigger not realize that there are objects inside of it because they technically never "entered" the trigger?
try it out and see
guys, i have a bug where all the animator controllers became empty when i compile the code, do u know why? i tried closing end reopen unity but it doesnt work. the error is this one
NullReferenceException: Object reference not set to an instance of an object
UnityEditor.Graphs.Edge.WakeUp () (at /Users/bokken/build/output/unity/unity/Editor/Graphs/UnityEditor.Graphs/Edge.cs:114)
UnityEditor.Graphs.Graph.DoWakeUpEdges (System.Collections.Generic.List1[T] inEdges, System.Collections.Generic.List1[T] ok, System.Collections.Generic.List`1[T] error, System.Boolean inEdgesUsedToBeValid) (at /Users/bokken/build/output/unity/unity/Editor/Graphs/UnityEditor.Graphs/Graph.cs:387)
UnityEditor.Graphs.Graph.WakeUpEdges (System.Boolean clearSlotEdges) (at /Users/bokken/build/output/unity/unity/Editor/Graphs/UnityEditor.Graphs/Graph.cs:286)
UnityEditor.Graphs.Graph.WakeUp (System.Boolean force) (at /Users/bokken/build/output/unity/unity/Editor/Graphs/UnityEditor.Graphs/Graph.cs:272)
UnityEditor.Graphs.Graph.WakeUp () (at /Users/bokken/build/output/unity/unity/Editor/Graphs/UnityEditor.Graphs/Graph.cs:250)
UnityEditor.Graphs.Graph.OnEnable () (at /Users/bokken/build/output/unity/unity/Editor/Graphs/UnityEditor.Graphs/Graph.cs:245)
Hey yall, I have a multiplayer question/bug that im having on my project.. can I ask it here or is it in another channel?
Can you share the code
Also
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
https://paste.mod.gg/wzwolrlhsqnb/0
https://youtu.be/gTQafQPNpUU
Hey everyone, I could use some help, I've been stuck on this for ages.
All I'm trying to do is have the jump animation play when the player jumps by pressing spacebar. but it just won't!
Even though the debug message says the jump condition is triggering, the jump animation doesn't play. It does play when I click the jump button on the inspector, but that's it. What's going on?
A tool for sharing your source code with the world!
(first part of the vid is me pressing jump button, and even though the player moves up, the animation doesn't play)
I can't for the life of me get the Depth and Normal passes from my camera and visually render them onto a Render Texture
helpplz imma cry
Is that trigger even firing on the state machine? You could try animator.play maybe istead of settrigger
so there is the player.
There is a big collider on the camera, to detect if you are looking on a tree
But there is the problem;
void ontriggerenter(Collider other)... etc
if you are close to water, and you look at it, you will slot down.
how to ignore a collider if its on the player but also the script?
like the if other... not going to work, because the player is not the other collider
Didn't seem to work, but I have an idea now
Sorry I cant help more, I usually handled my jumping with a bool and not a trigger. I create a isjumping bool, set it to true when jump is pressed, then set it to false when collided with the ground layer.
do you want the camera collider to ignore the player?
pretty sure you just have to set up some physics layers for that
the player script needs to ignore the child, what is the camera, because it has a collider "eye"
also i dont think using a collider is a good approach to detect if the player is looking at something specific
yea, i guess its laggy, but i dont know how to make any other way xd
its the tree script xd
use a raycast.
That's pretty close to what I did, but I didn't consider making it false when I hit the ground, that's a good idea
yo!
tryna see if an idea for a feature i have is the "optimal" or even "okay" way to do what i wanna do.
I got a gum player object, that's supposed to stretch towards the mouse when holding left click, when it hits a ceiling etc, act like a grappling hook.
I was looking at grappling hook tutorials, but they all kinda beam you near the position you hit, and the rope also doesnt have collision or can fold around corners.
My logic:
- 2d raycast from the bone closest to the mouse.
- get distance/angle between bone and wall/ceiling it hits behind the wall.
- divide into n amount of segments.
- create a new Rigidbody2d, circle/boxcollider2d on top of original bone
- Move at angle and to position of raycast.
- Once "far enough" away, enable collision, connect via springjoint
- Repeat "create a new Rigidbody2d etc.." until all segments exist
- all other stuff with being stuck to the point
Just tryna see if Im missing a way easier way before I start typing away.
Thanks yall :))
u need to get the component of the cam
yes rob 5300 because youve never made an obvious mistake in your life cus ur perfect
sybau
do cam.fieldofview
that didnt fix it either cus it was an issue with the script names
i called a script Camera which is the exact same as the way youd call Camera.fov
u made a variable but u dont use it. u still try to acces it through Camera.
Well if we look at the documentation its easy to see that fov is a property we can modify. a quick google gets us to the page easily
the Camera var is a script?
ya
Ah well that makes sense (you "hid" UnityEngine.Camera)
i called a script camera
All unity classes are in a namespace so it can be worked around but best to not name your things the same as unity classes
oh
can u send the camera script?
fixed now i can use all the camera stuff fine
ok
i fixed it like 3 hours ago idk why it got replied to
oh ha that is weird
okay
Looking for a nudge in the right direction.
- I wrote pixel data to a texture and made a shader to add a grid where i can adjust the line thickness. (left image)
- I'd like to also overlay the green divisions like the right image. Theses lines fall between pixels so I'm wondering how I could best draw this.
I was thinking i could draw pixel data on another texture then blend them but it's a little confusing trying to make something like a vector line align with a rasterized line lol.
Orientation.localRotation = Quaternion.Euler(0f, MouseMotion.y, 0f);
float VerticalInput = Input.GetAxisRaw("Vertical");
float HorizontalInput = Input.GetAxisRaw("Horizontal");
Vector3 MovementInput = new Vector3(HorizontalInput, 0f, VerticalInput).normalized * CurrentSpeed;
if (MovementInput != Vector3.zero)
{
PlayerRB.linearVelocity = new Vector3(MovementInput.x, PlayerRB.linearVelocity.y, MovementInput.z);
}
how can i make the movement toward the Orientation?
Sorry how are the green lines different and not something you can append to the texture later?
You need to rotate the input using the rigidbodies rotation Quaternion first to make it relative to its rotation
you can do Quaternion * Vector3 to do this
yea I'd like to add the green line later. The process I was thinking was to draw the green lines as pixel data on a second texture then overlay or blend the two textures together in a shader. I'm just trying to decide if that process makes sense or if there is a more insightful approach.
Can you not generate the line in the first texture to avoid some needless extra steps?
(presuming its the same resolution)
I was lucky enough to be able to just generate the gridlines with a quick trick to math the tiling and offset with unity units. What could the process of getting the other lines into my shader look like? Am I limited to drawing pixel data on a raw texture or can you think of other ways I could create the data to pull it into the shader to play with?
That probably makes more sense to create a mesh with code and bring it in rahter than messing with rastered data.
If the data can somehow be put in a texture that your shader can sample that could possibly work
Otherwise id just generate and write to a texture via cpu/compute shader once
Line renderers are a viable alternative
does universal 3d and 3d (built in render pipeline) handles physics differently?
because ive literally copied everything over 1 to 1 yet the universal project has a bug that the other doesnt
my only guess rn is that they handle physics ever so slightly different
The render pipeline is just the render pipeline. It doesn't change stuff about physics, no. If the two projects aren't the same unity version, you can have differing physics qualities just due to that, but same version across URP and Built-In will be the same package.
ill check the version but they rlly should be the same
yh theyre the same so god knows how urp has a weird physics bug
no post proccesing ig
what kind of bug
magnitude is 0.05 faster after landing from a jump which the other project just doesnt have
its such a nothing issue but i copied it 1-1 down to player model position and everything
it just shouldnt happen yet it is
how to change this via code?
Yo guys someone can help me pls i dont know to solve this
would be easier if you show where in the code the error is happening.
and the code itself
do you have "using UnityEngine.SceneManagement;" in the code though?
idk
https://discussions.unity.com/t/access-unity-transport-via-code/915760/2 There are indirect functions you have to provide data, and it switches the protocol for you
i just put some texture
and this happend
i was using a tuturial from youtube
this the code that have the error
oh thank you 🙏
hello is there a way for it to use singleplayertransport?
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
İ am making a 3d game and i use raycasta(bunch of) to simulate their sight to detects player or otger stuff. But raycasts are heavy even tough i update them in fixedupdate. Are there any alternetives for that. İ have heard about dot products
Simulate the sight of enemıes
Sorry for typo
raycasts are pretty cheap all things considered
I'm doing a bit of some c# variables rn
does anyone know why when I change the value of my variable in code, it doesnt update in the editor?
I originally had it as 4 and 5, then updated maxForce to 8 but it doesnt change on the editor
the code changes in the scripts section
but not the public variable values
Code defaults only apply when the instance of that class is first made, which is when you added that component
After that unity values take control, otherwise the code would just constantly override your inspector values
oh okay, so if I want to switch values I should just do it on unity and not on my code?
would those changes be updated on the code?
if not wouldn't my local editor and the code itself be different? does that create any conflicts
They would yes
Remember your Script is like a blueprint for something that will exist, it defines what it is, what it has and what it can do
An Instance of your Script is the actual "living" version of it, which in this case is the component on that gameobject
the only time they would reset to the original text file is if you would right click and hit Reset on the component or deleting it and applying it again, or to another gameobject
unity never touches the original textfile
hi i need help with something
im following a tutorial and its already not working
:thinking: Asking Questions
:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #🔎┃find-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.
-# For more posting guidelines, go to #🌱┃start-here
you'll have to provide some details
If you don't use version control package, try removing it.
If you do, remove and install the latest version.
huh
is there something there you need clarification for
just a "huh" does not tell us anything
we aren't psychic
public class PlayerController : MonoBehaviour
{
[SerializeField] private float moveSpeed = 5f;
[SerializeField] private float jumpForce = 5f;
[SerializeField] private Rigidbody2D rb;
[SerializeField] private int extraJump = 1;
public Vector2 movement;
public Vector2 boxSize;
public float castDistance;
public LayerMask groundLayer;
private float coyoteTime = 0.25f;
private float coyoteTimeCounter;
private float jumpBufferTime = 0.2f;
private float jumpBufferCounter;
// Update is called once per frame
void Update()
{
// set movement fomr input manager
movement.Set(InputManager.movement.x, InputManager.movement.y);
if (InputManager.jump)
{
jumpBufferCounter = jumpBufferTime;
}
else
{
jumpBufferCounter -= Time.deltaTime;
}
JumpLogic();
}
void FixedUpdate()
{
rb.linearVelocity = new Vector2(movement.x * moveSpeed, rb.linearVelocity.y);
}
private bool IsGrounded()
{
if (Physics2D.BoxCast(transform.position, boxSize, 0, -transform.up, castDistance, groundLayer))
{
Debug.Log("On ground");
return true;
}
else
{
Debug.Log("not on ground");
return false;
}
}
private void OnDrawGizmos()
{
Gizmos.DrawWireCube(transform.position-transform.up * castDistance, boxSize);
}
private void JumpLogic()
{
if (IsGrounded())
{
coyoteTimeCounter = coyoteTime;
extraJump = 1;
}
else
{
coyoteTimeCounter -= Time.deltaTime;
}
if (jumpBufferCounter > 0 && coyoteTimeCounter > 0 && extraJump > 0)
{
extraJump--;
Jump();
jumpBufferCounter = 0;
}
}
private void Jump()
{
rb.linearVelocity = new Vector2(rb.linearVelocity.x, jumpForce);
}
}
``` Can someone help me understand how to implement coyote time and or jump buffer. i originally had a working double jump now after adding it seems that nothing worked LOL
what's the issue you have
in taht code its like the coyote time doesnt actually do anything something is preventing my coyote time from even happening
Explain what's happening and what isn't.
coyoteTimeCounter > 0 && extraJump > 0
you need to both have the coyote time and the double jump available to be able to jump - that doesn't sound right, either you use coyote time or the extra jump
you also don't have anything allowing jumping while already on the ground, it seems
hey guys Kind of beginner game dev , so does not able to fix issue where , I do show projectile before release a throw , and prview is working correctly but my throwing force or velocity is not correct and creating a slow motion kind of effect and it feel like a my fruits a fly bird as welll as going towards a direction very slow can someone here can guide me and help me to fix this issue so it can explain me as well as guide me
share code properly please 👇
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
would also help to only share the relevant bits - probably where you're doing the physics
@naive pawn can you able to join a vc I could share screen not famillar with all thing could guid me to look through and fix and explain me as well.
no
https://paste.mod.gg/cnmmrdkfndmh/0 here a link of could I do not know do i need to fix code or not
A tool for sharing your source code with the world!
what's the intended behavior and what's the current behavior that's the issue here
What's the simplest method to change the name of a variable shown in the inspector?
for example, TMP_Text has this property
rename the variable
i don't think i can have parantheses in variable names
oh, yeah no you can't change components you don't own
i meant like:
how do i change the names of variables i declare in my classes
im a beginner if I do able to understand that much why do I even ask a basic question
in a way that has a different name in the editor and the inspector
if someone is avialble to help me and guid me please let me know
more specifically, having an editor name like "classNameTest", while showing "Class Name Test (units)" in the inspector
custom inspector but it's abit of a hassle
ohh ok
just having a different name would be achieved by having a different name
if you want a customized name, that's more complex (as batby said)
I think no one love to help and educate
we cannot help if we don't know what you need help with
its been 3 minutes
you need to describe what the issue is
I do describe a problem
what's the intended behavior and what's the current behavior that's the issue here
what's the intended behavior
also like i mentioned before, it'd help if you sent just the relevant code instead of the entire class
is ThrowFruit the method that you're having issues with
behavior should a accurate throw of a object where , using a fruits as an object to thow inside a bucket , but a current behavior is showing slow motion behavior when i release a throw object from a hand
why is it slow
and also have problem with a projection of projectile . let me send a video
of 10 sec
- try debugging
launchVelto make sure it's what you expect - what are
powerandpowerMultiplierset to? - what's the gravity set to?
- have you perhaps set the time scale somewhere?
check this out
ok
@naive pawn check video as well once please is there are more thing i should look for
how large is everything? make sure stuff isn't scaled up a ton
Can just able to join and guid me a little bit for a 10 min it would be enough , no need more just tell me what to do then you would leave I will fix it .
there aren't any vc's here for a reason
I just need guide Im begging
It's ok leave
it
you are thinking im asking for hand holding guie but im not asking for that
so its ok I will take help from somewhere else they would be good guide not like you an ego who does not want to educate
people are happy to help, just not in vc's
sorry to bother you have good day .
What you're asking for is basically a private tutor. No one does that for free.
@teal viper not asking for tutor , tutor can help me till I full learn all things not a some little small thing for 10 or 5 or 2 min
For that you can ask here. Don't expect people to commit to providing help to you specifically(which is what you're asking for currently).
bro I already got person we are working on fix just , keep your thoughts process to you guy do nt spread a false awenress
@prime goblet why do you want to know ?
you asked for help?
help can done so many ways
instead of asking for someone to hop in vc you could just post your question
which is what the server is for (mainly)
do it your way I got from another server
your problem dude
it's your tiny brain keep to you
Ah you caught us those of us in this server to help are all actually just here to mock and laugh at you guys for your dumb questions after all why should we waste the time from our day when all we get back are snide comments like this
!warn 325261025819492353 Don't insult people, and next time either post the problem or stop spamming the channel.
@hike_fps warned
Reason: Don't insult people, and next time either post the problem or stop spamming the channel.
Duration: Permanent
https://pastebin.com/CzbZakJL
im having some issues with weapon rotation. whenever im facing the ground the weapon renderer just seems to flip and end up on the opposite side of where im facing
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
sorry for the late response but thanks!
lock the max rotation on that axis
Its normal to clamp rotation to avoid going to far. This is easier when we handle rotation as euler values
yeah i just realized this
wouldve thought that attaching it to the main cam wouldve had it follow the axis automatically and thus not go over 90 degrees but apparently not
If its a child of the camera then that will work fine. I cannot see anything "flip" in your video myself
Anyway usually we read mouse input and change the camera rotation using this
yeah i have a seperate script that handles this for the main cam
Over there you should clamp the local x rotation to be in the range -89 > 89 or so
{
float mouseX = Input.GetAxisRaw("Mouse X") * mouseSensitivity * 100f * Time.deltaTime;
float mouseY = Input.GetAxisRaw("Mouse Y") * mouseSensitivity * 100f * Time.deltaTime;
yaw += mouseX;
pitch -= mouseY;
pitch = Mathf.Clamp(pitch, -maxLookAngle, maxLookAngle);
// --- STRAFE TILT ---
float strafeInput = Input.GetAxisRaw("Horizontal");
float targetRoll = 0f;
if (isSprinting && isGrounded)
{
targetRoll = -strafeInput * strafeTiltAngle;
}
currentRoll = Mathf.Lerp(
currentRoll,
targetRoll,
Time.deltaTime * strafeTiltSpeed
);
transform.rotation = Quaternion.Euler(0f, yaw, 0f);
cam.transform.localRotation = Quaternion.Euler(pitch, 0f, currentRoll);
}
my guncam is an overlay cam if that helps
okay, the problem i was facing was completely unrelated to the way i handle mouselook but i fixed it
Don't scale mouse input by Time.deltaTime. Learn why...
@rough granite what you think I do like to pass those comment and look there are two kind fo problem for beginner one which are visual explained and one which are explain by words , so don't act like a tough guy here
!mute 325261025819492353 3d Ignoring warnings, spam. This is your last warning.
@hike_fps muted
Reason: Ignoring warnings, spam. This is your last warning.
Duration: 3 days
is this ragebait
this guy is 100% deadass dude
help why is this not working?
HeadEulerAngles.x = Mathf.Clamp(HeadEulerAngles.x, MinHeadRotation, MaxHeadRotation);```
its been 1 hour i'm tweaking
Vector3 HeadEulerAngles = Head.transform.rotation.eulerAngles;
HeadEulerAngles.x = Mathf.Clamp(HeadEulerAngles.x, MinHeadRotation, MaxHeadRotation);
Head.transform.eulerAngles=HeadEulerAngles;
Yea you need to write back the rotation changes to the transform
eulerAngles is a value type, just like float, int, and Vector3. With value types, you need to set (reassign) the changes you make. With reference types, like classes, you can modify them directly.
--> #💻┃code-beginner message
Unity doesnt even store rotation as euler angles, its just an alternate format thats easier for us humans to use
to be pedantic, eulerAngles is a property with a value type, that being Vector3
I'm having a hard time understanding why my ScriptableObject was failing to save to disk (it saves to the instance in memory just fine) because my path to the SO had a space in it. Whats the deal here?
you'd need to provide context
what do you mean save to disk? is there code involved here?
If its already an asset you can just modify that and save it with AssetDatabase or make it dirty
There is, it's for an editor window and I'm using SetDirty, the class is serializable, I'm using AssetDatabase.SaveAssets(); AssetDatabase.Refresh();
everything is being added to the instance of the SO when I view it in the inspector but it's not actually modifying the .asset file on disk
you'll want #↕️┃editor-extensions for this kinda stuff
Thanks
So where do I start
download and IDE and start with c# basics
Thank you sir
have you ever used any programming language before
so im using the Old Input Manager of unity and im wondering how can i get the current KeyCode that is being pressed in the frame? (without knowing like which KeyCode to check)
there is inputString, you could probably make a mapping (though it wouldn't be actual keycodes)
i think the other option is to just loop all of them
oh seems like you can configure "Use physical keys", so if you have that disabled i guess inputString would match the KeyCodes if you check them
so i can like get the KeyCode as string type?
no, that's not really a thing
KeyCode is an enum
you would have to have a mapping from each char to the respective KeyCode
what i meant is like it returns "a" instead of KeyCode.A
yeah, i think so?
alr alr thanks, maybe ill make a hashmap out of it
though it'd probably not include modifiers
and shift might make it "A", you'd have to test
its better than brute forcing all the keys
if you actually need a solid check for KeyCodes, i think looping over them would be the more solid bet, but that depends on your usecase i guess
ehhh that's debatable
a lot of possible edge cases
well i think it would result in slower times, frame rate drops?
what about when holding alt or altgr or shift, or for different languages?
that absolutely does not matter
there are 339 members of KeyCode, that can be done in an instant
maybe its way too much for my use case of just simple keys
again it more depends on your usecase
do you want reliable access to KeyCodes, or just the keyboard buttons pressed on that frame
if you want KeyCodes, check for KeyCodes
if you want text, check for text (inputString)
thanks for ur help
Hey, swapped to VScode since I last used unity. I cannot get intellisense to work. For example [SerializeField] will not autocomplete, I cannot ctr click on things to go to other scripts.
Does anyone know what im missing.
!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
^follow the instructions linked above
Got the extension installed in vs code too?
VS code isnt as good as VS but Ctrl + space should still provide similar suggestions
I just dont get what im used to for the autocomplete . [SerializeField] doesnt show at all
Do you just recommend i swap back to visual studios
have you installed .net via the .net installer extension
ctrl+shift+p > install .net
like this?
yeah
VS code is worse, you cant tell it to show things from all namespaces from that UI (not sure if it can be changed via config)
Okay installing .net did fix it. Wonder why that wasn't in the guide maybe I uninstalled it at some point? Thanks Chris. But yeah to robs point, I just like vscode because its faster and cleaner UI to me. But yeah I can swap to visual studioes if I have endless problems.
it technically is part of the guide, but only in so much as it should be automatically installed with the c# dev kit.
the output tab in vs code should have told you there were problems and that .net needed to be installed
Makes sense yeah. I probably did ignore that message in vscode. mb
It feels faster from my experience. Might not be true but.
i feels more streamlined to me (not that i can use vs anyways lmao)
Well imo debugging is just a worse experience in vs code and thats very important to me
Guys im running into a problem with the text mesh pro basicly im trying to show the ammo 30/30 and the textmesh doenst show up but in hte text input show up the current ammo i have
in the editor
in game
if you put in text in edit mode, does it show up
yes
in play mode when you see the text has content, does it show up in the scene?
wait this is the code channel
edotpr
okok
and answer this there
i put code also in this
to set the current ammo
the code works the ui doesnt work correctly
everything with a computer involves code, here it seems the UI isn't working so it'd be for #📲┃ui-ux
okok
even UI-specific code would go there if the issue was with configuring the UI
if it were like syntax stuff or logic flow, then it'd fit here
it needs to be the UGUI variant to show up in a canvas properly
use whats in the UI menu only
can u show me in a call?
ah, that's probably the issue
woooo issues with crossposting
let's continue in #📲┃ui-ux
No im sure you are smart enough to navigate the Create menu...
😭 idk honestly
If I have absolutely no idea about coding, can I solely rely on Junior Programmer Pathway on Unity Learn? Or should I specifically learn about C# first, then start the course later?
you cannot rely on any one resource, no
i would recommend learning c# first without unity programming
the junior programmer pathway is, imo, a good starting point to show basic features you need for unity, but it doesn't really explain anything, you'd have to go research those yourself
learning c# on its own separately also helps reduce the mental workload of learning many things at once, and it can be useful to understand what parts are from c# and then see what extra stuff unity has
Can you recommend how much I need to learn about C# to create a game? Like, when do I need to feel like "ok, this is enough"
not really, it depends on a ton of things
you will never stop learning C# once you start
so theres no threshold
does JsonUltility supports parsing MonoBehaviours?
it does support.
Learn 100% bro
All you need to know is key words, algorithms, software architecture, webservices, threading and Unity related stuff
this literally just isn't a thing
Learn 101% then
nor would that be particularly conducive to unity dev
you won't use threading to start out, and you'll just end up forgetting, for example
Yess learn the fundamentals
new stuff is being made all the time, and you can't even use all of it in unity because mono is behind on .NET version lmao
I usually try to do something, see what I dont understand, learn it and then implement what I learned
if you set a goal on learning 100% you'd never do anything else
Thats software development in general. You can implement more/better while you learn more
And the truth is if you only do what you already know, its dead boring
There’s no real answer for this. Different games need different things. Just try to make a game and learn as you go. You will run into problems. Each problem you learn how to solve is something you add to your mental toolbox, and over time after going through these motions a lot and seeing common problems and applying common solutions, you will become faster and more competent.
#region Attacking
protected override IEnumerator AttackTimer()
{
animator.applyRootMotion = true;
agent.isStopped = true;
animator.SetBool("isSecondAttacking", true);
yield return new WaitForSeconds(0.8f);
animator.SetBool("isSecondAttacking", false);
animator.applyRootMotion = false;
agent.nextPosition = transform.position;
agent.isStopped = false;
yield return new WaitForSeconds(0.1f);
SwitchState(EnemyStates.Moving);
yield return null;
}
does anyone know why the enemy is teleporting to me after the animation ends?
im trying to switch between no rootmotion and rootmotion for attacks
to make them more natural
I believe it's due to a desynchronization between NavMeshAgent and Root Motion.
protected override IEnumerator AttackTimer()
{
agent.isStopped = true;
agent.updatePosition = false;
agent.updateRotation = false;
animator.applyRootMotion = true;
animator.SetBool("isSecondAttacking", true);
float t = 0f;
while (t < 0.8f)
{
agent.nextPosition = transform.position;
t += Time.deltaTime;
yield return null;
}
animator.SetBool("isSecondAttacking", false);
animator.applyRootMotion = false;
agent.Warp(transform.position);
agent.updatePosition = true;
agent.updateRotation = true;
agent.isStopped = false;
SwitchState(EnemyStates.Moving);
}
If it doesn't work, let me know so we can try something different.
hey so I'm currently making a 2d game and I'm having a bit of trouble deciding whether or not it's a good idea to make it so each bullet is performing a raycast, checking if it hit something or should I just put a rigidbody onto the bullet
which is more performant?
don't worry about performance
figure out what solution would give the behavior you want
it really depends on what you need if any of your planned mechanics require projectile based bullets then go for individual rbs if its simple enough you should stick to raycasts
its a question about your game design and intentions not performance
I mean, should I put the raycast on the bullets themselves
raycast is instant
because currently it's setup without an rb so I have to use raycasts to check for collision
can just check for collsion events on it
oh I don't have to use an rb to check for collision?
if you want something like hitscan, you wouldn't have a physical bullet at all, just vfx
yeah I want the physical bullets to hit, I just don't know if rb on the bullets or a raycast fired by the bullets themselves is the way to go
do you want a projectile or hitscan
if hitscan, use a raycast
if projectile, use a physical bullet with a rigidbody and a collider
a raycast on a bullet doesn't really make sense
what is it supposed to detect? that it hit something? but that would be when the bullet hasn't hit the thing yet
I mean, if the ray picks up an interface of say a damageable thing
its its a physical bullet with travel time just make it a rigidbody
you can do the same in collision messages
the ray has no part in that
the ray just gets a collider
a collision can also get a collider
so ray and rb have no issues in performance?
then you can get that component from the collider
ignore performance for now
this just is not a concern
you are best to take the simpliest way forward that fits your intent
if there is a performance issue profile and figuyre out why
don't worry about perf unless a) you start having perf issues, b) you are working in the millions of iterations, or c) you are working with extremely limited hardware, like an arduino or an NES
altough you might still need some sort of raycast based anti tunneling if the projectile is fast enough
alright I'll keep that in mind--design first then performance
which is a lesson i learned when i decided to stick with projectiles over raycasts for my project
don't rigidbodies cast the collider to prevent this?
chances are if you get a perf issue it wont be the collisions it will be the instantiations
which would not be solved by raycasting it
in which case I'd probably need to look into object pooling or something right
yes
honestly i lost my mind trying to fix it and implementing this:
private void FixedUpdate()
{
//ant-tunneling i stole from unity discussions
if (hasHit) return;
Vector3 direction = transform.position - previousPosition;
float distance = direction.magnitude;
if (distance > 0.01f)
{
if (Physics.Raycast(previousPosition, direction.normalized, out RaycastHit hit, distance))
{
if (hit.collider.gameObject != sourceObject && hit.collider.gameObject != gameObject)
{
hasHit = true;
transform.position = hit.point;
HandleHit(hit.collider, hit.point, hit.normal);
return;
}
}
}
previousPosition = transform.position;
}```
Fixed it for me.
i would take the path that gets things working correctly to design fastest so you can play with things and figure out if there are more issues to solve
is it efficient? who knows.
might be with continuous collision specifically - i vaguely recall seeing a diagram of that in physx docs
alright! Thanks guys
When continuous collision detection (CCD) is turned on, the affected rigid bodies will not go through other objects at high velocities (a problem also known as tunnelling).
https://nvidia-omniverse.github.io/PhysX/physx/5.6.1/docs/AdvancedCollisionDetection.html#continuous-collision-detection
that's within the context of physx though, it might not necessarily just be setting one rigidbody to continuous detection 🤷
yeah i have them on continous for the projectiles rb, but at higher speeds the tunneling is unavoidable
that raycast check is the only thing really making it work
and let me just say something, doing it is completely pointless, apart from like slower firing flechettes? when the hell would i ever need these projectiles
i should have just went with raycasts but now i have to commit
-# heh, ant tunnelling
Hello, I am having a hard time with optimally designing my games and it is causing me a lot of frustration and causing me to just stop working on many projects and just ramming my head against the wall on the same things. Does anyone have advice for this? Do you usually feel like your game is perfect or as you develop are there many things that you start to realize you should have done earlier and then end up wanting to restart the whole thing. I can give examples if needed
focus on making something work before making it "optimal"
its a bit of a nuclear option but restarting sometimes isnt so bad
especially if youre experimenting and you realize that the foundation for your project isnt as solid as you hoped, it might be faster and more efficient to start again, but this something that happens early on in the development
rarely at later points
Hello guys, I'm new to Unity and I'm currently working on a 2d boss rush project game and I wanted to know if yall have some advice to use well ai for boss ?
Don't cross-post, please
Yeah sorry
You'll need to clarify your question. What kind of AI are we talking about? Just the behavior of the boss?
Yeah like how he recognize where the player is
How he play and use this animation when the player is at this distance
Well, you could hardcode it. Or you could use an FSM(state machine), behavior trees, goal oriented planning, and many other techniques algorithms to control the boss character.
Recognizing the pkayer would be done via sensors. Animations would be initiated from your code depending on your implementation.
Hey should I learn C# coding by itself before like trying to do coding in Unity? Would it really help a lot?
Cause a lot of it is just. Not sticking
Idk if thats just how it is or maybe its too much at once
It could help, yes. But you can also learn it along unity. It depends on you.
Yeah cause I see a lot of stuff in it that does look helpful, but at the same time a lot of it seems quite different than how unity actually handles it yk
What in particular are you having trouble with? Is this with regards to syntax, programming methodology or integration with the Unity API?
Its mostly just what different things mean and what they do, like I can do an if statement, but then when I want to chain stuff together it feels extremely like "Okay what now"
Well, no. It's not really different. At least the basics are all the same.
Like I couldnt really explain what some things actually do
Hmm I see
Normally you wouldn't unless you've seen it (the pattern) before or the lines of code have been properly documented (which most tutorials do not do properly)
Yeah ive seen a few here and there which kinda helped me grasp what a Quaternion is but a lot of it feels like. Okay put this here and there but doesnt really help explain how or why you would put this vs this or whatever
Quaternion isn't restricted to programming and is more of a math issue. Not many will understand it but can use it (the Unity type).
Yeah for sure, math is not my strong point at all
the cool thing about programming is how well it teaches you math
Yeah it does feel like a more fun way to learn math tbh even if I dont understand a lot of it currently
Feel like ill get the hang of it once I actually learn how to put things together like puzzle pieces
Cant remove package from project, even though i had already manually removed it from the project (and deleted the library folder and everything). It doesn't even appear in the manifest .json or in package lock?? Why is it still being shown. Also re-imported all to see if that would be the fix
This all comes with experience: following courses, learning pathways, tutorials, reading the manual, the api docs, other people's code.
Its also important to make sure you understand what you're seeing well enough. If you see a word/syntax/technique you don't understand in a tutorial, the worst thing you can do to yourself is ignoring it. Instead, research it up, you should unserstand what it is even if in general terms.
Yeah for sure, feels kinda bad to get stuck on one thing at a time but at the same time I really wanna make sure I understand something before trying to move on to another.
Like sometimes idk if I should move on and come back or what but
the trials and tribulations of a programmer
getting stuck on one thing
Also, it's better to think of programming as building with bricks, rather than puzzles. There are numerous bricks that can all be used to achieve the same goal. In puzzle there's only one way.
Like not sure if I wanna tackle events while not being entirely sure of how to use vectors lmao
theres a very loose linear order in which certain concepts are learned
i guess if you follow the learning pathways and most courses you will also follow this loose order
Yeah feels like that for sure, I do wanna learn state machines early cause it seems like an extremely useful thing to get stuck in my head
but there gets a point where it sort of becomes a "sandbox" and that happens after you are done with the fundamentals
i say dont think about that for now
Yeah like thats one thing where im like idk should I learn this now or later right
Did you restart the editor after modifying files like the package manifest?
guys this might be my dumbest question, but if i do
#if !UNITY_EDITOR
it would never get put in the editor right? there is no way for it to corrupt one day and actually run those lines right?
I think the main issue is that you dived into your own project before having a grasp on the basics. I'd recommend postponing your project to after you're done with the beginner learning pathways on Unity learn, and finished a few simpler games.
Right. Unless you delete these lines for some reason.
is there any way to know that i am in editor?
as a life saver if i delete that line for some reason
Yeah for sure, think right now imma just try and learn different things and kinda hold off on actually making something in its entirety
you know you are in editor if you are playing from the editor and not a build
I think there's a property in the Application class. Check the docs.
im talking about code that checks that
the line as long as its there is 100% reliable
ah okay
thank you
found it
Application.isEditor
If you're referring to Vector3 it's simply a type that holds three floats. It also provides other miscellaneous functionalities that you'll not need unless you're aware of it.
Math stuff like normalization, magnitude, projection, reflection, creating an angle from three points etc
Programming stuff like lerping, slerping, moving and rotating the value, interpolating etc (mainly common patterns that were implement for when operating with a set of three values)
Oh okay thanks you so much for the advice
it is a problem that i didnt use unity's ai for npc?
in water, its slows down,
and if its wall in front of the enemy, its rotates slowly and goes right until there is no wall, and start following the player again, its smooth i think
void OnTriggerEnter(Collider other)
{
if (other.gameObject.name == "Radius")
{
InRadius = true;
}
if (other.gameObject.name == "eyes")
{
eyesInside++;
Bar_Active = true;
}
if (other.gameObject.name == "water")
{
InWater = true;
}
if (other.gameObject.tag == "talaj")
{
talajInside++;
wall = true;
}
}
void OnTriggerExit(Collider other)
{
if (other.gameObject.tag == "talaj")
{
talajInside--;
if (talajInside <= 0)
wall = false;
}
if (other.gameObject.name == "Radius")
{
InRadius = false;
}
if (other.gameObject.name == "water")
{
InWater = false;
}
if (other.gameObject.name == "eyes")
{
eyesInside--;
if (eyesInside <= 0)
Bar_Active = false;
}
}
...
if (Enemy_HP > 0)
{
transform.Translate(0, 0, -speed);
if (!wall)
{
transform.LookAt(Player);
transform.Rotate(0, 180f, 0);
}
else
{
transform.Rotate(0, 1f, 0);
transform.Translate(0, 0, -speed / 2);
}
}
on every barrier there is the "talaj" tag, and there is big collider on the enemy's head
is it okay, or too laggy?
I don't see how those lines of code would cause lag. Best use the profiler if you're concerned.
i would not be wanting to do so much based on the names of things
bit on the fragile side, also CompareTag is faster then using ==
I have an incredibly stupid question I'm asking on this channel, because I have a bug seems to have come out of nowhere, and I want to recheck the basics.
My raycast based shooting mechanic suddenly doesn't register a hit on my enemy.
My hit checks for the tag "Enemy", but it literally doesn't hit the enemy collider. It hits the level geometry behind it and registers the level hit.
The enemy is kinematic, navmesh, and has a capsule collider on the root. It is not set as a trigger right now, but provides contacts.
The bones on the enemy rig have empty children with the box colliders attached.
I'm wondering what stopped working here when I was messing with other settings.
The box collider is tagged and layered as enemy.
I feel like something is misconfigured or maybe failing silently?
I have several systems built and now the one that worked forever isn't working anymore. I had to put the mouse down for a bit, but it has been annoying me all day.
Anyone have a text checklist for a basic raycast shooting system with rig bone colliders? (the bone doesn't have the collider to reiterate)
when I was messing with other settings.
like what
and show the code and how you debugged the rayc
guys I am brand new to scripting I don't know if I have this wrong but I have been trying to fingure out how to make the mario jump sound play when ever I press space. I have been doing this for an hour and can't seem to figure it out dose anyone know what to do?
hint: look at the docs for the AudioSource component
ok wdym docs like google docs?
!docs
ty
hey, how can i access the PriorityQueue data structure on Unity, cuz it seems non-existent inside the using System.Collections.Generic;. or i should copy paste an implementation of it on google?
PriorityQueue was introduced in .net 6 so not available in unity, unity only supports .net standard 2.1 or .net framework 4.8.1 (assuming you're on 2021+)
you could implement it manually if you really need it that badly
alr, ig ill paste a c# impl of it on google
is there a reason you need a PriorityQueue specifically?
Heyyyyy so like, I'm trying to set up this thing where the player object faces towards the ground, but I wanna have it so it gradually rotates to be perpendicular to the normal, instead of violently snapping to face that orientation (which is what it currently does), any idea how the hell to go about that?
use Quaternion.RotateTowards to rotate it over time
The Raycast output isn't accepted by that tho
Did you by any chance read the documentation for the method to see what you should be passing to it?
getting the nth smallest number in a list?
its the properties of heaps, plus its way faster to push/pop instead of just sorting it all over again.
for my case specifically, im trying to instantiate the monster with the lowest health first.
if (Condition 1)
{
}
else if (Condition 2) // Execute if condition 1 is false
{
}```
i dont get it... isnt this the same as "else"?
so no difference right?
Like if i put if and then else
no, you have a condition 2 here
if condition 2 is false the second brackets won't run
OHH omg took me long enough to know. so else means if any of the condition wont run. okok got it! thanks
if (Condition 1)
{
}
else if (Condition 2) // Execute if condition 1 is false
{
}
is the same as
if (Condition 1 == true)
{
}
if (Condition1 == false && Condition 2 == true) // Execute if condition 1 is false
{
}
ahh i see ... i think i understand. ty!
only if those conditions are not guaranteed not to change in the first block
the second example could potentially run both blocks
depending on what's inside the first
copy pasted your code but still doing the same thing
protected override IEnumerator AttackTimer()
{
animator.applyRootMotion = true;
agent.isStopped = true;
agent.updatePosition = false;
agent.updateRotation = false;
animator.SetBool("isSecondAttacking", true);
yield return new WaitForSeconds(0.8f);
animator.SetBool("isSecondAttacking", false);
animator.applyRootMotion = false;
agent.nextPosition = transform.position;
agent.Warp(transform.position);
yield return null;
agent.isStopped = false;
agent.updatePosition = true;
agent.updateRotation = true;
yield return new WaitForSeconds(0.1f);
SwitchState(EnemyStates.Moving);
yield return null;
}
im trying to add more checks but not sure xd
hi so a quick question do i need to learn entirety of c# or just some parts of it
3d gamesig
learn what you need
Hello everyone, I am a beginner who has only been learning Unity game development for a short time. I would like to create an effect where the player enters an indoor scene when approaching a door. However, I am not sure how to implement this.
My goal is that when the player approaches a door in the outdoor scene, it triggers a scene transition, and the player then appears at a fixed position inside the indoor scene, facing forward (from a third-person perspective, this means the player’s back is facing the camera). I want this to work reliably every time, with the player spawning correctly without bugs or position issues.
Could you please advise on how this can be implemented?
i use ids
Hey y'all - currently I am having a problem with Object Pooling, as I am doing it for my first time. Right now, after the bullet (which is pooled) has been created and deactivated, the bullet that is then reactivated and moved won't return to the "attack point" - instead it will go from the former position and then race towards that new position. After that object is created and presumably when reactived, it is meant to go to the attack point transform:
currentBullet.transform.position = attackPoint.transform.position;
It's hard to explain without a video, which I'm trying to figure out how to send. Anyway - here is the entire code of the script if it'll help: https://paste.ofcode.org/WZCk5QLrUsNWQrk5C6dVKF
If you respond, please @ me. Thank you so much!
sorry,I don't understand
What do you mean by effect if you dont mind me asking?
I have already record a video ,but I can't send here🥺
i have a ChangeScene prefab that contains a repositionPlayer object as a child
that repositionPlayer is the coords the player will teleport to
i also store an guid in the ChangeScene
when you click on one ChangeScene, it will save that Id into a JSON or singleton whatever you want
when moving to the next scene, the player will search in a list of ChangeScenes for the correct Id
finds it, then moves to the repositionPlayer transform position
and the forward position for you in this case as well
what makes this system good for me is that i can enter the same scene through multiple entrances
oh my bad
Can can i ask a question on c even if its not on unity?
I have been stuck for a long time and need help
I assume you mean C#?
No normal C
i dont think that would be allowed here
hmm ok
Is there any other channel for non unity?
only unity related stuff here
If its if else while, then its fine
Hey! Looking for some good Unity 6 tutorials on FPS movement and level design. Anyone got recommendations?
Hey! So I'm working on a project where I'm trying to map mpu sensor coordinates on to a model in unity (trying to make a MoCap Katana basically). But I'm kinda stuck on the axis mapping. If anyone has any experience working with this sort of stuff do lemme know. Feel free to ask anything btw. Thx
Hi, in my code when I jump next to a collider other than the floor I go flying in the air, would appreciate some help.
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
A tool for sharing your source code with the world!
first change this
private void OnTriggerStay(Collider other)
{
grounded = true;
}
to OnTriggerEnter and check for a tag
rn you are always grounded whenever you hit a Trigger
but if i check for a tag will i still be able to jump off other colliders besides the floor
so i dont know what you want to achieve but assuming you want to set grounded to true when you enter the gorund you´d check for the ground tag
you'd probably want jumping to be a one-time action, checking for GetButtonDown rather than GetButton
and/or you'd want to "consume" the jump when you actually jump
what's the setup here? is the trigger on the ground or on the player?
So, I have a problem where if I stand next to an object I jump super high, I want to be able to jump off any mesh however
player
I got a cylinder collider on the players feet
is that trigger set to only collide with the ground layer?
yea
is that wrong?
it's not a common way to do it afaik, i haven't seen this before.
oh k
your grounded logic is separated between OnTriggerStay and FixedUpdate, kinda fighting over the state of grounded, it'll be flipping every fixedupdate
this seems like a fragile system to me
oh, what should i do then
a common approach ive seen is to use Enter and Exit pairs to set the grounded state accordingly
ok
!help
Use
!help <command>to get more information
!collab
!code
!logs
!bug
!screenshots
!cs
!vc
!dots
!vrchat
!vscode
!blender
!vs
!forums
!learn
!install
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
that info is available in #🌱┃start-here, btw
Thanks, I was looking for it but the channel was hidden for me
Just double checking while its quiet here 🙂
So im having an issue with my brain, I have the following block of code to scroll around my 2D game:
private void Update()
{
if (!mouseGrab) return;
// move the camera
difference = getMousePos - transform.position;
transform.position = origin - difference;
// scroll the background
img_BG.uvRect = new Rect(img_BG.uvRect.position + new Vector2(difference.x, difference.y) * Time.deltaTime, img_BG.uvRect.size);
}
the camera move works fine, but my background wants to scroll constantly, even when i am not pressing down my "mousegrab" button
Yeah, it is trigged using unity events and seems to only output true when using the appropriate input action
(though for something directly in a message like this i generally wouldn't use a guard clause, it cuts off options of doing other stuff unrelated to that condition within Update)
I see
I tried to put the background scrolling in a seperate if statement but that didnt work either
so, that statement isn't being reached when it shouldn't be, correct?
it could be something else also trying to scroll it, perhaps check for that
No sorry, maybe im not explaining very well
The staments that move the camera are working correctly, only working when the player holds down the right mouse buton. The statement underneath that is intended to scroll the background while the player moves, that appears to be ignoring the right mouse button and is on constantly
despite me checking for the right mouse button before it
so have you debugged to see if that statement in particular is responsible?
I have run it again while commenting it out and the scrolling stops, so i know that its responsible
So im not sure how it can be ignoring the check above it, unless im missing the way that this code works
ok so to be blunt, some of the info here contradicts, so something you've said must be incorrect
(mistakes happen, this isnt' anything against you personally)
Okay sure, I can try to clear things up
Yeah sorry text is not an easy format to convey this in
Maybe I can take a short video with OBS
could you show how you debugged this?
sure, I have this block of code in the same script
public void OnDrag(InputAction.CallbackContext ctx)
{
if (ctx.started) origin = getMousePos;
mouseGrab = ctx.started || ctx.performed;
}
and then in engine im using a playerinput component to trigger it
how's Look set up? i'm not particularly familiar with mouse input stuff so i'm gonna have to scour docs a bit
Why are you treating mouse movement as "mouse grab"?
Im not sure that I understand the question
anyway id expect this action to work correctly: any movement would either start or keep the action going
The player sort of "grabs" the screen to move around
click and hold right mouse button, then drag and the camera moves
The action is for gamepad stick movement or mouse movement so "mouse grab" is mis leading
Just keep that in mind so you dont confuse yourself
Yes sorry, im using the right mouse click check seperately, that would be the "grab" part
yeah this is just gonna be started/performed whenever your mouse is moved , isn't it?
you're setting mouseGrab in the callback for this action though
are you also setting it somewhere else?
oooo
good point
lemme see
I think youve cracked it
Im not checking for the right mouse click anywhere
Im not sure how the code was properly functioning before tbh
Im gonna go and debug this and hopefully it solves things
ah yes, the duality of programming
"this doesn't work, i don't know why"
"this works, i don't know why"
thanks a million both of you
Good variable names matter!
Hi, not sure if this is the right channel.
I want to load a lot of prefabs in my c# script. So far I have used AssetDatabase.FindAssets(), but I can't use that in a build.
One option I also saw was using a Resource Directory, but I read it's bad practice.
What "best practice" options are there for me? Thanks
What I use right now:
var guids = AssetDatabase.FindAssets("t:prefab", new[] { "Assets/CardData/PlayingCards" });
foreach (var guid in guids)
{
var path = AssetDatabase.GUIDToAssetPath(guid);
var go = AssetDatabase.LoadAssetAtPath<GameObject>(path);
_cardDeckPrefabs.Add(go);
}
do you need to load them at runtime? what's stopping you from just using serialized references?
I don't want to add like 50 cards manually
you can select multiple assets to drag into an array/list
Feels too hard coded, if I want to switch something
Oh, I have only tried a List, not an Array
Whenever I click outside the inspector, it disappears
I didn't know you could lock...... thanks a lot.
(rip all the time I wasted implementing AssetDatabase.FindAssets() and looking up other options)
you can also select the "Properties" option from the context menu to pop out a little window with that component in it to assign things
is there a name for the 2nd constructor's syntax?
i don't think c# ascribes a specific name to it. i tend to describe that as delegating to another constructor
i'll have to dig through syntax specs to see, not sure how long that'll take
no worries, it's not that important anyway I was just curious
seems like both it and the base(...) syntax are called "constructor initializers" in the language spec
I have 2 canvases in my scene, one screen space camera one which i use to interact, and an overlay for settings. Is there anyway i can block the mouse from clicking through the ui to the gameobjects behind for the overlay canvas but not for the camera canvas?
you got a raycast target option on your components
hi is OnMouseEnter() and OnMouseOver() secretly really inconsistent or like what am I looking at
the player is supposed to insta die if they ever touch one of the bubbles (or hover over a flower for too long) but the bubbles just don't react 90% of the time and the flowers only register like 1 or 2 frames of being hovered over instead of however long they actually were hovered over
bubble script --> https://paste.mod.gg/vfttyfkpeeex/0
flower script --> https://paste.mod.gg/cesuftazssmv/0
tried doing raycasts too but that didn't work at all
I might just be stupid or smth but yeah
||flowers being the red circles and bubbles the blue ones for context if that wasn't clear enough already btw||
if anyone could maybe help that'd be awesome
i think a rc would be much more precise in this case
what's an rc
Its better to use IPointer event interfaces (which use an Event System + physics raycaster)
means they´d have to change to ui elements then
no it works with 3d/2d physics colliders too
the monobehaviour OnMouse x functions also only work with the old input system so should be avoided
but but what's even the difference between OnMouseEnter() and OnPointerEnter()?
Don't know but the event system events all use the term pointer
https://docs.unity3d.com/Packages/com.unity.ugui@1.0/api/UnityEngine.EventSystems.IPointerEnterHandler.html
This also provides drag events too
does linearVelocityY always affect the direction parallel to Y axis or is there a way to make it go along with the rotation of the object
assuming you mean of a rigidbody, linearVelocity uses global directions
you can multiply your intended Y velocity by transform.up to get a local Y velocity, or with something like transform.InverseTransformVector (i think, check the docs on that)
https://pastebin.com/kzNcyac7
https://pastebin.com/aGdvbzLJ
https://pastebin.com/ZMz0c72K
https://pastebin.com/fzWv6zzL
for some reason the slot icons dont get defined (so far i only have weapons implemented)
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
could you give more context
this is meant to be a hotbar system
please only give the relevant bits of code, 6 files is a bit much
i have the system a bit spread out but i tried omitting a few files
public Sprite hotbarIcon; // ← NEW```
i have this in retroweapondata
what component/field is the issue here?
what do you mean by "slot icons" exactly?
what's the intended flow/behavior, how is the current behavior deviating from that
the component thats the issue is the icon here (HotbarItemIconUI)
it should ideally grab hotbarIcon from retroweapondata (which it should have access to thru hotbarsystem and then inventorsystem). unoccupied slots should be disabled until occupied (which is already happening), but it doesnt assign the weapon icons at all for whatever reason
nah im a dumbass i thought i had assigned the icons
Unable to load font face for [PixelPerfectTinyFont]. Make sure "Include Font Data" is enabled in the Font Import Settings. You may disable it after creating the static Font Asset.
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
What on earth does UNITY want from me. Like just let me generate my asset for I can get my atlas....
Where are the god damm settings for this cannot find anything anywhere
this is the code channel
try #📲┃ui-ux
no one speaks there
that doesn't mean this is the right place
do you think UI people would be checking the code channel
this one i can help with probably, but i'm not gonna do it here
im trying to switch an audio clip in the script when theres a game over but for some reason the new audio clip just never plays, ive put audiosource.play() afterwards as well but it still just doesnt play
music.Play();```
thats literally all im doing
have you tried debugging to see if that code is being reached? make sure the volume is set correctly, the gameview isn't muted
the code is definitely getting reached because the gameover screen is appearing.
{
timerStarted = false;
timerPaused = true;
time = 0;
music.clip = musicClips[1];
music.volume = 1;
music.Play();
gameOverScript.GameOver(Mathf.FloorToInt(timeElapsed / 60), Mathf.FloorToInt(timeElapsed % 60));
}```
have you had it set to play something previously?
if so, does that other thing continue playing
yes and no
are you sure musicClips[1] has content that's loud enough compared to your other audio
yes because if i assign that to play first it will play
also i tried switching both clips and now when the gameover screen is reached a really loud buzzing sound plays
sort of like when you get a blue screen
what do you mean by "switching both clips" exactly
switching them around in the array
so musiclips[1] is now musiclips[0] and vice versa
is this the only audiosource?
i have another object with an audiosource that gets instantiated when i need to play it but those are the only two
you can play multiple clips with one audiodource, you just need a collection of audioclips. i think you are not aware of that since you are trying to wok with multiple audiosources
no i am using one audio source for the music and another for sound effects