#💻┃code-beginner
1 messages · Page 784 of 1
you can cast
it really depends on the result you actually want
i just want the more time passes by the higher the score goes up
there are floor, ceil, round, explicit casts etc.
ok, and there are infinite ways to implement that, why not send the code that's causing issues
and looking at the Math.Round function, it seems to be capable of returning floats etc., I didn't read the docs fully tho, I just skimmed through
https://learn.microsoft.com/en-us/dotnet/api/system.math.round?view=net-10.0
Mathf is unity's math library, Math is c#
https://docs.unity3d.com/ScriptReference/Mathf.html
I found Mathf.FloorToInt(); that worked
You can use either, mathf is just more common
do you know what that function does tho?
If the number ends in .5 so it is halfway between two integers, one of which is even and the other odd, the even number is returned.
Mathf.Round is a tiny bit weird tho
yes, it's different to rounding numbers in regular math
you can easily make your own implementation tho
Rounding the deltaTime directly isn't a great idea btw
Even if you multiply it first
It can become super inconsistent, for example at a high framerate the deltaTime could always be rounded to 0
I have a feeling he is not rounding the delta itself but the total stored value displayed in the ui, based on this message.
I could be mistaken tho, it's why I asked for code instead of just describing the problem.
Why can't I access UnityEngine.XRModule?
The package is installed, as seen in picture 1.
According to docs, I should be able to use it:
https://docs.unity3d.com/6000.3/Documentation/ScriptReference/UnityEngine.XRModule.html
But as seen in pic 2, it's not accessible :/
thats not where you would use that in the code
The module name is not the same as the namespace name
For example
the problem was that I forgot to store it in a variable 🤣
classic
Sorry, my bad when I was making this script.
I tried using it within a function in another place and it didn't work.
Oh, well that was quite confusing in the docs, as well as the message in the deprecation warning :/
XR is an API/namespace in XRModule, I can see how that can be confusing though
Yeah, it makes sense now.
However, the deprecation warning is really poorly written.
I've been going through docs and I am having a hard time finding a replacement for the GetNativePrt() method.
It'd be nice if something's getting deprecated to at least leave the name of the replacement function, similar to how it's done with rb's linearVelocity etc.
This is all the additional context I have for it, I don't know p much anything about vr development so that makes it even more difficult for me to find the appropriate replacement function :/
it is very difficult to read these screenshots ngl
get { return XRDevice.GetNativePtr() != System.IntPtr.Zero; }
That's what I'm trying to update to the latest api
This is the warning:
Assets/steamvr_unity_plugin/Assets/SteamVR/Scripts/SteamVR.cs(131,17): warning CS0618: 'XRDevice' is obsolete: 'UnityEngine.VRModule is deprecated and will be removed in a future version. Please use the APIs in the UnityEngine.XRModule instead'
As you can see, deprecation warning gives you nothing other than the package you are supposed to use.
From what I can tell, that looks like a null check basically
So I would start by looking at what is the main replacement for XRDevice and see if it's something you can null check/has something similiar
(Or simply a way to check if an XR device exists)
Yeah, I've been trying to look for that, but from what I can tell, there is no way to just get the device and check if it's null.
Closest I've gotten is the following:
get { return UnityEngine.XR.InputDevices.GetDeviceAtXRNode(XRNode.Head) != null; }
However, that's just me taking a wild guess, and XRNode.Head just seemed like the right choice as I am assuming that's the main part of the vr set.
But I am not gonna play smart, will just leave this as a comment on the PR and see what devs have to say about it.
Thanks a lot for taking your time and pointing me in the right direction!
Yeah, that could be that I guess.
I also ran into these 2:
https://docs.unity3d.com/6000.3/Documentation/ScriptReference/UnityEngine.XRModule.html
https://docs.unity3d.com/6000.3/Documentation/ScriptReference/XR.XRNode.html
What would be the equivalent of a 'module script' in unity?
e.g. a script with functions that can be called by any other script after it requires them (or whatever method that I should be using instead)
I can tell unity is far different from lua, but since that was pretty core to making stuff on roblox I'm just wondering what I should do to segment core stuff like hitboxes into one script that any other can use
Perhaps you want a static class?
Or static methods in general
It's common if you need some utility methods that can be called from anywhere without needing an instance of the class
yeah maybe, I'll try'em
the more specific you can get with the example the more specific we can try and explain the equivilent
Yep, 'module script' is a bit ambiguous but
a script with functions that can be called by any other script
Really just sounds like statics or singleton
since both players and enemies would need to create hitboxes, naturally youre gonna want 1 script that can handle hitboxes
sure
so you'd write 1 script that can handle hitboxes
what's the issue unity wise from there in your mind currently
well based on the more specific example static stuff probably is not the answer
a "module" script is just a script really
it's as module as you design it to be
A MonoBehaviour component script to be more precise
That crossed my mind first but i thought it's too obvious
Sorry this reply is a little late, but one important difference is that System.Math tends to deal with doubles, while UnityEngine.Mathf uses single precision floats (thats why the 'f' is in the name). For that reason it could potentially be more performant if you're doing a ton of calculations per frame.
I don't know if this is a beginner question, but do any devs have tips on how to make sure yield return new WaitForSeconds() counts consistently on WebGL?
As in, if in my IEnumerator function has the script wait 3 seconds in-engine, it will also do that on WebGL regardless of GPU load/computer specs? Or is that just unavoidable?
WaitForSeconds will not count "consistently" on any platform.
It will always be subject to wherever your frames land on the timeline
Can you explain what you're trying to do and we can discuss whether WaitForSeconds is an appropriate tool for doing it?
Just to explain how it works - if you do WaitForSeconds(3) it will resume on the next frame after 3 seconds have elapsed This may be 3.01 seconds or 3.056 seconds etc...
In the scene I'm working on, there is a character walking around and looking at things. There is an item that when clicked on, will trigger an end sequence where the following happens:
- Character moves towards a specific spot.
- Character then looks at the item you clicked.
- If your dialogue box is open, close it.
- Character yaps about the story.
- Sequence ends and it loads in the next scene.
I put in some wait times at the start (the clickable item also has things to read so I want the player to be able to read it.) and in between dialogue.
That doesn't sound like something that needs precise timing exactly
I'm making a new build to post, but when testing it out on WebGL, it seemed to take a lot longer for seconds to go by than when I tested it in-engine. Maybe it was just a fluke on my end. So I'm going to make a new build and see if the problem comes up again.
The difference in timing should be no more than the duration of your slowest frame
if it's longer than that, something else is going on.
if your framerate is really slow it could be perceptible
but I'm talking like 10fps or worse
Not that I noticed at the time. I did find an error in my code regarding locally calling and assigning something to a variable so maybe it was just the game soft crashing and I mistook that as a time delay in my IEnumerators script
Why aren’t you testing it again?
I am. I'm making a new build right now
Aaaaaaaaaaaaaaaaa, makes a lot of sense thanks
I'll do that too!
ok, so i have 2 step sounds and when i walk i want them to play with 0.5 seconds in between each step, it needs to go one after the other though, any ideas? ive tried messing around with coroutines and while loops but i cant seem to figure it out, i may just be dumb tho
show what you've tried
{
float num = 0;
if (num == 0)
{
num = 1;
Footsteps[1].PlayOneShot(Footsteps[1].clip);
}
else if (num == 1)
{
num = 0;
Footsteps[0].PlayOneShot(Footsteps[0].clip);
Delay(0.5f);
}
}
IEnumerator Delay(float delay)
{
yield return new WaitForSeconds(delay);
}```
it will call the function if your moving
ive also tried doing it in the ienumerator function itself
wait i think i forgot to use start coroutine
Okay, it worked! (but now my decals are missing???? I'm so tired dog)
only yield things are actually going to stop a function in place until it "yields"
those only work in IEnumator functions (and other async related things)
those only work when run with startcoroutine
all three need to be true
and in that snippet you posted it still wont work if playsteps is not also a running coroutine
I don't know why this is the case.
since your starting that delay but nothing cares about it
dunno about the decal stuff
cute game
I'll ask around. I'll hold off on posting until your done helping Davey. I'm cutting in to the chatter
Check the different Quality Levels in your URP asset, one or more quality levels might be missing the decal render feature
That's in the projects tab right? I'll go check
WebGL and decals a little wonky, but yeah try the URP renderer asset
WebGl ahs a lot of weirdness going on
you have the right idea with the logic flow, but it isn't set up correctly at all
PlayStepsdoesn't have anything that would make it wait. the yield inDelaymakesDelaywait, notPlaySteps(and only if used as a coroutine)- every time you call
PlaySteps, you create a new variablenumthat starts at 0. that'll happen every time you callPlaySteps
you'll want to have some loop that's aware of time (aka in a coroutine or in an Update message) with some persistent state (a variable that's in a higher scope than a single sound effect)
iirc it does not like the dbuffer ones
ah forgot to mention i got it working
Should be in settings, you can change which detail level the different builds have, and then there should be references to the URP Assets used by each
Project Settings?
I think so, should be under the "Graphics" section
It was. It's sort of evolved
I can move the convo to the appropriate channel
Yeah might be good to move this decal issue to #1390346776804069396
ah that makes sense, i was kinda lost lol
Ship-of-Theseus'd into a rendering problem after the code issues were fixed
complaint of theseus
can u help me ther e
hello! I was wondering if anyone could help me with a collision issue in Unity 2D? (at least im pretty sure its a collision issue)
!ask
:thinking: Asking Questions
:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #🔎┃find-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.
-# For more posting guidelines, go to #🌱┃start-here
can't help without info 😉
ah alright my bad! 
The last two suggestions are what to focus on
so I have this collision box with IsTriggered activated (idk if thats the right word), on the same layer as my character, yet for some reason the player does not activate it. Ive also added the beginning of my script; I only get the first debug.log, the second one doesn't show. (keep in mind im relatively new to the world of coding haha)
IsTriggered activated (idk if thats the right word)
there's no fixed word for that, so "activated" is ok - though "active" is also a specific thing in unity, so you might want to consider alternatives. you could just say it's a trigger in this case
(also yeah, is trigger, not is triggered)
ah alright thank you!
do either have a rigidbody
You need specific conditions in the scene to be true for triggers to work. Such as at least one object (the moving one, preferably) having a RB, both having colliders, etc.
my player character has an RB, and they both have colliders
show their inspectors
If you mean IsTrigger then as it’s a bool the appropriate/common terms would be enabled & disabled
also, put a Debuglog at the top of the message to see if it's being called, outside of any logic
first one is the non-moving object (the orange shape in the original image i sent) and the second is the player character
I’m new here and I was just checking, is there any reason a specific bar of starter code wouldn’t want to interact as it should normally when opening through 6000.3f1 of unity and visual studios 2026 as the coder
that's not much info to go off of
Yeah I get that lmao
what do you mean by "a specific bar", "starter code", and what interaction are you referring to
You might need to configure your IDE in Preferences, and check that you have the correct package installed (Visual Studio Editor)
I haven’t inputted any code and I’m just staring at the first thing you have when you pull an empty script from unity, but the words aren’t colored or doing anything like the walkthrough I’m following has it
Yeah it is, I’ve had that suggestion
!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
Hmmm I’ll look into it more through this, thanks!
@pearl isle do this
above the void awake?
no, in the OnTriggerEnter2D, the thing you're having issues with
only the first debug log shows
the tutobase awake called
is Destroy(gameObject) also being called perhaps?
That could be it, im thinking. Im gonna comment it and see what happens
Hello, I'm trying to add some optional buttons for my 2D web game to make it playable in mobile. I want to detect the buttons being clicked down and released propery. But I could not find a way to check whether the button is being pressed. Buttons defult come with the condition OnClick. Is there a deferent library or any other in built way to ditect whether buttons are being clicked down or atleast a way to find when they are released?
look into the Input System's On-screen Controls
well what do you know, that worked! unfortunately now the box gets called every time my player passes through it, but id like it to only be called one time and then destroyed forever.
call destroy after the player collides with it then 👍
yess thank you!
Can this be managed by the IPointerDownHandler? Is it as efficient as the On-Screen Controls for stuff like player movement buttons?

as for "as efficient", you'd have to profile it to find out
Ok, Thank you
here's a quick little hint at the "efficiency" part of your question though, you can look at the actual code for the on-screen controls related components to find out how they actually work, it is available not only in the package files but also on github to view
I wish I could make a hexagonal prism collider for the player
Can I make custom shaped colliders for the player?
hello dude what's up
Hi?
how s your day going today dude
Could do a mesh collider, but usually for the player you want a simple shape, since it's gonna be interacting with a lot of objects speed is a priority
This isn't a social server
sorry for that
Im aware but a hexagonal prism would be soooo convient
Lemme try the meshg collider rq
actually I am also graphic designer with 6year experience in this field and I have my own website
Remember that you can have a mesh collider that is different than the mesh that's rendered
!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**
If you're looking for work, go there
okay but I can make it just tell me what are you looking for if you need so okay got it
I'm beginning to see why Discord has flagged you as "likely spammer"
Hey is anyone facing the issue of not able to see the camera border in unity 6
!warn 1258003148736565382 There's no self-promotion on the server. You've been directed to forums already.
@joyful_sparrow_49197 warned
Reason: There's no self-promotion on the server. You've been directed to forums already.
Duration: Permanent
okay got it
Anyoneee
doesn't sound like a code question
please do not pester random people for help
oh this one is for code only
I updated Unity to 2022.3.62f3 due to the security issue, and now some code that I had working is no longer working. (Surprise...)
Specifically, I have aimAction.action.Disable(); to disable aiming controls. (Used in tutorials and a few other locations.). This goes for all my other input blockers.
I checked and I am making the call to it, however its still providing updates. Any ideas why this might be happening?
I have been trying to find it for hours in google chatgpt and discussions ; everywhere it just says that toggle on gizmos; and there is no option of gizmos
how are you receiving input? a playerinput, polling actions, etc?
Player Input using the new System.
To add to this, remapping controls also seems to be broken since updating...
how are you retreiving aimAction?
public InputActionReference aimAction; Set in editor.
that will be disconnected from the actions used by PlayerInput
so, this shouldntve worked before hand
Well, it did.
PlayerInput creates its own instance of the InputActionsAsset, if you modify the actions or whatever from the source asset it won't affect the instance that PlayerInput uses
So then whats the simple fix? This isn't really something I'd like to re-write being this deep into the project. And again, it worked before this on 2022.3.43f1
And seeing as how I use this a fair bit over my entire project, I'm deff not looking forward to it.
to be honest, i think either you're mistaken about something, or it was working due to a bug (that was fixed)
playerinput just doesn't propagate changes from its asset, since it instantiates its own copy
how ive done it (in the case of rebinding controls) is that i use an InputActionReference to specify in the editor which action to target, but i get the corresponding action from the active player input to modify that instead (or sync the changes back to the playerinput)
I mean, seeing as how again, I've been using this method for a fairly long time now, I don't see how "I could be mistaken" from something working to not working.
oh i don't mean that, i shouldve been more specific, mb
what i meant there is that there might be some other fact that made it work, and it's not just a playerinput propagating changes to its source asset
i don't really know what that might be, and to be clear i'm not trying to blame you - that's just the possibilities i see given what i know
public InputActionReference actionReference;
InputAction action => actionReference.action;
InputAction playerAction => playerInput.actions.FindAction(action.id);
void SyncOverride() {
string overridePath = action.bindings[bindingIndex].overridePath;
if (!string.IsNullOrEmpty(overridePath)) {
playerAction.ApplyBindingOverride(bindingIndex, overridePath);
} else {
playerAction.RemoveBindingOverride(bindingIndex);
}
}
```this for example
(though of course i might be misremembering something, i haven't worked with this stuff for a while)
hmm yeah maybe that's the case
action.actionMap.asset.Disable();
it does copy the asset. i don't know why i wrote the code there like that, i wouldn't expect that Disable to propagate
private void CopyActionAssetAndApplyBindingOverrides()
{
InputActionAsset inputActionAsset = m_Actions;
m_Actions = Object.Instantiate(m_Actions);
// ^~~~~~~~~~~~~~~~~~
/* copy binding overrides */
}
or maybe the actionmaps inside aren't deeply cloned. that's a bit too deep than what i have time for, sorry.
maybe try #🖱️┃input-system
I'll just have to move everything over to playerInput.actions.FindAction(aimAction.action.id).Enable(); I guess.
Just bothers me that I've been using this for well over 2 years now, and being forced to update due to a security issue basically breaks everything.
hello, im wondering if its possible for the direction of a moving platform on a spline to be reversed if the player's camera transform is facing in the opposite direction of the movement?
split that down into separate parts
you described it, so it's possible (unless you're using a system that doesn't support that, but you didn't specify)
im not sure if its a system issue. I haven't done custom spline movement like this before so its all a bit new to me at the moment, and sort of what seems to be going wrong too. so right now im calculating the dot product of the forward transform of the platform and the forward transform of my player camera (attached to the player as a 3rd person free cam). it is successfully computing the dot product but the movement isn't changing as I hope. the player is also parented to the boat so that the player doesn't slip off with the movement. I'm handling this in my update() function. the player also doesn't use rigidbodies, its the third person character controller from the unity asset store for context
if im still slipping up on the explanation, do tell 
{
Floater floater = boat.GetComponent<Floater>();
Vector3 boatForward = boat.transform.forward;
boatForward.y = 0;
Vector3 cameraForward = floater.cameraTransform.forward;
cameraForward.y = 0;
float dot = Vector3.Dot(boatForward.normalized, cameraForward.normalized);
Debug.Log("Dot product: " + dot);
float angle = Mathf.Acos(dot) * Mathf.Rad2Deg;
if(dot > 0)
{
}
else if(dot < 0)
{
}
} ```
this is sort of what i'm doing
but the movement isn't changing as I hope
well, you don't seem to have anything that would do that?
sorry, I tried this: ``` void Update()
{
Floater floater = boat.GetComponent<Floater>();
Vector3 boatForward = boat.transform.forward;
boatForward.y = 0;
Vector3 cameraForward = floater.cameraTransform.forward;
cameraForward.y = 0;
float dot = Vector3.Dot(boatForward.normalized, cameraForward.normalized);
Debug.Log("Dot product: " + dot);
float angle = Mathf.Acos(dot) * Mathf.Rad2Deg;
if(dot > 0)
{
//t += Time.deltaTime * speed;
dist += speed * Time.deltaTime;
}
else if(dot < 0)
{
//t -= Time.deltaTime * speed;
dist -= speed * Time.deltaTime;
}
// t = Mathf.Clamp01(t);
dist = Mathf.Clamp(dist, 0f, length);
float t = dist/length;
transform.position = splineAnim.Container.EvaluatePosition(t);
} ```
no, it doesn't rotate at all
and it points in the direction of travel?
right now on play, its completely static in its starting position
try adding some logs to see what's going on
That code looks fine to me 🤔 Is the dot product log printing what you expect?
And is speed non-zero
the dot product log is printing what I expect and speed is set to 2, which was working before
try logging the dist, this will narrow down the issue
i don't necessarily need to rotate the platform also, the reverse movement based on camera transform is mimicking ping pong
stupid question but is the object static
or thats how I would like for it to behave
can happen
What is this script attached to?
i checked just now, its not static
@heavy basalt see if this value is updated as expected
its attached to a child object of the boat, handling the trigger
ok will report back
And that is the object you want to move?
the parent object, the boat (platform attached to the spline)
But you are modifying transform.position which is the child's transform, right
yeah I think I might be doing that
now that you've said it
@naive pawn I checked the distance for when the dot is > 0 and < 0and its a really low number, like between 00.0015 - 00.0072
you're probably just gonna have to debug more to figure out what exactly is going on
(if the issue wasn't just that you were moving the wrong object)
I have both a box collider and a capsule collider in my player. In a OnCollision method when colliding with whatever I tagged ground. Could I assign specific colliders for when it collides with the ground?
I only want the box collider to have the property of being grounded
but I still need the capsule collider there to collide with stuff
you could have the colliders have separate layer overrides, or you could separate them out to different objects
{
float posx = (mapList.entry[index].x1 + mapList.entry[index].x2) / 2f;
float posy = (mapList.entry[index].y1 + mapList.entry[index].y2) / 2f;
Vector2 position = new Vector2(posx, posy);
Debug.Log("Spawned a marker in: " + position);
GameObject markerInstance = Instantiate(marker, position, Quaternion.identity);
}
I have this code for spawning markers in the middle of rectangles on my HUD. for some reason it spawns them wrong though
!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.
wrong how?
if the capsule shouldn't collide with the ground at all for example (assuming the box is the collision of the character as a whole) you would have the capsule as a child or with layer overrides to not hit the ground
@pliant dome
whats the expected result and whats the actual result
I don't understand this. When I add this line:
bramble.transform.localRotation = Quaternion.Euler(0f, (Random.Range(0f, 360f)), 0f);
The rotation doesn't work. It rotates on a random axis it seems like. When I rotate it manually in scene view, it works perfectly. How is that possible?
Ohh okay so barely sorta like a compund collider
Well how its set up with the child
I mean
does this object have a parent?
does the parent have any non 0,0,0 rotations?
OK for reference;
void InstantiateBrambles()
{
Vector3 pos = new Vector3(0f, 0f, startOffset);
for (int i = 0; i < 5f; i++)
{
int rand = Random.Range(0, 2);
GameObject bramble = Instantiate(Brambles[rand]);
bramble.transform.SetParent(gameObject.transform);
bramble.transform.localPosition = pos;
bramble.transform.localRotation = Quaternion.Euler(0f, (Random.Range(0f, 360f)), 0f);
pos += new Vector3(0f, 0f, nextOffset);
}
It should be noted when I rotate in world space, I get the same kind of weird behavior
Does it have a rigidbody, an animator, or any other scripts/components that could be modifying its transform?
so if you do just transform.rotation instead of localRotation the issue still happens?
nope
yep. Seems impossible, yea?
also side note ive never seen a for loop use a float
at least in this context
when you are just incrementing i
that probably shouldn't be there but it doesn't change the behaviour
I understand what you're saying but that part works
ik ik i was just pointing it out
has "side note" lost all its meaning already 😔
I will quickly take a pic of how they look vs how they look if I don't apply rotation
anyways can you try "bramble.transform.localEulerAngles"
if you havent
yeah im commenting on the sidenote in support of it
here, wrong one
is the parent rotated?
forgot one line in the bottom
markerInstance.transform.SetParent(MapHUD.transform, false);
And this is how it instantiates
the debug log gives the correct pos
here is default
What is wrong about this though
could be something to do with anchoring.
Oh, your object/its mesh just isn't oriented properly
as you can see, in the first image, the selected bramble is offset by only 8 degrees
yeah but notice they all share the same X rotation
Notice how it's at -90 X degrees at the resting pose
try
bramble.transform.localRotation = Quaternion.Euler(-90f, (Random.Range(0f, 360f)), 0f);
they are actually all rotating correctly on the y axis
Ok but what's the difference here? It's 0 on those axes
Idk what you mean, the object in your second screenshot is at -90 x
Did you make the mesh in blender?
ok so it's correct at 0, 0, 0 but wildly incorrect at 0, 1, 0 rotation? Gotcha
whatdo you mean 0,0,0
the second screenshot has x at -90
thats not 0,0,0
thats -90,0,0
oooooh
I'm stupid
I didn't even see that
yes, obvious blender problem
my brain is small
thanks anyway tho
also please "fix" that for loop
youre wasting perfectly good bytes of memory for that float 
floats are as wide as ints
you're actually wasting a few cycles converting the lhs int into a float as part of promotion, smh
honest to god
i couldnt actually think of it
embarassing considering i just had a midterm regarding exactly memory types 😔
My capsule collider is too ingrained with how it changes in size whenever I airdash in the enum so changing the the capsule collider to be its own child is gonna be so hard omg
Im so cooked
C does weird things to you
friendship ended with float, int is now my best friend
always use Bytes for for loops /s
why is the interactions between ledges and the collider and the raycast so absurdly difficult? Its just esentially a platformer thing
i mean, it depends on how you're going about it too
were you the person asking about detecting ledges vs walls
Yeah but that was a while back. I solve one issue then a new crops up. I know thats coding in a nutshell but its ALWAYS about the ledge
About how I slide down the ledge cuz of capsule collider or the boxcast causing issues with how big or small it is or just anything!
i was gonna ask yeah, wouldn't raycasts/overlap checks be easier than collision checks for your purposes
I realized that the issue is that I record the mouse position wrong. Or the game itself does
public Vector2 MousePosVector()
{
Vector2 mousePos = Input.mousePosition;
return mousePos;
}
This changes based on how big or small the window size in the editor is
Is there a universal way to get a proper mouse position (how far the mouse is from the center)?
I even get negative values for mouse position from this
make sure to read docs
Using raycast only never solved any of the issues I was facing
Sounds like your design for your approach to this hasn't been fully / well throught through
The current mouse position in pixel coordinates.
The bottom-left of the screen or window is at (0, 0). The top-right of the screen or window is at (Screen.width, Screen.height).
When running in windowed mode with an unconfined cursor, position values smaller than 0 or greater than the screen dimensions (Screen.width,Screen.height) indicate that the mouse cursor is outside of the game window.
https://docs.unity3d.com/ScriptReference/Input-mousePosition.html
this means it's in screen space. you can use Camera.ScreenToViewportPoint or similar methods to convert this into viewport space
proper mouse position (how far the mouse is from the center)
This is not the usual definition of mouse position
What are you trying to achieve here exactly?
I can assure you I have and it wasnt gonna solve them anyways
if im remembering correctly, it's pretty much the exact region you want to check for collision, no?
So much for LTS... Really glad thats a thing.
I'm now trying to disable all input actions.
foreach (var item in playerInput.currentActionMap) {
item.Disable();
}
This works, however, UI navigation is still allowed.. even though its included in the action map list... Why?
make the wall and ground all a uniform "terrain" layer
if you cast down and hit, grounded
if you cast, i guess in the direction you're facing (projected to the horizontal plane) and hit, you're facing a ledge
Trying to record where the user clicks, and if the user clicks within a country (rectangle) it creates a marker in the middle of it #💻┃code-beginner message
is UI navigation done through the player input? i wouldn't expect it to be
It appears to reference the exact same Input Action System...
Again.. All of this previously worked. For something that's supposed to be LTS it clearly isn't...
Input Action System
not sure what you mean by that, that's not a thing
not sure what you mean by the LTS thing either. LTS doesn't mean stable
it's supposed to be stable, but that's not exactly what the goal of it is
I wouldve solved this specific problem with dashing into the ledge with having the capsule collider be wider then the box collider at the bottom
but since you cant assign specific colliders in a OnCollision Script I couldnt do this
you can separate them out into separate children, so you can do that
but you should not
it sounds like you're really overcomplicating this
you need to step back and think about your design before making it more complex to solve a specific issue
But if I make it more simple nothing gets accomplished
Are we talking 2D or 3D here btw?
3D
I have. Thats how it started first
i'm not telling you to make it simpler, i'm telling you to reconsider your direction to potentially end up with something that achieves your goals but is easier to work with and maintain and tweak
It's also possible to see which collider was hit from the contact point that you can get with Collision.GetContacts
Without having a separate child
Just FYI
It wpuldve been simpler if I could just make my own shapes for the collider Im using for the player
But I cant
oh damn, forgot that was a thing
you can though...?
but no, that does not sound like it'd make it simpler
A capsule is close but the fact that the ends are round causes issues for me
Are we using a solid (non trigger) collider to detect ledges here? 🤔
i feel like you just want to complain rather than find a solution at this point
I'd usually go with a physics query, or a trigger collider at least
i also might be imagining things but didnt we already discuss this exact problem before?
yes
and the solution was also "simplify" it
hmm i don't remember how it ended 🤷
Simplifying it would be reverting back to a point where I would just encounter the same issues though
not really, theres a difference between simplify it and just using an earlier version
...so you're just discarding the idea because you think it won't work, or...?
you still need a solution youre just going to have to have a different approach
time sunk fallacy or whatever, sometimes its easier to start fresh
Like the collider thing. If I decide "okay lets keep it as a casule and only a capsule. All the issues would still be present
you have version control (i hope) so nothing is ever truly lost when you experiment
Mind pointing out some of the issues?
Cause otherwise this is just a pointless rant
but you've now removed the issue of having to deal with 2 colliders, for example
also didn't you want to use a boxcollider or something
it would be easier if you had a list of issues specifically caused by using a capsule collider
a lot of your issues might be interconnected enough that a singular implementation could solve them
Are you able to vc? I really wanna just show it cuz it be soooo sooo much easier to show then to explain the exact one issue which it isnt just one issue
theres no vc in this server
Oh then call just a sec?
Better just make a thread
damn
Video + explanation can go a long way
you'd be sending all your thoughts into the ether, impossible to check after the fact, for yourself or for others
if you did this #💻┃code-beginner message, and had your character as a boxcollider, what would the issues be
you can also just take your time
i'm trying to help here but i can't if you just deflect that it'd have the same issues as before, when i don't even know what the issues you had before were
you dont have to list all the problems in like a second lol
record a video and write up something from 1. to n.
u guys know any tips or guides on avoiding build only bugs
the only way to not have bugs at all is not have any code
Why do that manually? You can do that with either a UI element or a collider
Make a development build and debug it
learn well-known patterns and where/when to use them, use available tooling to your advantage - these can help reduce risk of bugs
but they're kinda inevitable, we can't see the future
you'll get better at identifying bug-prone code (antipatterns), or fixing bugs as you get more experience
Unless you mean build errors
Hey what are good sources to learn all the unity specific methods, properties etc for someone who already has a solid C# background?
Or is the documentation that good 🤣
clicking the (?) on the component on the editor
usually just get the methods, but sometimes an overview
the documentation is sufficient
you would not want to learn all of them lmao, there's so many
if you are into shaders though I would marathon through the shader graph docs and all nodes specifically, also Daniel Ilett has a nice resource for that
how do you put multiple different types of values in a dictionary/array? (e.g. ints and strings in 1)
got a hitbox system working, but passing all these different variables for the properties of the hitbox is obviously not that great
I want to pass a dictionary/array through the parameters which contain the information, but since stuff like what shape the hitbox should be would be a string, I can't pass it alongside other stuff
Dictionary<string, int> amounts = new()
{
["hitboxSize"] = vector2 stuff,
["hitboxShape"] = "Square",
};
you don't. why does this need to be a Dictionary and not just some custom class or struct that holds the data?
it doesn't, I'm just wondering what the method would be
you'd make a struct or class
mk
For example:
enum HitboxShape {
Square,
Circle,
Capsule,
}
class Hitbox {
Vector2 size;
HitboxShape shape;
}```
definitely avoid strings for data wherever possible.
gotcha
i am trying to make a multiplayer pvp pve project and now im strugeling with damage comunication. Is it smart to make a server gameobject wich handels all the damage and says to the objects on the clientside that they take damage?
types cant be passed through parameters apparently
though if you know a better method for storing the stats of attacks and such in one place instead of the script where it's used, that'd be neat cause I'm mostly just working off what I know from workin with LUA
yes, because parameters need to be values
consider generics, though not sure what you're trying to go for here
something like CreateHitbox definitely seems like it'd want to have some data, not just a type
neither am I lmao
as I said I'm just doing what I know from lua which clearly aint gonna work out
I dunno man, I'm tried what they said would work
this is definitely not what one might say would work
Mayeb you're misunderstanding something? The error states that you're trying to pass a type as an argument.
you can lowkey just ignore what I wrote and tell me what I should actually be doing
what is the ultimate goal here?
I want it to take a group of values
eg. the size, location, owner of the hitbox, etc
cool, so attahcHitboxInfo is not a group of values
it is the shape of a group of values - a template, a blueprint, whatever analogy you're familiar with
doesn't lua have this concept too
I dunno man
yeah lua has classes too
Can you show us Player?
How to post code:
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 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 know
any strictly-typed statically-typed language doesn't
again
but even so - you understand the difference between classes and their instances, right?
lua has this distinction
The
varkeyword in Unity (C#) is used for implicitly typed local variables, where the compiler automatically determines the variable's type based on the value it's assigned.
attackHitboxInfo isn't a table there, it's table, the constructor
I'd rather you just fill me in on what I should actually be doing to make a single script handle hitbox creation
anonymous types and shapeless types aren't the same
mate, you're missing a core concept. you aren't going to get far without it
instead of trying to make comparisons to lua when I'm in the dark on the C# side
...which is why i'm trying to give analogies to lua...
Dictionary<Key - probably an int is best depends how you will access, Value - literally any struct or class of your own creation> ???
ok I appreciate you tryna help but ill just
Instead of passing the type like int, pass the actual instance instead like level (a variable of type int(
not what they're going for
In your case, you'd pass an instance of your struct etc
@crimson laurel if you've used classes in lua, this is a concept you're already aware of, and you just need to apply it here.
if not, you'll have to learn this concept. see the beginner c# resources pinned here
What do you mean? Why would you pass a type as a parameter? What are you trying to do?
I feel you're just missing the basics of using types, parameters, classes, structs, and methods in C# here.
dunno if this is more fitting here or in #🏃┃animation but
i made a bunch of rigs for the player character in different angles and set them up so that they have the same sprites/bones/etc
now in Editor Mode, I can just change the Prefab using the dropdown in the Inspector, but how do I do that during runtime, and more specifically, through code?
i did find a 'swap prefab' function in the docs, and it seems to have been deprecated
hey can anybody hop in vc and help me out with some unity issues
would the best alternative perhaps be destroying and instantiating prefabs whenever the direction changes?
Hey all
I've seen so many ways of doing the ground check for a 2d platformer now a days, what's the most up to date and recommended by the community?
I'm also going to have wall jumps
Ray casting, OnCollisionEnter2D, contactFilter2D
It seems that the recommended one, by a unity dev is contactFilter2d? https://github.com/Unity-Technologies/PhysicsExamples2D/blob/d957391d0a2b70225ffdcaede90f40d679df5d1e/Assets/Scripts/SceneSpecific/Miscellaneous/SimpleGroundedController.cs#L17
Thanks 🙂
There is no recommended method. You can use whatever you want and that fits the rest of the game's structure
I went with contact filter 🙂 Seems to work fine for what I need
Hey folks, I have a problem with maths...
I have a drone moving in top-down view on X,Z.
I would like to make the drone tilt slightly in the direction it is moving. Like moving left (X = -1) => Tilt left 30°
How do I code that ? With a smooth tilt animation on top of it :/
How are you moving the drone? You could get the velocity by math if not using physics orjust get the velocity and according to it remap the desired rotation based on the direction
I'm just adding a force in the direction pointed by the inputs
then you should get the rigidbodies velocity and use that
Ok so I map the inclination on the velocity, nice way to have the animation of the tilt.
But where I have a hard time is defining the angle of the tilt depending on the direction
Did you log your velocitys axis and check if you could use that already?
I'm a pure beginner, I don't know crap about what You're talking about 🙂
what words dont you understand of what I suggested and where does google fail in reseraching those terms 😉 First thing to learn, read the unity docs about topics you dont know. If its still not clear, just come back and ask 🙂 The velocity is the directional vector of your current rigidbodies positional change: https://docs.unity3d.com/6000.3/Documentation/ScriptReference/Rigidbody-linearVelocity.html
If you move with adding forces, it will change the velocity according to the physical calculations
I'll read that and check if I can work with it
DroneBody.transform.rotation = Quaternion.Euler(droneTilt.z, droneTilt.y, droneTilt.x * -1); ```
Seems like this is as simple as that 🙂
just be careful with changing the rotation directly, as it will ignore physics for that frame it acts like its teleporting to the new rotated values. If you are only rotating the visuals tho, that would be fine
Yes I have an empty object as my player and the drone body as a child.
Thus I tilt the child which is only a visual
no 👇
!ask
:thinking: Asking Questions
:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #🔎┃find-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.
-# For more posting guidelines, go to #🌱┃start-here
I need a direction on what I should do. Im making a strategy game with castles and walls. Im trying to make an Enemy AI that will priotize breaking the castle but if there is no path, it will break down its closest wall. How do I do this ?
break down the behaviour into simple parts and then figure out how to implement those simple parts
might be pathfinding, finding the wall, breaking the wall for example. how you split it up exactly depends on what you have already
Easiest way would probably be to use the NavMesh and have the walls act as Nav Mesh Obstacles. If the enemy can pathfind to the target, all is good. If it can't, just use something like a Raycast towards the target to get the wall in front of them or use Vector3.Distance to find the distance of every wall, then get the closest one either to the player or to the target
!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.
lil question, Random.value is 0 1 inclusive right?
so
if I use Random.value <= chance it would return true if chance is 0 and value is 0
if I use Random.value < chance it would return false if chance is 1 and value is 1
do I trim 1 or 0 away or something for checking random chances?
Yes it's 0 to 1 inclusive. Whether you use < 0.5 or <= 0.5 makes practically no difference.
It should be inclusive yes, but does it matter is what we should ask?
for reference there's about 1 billion numbers that a float can represent in 0 < x < 1 range
yeah whatever
You can always make a loop and count how often you get exactly 1 or 0, not very often is the answer I'm sure
I just assumed that to check if a crit chance worked out or something I meant to do Random.value <= chance
but after decent amount of time I realized that it won't work I expect it to work on if chance is 0 and random value returned is 0
and I can't fix it by replacing <= with < either
so I have to specify I don't want 0 or 1
right?
what's the easierst way to check a chance
I have this image, I want to make it into a jpg image with the white corners all got cut out, is there a way to do such thing ?
Sorry if this is not the right place to ask
You don't need to check the random value if the chance is 0 or 1. if(chance > 0 && Random.value <= chance) for example
oh makes sense, thanks
Doesn't sound like a Unity question but jpg can't have transparency so you can't have a jpg image that wouldn't have any color in some parts
so I should convert it into a png ? how should I do it ?
With any image editing software
this is a code channel
yeah ok sorry I will bring this question over 2d-tools
Using GIMP you can easy add an alpha. Then yes PNG export
Photopea if u want an online workflow
the conversation was moved to the correct channel, let's not drag up an off topic chat 🙂
hello ! I have a problem, I'm trying to get the position of a part of a model but all of the local positions 0,0,0
I searched a little but didn't find anything useful, or didn't understand what was said
Can you elaborate more on what you mean by this and what code you tried?
I have a board, with a lot of tiles, all of those tiles are at position 0,0,0
I tried drawing a sphere gizmos at the position of one of my tile and it drew it at the center of my board
I understood that there was local positions and world positions but I'm using transform.position and if I understood correctly it should return the world position of the object
also when I debug.log my tile position with transform.position it gives me the correct (I suppose) world position
If transform.position is correct but the gizmo is not in the right place then the problem is how you place the gizmo
I place it at the transform.position of the tile
Also the rest of my code breaks because it seems to take incorrect positions
You'll have to show the code if you want someone to tell what's wrong with it
oh sure sorry !
void OnDrawGizmos()
{
if (currentTile != null)
{
Gizmos.color = Color.red;
Gizmos.DrawSphere(currentTile.transform.position, 1f);
}
}
here is the gizmos code
And if you log the position how did you confirm that it's correct and different from where the gizmo goes?
because the gizmos position is at my board's position and the logged position isn't the board's position
but I might have an idea of what's causing the problem
I told my friend I was receiving his assets 90 degress on the side and he told me to check that box
So i'm curious, does this mess with everything ?
because looking further at the logged position, it's completely outside the board, in fact it's under the board around where it would have been if the board was 90
ok I don't know I'm lost ._.
hey i need help with a project i want to steer a plane using gyroscopic input of android device how can i do it i searched the forum but i couldn't find any thing use full
What part are you struggling with exactly?
Reading the input?
Rotating the object?
Something else?
well i cant understand what kind of output will it give like using gyroscope will it give me input in x,y,z chage and i yes how can i use it to steer the plane
is it possible to move the plane using a vector force as i dont want to do all the friction and drag things
Have you looked at the documentation?
You probably want to use the Attitude sensor if available, not the gyroscope exactly
It depends exactly what you're going for
ok thanks will do
w/e the output you can probably normalize it 0 -> 1 or -1 -> 1
and apply that to ur movement
Help Why doesn't this come up?
And yes I downloaded it with Visual Studio Code installer
but it just doesnt come up
"C#" doesnt come up either
this looks like Visual Studio, not Visual Studio Code
they are two completely unrelated editors (thank you, Microsoft!)
i'm pretty sure this doesn't fix the 90 degree rotation that you get when going from Blender -> Unity
i'm unclear on what it actually does, actually
well the preview of the model is correct now and when placing it the rotation is 0,0,0
alright well we're 2
That’s what I expected it to do, haha
Maybe I just haven’t noticed because I always use the “apply transforms” option in Blender’s FBX exporter
When two systems disagree about which direction each axis points, you have to rotate the model to compensate
To “bake” that conversion would be to change the mesh itself, instead of just giving the entire object a default rotation
So that makes sense
but yea, that doesn't look like
(your image)..
looks like
instead
if so... https://learn.microsoft.com/en-us/visualstudio/gamedev/unity/get-started/getting-started-with-visual-studio-tools-for-unity?pivots=windows its in ur "Workloads" if ur looking for the development environment
Okay so I took a few steps back and now Im just trying to figure out how to properly detect when Im not touching the ground using boxcast because when I jump for like a frame or 2 Im grounded even when Im not supposed to which messes with alot of stuff
I made the box cast super short and this still didnt fix the issue
are there any good resources to create a building system similar to valheims? Code monkeys isnt quite what im looking for and I cant seem to find many resources about modular snapping/rotation online
Hello, I'm here to ask for help with my vehicle which only does Tanger and drift. I've tried modifying it with all the scripts from YouTube, but nothing works; it hasn't changed for an hour.
I spent all day on a tiny bug like this, and I still haven't fixed it. If anyone knows about vehicles...
quick question i have my player inside this gameObject just to be able to move freely since without the GameObject my player would be fixed in 0, 0, 0 now i wonder how do i share a variable from GameObject to PlayerSprite, can someone explain to me how to do it?
using UnityEngine;
public class movement : MonoBehaviour
{
public float speed = 40f;
// Update is called once per frame
void Update()
{
float horizontal = Input.GetAxisRaw("Horizontal");
float vertical = Input.GetAxisRaw("vertical");
float moveAmount = new Vector2 (horizontal, vertical).magnitude;
Vector3 movement = new Vector3(horizontal, vertical, 0f) * speed * Time.deltaTime;
transform.position += movement;
}
}
that code is goona work?
test it
i did its teling me this ArgumentException: Input Axis vertical is not setup.
To change the input settings use: Edit -> Project Settings... -> Input Manager
UnityEngine.Internal.InputUnsafeUtility.GetAxisRaw (System.String axisName) (at <f4e06d84f805445ca5ae28cb191715cf>:0)
UnityEngine.Input.GetAxisRaw (System.String axisName) (at <f4e06d84f805445ca5ae28cb191715cf>:0)
movement.Update () (at Assets/movement.cs:14)
thats the input mangar somthing worng?
"vertical" is not "Vertical" 😉
wym?
case sensitive
u have this: float vertical = Input.GetAxisRaw("vertical");
u need this: float vertical = Input.GetAxisRaw("Vertical");
oh never mind thanks its fixed
quick question i have my player inside this gameObject just to be able to move freely since without the GameObject my player would be fixed in 0, 0, 0 now i wonder how do i share a variable from GameObject to PlayerSprite, can someone explain to me how to do it?
help thnk ^^
sounds like you should read about https://unity.huh.how/references/serialized-references !
thx that should do
A component on GameObject can store a reference to a component on PlayerSprite
or vice-versa
you can then access the public fields of that component
i know about the logic i just didnt know how to do it in Unity specificly as i have coded in other languages and engines
also, if you're wondering why you had to do this: I'm guessing you have an Animator on PlayerSprite (and it's trying to set the position of the player)
and yeah, this is the correct way to handle that
parent it to another object that moves around
thx
Hello:)
I'd like to ask if anyone know
what this
Screen position out of view frustum (screen pos 601.000000, 395.000000, 0.000000) (Camera rect 0 0 1059 494)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
mean
😭 😭
thank god
that scares me
the bot is doing a great job
hey does anybody have a second to vc about some unity questions
better ask here so more people might help you
here as in this subchat?
depends on your questions if code related yes
yes, i cant get my capsule (player) to bind to a controller. my code may be bad
: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're gonna have to give some more detail than that
what do you mean by "bind", and what do you mean by "controller" here?
well, ill put this out there i have NO idea what im doing. ive just started learning all of this in the past 3 days. so i had gemini write me a character movement script that is supposed to be binded to WASD. I link the "character conntroller" to that script component and i get an error. i was hoping someone could look at my code and tell me whats wrong with it as i dont even know what to look for.'
At the very least, you need to share the error.
i dont know where to start leearning tho. im not really good with youtube tutorials. and every other person ive contacted has just say use AI
But mainly, you should actually do a tutorial on character movement so you're doing the thing yourself.
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
Unity has an entire series on learning the engine and basic coding. Including on how to make things move.
UnityConnectWebRequestException: Token Exchange failed due a failure with the web request.
UnityEditor.Connect.TokenExchange.VerifyTokenExchangeResponse (UnityEngine.Networking.UnityWebRequest exchangeRequest) (at <653e87cf2eee46cba35f0658f2b1887c>:0)
UnityEditor.Connect.TokenExchange.TokenExchangeRequestAsync (UnityEditor.Connect.TokenExchangeRequest tokenExchangeRequest, System.Threading.CancellationToken cancellationToken) (at <653e87cf2eee46cba35f0658f2b1887c>:0)
UnityEditor.Connect.TokenExchange.GetServiceTokenAsync (System.String genesisToken, System.Threading.CancellationToken cancellationToken) (at <653e87cf2eee46cba35f0658f2b1887c>:0)
UnityEditor.Connect.ServiceToken.GetServiceTokenAsync (System.String genesisToken, System.Threading.CancellationToken cancellationToken) (at <653e87cf2eee46cba35f0658f2b1887c>:0)
UnityEditor.Connect.UnityConnect.RequestNewServiceToken () (at <653e87cf2eee46cba35f0658f2b1887c>:0)
System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) (at <1eb9db207454431c84a47bcd81e79c37>:0)
That has nothing to do with your code, that's something to do with the editor.
oh lord
You can use Google (I know, in the world of AI this is a scary thing), to search the exact error up and see what people are saying about it. You're not going to be the only one who would have had it.
do i just paste my error in to the search engine
Have you never used Google before?
i just didnt know if i out the whole thing or if just a piece of it will do
You type something in it and it'll find similar results. So something like UnityConnectWebRequestException: Token Exchange failed due a failure with the web request. would be enough to get something back.
I downloaded the Game Development with Unity thing. But nothing comes up when I write something ( like it doesnt recommend things ).
ANd since I'm new I would like Visual Studio to show me recommend script
But I'm gonna download Visual Studio ig
ive heard anti gravity is nice alternative to visual studio
I'm not using knockoffs
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
Well I have visual studio
This has the guides for setting up VS or VSCode with Unity. If you install VS through the Unity Hub, it'll auto configure.
the pink one
Look, I just want have to get the Unity Script Recommendations on Visual Studio. But I don't know how, because it's not in the extensiosn and I also added it at the download.
right, that's what the configuration instructions are for
Look, just follow the IDE Configuration instructions.
also vs is usually referred to as purple, i don't think ive heard anyone refer it to pink. that's a first for me lol
"
Select Modify or Install to complete the installation."
It tells me literally
nothing
about my goal.
You installed the module?
These things have nothing to do with the Unity thing
Download the Visual Studio installer, or open it if already installed.
Select Install, or Modify if Visual Studio is already installed.
Select the Workloads tab, then select the Game development with Unity workload.
If Unity isn't already installed, select Unity Hub under Optional.
Yes.
And it still doesn't recommend me anything
no script
no nothing
And you decided to stop reading after that point?
In the Unity Editor, select the Edit > Preferences menu.
On the left, select the External Tools tab.
I did this.
I watched 4 tutorials on it
The rest is about how to set up Unity
Now VS with Unity
But it's not different with the blue one
Okay and in your opinion, those steps don't matter?
VS has nothing to do with Unity directly,
If it says "How to set up unity"
and another thing says
"How to set up unity with VS"
Okay, sure. Good luck. 👍
I only read the second thing.
Alr. Tell me what this has to do with VS?:
Open the Unity Hub, which was installed during the Visual Studio Tools for Unity installation.
On the left of the Unity Hub window, select the Installs tab.
Select the Add button.
In the Add Unity Version window, select a version of Unity to install.
Select Next to continue the installation.
In the Add modules to your install step, select Done.
One single thing?
I downloaded Unity Hub 1 year ago.
Exactly.
Nothing.
Maybe, just maybe you could help next time. Telling somebody to read things they already read, which have nothing to do with VS does not help.
I am not sure if you even read the article.
You should actually do all of the steps instead of just picking the ones that look relevant and ignoring the rest
In order
As I said.
What does this have to do with VS?
Open the Unity Hub, which was installed during the Visual Studio Tools for Unity installation.
On the left of the Unity Hub window, select the Installs tab.
Select the Add button.
In the Add Unity Version window, select a version of Unity to install.
Select Next to continue the installation.
In the Add modules to your install step, select Done.
"If .... you're read to set up Unity". Guess what. I set up unity 1 year ago.
So it's not actually needed to read "How to set up unity".
But "Configure Unity to use Visual Studio" is very interesting.
So I read that.
@undone terrace Stop spamming the channel and follow instructions
I followed the instructions. I watched 3 tutorials. Nobody could help. Now I ask for help and they tell me to follow instructions?
Because the instructions have worked for everyone who's actually done them
have you set the external tools
Like, let's use a bit of critical thinking. If you have installed Unity, then obviously you can skip that part to the Configure Unity to use Visual Studio that follows. This article, from microsoft, is an all encompassing article for setting up both VS and Unity and then configuring them to work together.
Yes.
use a bit of critical thinking
They haven't been allowed to teach that in schools since the bush administration
Why should I skip "Configure Unity to use Visual Studio"?
Why would you skip that
You wouldn't. Reading comprehension is clearly something you're struggling with. Skip to the Configure Unity to use Visual Studio part.
he's saying to skip to that part
I will not paste this again, because Iwill get banned.
I will explain myself one last time.
Honestly, this article has less words in it than you've posted here arguing lol.
1 Year Ago I downloaded Unity.
Great
2 Articles: How to download Unity. How to download VS.
Sound perfect
Why should I read "How to download Unity"?
You shoulnd't, nobody is askin you to.
no-one is telling you to
Why would you skip it when the thing you were replying to specifically told you to do it
It's baffling that you're hung up on that fact.
Because, I set Unity up ( 1 year ago). After I was told you I read it ( you can notice because I pasted it above ). I asked where the specific point was, which could help me.
Yet nobody asnwered me to this question.
And you were answered
Where?
You were given exactly what to do
Alright, this is going in circles lol. Make a thread if you want to continue this, please.
I am repeating myself. I READ THE ARTICLE
THE ARTICLE COULDNT HELP
NOW IM ASKING FOR HELP
That's what Humans are for.
I watched 3 tutorials, READ THE ARTICLE, and I don't know what to do?
And humans wrote that article
which tells you what to do
and when you asked for clarification of if you can skip a thing
This Channel is COMPLETLY USELESS, if everybody just says "Read an article".
you were told to
I READ THE ARTICLE
and then you invented a different thing that you thought you were told to do
do you want us to just repeat the same steps in the article one at a time
like, those are the steps to do it
what exactly are you expecting us to do?
I'd like to know, why My Unity is not able to recommend me scripts.
I sended you photos
I can give more information
I was answered to read the article.
that would be because it's not configured
I read the article.
You can do so in the thread
Install VS, install the module, set the editor in options, install the package
donezo
Make a thread, show your screenshots of your set.
Oh really? That's why I told you 100x times I CONFIGURED IT.
Alr wait.
If it were configured, you'd have code suggestions
i don't doubt that you've tried to configure it before. obviously, something has gone wrong. we aren't trying to find blame here
If you're not going to make a thread, then stop using this channel.
I am going to make a thread if you stop replying to my messages
You're just going to get muted, so either make the thread or don't.
jesus it's not that hard
Baffling
hi
Thank you
you could have done that yourself, but sure
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
!install
- Make sure you have enough space including on
C:drive. - Check that it's not being blocked by antivirus/security programs.
- Look through the logs for a real reason why the setup fails they are pinned [here](#💻┃unity-talk message).
If you still have issues, perform a clean install in another location:
- Install the Hub and Unity in a non-system drive or a clean new folder in the root of
C:drive. - Failing that use the recovery Refresh option or reinstall OS entirely then repeat the previous step.
You can stop spamming the bot commands, thanks.
☠️
Hello! I have an issue where I load a scene, but when I try loading it again it does not work.
ex. I have a Main Menu where I can click a button to open another scene where I can choose what ship to use. Although if I go back to the menu I cannot load the ship selection scene. I am very new to unity so plz help :]
you're gonna need to provide more info, like what happens when you try and the relevant code
is there somewhere I can upload screenshots and code?
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 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.
screenshots you can just send here, but be wary of sending too many lest you get timed out lol
A tool for sharing your source code with the world!
am I supposed to unload a scene? I am fumbling in the dark here
I could share my screen if possible
in a vc or something
If you just load another scene, it'll unloading any existing ones.
well, then I am unsure why it does not work. Supposed to be able to switch between menus, but I cannot 😐
Put Debug.Logs where you think things should be happening to verify the code is actually being called.
could you be more specific with "it doesn't work"?
is it erroring, just not doing anything, or doing something unexpected?
not doing anything
go through what osteel said
could it be cause the references on the buttons disappear when I load another scene?
the object with the script has dontdestroyonload
yes, that would be exactly why
Hay I'm having constant issues with my ledge grabbing script, from what I can deduse is that the SphereCast I have just dose not work but I have no idea why.
This has been going on for days now and I'm at my witts end.
What debugging steps have you taken?
Spherecasts don't just "not work"
I put in some debug.logs to see what is activating and the Spherecasts just never turns on.
You're going to need to show details
Spherecasts do not detect things that start inside the sphere
"just never turns on" is not helpful
The sphere needs to actually hit them during its movement
Yes but it's just not detecting anything.
What is the radius, length, and layer mask your passing to the cast?
And when are you calling the function
I'm calling the function in the update. I don't think I have a radius but I do have a length of 3 and the layer mask is WhatisLedge.
Why is it a spherecast at all if it doesn't have a radius
If it doesn't have a radius then it can't hit anything
Is this where .OverlapSphere comes into play? (I'm reading online that's one of the main differences.)
(Sorry late reply
)
guys i want to know by which angle my object is thrown in the air (it's in projectile motions)
i was thinking about making a system in which an arc appear on the path of my thrown object
Can you get its velocity vector as it is thrown, and find the angle of that from horizontal?
I have 2 objects in 2D objectA and objectB
I want objectB to always look at objectA I mean rotate its z towards objectA's position.
how can I do this?
Transform.LookAt points the Z axis at another object which is not ideal in 2d.
all that needs to be done here is set the transform.up or transform.right (depending on the direction it faces at rest) to the direction between the objects which is just (endPosition - startPosition).normalized (although you don't actually need to normalize it here since those properties are normalized automatically)
Yeah, you're right, forgot about that
let me try this, I'm a new Unity and in programming too.
red one toggles between two x positions
then black always face towards red object and lerp to that position.
using UnityEngine;
using UnityEngine.InputSystem;
public class Gun : MonoBehaviour
{
public Transform raycastPos;
public Transform cam;
float distance = 2f;
public Rigidbody player_rb;
public Transform player;
float force = 7f;
bool looking_at_ground;
void Update()
{
Ray ray = new Ray(cam.position, cam.forward);
Vector3 origin = raycastPos.position;
Vector3 direction = cam.forward;
RaycastHit hit;
Debug.DrawRay(origin, direction * distance, Color.red);
if (Physics.Raycast(ray, out hit , distance))
{
if (hit.collider.CompareTag("Ground"))
{
looking_at_ground = true;
}
else
{
looking_at_ground = false;
}
}
}
void OnFire(InputValue val)
{
if (val.isPressed && looking_at_ground)
{
player_rb.AddForce(Vector3.up * force, ForceMode.Impulse);
}
}
}
you cansome tell me why the there is no force
log the values you are checking and compare them to what you expect them to be
bro i just want to addforce not pos
huh? i am telling you to debug your conditions mate
i did and it is normal
wdym "it is normal" what is normal, and what does "normal" mean in this context
oh wait a min
thei nput system of the FIre is not working so that si the problem but it is the same name as in the input manager
and what object is this component attached to? and does that object have a PlayerInput component on it? because that is what is sending the OnFire message
omg i forgot to add it 😂
i know its initial velocity ,(i want to make something like grenade throwing mechanism where we can see that red arc to throw my nade )
i am having a problem picking the right rigidbody2D types and setting the right colliders with triggers.
this looks like a nightmare tbh, any ideas as to what i can do to resolve such kinds of issues?
What is the actual issue?
I have four rigidbodies in total:-
-> The Dragon Garbage: Has a Box Collider placed on it,so that when any unit is placed on it , it blasts it away, destroying the unit.
-> The Unit: Has two colliders (circle and box), I want box to detect collision with Garbage, and i want circle collider to detect collision with enemies (to know whether an enemy is in range or not, if it is, then it shoots bullets at said enemy)
-> Enemies: Has a Polygon Collider
-> Path: Has a Collider on it. (If a unit is to be placed on the path, it detects collision and destroys the unit)
My first thoughts are. You could use something like a spherecast instead of relying on ontriggerenter or whatever to detect enemies. You can use the physics matrix to separate layers of collision detection in your settings too.
Place objects on specific layers. Use OverlapXXX methods or XXXCast methods to check for collisions (filter them based on layers). Or you can use triggers and check for specific components on the collided objects. That's it . . .
"Or you can use triggers and check for specific components on the collided objects", doesn't the object produce a collision if any of the colliders attached to it, collides with another collider? that doesn't rly check which collider it collided with...
You should look at the docs/manual on what the Layer Collision Matrix is . . .
get the angle of motion
this one i presume
out of curiosity, what for does KeyCode.None exists?
i guess i will just need to check out how other peeps do it then
You check which object collided inside of the trigger method. That's typical and pretty much how unity trigger and collision methods work. I'd look at a tutorial on trigger/collision methods . . .
Unbind key bindings?
that's not what i said, what i meant was that, if an object has two colliders on it, then whenever one of them has a collision, the OnTrigger event will be triggered no matter what(given they both have trigger enabled). it's not like, i can set it such that it would happen iff one of those colliders detects the error
Each separate collider should have its own GameObject. Each of those GameObjects will have their own script. Each script will filter and check for a specific component, layer, etc. That is how each of them—the colliders—will detect only what they need . . .
💀
i just attached the colliders onto the actual gameObjects themselves
You can just make an empty child object and put the collider + script on it, for each collider on the object
exactly what i was thinking
ima cooked
That's fine, but if a GameObject needs more than one collider, place any other colliders on an empty child GameObject . . .
Hey folks I would like a bit of help with a singleton issue.
I have my game manager as a singleton, I create an instance of the GM on the awake method and I use it for scoring/UI management. But also for a boolean stating if the game has been paused.
When I start the game it doesn't seem to have any issue, but if I start a new game (reload the scene), one of my script attempting to access the boolean cause an error.
I have no idea why
Seems like it only make the error once per script (73 times) and then stop making errors
Does the GameObject with the singleton already exist in the scene that is reloaded?
Or is it initially in a different scene?
It's for storing keycodes to variables. For example here "not set" would be KeyCode.None. That way you don't need a separate check for if the keybinding is set or not
I reload the same scene. The GameManager already exist but I destroy the instance when I reload to avoid weird interactions.
Ok, this might not be a beginner question, but I was unsure of which channel to ask in. Is it possible to subscribe to the same events that OnTriggerEnter and OnTriggerExit methods use?
it is not
Ok, thank you. I will just have to make a script just handling that then.
hi guys i need a professional opinion
is this an ok way to do animation transition?
it looks real messy to me
This is a code channel. Ask in #🏃┃animation
ok got it sorry
is there anythign special u need to do to get mesh lod working in unity 6.2, i cant see it working
this is a code channel, are you doing something code related with that? If not #🔀┃art-asset-workflow seems the better channel
kinda basic question, but I'm not quite sure about management of coroutines and if I understand it fully
if I call StartCoroutine, then cache the resulted routine into a field and after some time call StopCoroutine on that routine reference: will another StartCoroutine call with the cached routine will create a new instance of the coroutine (and so create garbage on every start of the routine) or it will reuse the same instance of the coroutine object every time (so no garbage on every start)?
It creates a new one
another StartCoroutine call with the cached routine
You can't call StartCoroutine on the same IEnumerator that waas already used elsewhere.
Actually maybe you can but it's a bad idea, it will get iterated twice as fast
you want to make a new one each time
You cannot restart a coroutine
What you can cache the yield instructions though, if you want to save performance.
oh, thanks!
tldr there's no way to avoid creating garbage when starting a coroutine.
does anyone know any good tutorials for making a substantial 3D platformer?
when I say substantial I mean like what 20+ hours of work total?
20 hours of work on a platformer is like, doodle jump
when i hear substantial that sounds more like couple years
there's not many tutorials like that period
okay good point
im just
trying to complete a school project
and
i need something
it cant just be over in like 5 hours tho
Probably better to do something simple then improve it
School projects probably shouldn't really be substantial, simple is better
than setting out to do something big
oh they want it to be like 1-2 months of work
i say school project but its an official examination board
make something simple then make it really simple and really good
i can't really program tho...
thats why I need a tutorial
and if youre wondering why I don't just learn
its because I have nowhere NEAR enough time
im not just being lazy I promise
sigh
learning is 2 months of work
no
i will have learnt
thats the solution
and will have no project
you learn by making the project..
You learn by doing
have you tried searching?
idm learning if it ends up with a finished product
Surely the people who have given this task, can provide resources for learning
nope
theyre not allowed to help
its an exam board
i shouldnt have called it a school project
its a non exam assessment sent by a national examining body
They can't help you make the project itself
Providing resources isn't the same as them making it for you
You can look for not so specific tutorials, learn, and then try to apply your new knowledge to what you actually want, experiment, fail, retry then finally succeed. Even if the result is not as shiny as Mario 64, the learning process is here and you have a thing.
oh, well in that case no they didnt provide any resources
You need to relay your issues to them, see what guidance or advice they give you
okay let me show you what it is i actually need to do
(if you have no programming experience and need this done in 1-2 months i'd suggest making something in 2d and not 3d)
this is oversimplified
hold on
i need to do all of this with the project
I didn't suggest any 3d. I suggest learn minimal stuff (make a character jump, interact with an item, spawn enemies, whatever) and try to expand.
i cant go in to a tutorial blind if idk if it will work out
or im putting the entire subject at risk
(i already did this once actually im trying to fix it now)
i tried doing a project in unreal 5 and it failed miserably
this requires you to code
you need to learn how to code
so now im dedicating myself to unironically, no joke at all spending the next week pulling non stop all nighters to fix it
then you will fail
this is how much code im expected to know:
naw everyone just uses tutorials.... hence why im here!
basically nobody in my class knows how to code
to learn how to code
...they just follow tutorials
follow those tutorials then
(none of them are really learning, they just dont know how)
i cant make the same project as them
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
is this a post high school thing
no
but i need it if i want to go to uni
For your sake, you have to tell your teacher about the problems your facing. Only they know what they can and cannot provide you, and I'm sure they'd rather you have the ability to begin working
i have 😭
im like
5 months into this
i already made a project
tried to learn
i watched tutorials
messed up
and now i am absolutely screwed beyond imagination
i have like 2 months to catch up and finish development
when other people have already finished their entire project
To be completely honest homie we can't help you here
