IEnumerator MoveMonsterJumpscare()
{
JumpscareSound.Play();
canvasGroupV.alpha = 1f;
while (Vector3.Distance(Monster.transform.position, TargetEndPos.transform.position) > 0.1f)
{
Monster.transform.position = Vector3.MoveTowards(Monster.transform.position, TargetEndPos.transform.position, monstermovespeed * Time.deltaTime);
yield return null;
}
}
#💻┃code-beginner
1 messages · Page 676 of 1
where it checks if the collider was the player
you could probably just use layers for this but that's a separate topic
still haven't gotten an answer for this though..
the trigger
should it not be on the canvas/vignette/whatever
so anything that needs to do the FadeOutVig doesn't need the extra script
that way it manages itself
so, what are u implying i should do
ok one sec
well
time.deltatime isnt freezing anymore
and everything else is working but the fadeout again..
again, debug values, next to where you use them
check deltaTime and elapsed within the coroutine, so you can also see if the coroutine stops prematurely
ok so
im as close as i can be
IEnumerator MoveMonsterJumpscare()
{
JumpscareSound.Play();
canvasGroupV.alpha = 1f;
while (Vector3.Distance(Monster.transform.position, TargetEndPos.transform.position) > 0.1f)
{
Monster.transform.position = Vector3.MoveTowards(Monster.transform.position, TargetEndPos.transform.position, monstermovespeed * Time.deltaTime);
yield return null;
}
yield return StartCoroutine(FadeVig(1f, 0f, 2f));
Destroy(Monster);
Destroy(Trigger);
}
ive done this
but it works
it just doesnt fade out
like it just disappears instantly
in 2 sec
i don't think you'd want to wait for the vignette to fade before destroying the trigger/monster
anyways, do some debugging then lol
`using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class Touching : MonoBehaviour
{
public string scene;
void OnCollisionEnter(Collision collidedwith)
{
if (collidedwith.gameObject.tag == "Player")
{
SceneManager.LoadScene(scene);
}
}
}
`
Does anybody know why this might not work?
The player has the Player tag and scene is set on the object
-# testing...
Are you getting any errors?
hmmm omg there might be a wall of embeds 😬
Attachments and embeds broken
• Impact: major
• Affected Components: API
Investigating (11 minutes ago)
We are investigating an issue with attachments and embeds not being rendered in the app.
from discord status
oh what it just worked?? i littererally didnt change a thing??
ahh thats what it was
use a Debug.Log inside the if statement
rite of passage
rubber duck
hey guys idk if this is right place to ask questions as a complete freshie to game development but where should I get started? I watched some yt vids and nothing seemed to help me understand anything or how to get started. sorry if this is the wrong channel to ask in
!learn and see pinned resources
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
is this how you learned and thanks
https://www.youtube.com/playlist?list=PLFt_AvWsXl0fnA91TcmkRyhhixX9CO3Lw this one did me the best justice
that's how i started, yeah
wasn't the only resource i used though
This would be the beginner programming channel btw
The appropriate future channel would be #💻┃unity-talk or whichever channel would fit the category #🔎┃find-a-channel
thanks idk if ill persue this if I cant figure out anything by the end of the day
No one becomes a professional in a day
-# if ur already moving forward with that mindset then game-dev probably isnt gonna be right for you anyway
now, if u enjoy puzzles, hard work, and learning how things work.. its great
never said I wanted to be pro by the end of today
- Is the Scene correctly named if you are trying to switch Scenes and the strings dont match.
- Is this script on a player or on a object with collider ?
as long as u stay in "pursuit" u'll be fine
oh.. thats them 👻 issues.. no one believes they exist
Should I use individual sprites (png images) or spriteatlases? I don't really get witch one to use
Functionally, they don't do anything differently. You use the sprite (either single or from the sheet) on your SpriteRenderer component.
The difference is that a sheet is considered one thing for performance consideration, and it just displays part of that sheet/texture to make it look like it's just one sprite.
So which you use is up to you. For things that are closely related to each, such as something with animations, you would use a sheet.
Tiles are also a common usecase for sheets, if they are all part of the same environment.
I use non pixel art images in my games. Should I pack my 6 characters in atlas or leave then separate png files?
Whether they are pixel art is 100% irrelevant to anything
So leaving them separate files won't effect performance?
Actually my game runs good on webgl in 7 years old chromebook so I guess I should not be worried 😄
It does affect performance in some way, everything does.
But if you're micro optimizing, you may as well just stop and continue doing as you're doing. There's no point stressing if it's not a problem.
It does affect performance but by today standard having multiple png or everything in 1 png it dosent matter honesly. We have hardware that can run that if this was 1960 then it would be diffrent story 😄
Also word of advice dont worry about performance at the very start of the project. Make something first and then try to fix it so it runs better.
Ok, thanks! One more question. When I place my 400×400 image into a Sprite Renderer, it appears as 391×396. Why does this happen? I made all the png divisible by 4 in photoshop. Does this effect something?
I also cropped the transparent pixels around a PNG before importing it into Unity. Is it ok?
I think the second sentence explains the first
My original image from photoshop. Second one what spriterender uses. it destroys the divisible by 4
Does it matter?
to be able to use DXT or ETC it needs to be a pow2 size
so 512 is the closest to 400~
But why does my sprite go from 400x564 to 393x550
when it's in the sprite renderer
it destroys the divisible by 4
Whats this object called in scripting and which namespace is it?
TMP_Text in namespace TMPro
Thanks!
for ugui its actually TextMeshProUGUI https://docs.unity3d.com/Packages/com.unity.textmeshpro@4.0/api/TMPro.TextMeshProUGUI.html
Works as well, the UGUI is a derived class of TMP_Text
So if you ever change to a 3d text, use the base TMP_Text
if writing ugui code its very unlikelly
I do lots of ugui code so im very used to writing this
Both work so whatever
👍
Could someone ples help me why doesnt this attribute doesnt worky?
Never heard of that one. Use [HideInInspector]
are you looking for [HideInInspector] ?
Probably yes, thank you
[NonSerialized] works too assuming you're not changing the value beyond the default in the inspector
its part of UnityEngine.Properties
https://docs.unity3d.com/Packages/com.unity.properties@1.0/api/Unity.Properties.DontCreatePropertyAttribute.html
Ah, I'm assuming that just applies to all instances then
btw much cleaner to usually use a private field and a public access property
Whats a public access property?
Like a public getter?
ima google one sec
Ah, true but I do need to use it in other files
Oh wait internal exists
Thx
ohh why is it public at all
public bool CurrentlyUp { get; set; } = false```
Prevents it from serializing too
Idk cuz ima a dumbass, and I need to use it from other MonoBehavs, so I thought using a hidden public would be smart
🤷
private bool myBool;
public bool MyBool
{
get { return myBool; }
}```
or
```cs
public bool MyBool=> myBool;
this wont show in inspector and a cleaner pattern
I already made it internal, but still thanks!
ok why does text mesh pro look different what did i do
what nav showed is the better option. the property can be internal as well if you actually need it to be internal instead of public. but exposing fields to other objects should almost always be done through a property
your inspector is in debug mode
also not a code question
Do I really need to mess around with backers
meow
But alr
I can expose it in a wrapper ill soon do
Actually yeah ill do that
cuz nono wanna backing fields
can you finish a thought before sending a message instead of spamming one thought across 7 messages
#📖┃code-of-conduct
Will do
Will the standart constructor of a component run when creating a gameobject with a said constructor?
the parameterless constructor will be called, yes. but you really shouldn't be using that unless you have a good reason for why you would be. just use Awake instead for 99% of cases
Oh yeah Awake exists, I literally forgot, thanks
hey!! dont post here usually but looking for some advice regarding exporting data to text files :)
excuse the absolute mess of the code - im trying to just get it working 😭, im wondering how id go about storing these lists as a text file (to be imported / exported to other players), specifically the "listofpositions", "list of rotations" and "timestamp". Ideally these values would be read at runtime too in order to simulate a "ghost".
Lmk if any more context is needed :)
exporting data to text files
look into json serialization. unity has JsonUtility built in which can handle that data easily
yeah ive looked into JSONs - just really struggled to get them working / wrap my head around them. Documentation seems pretty complex and im not finding any solid tutorials for them. Could just be looking in the complete wrong place though
well if you need help with it then you'll need to show what you actually tried
truth be told everything ive tried has ended up in deleted code 😭 , do you know of any recourses that explain them in a more simple manner?? would be really helpful
back to google it is then, thanks anyway :)
Is there any way to Monobehaviour:Invoke() a method and give args to it?
Except storing them externally
no. if you need to delay a method call you can use a coroutine instead, the coroutine can accept an Action as a parameter and the time so you can reuse it for any method call delays
Ah, thx
Hey
Trying to increase a variable from OnCollisionEnter2D, but it keeps getting set back to its default value every time it runs
Show !code
Posting 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.
show the relevant code, but if i had to guess i'd assume you're probably modifying a variable on an object being destroyed rather than keeping a single source of truth for that value
public class BirdController : MonoBehaviour
{
private GameObject birdObject;
private Rigidbody2D _rb2d;
private float moveSpeed = 6f;
private float _maxTIme = 3f;
private float _Timer;
public GameObject _PipePrefab;
private Vector2 _PipeSpawnPos = new Vector2(0, 0);
public float HighScore;
//public float CurrentScore;
public float score;
public GameObject _scoreText;
void Start()
{
birdObject = gameObject;
_rb2d = birdObject.GetComponent<Rigidbody2D>();
HighScore = PlayerPrefs.GetFloat("HighScore", 0f);
//CurrentScore = PlayerPrefs.GetFloat("CurrentScore", 0f);
}
void FixedUpdate()
{
if (_Timer > _maxTIme)
{
SpawnPipe();
_Timer = 0;
}
_Timer += Time.deltaTime;
}
public void OnFlap()
{
_rb2d.linearVelocityY = 1 * moveSpeed;
}
public void SpawnPipe()
{
GameObject ClonedPipe = Instantiate(_PipePrefab, _PipeSpawnPos + new Vector2(15, Random.Range(-2, 2)), Quaternion.identity);
Destroy(ClonedPipe, 8f);
}
void OnCollisionEnter2D(Collision2D collision)
{
//if the bird hits a pipe
if (collision.gameObject.tag == "Pipe")
{
Debug.Log("bird hit pipe");
}
//if the bird passes the enters a pipes border
if (collision.gameObject.tag == "PipeBorder")
{
Debug.Log("bird passed pipe");
//increase current score by 1 when player passes a pipe
score += 1;
_scoreText.GetComponent<TextMeshProUGUI>().text = score.ToString();
Debug.Log(score);
//if the current score is greater than the high score, save the current score to the high score save
if (score >= HighScore)
{
PlayerPrefs.SetFloat("HighScore", score);
}
}
}
}
making flappy bird
been trying all sorts of stuff but I have no Idea whats wrong
Okay and what is the thing that's happening that's not what you expect
I want the score to increase whenever the player passes through a pipes border (gap between the two pipes), however the score isnt being increased at all, everytime it runs i just see 1 in the console.
Are you accessing/changing score from another script? It's a public variable, so it's possible.
Are you getting the log bird passed pipe?
How about logging score?
No, only in this script is score mentioned
The gerund form of the word log
which you already seem to know the meaning of since that was my previous question
yeah Ive been logging score, and its 1 every time
How many objects is this script on
How many times does it trigger on each Play?
just once when the player passes by a border
Try making score private. Do you get any compile errors right away?
You do know variables reset on each Play right? I think this is the issue
"Play" as in starting the game not on each trigger of the function
Wouldn't that be a trigger collider?
Trigger colliders would be using OnTriggerEnter2D
Not OnCollisionEnter2D
Well I have the border set to IsTrigger so the player can pass through it, and with OnCollisionEnter2D on the bird it'll detect whatever it collides with, in this case the pipe border. Im using tags to tell the pipes border and the pipes themselves apart
its working pretty well besides my issue with the variable
You need to double check that because OnCollisionEnter2D will definitely not run for a trigger
something is fishy about your story here
Just deleted an old script from the pipe border before I decided to make the logic on the bird script.
think that may have been apart of the problem
When you're cleaning things up, you should probably switch all of your score stuff from floats to ints. This way will work, but you'll be doing string formatting and other crap you don't need to waste time on.
Okay so I've managed to fix it by making the bird IsTrigger and swapping OnCollisionEnter2d with OnTrigger, and I think the variable was being affected by the remaining c# float score; I had on an older script.
well but now the bird doesnt collide against the pipes.
The pipes should be solid colliders
The space between them should be triggers
Bird - has rigidbody, has collider, not Is Trigger
Pipe - has collider, not Is Trigger
Pipe Pass Through - has collider, Is Trigger
Then have an OnTrigger method for passing through the pipes and an OnCollisionEnter2D method for hitting the pipes.
I'd ask in #↕️┃editor-extensions
I dont know about that attribute but sounds useful if it exists
bruh i just thought i found it lol
It does use the first string field in the class as the name though
Iirc
yeee, just for this i dont have any
i dont mind worstcase but wouldnt mind avoiding if i can
Its a hack anyway yeah but its the only way I know apart from custom property drawers
https://docs.unity3d.com/6000.1/Documentation/ScriptReference/InspectorNameAttribute.html
applyToCollection Makes attribute affect collections instead of their items.
this should be it, the docs do say it's for naming enums in the inspector but the doc page for that property does show it being used for an int array
ah wait, nevermind the page for that property is being used for the base class so that's probably not it
if such an attribute does exist then it does not appear in the list of attributes in the docs
are you certain it wasn't from a package/asset?
I think I saw that and just was yet to test it
exact thought process i had LMAO
yeah seems to be the case
also apparently this is what you get if you try to serialize an empty struct lol
we can use return; to go in situation like this
if (something == true) { do something return; }
but is there any other uses for it?
return; is used to exit early from a method that returns void, that's it
i see people say it returns a value...?
you can return an object, yes. but not by just typing return;
you need to actually specify what you return. but that wasn't your question, your question was about return;
how would i know what to ask if i don't know that thing
how would i know what you are actually asking about if you don't actually ask about that thing?
your question specifically used return; and the example included was about returning early. if you wanted to know all of the uses of the return keyword then ask that next time
never mind it
if (!something){
return;
// else do something
}```
early returns i think are useful
can use it for guard clauses too
I'm not sure why this is giving an error
public bool Test(GameObject _enemy, int enemyWalkRange, int enemyAtkRange)
{
for(int i = 0; i < 49; i++)
{
if(Mathf.Abs(Vector2.Distance(_enemy.transform.position, _tileData._tileArray[i].transform.position)) <= enemyWalkRange)//sees if enemy can walk to that position
{
for(int j = 0; j < _tileData._playerUsingTile.Length; j++)
if (Mathf.Abs(Vector2.Distance(_tileData._tileArray[i].transform.position, _tileData._playerUsingTile[j])) <= enemyAtkRange)//checks if valid attack
{
return true;
}
}
}
}```
the first would be due to where you call this method. the second is because not all paths return a value. you only return anything in that inner if statement. what happens if that is not true?
also kinda unrelated but should i use Mathf.Approximately to avoid float problems or does Mathf.Abs already do that for me
If you're comparing floating point values, yes you should use the approximate function. Vector3 auto implements this when comparing Vectors.
Mathf.Abs(Vector2.Distance(_enemy.transform.position, _tileData._tileArray[i].transform.position)) is returning a value over three hundred when the 2 GameObjects are 1 away
you don't need to Abs the distance, the distance is always positive
but you should log some info to make sure you are checking the position of the correct object(s)
So I invented a data structure I am calling a Fan -- as in a peacock fanning it's display
I just checked but that doesnt seem to be the problem
show the current code, both objects involved in the check, and how you've confirmed you are getting the position of the correct objects
(please forget i said anything)
I am trying to access the Tracking Target field through scripting by
private Transform player;
private void Awake() {
player = GameObject.FindGameObjectWithTag("Player").transform;
TPP_cam_settings.Target = player;
}
and the error that i am getting is Cannot implicitly convert type 'UnityEngine.Transform' to 'Unity.Cinemachine.CameraTarget
How can i set the tracking target during runtime?
the Target property is a CameraTarget
yes, this solved my case
player = GameObject.FindGameObjectWithTag("Player").transform;
TPP_cam_settings.Target = new CameraTarget{TrackingTarget = player};
}```
Thanks for the reply. Could you explain why I had to use the {} for defining a new camera target? isnt it the same as
Vector3 targetPos = new Vector3(x, y, z)
it is not the same, that is object initialization syntax because the CameraTarget struct does not define a parameterized constructor. you could have alternatively done this:
var target = new CameraTarget();
target.TrackingTarget = player;
TPP_cam_settings.Target = target;
another option would have been to just copy the current value in the Target property, assign the TrackingTarget field on that copy, then assign the copy back to the property (assuming Target is a property and not a field. if it is a field then you could just directly assign its TrackingTarget field without making a copy)
so is this the same as creating a new instance of the Camera Target class?
yes, but it's not exactly the same as invoking a constructor with arguments
the syntax you have is basically the same as the example code I wrote, it's just done inline
here's the docs page if you want to read more about that syntax https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/object-and-collection-initializers#object-initializers
thank you
the hell json is so slow, i stored 50mb ish base64 in it and it takes like 15 seconds to parse and with string split its under second
50mb of text is pretty big, no?
no 50mb of pcm for audioclip
i thought it turns into class like structure right away but it appears it scans through strings live time
i mean it is a big string at the end of the day
are you aware of how large of a file 50mb is? anyone here could've told you json would be slow on this
if you can process it directly using string.split, then it doesnt make sense why you were using json in the first place considering that wouldnt be a valid json format.
because im limited to 1 string and holding it inside json would be much easier to manage than glue some base64 outside of it
limited to 1 string
an entire file can be seen as one string. this really doesnt make sense either way.
as for the rest of that sentence, really none of that makes sense either but 🤷♂️ we have no context as to what you're doing here as usual
just i remember lot of people were saying that string split is bad and to not use it
meanwhile json is even worse
i havent seen the context of who said this or why they said it but i can firmly say you have a big misunderstanding. you cannot compare a json parser and string.split in any world.
string.split works exactly how it should. if you need to process a string and split it by a certain character every time then .Split is made for this. This takes a string and gives you an array
Json is a format and to simplify you can use it to parse a file to get structured data back. this might represent an instance of a class
you were more likely told that its bad because you shouldnt have been using strings in the first place, since we've seen you use it for pretty much every feature.
possible
a json framework is doing way way more than searching for a character and creating an array based on it so yea itll be slower. if your 50mb file can simply be read by string.split, and all you need to do is store this in an array then by all means do that.
If suddenly you need to do more like process data on each line of the file, you'll notice your code will also slow down
i might be wrong here but a 50mb file should be 50 million characters.
i do need to do that as well, just json is good for small things but not big, so i stick them together and later separate with split so i can still run my json
i could do everything with split but then i would clog up my ram by splitting 50mb string 10 times
Why the fuck are you working with a 50mb string in the first place
eh going offtopic again
If I have two tri’s (two sets of 3 world space positions) is there any suggested way on checking if they intersect?
I think thats a very googleable question.
two be honest the results i got where either not related to my question or stackoverflow posts full of fairly math heavy responses where people disgree with eachother
i didn't do high school so maybe the math is more simple than i think but i did look around
math is surely fastest solution but if you dont know it then just check if meshcolliders colliding
i dont have meshcolliders in this context
Well a simply solution would be to check if each point of a triangle is inside the other one. This has the literal edge case of failing if a point lies exactly on an edge of a triangle. For more precision you can implement the Separating Axis theorem
i see, i'll google that but i don't actually know how to do that which probably explains why im not sure how to approach it 😄
Hey folks, I'm having a small issue with the flappy bird game I'm trying to recreate. I'm using time.timeScale = 0 to stop the game on gameover, and reset position after. But for some reason the bird seems to keep momentum, so if I hit gameover on a pipe it's okay, but if I let it fall repeatedly it accelerate and it becomes unplayable
Any idea what's happening ?
What you're trying to do is called "triangle-triangle intersection algorithm" so searching with that term should give results
you need more logic for what should happen during this reset, like resetting its velocity and maybe even rotation.
we dont have context as to how you're moving this object though
How do I reset velocity ?
I have a very basic :
`void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
playerMovement = Vector3.up * FORCE;
}
playerMovement.y += GRAVITY * Time.deltaTime;
transform.position += playerMovement * Time.deltaTime;
}`
playerMovement.y = 0
That did the trick, it was that simple thanks
Now I can work on progressive difficulty 👍
!collab (in reply to the now deleted message)
: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
but you do need to !learn to code if you want to make a game, there's no going around that.
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
@exotic laurel ^^
Hi, thank you, i completed the pathways for beginners, that is why i made some progress in my 'game' but i am not hidding that i use ai for coding. Anyway, thanks
Keep in mind that copy/pasting LLM answers is not learning. You need to make an effort to understand the material and apply the knowledge yourself to learn.
I agree, that is why i participate in the unity pathways and follow some YT tutorials too! but i guess i am to excited and eager to do my own project that i cant help myself and use ai to speed things up! And now im stuck, so i guess it backfired heh. thanks again
Looking up answers in the manual you get a lot more information than getting a digested word salad.
any particular manual you have in mind?
i appologise if i misunderstood, english is my second language
The Unity manual. The answers you get from when you use search engine.
Thank you kind sir!
Hey, I'm making a system for storing all available characters in my game and all their associated stats etc, I want to be able to access it across scenes so I can update for example if a character dies in a fight. I was looking at SO's or a list in a monobehavior attached to a instanced don't destroy on load gameobject but I was wondering what's the better approach? Or if there's a better way to do it I'd love to hear, thanks!
sounds fine yeah, personally as someone who probably overuses so's i'd maybe even have some sort of ScriptableManifest type thing that holds the list of characters on that so, and have it referenced in a core manager that relates to its usage
Sorry could you explain what you mean by ScriptableManifest type thing?
basically just a SO that holds that list of SO's
suggestion more out of preference than superiority but i find the list of available characters itself also feels more like a job for an SO asset than on some prefab somewhere
Sweet thanks, I'll give that a go 🙂
!code
Posting 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.
Hello, I got this error with nothing else and I dont know where it's from . Does someone know what did I do?
Parser Failure at line 2: Expected closing '}'
I went to see any unclosed brackets, but all of them were closed, on all the scripts, idk what to say
you didn't ask a question, and this is a code channel.. so if it's not code related, delete from here and actually ask in #💻┃unity-talk
got it
do you know anything at my question carwash?
you have a missing bracket, even though you think you don't
i checked every single bracket of every single script, i cant find any missing bracket
At a guess.. your IDE isn't setup correctly to show you errors within it, and you're seeing that error in Unity console?
indeed
💡 IDE Configuration
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
aint working
^ get your IDE setup correctly
it supposed to led me to problem, but it doenst
its just an error and Idont have a line, it doesnt led me anywhere
care to share screenshots
haha, I've just opened Unity and look
is not ledding me anywher
I could not care any less about it
I'm also not on the latest version of 6, so it may not be present anymore anyway and I'm not updating to find out
indeed, so it shouldnt disturb us?
and if so, is it a channel to report a problem like this?
idk, where some admin will look?
in the editor help -> report bug, same as every other bug you need to report
There is no reporting issues on here, it would be a nightmare to organise and track.
i mean yeah, but this thing appeard to me yesterday so its something that they did recently
so it wouldnt be that hard to track
ig
and its something on the using System.Collections.Generic;
you misunderstand what I mean by track
🪲 To make bug reporting as quickly as possible, we made a bug reporting application for you. When running Unity choose Help->Report a Bug in the menu, or you can access it directly through the executable in the directory where Unity is installed. It will also launch automatically if you experience a crash.
📝 If your bug report is to do with Documentation, either an error, typo, or omission, you can report it by scrolling to the bottom of the page where you found the issue and click ‘Report a problem on this page’!
💡If your report is to do with a new feature idea, you can check the Unity Product Roadmaps page to see if your idea has already been planned.
For more complete instructions on how to report bugs, access: https://unity3d.com/unity/qa/bug-reporting
guys help, how do i bake a navmesh
i cant find the bake tab or object tab like it says in the learn.unity site
ok i found it
Good afternoon, I am having trouble with grabbing something via a tag. Everything else is grabbed fine, but this one thing just does not want to work. Any help is much appreciated.
Do a debug log to print this take it finds. If it's null or false, then it can't find it
Also avoid using the ?. operator with unity objects (gameobject, components, scriptableobject)
also give more details about how exactly it's not working
what do you recommend instead? I found the issue, it was a stupid one but one I thought I had changed. The gameobject was inside of a parent object which was false at the start and therefore it could not be found.
?. just doesn't work as you might expect with unity objects, there's no direct replacement
you have to do if (someGameObject == null) - unity doesn't override the ? operator so you can occasionally end up with the underlying C++ object being destroyed but the C# object being alive, or vice versa, can never remember which way around it is 😂
ah, seems to be working for my usecase so I am not going to touch it lol/
you should touch it
it's gonna cause issues later
for unity objects, == null and is null are different
you almost always want == null
but ?. uses is null
get rid of it now and either:
- let it fail-fast if this is something that should always be available (you get an error that you can see)
- handle it properly with
== nullif this is something that may or may not be available
What is console pro?
a third party console
hello i have made a vfx that sends a slash, now my problem is what should i do to make it usable as an ability and affect some damage if it touches an enemy for example i want to make a hit area like that image shows. if any professional in that field could guide me a little i will appreciate it
use some sort of cast
Use a physics query
a ray cast maybe?
a ray could work but might be too thin
yeah
Does anyone know where is that? I have no idea in which channel should I ask for help so I am asking here.
they have basic shapes like Spherecast, Boxcast, etc.
Alright but like what does the error mean?
i was thinking to use a collider on the slash it self
Parameters don't magically exist
it means you're trying to use an animator parameter called LastY trhat doesn't exist in your animator state machine
in the animator state machine
it's a warning not an error. and it means that your animator controller does not have those parameters
Oh alright thank you
You could do that too sure, you'd need at least 1 ridigbody between the two colliders to call the function
yeah
Unity doesn't have a built in mesh type of cast for Physics class but you can also use this
https://docs.unity3d.com/ScriptReference/Rigidbody.SweepTest.html
but you mind as well just use TirggerEnter / TriggerStay anyway...
Could anyone please tell me where is in this script anything about "LastX or LastY" like wth...
I only have for X and Y
that may work
It doesn't. But are you sure your code has been saved/compiled recently?
you still didnt configure your IDE...
😭 No way
yep, not saved
yes I know and I am sorry
Alright warning is gone.
Thanks for help.
get it configured 👇 !IDE
💡 IDE Configuration
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
which one
surely you can use your eyes and logical reasoning to figure out which link you need to click
and they been told already few times which, but somehow have amnesia now
How does this make sense? How can my capsule of height 1.9, be at rest on the floor of (0,0,0) and have a center of (0, 0.50, 0)? Should it not be (0, 0.95, 0). For reference I am using capsuleCollider.transform.position.y
you probably want the pivot of your player at the center of the feet instead. this should be the case when you import
It is in blender, do you know if there is an import setting for this? I'll do some research on it.
Or can it be changed in unity?
looking good here but it seems like it has not been applied
i wouldnt use the collision/trigger messages here tbh. you can probably generalize the area in that 2nd screenshot to a box cast as it moves along its path. I doubt you'll have any cases where that the upper corners of the box hit a target when visually the arc didnt.
the first image maybe use a spherecast and then filter out results by checking the angle.
i mean by the first image i just want to make an ability indicator for my ground slash, and yeah i can use a box cast for the slash but i want to damage only when the actual slash touches the person not the all the line
you would cast in small amounts as it moves, or use like OverlapBox at all times and see if anything is within it. not just once on ability cast
as for the ability indicator im not entirely sure how those can be recreated. I'd imagine its really all just a mesh and custom shader
i have found some informations about the indicator it is just an image xd
on the canvas
i will try that
interesting, guess that makes more sense
i have found some tutorials in youtube if you want to check
if interested
i googled and saw a few tutorials exist but dont really have time to check it out now
thanks though
Why is my floor saying it's y position is at 0, yet when I move it down by -0.5, all game objects appear to be at the position they should be? Its like they have a different world transform???
I think the issue was in unity but I don't know how this is occuring?
nah it is something on your side. in blender your pivot point looks right.
but anyways, it seems like it is fixed now
I am making a survival game and i added the ability to mine stuff like stone, but this is happening
!code
Posting 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 my function for mining
A tool for sharing your source code with the world!
does anyone know a fix
the best course of action here is to start debugging it
print out the hit point, print out which tile pos that's being converted to. See what's going wrong there. DOuble check your raycast as well
i did and the best thing i was able to do was add that if statement
i removed them
you should be printing all the relevant info - and drawing things with gizmos, until you find what is off
You should be adding logs at this point, not removing them
nobody is going to be able to just eyeball this code and tell you the issue offhand
alr
how is the mining supposed to work? A raycast from the player to the mouse and it destroys whatever block is hit?
I would expect subtracting half a grid unit in opposite direction of the normal before converting to tile coords though
not converting to tile coords and then subtracting a whole unit
Hi all, would anyone know of a tutorial/guide (ideally video) for creating a quadtree for a simple plane object? All of the ones I've found and tried to follow are heavily interwined with other code etc. and I'm finding it all very confusing. 😕
if I'm tweaking something like the perameters of some physics objects to get a good feel, e.g. tweaking and working while running, how can I make those changes stick once the simulation stops? The best thing I've been able to figure out so far is just screenshotting the settings before I end the sim
You mean playing in the editor? Or saving things in the game itself.
For in the editor, you can right click on a component tab to copy the values, then you can paste them (By right clicking again).
There are also assets that let you save multiple things in play mode, I personally don’t remember the name though
ah, thank you!
when the error 'Object reference not set to an instance of an object' occures when a 2D body collides with a 2D collision object, and i'm trying to make it so a death screen appears, would it be that the interaction between the body and the object has an error or that the object to death screen has an error?
i'm not getting the debug message for when death screen is happening, so it seems like it's before that happens but after a collision happens
it means something in your code is trying to use an object that is null
https://unity.huh.how/runtime-exceptions/nullreferenceexception
without knowing what the code looks like or even where the error occurs, this is all anyone here could possibly know about your issue
private void OnCollisionEnter2D(Collision2D collision)
{
Debug.Log("pipe hit");
logic.gameOver();
}
(probably not enough to go off of but heres this anyways)
if that's where the error is pointing you, then logic is probably null?
might be inside gameOver, check the actual stacktrace
also see below for posting !code
Posting 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.
now that i think about it, it probably is logic
aghh
when calling for a deathscreen activation, what else can i use you think?
why not just fix the error instead of trying to bypass it by doing something else?
i have no context on what your code architecture currently is, i cannot possibly answer that lmao
you've come to the conclusion that the logic variable contains 'null' so make it contain a reference to the correct object instead
how can I tweak the accelleration curve of an object?
I'm using addForce and a custom function to add drag, and those two combined give me an okay top speed and stopping speed, but I'd like to tweak the rate at which I reach top speed and I can't find any resources that specifically cover this
you would have to vary the amount you AddForce by according to that curve, or manage acceleration/velocity yourself altogether
How would I do that according to a curve? Or can you reccomend a specific tutorial for that kind of implementation of a curve?
thank you! so it turns out i was missing a chunk of code from another script that told me that Logic was meant to look for an unattached script at the start of the game
-# do you need it to be a curve though
you'd probably achieve it with some function of acceleration over time, and sample the function at [time elapsed since started pressing run]
that being, one i had already made for a different object that didn't exist at the beginning of the script either
actually pretty proud of myself for understanding that one
I probably dont need it to be a curve, I probably just need to find the right way to shove math into it...
currently testing out reducing the forward drag by a scalable number the higher the current velocity is, that might give me the control I need
perhaps check out this - https://gmtk.itch.io/platformer-toolkit
Hey! I have a question - How can I learn to code in Unity without relying on memorizing every line? After watching tutorials, I try to write scripts on my own, but I keep forgetting the exact syntax or what to type
you gotta remember the syntax and slowly learn a lot of the function names but that doesnt mean remembering every line
you aren't supposed to memorize lines of code, you're supposed to understand them and then write your own
(in general) there's 3 major parts to programming:
- Language - The syntax, structure, and paradigm of each language
- Library - The interfaces and utilities that each environment or toolset provides
- Logic - The algorithms to do work at runtime
Logic is almost completely transferrable between each language and environment, you just have to learn the specific Language and Library that you're using
Language is also shared quite a bit between languagesof course, learning 1 part at a time is easier than learning everything at once, which is why tools like scratch or code.org are popular as coding courses for beginners, especially kids, because it only focuses on the Logic aspect
Ohhh I see, this makes way more sense. I didn't know about these 3. I appreciate that 🤝
the core of "learning to code" is the logic - the language and library aspects can be looked up
there are other skills (knowing where to find info, what to search, terminology, reading docs, etc) that help with looking up syntax or method names - none of us remember everything single thing we use
but the most common parts of language/library, in this case methods, conditionals, loops, GameObject and Component methods, unity messages, those you will get better at remembering as you write more code, akin to muscle memory
Gotcha, yeah. I understand now
ultimately the skills you need to practice are problem solving (the logic aspect) and finding and understanding technical information (c#/unity docs)
the rest you'll pick up along the way as you get more experience
Yup, that sounds awesome. Thanks
is there any good way to align animation with audioclip time or should i do it manually in code
there are several ways to achieve this, which one fits probably depends on what exactly those clips are
you could use animation events if the audio accompanies the animation, for example
or use a timeline to sequence them together
or you could trigger them both at the same time in code
Im brand new to game development. Could someone help me with my camera system. In the game when you press WASD, the camera moves to the direction in which you turn in. Could someone give me a basic run down on what to do in my situation
i opened the language, got scared. and joined the discord server bc theres no shot im doing this all on my own
realistically no one is going to be coding this for you
i didnt ask for that. i simply wanna know a basic run down. and do it on my own
i mean, how would i learn if i didnt do it on my own
you follow a structured course like ones on !learn 👇
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
start small, build your way up to more complicated game
this is what tutorials are for. you should also definitely learn c# basics before trying any of this. there are pins in the channel like "intro to c#"
i have to
listen. ive searched, and searched, and searched. ofc the only thing i wanna do isnt public information apperently
its very much public information
being hyperbolic
development is about breaking down larger problems into smaller ones, you might have searched too specific
you don't learn how to drive from your local mcdonalds to your local chemist right?
you learn how to drive
its just. for how simple my game is, i woudnt think id have to "get my feet on the ground" type thing
ok ok
no game is simple
shiiii ur right
im also a 1 hit wonder so. yyyeeeah
i wanna do this one thing and never do it again
your learning an entirely new language here that slaps your fingers with a ruler and tells you to go home if you pronounce something wrong. you gotta learn from the start
ok ok, noted
so why not make it my best work
you want to make a game just to get rich somehow then never make one again ? sounds unrealistic
wtf hell nah
i wanna make a passion project and call it a day
if you want to call it your best because its your only work, then sure it is technically your best. I can absolutely guarantee you will be writing some horrible code.
your best work is never your first thing
work on it for a few months or smth
well, its techically my last as well so, 50% credit
nah dude my code is gonna be AAAAASSS
but hey my game works. sorta
yeah im not satisfied with that nvm
i mean, im willing to stay up for days on end just to get this done so i can rest knowing my idea is finally alive
if you want to realistically make a project in a few months from knowing nothing, then dont start by immediately making the foundation of your project. Go practice basic c#, learn the basics of how the engine works.
and then yes break down your problems into smaller manageable chunks. You dont google "how to move using ABCD keys". You research how to move, then research how to check for the input you want, then combine the two
oooooh ok ok
days is nothing here. you will most likely be wasting weeks especially if you have a bad foundation of code. you'll spend more time rewriting than anything else
i say this to a lot of people. you cannot willpower your way through making a game, thats not how it works
so even if its excessive? the breaking down part. orr does it get to a point
ok
taking notes
and here i was thinking my little room with camera movement would be simple and easy. damn
break it down as far as you want. you'll know when its excessive if you're starting to break it down to "how to add"
there are premade controllers you can plop in if you just want to move around, but you still need some basics of the editor
im not saying i wont make games. but i just cant see myself willfully crafting something for weeks just for it to not work properly in the end
idk
its like a gamble, for my time
like if i really wanna do this who knows it just might not work at all
find a hobby that you actually enjoy sinking hours into
or i lose this spark of energy and give up all together
oh i already do
if your only goal is a camera moving around a room then sure thats feasible, i wouldnt call it a game. If you're talking about anything with actual gameplay then change that weeks into years
especially if you dont know c#
well, as you said break shi down. this is just the very very very basic form of my game
and then the next day. work on the walking animations type shi, and then the next. creature animations, so on and so on
im solo, and im aware of the complications that holds
then weeks isnt feasible at all
holy shit
id give myself 8 months maximum
anything above that, why work on it
i mean, the person who made my favorite fan game deleted his 3-4 years of work in 5 hours.
well, just to fix stuff from the constant lash out form the players due to how difficult it was, but still that had to make the dev feel a certain way
hats off to those individuals but in my case. i dont see how making something so simple in mind could take possible years, it could be you dont know my standards but still
im not abt to make the newest Ray tracing software only playable through a certain graphics card, i just want a shitty fnaf 4 remake with movement and a 3D environment with my own creatures.
ive had this idea since childhood, and now that im older, making it a thing would be fire asf.
but i do have a few standards i wanna meet for myself, and how knows if i learn it and wanna add more
animation isnt too hard, ik how to do that. pretty well actually, but that isnt gonna cut the rest of the 98% of my project
my main main question (my friend asked me to ask)
if i were to make a game. camera movement, movement to doorways, and animations leading outside the doorways, creature AI,
and modeling as a solo dev with no experience, how long would you say it would take
depends on what you're trying to exactly make. obviously it wont take a full year of everyday hard work to make camera movement and characters use animations. if I had models and animations already, it's really a 1 hour setup to get something prototyped.
the difference for you is that you need to actually learn c# and unity. lets say you write some script which helps you play animations per character. In the future, you realize this script doesnt suit your needs because you hardcoded all the strings. Suddenly you got to rewrite it. Anything referencing this script might also need an update. It takes awhile because you need to learn and will likely have to redo lots.
it doesnt really matter if the overall game is silly or simple. the code has to work at the end
from learning all the way up to finishing the DEMO not the full game
reading this rn
If you don't know how to do these things how can you confidently assume how long they will take
daaamn ok ok
building a game is simple..
the hard part is finishing it..
and having a full game-loop
well, someone told me to learn what i needed for my project and branch off. does that work?
it just isn't though
no one can answer that question for you. (my answer above also partly addresses this) but stuff like "creature AI" can mean anything. An AI could mean it follows you. An AI could means dark souls npcs or the worlds strongest chess engine.
everything other than the game is writen down and ready to be made, i got everything other than the experience with programming that it
writing the stuff down is the easiest part tbh
the last 20% takes 80% of the time
sorry sorry i understand lmao, i just wanted a refrense point till if i DID actually finish a demo
mhm, mhm
thats clear as day
it really was
the thing is, the enviorment is my own ROOM, so recreating it shouldnt be that hard?..
well. i gotta make 3 more rooms.
for, for the movement.
do you know how to model
yeeeah im starting to see wtf is happening
basic understanding
asset packs
planes
...materials
i can animate a model
(planes are the only one out of those three that are actually modeling but fair response)
i mean
i made a chair so
yay?.
to think ur not even close to finishing it. damn.
also noted
by the end of it all, ur a modeller, a graphics artist, a programmer, a music engineer, and the list goes on
ok so for me. animation, music, sound effects, i can do that, programming, and MAYBE some modeling i gotta learn
The real trick is that solo devving is fake and games are collaborative 😄
i dont see modeling being too hard unless im shooting for the stars
well thats half the battle.. i think ur in good shape 🍀
but if i can turn a cat into a humanoid figure then thats all the modeling i need
not soo hard.. as it is time consuming
right right
ur aura gives me hope
but it also depends on whether ur a perfectionist, or just wanna get something done and out the door
it could be less i suppose
hell ya mate.. u got this
i will not stand for it unless it is perfect
perfection sucks
so i gotta fight that, along side my capabilities
oh ya.. ull def have a multiplier added onto ur time-management then 😄
NOOOOO
damn
idc atp
then everything will be less perfect, and no one but me will realize that when playing
and it just, urks my soul
perfect games don't come out
exactly! lol
please dont bring that to light
i dont wanna accept that rn
if u keep at it.. you'll def adapt. and adjust ur expectations
so i wouldnt even worry about it anyway
music already enough is a headache as a perfectionist so.. oh shit
my expectations for rn are low, this mainly works bc anytime i do something, i do it better than i expected and just settle on that
u make music? wanna throw me some free soundtracks 😉 hehe
oh shi, i could. i dont really like my music a whole lot but its my music so. yeah?
tbh i feel like music and sound design can make or break a game..
thats why i'll probably end up purchasing all that
if its a vibe.. i dont care what it looks like 😈
Post Shift 2 wouldnt be Post Shift 2 without its sound design
LMFAO
hold on
i got you
oh, this is the code channel.. just noticed.
use #💻┃unity-talk or #archived-game-design if u just wanna talk about generalist (Unity) game-dev stuff
yeeeah i added you
beeettt
` void Start()
{
moveVector = new Vector3(0, 0, 0);
rb = GetComponent<Rigidbody>();
animator = GetComponent<Animator>();
}
private void FixedUpdate()
{
rb.MovePosition(moveVector * Time.deltaTime * 15);
}
public void OnMove(InputValue value)
{
//animator.SetBool("isWalking", )
Vector2 moveValue = value.Get<Vector2>();
moveVector = new Vector3(transform.position.x + moveValue.x, 0, transform.position.y + moveValue.y);
Debug.Log(moveVector.ToString());
}`
There's a few issue with my code to move my character :
- moveVector is set to 0, 0, 0 so at the start it moves my character to the origin
- the character is reset to 0, 0, 0 when releasing the movement keys, I can't figure out why, I make sure that the new moveVector contains the position of the character before adding the movement.
-because of using the player input component I have to make the movement in different parts (what movement in OnMove and the actual movement in FixedUpdate) and it's confusing to me
https://docs.unity3d.com/ScriptReference/Rigidbody.MovePosition.html take a look at the example script and see how it differs from urs
specifically the parameter's MovePosition( ) is using in that example
so im currently trying to use a spring joint, attached to a player, to pull him towards a kenimatic object, the thing is even tho i set the min distance to 0 and max to 1, my player is like stuck and isnt getting pulled towards the object
is it a rigidbody player?
when testing what if u were to disable the movement script.. wonder if it gets pulled in then..
i feel like that's exactly what I'm doing :/
that's what I'm doing here :
moveVector = new Vector3(transform.position.x + moveValue.x, 0, transform.position.y + moveValue.y);
does that run?
yeah but not right
https://imgur.com/yQMXrqU
btw u dont need to ToSring() variables
Debug.Log(moveVector);
Debug.Log($"my vector is: {moveVector}"); or even string interpolation like this <-
oh okay thanks
ya, that isnt right lol
is that temu olimar
im not particular sure how the OnMove works.. (im guessing thats the new input system)
theres no way for me to know when and how often it actually gets updated
it may have something with how the actions are set up
no clue sorry 🍀
it's supposed to get called everytime I press a key binded to an action, and the script basically works just it sets me back to 0, 0, 0 even tho I'm storing the transform.position
moving the character is supposed to be the easy part that's so frustrating :c
ya, see that doesn't make sense to me.. b/c the code only has u setting it to 0 in teh Start() and it only runs Once
debug the position and the inputs in ur OnMove
then check the console. make sure its logging often enough (as u expect)
and that the values are what u expect
I will, thanks
and thanks for the string interpolation method, that's nifty
get that information and come back if u find anything.. or cant figure it out.. someone with some more knowledge of the input system + rigidbody might come around
so the player and the object im trying to attach player to both have a rigid body, and i tried disabling the movement script i have, doesnt seem to make a difference. no matter what i make the spring force it just like gets stuck, and doesnt get pulled inward
i would try with other objects besides the player for testing purposes..
maybe smaller ones, less weight, frictionless materials, etc.. just to see whats causing the issue in general
yeah ill go give that a try, just weird ive used spring joints in the past on this character so im not rlly sure whats different
it seems like the issue is with transform.position, I don't know why tho
make sure you have no other code or components that modify the transform.position, including an Animator component with a state that modifies the position even if that state is not active. if you have a state that modifies the position then you need to make sure your animator is set to not write the defaults (or whatever that property is called)
ohh shoot ye i forgot about animation
I'm not sure if there's something wrong
check the animation clip of idle for example.. or walk.. see if its animating the transform
you can view them in the animation window.. what ur showin is the animator
where can i learn how to use C#
there are beginner c# courses pinned in this channel
Hey! Having some problems with my characters 1st person camera.
The camera is supposed to move whenever the mouse is detected to move, but it won’t register even the mouse input (if so, OnMouseMove would show in the inspector when it would be played). Note that this is horrible code- I’ve never done 3d game development before so I’m dragging my foot with this 😅 feel free to say if anything looks off on the code.
Please @ me if you respond. Thanks!
https://paste.ofcode.org/tcKZUrqV3i9FKg7rZhzL3
Thanks
do all scripts just automatically run on start and do they run per frame or delta time
thanks
Per frame and delta time are the same thing
deltaTime is literally the amount of time that has elapsed since the previous frame
or whatever real change in time is
so high fps gets no advantage
That's exactly the same thing
change in seconds
like i want something to run 60 times a second no matter frames
using deltaTime properly is how you achieve this
what are you trying to achieve? what should be running 60 times per second
my game script
also how should i structure project? i just put everyhthing in scene
everything running is a script in your game. usually when we see beginners say they want to run at 60 times per second, they are doing something very wrong
i don't know how it works, i press play and stuff starts running
sounds like you just need to experiment around and !learn. maybe look at the unity courses if you're already familiar with basic c#
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
will try, thanks
what course should i do
btw anyone have experience with a fully physics based active ragdoll? would this be a good first project?
Start from the beginning if you aren't sure, like unity essentials. if you start a course and feel you already know it all then you can skip ahead
No it is not a good first project, this is very complex to setup
how much physics knowledge would i need to do this
thanks for help all
Develop physics based active ragdolls?🤔
Real life has a faster cpu 😄
you should be very familiar with the engine and how objects should move. its not a question of physics knowledge unless you plan to make your own physics system or a real life simulation for a character.
an active ragdoll is a LOT to setup to get it to work properly. A lot of your game is going to be designed this physics based character, that is the point of every game that uses an active ragdoll. dont be fooled, these type of games are silly and look simple because that is the design. it is not trivial to make and they are usually made by teams
if you try to jump into this, expect to waste a few months with a character that isnt playable
what games have this type of system? might take a look
move like an active ragdoll
human fall flat, TABS. i dont remember more atm but last i remember, human fall flat had their own physics system. either way pretty much every one of my messages is saying you shouldnt be doing this yet
yeah probably won't try it yet
they look fun but it looks like they use external force to cheat and balance characters, is it possible without doing that?
physics in games is cheating
like no external force, only gravity and friction and counterbalancing center of mass
that is how they are made, you move a rigidbody via force or by setting its velocity. what else would you expect to be doing here?
if you're looking to create a real life simulation, well then you better be a top tier engineer because this is a problem still being solved in the real world with real robots.
it looks like a velocity is set then the legs try to follow with ik
What do you want this for
fun making yes? like is there an actual game here or do you just want to learn
yeah i'm looking for a first project
a game with a true active ragdoll player wouldnt be moving the legs directly with IK either. it would still move via physics. You might use IK or animations to get a reference position for where you want each limb to be, but ultimately you have to move there using physics
if its your first project then just based on all the information available for people making their first project
it won't finish
or get close
if you also think you're going to be doing anything remotely close to real life physics, you wont
its all through force and painfully setting up configurable joints. This wont be fun, im telling you from experience
after you learn the basics of how the engine works, you could maybe set up a basic ragdoll through the existing tutorials but there are not many great resources on this. It will look like complete shit and not move in any way that you want it to
are the animations for the ragdoll premade?
the kinda selling point for a ragdoll is that it's not premade
an animation could be premade but it doesnt matter if it is. this is the same concept as my message above for moving with IK. You dont actually move via animation. You use it to get an idea where each limb should be then move it via physics
this is not a fake ragdoll. what you're expecting to do with realistic physics (friction, gravity, counterbalancing) is never done in games
this is what i was saying is still being solved in real life
the "fake" ragdolls are when the actually move via animation. like people say your character in GTA is an active ragdoll which is wrong mostly. You only ragdoll when you lose control of the character
thanks for the help all anyone rec some starting resources?
i thought the animation did nothing
and the outside forces just pushed it
kind of an outside 'just need these checked to see if they make sense', do these make sense, i'm taking some notes and want to know if i got them right
i could be wrong but in games like GTA, it looks moved by animation until you lose control. You can tell if for example the hand goes through a wall during a punch animation. GTA is made in a different engine so it is hard to compare, i just didn't have another example for a unity game where people claim its an active ragdoll online. I do not call this an active ragdoll myself.
In a character thats moving entirely via physics, yes the animations should not actually move the limbs. If you were to punch, the hand would stop upon hitting the wall
but you should ideally use camelCase when writing variables (local to a function and as a field like you are). capitals on all words is reserved for classes, functions and properties (ideally)
what should i start with
should i take like a course
theres no literal reason to do this but it makes it way easier to read code and understand what the words are
i figured, it also makes it easier when writing, because it keeps everything consistent
at least that's what i got after i finished the flappy bird
it got to the point i was able to solve most everything on my own after awhile
also probably the DIY aderall i took
just a correction incase this wasnt a typo, it is decimal, not decibal
i feel ashamed.
(also just wanted to show off my silly naming conventions of 'hedgehog')
(i haven't figured out the use of string yet because i haven't used it yet, so it is a dedicated Mock the eggman button)
script can always refer to self.transform and self.gameobject? then other stuff you need to make a variable with it and drag it in
A script inheriting from MonoBehaviour can because those values we’re already defined there
self is a python naming convention. in c# you could use this. but you don't need it here.
https://docs.unity3d.com/ScriptReference/MonoBehaviour.html
this page shows what exists on a monobehaviour. those 2 are listed under Inherited Members > Properties
Hey all, I'm experimenting with generating terrain chunks and I'm having a bit of an issue that I can't seem to figure out and it's really confusing.
Can anyone take a quick look at this code snippet and see why the 'newTerrainChunk' object isn't getting passed to the BuildTerrain method on the second 'loop' iteration please? I know it's going to be something really stupid that I've missed but just can't see it.
private void GenerateGrid()
{
xOffset = 0;
zOffset = 0;
for (int x = 0; x < worldSize; x++)
{
for (int z = 0; z < worldSize; z++)
{
//GameObject newWorldChunk = Instantiate(chunkPrefab);
GameObject newWorldChunk = new GameObject("Terrain Tile " + x + z);
newWorldChunk.transform.position = new Vector3(xOffset, 0, zOffset);
newWorldChunk.transform.parent = transform;
BuildTerrain(newWorldChunk);
GameManager.Instance.GetManager<DataListsManager>().terrainChunks.Add(newWorldChunk);
zOffset += chunkSize;
}
zOffset = 0;
xOffset += chunkSize;
}
CenterGrid();
}
void BuildTerrain(GameObject newWorldChunk)
{
Terrain terrain = newWorldChunk.AddComponent<Terrain>();
TerrainCollider terrainCollider = newWorldChunk.AddComponent<TerrainCollider>();
// Everything about the terrain is actually stored in a TerrainData
TerrainData terrainData = new TerrainData();
not seeing anything named newTerrainChunk there
anyways you should probably just do some debugging
log some stuff before you pass it into the method
What do you mean isn't getting passed? Does it throw an error? How do you know it isn't getting passed?
It's okay, I think I've figured out the issue. Looks like the called method wasn't finishing before the next loop iteration. Seem to have fixed it by using coroutines.
!code
Posting 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.
private void OnDrawGizmosSelected()
{
Gizmos.color = Color.red;
Gizmos.DrawWireSphere(transform.position, attackRange);
Gizmos.color = Color.yellow;
Gizmos.DrawWireSphere(transform.position, sightRange);
}
why doesnt this work?
Can I somehow get list of all Input Axis?
be more specific please
If you're on the old input manager, you can open the input manager in the project settings and view them
Nono, as in a script
!ide
💡 IDE Configuration
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
can you redefine the path/linking of an assembly?
u see i packed all of my external plugins nicely in a folder
but some plugins cannot be put inside that folder maybe
i just dont want to take out all of them and scattered them everywhere
I believe you can use asmdef files to link between assemblies but i dont think that fixes folder/path issues if the plugin depends on being in a specific spot or example..
outside my wheelhouse if im honest tho..
i found the issues
its a bug that exists quite long ago
nice!
ofc all lies onto delete/regen library folder, but assembly links just broken after i do that
chatgpt mentioned Symbolic links
that sounds liek a can of worms i wouldnt wanna open tho lol
symlinks are just files that act like other files
Hey all, I'm watching a youtube video about interfaces to learn more about them and thought of a question during the video. In the video, it's making an IEnemy interface for the enemies and then each enemy needs to have a Attack/Defend method in the class. The video includes making a Dragon class that has an attack/defend method but what if you have different types of dragons? Would you just make a class like normal with their own attach/Defend method or is there a better way to organize this all? Maybe inheriting the dragon class with override methods? OR, maybe use a scriptable object?
public interface IEnemy
{
void Attack();
void Defend();
}
public class Dragon : IEnemy
{
public virtual void Attack() { /* Default dragon attack */ }
public virtual void Defend() { /* Default dragon defense */ }
}
Maybe do something like this to keep things organized more? Any recommendations from personal experience?
public class FireDragon : Dragon
{
public override void Attack()
{
// Fire-specific attack
}
public override void Defend()
{
// Fire-specific defend
}
}
public class IceDragon : Dragon
{
public override void Attack()
{
// Ice-specific attack
}
public override void Defend()
{
// Ice-specific defend
}
}
Hey all,
I'm trying to build a grid spawning system for my game world, but I'm struggling a bit with the maths involved.
Attached pic is the layout I'm going for (needs to be scalable)
private void GenerateGrid()
{
xOffset = 0;
zOffset = 0;
for (int x = 0; x < worldSize; x++)
{
for (int z = 0; z < worldSize; z++)
{
GameObject newWorldChunk;
if ((x % 3 == 0) || (z % 3 == 0))
{
newWorldChunk = new GameObject("Terrain Tile " + x + z);
newWorldChunk.transform.position = new Vector3(xOffset, 0, zOffset);
newWorldChunk.transform.parent = transform;
BuildTerrain(newWorldChunk);
}
else
{
newWorldChunk = Instantiate(flatChunkPrefab);
newWorldChunk.name = "Terrain Tile " + x + z;
newWorldChunk.transform.position = new Vector3(xOffset + chunkSize / 2, 0, zOffset + chunkSize / 2);
newWorldChunk.transform.parent = transform;
}
GameManager.Instance.GetManager<DataListsManager>().terrainChunks.Add(newWorldChunk);
zOffset += chunkSize;
}
zOffset = 0;
xOffset += chunkSize;
}
CenterGrid();
}
This is the latest version of the code I have, it's very wrong (was trying to get it to spawn the first version of the terrain tile every 3rd 'slot' but didn't work. 😕
Would anyone have any ideas/directions to point me in please?
depends on how exactly the dragons differ and what's shared among different kinds, i suppose
if they don't share anything at all then the intermediate Dragon class would be wholly unnecessary for example
you want (x % 3 == 0) && (z % 3 == 0), instead of the ||
Thank you (bangs head on desk) lol.
Does anyone have any advice for achieving something akin to "normal" physics when coding values and materials?
As an example
One object, weight 40, addforce 20, linear drag 10
And the other, weight 1, addforce 0.5, linear drag 5
Will both behave roughly the same when controlled
But if you multiply the addforce by a throttle, to add in an engine power mechanic, suddenly they behave completely differently
Any tips or guides to reccomend in this area beyond just plugging in values and trying different orders of magnitude until something works?
if you are gonna have a fixed map size you could just have a for( int i = 0; i <= myInt; i += 3)
also that yeah
Aaah cool. Thanks. 🙂 Got it all sorted now 😄
Just working more on the randomisation of 'islands'
you're scaling weight and force by 40 but drag by 2?
that would make them behave differently yeah
Make sure you are using AddForce correctly and in FixedUpdate. Might want to post the code to review.
thats either gonna be easy and simple or brain numbingly annoying lol
I mistyped, it was roughly the same scaling
will do, give me a moment to trim out the movement stuff from the rest
I think that it is hard. After scaling the world down by a factor of 10, I had to adjust gravity, mass, engine power and drag in a not obvious way to feel about the same. So don't forget the scale either.
private void FixedUpdate()
{
updateTankDriving();
updateDragForce();
currentSpeed = rb.linearVelocity.magnitude;
revFactor = currentSpeed / maxSpeed;
currentEnginePower = Mathf.Lerp(minEnginePower, maxEnginePower, revFactor);
}
private void updateDragForce()
{
Vector2 localVelocity = transform.InverseTransformDirection(rb.linearVelocity);
localVelocity.x *= 1f / (1 + sidewaysDrag);
localVelocity.y *= 1f / (1 + forwardsDrag);
rb.linearVelocity = transform.TransformDirection(localVelocity);
}
private void updateTankDriving()
{
if (currentSpeed >= maxSpeed)
{
rb.linearVelocity = rb.linearVelocity.normalized * maxSpeed;
}
}
public void forward()
{
rb.AddForce(transform.up * throttle * currentEnginePower);
}
public void backward()
{
rb.AddForce(-transform.up * throttle * currentEnginePower * reverseMultiplier);
}
public void left()
{
rb.AddTorque((0.1f * throttle * turnForce) * speedTurnFactor);
}
public void right()
{
rb.AddTorque((-0.1f * throttle * turnForce) * speedTurnFactor);
}```
up, down, left, and right are called in the player controls manager's FixedUpdate script
I plan on using the same prefab to make player, client player, and AI tanks, so I wanted the control functions to be not intrinsicially linked
Your physics methods bound to buttons calling them, not FixedUpdate. Buttons should change values to plug into FixedUpdate, not run them directly.
so something like
buttonDown(W) {tank.isGoingForward = true}
buttonUp(W) {tank.isGoingForward = false}
?
private void Update()
{
throttleInput = Input.GetAxisRaw("Vertical"); // get data
turnInput = Input.GetAxisRaw("Horizontal");
}
private void FixedUpdate()
{
MoveTank(throttleInput, turnInput); // act upon the data
}
is there a better way to write this?
if(Mathf.Round(Mathf.Abs(myGameObject1.transform.position.x - myGameobject2.transform.position.x)) <= myInt && myGameObject1.transform.position.y == myGameObject2.transform.position.y)
{
Debug.Log("working");
}
utilize more local variables so your lines aren't 90% just chaining property accessing
public void setControls(float receivedThrottleControl, float receivedTurnControl)
{
forwardControl = receivedThrottleControl;
turnControl = receivedTurnControl;
}
private void FixedUpdate()
{
updateTankDriving();
updateDragForce();
currentSpeed = rb.linearVelocity.magnitude;
revFactor = currentSpeed / maxSpeed;
currentEnginePower = Mathf.Lerp(minEnginePower, maxEnginePower, revFactor);
}
private void updateTankDriving()
{
if (currentSpeed >= maxSpeed)
{
rb.linearVelocity = rb.linearVelocity.normalized * maxSpeed;
}
if (forwardControl > 0)
{
rb.AddForce(transform.up * throttle * currentEnginePower);
}
else if (forwardControl < 0)
{
rb.AddForce(-transform.up * throttle * currentEnginePower * reverseMultiplier);
}
if (turnControl != 0)
{
rb.AddTorque((-0.1f * throttle * turnForce) * turnControl);
}
}
private void updateDragForce()
{
Vector2 localVelocity = transform.InverseTransformDirection(rb.linearVelocity);
localVelocity.x *= 1f / (1 + sidewaysDrag);
localVelocity.y *= 1f / (1 + forwardsDrag);
rb.linearVelocity = transform.TransformDirection(localVelocity);
}
how's this look?
I would have preferred the avoid the if statement making the forward control part longer, but I couldnt think of a better way to make sure I only implement the 50% power reduction in reverse
facing a lil problem, any ideas?
you made person a function not a class..
doesn't make much sense what you wrote
also you don't write the variable again when you assign the value
ajh
my character keeps getting stuck on the tiles
not a code question
put composite mode on the collider
oh
public class Person
{
public string Name;
public int Age;
public Person(string name, int age)
{
Name = name;
Age = age;
}
}
public class TestClass : MonoBehaviour
{
public void TestMethod()
{
var person = new Person("Joe", 42);
Debug.Log($"new person: {person.Name} age : {person.Age}");
}
}```
i have already done that tho
no idea. it must not be correctly setup . can't deduce much from this screenshot alone..
best ask in #🖼️┃2d-tools or #💻┃unity-talk
rgardless this is a code channel
ok thx anyway
also you would need to check the "Used by Composite" option
have you set the tilemap collider to used by composite
im using unity 6 they removed
used by composite
they changed it to composite operation or something
same thing, you still have to set it
iirc you now need to do it on the collider itself
needs both but you select it on collider2d now ig
oh it worked tyyyyy
that didn't change
it just changed from "used by composite -> true" to "composite operation -> merge"
the "used by composite" i mean
yeah basically now its in an enum or whatever
it's still on the non-composite collider
yeah idk I don't use 2D often lol
Hey, would anyone mind taking a look at this?
It’s a camera-based issue, wondering why I’m not having any input of the mouse when I move it (it should move the camera if it had input)
Thanks
could you show your PlayerInput setup
I apologize, a little confused by what you mean by this. Is it the player input editor? Or the coding or the player camera?
Sorry, I know this may be a little dumb.
they are talking about the PlayerInput component on the gameobject
Ohh, I have that on the player object (not on camera). Let me screenshot it real quick.
Should I add it to the camera as well?
if you're using Messages mode you need on the same gameobject that has the script
well, only for SendMessages
Completely forgot it was like that. Thought it was similar to a naming scheme of functions, fixing that now. Thank you so much! Let me see if that fixes it all
yeah SendMessages mode basically calling OnCamera or OnPlayerMovement then you capture inputs from there
btw don't multiply mouseInput with Time.deltaTime
only if you are using a controller
mouse input is already frame independent since you normally get the returned delta (movement since last frame)
Gotcha. So remove Time.DeltaTime from these, correct?
float MouseyCamera = PlayerCameraVector2.y * mouseSensitivity * Time.deltaTime;
yea if its mouseInput only yea
if it were also controller then you would add
if(controller)
input * sens * time.deltaTime
else
input *sens
Thank yall! Finally getting it to work now. Yall are a huge help!!!
Hi, does anyone know what kind of values ReadValue<Vector2>(); on a move action in the new input system will return?
it will return a Vector2?
yeah but in what range will the values be? is it 0-1 or 0-100 or something else?
depends on what it's from
I'm trying to migrate a script from the old input system to the new one and I'm not really getting it yet
it could be [0, 1], [-1, 1], {0, 1}, {-1, 0, 1} - but generally it'll be within -1 and 1
the range of values will be the same
(some things like touch or mouse data might be outside that range)
the old script was using GetAxisRaw so it would be either -1, 0 or 1
and then multiplying that with speed
well no GetAxisRaw gives results in [-1, 1]
ah I see
using digital inputs means you don't get the in-between values
that makes sense
so I suppose I will have to write different movement methods depending on the input device being analog or digital
but yeah Vector2 could represent a lot of things, what values it can give depends on what it represents
well, not necessarily
a controller analog stick would still be in the range [-1, 1]
some things you'll have to though yeah, like mouse movement vs controller input
Hey im looking for some help on how to find the code window or where my code is gonna be for my character
Most tutorials say make a script folder but after that I dont know how they pull up coding window
there's no "code window", it's an entirely separate app
do you have an IDE installed?
visual studio/visual studio code/jetbrains rider
is .wasPressedThisFrame the only way to check if a button (specifically the jump key) was pressed?
No
should I use it or is there a better way?
you can use events such as performed
wasPressedThisFrame typically used in polling instead fo events
I see
This method will disregard whether the action is currently enabled or disabled. It will keep returning true for the duration of the frame even if the action was subsequently disabled in the frame.
The meaning of "frame" is either the current "dynamic" update (MonoBehaviour.Update) or the current fixed update (MonoBehaviour.FixedUpdate) depending on the value of the updateMode setting.
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.2/api/UnityEngine.InputSystem.InputAction.html#UnityEngine_InputSystem_InputAction_WasPressedThisFrame
nvm sorry I had a friend help me out
Posting 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.
Here's another way: https://paste.ofcode.org/ja7w5N9M2YzHzNJsYSbrg4
and cs void OnJumpCanceled(InputAction.CallbackContext ctx) { isJumping = false; }
Thanks. What exactly does jumpAction.performed += OnJumpPerformed; do?
It subscribes the 'void OnJumpPerformed()' method to that action event 'performed' You can call it whatever you want, but the event is called 'performed'
Yo so im using a tilemap in a 2d game and want to rotate this thing but Idk how could someone pls tell me how pls thanks
Thank you
not a code question
Yup
*and can it be solved using code
also tiles don't get rotated, you have to put a rotated tile there.
they are not gameobjects, they don't have transform. They are just a sprite with some basic data
This is giving me Object reference errors on lines 5 and 16
In the Inspector panel of Unity, click Add component, and type PlayerInput
that did it, thanks!
Is it normal that when this code debugs like 50000 it gives off heavy lag? Around 30ms
float minX = Mathf.FloorToInt((position.x - radius) / voxelSize) * voxelSize;
float maxX = Mathf.CeilToInt((position.x + radius) / voxelSize) * voxelSize;
float minY = Mathf.FloorToInt((position.y - radius) / voxelSize) * voxelSize;
float maxY = Mathf.CeilToInt((position.y + radius) / voxelSize) * voxelSize;
float minZ = Mathf.FloorToInt((position.z - radius) / voxelSize) * voxelSize;
float maxZ = Mathf.CeilToInt((position.z + radius) / voxelSize) * voxelSize;
for (float x = minX; x <= maxX; x+=voxelSize)
for (float y = minY; y <= maxY; y+=voxelSize)
for (float z = minZ; z <= maxZ; z += voxelSize)
{
Vector3 voxelPos = new Vector3(x, y, z);
float distance = Vector3.Distance(position, voxelPos);
if (distance > radius) continue;
float delta = Mathf.Clamp01((distance / radius));
updates.Add(new VoxelUpdate(voxelPos, delta, VoxelUpdate.Type.Min));
}
Debug.Log(updates.Count); ```
its just a loop and some random calculations basically, but still, 30ms? just for 50000 iterations?
i mean also depends on the operations you're doing
Vector3.Distance can be quite expensive too
square root calc aint so cheap
ok thanks
Maybe i could optimise such stuff with unity jobs or sth like that, do you think that could help (if youve heard of it)?
its possible but not 100% sure also just guesstimating its square rooting, there could be more. Also you'd have to profile it in a build too and see if its same lag
yeah i get it, but theres generally a lot going on later with my code. The updates are getting applied and some other things happen which leads to like 120ms lag in total, which is terrible. So fixing the square rooting wont really help that much
I guess i just need a quantum computer for my project lol
Why cant I use .enabled on anything Im trying to disable a objects component
wdym you cant ? whats stopping you
how did you find this 120ms lag lag
okay well what is the itemPreviewImage type ?
its probably not a component
its a image
the type
normal image
rigidbodies dont have such property
what is a "normal image"
like the normal image object
Try to count how many times the loop is executed. You are now only counting how many times you go beyond the if. If the bounds are conputed incorrectly, you could end up with way too many iterations
UnityEngine.UI.Image ?
in the code...the inspector is irrelevant
show the entire !code
Posting 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.
wdym
you can hover over it in IDE and you should see the original definition and which namespace is from
whatever Image you put, its not from UnityEngine.UI one
hence the missing namespace
but i cant use enabled on anything
only from Components that inherit Behavior
yes I understand but thats not the Image you referenced.
that tick only exists and does anything if the Object has one of the MB methods
Hey, sorry for another question in same day - having some problems with wasd and the input system.
Whenever the camera turns, the player still has the wasd (1,0) as if it was the previous direction. So if they turned west and pressed a for left, they would walk forward.
I’ve attempted to rotate my player model(the player object) as well, yet that does nothing. Here is the script for player movement and the input system.
https://paste.ofcode.org/KrKFmfzZiXa8H5zYCn7xGa
Is there any reason for this? (Please @ me if you respond, thank you so much!)
I tried to do it with a light and enabled still didnt show
nvm
im so confused
on what
idk 😭 i just wanted to disable the image and get its SourceTexture to change it via script
again, you can if you reference the correct Image component
UnityEngine.UI
But I get the image like this Transform hotbarSlot = hotbar.transform.Find(avalibleSlot.ToString());
how am i supposed to get the image
thats a different thing entirely
we're talking about the code for Image
where did you put the code?
no the one you sent in the discord..
ye
didnt want people seeing lol
using System.Collections.Generic;
using JetBrains.Rider.Unity.Editor;
using Microsoft.Unity.VisualStudio.Editor;
using UnityEngine;
public class InventoryHandler : MonoBehaviour
{
private GameObject currentItemHeld;
[SerializeField] private Canvas hotbar;
[SerializeField] private int maxSlots = 1;
private Dictionary<string, int> inventory = new Dictionary<string, int>(); // Current items in slots
int getAvalibleSlot()
{
for (int i = 1; i < maxSlots; i++)
{
if (!inventory.ContainsValue(i))
{
Debug.Log("Slot " + i + " is empty");
return i;
}
else
{
Debug.Log("Slot " + i + " is not empty");
}
}
return -1;
}
void addItemTooSlot(GameObject item)
{
int avalibleSlot = getAvalibleSlot();
if (avalibleSlot < 0) { Debug.Log("No slots" + avalibleSlot); return; }
inventory[item.name] = avalibleSlot;
Debug.Log("Picked up: " + item.name + " Into slot: " + avalibleSlot);
Debug.Log("Current slots occupied: " + inventory.Count);
Transform hotbarSlot = hotbar.transform.Find(avalibleSlot.ToString());
Transform itemPreview = hotbarSlot.Find("ItemPreview");
Image itemPreviewImage = itemPreview.GetComponent<Image>();
itemPreviewImage.enabled = false;
}
public void pickUp(RaycastHit itemHit)
{
GameObject item = itemHit.collider.gameObject;
addItemTooSlot(item);
Destroy(itemHit.collider.transform.gameObject); // Destroy the item cause its in ur inventory now
}
}
😭
