#💻┃code-beginner
1 messages · Page 825 of 1
Yeah I'm doing that for mouse clicks. I have onpointerdown/up working nicely with it. But I can't find equivalents for a controller
You need to handle this from the input system side not the UI event system side
started / canceled phases for the input action
Started/cancelled?
It really depends how you're doing input handling in general
Depending on if you're polling or using events, it's a bit different
Events
Currently using IPointerDownHandler and IPointerUpHandler in the script to grab those events for mouse and touch
Event system pointer events work the same on both input systems (as long as the event system is updated if showing a warning)
This stuff does not apply to reading device input directly
I'm so confused 😅
Want to know when a game pad key is pressed? input system action/direct device events
Want to know when the pointer clicks a collider/ui element? Event system pointer events.
event system pointer events exist at a higher level as they just inform you when a pointer does stuff to a collider/ui element.
Doesn't the input system actions have to be done on the gameobject of the input action part?
Unlike IPointerDownHandler
I do not understand your question
input system actions can be "listened" to and have their state read in many ways in code
The input system messages are only sent to that game object and its children (if it's broadcast)?
Yes but that is just one way to use input system actions. You can also just get an action and subscribe to events in code without the helper component.
And I can specify an action through that and then listen for it with On<action>?
Yes you can find an action by name and listen to its events and do stuff
If you want to keep using PlayerInput you can get the current action map and find an action by name from this instead.
Either way you can find an InputAction and interact with it!
hello, does anyone know why my player doesn't wanna stop sprinting?
public void Sprint(InputAction.CallbackContext context)
{
if(context.started)
{
IsSprinting = true;
}
if (context.canceled)
{
IsSprinting = false;
}
if (IsSprinting)
{
Speed = SprintSpeed;
}
else
{
Speed = WalkSpeed;
}```
How did you set this code up to run
i have a player input on my player
and how is the inputaction set up?
might want to move this to #🖱️┃input-system
Ok and how did you hook this up to it?
events
Please be more specific
ok then yeah please show the action configuration
how is the input action set up
Add this as the first line to this function:
Debug.Log($"Sprint callback running with phase {context.phase}");```
And show us what prints when you press and release the key
@naive pawn dunno whether i had this convo with you or not, but remember how my projectiles were meant to track an enemy and destroy on collision? and the problem was what would happen if the enemy object got destroyed before the collision even took place...i came up with the following possible solutions:
- On making bullet, get a reference to the tower. When target object is destroyed, reference the tower's enemy list to get a reference to get the next enemy in line
- On making bullet, tower stores a reference to the bullet. If a target gets destroyed when in range, it iterates through the list of bullets and finds the bullets which have a null ref (due to the target getting destroyed) to the target. Change the target to the foremost target in range
looks like the input handling is fine. I think the problem is probably in your movement script then
(fwiw i think you'd need performed, not started, to handle the presspoint for analog inputs correctly - that shouldn't affect the current issue though)
no need to ping specific people for help
Also make sure the speed values (WalkingSpeed, SprintSpeed) are set up correctly in the inspector
it is
and uh yeah no i don't really remember
should i set the speed
show us the full Player script then
in the if (context........) function?
yes it's fine to do it here
couldn't you just get the speed based on IsSprinting in the actual movement function
that seems like it'd be simpler/less spaghetti
you could do that too
They should both work but we need to see the rest of the 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.
Can you show the inspector for the Player script on the player with all the populated values?
Also in the inspector is the IsSprinting checkbox working as expected when the game runs?
👍
What about the Speed variable?
good but i think i found the reason why it isn't working
my acceleration code is changing my speed
Currently I have this setup:
A Tower, Bullet and Enemy
- When enemy in range of tower, bullet is made.
- Tower gives a ref to bullet of enemy on making the bullet.
- Bullet moves towards the tower until it either collides or gets destroyed beforehand.
Issue:
- Currently, when the target is destroyed before the bullet hits it, the bullet ends up getting stuck at the same place. I have a timer set on it which destroys the bullet once its lifetime reaches a certain threshold
What I want to do:
- Make bullet redirect to the next enemy in range when it's target enemy is destroyed.
Possible ways to achieve this:
- On making bullet, get a reference to the tower. When target object is destroyed, reference the tower's enemy list to get a reference to get the next enemy in line
- On making bullet, tower stores a reference to the bullet. If a target gets destroyed when in range, it iterates through the list of bullets and finds the bullets which have a null ref (due to the target getting destroyed) to the target. Change the target to the foremost target in range
Question: Which one should I commit to?
it looks ok to me at a cursory glance...
oh i think i found the problem
and it's so dumb
it was that my speed variables were too high
and with the acceleration, i couldn't notice much change
so it was working fine
sorry for wasting ur time
odd, i'd expect it to take 2 seconds to go from sprint speed back to walk speed (and vice versa) with those parameters
i tweaked it around
and set it to 20
How do I manually make unity reload environment or something like that?
I changed a file and normally it should say “reloading envirmontment” or something but now it doesn’t
so i can’t test my changes
ctrl r
thank you very very much h
do you want the bullet to redirect like a ricohceting bullet from enemy to enemy until it's gone, or do you simply want bullets from the tower to consecutively hit the next closest enemy? This seems like a design choice to me rather than an optimal approach
the latter
I want the bullets to change target when their current Target is destroyed by another bullet.
So you should go through the enemies kind of like a queue, you must first choose an "enemy" to be the target of the tower, then you shoot bullets only to that target. When the enemy becomes null or destroyed, you then recalculate the next enemy to be the tower's target
i already have the target setting mechanism working, only problem now is that i need to make it somehow change its target, i guess just use a queue then
//don't check for null, instead check whether target is active or not since pooling is implemented
if (_target.gameObject.activeInHierarchy != false)
{
Vector3 direction = (_target.position - this.transform.position).normalized;
this.transform.position += _bulletSpeed * direction * Time.deltaTime;
if (Vector3.Distance(this.transform.position, _target.position) < _blastRadius)
{
_dropletBulletpool.Release(gameObject);
_duckPoolContainer._duckpool.Release(_target.gameObject);
//set target gameobject's elapsed time to 0, so that it doesn't spawn at the same spot
_target.gameObject.GetComponent<SplineAnimate>().ElapsedTime = 0;
//Destroy(_target.gameObject);
}
}
else //redirect projectile to next enemy
{
}
do you want the last bullet that kills an enemy to not be destroyed and hit another enemy?
so if the bullet hits, it gets destroyed. then all the other bullets in runtime change target
the bullet that hit the enemy is destroyed
oh okay so you want all bullets already fired including the tower's new bullets to change target
well if your problem is redirecting each bullet, dont you have a list of all active bullets somewhere? you could set these from the tower. I recommend not having each individual bullet calculate its next target as that can get costlly and perhaps complicated
ahh, i didn't think of it that way. every bullet would have to access the list or queue, but if it were just the tower, all it would need is access the queue, then iterate through all of its bullets i guess
yeah, treat the tower's target as a single source of truth for all the bullets
i will also need some form of a query in scenarios where if the target does go out of the tower's range, then the bullet sends a signal to the tower to change its target to the next one in range
I dont think you would need a queue, because the enemies are constantly moving so you cant simply use a snapshot and store it in a queue
I guess you could check every frame if the current tower's target is in range, otherwise change targets
i think i can actually, everytime an enemy trigger onctriggerenter, i can push it into queue and then if ontriggerexit gets triggered i dequeue it out
i don't need to check every frame as that would be costlier
i can just use collision triggers to find out
I still think a boolean check of position is less costly than what you're suggesting
checking whether enemy is in range every frame is less costly than updating the queue only when collisionexit is triggered?
I also recommend not relying on oncollison enter and exit i've found those to have some inconsistencies depending on speed of collision
sorry, not collision, trigger
you mean only checking when the bullet hits it? What if it's long gone before the next bullet is able to hit it to give information
if you're willing to have that compromise I guess it's probably more optimal, but I still would say it's not worth it if you have one enemy as a target
well, then i can just use ontriggerexit to find that it's gone from the game scene, in which case, i can make the tower change its queue
i have 5-10 enemies as target at times
it's a tower defense game lol
So you mean the bullet goes through an enemy completely and exits the collider?
because that's the only way on trigger exit is running, it doesn't run if an object is destroyed within
wait lemme draw it out, that would help you understand it better
you could also just have the boolean check right before you spawn each bullet, and that would be just as optimal and much less complicated
truth be told, i think it does O_O i recently faced a problem with this exact scenario where if the object was in a collider and then got destroyed or disabled, it triggered oncollisionexit
how did you find a month old comment? 😄
from:me trigger
Oh, well i honestly thought it didnt work, but it's still not a territory i'd suggest relying on
oh that conversation was with you, ok makes sense then 😄
just so that i don't misunderstand, you are telling me to calculate the distance between the tower and the foremost enemy in range every frame, and then, if it does go out of range, it is supposed to iterate through the bullet list and change their target to the next enemy in range, correct?
then i would also need to worry about enemies which do get destroyed when in range and alter the list
Initially yes, but I think a better approach is to calculate the position of the target only right before shooting a bullet, and if it is out of range, recalculate target, then send all active bullets to that new target. Only saying the last part as that is what you had in mind, although i think it may suffer from constantly switching between options
well you'd have to worry about that regardless no? when you are shooting to a target, it can't be null anyway
what if the bullet were already following its trajectory and the target moved out of range of the tower while the bullet is on its way?
you said to recalculate target when another bullet gets shot, what if there's only one bullet
you could allow the bullet to finish, which i've seen some games do, or destroy all bullets at the boundary of the tower's range
i am currently doing that, and trust me when i say this, it genuinely looks wack xD
it keeps following the duckies when out of range lol
hilarious
yeah then you should probably destroy bullets at the boundary
are these homing bullets?
yes
I see, well still destroying them at the boundary works for that as well
i guess its a matter of what i want and not of implementation at this point, still thanks. i will try to see what i can use. the info you gave me will help me decide stuff!
No worries good luck on the project!
once the tower shoots toward its target, it doesn't matter if it exits the range . . .
unless it's a homing projectile, you only need to provide the bullet with a direction (to shoot) . . .
is there like an attribute so some variable is seen in non-debug inspector even if private?
naughty attributes has one, or make your own
I am honestly hesitatnt to get plugins for Unity
gotta make your own then..
NaughtyAttributes is a well used asset though its been around for a while
can someone help me my audio player doesnt work for some reason and idk why
!ask 👇
pay particular attention to the last few lines
: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
gonna need more info than "doesn't work"
when i do sound.Source.Play() is gives me a ArgumentNullException
the variable you are calling Play on is probably null
its not
i have if its null theres a line above it that checks and tells me if its null
📃 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.
this is the code in the player
and this is what im calling from a different script
that does not prove that s.Source is not null
if i leave it null it works it tells me te sound isnt found
you have not assigned an audioclip
(it would be a different error...)
it actually wouldn't
it would be an NRE
you would think it would be a NRE but it's somehow not
so what do i do..
make it no be null
find out what is null and make it not null
it's not an extension method
it would be an NRE, then, no?
guys its not null//
prove it
have you actually confirmed you've assigned an audioclip to the audiosource
pretty sure
i'm trying to find the source, but i have seen this like a dozen times where the AudioSource variable is null and calling Play throws an ArgumentNullException
validate that.
this is the same audiomanager ive always used and its always worked
prove it, don't just assume
how do i proce that
how do you prove its not
null check both the audio source and the clip assigned to it
so far you're only null checking the thing that has a reference to the audio source
wdym check the clip
Debug.Log or breakpoints
s.Source.clip
you've only checked that s isn't null
we're saying to check if s.Source and s.Source.clip are null
did they change it ?
not sure it should matter if you do Play without a clip assigned gives that error
and how do i do that
how are you checking that s isn't null? it's the same concept
it's an NRE, just tested.
just add this before the Play line:
Debug.Log($"Is the Source Null? {s.Source == null}");
Debug.Log($"Is the clip on {s.Source} null? {s.Source.clip == null}");
and show what it prints
it gave another error
what error
what was the error
when it was trying to check s.Source.clip it spat a nullexception
and what was the result for just s.Source?
must be a recent change, i found a few stackoverflow and gamedevstackexchange questions about this that indicate that it at least used to throw ANE for a null source
source is null
mic drop
ah, gotcha
so what do i do now
make it not null
what even is source
presumably the AudioSource assigned to s.Source
assign it an actual value
i think i've encountered that before (helping here), i guess i'll try to commit it to memory this time lol
ohhh yea its a variable
i tested on 2022
there is not one assigned to the Source variable, correct
so the situation now is
it does create the component with the right clip and settings
i dont even know what to check
the img is red bc its running and i made it go dark red during runtime
are you certain that the line that is throwing the error isn't being called before this object's Awake method is run?
no its after i click smth with my mouse
i didnt try it yet i js clicked play to get this screesshot
you're going to need to show more context then
what do u need to see
all of the relevant code and anything that may be relevant in the scene
thats pretty much it
when i start the audiomanager creates audiosources of all the sounds it has
and whenvever i click mouse button 1 it plays one of them
is doing s.Source = gameObject.Creatcomponent valid?
depends how Sound object is managed and all that
not without more context
also why does each sound have their own AudioSource why not just a few and swap audioclips
its js how the manager works
its kinda old so maybe its a little trash
i think i found the issue tho
unhide the AudioSource field, does any items in array have Null one ?
i added the debug line and its giving a null exception here
its not updating s.Source at all
how do i fix that..
that's throwing a NRE because you haven't assigned to it's clip yet
s.Source is getting assigned here
of course, that doesn't prove that the s.Source you are accessing elsewhere is the same which is why we need all of the relevant context
well its giving me an error whenever i try to call s.Source.clip.name
yes because the clip is null like i just said
how is that going to help? we can literally see it being assigned here, and it still isn't the clip that is the issue in the other code
bc then itll check AFTER the clip has been assign
if u noticed the s.Source.clip = s.Clip line
was after the debug
wasnt that what u were saying?
you're focusing on the wrong thing
just give us all of the relevant context so we can actually help pinpoint the underlying issue here
i dont get what else u need
show the full class and relevant inspectors for these objects if you are unsure because i have no idea what other context there even is
!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.
this is the Sound class, the audio manager, where the Audiomanager.Play is being called from and the AudioManager from the editor
where do you assign AudioManager btw
u mean to the other script?
In PlaneterBoxController
are you sure there isn't like a duplicate thing going on here
both audiomanager and the planterboxscriupt game object are both prefabs
if that matters
wait
i found the issue
the fact theyre prefabs does matter aparently
are you assigning the field with the prefab?
because yes that does matter
if you need a reference to that specific one in your scene then yes
you need to assign it at runtime
this is why context matters
i did some testing on 6.4, 2022, and 2021. it looks like this doesn't happen at all in 6.4, but in the other two versions i tested (both latest publicly available minor and patch) it happens with serialized AudioSource variables, non-serialized variables throw NRE as expected
try { _serialized.Play(); } catch(System.Exception e) { Debug.LogError(e); }
try { _nonSerialized.Play(); } catch(System.Exception e) { Debug.LogError(e); }
6.4 gave the expected "you probably need to assign in the inspector" error for the first line
when i tested it was just AudioSource s = null; s.Play(); inline
so yeah that's... weird i guess
I can't yet figure out why my method allows the ray to be 0 while I think I did all needed checks, I am probably missing something but staring at the code haven't helped so far, any ideas?
private Vector3 GetAssumedCollisionPoint(Collider other, out Vector3 assumed_hit_normal)
{
Vector3 assumed_collision_point;
Vector3 previous_pos_for_checking;
if (previous_pos == Vector3.negativeInfinity)
{
Debug.Log("failed to simulate collision point");
assumed_hit_normal = -body.linearVelocity.normalized;
return other.ClosestPoint(my_collider.bounds.center);
}
assumed_collision_point = other.ClosestPoint(previous_pos);
if ((assumed_collision_point - previous_pos) != Vector3.zero)
{
previous_pos_for_checking = previous_pos;
}
else
{
if (previous_previous_pos == Vector3.negativeInfinity)
{
Debug.Log("failed to simulate collision point");
assumed_hit_normal = -body.linearVelocity.normalized;
return assumed_collision_point;
}
assumed_collision_point = other.ClosestPoint(previous_previous_pos);
if ((assumed_collision_point - previous_previous_pos) != Vector3.zero)
{
previous_pos_for_checking = previous_previous_pos;
}
else
{
Debug.Log("failed to simulate collision point");
assumed_hit_normal = -body.linearVelocity.normalized;
return assumed_collision_point;
}
}
Ray ray = new Ray(previous_pos_for_checking, assumed_collision_point - previous_pos_for_checking);
//more unrelated stuff later
}
somehow sometimes ray have Vector3.zero as direction
bit of context which is probably not important
private Vector3 previous_pos = Vector3.negativeInfinity;
private Vector3 previous_previous_pos = Vector3.negativeInfinity;
void FixedUpdate()
{
previous_previous_pos = previous_pos;
previous_pos = my_collider.bounds.center;
}
yeah, it seems to be related to unity's fake null for inspector serialization. i'd bet this wouldn't happen in a build and it would just be a regular NRE no matter what
assumed_collision_point and previous_pos_for_checking are the same point then, it seems
that happens in the second if
😑
or right, what have I done
should ve be another variable
... is someVector == Vector3.negativeInfinity even reliable?
seems like the idea to use it as null was not very bright
I am doing unity 3d essential tutorial, I placed frefab kid's room on the environment>cube, and unity placed kid's room nicely on top of cube. but when I see in inspector it's position, according to it's y position ( it was neg 5.5) kid's room is supposed to be half-buried inside cube. why does unity do this? (ignoring it's y position and force kid's room to be not buried into cube. but not putting it's proper y postion - suposed to be y = 0 but putting y = -5.5)
depends on what you mean by reliable
== has an epsilon applied
is the stuff in the prefab lower?
I have redacted the code and now after that ray line it says that previous_pos_for_checking is infinite vector in debug
am I wrong or you can't compare vector with infinity?
unity doesn't ignore y's
Vector3.negativeInfinity == Vector3.negativeInfinity returns false
Probably because the comparison produces NaNs
yeah that's what I was afraid of
-Infinity - -Infinity = -Infinity + Infinity = NaN
you could use Equals instead
Equals uses == on the floats
uh yeah, the stuff I dragged onto the cube is under the prefab folder in project window.
the stuff is the kid's room.
as in
is the stuff in the prefab at a lower y
unity does not ignore y's so you just gotta look in your hierarchy to figure out why it's lower
what's the technical difference between == and Equals ans why one is not a strict upgrade over the other?
I guess == have some wiggle room?
alright, judging by google it's not that simple question to answer
so as I am getting it == allows custom implementation while equals is plain robust reference/bits for value types comparsion?
I have done some Java BlueJ programming Im not great but learing I have decent blender experience and Im looking forward to learning Unity what is the best way to approach this
you can provide a custom implementation for either one, it's just that for Vector3 the implementation is a bit different with == providing that epsilon for some slight variance
I prevoiusly did the car tutorial it was at a too slow pace any suggestions
make a fairly simple game watching guides
when I asked AI it answers that there are occasions unity ignores Y position (If the prefab has a Collider component and you are spawning it onto another collider, etc) I just can't figure out what causes this. and Yes, it does seem that unity is ignoring Y position of the prefab when I drag it from project window to scene window. when I drag the prefab to scene initial position (12,-10,12) and it is actually at (12,0,12) -> then I change it's actual position to (12,0,12) and it's physical position does not move. -> when I change actual number to (12,-10,12) then the prefab actually movoes to physical (12,-10,12) position. so I can see that Unity ignores Y position of prefab only when I first drag it from project window to scene window on top of other object, which is the cube in this case.
any recommandations on specific ones u did that worked good
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
Yes and it breaks when you try to wiggle negative infinity
Unity does not ignore y's
I just watched guides on different mechanics I wanted to implement
including low views indian guy talking
It did. 🙁
go do it yourself, cus I am see it while I am doing it. lol
thats like saying sometimes numbers skip 2
I am here only to ask why it does it not here to argue it.
This also depends if your mode in scene view is Center or Pivot
you cannot apply occams razor to everything
is it parented to anything, are you looking at the right object, are you using pivot mode rather than center mode for your tools
the answer to that question is "it doesnt"
not here to argue it.
"i have an assumption, i want to know why this assumption holds, i don't care if the assumption is false"?
gotta check yourself a bit there mate
That there are occasions unity ignores Y position (If the prefab has a Collider component and you are spawning it onto another collider, etc)
this is directly just not true btw and a great example of why AI is awful for learning, atp we need to keep track of bullshit like this
only thing I would tell, it might be my personal preference but
just screw the animator transitions, state scripts, and variables (unless self-repeat transition and values connected to animations)
you can do anything by code and it won't break or it would and it will be easy to find by inserting sanity checks
I ve wasted stupid amount of time trying to connect animator FSM with my own FSMs to avoid edgecases, now I just execute transtions from code
definitely personal pref, that one. i haven't had any issues with the animator using its transitions/substates/blendtrees
You guys try it yourselves. Drag a cube prefab from the project window onto another cube in the scene.
In Pivot mode: the cube clips into the other object.
In Center mode: the cube is placed on top of the other cube.
Is that what @frail hollow is talking about
I know I am noob that's why I am here lol thanks guys I am reading your answers now
But the y's reflect that, no?
it gives pretty nice separation of concerns - the code tells the animator what's going on, the animator decides what animations to play based on params
what anchor mode are you referring to?
sec guys first I will show you screenshot of what I am seeing.
the reason is, Ai will just lie if you convince it youre right
Oops I meant Pivot mode vs Center
when I first dragged prefab to the scene on top of cube.
If you tell ai "It has to be this" then it will pull answers out of its ass
changed Y positon to 0 and physical positon not moving
what was the y position before? are you sure it wasn't just something really close to 0
changed Y positon to initial value, and prefab actually moved, it is floating.
Unity ignored Y positon proved.
lmao
no
you didn't change it to the initial value
you changed it to 3.8
what was the initial value
yeah the initial value is 100% scientific notation
was it perhaps, 3.8e-10
so why does it do this?
why does it do what?
ignoring y positon.
it most likely does not
to be blunt, you have an incorrect assumption
you are refusing to challenge that assumption
what assumption?
the root assumption i'm seeing is that, the initial Y value is close to 3.8. it probably isn't
go check what the initial Y value is, in full
teach me. cus I am in code beginner channel. I am only asking.
how is this even a code question
not trying to be insulting here, but just trying to get to the point
the overall assumption you've brought was that unity ignores Y position
you came here refusing the possibility that that assumption was wrong. you gotta be able to verify or challenge your assumptions
it has nothing to do with code?
it doesn't, yeah
another case of unity-talk being poorly named
@frail hollow go do this.
undo until you see the 3.8320... in the inspector, and check the full value
I did, and this time I copy and pasted the value, now it did behave differently yes. when I changed value original > 0 > back to original, the physical position didnt change.
why is it so?
what is the actual full value
copy that full value here
I used other prefab this time and value is 4.232814e-08
thats pretty much 0
yeah so that's 0.0000000423
ahhh lol
the position does change, it's just a tiny amount so you don't see it
so yeah, this assumption was wrong.
so position window size is too small I couldnt read full value of y position lol
it's hard to drag right answer from you guys as usual but thanks ^^
or you could like, scroll in that text field
its literally your fault lmfao
but the right answer was given when you actually demonstrated what you meant. you just chose to ignore it
could have said that earlier yeah
mate.. imma be real here, it's hard to help you when you come in with an assumption and refuse to challenge it even when told you're wrong
free support btw
that's why it's hard to teach.
i told you to check the Y position 10 minutes ago. i assumed you would know how to use text fields
yeah because of the students
this is very rude
you made a wrong assumption, it's time to learn now, not time to deflect or blame other stuff
you should apologize
that's what incompetent teachers usually say
ok atp its trolling
the only thing to blame is your inexperience - with time, you can get rid of the inexperience, but you first have to know that you have inexperience
it's alright they dont need to
yeah... just trolling
ok have a nice day
i regret helping now
hopefully ai lies to you plenty more
"your assumption is wrong" (deflected)
gives help (ignores instructions/questions)
yall are bad at teaching
I just find when question asked to coders they can't imagine from other person's perspective it happens very often.
and get mad when argued even insulted lol
if you only deflect and blame others you'll never improve
insults people
why are you insulted
I wonder, if they remember when they were asking questions, noob questions in programming classes, how teachers answered their noob questions.
we remember
we were noobs once
we respected the answers and the effort that our teachers put into teaching
what would happen if a game have a huge frame drop while animator chain is set in a chain animation A > B > C while your code executes FSM which checks animation A and then sets trigger A > D and put FSM at a state assuming that, am I meant to validate next frame or something?
I dunno, maybe I suck, but I found it unbearably annoying to keep track of basically 2 FSMs at the same time, while also as I am getting it they are in different "update" frames, and while the animator transitions have the ability to skip through each other on lag spikes
even more so, now that we teach ourselves
start with insult or blaming? or try to see what your noob persepective mind is missing and try to guide you. probably didnt' even notice when you were guided by teachers lol
ok, where did we start with that
its not worth your time man
I find that most coders miss this especially in cyber chat room, and jump into noob's question with agrresive assult, mostly you don't or cant behave in real life. cus you probably get punched in face lol
i'm not sure what you're asking with that exactly
my code FSM just doesn't care about the animator FSM at all
i teach in real life too
many people here do, afaik.
if you don't know where you start what, you are as noob in social skill as me in coding
you're the one going on the attack here because you were wrong. at this point you should really just take the L and move on
you can move on. you don't have to participate in this. well go on. move.
or you can try to protect your friend your freedom
we can just ignore the weirdo
heh, "friend"
no stress
can you stop, conversation is over, now you are just spamming
you know what, when people drive car, they sometimes think they are the car, think they got bigger like car and behave suddenly like a monster, old women becomes a bear when drive car. what people miss in aggresive driving is that you are still a person in real life. you gotta behave when driving car same as you are walking street. but some people can't do that and do rage driving.
how do you handle situations where you need some animator feedback, like, can't shoot while holstering
I find chat channel behavior same as driving. you wouldn't behave like this in acutal life.
when question is asked.
just remember, you are weirdoes. -_-
can a <@&502884371011731486> shut this clown down
anyway, I am gonna come back when I have other question, if you had bad experience on my questioning, you don't have to aswer my question next time.
Sure let's move on
as in, to check when the animation is finished?
could use animation events, i guess? i don't think i have any cases of that
Please keep these comments off the server, and everything will be fine, thanks.
bro kept himself off the server
oh i do actually, to sync up attack visuals with physics queries (well, enabling hitboxes)
using animation events
ive found that it's really confusing to come back to though. i'll probably find other ways in the future
iirc they are not great for that and have same issue of "you can skip it if you had such awful fps that you skipped the animation entirely"
I just tried to make something 100% reliable, that was like beating my head against a wall with animator transitions and stuff
doesn't the animator do like, max 1 transition per frame or something? i might be misremembering
I have not been extensively checking for that tbh
I sucked much more than now back then but I remember that I had edgecases constantly till I remvoed their possibility by always manually forcing all transitions and if I needed checks to check what is playing and normalized time if I needed that
I was pretty surprised why it's not mainstream to not to use animator transitions and parameters
like the visual/regular programming situation
if i had to guess, the difference there would be because each system of animation and each api for said system would be quite different from each other, whereas with programming languages, a lot of languages are quite similar to each other
I mean in Unity specifically, like, techincally we got visual programming?
and visual programming is super different from, eg, blueprints or scratch or code.org
but c# is pretty similar to java, or c++, or js
it's a more transferrable skill set
Unity having c# has made it not a priority to add visual scripting. Unreal perhaps needed BP a lot more due to c++
And I guess long ago we also had JS and boo in unity too
btw, my code checking animations looks like
else if (animator.GetCurrentAnimatorStateInfo(0).IsName("Stun") && !animator.GetNextAnimatorStateInfo(0).IsName("Stun") //checking next because you can interrupt stun by stun
&& animator.GetCurrentAnimatorStateInfo(0).normalizedTime >= 1)
{
StunEvaluateExit();
}
I could use cached hashes but... it's probbaly fine
damn
i wouldve assumed you had it all in code and only just synced the state to the animator
I genuinely want to know how people find AI useful for coding. 90% of the shit it makes is inefficient like not using events and subscribers etc. Like what kind of spaghetti code simple website projects are vibe coders making to brag about this garbage
I cant imagine building a game like this
it technically works at least half the time?
60% of the time it works every time
If you already have knowledge you can ask it better questions and correct what it gives but I hardly use it myself.
for real though, it's not super useful unless you already know what you're doing and in that case it's really just a tool to help you do the stuff you already know faster
can i safely delete these?
the readme and tutorialinfo folder definitely, the rest is actually useful stuff
also not a code question
okaythanks
How to actually learn c# in unity. Like is there some official documentary or something, tutorials dont really give me anything, i cant remember what im doing and why, or what the code does
!learn and there are beginner c# courses pinned in this channel
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
I just got to a random site teaching you C# and completed it
and it was apparently enough
Should i start with 2d or 3d?
do you remember what site?
well that won't matter when it comes to the actual code
...no, it looked pretty basic tho
Its even worse because im a noob and sometimes im just sitting there wondering what the f it was even trying to do since its not code i wrote
like it was introducing concepts and having excersises for those concepts
if you don't know what you are doing then definitely don't use an LLM to generate code for you because you won't be able to properly check what it outputs and you won't really learn anything from it
but that was just enough to start being able to understand code from tutorials
watch them go pick some random thing over unity learn
learning to make my own code and understand unity took me months following tutorials and using what they describe in other contexts
I am surprised, I can't find online learning site with a built in compiler or something for C# learning, are they still there?
im telling u man the C# resources are garbo
and the youtube tutorials arent much better
one I followed through was nice, but I suspect it was Russian
what are you looking at random resources instead of things like the official docs? because the official resources are excellent
i quickly stopped using the official docs because 2 C# experts told me that they are not good as they are full of tons of irrelevant information that just wastes time
are these c# experts in the room with us
nope they are in the C# discord, and its hard to disagree with them because even a tutorial guy (Code monkey) also restated what they did
why not learn fundamentals through c++ ?
it's pointless to learn one language with the express purpose of not using that language and only taking the knowledge to another one. just learn the one you intend to use
They are fine
i hope that was a joke with c++
Biggest beginner trap is getting stuck min maxxing their educational sources and never actually committing to any
did they say why? if not, then it's impossible for us to confirm or refute any claims presented. so we can only really tell you that they're fine
what would you say about something like this site?
https://www.tutorialsteacher.com/csharp/csharp-variable
i mean i learned my fundamentals through c++ and was able to pick up c# relatively smoothly, its just a suggestion since learning fundamentals is important deosnt nessarily need to be c++
(who's that question targetted at)
If someone is struggling with c# I think c++ will be even harder
both the guy who ask for resources and competent C# people
if you know you want to learn c#, you would not take a detour to a different language and then come back to c# and relearn all the things that are different
yeah true didnt think about that
knowing other languages helps to learn the new language, if you already know that other language
the first language is always the hardest to learn
me personally I would use it to learn and it would work
can't tell if it's efficeint but that site would like make the job done for me
it is a good website i remember using it a long time ago
of introducing C# enough so I could use that knowledge to get into using Unity tutorials zone
really nicely structured and well organized
C# seems like a great 1st language to me. And it gives so much java readability
C# is top class i love it
C# programming language
Interview with a C# developer with Jackson Monaeghan - aired on © The C#.
Music by:
https://teknoaxe.com/Link_Code_3.php?q=139
Programmer humor
C# humor
Programming jokes
Programming memes
C#
C# memes
c# jokes
c sharp
.net
dot net
.net core
.net 5
visual studio
azure
…
...according to Microsoft
(this is a joke video I kinda love)
-don't tell me it's only for gamedev, you can do other things in Unity too
you could easily learn c# and go get a backend dev job
(with lots of time and effort in the middle)
do yall have any good suggestion on where to look for researching data persistence and save/load like a youtube video or article?
is there a method to check if I can call that before calling that?
I can check box - sphere - capsule collider explicitly I guess
convex... seems to be able to check that too...
would be nice to know if there is something less awkward tho
Its a common concept. You can use many formats to serialize your data on disk such as json, protobuf or even via something like sqlite
if (!(myCollider is MeshCollider mc && !mc.convex)) closestPoint = myCollider.ClosestPoint(...);```
property pattern would probably look better
wait there are no other opetions other than box/capsule/sphere/mesh convex/mesh non convex?
yeah non-convex mesh collider is really the only one excluded from that
great, thanks
if (myCollider is not MeshCollider mc || mc.convex)

C# syntax is truly a work of art
if(myCollider is not MeshCollider { convex: false })
so plane collider is... apprently... a non convex mesh collider?
does that mean it's bad for optimization? 🤔
it's a very simple collider
What Rider generated:cs if (myCollider is not MeshCollider { convex: not true })
the problem with the concave collider algorithm is it scales poorly with the number of triangles
not true threw me off
but the plane collider has... two triangles
lmao "not true"
iirc this can still fail with a missing reference exception
Those patterns are still so cursed to me
I don't use them since they confuse me (with the arg brace stuff)
since it skips the overriden equality
yeah but.... usually not an issue
until it is 😛
i just fully avoid that for anything derived from UnityEngnine.Object
thankfully large parts of the game are just regular C# code and not untiy objects
as casts act differently to () casts
well is and as will not throw a excpetion if it cant cast
ops i meant as, is should be safe but doesnt account for fake null
🤔
you can just use other there
no wait right
unless that function needs a MeshCollider specifically
It gets defined outside of the if statement scope so has a chance to be unassigned in your example
Similar things happen when you do out var blah
it gets into the if if it's not a MeshCollider, so mc is invalid
Does that method expect a MeshCollider or no?
my brain is too scrambled now
why not just de morgan this and make it simpler
if (other is MeshCollider mc && !mc.convex)
reads much more easily
because that's not the right condition
i don't know what the original question was
or the property pattern which was already suggested other is not MeshCollider { convex: false}
yeah i probably shouldve asked
we allow: MeshColliders that are convex and any other collider
we don't allow: concave MeshColliders
gotcha
yeah it's what should be there
I want exception for concave mesh colliders
The problem here could have just been fixed by plugging other into the function
instead of mc
yeah it could but I just don't understand why won't mc fit
mc doesn't exist
becasue if it's a BoxCollider mc isn't assigned
yes it wasn't existing
because if the first condition is true then mc is never assigned
I mixed up things but like this it's fine
if (other is MeshCollider mc && !mc.convex)
{
return GetAssumedCollisionPointNonConvex(mc, out assumed_hit_normal);
}
so this is the opposite of what you want, isn't it
isn't this completely the opposite
sometimes I just find issues not really related to what I do or I could workaround but I still want to figure out how to deal with them anyway
Well the thing is what you're trying to fix isn't an issue 😛
Remember if you're trying to pass a MeshCollider variable into the function you can only ever put MeshColliders in, never BoxColliders etc
let's simplify + duplicate the logic here
is this what you're trying to do?
if other is MeshCollider (mc):
if mc is convex:
GetAssumedCollisionPointNonConvex(mc)
else:
GetAssumedCollisionPointNonConvex(other)
if the collider is mesh collider and non convex, then use another method, else proceed normally
it works like that right?
mm so that other function is specifically for concave meshes?
ok, then this is correct then. if it's a mesh and concave, then use that function
honestly neither functions are very useful / clean
the idea of using raycasts to get normal of a hit from a TriggerEnter...
not super robust
I am thinking of somehow making a duplicate of a projectile to follow a trigger-collider main one
to detect physics collisions
out of spite
regenerating it after each hit
or something like that
also I wonder why don't we have Physics.ConvexMeshCast or Collider.SphereCast APIs
are they techincally possible within PhysX even?
collider.spherecast would be "possible" within the system of physx, but 🤷 on whether physx actually supports that call
I think I just found how to make CharacterController.isGrounded consistent. The property gets set after every CharacterController.Move() call. From some tests people have done on the web, isGrounded needs the object to attempt to move into the ground. So, every CharacterController.Move call should have a negative y component if in that specific call it should be grounded.
that's correct, yes.
that would be "quad" tho
plane have alot
plane probably have... 200?
this is why it is recommended to only make one call to Move each frame so you can be consistent with it. (though i still think physics queries are superior to relying on the isGrounded property)
Yeah, funnily enough, part of my problem yesterday was calling it twice, and in one call, it was being fed an erroneous vector with a zero y component.
And yeah, physics calls might be the way to go, and I can definitely see myself using those in the future if necessary.
Where should I start to start to learn how to code
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
I looked there I did not understand it at all
what did you have trouble with?
I did not see where to learn how to code there
It might be easier to check the pinned messages in this channel
Or start here https://learn.unity.com/course/beginner-scripting
Learn about programming for game development, from the very beginning with these easy to follow video tutorials.
cant you just whitelist it?
Can't help you with that. Bring it up with your parents or whoever is running your network
Ik I need wait a few hours
Im not entirely sure what catetgory this falls into so this is going here, does anyone know how to make a overlay in unity 2d urp to make it look glitchy, like the five nights at freddys 1 main menu static effect
does keeping ragdolls in the scene without deleting them effect alot on preformance?
i saved my unity data into a json file but im on mac, how do i find the json file?
look at the path you saved it to
use the profiler if you have performance concerns
macs also have file explorers 😆
The doc page states where persistant data path goes on each platform:
https://docs.unity3d.com/6000.3/Documentation/ScriptReference/Application-persistentDataPath.html
My single biggest demotivators in coding is the anxiety of scalability. Is there any actual good ways to know if there isnt danger in scalability or is that just an expert only ability? Because you can see it with some older games where they cant implement even integer limit changes because of 32 bit vs 64 bit etc
test around and convince yourself what is a problem and what isnt. int limit is a fairly large number, you really dont need to care about it in most cases. as you develop systems, you'll know which values in your system can realistically hit large scales. Even if someone does hit the limit, congrats, they played the game long enough to hit the limit
there isnt anything scalability wise to consider in most games
I guess i wasnt afraid of integers that much because the numbers go so high these days but i meant more like having a trip wire of fundamental game logic that if is flawed would collapse a bunch of stuff later on
Perhaps a question of "If something works early that doesnt mean its a good build because it wont work later on so u cant build off it"
🤷♂️ make logic that isn't flawed in such a way. its inevitable there will be an edge case you don't consider if you build a large enough game. there isnt that much to really say here other than you just need to sit and think about how systems intertwine so you can design each system properly. if you just start coding stuff with constantly changing goals, yea it'll likely become a giant tangled mess
though regardless your game might still be a relatively tightly closed loop. Maybe it doesnt matter if you hardcode certain aspects or follow poor practices to make something work quicker. Pretty much every single massive game you've played or heard of has had game breaking bugs at some point
Then there are workarounds and bootleg patches when your implementation is too far to rewrite from scratch.
even take a moment to go look up past bugs in games you've played. You'll quickly stop worrying about minor bugs when you see what larger games have gotten away with. Osrs (which ik you've mentioned before, and from your name) has had game breaking bugs for the past 20 years. Up until like 4 years ago, people were easily crashing servers.
has there been times where people had a bug for like 5 years though and eventually fixed it. professional bugs seem either hot patch fixed or they just dont build any architecture off it. Like i doubt runescape was trying to add permant server architecture on top of bugged crashing vulnerablities. but i might be wrong
As dlich said, you can just write a workaround or like a bandaid fix as many sometimes call it. You don't always need to fix the core issue
Basically, you build something that works within your expected use cases. That much is totally achievable.
the point is less about what osrs does, more that you simply don't need to care about bugs to the point that it hinders development. Your game is going to have pre defined closed loop functionality. Make it work and people usually won't care about minor bugs here and there unless they're actually negatively impacting gameplay
thanks for the advice its a bit calming even though i know im gonna mess something up anyway
Large games often will have more of these bugs because theres so many mechanics going on, and so much deep rooted logic that they cant fix the core issue. So they implement workarounds. Those workarounds very often lead to new bugs
If your game is so large with so many people playing it in the first place, you'll have enough money to not care about the bugs suddenly
So many league champions have like 8 year + bugged interactions so yea definitely
Oh, you definitely will. And if you're overscoping, you might even need to drop and rewrite from scratch several time.
Yea go through any vandril videos and see that 2 champions have probably caused 10+ different instances of crashing servers. The osrs ones are a bit more niche to find, no one puts out truthful informative videos on it
Though one important thing is sitting and thinking about gameplay before wasting time writing logic. Just so we aren't purely talking in hypotheticals lets just take movement systems for example. You don't just start by writing a fully finished movement system before any of your game is thought out. You think about how other systems may interact with a character whos moving. Maybe something can push, stop, or teleport you. If you built a system without considering these, you're going to likely scrap your work or be implementing workarounds to allow it to work
I think in that in that regard i already got it covered as i have a 20 page document including math formulas for combat etc
can anyone help me out with making it slow down when im zooming into somehing its like my mouse is to fast but i dont wanna slow that down
Wouldnt all those values be in the camera's inspector?
if not u can also check the camera's code in C# and it should be pretty easy to find
possible ill take a look new to it so i diddnt wanna be messing with stuff idont know much about i aappreciate the help
Hi everyone. I'm trying to build a project but getting this error when i try to do it.
Its not my project, i just need to build it, but i cant update Universal RP from package manager. Kinda lost what i should be doing here to be able to build. Game runs without issues in editor as well
are these inputs automatically fired or just an example of what the game lets you do?
like, a template is what i mean
Pretty sure this is one of those old version of unity outdated rendering pipeline issues. Check Render Pipeline Converter. check using Window > Rendering then check the urp material upgrade and render settings. It should have initialize converter options
I am an absolute noob though so take what i said with a grain of salt
Trying now. Anything to make it work at this point
i think i had a similar issue when i tried to play with an ancient project imported into unity
yep no luck
please don't crosspost
Hey for people who know Unity and coding and routing in it can you DM me just need some help thanks
someone advanced
need help with the camera to Follow a Race leader on racing game please
!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 was 99% certain they didn't read anything I said and would repeat their question.
if this is about me i listually have been on Google AI and Chat gpt for alot of coding and its helped so much untill the routing part came through and i had it and i messed up one of the files and cant get it to work again
okthankyou
hello im completely new to coding and i want to learn how to what should i do ?(just basics like walk or run in first person)
!learn 👇 there are also beginner c# courses pinned in this channel
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
Super smash brothers melee lives off bugs that were never fixed
The community refuses to play on the newer versions of the games because they like the bugs
Has anyone here done vr with unity before
i’m crashing out trying to change the controller to hands with animations 😭
the animations just won’t work
ah yes it works until it doesn't work
we don't condone DM support here
this is a code channel, you might have a better chance asking in #🥽┃virtual-reality
Hi
One message removed from a suspended account.
Decals are projected in the lightmap uv2 space. They aren't exactly blitted onto independent material renderings
One message removed from a suspended account.
Not entirely sure of your requirements, but yeah editing textures CPU side is slow especially per pixel operations. Usually want to use the Graphics API for any texture modifying operations
https://docs.unity3d.com/2020.1/Documentation/ScriptReference/Graphics.html
One message removed from a suspended account.
One message removed from a suspended account.
hi guys i know this has probably been asked a million times but where do i get started? can i use unity.learn?
oh but you just want decals? So you're just initing a projector in world space, not exactly modifying that texture
hey is it best to find objects during runtime with Gameobject.Find... or drag and drop them in inspector with [SerializeField]
SerializeField all the way
One message removed from a suspended account.
One message removed from a suspended account.
what tools can i use to collaborate with someone on a unity project? i have to do a game over summer w my buddy, can i use github?
One message removed from a suspended account.
is there like a clean way people usually use to organize it like put all the serialized components or gameobjects in one object or script
Decals are projections, that blend over your rendering using uv2 space
if you mean to modify a texture then you wouldn't use decals
One message removed from a suspended account.
i see! thank you
there are many many ways on how to organize things, you can have singletons taking care of several things , you can seperate workflow into single objects and so on
not entirely true. They both can serialized into binary but 100% of the time it's human-readable
I see, we are doing a graded course so I have to use git anyways for tracking. Thank you!
One message removed from a suspended account.
Prefab data just has problems and it's hard to resolve for both godot and unity.
So if you're working with someone, you don't both work on the same scene or prefabs at the same time.
oh..
Unreal actually has some tools to help prevent multiple people working on that data
probalby too much for us, we're both complete noobs and we need to finish a game over the summer
But any c# scripts should merge fine, just gotta communicate it out, but it can break serialization of prefabs but wouldn't create problems with those specific assets.
I see thanks :> hopefully it works out
ill check im not sure if its any better
not used github desktop before
github desktop is just a client for git
yeah i watched a few videos theres no added feature from the client to help with any merging issue
illl just use the cli
idk the videos i watch just covered stuff like clone/push/branching
well yeah extensive merge conflicts aren't exactly a beginner topic 😓
wassup chat
i got a quetion if u set smthng active false setActive(false ) can u set it back active true from same object
or it has to be from a scirp not attached to it
If the object deactivates itself, Update and most other unity methods won't run on that object
So you can't set it back to active if that code is in Update for example
so i should make a variable containing that game object in another script and set it acteve from there?
Maybe
thx
(I don't know anything about what you're doing)
@cerulean raft Hey! Are you greek?
lemme send u "da spagheti code"
nope
!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.
oh because Aris is a greek name I though
is it for the name
yh i know its a greek name it means god off war or whatever
Yes the name is from Ancient Greek God of War.
64 is pretty long, use a paste site
ok
lemme dm u
Nah keep it here
Use one of the paste sites in this bot message
#💻┃code-beginner message
Save it and then paste the link here
Don't save the website
Hold on
Go here https://paste.ofcode.org/
Paste the code, then press "Paste it" @cerulean raft and then copy URL link here
ok
a powerful website for storing and sharing text and code snippets. completely free and open source.
a powerful website for storing and sharing text and code snippets. completely free and open source.
like this?
Sure. So what's the issue
do u understand what i wanna do
Yeah that Update will not run because the object is inactive
ok
lemme change code fast and ill give it to u
deletede 2nd code and left this
a powerful website for storing and sharing text and code snippets. completely free and open source.
it works!!!!!!!!!!
thx osmal
ik ik pro art lol 😂
I have a problem I have a origial iteam steak I make a prefabs folder and I made steak prefabs with copies of origianl appear when u press space with initialisation but now I wanna cap the range of the prefab steakes yet they dont have x y z axis anymore it they ignore it
Can you clarify what you mean by this?
I wanna cap the range of the prefab steakes yet they dont have x y z axis anymore it they ignore it
Also please don't share code as screenshots
!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.
the steak at the bottom is a prefab it doesnt dissapear when reaching out of bounds like in the code it ignores the z axis
chat how to make my olayer a transform for bullets while my bullets ar prefab and player isnt
hey i was using a script that moved my camera pos to player in update (with z offset) in 2d to make camera follow player, but its causing really annoying jittering, is there a better way to have the camera follow player? my player is moving by setting velocity in rigidbody
never tried camera movement im new
i dont get what u trying to say
but try doing a transform player in camera script
then make camera position = player position
LateUpdate instead of Update maybe
okay let me try that
bros a genius!!!!!!!
what would it really change to stop jitter though
its also definitely not my fps lol fps is not dropping below 500
like it does it every frame but as last
like it lets the objext it follows move first
Hey, guys! I would really like to expand on Game Math, but I am really very confused on where to start and how to actually study maths?
What do you recommend?
Nothing in the scene is ever a prefab
prefabs live in the assets folder / project window
DO you mean it's an instance of the prefab?
I saved it in a new folder prefab as a copy of original
Yes but the one in the scene that we're looking at, what is that?
Is that one that your script spawned?
Is it one you put in the scene directly at edit time?
the one in the scene is the origial the prefab one only spawns when pressing space
i reckon creating projects that are simulative of real life things by nature, you will run into many places needing game oriented math. although you need to specify what exactly game math means
delete the one in the scene
it shouldn't be in the scene
prefabs live in the assets folder
but if I delete it I delete the origial and the other ones dont spawn
then you messed up
whats happening idk
you need your spawning script to reference the prefab
oh rlly
prefabs are like a preset of a gameobject, put it into assets folder then drag it into a field in the inspector
yes
you need to reference the prefab from your spawning script
the prefab is the original
delete the one in the scene
a powerful website for storing and sharing text and code snippets. completely free and open source.
a powerful website for storing and sharing text and code snippets. completely free and open source.
idk why bullets r going like this weird
- you forgot to disable gravity
- its hitting the player's collider and bouncing downwards
gravitys 0 wait for me to check about colider
yeah
set the bullet object's collider to a trigger collider imo
wont run into these problems cuz it disables collisions entirely
it was the colider thing thx bro
ok nice
it tells me that
i probably need to work on my pixel art , idk if its even to call it art
first drag the prefab into assets
then drag it on to the inspector from assets
and idk how to do , i cant place the player in transform variable cuz bullet is a prefab
i thought about making a prefab that when start spazns to player with same position ext , then do it instead of player in the variable
is there any other choices or just this
is there a guide on how to use the new input system code wise?
!Input
To set Active Input Handling, go to:
Project Settings > Player > Active Input Handling
• Input Manager (Old): Use the original Input settings.
• Input System Package (New): Uses the new input system package.
• Both: Use both systems.
there's quite a few, try googling around
In this series of tutorials, you will first learn how to install the Input System Package and quickly get set up with game-ready inputs. Next, you will learn how to script player movements as well as control your player using the game-ready inputs. Then, you will learn how to customize your own input actions, tailoring the input system to your o...
When trying to build a Unity game with an IL2CPP backend (and HDRP) on a dedicated server running Windows Server (without a dedicated GPU), I'm encountering an issue with missing meshs. I've tried building it using both the CLI and the Unity Editor. What could be causing this problem?
thanks ill have a look
thx
What did you try to drag exactly and where?
i presume from scene view into the inspector, and then switched scenes
so basically the prefabs square was white it was incomplete I deleted the original steak and put the projectilePrefab so the copy steak from the prefab folder into assets
Wha
yeah when u drag into inspector, you have to drag from assets, not from the scene
when dealing with prefabs, that is
Prefab assets can only reference within themselves or other prefab assets
it wasnt that I didnt do that it was just incomplete for whatever reson I had to copy it and paste it into assets again
how do i check if a specific animation clip is playing? i have a clip as a variable and i want to know if its playing or not
you can use a debug log
How unhelpful
Audio clip? Animation clip?
animation clip
yeah it kinda is
sorry
youre using the animator yes?
yeah
In an animator you can check the current state or current clips so quite easy
Check the doc page for Animator to see the functions for this
https://docs.unity3d.com/6000.3/Documentation/ScriptReference/Animator.GetCurrentAnimatorClipInfo.html
How would i allow unity to use my function
MovementController.cs
using UnityEngine;
public class NewMonoBehaviourScript : MonoBehaviour
{
public float PlayerSpeed;
private CharacterController character_controller;
private Vector3 player_velocity;
void Awake()
{
character_controller = GetComponent<CharacterController>();
}
public void Walk(Vector2 player_input)
{
Vector3 move_direction = Vector3.zero;
move_direction.x = player_input.x;
move_direction.z = player_input.y;
character_controller.Move(transform.TransformDirection(move_direction * Time.deltaTime));
}
}```
Another question is if i should edit it in the `hierarchy` or the `assets` tab as i have the player as a prefab
Which function? Walk?
You have the wrong parameter type
the correct parameter type for this is InputAction.CallbackContext
e.g.
public void Walk(InputAction.CallbackContext ctx)
{
Vector2 player_input = ctx.ReadValue<Vector2>();
// The rest of your code...```
but also
putting character_controller.Move in here is wrong
that needs to go in Update
basically:
- in the input handler store the input vector2 in a variable
- in Update call Move using it
yeah that
Example:
Vector2 moveInput;
public void OnWalk(InputAction.CallbackContext ctx)
{
// Get the latest input data and store it in our variable
moveInput = ctx.ReadValue<Vector2>();
}
public void Update() {
character_controller.Move(transform.TransformDirection(moveInput * Time.deltaTime));
}```
i'm trying to call the functions via the input thing in unity though & it wouldn't let me select the MovementController function
yes look what praetor wrote , you have the wrong setup
the method needs the proper Parameter type and its not Vector2 but CallbackContext
see
even the inspector says so
Your class is called "NewMonoBehaviourScript"
also yea
for clarity your file is called MovementController.cs your class should also be named MovementController not NewMonoBehaviourScript
uhh its named like this in assets
sorry im new to unity
Filename does nothing
this is just a FILE, not the class itself
public class NewMonoBehaviourScript : MonoBehaviour
but you wrote this in the code^
ohokay
ultimately is the class name it looks for not the filename
uh did you change class name and let it recompile ?
did you save? Are tehre any errors in the console window?
yeah i did CTRL+S
yea you missing new input system namespace
If your IDE is not autocompleting code or underlining errors, please configure it.
Select one:
•
Visual Studio (Installed via Unity Hub)
•
Visual Studio (Installed manually)
•
VS Code
•
JetBrains Rider
• :question: Other/None
You're missing using UnityEngine.InputSystem;
also it should be underlining red in editor so def do this #💻┃code-beginner message
thanks
Hello I am trying to make random npc like I have many hairs and body parts and more but how do I combine them so that every 10sec an npc spawns with an other variation. You know what I mean? If it helps its in 2d
break that down into smaller, simpler parts
eg - combining specific body parts, doing the spawning, randomizing body parts
ok
Yeah this is really 3 seperate issues
start with establishing a base system for the body part variants
that should be first, then figure out spawning, and then all youre left is with randomizing it
thx
okok so i have this but theres no error checking squiggly on line 6 for whatever reason
so your ide isn't configured. configure it
i have the unity workload
pretty sure that isn't the only step
make sure you also have the solution open, make sure it doesn't say "miscellaneous files" near the top
it says miscellaneous files
so that's an issue yeha
If your IDE isn't providing autocomplete suggestions or underlining errors in red, then it needs to be configured.
i can't help further than that though, im not familiar with vs
okay thanks
you need to get intellisense working
ah ok was already mentioned
that is true
I'm late but yea you can tell by the lack of colouring it's not configured still
how do i
configure
If you followed the help steps linked by the bot msg then close visual studio and open it from unity via Assets > Open C# Project
Or double click a script in the unity editor
Is visual studio set as the external editor in your unity preferences?
yes
Click the regenerate solution button in there and then try to re open vs
Edit, preferences then external tools section
https://docs.unity3d.com/6000.3/Documentation/Manual/Preferences.html#external-tools
oh i thought it was in VS
Double check the steps on the help page below
!vs
If your IDE is not underlining errors in red or autocompleting code,
please configure it using the link below:
• Visual Studio (Installed via Unity Hub)
• Visual Studio (Installed manually)
Are there any good tutorials for raycasts
If the problem isn't resolved, I would suggest showing images of these:
- Unity workloads
- Visual Studio Package (VSCode package should not be installed - old and conflicting)
- External Editor
▸ Learn how to CODE in Unity: https://gamedevbeginner.com/how-to-code-in-unity/?utm_source=youtube&utm_medium=description&utm_campaign=raycasts&video=B34iq4O5ZYI
Learn how to use the Raycast function in Unity.
00:00 Intro
00:57 Creating a Ray
02:33 The Raycast Hit variable
03:11 The Raycast function
04:48 Layermasks
07:10 How to exclude Trig...
Thank you
idk if this is the right channel, but how can I make a 2D sprite glow? just want bullets to have a nice glow effect, nothing complicated
did everything
it did not work
i DO have the workload though
If your IDE isn't providing autocomplete suggestions or underlining errors in red, then it needs to be configured.