#💻┃code-beginner
1 messages · Page 690 of 1
from within what script?
within the plant script itself
in the method that sets its position
and then ive just tested this within addplant
they are not equal>
even after just assigning it
you swapped posx and posy
oh damn
the pivot is my enemy.transform, 1 endpoint is where my enemy is facing (transform.forward) and the other is where my player is....(sorry for not mentioning) i want to animate the enemy to face my player when the angle is higher than 30 degress

if you want to also account for vertical displacement i think you'd have to get the normal of the plane formed by the vectors? that's be Vector3.Cross(vectorToPlayer, transform.forward)
wouldnt it return a vector3? im looking for an angle
yes, i'm not saying to use Cross directly as the angle
the cross product gets you a vector that's perpendicular to both other vectors, i'm saying to use that as the axis of rotation in SignedAngle
wait actually if your goal is just to get the angle difference, you can just use Angle, no?
you can omit the axis altogether with that
i want to ignore the y displacement... i want the angle in just the x-z plane... i want the angle to be the same no matter where the player is vertically... so can i use angle for that?
i also want it to work when the player is higher or lower than the enemy.
so.. what's up with that then
Hey mastersneeza can i dm you i have some questions
what i meant is what i sent just now 😭 im so sorry... my communicaition skills are ass
please don't ask for help in dms, it negates the purpose of having a community server @sonic arch
ok so.. what was the issue with the code you originally had then
oh okay alright
that angle changes when i jump
What?
@round glade you've been told already where and how to ask for help. put some effort in
I asked someone not whole chat
yeah that's the problem
i mean what i said
for example i stood in a place and the angle is 10, when i jump, it raises to 25, but i didnt move horizontaly
maybe im misunderstanding the axis, one sec
ok yeah signedangle is already on the plane of the 3 inputs, the axis just determines the direction
you'll have to project the inputs onto the same plane or zero out the y component of the inputs
ohhhh i see
angle = Vector3.SignedAngle(new Vector3 (vectorToPlayer.x, 0, vectorToPlayer.z), transform.forward, Vector3.up);
Im trying this out
it works perfectly... thanks a lot!!!
this won't work if the current transform looks up/down, btw
also footnote on the vectorToPlayer, you can do b - a instead of -(a - b)
as in when there is rotation in the x axis for the enemy? that wouldnt be a problem
ohh alrighty thanks!
i am using unity's new input system
is there a way to check when button is released if my playerinput component has behaviour set to send messages
would switchnig to a messaging system be better for wehat I already have?
no clue what you're talking about
set interactions to press & release and receive the InputValue to check isPressed
also #🖱️┃input-system for future reference
like having the gamemanager send a message to the plant when iti is placed to set up its fields etc
oh wati thats legit the same as what im alrady doing nevermind
this did not work, i sent more about my problem in #🖱️┃input-system
@wise quartz !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
how can I add a number of int variables into a list or array?
could you be more specific about what you mean by that? because adding something to a list is literally as easy as calling the Add method on the list
omd all this time it was because i had both the parent and child class attached to the gameobject omd 😭 thx guys
if i have 18 ints, and I want to add them all to a list, how would i go about doing so? i assume theres a simpler method than just .Add 18 times
AddRange()
why do you have 18 separate ints that you want to add to a list? why not just put them in a list directly and not have 18 separate ints? what is the actual purpose of this?
https://xyproblem.info
each int is for the difficulty of a separate enemy, and yes all 18 of them are different and exist independent of each other.
Do you have a list of the enemies?
also how do i make AddRange work in this context it only takes one argument so I can't just feed it all 18 ints
AddRange is not the solution to this
well then
what is the actual purpose of putting these ints into a list like this? it seems like there is definitely a better way to go about whatever it is you are actually trying to accomplish
Where are the numbers coming from? Is there a list of enemies?
Do you just need to basically convert "List of enemies" into "List of difficulties"
you should give https://xyproblem.info a read because this is absolutely an XY Problem and whatever you are doing can absolutely be done in a better way
well, if you ever worry about your naming...
fun fact, inputsystem has interfaces IInputActionCollection and IInputActionCollection2
i'm completly new to unity and i heard about "tutorial hell" so i'm afriad to watch tutorials, what do i do?
tutorial hell isn't watching tutorials
tutorial hell is solely relying on copying tutorials and not actually learning
Actually put effort into learning instead of just mindlessly copy-pasting
ah ok
what are += and -= in relation to void statements? ie. Position.OnValueChanged -= OnStateChanged;
those aren't void statements, that's just not really a thing
what you have there is adding or removing delegates
OnValueChanged is some delegate, probably an Action or UnityEvent
+= basically subscribes to an event, -= removes the subscription
my bad i'm not great with terminology
and thanks, i'm not privy on events either
further reading:
https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/delegates/using-delegates
https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/delegates/how-to-combine-delegates-multicast-delegates
hey, im having a problem and i dont know why
for a weird reason my second enemy doesnt die when health is less than zero, yet my first enemy does, why this happens?
this works
{
enemyCry(trooperhurt1, trooperhurt2, trooperhurt3, audioSource, 1f, 1.5f);
currentState = MortemState.Pain;
health -= damage;
if (health <= 0)
{
mortemExplode(RifleRoto, transform, attackposition, 3);
moon.comboReload();
Destroy(gameObject);
int cantidadPoints = Random.Range(cantidadminpoints, cantidadmaxpoints);
for (int i = 0; i < cantidadPoints; i++)
{
mortemExplode(RifleBulletspointPrefab, transform, attackposition, BlastForce);
}
}
}```
this not
``` public override void TakeDamage(float damage, int type, float pushForce, float BlastForce, Transform attackposition)
{
enemyCry(sargenthurt1, sargenthurt2, sargenthurt3, audioSource, 1f, 1.5f);
currentState = MortemState.Pain;
health -= damage;
if (health <= 0)
{
mortemExplode(RifleRoto, transform, attackposition, 3);
moon.comboReload();
Destroy(gameObject);
int cantidadPoints = Random.Range(cantidadminpoints, cantidadmaxpoints);
for (int i = 0; i < cantidadPoints; i++)
{
mortemExplode(RifleBulletspointPrefab, transform, attackposition, BlastForce);
}
}
}```
health goes minus, i dont know why
are there any errors on the log?
maybe one of the lines in between health -= damage and Destroy() is failing so the code stops
just that i havent set yet the object that spawns when is destroyed, but the other neither and works
also make sure the script on the object is the correct one, maybe it has BaseEnemy instead of mortemshotgunner?
no, or else wouldn't even move
How about adding a log after you deal the damage?
Debug.Log($"{gameObject.name} has taken {damage} damage and is now at {health} health", this);
add debugs to see whats running. if the health is truly less than 0, then maybe you have this script on the wrong object and Destroy(gameObject); isnt the object you think
makes sense
i added one of the kill objects to the enemy, and died
but this is whati find weird
when an enemy dies, it drops 3 prefabs
the one who works, only has 1 set
this one had none, it died when i added that one
why?
What does the log say on one of the ones that doesn't die when you expect it to
says the value "objetive" hasn't been set, but is weird, cuz is set
So you do have an error
but is weird, cuz in theory should be fixed
So, when someone asks if you have an error and there is an error you should probably mention as such.
If you have an error, the function ends immediately. You need to fix that first.
What do you mean "is small"
a small prefab that will not use
If there is an error, execution halts.
but well, now the not-exploding enemy issue have been fixed
but now i have another, the constant error log that is making me feel confused
If something unexpected is happening and you have an error, fix the error
are you getting an error or not
"Objetive haven't been set" meanwhile Objetive is happily set
you mean, an error in gameplay, or in log
Errors do not lie
those are the same thing
There exists at least one tuetue_script that does not have objetivo set
runtime errors are logged just the same as compiler errors in the editor
The one in your screenshot does have it set, so the error is not talking about this one
go to enemy_base:46 (which probably shouldn't be named that*) and add a debug above it, with context included, so you can find which instance has it as null
-# * types in c# are in PascalCase by convention.
so my game is crashing bc a mere bird doesn't have the objetive value, uh
it isn't, but some function is early-exiting
yeah, i select all of em, and yeah, the objetive variable wasn't equal, wich meant some didnt had it, i fixed it, now works, yey
The game is throwing an error because you have an error
wich is, that
There's no such thing as "small error". If there's an error, fix it.
makes sense
yeah was it, that single tuetue didnt knew where i was
now everything works
thanks
if all of them are supposed to target the single player you could probably have it be a singleton or have some other singleton provide a reference
yeah makes sense
but i mean, the player differs on scenes
but yeah makes sense
if you had the player as a singleton it wouldn't change per scene
just a design thing
How could I have procedural recoil (which I already have) with a procedural sway and walk animation? The procedural recoil and sway override themselves and the solution I found seems to be to make a ton of childs and that just got confusing real fast. I saw a post about using IK for this but I'm not too sure how to go about doing that
sorry for bother, but now after fixing this, for a reason i dont understand everytime i do a melee attack the game crashes, and is frustating
you sure this is a code question? sounds like you're asking about animation
the game isn't crashing, you have error pause on
this occuredd after fixing them
well that
the error tells you what line it's happening on
{
Vector2 MacheteRange = new Vector2(attackRangeX, attackRangeY);
Collider2D hitEnemy = Physics2D.OverlapBox(machetepos.transform.position, MacheteRange, 0f, demons);
Collider2D hitProyectile = Physics2D.OverlapBox(machetepos.transform.position, MacheteRange, 0f, proyectile);
if (hitEnemy != null)
{
if (hitEnemy.TryGetComponent(out EnemyBase enemy))
{
if (enemy.CanDodgeMelee == true)
{
enemy.dodge();
}
else
{
enemy.TakeDamage(meleeDamage, 0, 2, 4, machetepos.transform);
}
}
if (hitProyectile.TryGetComponent(out MortemRifleProyectile enemyProyectile))
{
enemyProyectile.Parry();
}
}
if (hitProyectile != null)
{
if (hitProyectile.TryGetComponent(out MortemRifleProyectile enemy))
{
enemy.Parry();
}
}
}```
go check that line and see what could be null
yet i dont understand it
i already posted it
and i checked all
everything should be fine
there's only one player
and all values are set
well clearly not
i know, but i have checked stuff
go check the error to see what line it's pointing to
i already did, is when does a melee attack
yeah, this line
It's sort of both. I'm wondering how I could have a procedural recoil and sway without them overriding each other but I'm also wondering about the IK part. In my recoil and sway I'm setting the result to transform.localRotation and transform.localPosition so I'm assuming that's why they're not working together but I'm not sure how to fix that without needing tons and tons of children game objects
no, that's the method being called
go to your error, click the error, look at the message in the window at the bottom
there is a stacktrace
check the first line of the stacktrace, the one that's mentioning MeleeAttack
look at the end of that line, where there's a path to the file of the script
im teleporter there everything i double click
the part with :number is the line
i dont see it
or i dont get it one of both
look at the message in the window at the bottom
it's also telling you in the preview but the line happens to be too long
are you using localRotation/localPosition as the state as well?
what do you mean by that?
ooooh i didnt noticed that
ValeriaController.MeleeAttack (UnityEngine.Transform machetepos, System.Single attackRangeX, System.Single attackRangeY, System.Single meleeDamage) (at Assets/DaStuff/Valeria stuff/scripts/characters/valeria/valeria_playercontroller.cs:553)
ValeriaController.HandleValeriaMachete () (at Assets/DaStuff/Valeria stuff/scripts/characters/valeria/valeria_playercontroller.cs:360)
ValeriaController.Update () (at Assets/DaStuff/Valeria stuff/scripts/characters/valeria/valeria_playercontroller.cs:102)
is........is the same line of the method
360
no, that's the call prior to the current stack frame
it's pointing to line 553
do you mean, where the function is working?
are you assigning directly onto the localPosition/rotation, or adding to them?
cool, so hitEnemy is null
Directly assigning. I've trying adding but that didn't seem to work, I might have done it wrong
holup
i think is this on
if (hitProyectile.TryGetComponent(out MortemRifleProyectile enemyProyectile))
is that line 553?
Is that valeria_playercontroller.cs line 553? You've disabled line numbers for some reason
yes
(you should absolutely turn them back on)
i wat, i didnt knew that, i dont think i ever did, it would be accidental :-;, dang
how
I don't know I've never been insane enough to disable them.
could you show an example of how you're assigning to the value (and yeah assigning would mean it overrides the value so the effects don't stack)
settings > search for "line numbers"
Sure, one second
it. was. an. accident.
;-;
oh, thanks :3
private void SetRotation()
{
_targetRotation = Vector3.Lerp(_targetRotation, Vector3.zero, returnSpeed * Time.deltaTime);
_currentRotation = Vector3.Slerp(_currentRotation, _targetRotation, snappiness * 10f * Time.deltaTime);
transform.localRotation = Quaternion.Euler(_currentRotation);
}
private void SetPosition()
{
_targetPosition = Vector3.Lerp(_targetPosition, defaultPosition, returnSpeed * 5f * Time.deltaTime);
_currentPosition = Vector3.Slerp(_currentPosition, _targetPosition, snappiness * 10f * Time.deltaTime);
transform.localPosition = _currentPosition;
}
This is for the recoil, the functions run in Update()
im not sure cuz i havent tested, but...looks like was tring to check if the enemy was a proyectile after checking was an enemy, to wich wouldn't make sense unless it mutated into a proyectile
yeah, that is it
maybe
no, it wasnt
Instead of guessing, check
ok
Look at the line number the error is on
ok so your state is in _currentRotation/_currentPosition
you'd probably want to reset the localPosition/localRotation each frame before these functions are called, and then do += instead of = on them? so the effects stack
ooh, nvm, i was right, just Unity didnt compiled
but yeah
that was it
take that with a grain of salt though, haven't done that kind of thing before
cool, now go learn how stacktraces work for god's sake
I'll try this. For localRotation, I need to multiply it, right?
yeah for the quaternion, forgot to mention that
Alright
i mean cuz i wonder if is funnier a proyectile or a hitscan
what feels more... "destructive"
oh, and stop being so sure of yourself when you can't even pinpoint the line the error is coming from
with checked i mean values, cuz i thought was a value error like earlier
sorry tho ;-;
its ok
that doesn't even make sense, everything's a value lol
but yeah go learn how to read stacktraces
Seems like the recoil is still overriding the sway even after this. Here's how I'm assigning it now:
// Sway
transform.localRotation = Quaternion.identity;
transform.localRotation *= Quaternion.Slerp(transform.localRotation, targetRotation, speed * Time.deltaTime);
// Recoil
transform.localRotation = Quaternion.identity;
transform.localPosition = Vector3.zero;
transform.localRotation *= Quaternion.Euler(_currentRotation);
transform.localPosition += _currentPosition;
you'd have to do the reset from some central part, only once, before the effects are applied
here you're resetting the effect from the sway then applying the recoil
Ah
I am currently using the unity player input to detect player inputs. I am also Using UI buttons.
Is there a way to get the ui-buttons to "eat" the OnClick from the mouse? or alternatively a check weather the mouse is currently over any ui image so I can filter the player input?(this seems like a bad workaround tho)
are you using UI buttons at the same time you want to be able to.. click in the world or whatever?
yep, the ui sits around the screen, so no deactivating anything in certain situations unfortunately
and what would clicking normally do?
depends, mostly select somthing on a board
problem is when I press a ui-button it also does the select on the board
you end up clicking something behind the button on the board, or...?
should probably continue in #🖱️┃input-system
and show an example there
ah, makes sense
Hey, I feel like I'm blind. Is there any documentation that explains the bindings in the input system's input map? For example the binding PrimaryTouch/TouchContact? exists but I don't seem to be able to find anything on what values it returns? I thought this could be used to detect touch contact and touch release states. I've been searching for this since yesterday and just can't seem to find anything on the input system docs that might help me find out when a touch is released. I realize I could probably do this easier with a proper c# script but I've been trying out the visual scripting graphs lately and wanted to do it that way this time
Hmm, yes somewhat. I stumbled upon this as well but it seems to be missing some stuff. I'm specifically looking for this one, which seems to be missing from https://docs.unity3d.com/Packages/com.unity.inputsystem@1.14/api/UnityEngine.InputSystem.Controls.TouchControl.html#properties
go to #🖱️┃input-system if you need further help
Oh thanks! I didn't have that channel yet 🙂
I know && represents and, but what represents Or?
Hey, I came up with this:
using UnityEngine;
public class Combine : MonoBehaviour
{
[SerializeField] private Sway sway;
[SerializeField] private Recoil recoil;
private void Update()
{
transform.localPosition = Vector3.zero;
transform.localRotation = Quaternion.identity;
sway.SetRotation();
recoil.SetPosition();
recoil.SetRotation();
}
}
The sway is still being overriden by the recoil. The SetPosition() and SetRotation() are only adding to the transform
that'd be || ( totally missed the link right below :/ )
!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.
guys im trying to create this zoom in effect using the FOV feature on my camera but for some reason the script isnt doing anything. Gotta be honest with you I have no idea what I am doing with the handleAim function that part is chatgpt but basically I have a normal MainCamera with a cinemachine brain attached to it. pls help
A tool for sharing your source code with the world!
if you're using cinemachine you need to modify the zoom on the CM camera not the actual camera
You can also just make a second, more zoomed in, CM Camera and transition to that one and back as needed
stupid question but how do I access something i just got from the asset store?
um ive never like made a game or scripted before like i just got into it and was wondering like where to start and if yall have any tips
i dont really wanna become a big game developer i just wanna make some cool little games
nvm im dumb
A good place to start is the Unity learn website or check the pinned messages in this channel . . .
I'm a beginner and im making a story game. This is the dialogue UI script. I don't know why I can't click the continue button and i added the debug.log after the AdvanceDialogue() and it doesn't show it in the console. If anyone wants to help and knows how to help, please dm me.
Do you have an Event System in your scene?
nein
You can't interact with UI without an Event System in the scene
help me please bro i just following unity tank tutorial and when i wanna but healthSlider it's not appear in my screen and whenever i tried to place it this error appear :v, stuck for last hour please someone help meeeeeee
those are some very weird, serious errors. I'm not even sure how you would get into that state.
I would definitely start by restarting Unity.
so i need to restart my project?
restart the Unity editor
ok i'll try it
uhmm i think still same when i tried to place healthslider this error appear
any idea?
can you explain what you mean by "place healthslider"? What exactly are you doing in the editor?
so i following unity tank tutorial and when i finally came to this step so i follow the instructure then idk why that's didn't work for me
which part causes the error
when i want put healthbar on canvas
which step in particular
the third one
the third one is broken down into three smaller steps below
Is it the click and drag part?
Ok - maybe something is wrong with the health bar prefab
it's corrupted or something
yeah i think so
well- can you show it?
here
I mean show the prefab itself
is this look normal?
not sure - did the tutorial have you create this? Or was it already there as part of the project or whatever
I'm not familiar with this project
thank you i just tried it
its already there
they just ask me for download the project resource
I would try redownloading the package
ok i'll try it so should i start over my project?
excuse me yeah i've another question, i saw some different button from tutorial and my editor how to spawn that's button thanks
and this my editor looks like
im using UnityTest but I need a OneTimeSetUp and OneTImeTearDown
I'm currently faking the setup by doing
public IEnumerator SetUp()
{
if (!_oneTimeSetup)
// do stuff
oneTimeSetup = true
{```
Is there actually a better way to do this? And how can I do it for the teardown?
depending on what you need to actually set up, then PrebuilSetup and PostBuildCleanup attributes might be what you need
i'm trying to create a gif making software but recorder is editor only and not supported with c#
the onetime setup and onetime tear down would be entering and exiting playmode along with loading into the level. We're doing golden path flows for these tests.
sorry the only golden path i'm familiar with is the one that saves humanity thousands of years in the future. perhaps create a thread in #1390346827005431951 with more info about what you are trying to do 🤷♂️
fyi it is. See the MovieRecorderExample in the samples
how do i start or stop recording
What you mean?
&& is for checking if two condition are true
Example
They were asking about what operator is used for the conditional OR, which I provided a link to answer them
If (Input.GetKeyDown(KeyCode.w) && Input.GetKeyDown(KeyCode.alt))
Ahh
and they already got answers
you don't need to repeat what two other people have already said
So | | is really same to &&
You are talking to me?
yes
Shut up
that message was a good 15 hours ago
you're just giving them unnecessary pings at this point lmao
See the MovieRecorderExample in the samples
doesn't matter, Chris is still right. you unnecessarily pinged someone who already got an answer and weren't even going to provide an answer to the question they asked
that's ok, im talking to you
Hello everyone !
Someoen can tell me what's the official way to serialize a binary file in the resources folder ?
com.unity.serialization ?
Thanks !
You can use JsonUtility
Thanks for your input, but I said binary file 👉 👈
I had good experiences with com.unity.serialization, it was pretty easy to serialize and deserialize the binary files
had some issues with the source generation option though
I wanted to be sure because it's almost one year since the last update, but well when the code is complete there is no need.
Thanks
i personally use and recommend messagepack for binary serialization, but i also have no experience with unity's serialization package so i don't know how it stacks up (i'd bet that message pack is better overall though)
True, but it's for a package not a game so I want to limit the additionnal dependancies (and to be fair it's just settings, no need for high high speed).
Does messagepack has a unity package available by any chance ?
there's a github repo that has the package. it's also available through open upm
if a game would have multiple playable characters would each of the characters have a seperate script or would they have a parent script for most of the stuff like movement
I would probably make a Player parent class that is an abstract class and then create separate scripts for each playable cahracter that inherit from that base class.
But if the different playable characters only have differences in like model, animations and such you might be able to get away with only 1 Player class, it depends on the scenario.
Well thats the issue, i was kinda planning on making unique mechanics for each character, like one can teleport while another can move faster and charge their jump
but i dont know if its possible to seperate it into just whether i use a parent class or not
because on one end i might be able to get away with using a parent class for some characters if they're very similar like if a character unlocks some other mode or sommething, but at the same time i dont know if i get a situation like that if i should just add that in the code itself instead of making a new script for it
I think ill just seperate the characters into seperate scripts because i'm not that confident in using parent scripts
just use a parent classthen like thike
public abstract class PlayerBaseClass(){
protected abstract void AbilityQ()
protected abstract void AbilityW()
protected abstract void AbilityE()
protected abstract void AbilityR()
}
and then in each class you implement these classes as you wish, you can also add non-abstract classes for the things that are similar like health calculation. This is just a pseudocode.
Generally, these scripts would be separate from each other. A script should only have one responsibility. Movement is separate from the character. You'd have a Movement class that only handles moving the character. Each character would have the same script . . .
If a character has special movement, like a dash or a jump, I'd create a separate script to handle that and attach it. The scripts are small components that when combined build the functionality of your character . . .
Im just planning on putting everything for each character in different scripts separated by character not by function really
Mostly because I don't want a different movement script for every single character based on the way the characters move
Yes, you can add a dash and a jump to the Movement script but it becomes difficult the more functionality you add to a script . . .
You don't need different Movement scripts; create one and attach it to all the characters . . .
Im not planning to use the same movement for every character
🤔
I will do that for basic things but if a character moves completely differently then I will have to make a different movement system for it
Which might happen a couple times
Huh? You just said you don't want a different Movement script for each. Now you do?
I said I didn't want to separate things like movement and combat and just wanted to put mechanics in the same script, I'm only separating characters in scripts really
I already got my answer a bit earlier anyways so I'm just going to go
My neck is hurting anyways
is there a better way to put text on object rather than put canvas as a child of it.and should i worry about it chewing up my performance
dynamic text? if its static you can bake it into the texture
yeah dynamic
My inventory needs to store up to 300 inventory items. This means that each item needs a monobehaviour that implements IBeginDragHandler, IDragHandler, IEndDragHandler to handle swapping items in the UI. Would this be too expensive for performance considering im only using unity events?
No thats fine
stuff like health ui on an entities that move around
alright thanks!
if you have lots of enemies that show their health put all texts on one canvas and let the text track the position instead of multiple small canvases
i see . thank
you can ofcourse to that with every text/ui element like health bars that are bound to on-screen entities
its common practice to have a single canvas that contains all health bars for example
this isnt a code question but either way have a read here https://unity.com/how-to/unity-ui-optimization-tips. this is pinned in #📲┃ui-ux . its not good to have tons of objects on 1 canvas that are constantly updating
my bad, and thank you👍
assuming player is an object that inherits from UnityEngine.Object then yes
yes
its a transform
then yes, they are the same
why is this happening?
because you pressed play
no no
why is the purple cube revolving around my player cube, it is supposed to chase the player
i am using Navmesh according to the rollaball tuotorial
your video is not helpful in any way, explain it or make one that shows your current problem a little bit better
i only see a purple cube and a ball, which one is the player?
also show inspector of enemy and enemybody
guessing that you offset the model while the agent is on the parent
yeah
thats what happened
thanks alot
How can i make movement with new input system to not override external velocity like knockback and not leaving player with unchangeable speed if it was applied? I've tried to use code below but it will instantly nullify x-vector and if i wrap it to if (vector2.normalized != 0) then character will move in the last used direction
Rb.velocity = new Vector2(_moveDirection.x * maxSpeed, Rb.velocity.y);
are you using AddForce for the knockback?
I've tried to do so but then decided it will not work if initial speed would be too high. At this moment i use this method
protected virtual void KnockbackYourself(Vector2 threatPosition)
{
var knockbackDirection = ((Vector2)transform.position - threatPosition);
Rb.velocity = new Vector2(knockbackDirection.x * 12.0f, 5f);
}
Magic numbers
Remove them
For a knockback I would assume you'd want Addforce with an Impulse forcemode
I have a question, I am new developing games and I have a problem that I cant fix it. The main camera is in the main player but when i start the game it was somewhere else and i can see the capsule in front of me instead of the camera being inside. I dont know if it a problem in coding or in the hierchy
Use a bool that cancels out the set velocity method
Will try, thank you
do you have more than one camera in the scene
no just one, it just goes back when i hit play
what about MoveCamera
I use numbers instead of variables just to establish it for now and probably would replace it later, especially if there would be a need for different strength of knockback. As for AddForce it just felt out of space here
where is it on, and what's the transform that you have there
It's not very often you'd manually change the velocity.
i have the movecamera into the cameraholder and the transform is the camerapos, nad the PlayerCamera is on PlayerCam and the Transform is the orientation.
knockback is an instant burst of force in a direction you choose, add force with Forcemode.Impulse would do exactly that
try setting the camera offset to 0 0 0
where is dat?
transform
playerCam is set to -9.x units behind the cam holder
on PlayerCam
so it's going to be that far behind the player
the position? on playercam
yes
you're moving the parent with your script
but the camera is a child of that and always offset relative to the parent
ur so good thank you very much i thing that is fixed
Will see it again then, thank you
Using bool for temporaly disable move method helped but now it's looking like i'm beating against of air if bool switched before i'm landed. What can i do to fix it?
private void Move()
{
if (!IsImmobilized)
{
Rb.velocity = new Vector2(_moveDirection.x * maxSpeed, Rb.velocity.y);
}
}
protected virtual void KnockbackYourself(Vector2 threatPosition)
{
... // I use IEnumerator to switch IsImmobilized state
var knockbackDirection = new Vector2(
horizontalForceAmplifier * Mathf.Sign(transform.position.x - threatPosition.x),
verticalForce
);
Rb.AddForce(knockbackDirection, ForceMode2D.Impulse);
}
Hey everyone!
I’m working on a Unity inventory + equipment system for a lewd dungeon crawler RPG and could use some guidance.
Here’s what I need:
Inventory holds item prefabs with an Item component (CursedGear, Consumable, KeyItem, etc.)
Equipment tracked by slot using an enum (EquipmentSlot → GameObject)
Equip logic moves items between inventory and equipment, unequipping old items properly
UI shows equipped item icons per slot, icons come from a sprite field on the Item component (not from the GameObject’s Image component)
Uses an OnEquipmentChanged event to update the UI
Some items apply status effects like curses
My problem:
Icons don’t always update reliably, event triggers can be inconsistent, and syncing prefab data with UI is tricky. I want a simple, clean, open-source example or tutorial to emulate, especially one that clearly separates item data from UI representation.
If you have or know:
Good example projects or repos
Tutorials that cover this well
Assets or patterns that handle equip/inventory + UI cleanly and reliably
Please point me in the right direction! Thanks!
hoo boy, i gotta review the #📖┃code-of-conduct for this one
but also, game dev guide usually has some consistantly good tutorials. they have a tutorial on inventories too. just from a quick skim I believe it fits most of your criteria
Download Core to create games for FREE at 👉🏻 https://bit.ly/Core-GameDevGuide and join the Game Creator Challenge 👉🏻 https://itch.io/jam/gcc - Inventory Systems are a key part of most games, so let's look at how to create one!
Want to support the channel...
if you have any issues feel free to come back here and we can help you debug them 
could have just left the "lewd" out of it 
it's looking like I'm beating against of air if bool switched before I'm landed
What do you mean by this? I'm not able to interpret given the video what the issue is.
Once IsImmobilized switched to false player make a jump in the air and fall to the ground while x-axis velocity reseting to 0 since there is no input from me
Is that what you are wanting?
Nope, i want it to fall naturally unless i'd try to move character by input
I'm not understanding the question. I'm assuming you're wanting the bool to be false before the yield from the coroutine finishes. If so, just set it to false elsewhere.. like when landing etc.
I want to achieve smooth speed deceleration rather than just immobilize player until it hit the ground. Like this
Red is how it's working now*
Are you assigning to velocity anywhere else other than Move? Your velocity with regards to x shouldn't go to zero if you aren't modifying velocity.
Especially in the air as there very likely isn't any resistance-friction
(unless you've got some move dampening built-in or something)
Move method is in update so if i don't use movement buttons then it will just multiply rb velocity to 0 and kill all speed. I've tried to wrap it to if (vector2.normalized != 0) but in this case character would just move with last achieved speed in the last direction until i input another value and it'll just change direction
private void Update()
{
_moveDirection = _move.ReadValue<Vector2>();
}
private void FixedUpdate()
{
Move();
}
private void Move()
{
if (!IsImmobilized)
{
Rb.velocity = new Vector2(_moveDirection.x * maxSpeed, Rb.velocity.y);
}
}
Show where you're assigning velocity other than move. I'm assuming your character is immobilized and that movement isn't what's causing your velocity (relative to x) to become zero
instead of setting the velocity use movedirection to apply a force on your character and clamp the velocity to the max speed, then you can gently steer against the knockback but not disable it fully
Oh, there's only this methods and knockback itself change velocity in one way or another
protected virtual void KnockbackYourself(Vector2 threatPosition)
{
float horizontalForceAmplifier = 3.0f;
float verticalForce = 2.5f;
StartCoroutine(nameof(Immobilize));
var knockbackDirection = new Vector2(
horizontalForceAmplifier * Mathf.Sign(transform.position.x - threatPosition.x),
verticalForce
);
Rb.AddForce(knockbackDirection, ForceMode2D.Impulse);
}
protected virtual IEnumerator Immobilize()
{
IsImmobilized = true;
yield return new WaitForSeconds(.3f);
IsImmobilized = false;
}
Will try, thank you
also depending on if you want to keep a "stun" on knockback you can then remove the IsImmobilized as you cant airbreak instantly anyways
As it's made now it's more of workaround than stunning mechanic
i mean you can keep it as a stun
just dont apply the movement force on the player while the "stun" is active 😄
Oh, got it
oh and dont forget to multiply the movement force by deltatime if you apply it, constant force via ForceMode2D.Force should be deltaTime sensitive
I see, thank you again
jo guys what is a good approach on creating bosses in unity 2d?
Same as creating anything else. Create the logic in code, make a prefab, attach or the relevant components and references, create the visuals, etc...
If you need a better answer, you'll need to make a better question.
i seen alot said that co routine is bad and invoke is worse, what usually used instead?
coroutines are fine
don't just take "bad" at face value, actually do some questioning about why that's presented
yea how do i determine that
i can guess invoke is bad since it pass in a string so like maybe it search for that funciton
Invoke is generally regarded as bad because it uses magic strings and doesn't give you precise control over queued calls
idk co routine
coroutines.. idk, create garbage?
that new waitforsecond ?
i guess that's technically a bad thing, but it's not gonna matter unless you're creating a few thousand of them in a second
well i was referring to the coroutine itself, but yes, that too
but it really is not at a scale that matters
ok but what used instead
coroutines are fine, you can write timers yourself that are updated in Update (basically the same thing written in a different way) or you can use other systems like tasks or async
just use what makes sense to you, that gives you an easy time reading and writing
currently i know invoke is bad but really easy to use, the function can be reuse easy too
for coroutine i hate setting it up and to only use it through start coroutine
so really want aternatives
i gave you alternatives
yea just explain i cant really settle with them 2
hell, use invoke if you want to, i can't stop you
just know that there's debugging hell waiting for you if you ever mess up
I've never used async functions and don't know a lot of them but aren't whole game work asynchronously?
look, i'm not gonna sit here explaining every option only for you to settle on invoke or whatever
i gave you keywords, if you want to learn more you can go google them
chances are they're overkill though - most usage is just either coroutines or Update timers
i think you are thinking too much, that sentence i said just only to explain that i dont really want to keep using those 2 only. but not for want to keep you going
you said, "just explain", that's a request lmao
ok mb not really a english speaker here, thought remove that ''I" at the beginning wouldnt change the meaning
Normally, all of your code runs on the main thread in callbacks that unity provides you with(awake/start/update, etc...). Async, coroutines and some other methods allow you to defer your code execution to a different point of time or split it over several frames, etc...
Chris did mention the alternatives: your own timer kind of system in update, or async.
But to be honest, async can be more complicated for a beginner(has some pitfalls that you need to know and handle), so maybe stick to coroutines.
Your own system in update is fine too.
now i dont get it, this is me just explain my problem with invoke and coroutine right? what part imply something else?
genuine question, i want to avoid this hassle when asking a question again
what answer are you expecting?
Well, for one, lack of punctuation makes your messages hard to read and easy to misinterpret. If someone tired was trying to read and understand them, they would get annoyed for sure.
not really one tbh lol
Guess i got it, will dive deeper into it someday. Thank you
what's your question then
what are you trying to get from us
this just me show my problem so not really a qeustion i guess ?
you show the alternative and thanks you my question end there
your problem with coroutine is that you dont want to use it because you dont find it easy basically. learn to use it or just stick with invoke which you've said yourself, its worse.
To answer it simply. There is no problem really. The mentioned things are not always bad. It's important to look at things in the context of their usage.
so really want alternatives
right, so this kinda indicates you aren't satisfied with the answer, or you think you haven't been answered
ok i see
I think you both just misunderstood each other at some point and kept on developing that misunderstanding. 😅
if you were clarifying a previous message/question you need to put something that specifies that (ie "to clarify") or use past tense (ie "so i wanted alternatives")
ideally both
ngl at first yea i did go that route, but saw alot shit on it so i want to checkout the alternatives
Coroutines are easier to use if you have a snippet for it. For example I write coroutine in visual studio then it outputs below with my cursor at Name so its easy to change the name.
{
yield return null;
}```
my favorite snippet is "sf" which outputs [SerializeField] private int myField;
In unity6 is there a way to view read-only properties on components? I want to see some internal state without spamming logs for a property defined as public float seenHeat { get; private set; }
[field: SerializeField]
That works, however makes the property appear like it's meant to/can be set in the unity UI (is it actually forceably assigning the value?). Id like to maintain it being read only
Use NaughtyAttributes: https://dbrizov.github.io/na-docs/attributes/meta_attributes/read_only.html
Yeah that actually does just straight up let you mutate readonly fields, which at that point might as well just make it a public property
(btw readonly field is different from a property without a setter)
Ill check that out thanks
Oops replied to myself
Ah yeah, I meant a property only assignable within the class
If you have Odin Inspector that has a similar attribute as well, and can work directly on properties. But that's a paid asset (and Odin Serializer happens to be notoriously non-performant)
Im using a custom unity runtime so im trying to avoid libraries/packages as much as possible as theyre a bit of a pain to setup
You can also just write your own PropertyDrawer (which is how the NaughtAttributes lib above works)
I have an object with a single AuidoSource attached and two AudioClips referenced, the first clip works but the second one doesn't. The first clip is played here:
if(Input.GetKey(KeyCode.Space))
{
PlayerAudio.PlayOneShot(Fire);
}
The second one is played here:
void DestroyPlayer()
{
if(HasPlayedSound == false)
{
PlayerAudio.PlayOneShot(LargeExplosion);
HasPlayedSound = true;
gameObject.SetActive(false);
}
}
If I move the LargeExplosion sound to where the Fire sound is played, it works perfectly fine. Does anyone know why this isn't working?
The sound is played before the object is set inactive so I don't think that has to do with anything
it might if audiosource is on it
Wow. I have no idea how I didn't notice that setting inactive interrupted the noise. Thank you though for making me realize that lmao 😭
Hi, may anyone help me?
So i started doing 3d animation just now, and my animator controller logic already settled correctly, when its idle and walking, so the problem is not inside the controller i guess. However when i press play, the idle animation is playing in controller but not in the game directly, what could be wrong?
Ive asked ai, and watched basic animation in youtube, nothing helped
The rig also settled to humanoid not generic
Kinda hard to say anything without more context/info. Maybe record a video showing your setup and the actual issue
True.
But as i understand (i learned c# unity few days ago) the default animation would play even the script doesnt tell anything right?
But in my case, the animation isnt playing at all. My controller animation already settled to the correct controller, so i wonder what else could go wrong
Do you have any clue what should i look at
Even in my script, i already assign the gameobject to the correct one,
If you have the animator set up correctly, yes.
Really hard to say without any info.
Sigh, guess let me try from beginning
Need help making aim code
I made one version today but it gave me an error saying top was not accepted when I typed serialized field
So that one version won’t work
Gun aiming btw not just aiming in general
Huh
Can you be more specific about this?
Also how is "gun aiming" different from "aiming in general"?
What kind of game is this?
check if you selected the correct gameobject in the hierarchy
check if the animation "clips" are correct in those states
disable any scripts that you put that change anything on the animator
otherwise yeah show some footage
Thank you all, but the problem is in the 3d model ig, while when i use mixamo sprite its all alright, for now thats fine as im testing mechanism of unity.. ty !
mixamo "sprite"?
are you trying to run a mixamo animation on another character?
make sure you have the animation with a humanoid rig and your character model also it's own humanoid rig for easy retargeting
Yeah :))
I mean it worked in mixamo but for some reason its not accepted in unity
download in mixamo with skin once
I spent 3 hour to figure out ong
Yeah i did
and then select the mixamo rig in the mixamo animations
click model in project -> inspector -> rig and then set to humanoid (from this or from other which has the rig "skin")
again showing these will tell us more
Ill try again someday 😒 for now imma have fun exploring around
Hi, any data on this? I'm actually curious. Because I was considering to use the open source Odin Serializer only, on a next project. Any better recommendations? Mind you that I only played with Unity Json a bit.
I always heard that all the issues and bad performance on Odin were related to the Inspector side of the asset/package.
hello
ı watched a tutorial but when i tried it didnt worked
there is no error but not working
If you have a question then !ask an actual question that can be answered.
: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
how can ı do that
"not working" is not a description of the problem. Think about what you asking.
this is the code
there is a button when i click it it supposed to be hostlobby and show me the lobby creators name
Might worth a try to ask i have been struggling with my rigidbody. Im using object pooling. At first when the gameobject created it fly to the right, when it gets taken back to the pool second time, the force is not applied and just falls off.
Rigidbody rb = bulletcase.GetComponent<Rigidbody>();
if (rb != null)
rb.AddForce(spawnPoint.right * 5f, ForceMode.VelocityChange);
you need to provide more context than just that
wdym?
i mean exactly what i said. that is not enough context to know what is causing your issue
private BulletCase CreateBulletCase()
{
string path = "Main Camera/ObstacleAvoidenceRotator/Weapon Camera/WH/Primary/idle1(Clone)/gun_rig/main/bullet_case_spawner";
Transform spawnPoint = Reference.i.thePlayer.transform.Find(path);
//Spawn new instance of the bullet
BulletCase bulletcase = Instantiate(bulletcasePrefab, spawnPoint.position, this.transform.rotation);
bulletcase.transform.SetParent(poolParent.transform);
//Assign the bullet's pool
bulletcase.SetPool(_bulletcasePool);
return bulletcase;
}
private void OnTakeBulletCaseFromPool(BulletCase bulletcase)
{
//Reset the transform position and rotation
string path = "Main Camera/ObstacleAvoidenceRotator/Weapon Camera/WH/Primary/idle1(Clone)/gun_rig/main/bullet_case_spawner";
Transform spawnPoint = Reference.i.thePlayer.transform.Find(path);
bulletcase.transform.position = spawnPoint.position;
bulletcase.transform.rotation = UnityEngine.Random.rotation;
//struggling part
Rigidbody rb = bulletcase.GetComponent<Rigidbody>();
if (rb != null)
rb.AddForce(spawnPoint.right * 5f, ForceMode.VelocityChange);
bulletcase.gameObject.SetActive(true);
}
Whats is wierd that it works for the first time but when recycled it's not. I tried to reset the velocity but rb.velocity is deprecated and it suggest velocity linearVelocity instead, but it doesnt work with that.
You have to activate the object before applying force
oh my god....
Thanks, that seems like was the problem. I need to take a break, been coding since 6 hour straight, my mind is hazy.
hello everyone. I am doing that a character grabs and drops a cube. Grabbing works but when I drop the cube it doesn't collides with the floor. I've been trying for a long time but I can't figure out what is happening. If anyone can help me here is the code. Also the components in the cube and in the floor.
before picking do the cubes fall and collide with the floor? use gravity is unticked at start?
@trim anchor
before picking the cube the gravity is unabled but i have to enble gravity so when i drop the objects fall
so yes the gravity at start is unticked
show the colliders on the box and the floor( scene view)
and if you start with gravity enabled without picking them they also fall through?
yes
hmm...
what about project settings then physics. is it disabled in the matrix there? default to default layer collision
I have all enabled
also that script is the only one and it's on the player right?
yes
what if you make the floor 1 thick instead of 0.1
also what if you set interpolate to something else on the cube
What does interpolate is used for?
ok it's probably not interpolate
the interpolate in my cube is none
so if you enable gravity what happens after a like 5-10 seconds
where is the cube then
The cubes falls, passes through the floor and keep going lower
floor collider center y is offset by -1. shouldn't that be 0?
other than that I can't spot anything rn kind of sleepy
it doesn't work but anyways thanks for trying to solve it
what I'd try is with a new scene just floor and a cube with rigidbody and see if it works and if yes then re-add the things one by one
if is not trigger it works but i can't grab the cube if it isn't trigger
oh..
i didn't even see that
yea trigger is trigger
no collisions then
you would either have to add a child with box collider trigger on the cube or maybe have a trigger on the player itself
and definitely uncheck trigger on the rigidbody collider itself
how could i miss that lmao

but for grabbing the cube i use ontriggerstay. Is there any other method that works with collision
there are 6 important ones
ontrigger enter/stay/exit
and same for collision
as i said you can try adding a child box collider on the grabbable object and set that to trigger (and maybe make it a bit bigger)
i've tried putting the cube with a child that is triggered and the parent without is trigger and the cube just acts like a cube without is trigger
does ontrigger not get called? add a Debug.Log("ontriggerstay called") there
make sure you set the tag
also make the child (trigger) is a bit bigger than the parent because you may be pushing the whole thing without being able to enter the trigger box
I've made the child bigger but it seems that in physics it acts like a cube without trigger
what if you put a rigidbody on it too but set it to always kinematic
I have put the cube in kinematic. It just stays static and you can't grab and drop it
otherwise you probably need to use another logic. like oncollisionenter and then track last collided grab object in a variable (+ check distance when pressing grab key)
i meant the child trigger
like goes upward instead of how gravity should work?
yeah
almost certain its about the settings of the rigidbody
just forgot what it was exactly
look
that's the parent?
yes that is the parent
and child?
try to send bigger picture btw can't see collider on these
use gravity on child makes no sense but idk if that affects anything because you have kinematic checked anyway
oh check is trigger on child
otherwise they are literally inside eachother and the cube collides with it and flies
i've checked is trigger now it doesn't flies
ok and is it bigger than parent?
or try if you can grab it now
hmm although maybe it won't work with your code since you're getting the child
would need to change it a bit
how?
A bit hacky but in ontriggerstay where it says other change it to other.parent
other.GetComponent... becomes
other.parent.GetComponent...
do that with all the lines where you wrote "other"
since you want to change the parent collider
not the child trigger
it shows that is an error
how so?
Quick question on double tapping. I am developing a mobile game don't know how to do double tapping, I looked it up only and it looks like this is better practice then what I thought of doing. I thought having a timer where if button x was clicked twice within the same second the player would dash. Which is better practice here? How much of a difference would and does it make?
the link is the source I was following for reference to learn how to do a double tapping system
just show the error
just have a timer that counts down.
on the first click set it to for example 0.5f (half a second)
then on second click check if timer is above 0
adjust time how you want
does that make sense?
ah other is collider yeah right.. it has to be other.transform.parent 🙂
mkv not working on mobile here
@wooden hill thanks it works
the solution juan provided is really simple for example can just use that
nice
btw you could also put a child like that (with kinematic rigidbody and trigger) on player instead of every grab object
ok
but then you would again have to adjust code
at least need the trigger stay message script on the trigger child
yes
thanks
no problem basically just try to not overengineer/overthink if it's not too critical like this
But I don't want to stick to the stuff I already know I want to move a step forward so I can learn and do more stuff
And I want to learn how to do it the right way
there are multiple ways as you can see from that thread
which one is perfect? idk.. would have to run profiler and check if coroutine way is some micro/nanoseconds slower than the update method
Is there any book you can suggest me? Like the best course I have ever come across when learning c# was w3schools, have tried SO MANY different tutorials, w3schools is the only one standing on terms
something I keep on the side and read at my free time
that will move me onto beginner-intermidiate level
or help me move onto that
sadly not would have to ask others. can only point you to !learn. i would suggest just grab any book on c# (and/or unity)
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
I feel like from what I have seen 99% of them is just a lot of pages with bullshit, so money grabbers with basic stuff making it look like professional and good books
(and sugar coatting it)
I haven't had a c# book only read some c or cpp at my uncles place long ago and got interested in making games around that time too. in unity i started with tutorial hell 😄 but slowly transitioned to learning and doing more by mself
i did other programming languages too and experimented a lot so I can't really call myself to have an idea how to go about it other than just keep trying 😛
if you like books and want to learn c# i highly recommend The C# Player's Guide by RB Whitaker. it's an excellent introduction into the language in a gamified way that makes it feel like you're actually progressing. there's also an active and helpful discord community associated with the book to help with the challenges
as long as it's not too much basics (like stuff I already know) I will buy it right now
Can you send me an invite for the discord community by any chance?
it is geared towards people new to the language and programming, but has summaries you can skim through to skip ahead to the more intermediate stuff
as a beginner I sit down and spend like 2-3 hours, 70% of the time is doing research and chatting to more experienced people and 30% is actually coding 😭
does it touch topics like coroutines and more detailed stuff?
coroutines are a unity thing
ohhh, this more based on c#
yes, it is purely c#
should I start with the 1st edition?
lol no, they aren't sequels but rather updates that include restructuring of the content and newer language features. just get the latest one, but be aware that it teaches some stuff that isn't available in unity at the moment (there are some specific c# 10 features that cannot be used in unity yet)
hi y'all, quick question
i'm trying to use the splines package, to generate a path that connects 2 points smoothly
when i set the spline up in the editor it works as expected (pic1), but when i set the spline up from code, its fully straight (pic 2)
i set the rotation of both start and end knots to match the rotation of a transform that points into, and out from the objects i want to connect
(i also tried setting both in and out tangents on the start and end points, and that didn't help either)
is there something i'm not getting here?
there seems to be a sample on his page btw
show code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class HoldButtonHandler : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
{
public bool isHolding;
public bool slide;
bool dash;
public Text Debug;
int x = 0;
void Start ()
{
}
void Update()
{
if (isHolding)
{
doubleTap();
}
}
IEnumerator doubleTap()
{
if (x == 1)
{
dash = true;
Debug.text = "doubleTap coroutine run";
yield return new WaitForSeconds(0.5f);
if (x >= 2)
{
Debug.text = "Dashed and bool dash turned false";
dash = false;
}
else
{
dash = false;
x = 0;
}
}
else
{
dash = false;
x = 0;
}
}
public void OnPointerDown(PointerEventData eventData)
{
isHolding = true;
x++;
if (dash == false)
{
StartCoroutine(doubleTap());
}
}
public void OnPointerUp(PointerEventData eventData)
{
isHolding = false;
}
}
how does this look?
!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.
it works fine
oh yea, sorry
public SplineContainer handledSpline;
public Vector3 startPos;
public Vector3 startDir;
public Quaternion startRot;
public Vector3 currentEndPos;
public Vector3 currentEndDir;
public Quaternion currentEndRot;
void Update(){
Spline spline = handledSpline.Spline;
BezierKnot start = spline[0];
BezierKnot mid = spline[1];
BezierKnot end = spline[2];
start.Position = startPos;
start.Rotation = startRot;
start.TangentIn = startPos - startDir;
start.TangentOut = startPos + startDir;
mid.Position = Vector3.Lerp(startPos, currentEndPos, 0.5f);
mid.Rotation = Quaternion.Lerp(startRot, currentEndRot, 0.5f);
end.Position = currentEndPos;
end.Rotation = currentEndRot;
end.TangentIn = currentEndPos - currentEndDir;
end.TangentOut = currentEndPos + currentEndDir;
spline[0] = start;
spline[1] = mid;
spline[2] = end;
handledSpline.Spline = spline;
}
i am setting the positions, rotations and directions from a separate script that handles building the path, but that part shouldn't matter
make sure the code is actually running and that the values being used are what you expect them to be
tough to read especially on mobile. check the bot message to fix it first 
Anyone got a script where the monster walks around trying to find you
"Inline code" or if really long then use a paste site
no but you could try using navmesh for that
anyway this is not a script dispenser
i have the agent an he just sits in his idle pose
just FYI, this isn't the place to ask for handouts of free code. there are plenty of tutorials you can use to learn how to implement pathfinding, i suggest finding one and following it
i think this might be abit unrelated to direct code, but how do i parent child something without my object being stretched weird and all. Im trying to make a lever.
uh the first image needs to be clicked in
Make sure the parent has uniform scale if you're going to be adding any rotating child objects to it
everything is defaul
code runs fine, and sets positions correctly
tho the rotations always get hard set to a consistent value, that is completely different from what i set it to
I don't think it is
oh wait the parent of the parent right, not just the parent of the lever
Any parent
If any direct parents have non uniform scale, rotating the object will skew it
make the model in blender
or have them both under a shared parent instead of parent one under the other
ill separate the base and the lever itself

you have to tell it from your script the destination
https://docs.unity3d.com/6000.1/Documentation/ScriptReference/AI.NavMeshAgent.html
SetDestination
Funny question, when I put these Text boxes too close to the player they affect the movement of the player making it fly
why and how?
yes the player is 2d but that's supposed to be an on screen UI rather than something in the game
It shouldn't, most likely it's related to some nuance in your player movement script or something.
But you also cut off the hierarchy so it's a bit hard to see what's going on there
i dont have a script i have the component
Have made player the parent of canvas
these are my scripts:
hold button script, meant to detect button being pressed
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class HoldButtonHandler : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
{
public bool isHolding;
public bool slide;
public bool isDashed;
bool dash;
//public Text Debug;
int x = 0;
void Start ()
{
}
void Update()
{
if (isHolding)
{
doubleTap();
}
}
IEnumerator doubleTap()
{
if (x == 1)
{
// Debug.color = Color.red;
dash = true;
//Debug.text = "doubleTap coroutine run";
yield return new WaitForSeconds(0.3f);
if (x >= 2)
{
// Debug.color = Color.green;
//Debug.text = "Dashed and bool dash turned false";
dash = false;
isDashed = true;
yield return new WaitForSeconds(1f);
isDashed = false;
}
else
{
dash = false;
x = 0;
//Debug.color = Color.red;
}
}
else
{
dash = false;
x = 0;
// Debug.color = Color.red;
}
}
public void OnPointerDown(PointerEventData eventData)
{
isHolding = true;
x++;
if (dash == false)
{
StartCoroutine(doubleTap());
}
}
public void OnPointerUp(PointerEventData eventData)
{
isHolding = false;
}
}
@wintry quarry
the game manager script was too long to send here
You're always here helping me and other people out
!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.
really appriciate it praetor
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
A tool for sharing your source code with the world!
Looks more like a movement controller than a game manager but alright
Ay other scripts involved?
this is all
Anyway why is the canvas a child object of the player
Another thing i see is that the logic for the left button in the game manager is probably pretty problematic
Because you're multiplying the whole velocity vector by -speed
That's going to negate the y velocity, which could easily lead to your object flying
tbh I'm doing my best 😭
I have a question, what is the internet speeds at your place ? My avg speed is around 5 - 7 Mbps.
my friend
that is the speed for 2000s
we are in 2025
but it depends where you live aswell
what does it say on your contract
oh whoa, it been like this for 7 years or so.
what's the speed written the on your contract like
had 1000 now moved and got 70 mbps 🙂
if possible you could look for upgrades..
haha..
i don't think there is at this place. And I thought it's already really fast lol..
yes, rural area of vietnam.
I only got computer back when 2021 - 2022 as well
if you look at my discord creation date
oh.. yea i think if i was a bit more out of the town i would maybe also have low speeds like that
yes, vietnam is still pretty much a third world country.
better than laos and campuchia a little bit but still is
like for most of the country.
well good luck with your path 🙂
well, most of my friend already left to go to japan already since they want to do like physical work, since wage in here is so low and they don't want to live in the jungle all the time.
Hi, I have an error to get a Singleton. I want to add a Action from my Player class to a PlanManager. So, I add the reference of my method to the action in the OnEnable() method like here : https://pastecode.io/s/hw03ao1q. But, I have this error on the OnEnable line : NullReferenceException: Object reference not set to an instance of an object. I don't get the error in a awake when I get the reference of Player.Instance. Otherwise, I tried to put Player.Instance direclty in the OnEnable and now it works. Why ?
also if your player will always be a singleton then why not make the event "public static" ?
like
public static event Action TransitionPlanChanged;
i think you might need to manage your static events if you disable domain reloading though
Yes I know this graph but, I get the reference of the Player.Instance in the awake and don't get error. So, why in the OnEnable it says I don't have the reference
That's not a bad idea
oh yeah hmm ...
not sure why that tis
btw in your script there is no OnEnable anyway
i havent thought about that at all in my project 🥶 (not yet)
I have several different scripts, (mana, health, attack, move, animations, ect) and i want to edit the values all in one place (like a scriptable object almost). What's a good way to go about this
For more context, i'm trying to make it easier to add enemies to my game, so all the settings are cleanly laid out (preferablly in a scriptable object)
Why not a scriptableobject?
That might be the way to go, i'm not sure
I'd have to make almost every variable and method in my script that would need to be edited public
or i guess i could supply every script that would use the SO with the SO
hello unity bros. I'm currently struggling with a very basic problem. I have a 100x100 cell grid for my game and I'd like it rendered at run time to show where a player can build. whenever the grid is enabled, my editor starts to lag signifiganty.
the grid is just 100x100 quad prefabs with a transparent square texture. I even tried culling ones not on screen but it didnt seem to do much.
any tips on how to handle this scenario?
something like that would probably be the most efficient
I'd start by profiling to understand if it's a GPU or cpu bottleneck.
that would also allow me to remove and add components at will
yeah i think i'll do that
thank you
Sounds like you want a ScriptableObject and even mention it . . .
could use a single mesh and edit it at runtime... 
but yea profile first!
Yeah but i wasn't sure it was the right approach: eg it could work but not the best
I jsut stepped away from my pc so I cant profile for a bit. All I know is that I tried it with gl lines and it ran fine, but I couldn't get the lines to depth test so they always rendered through everything. Then I switched to quads and got lag. Is there a way to get gl lines to depth test in URP?
I can also cook up a grid display pretty easily in shader graph but I can't figure out a way to dosable/enable individual cells that route
So you can use a plain old c object to store entity data. If you Tag the class with [serializable] attribute you can then edit the POCO in the Unity editor. You can use this to build up a list of EnemyDefinitions, then at runtime build a dictionary from the list, dict<Id, enemy definition>, and you can look up enemy stats in the table in o(1) and set the Various values from the defition to your base enemy script
The poco can store all numbers and values, like ID of model and animations and all stats
I mean, you said you wanted to edit everything in one place. It has to be an SO or a database somewhere that your game reads to get the info. Not much else . . .
My technique is basically a crappy dB in a unity object
With the POCO as the rows
If you have a ton of stuff to store you could even in theory roll in an sql lite dB but you'd need pretty intense requirements to need that
I usually have an EnemyConfig SO and create many assets in the project folder for each type of enemy. Then I make a Database SO that holds a list and dictionary of those EnemyConfig SOs for easy access . . .
Yeah same result, different route
how do i get current playing animation length
Big old list of definition objects you do lookups against
guys is how to share my codes to github? last time i tried it didnt cuz it litrly uploaded the whole app file
and its too heavy
make sure you have the proper .gitignore
Hi, is there any way to solve this? I regenerated my files once and it solved it, but then I installed the Input package, and it note even the regenerate files does anything.
And I did select visual studio as my editor
public void ChangeFrame(int destPosition)
{
MMF_Position position = changeFrameFeel.GetFeedbackOfType<MMF_Position>();
RectTransform verticalLayoutRect = frameVerticalLayout.GetComponent<RectTransform>();
position.InitialPosition = new Vector3(-858, verticalLayoutRect.anchoredPosition.y, 0);
position.DestinationPosition = new Vector3(-858, destPosition, 0);
changeFrameFeel.PlayFeedbacks();
}
im trying to change the position of my RectTransform but for some reason its setting it to 0, 0, 0 anyone knows why?
im using Feels Feedback Asset but that shouldnt be relevant
!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
just work thru the steps again
Imma just reinstall all
I like vscode and I recently tot back into unity dev but I hate the way visual studio looks is the development experience in vscode that much worse than visual studio?
it's pretty good imo
Hmm then I might try it
a few stuff might be missing like alt+mouse to mark multiple lines
what i like is how quick it opens compared to vs(2022)
and autocomplete etc works just fine
I never realized how ugly the vs editor was until I used vscode and got a good theme and everything
Yeah that's my main problem with it
you can try both and then decide
And the editor itself and the font rendering looks a lot worse for some reason
or even try rider too while at it lol
i guess but that can be set probably? not sure
anyway just try

finally got back to profile and....
just unity being unity I guess
would try to profile a build
I'm not too concerned any more
alright
i've tried but with no success thanks anyways
yeah right now visual studio isnt working for me so im going to try out vscode
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
thanks
multicursor is definitely a thing in vsc
don't crosspost. you already created a thread in #1390346827005431951
didn't know that it's a rule not repost mb
Seems like the "Miscellaneous Files" problem only solves when I check one of the boxes here
what am i looking at🙏 😭
A screen capture of the profiler tool?
how do i make a camera move together with an object😭
or just how to move the camera
start here !learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
obligatory "Use Cinemachine "https://docs.unity3d.com/Packages/com.unity.cinemachine@3.1/manual/index.html
ty
guys, is it a chat to ask for help?
all channels are. find the relavant channel and !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
okay
was I stupid for making my own lerp function accidentally cause I was trying to figure out how to make a variable go between two points, but I didn't know that's exactly what lerp does?
It took me like 3 hours to figure out
😭
Lerp gets you a value that is some percent of the way between two other values
Ik. I'm not a native english speaker so I sometimes struggle with getting math related points across, since I learned them exclusively in finnish.
literally the first line on the docs tells you lol
ik 😭, I decided to go without google for the project. I probably should've pardoned the documentation from the rule though 😭 so I didn't know lerp was behind mathf.
lerp is just short for interpolation
linear interpolation to be exact
Yeah
yea cause you also have Slerp (spherical)
And I've used it in unreal before too so I probably should've expected it to also be a part of unity.
indeed, so many usecases for it
Prolly like a top 5 function
there is also one for colors which is cool to play around and mix
Color.Lerp
learning unity at the moment for the first time
and following this tutorial
🔴 Get bonus content by supporting Game Maker’s Toolkit - https://gamemakerstoolkit.com/support/ 🔴
Unity is an amazingly powerful game engine - but it can be hard to learn. Especially if you find tutorials hard to follow and prefer to learn by doing. If that sounds like you then this tutorial will get you acquainted with the basics - and...
at 24:29 he goes through this script to spawn in pipes (flappybird) and ive followed his exact script, but mine is getting an error?
let me show side by side
(the black one is mine, white one is his)
is there something i overlooked?
careful blindly copying
Also a missing semicolon
It means that compile errors need to be fixed.
what would compile errors be
like errors in microsoft studio
(i think it was called so)
Errors in your code.
They would be visible in visual studio if it's configured properly.
!ide
!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
basically the ones before you can hit play, if the code is incomplete/ has errors it can't finish putting them into the game
seems like it is #💻┃code-beginner message
ops wrong msg but yea lol
The same errors should also appear in the unity console log too
Probably somewhere above the errors in the screenshot
ahh okay !
omg now a brand new "error" is happening 😭
or more like
bug
code is working fine
but its not working correctly
let me take a screenshot wait
its spawning 5000 tubes at the same time but it should be like in the 2nd pic
heres my reedited script compared to his again:
your problem is with the timer update it should be
void Update()
{
timer += Time.deltaTime;
if (timer>= spawnRate )
{
spawnPipe();
timer = 0;
}
}
wait uh
not sure :/
what value did you put in the inspector?
spawnRate
if you didn't change it shouldn't it be 2 :?
they probably had it initialized it with 0
im just starting to learn unity (literally today) so im not sure 😭
fair not hating just curious
the inspector takes precedence over the value once its serialized (showing in the inspector) on a gameobject
the values in the initializer area (where you defined those variables there)
those are only used when the component is created (when you put a script on gameobject)
otherwise you'd have to reset the script or reattach it if you wanted the values to be like in the script (if not using inspector to change em)
not if they did:
- create script with variable unset
- created component
- saved
- added default
ah alright 😭 i kinda sorta understand
but with this tutorial im like.. barely understanding alot
it feels like im just copying off code
he does explain well but
it goes so fast i cant keep up 🥲
gonna try to complete it tho and see if it changes
pretty much its what you're doing. it might be easier to learn C# by itself first then start introducing some unity
learning multiple things at once is never easy
maybe this is why i found it easy to learn unity, had a class on java going at the same time which taught me the basics of coding
Am I missing something here about getters and setters?
public class Moves
{
public List<string> GetMoves { get { return m_LearnedMoves; } }
private List<string> m_LearnedMoves;
public void InternalTest()
{
Debug.Log($"m_LearnedMoves count is {m_LearnedMoves.Count.ToString()}");
}
}
public class Other
{
public Moves moves;
public void ExternalTest()
{
Debug.Log($"moves.m_LearnedMoves count is {m.GetMoves.Count.ToString()}");
}
}
Why does the internal method debug the correct count, but the external method debug 0?
Probably two different instances of the Moves class
Or running at different times when the count is different.
Your code sample is incomplete. We don't see how the instances are created or what calls the test methods
Was trying to simplify the code as there's a lot.
We also don't see where and when the list may be populated
Well you've simplified out the relevant context unfortunately
public class Warrior : MonoBehaviour
{
/*[HideInInspector]*/ [Sync][OnValueSynced(nameof(OnLevel))] public int level;
public HP hP { get; protected set; }
public Stats stats { get; private set; }
public Moves moves { get; private set; }
private void Awake()
{
motor = GetComponent<Motor>();
hP = GetComponent<HP>();
stats = GetComponent<Stats>();
moves = GetComponent<Moves>();
}
public void Init(int level, Vector3 spawnAreaCenter, float spawnAreaRadius)
{
this.level = level;
hP.Init(this);
stats.Init(this);
moves.Init();
SetupAI(spawnAreaCenter, spawnAreaRadius);
}
private void OnLevel(int oldLevel, int newLevel)
{
if(oldLevel == 0)
moves.Init();
else
moves.LevelUp(newLevel);
}
}
public class Moves : MonoBehaviour
{
public List<Move> GetMoves { get { return m_LearnedMoves; } }
[SerializeField] private List<Move> m_Moves;
private List<Move> m_LearnedMoves;
private CoherenceSync m_coherenceSync;
private Warrior m_warrior;
private void Awake()
{
m_coherenceSync = GetComponent<CoherenceSync>();
m_warrior = GetComponent<Warrior>();
}
private void Start()
{
m_LearnedMoves = new List<Move>();
}
public void Init()
{
if(m_LearnedMoves == null)
m_LearnedMoves = new List<Move>();
for(int i = 0; i < m_Moves.Count; i++)
{
if(m_warrior.level >= m_Moves[i].GetLevelLearned)
m_LearnedMoves.Add(m_Moves[i]);
}
if(SimulatorUtility.IsSimulator)
{
Debug.Log($"Simulator ran Init() and learnedmoves count is {m_LearnedMoves.Count.ToString()}");
}
}
public void LevelUp(int newLevel)
{
for(int i = 0; i < m_Moves.Count; i++)
{
if(newLevel == m_Moves[i].GetLevelLearned)
m_LearnedMoves.Add(m_Moves[i]);
}
}
}
public class Motor : CharacterMotor
{
[SerializeField] private float m_movementSpeed = 1.5f;
[SerializeField] private float m_runMultiplier = 2.0f;
private Warrior m_warrior;
protected override void Awake()
{
base.Awake();
m_warrior = GetComponent<Warrior>();
}
//THIS COMMAND IS SENT FROM THE CLIENT TO THE SIMULATOR
[Command] public void Cmd_UseMove(int index)
{
Debug.Log($"GetMoves.Count is {m_warrior.moves.GetMoves.Count.ToString()}");
Debug.Log($"index sent was {index.ToString()}");
if(m_warrior.moves.GetMoves.Count - 1 >= index)
{
//CanMove(false);
m_warrior.moves.UseMove(index);
}
else
Debug.Log("Server GetMoves.Count is not greater than the index sent.");
}
}
The debug in the Motor is always returning 0 for the count. Inside the Move Init() the count is correct.
I think it goes without saying, but, all classes exist on the same GameObject at instantiation.
hlsltools isnt working in visual studio, no idea why. c# highlighting and errors work just fine
i got a vague warning but its not really telling me a lot
The error means that the hlsl tools are built in into vs(as a component), yet you also installed an extension manually.
And Cmd_UseMove is called long after the Init methods.
yeah disabled extension and it works now nvm
its not highlighting nearly as much as would be preferable though
does it have syntax highlighting
no errors shown
It should. There might be an issue with include files though. Need to do some config files setup for that.
I have a Vector3 direction pointing at something outside of the camera view and I am trying to find the Vector3 position where the line intersects the edge of the screen. Whats the best method to do so / can someone give me bread crumbs?
Figured it out. Moves.Init is getting called and run before Moves.Start, and the Start method was resetting the Moves List.
I think that it has to do with GeometryUtility.CalculateFrustumPlanes but im not sure
Does anyone have a guide for Wheel Collider value callibration? I can't really seem to get any values that dont make the object wig out. The only time i can get it to not bounce like crazy it goes crazy when it finally rests on the ground, and when i can get it to not go crazy on the ground, it bounces like crazy
edit: to anyone who sees this message in the future, i based it off the "default" values for a 1500kg car and scaled. but for my purposes i had to change automatic tensor off
can anyone tell me why this is making my object move on axis other than z?
transform.position = Vector2.MoveTowards(transform.position, player.transform.position, 100000000);
Vector3 mousePos = (Vector2)cam.ScreenToWorldPoint(Input.mousePosition);
transform.LookAt(mousePos, transform.up);
transform.position += transform.up * GunHover;
You're setting your z position to 100000000 then adding some minor offset.
that's on purpose, it's so the gun slightly hovers.
Maybe rephrase your question.
