#💻┃code-beginner
1 messages · Page 601 of 1
those are the types of problems we all spend the most time on
ClampMagnitude could be used instead to ensure that magnitudes below 1 are allowed but it cannot go beyond 1
where is that supposed to happen?
ahh very true
droppedItem = Inventory.Last();
private void Update()
{
moveInput.x = Input.GetAxis("Horizontal");
moveInput.y = Input.GetAxis("Vertical");
moveInput = Vector2.ClampMagnitude(moveInput, 1);
}``` that is cleaner thanks Box 👍
this is just assigning the component not the image, is that what you want?
I want the dropped item image to be replaced by the last image in the inventory
right now ur just assigning Image component from Inventory's last Image component to this variable dropped item
its not doing anything
Yeah I tried droppedItem.SourceImage but that just gives me an error
what is the error ?
'Image' does not contain a definition for 'SourceImage' and no accessible extension method 'SourceImage' accepting a first argument of type 'Image' could be found (are you missing a using directive or an assembly reference?)
your ide is not configured is it?
ide?
yeah like your code editor
thats not a property on Image
it should show you all the correct properties you can use
Yeah I don't remember configuring anything
you should probably do that before anything.
!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
Oh I got it to work its droppedItem.sprite
@red igloo have u changed it out does it work?
Yep got it
Works amazingly but when the ball falls from height it falls very slowly. how do I fix that?
u can apply ur own gravity to it when its not grounded
because ur setting the Y of the velocity
u can just crank up the gravity in general.. but may need to adjust ur forces
ah
you can omit that and do
rb.velocity = (horiz, rb.velocity.y, vertical)
If it's RB just decrease air drag when not grounded
^ pass in its own y velocity in that slot
if you keep it at rb.velocity.y it gets affected by gravity as normal
Or just go edit -> project settings -> physics -> change y gravity from there
its more about him manually changing his velocity than that
good guess tho.. thats what i defautled to as well.. then i remmebered the code
I just came here so idk what's the main goal here
if you want custom than yeah do yvelocity * customGravity
Just took an educated guess
they might not want to change it global though
private void FixedUpdate()
{
// Preserve the Y-axis velocity (gravity effect)
float yVelocity = rb.velocity.y;
movement = new Vector3(moveInput.x * moveSpeed, yVelocity, moveInput.y * moveSpeed);
rb.velocity = movement;
}
is this for the one you made?
using UnityEngine;
public class BallController : MonoBehaviour
{
[SerializeField] private Rigidbody rb;
[SerializeField] private float moveSpeed = 100f;
private Vector2 moveInput;
private Vector3 movement;
private void Start()
{
rb = this.GetComponent<Rigidbody>();
}
private void Update()
{
moveInput.x = Input.GetAxis("Horizontal");
moveInput.y = Input.GetAxis("Vertical");
// Clamp the magnitude to ensure it doesn't exceed 1
moveInput = Vector2.ClampMagnitude(moveInput,1);
}
private void FixedUpdate()
{
var rbY = rb.linearVelocity.y;
movement = new Vector3(moveInput.x * moveSpeed,rbY,moveInput.y * moveSpeed);
rb.linearVelocity = movement;
}
}
``` this is ^
It's best to make a custom gravity component and attach it to the GameObject. Then you would scale by the value on that component (which internally scales by a global custom gravity) . . .
^ aye.. man knows his physics
pretty good idea
i hardly ever use the mass of an object tbh lol
purple gang 💪
i probably should more often 🙂
ya, someone robbed someone
making my first Template today 🙂
I get errors when I use that
did they make the process easier or is just the same
URP Template and BiRP Templates planned
with ur necessities..
- 2D package
- Cinemachine
- TMPro Essentials
- Possibly PrimeTween
you should probably show what errors are..
ya, u need to create a Template folder.. do some other jazz
then u just save it in the AppData Template folder
yeah same jazz.. wish we had like a single file we could use.. this way we can distribuite custom templates easy
all you need is something like the packages manifest...
you must be using a slightly older unity version, it's just velocity on that rather than linearVelocity like in 6
{
"dependencies": {
"com.unity.2d": "latest",
"com.unity.cinemachine": "latest",
"com.unity.textmeshpro": "latest",
"com.unity.inputsystem": "latest",
"com.unity.shadergraph": "latest",
"com.unity.vfxgraph": "latest"
}
}```
oh yea, sorry about that.. the newer versions of unity have velocity deprecated
ya exactly but if it was like 1 bigger container file instead of messing with folders
you can recognize old functions in new api and can be changed but old API has no clue what new API is
for the old api its nonsense
yea, unity tells me would u like to change API to work w/ older blabla
ya I think it autoconverts them or something
thanks it works amazingly ❤
backup? pfft
live dangerously
my projects are my new Rogue like. As soon as I hit a NRE I will delete the project
not sure what'd i do if i lost my scenes and settings folders 🤪
this is all stuff that can be downloaded via the package manager..
i want to keep my templates third-party free
for the most part
we can also add custom repos
ive gotten tired of duplicating template projects
gonna try out custom templates for a bit..
- i can use custom icons 👀 weeeeeee
having 1 for URP and 1 for BIRP with all the basics stuff is gonna be a game-changer
1 more reason custom templates button in hub would be neat
browse.. -> templateFile -> bamm new template added
sorry to keep bothering you but when I move around and then stop. Why does the player constantly move slightly?
Watch "ShootBallGame - SampleScene - Windows, Mac, Linux - Unity 2022.3.26f1_ DX11 2025-02-11 20-15-23" on Streamable.
thats rotation..
u never actual control any of hte rotation
u can tick the Freeze Constraint on all the rotations
probably collding with the ground its making it rotate
yeah youd have to freeze constrain
when not actively pressing inputs
I want it to rotate only while moving
^ the ground is wats rotating it
angularVelocity rotates it
my internet is running like molassis
how much MBPS do you guys get?
what confuses many is also Megabits vs Megabytes
ISP are sneaky they advertise megabits usually
I'm assuming you're referring to download speed (megabytes per second). It would be dependent on your Internet service provider. If you're referring to Unity's network speed (max threshold), I'm uncertain.
I remember when I use to get 50 + MBPS lol
private void Update()
{
moveInput.x = Input.GetAxis("Horizontal");
moveInput.y = Input.GetAxis("Vertical");
moveInput = Vector2.ClampMagnitude(moveInput,1);
shouldSpin = moveInput != Vector2.zero; // are we inputting?
}
private void FixedUpdate()
{
var rbY = rb.linearVelocity.y;
movement = new Vector3(moveInput.x * moveSpeed,rbY,moveInput.y * moveSpeed);
rb.linearVelocity = movement;
if(!shouldSpin) rb.angularVelocity = Vector3.zero; // should we spin?
}
}
now I get around 300 +
MegaBytes or Megabits?
And yes, the Internet has improved in speed throughout the last few decades
i supposedly get 500 rofl
damm thats ruff
thats like 12 MegaBytes
fast enuf i guess
theres bad weather.. so that kinda influences it too
i have no idea why. but it does
hmm was expecting more tbh
ahah scrub trying to flex
im also pretty far from my router and its wifi
same.. if i had hardline it'd be much much higher
this is pretty horrid.
Yeah and depending on the server (website), you'll get different rates - real world application. Speed test servers are usually pretty fast.
the name shouldspin doesn't exist should I make a private bool for that?
my friends have like Gigabit connections (they really do be flexing ) lol
ya its just a private bool i declared at top
sorry i thought that was more obvious
altho im not sure what ur equivilent to angularVelocity is
People confuse bytes and bits all the time and then get confused why it takes some random game 10x longer to download than expected
yes its a shitty marketing tactic
lmao.. steam be putting out 12mb/s tops
making ISP sound stronger than it is
net nuetrallity?
wow 300mbs! oh.. thats only 30MBs..nvm
50 MB/s is like 400 Mbps
Marketing
yeah its misleading af for your average folk
in ur case @red igloo you may want to modify the angularDrag to stop it from spinning
they need to stop making games that are like over 100GB I wouldn't mind slow internet..
There used to be an issue in Europe where they'd confuse Watts for brightness
Instead of lumens, which is the actual unit of brightness
So to represent power they'd use kWh/1000h
Which is just insane
[SerializeField] private float stopSpinDrag = 5f; // Higher value makes it stop spinning faster
[SerializeField] private float normalDrag = 0.05f; // Low value allows normal movement```
```cs
// instead of instantly stopping rotation like I do..
// you can set the angularDrag to a really high number to stop it
// and set it back to a normal drag value when ur not
rb.angularDrag = shouldSpin ? normalDrag : stopSpinDrag;```
Marketing gimmicks are weird asf
Europe kinda weird anyway.. i mean yall drive on the wrong side of the road.. for comparison
😈
It's like money inflation, it never decreases. Get ready to welcome 8k and 16k gaming - 2077
Free healthcare though
But yeah it can be weird there for sure
esp yalls measurement system..
its bad enough i gotta use meters in all my software
What's wrong with metric 😭
lol. just teasing.. yall do you 🙂
Yeah I know haha
also lazyiness due to advanced tech..less limits = more slop.
here i am looking at videos on hub devs from nintendo fit entire game from CD into n64 mall cartage 😦
I got COD on my PS4 (like 100 GB)
To make the game even playable I had to install an additional 150GB worth of DLCs alone
lol.. ur under estimating that tbh
its wild. Once we hit 1TB games
call of duty is by far the Biggest game ive owned
Each new gun would sacrifice a kidney for my harddrive lmao
Some people believe the bigger it is the more valuable it is
20mb game vs 80gb game
lmao ive gottent to where i dont even update it until my friends want to play
DOOM 1993 is 2 MB
They'll need to trim a bit to fit on a floppy
Your upload is crazy. I never see anyone's that high . . .
Or double disk
ya, sometimes my ISP wigs out and i get higher Upload speeds than download
Or a PDF (not a joke)
its not very common tho
130 mb upload is intense
Each episode was on a different disk
yeah not much good there without streaming or anything'
mmhmm "Please Insert Disc 2"
tbh i was always really impressed back then how they broke up an install on 2 disks
but i guess Microsoft did it way before
Not quite. DOOM was basically three different games. You'd put in disk 1 and play Episode 1, then when you beat it you got kicked back to the menu. If you wanted to play an episode 2 map you had to put that disk in (or just copy the files over and play without the disk)
tried to download photoshop back in teh day on dialup..
could never finish it w/o a disconnect. and then id have to restart..
took like 3 full days to finally finish it w/o failing
and then i think the next year Kazaa or Limewire became mainstream.. changed my world
ahh thats right.. b/c the first disc.. was the freeware version
ah yes I miss p2p viruses lol
i can send u one real quick.. if ur after a hit of nostalgia
when Limewire become Frostwire, things got sketchy quick
It's pretty standard
(╯°□°)╯︵ ┻━┻
Although sometimes it feels like in practice it REFUSES to be 180 Mbps
oh yea.. it knows ur running a speed test
yeah feel like the test is inflating actual real loads
Lucky to even reach 5 MB/s lmao
6ms ping is nuts tho
Let alone 22
are u sitting on top of ur ISP?
its also depending on the server you're downloading FROM
ahh yes, downgliding
lol mykeyboard crazyy
LMAO nah just in my room
I usually have high download, but upload is always minimal . . .
i imagine if i were hardlined i'd get 2x the speeds
but rightnow im just using a wifi dongle..
Although wireless is pretty much obsolote for certain setups
dammm flexing those DL speed
pretty sh*T one at that
Just use Ethernet for desktop
i was waiting for the T1 college type connection to appear 🙂
i rather have those downloads speeds if it means thats my upload speed lol
i don't stream or anything anyway
10$ (funny snake looking cord) vs 100$ router
lol my router was 20 bux muahahah
Mine is 50 lmao
I know some people who get TB speeds; it's insane. I usually have 20+ connected devices though, so a lot of it is split up . . .
100$ is really high end for wireless
wowzer TB is insane. I only know a few Gigabits thats about it
I don't stream as often as I used to. Probably 5-8 going on at one time . . .
Google was popular where i was it was over 100Gbits but I moved and now got different ISP
Reminder that the values are simply for pinging. If you're downloading, disk write speed would be a factor as well. Writing to USB 2.0 would likely limit the real world experience to less than 20MBps and if the files are small and many.. good luck.
Sorry, that's what I meant: GB, not TB . . .
the size of my new router (on top)
vs the router i once had
was about to say lol must be running some NASA networking or something
you could sneeze and lose it in the cracks of the walls
Exactly. Misleading values tbh. In practice they're much lower
lots of things.. time of day, hardwired vs wireless, location of ping etc
but yea. usually lower than in practice
well, i feel more poor than i did before seeing everyones speeds 🤣
gotta get a fun project going to relax
the test is checking also the closest server to your ISP so you always get best results, not necessarily the one you're downloading from / uploading to
Yeah, everything's cached onto local servers. We aren't actually accessing files or servers across the world unless they're uncommon
for all you know you could be downloading something from cambodia while you're in the US
some of those speed sites will let u chose the server u ping to
I made a script where my player can go on moving platforms but when I am on the platform why does the stuttering happen?
Watch "ShootBallGame - SampleScene - Windows, Mac, Linux - Unity 2022.3.26f1_ DX11 2025-02-11 21-04-17" on Streamable.
is it because of my camera?
when I turn off the camera script it no longer stutters
Move the camera in LateUpdate
It gives it time to render before moving
Thanks ❤
obligatory: use cinemachine
I would guess either
The ball is an uninterpolated rigidbody and the platform is making it move in Update
Or the platform is an uninterpolated rigidbody (or otherwise moving in FixedUpdate) and making the ball also move in FixedUpdate
I might do later on im just testing stuff
the stuttering is fixed btw
If there's uninterpolated rigidbody motion / position being updated in FixedUpdate, moving the camera to LateUpdate won't fix it but conceals the issue
a moving platform should prob be a kinematic body moving in FixedUpdate with MovePosition so its motion aligns with rigidbody
But that might be good enough
well u kinda just left in the middle of us debugging it so..
no u say me to find other code application
not really. I just said its another option as well since its free
and rider is also a bit easier to setup in unity tbh
you haven't actually shown which SDK version you installed, did you restart afterwards?
where are you launching VS from ? show
unity dont use C# language
unity's api certainly uses c#..
and did u restart
yes
I think they're working with a regular c# console application #💻┃code-beginner message
i dont understabd
ahh..so it seems.
they mentioned unity so i got confused
well what I would do in this case, uninstall VS. Download the VS installer, and try a clean install
chat gpt doesnt know shit
install Rider and call it a day
I could help you better in the context of unity anyway, since this is more of a general c# issue maybe try !cs
Join the C# Discord server, a programming server aimed at coders discussing everything related to C# (CSharp) and .NET. https://discord.com/invite/csharp
your .csproj may still link to old sdk or dont have link at all
ty
what would i do if i wanted when all enemies are not active, the next scene is opened?
put enemies in a list, then count down each time you disable one. if reaches the amount desired do LoadScene
how exactly would i do this tho
like in a script would i need a list or what
or make an empty gameobject holding all enemie
how would i put the enemes into a list tho
cuz im used to having variables not proper objects
it depends if they are spawned at runtime or have fixed number
fixed number
if they're in the scene already make an array of whatever type your enemy is
[SerializeField] private Enemy[] enemies;
then select all enemies you want and put them in inspector field
Drag and drop
where i put this tho
like an enemy manager or something
so you can loop them and check if its disabled, if one of them is enabled break the loop
I want the ball to keep hitting the walls as I drag it.
How can I do that?
you can probably make it more efficent by using events but thats a whole different monster rn..
what the heck
idk what that all means bruzz
You have a lot to learn about coding then
so would i write any cde
Time to learn
just an example```cs
foreach(var enemy in enemies){
if(enemy.gameObject.isActiveSelf == true) break; // one enemy was still active - leave loop;
//Otherwise we reach end of loop - All Enemies are disabled```
what?
that signature is Object, Transform
oh wait nvm idk what it says scene
wonky
visual studio is being a pain again ig
the code is still wrong anyway though
ya with position you need third argument for rotation
i see
Quaternion.identity means no rotation
thats the first time i seen vs bugg out like that bad
idk where it got Scene from lol
yeah no clue, might be to do with the update from the other day
yeah one update broke my assemblies, thats when I just went to VSC and never looked back
ive been hearing a lot of good about VSC, even my professor uses it
idk wat they're pushing at m$ rn
but i hate change and im too used to visual studio lol
yeah the Unity integration getting better each update
only 1.1 and its pretty much solid. Only cause its maintained by m$ open source community not Unity lol
u missing closing bracket at the end btw
cheers
I am trying to insert an image into my text. I am using TMPro, and all the information online says to do "<sprite index = x". I put the sprite after conversion in sprite asset under extra settings in the text inspector, but the unity console is giving me error "invalid expression term '<'". My line of code: upgradeText.text = button.name + " " + upgradeNumber + "\n" + " <sprite index = 0> " + Math.Ceiling(minClicksToUnlock);
Is your IDE configured?
(is your code editor showing you errors inline and auto completing things?)
Never, I use Sublime and turned off all those features
Well you have a syntax error
I tried getting rid of the "" around <sprite index = 0> but that didnt work either. Im worried that <sprite index = 0> only works if I use it in the text field in the inspector, because I need to script all the text for these buttons
What you're describing is a C# compiler error because you've written invalid C# code
Textmesh pro isn't really involved yet at this point
Can you show the full code and the full error?
It would really help you to use a properly configured IDE to avoid this kind of thing too
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
im confused - I can't create a monobehaviour with the new keyword, but I also can't AddComponent?
for generic type use <>
otherwise you need typeof
I despise the autocomplete xD
upgradeText.text = button.name + " " + upgradeNumber + "\n" + <sprite index= 0> + minClicksToUnlock;
this doesnt look allright
https://docs.unity3d.com/6000.0/Documentation/ScriptReference/GameObject.AddComponent.html
generally you want to use the Generic version ofc
Your error is on line 29 and you're missing the quotes around the sprite string
oh my gosh I am silly, I thought it was line 77 for some reason, thank you
IDE would help avoid those errors 😉
You can turn off autocomplete
While still having error highlighting
oh???
Yes in VS the autocomplete is called Intellisense
the error give you information where to look (<line_number> ,<column_number>)
It's configurable on the options
nvim also have nice support for lsp errors
I have my objects height and with right on the edges in rec transform, but what are these big light gray boarders around the text and how do I adjust their size?, theyre blocking interactions I have
they're probably from other rect transforms
also not really code related q
hi question, whats the best way to import and animate a character for my unity project? I have the character created with armiture/bones, etc. but no animations or anything.
Should I animate everything in blender or should I import it into unity before or whats the process? never done it before 😄 any tips/advice?
are classes internal by default?
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/accessibility-levels
Everything in C# defaults to the least visibility possible: internal for classes, and private for class members and inner classes.
https://stackoverflow.com/questions/106941/should-i-use-internal-or-public-visibility-by-default
You could animate the character either in blender or in unity, I usually do the former because I am used to blender. As for the importation process you could use the FBX file type and unity should automatically make GameObject bones which you can animate in unity itself if you have not used blender for animation already. (unity will see the animations you made in blender as well if you select the animation button when exporting)
i suck at blender so maybe i should try the unity approach. So i can export FBX and can i simply drag and drop into my assets?
yes you can drag and drop the FBX file into unity's asset folder and it should just work
notably: if you want to change the model, just overwrite the existing model file
unity will reimport it, and existing uses of the model will update
works but my character is a giant 😄
im not expert but i can simply just scale down, right?
it's best to have correct scale in Blender before importing
noted, thanks
fair enough. I just dont know what the "right" scale is, cuz in blender the scale is just x,y,z
i mean like
i dont know the units or conversions or what it would be
if that makes sense
do you have another model are you using in Unity? use that as a reference for scaling. At least, that's what I do
1 blender unit can be compared to 1 unity unit
(with the right export settings, default is 1:100)
export from blender with "FBX All" instead of "All Local" to get models to come in with a [1,1,1] scale
either way: try to have the scale correct in Blender in the first place
it makes things simpler
also applying transform will produce less crazy units
Im actually not sure what the Apply Transform there related to
oh
but I click it anyway lel
the warning sign scares me ;3
Object mode -> Ctrl A -> All Transforms
thanks although i did search yet found no relevant answerws
so.. im confused. what SHOULD my scale be? cuz 1 is a giant. should i change it to like .1 or something?
In vscode, after creating a script via dotnet new, I tried renaming the top of the hierachy from csproject to something else and now everything has fallen apart and won't run.. what can I do?
we cant help you without showing us any errors
Exact same problem as this https://www.reddit.com/r/csharp/comments/18lfpnz/how_do_you_rename_a_project_on_vs_2019_without/
Regenerate csproj files probably
okay i hope it works
so it seems im getting this error now
Configuration 'C#: MyCSharpApp' is missing in 'launch.json'.
When I try running .net generate assets I get this error
What even is that
Could not locate .NET Core project in 'test'. Assets were not generated.
"test" is the name of my renamed project that i deleted, then deleted again from recycle bin
You really shouldn't be doing much in Visual Studio, Unity handles almost all of it
well its not unity related, it generated project via dotnet new
Then why is it in the unity server
Hey, dumb question but where can I learn C# in for unity? best yt or site
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
which one would you recommend?
hi,new here
I'm kinda learnig a little bit from chtagpt
If you're new to unity, try clicking the one that says "new to unity"
but i'll need a new one
I'm trying to understand c# but can't even compile because vscode is being a little bitch
Oh alr I'll try that
hey, vscode is friend
Can I just tell this to not send a console error if the NavMesh does not exist or do I have to create a condition for it to skip it?
If condition
Cause I don't really need that reference for anything else
So having a reference to that is kinda useless otherwise
Remember exceptions don't just send console errors they also stop your code from executing any further
Yeah, it's the last step of that code fragment
That code but what about the code that follows the method
You really don't want to be throwing exceptions randomly
It just happens that this can sometimes execute the first frame before the NavMesh has been enabled so it returns error
But other than that is fine
If statement
Better yet fix your initialization sequence
imho I'd warn/log on something like that every time, even if you don't think it can happen, it invariably will during development.. even just:
var destination = GetAgentDestination();
if (destination == null)
{
e("Destination was null. This is a bug.");
return;
}
agent.SetDestination(destination.position);
e() is shorthand for debug.logerror or whatever
It does work like that, just that the first frame of setting the agent on the NavMesh sometimes fails
But if it's just the first frame does not cause any issue
then use a flag to see if it's initialized..
bool _isInitialized = false;
void Update()
{
if (!_isInitialized) return;
...
}
(and set the flag to true whenever you know it's ready to use)
Yeah, so the easiest way is just to get a reference to the NavMesh
Oka
I just wondered if you could just say, "try this but if does not happen is alright"
yeah you can but exception handling in normal code logic has very poor performance and is really poor code practice.
What actual exception are you seeing?
That you cannot really set anything from a agent that is not on a NavMesh cause the agent fails to exist until the NavMesh is
I'm looking for specifics
NullReferenceException?
Something else?
What's the actual error?
I just changed the logic, huh, that should not happen right?
Oh, no, I think I see the issue now, isCombatTimeRunning and the NavMeshEnable happen at the same frame on the game manager
🌍 Get the Premium Course! https://cmonkey.co/csharpcompletecourse
💬 Learn by doing the Interactive Exercises and everything else in the companion project!
🔴Learn C# Intermediate FREE Tutorial Course! https://youtu.be/I6kx-_KXNz4
🎮 Play my Steam game! https://cmonkey.co/dinkyguardians
❤️ Watch my FREE Complete Courses https://www.youtube.com/wa...
I'd recommend this tutorial series for whoever is starting with c# and Unity. Or you can buy some books online to get the fundamentals as well
check out unity !learn or some online resources like
w3schools
brackeys
Code Monkey
microsoft docs
unity docs
and many more. google as always is going to be the best method for finding help (if all else fails, ask here)
W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.
Learn how to make video games!
Top-quality game development tutorials on everything from Unity, Godot and programming to game design. If you want to become a developer this channel will help guide you through it!
Join us on Discord: https://discord.gg/brackeys
► All content by Brackeys is 100% free. We believe that education should be availab...
Hello and Welcome!
I'm your Code Monkey and here you will learn everything about Game Development in Unity using C# taught by a Professional Indie Game Developer.
Watch the free Video Tutorials or learn from my complete Step-by-step Courses
https://unitycodemonkey.com/courses
Check out the official website to download the free Project Files a...
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
tools like ChatGPT also work. its prone to error though. in the worst case scenario, can be a bit of a bugger to debug, even for more experienced devs
also check the pins

does anyone have any good resources to really learning C#/unity? Everything I run into is mostly just "Heres how to do this" but not how and why it works.
It gets frusturating when everything you read is just telling you how to do things but not actually why you're doing those things or why it works.
i didn't scroll up or see that btw ^^^
lol
hey so i made a minecraft like mesh but how do i add textures to each face? i want to be able to customize it. already got uv mapping done
where did you do the uv mapping
perchunk on the whole mesh
I have a small C# problem and I have to go to bed
If someone could call me for just a few I would appreciate it
we don't do that here
just ask
!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 #854851968446365696
can you help with my issue?
also if it's unrelated to unity, there's a c# server that would be a better place to ask
please don't ping random people for help. it's also not a coding question
It's strictly a unity issue
see one of the artist channels
it is a coding issue?
thank you
you're asking about setting a texture on a mesh?
yes a procedual mesh that is not premade
I'm gonna get some screenshots for you
start with a description please
got it
I was following a character controller Brackey's tutorial and obviously made a very small mistake somewhere
discord can't embed mkv, convert it to an mp4 so it can be embedded
(also, so what's the issue)
Describe what's happening and what isn't happening.
let me record again
you could just go convert the recording you already have
it was bad
Just post the !code using an external link and explain what's happening and not happening
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 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.
also for future reference, a textual description would be easier than audio
How do I explain my issue?
paste a link to the site here instead of sending a screenshot
text is much more useful to us
thank you
When I start walking I teleport
after you teleport, you said you "weren't moving", but have you checked the inspector on the player to see if that's actually the case
No I was moving but there was a barrier at spawn
can you show the inspector of the player
Like the console?
no, the tab that says inspector that's on the right side by default
bruh you showed the thing i asked for last lmao
so it's scaled by a factor of 100.
it should probably not do that.
that's gonna skew other measurements
so 1?
yeah, and then scale the mesh to make it an appropriate size
One more thing
Non-code related
how can I invert the look controls? I used Cinemachine
but I can look around
I don't think so
it's probably a cinemachine thing then, i haven't used cinemachine so i can't really help you. try asking in #🎥┃cinemachine
Okay thank you so much
goodnight
Hi, im making a bird game. Does anyone knows why my bird cant stay on my cube? i put box collider, rigidbody (use gravity). My bird keeps going up down (stuttering)
Does the cube have a collider?
this is my gameobject
bird
|_ bird model stuff here. All my rigid body and my collider are here
and yes, my ground cube has box collider
The information you’re giving is a bit vague. Have you checked to see if the collider on the bird is centered and sized appropriately for the bird? Have you done the same for the cube? Have you made sure that the colliders aren’t set as triggers?
Sorry melton i will provide screenshot in a few hours
playerRB is null! Cannot jump. Make sure Rigidbody2D is assigned.
UnityEngine.Debug:LogError (object)
PlayerMovement:Jump () (at Assets/Scripts/Player Controls & More/PlayerMovement.cs:89)
PlayerMovement:<Awake>b__10_2 (UnityEngine.InputSystem.InputAction/CallbackContext) (at Assets/Scripts/Player Controls & More/PlayerMovement.cs:48)
UnityEngine.InputSystem.LowLevel.NativeInputRuntime/<>c__DisplayClass7_0:<set_onUpdate>b__0 (UnityEngineInternal.Input.NativeInputUpdateType,UnityEngineInternal.Input.NativeInputEventBuffer*)
UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate (UnityEngineInternal.Input.NativeInputUpdateType,intptr) i always get this error but the rb is active on the player ?
that always happens when i hit a enemy and restart and want to jump
The first line of the error tells you the problem though, so just fix that?
but the thing is i already looked into that i rewrite it again and again and still have the same issue
then show the relevant !code, preferably the entire PlayerMovement class so we can see where it is being assigned
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 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!
and do you see any of the other logs from that component in the console?
beside of that not
what happened in the 3 seconds between the last successful jump and this attempt? that can help narrow down what may be happening
actually wait, your console is in collapse mode. turn that off and screenshot the entire thing
Is that all of the logs in the console or are there perhaps more above what you've shown
Because if I had to guess there's probably a much earlier log about the object not having a rigidbody and the component is probably attached to more than one object in the scene
Search your scene with t:PlayerMovement to check for duplicates
My guess is that the restarting of the scene removes the link with the RigidBody which he set in the editor.
Not sure how he's restarting it, if he just instantiates a new Player again.
But you can check that by just looking at the component after it has restarted the scene if it still has a link with the public rigidbody
if i add that in console it does works then i can respawn again and jump again
and now does it work lmao?
I said search the scene not the console. You're hiding your logs by searching the console like that
Is this search during or outside of play mode
outside
now gonna try it when i play
Do the search when the error starts happening
it seems like it works perfectly rn
now it does work?
when i did search in console "t:playerMovement" after that it worked
what could be the thingy here?
most likely you changed something and didn't realize. searching the scene/console doesn't do anything
You also still get the error in the console at second 6
yep iknow but now it works even when i recieve the error
you had error pause enabled before. so absolutely nothing has changed if you are still getting the error
add this log to the beginning of the Jump method and show the console when you get the error. i also recommend turning Error Pause back on so we can see exactly what is happening at the time of the error
Debug.Log($"Jump invoked on {name} ({GetInstanceID()}, with rigidbody {playerRB} and grounded state {isGrounded}");
please make your console window bigger so we can see the relevant logs
also are you certain you actually added the log i provided? because theoretically we should be seeing it above the error and also separately above the following jump attempted log
so where's the log i provided?
where to find it
do i need in code?
to look for that
or
playerRB is null! Cannot jump. Make sure Rigidbody2D is assigned.
UnityEngine.Debug:LogError (object)
PlayerMovement:Jump () (at Assets/Scripts/Player Controls & More/PlayerMovement.cs:89)
PlayerMovement:<Awake>b__10_2 (UnityEngine.InputSystem.InputAction/CallbackContext) (at Assets/Scripts/Player Controls & More/PlayerMovement.cs:48)
UnityEngine.InputSystem.LowLevel.NativeInputRuntime/<>c__DisplayClass7_0:<set_onUpdate>b__0 (UnityEngineInternal.Input.NativeInputUpdateType,UnityEngineInternal.Input.NativeInputEventBuffer*)
UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate (UnityEngineInternal.Input.NativeInputUpdateType,intptr)
this?
no, i asked you to add a log to the code and you assured me that you had done so. you clearly did not.
explain it better, because i dont find any log for it
or where i can find
i did added
wait
this is the jump
so the debug is there also
ok lemme try
playerRB is null! Cannot jump. Make sure Rigidbody2D is assigned.
UnityEngine.Debug:LogError (object)
PlayerMovement:Jump () (at Assets/Scripts/Player Controls & More/PlayerMovement.cs:89)
PlayerMovement:<Awake>b__10_2 (UnityEngine.InputSystem.InputAction/CallbackContext) (at Assets/Scripts/Player Controls & More/PlayerMovement.cs:48)
UnityEngine.InputSystem.LowLevel.NativeInputRuntime/<>c__DisplayClass7_0:<set_onUpdate>b__0 (UnityEngineInternal.Input.NativeInputUpdateType,UnityEngineInternal.Input.NativeInputEventBuffer*)
UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate (UnityEngineInternal.Input.NativeInputUpdateType,intptr)
where is the log that i gave you
not everyone is fast with things but like i placed it right here & have this
okay so the issue seems to be that your Jump method is still subscribed to the input action's event but since you create a new instance of PlayerControls and subscribe in Awake that shouldn't be possible
and how to fix that?
disable/dispose controls in OnDestroy
hm so let's say we got a matrix for chunks, how does one draw the mesh efficiently?
i dont find it
what do you mean by that
i dont see the controls in ondestroy
huh?
or where to find it
OnDestroy is a method, controls is literally the name of one of your variables
yea but i dont find the "ondestroy or the controls in this: https://paste.mod.gg/lrfnkqofmwec/0
A tool for sharing your source code with the world!
or you mean this? // Input-afhandeling
controls.Land.Move.started += ctx => direction = ctx.ReadValue<float>();
controls.Land.Move.canceled += ctx => direction = 0;
controls.Land.Jump.performed += ctx => Jump();
}
well first of all, you should at least be able to find controls since, as i already pointed out, it is one of your variables. and second, if you don't even know what MonoBehaviour.OnDestroy is, you should start by going through the pathways on the unity !learn site
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
just explain it better lmao
nah, i'm done helping you now
i sended u the script and u didnt even help to find them Monobehauvior.Ondestroy
you didn't even bother googling it
then go through the pathways on the unity learn site
you're very clearly missing some fundamentals, so go learn them
i dont
they always said if it works it works :d, and at some point when i dont use the pause console thing it works like normal
i can respawn
and jump
and still get hitted
but the error still appears
but works
ignoring your errors just because it isn't pausing is stupid
ah yes, then when your players get multiple game overs and their logs are being spammed with errors because you decided not to bother fixing them so the performance of the game is degraded i don't want to see you coming back crying about getting help fixing it
i also don't help people who refuse to bother learning the basics so i'm just going to block you now. good luck with ignoring your errors instead of the super easy fix 👍
lmao😂 , with the wrong leg out of them bed
i just don't help morons who refuse to read the information presented to them 🤷♂️
uhm u ever heard of non fast readers or people that just doesnt get it easy right bcs of stuff (adhd & autistic etc) bcs that shit and programming things while already fucked is fucked
it is not about refuse read
cause i read everything
btw i already found it
see
@slender nymph
Thank you
So in my game bascially you shoot barrels, when i shoot a barrel i want it to chip, i have split the model in blender into sdiferent parts of the barrel, and i also have a mesh where its all intact, but the mesh intact whilst separated just looks way different even when all parts are there. whats the best part to, when the barrel is shot a particle system plays where some pieces of the barrel flies out, and the actual barrel model visibly has a random part missing
what does "way different" mean in this case? could you share with us some screenshot comparisons of what you mean?
this is also a code channel, if your question isnt code related, move it to #🔀┃art-asset-workflow
IEndDragHandler doesnt get called when the drag ends but when u releade the buttom
İs there an event that runs when u stop dragging?
what does it mean to "stop dragging" in this case
and how are you supposed to determine that the actual intention was to complete the drag and not just pause moving for a moment?
Doesnt matter i want to call a function whrn it pauses/stop
then you'll just need to check that the position hasn't changed within some arbitrary time
yeah doesn't sound like you want dragging
Ye but this is a mobile game and there are multiple touches
dragging is a composite action, mousedown + move + mouseup
Can you get the touch id on pointer down?
yes, but you wouldn't use pointer down for this
What do i use?
all of these interface methods that have been mentioned so far receive a PointerEventData parameter that contains info you may find useful
you would just have to track the movements yourself. there's no corresponding action for "didn't move"
Yea i will manually track the movement but how do i get the touch drom poonter events
İ couldnt find it in that
did you try looking harder?
İt is id not index it is a number like 1513...
what is the point of getting that anyway?
To get the touch and get rhe delta of the touch
why do you need to get the touch for that? the PointerEventData already contains the delta
And if you just need to determine if the pointer has stopped moving, you just need to figure out when OnDrag has not been called within whatever arbitrary time you pick
Which loop does event system run on?
Does anyone know any tutorial or place to help. I am making a 2D game and I need to make barricades that ask a question which needs the correct answer to pass and not sure in how to do it. Thank you
Like Update LateUpdate FixesUpdate?
https://docs.unity3d.com/6000.0/Documentation/Manual/execution-order.html
I would guess it's the Input Event's tab.
i don't see the relevance in that question. just timestamp the last time the drag happened, once the time elapsed since that timestamp is beyond some arbitrary value you pick then it has "stopped dragging" (according to your logic)
what is the method that returns a bool for if the game object is active?
https://docs.unity3d.com/6000.0/Documentation/ScriptReference/GameObject.html
there is no method to check if a gameobject is active, there are properties though
That's a very specific scenario. You would combine multiple steps to create the entire interaction . . .
- make barricade
- interact with barricade
- ask question to player
- allow access to new area
Yeah
Hi, I'm making a third-person character using a Character Controller, and was wondering if the movement script should rotate the whole game object or just the body visuals? Hierarchy is as follows:
- Player (Root, has CharacterController)
- Body (Visuals)
An example of movement style is Yooka-Laylee.
Character move forward and backwards in the directions of the camera but moves sideways facing to the side of the camera.
I figured this can be done easily enough by just rotating the body visuals only, but when I factor in other things such as Hitboxes for swords etc, should I rotate the whole game object or just the visuals and Hitboxes?
The character has a sword attack, so the attack hitbox needs to be properly aligned.
Just wondering which is the better approach for down the line.
rotate the root object so that it is always pointing the correct direction and you won't have to separately account for directional stuff
is their an option to remove to get the full game at 1 screen without camera followement?
cause when i press play it doesnt follow the player?
i dont get an error also
Ok thanks. I can see reasons for both, but just wanted a second opinion. Will look at rotating the whole thing. Thanks
I try to make the character root have an accurate position, rotation, and scale
that way, I can do whatever the hell I want with the child objects (e.g. make the body shake around) and it doesn't mess with my game logic
remember to reap your children!!
The harvest is bountiful
I want to group methods from an external script in a dictionary, like:
public AnotherScript script;
Dictionary<string, ??> dict;
void Start(){
dict = new Dictionary<string, ??>{
{"Method1", script.Method1},
{"Method2", script.Method2}
}
}
but idk the name of the type the methods are
if they all return void and have no parameters then the type would be System.Action
but also why would you want to do this
what if they're void but have parameters?
answer this
https://xyproblem.info
There is almost certainly a better way to do whatever it is you're trying to do
it's complicated .- i gtg now but I'll try to answer that in like 15 min
whats this btw?
click the link and find out
They posted what they were trying to do. If you suspect that they're approaching the problem the wrong way, or think what they're asking doesn't make sense, you can just ask for more information.
Referring someone to xyproblem instead of just telling them you don't understand what they're going for is not really a nice thing to do, and probably makes the person feel like they did something wrong.
i asked for clarification and also shared the xyproblem link to show why the clarification was needed. your pointless interjection about what is and is not "nice" is not needed here
Also, https://xyproblem.info/ is a very informative site that thoroughly explains why their question might have to be reconsidered. That's likely something they didn't realize and it greatly helps if they read more about it.
I'm just saying it can be perceived as a bit hostile, even if I'm sure that wasn't your intent.
many things can be perceived as a bit hostile, unfortunately
One thing I do think people have to realize is that linking sites like this is not in any way supposed to be a discouraging thing. These things happen so often that sites like these are really useful instead of explaining the problem ourselves.
Same with telling people how to screenshot, or to share code, or how to ask questions in general.
No, that's fair. Maybe I just have a habit of baby'ing people a bit more because it's #💻┃code-beginner 😅
How would I add custom methods to string data type? public override string ToString() {content here} seems to override an existing method, but I'd like to add a new one
Is it a channel for newbie?
what do you mean by "add custom methods"
by the sound of it, you are probably asking about extension methods? but you gotta provide more context
I just have an idea and hear about unity 😅
Like in JS I think you can modify prototypes, I'd like the same thing to achieve my desired result of being able to run ("test").LengthTimesFour and see 16 being returned
Extension methods
https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/extension-methods
Yep, that's what you're looking for.
Thank youu
note that extension methods are basically no different than regular static methods in a utility class, they can just be called as if they are an instance method on specific types of objects
so you won't get access to anything that isn't public on the type
im back
I clicked it before and didnt understand what it meant, but now reading twice I got it
well, in the meanwhile I found another solution to what I want to do, but if you're up to explain me, I'd appreciate how you do what I was talking about before just for the knowledge
this is a code channel.
#🥽┃virtual-reality
you still need to describe what you were actually trying to achieve so a proper solution could be suggested
Ok, sorry
basically a system to call different methods with a given context without having dozens of ifs and else
If you don't know the methods, I suspect you're looking at reflection. Otherwise you'd do something like
dict.Add("StartGame", myClass.StartGame);```
or code generation, I suppose
yeah that doesn't really make what you are trying to achieve any clearer
👆 At this point I will agree
Do you mean, e.g., having different buttons that do something different (execute a specific method), but you don't know which button is selected?
I remember earlier. If your main concern is having a bunch of if/else there’s a few ways to resolve your issue
Mainly, if you want to use the legacy input system, offload input gathering to a separate MonoBehaviour which raises events for inputs
Then any class which cares about input will just subscribe to those events
Hey guys, I have a question, I have started to make a voxel engine within Unity to help with my future games, but I saw the news that Unity 7 will have significant (good) changes. Do you think I should wait for a beta of Unity 7 where the core CLR and .NET 9.0 have already been implemented?
Then you’d have the ugly if/else or switch but it’d be hidden off into one class
Other option is use the “new” Input system
And also I heard that ECS is now going to be the default in Unity, which is great for me
do what feels right to you. imo just get to work on it, it'll be easier to migrate from something you have than to make it from scratch again
Its not going to be default, but built-in, easier to access but not forced to use it, also from their announcement they said it get better integration with gameobjects
It sounds like the "new" input system would solve their concerns
From what I've seen, it will be the "default" in terms of, instead of having abstractions to use entities with game objects, it will be gameobjects that will have abstractions to be used in the ECS system now
Unity 7 is a good time away from its first LTS, there is not reason not to start on unity 6 and upgrade later
Time waiting will be far larger than the time you need to upgrade
I believe the ECS changes you're thinking of is lower level changes to how Gameobjects work, where Unity would use a lot of the ECS foundation "under the hood" even in traditional gameobject workflows.
But we're likely talking about mostly non-breaking changes, so I don't think there's any reason why you couldn't start working on your game now in Unity 6, and upgrade later on.
afaik unity is reworking gameobjects to use ecs under the hood
even if the jump is a major version unity usually stays reasonably backwards compatible
My fear is that because it is a very big change, many things will have to change, since for example the jobs I imagine will no longer exist, since the Tasks do the same work with the same performance in .NET 9.0 but much easier to write, so I would have to refactor the entire project for example
we had smaller projects upgrade from 2021 to 2023 (6) that only needed a package update and code changes in like 5 places after
ECS and jobs packages (as most other packages) are shared and 99% compatible even between major unity versions
also jobs do a lot more than tasks 😄
The biggest problem with jobs for me is that to do something simple you have to write many lines of code (especially following the current ECS workflow in unity)
You give up simplicity for performance
most of the time you are absolutely fine doing a computation on the main thread, simpler but slower
anyone know why this is scaling a tilemap insanely small and no amount of code or inspector adjustments makes it bigger or smaller?:
using UnityEngine;
using UnityEngine.Tilemaps;
public class ScaleTilemapTiles : MonoBehaviour
{
public Tilemap tilemap;
public Vector2 scale = new Vector2(0.5f, 0.5f);
void Start()
{
if (tilemap != null)
{
BoundsInt bounds = tilemap.cellBounds;
foreach (var position in bounds.allPositionsWithin)
{
Tile tile = tilemap.GetTile<Tile>(position);
if (tile != null)
{
tilemap.SetTransformMatrix(position, Matrix4x4.Scale(new Vector3(scale.x, scale.y, 1)));
Debug.Log("Scaling tile at position: " + position);
}
}
}
else
{
Debug.LogError("Tilemap not assigned! Please assign a tilemap in the inspector.");
}
}
}
You have your scale variable set to public which means it will be overridden by whatever value is in the Inspector.
Generally speaking, don't give your public variables a default value for that exact reason, and modify it on the component itself.
If you are changing it in the inspector ... then no idea, bad matrix math? 😬 Debug log the scale to verify
adjusting the value in inspector has no effect on the problem either?
btw, when posting !code like this, can you remember to place "cs" after the three ` at the start.
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
📃 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.
just makes it a little easier for us to read
Hello, i need to put several colliders on my character, and link a script with OnTriggerEnter on each one,
Is it necessary to put as many rigidbodies as colliders?
the public was the problem. thank you
hey guys question my instructors asking me to insert this here
and i have no clue how
Type it..?
but i have
like, put the cursor where you want to add stuff .. and type what you see..
it keeps giving me some weird error
if you have an error - it's not showing in this screenshot.
You haven't typed exactly what was said either (you missed the { })
What you've been told to type is also shit code
Yeah this is a bad tutorial
Transform is an accessible property for every MonoBehaviour, you do not need to ever do GetComponent<Transform>() in this situation.
just do transform.position += upDirection;
Its obligatory at least one have a rigidbody ? (i would like not because their parent have already a rigidbody for another collider)
What isn't clear about the error?
For every { you have, you MUST have a corresponding }
but i do
You do not, hence the error
i dont see what im missing
The error tells you what you are missing - a }
you've messed up the closing } of the method or class
oh whoops
for this singular method you may. scroll up, there are more opening brackets { for the class
Anyone ?
all colliders will send the message up to their first rigidbody
you could just test it - quicker than asking and waiting 😄
Only ONE class will receive physics events though.
i spent my entire afternoon on that...
Their first ?
I dont understand
My issue is :
I have a Character with CC and Rb
And 2 children (Child 1 and Child 2) with each one Collider is Trigger
I would like the Child 1 detect the Child 2 form others characters ( and Child 2 detect Child 1 from others characters)
It's different for collision events and trigger events
I always forget which is which
I want to say that triggers are received on both the object with the collider and the object with the rigidbody, but I could have that backwards.
You do not need a rigidbody on every object with a collider, no.
Hum weird thy cant trigger
https://unity.huh.how/physics-messages/trigger-messages-3d
Go through these pages. They explain all of the requirements.
What I meant, that wasn't stated clearly. 2 components, with physics events in (OnCol.. etc) on the same Go as the RB, only one of these components will receive the messages, not both
that does not sound right, given how unity messages normally work
What i note its if Child 1 and Child 2 have not a Rigidbody so they cant OnTriggerEnter()
yeah, just checked: OnTriggerEnter is sent to both objects. The same goes for OnCollisionEnter
No every, but one of them
youd put a component with ontrig enter on the parent with the rb
"objects" being..?
But he already have with a different Collider, i want detect the Child collider..
both components
attached to the same GameObject
"objects" was vague there
aye, why I asked for clarifaction :p
a child collider sends its messages up the hierarchy until it hits an rb
additionally, trigger messages are sent to the game object with the collider and the game object with the rigidbody
I am really confused does OnEnable get called on like ever script inside of an object when i Instantiate one?
i would expect a inactive script to remain inactive
but it seems to get activated
however, collision messages are only sent to the game object with the rigidbody
OnEnable is called upon creation of the MonoBehaviour if it is active and enabled
If it is not yet active and enabled, the method is run as soon as it becomes active and enabled
but its not enabled
this means that its game object must be active and the behaviour must be enabled
Then OnEnable is not being called. Perhaps you are missing something.
Are you disabling it immediately after instantiation?
That's too late.
ok ill explain my rpoblem more then
So i put the script on the same GO than the rb, but how i can distinguate which collider is the detector ?
This is not necessary: #💻┃code-beginner message
The page I linked describes all of the conditions for receiving trigger messages
Instantiate returns the instantiated object. I'm unclear what "original state" or "current state" would mean here
Carwash responded in #💻┃unity-talk , in case you missed it
ye i did see that
but i thoguth i would move in here
Fen responed better in here
Here is my test setup. The "Test" component logs when it receives trigger / collision enter messages
like if i have enabled a script thats by default disabled and then use instantiate, will the new instance have it enabled or disabled
im trying to debug this issue ive been having where https://paste.ofcode.org/MazWfC9F9HXzpNhgZiw7QA this is causing like a loop and keeps activating itself
oops, forgot to remove the box collider from the parent. so that's why I was getting too many collison messages...
everything still works as expected, though (:
i tried disabling it instantiating and reenabling it but that didnt seem to help
The resulting object will be an exact copy of the original (as far as Unity-serializeable properties are concerned)
Have you checked when OnEnable is actually running?
so then why does that script in the link i set get in a loop
ye its running straight after tile = Instantiate(gameObject, transform.position, transform.rotation);
i checked the callstack
with debug mode
ye but by default this script is disabled so it shouldnt get in a loop
I have looked already the documentation https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnTriggerEnter.html , i know ". At least one of the colliders must be a trigger collider and at least one must be a physics body collider"
I have already the CC on this GO so if put another Collider how i distinguate which one is the detector ?
it instantiates a copy of gameObject which this component is enabled on
There is no way for the behaviour to not be enabled and still reach that line of code
so how do i do this then?
i tried disabling it instantiating and then reenabling it but that didnt seem to work either
https://unity.huh.how/physics-messages/trigger-matrix-3d
this more clearly shows the rules
I have this elevator with a propeller and they both have animations why doesn't the propeller spin?
Watch "ShootBallGame - Home - Windows, Mac, Linux - Unity 2022.3.26f1_ DX11 2025-02-12 17-15-55" on Streamable.
Hum ok thank you
because it's in the Elevator state
not the Spin state
perhaps you meant to have two animator layers
that lets you play multiple animations at once
okay let me run it again czu unity crashes every time
I'd add a check for infinite recursion
e.g. the number of game objects in the scene is over 500
THANK YOU!!!
or some criteria like that
I've done this before when chasing down infinite recursion
on the subject of character controllers: I've gotten some really weird and inconsistent results from those
They act as a collider, so if a non-kinematic rigidbody hits it, you can receive a collision message
You can also receive trigger messages when you get hit by a rigidbody with a trigger collider on it...sometimes?
or was that kinematic rigidbodies that were inconsistent..
I'm not sure what the best option is here, actually. My first guess would be to put a kinematic rigidbody on the same object as the character controller
That should allow your trigger colliders to interact with all other trigger colliders (including those without a rigidbody)
I need to go test all of that stuff again.
btw CC does 100% work perfectly fine if other triggers do not have rigidbodies to call OnTriggerEnter
when the CC moves into the trigger collider?
yea
what's interesting is it also works with Transforms moving directly and .Move() not being called at all on the CC.
CC is the Capsule btw
actually, that's exactly what I was testing a while ago
notice how it doesn't instantly hit
it just kind of...eventually hits
i'm not sure what's going on there
ah yes, eventual consistency
😭
makes sense since its like a query of estimation and not actual collision?
Idk about how unity/nvidia deals with physics queries tbh
nvidia?
yea nvidia made the physics
huh..
I'll have to go bang colliders together some more to find out what's going on there
why does "physx" sound like a medical suffix...
lmao
also this is me testing with Transform practically teleporting and Move() not being called at all. Maybe that can help precision a bit? tbh I never had issues though with consistency at least from my testing in-game so far in other projects
kinda amazing how unity flipped this controller for c# / .net tho
PxUserControllerHitReport::onControllerHit basically is OnCharacterControllerHit
well, yeah, that's the point :p
Note that the character controller does use overlap queries to determine which shapes are nearby. Thus, SDK shapes that should interact with the characters (e.g. the objects that the character should push) must have the PxShapeFlag::eSCENE_QUERY_SHAPE flag set to true, otherwise the CCT will not detect them and characters will move right through these shapes
I guess Unity applies this for all colliders
or is this for pushing dynamic rb. shits confusing cause there is also CCT-vs-dynamic actors section
Is there a really simple way to grab objects by pressing E and being able to drag them? I'm making a 3D side view game and I'm getting confused on how to make this. I don't want to use joints as it looks difficult to use lol.
Watch "ShootBallGame - Level 0 - Windows, Mac, Linux - Unity 2022.3.26f1_ DX11 2025-02-12 14-57-57" on Streamable.
whats the problem so far?
eg what did you try
I haven't started making it yet cause I'm confused on how to take a approach to this.
arent you pushing it already ?
Like I want to be able to grab the object and drag and push and I want the object thats being pulled or dragged react to the ground
did you try the joints? what happened there?
oops not push I meant pull
Im not using joints?
thats why Im asking, did you try?
its A way to do, there is no "best way" usually
all problems get solved in different ways
i think joints will be the easiest to try and most straight forward
which joint would be used in this case?
I had luck myself for "holding planks" and stuff
id start with the most robust one
FixedJoint
if you want more slack try the other
should that component be on the player?
the tricky part is your object rotates
so you cant just anchor it to the ball
you'd need a way to solve that
for example making ball rotate only visually and not the actual rb
this would let you at least split independently
If I made it so when the player presses E on the object and the object rigidbody is placed in the connected body (FixedJoint) would that work?
well thats normally how you fix a rigidbody to something yes
idk if it works, you're the one who can test it lol

did it work?
Hi all,
I was just wondering if someone could point me in the right direction on where to look to achieve a 'mortar shell' launch and arc.
Idea being that the rounds get launched randomly from the red x's, and impact at random points within the green circle/area.
I'd like to be able to calculate the 'arc' of travel as I want the player to be able to shoot them in mid air.
not yet kind of confused on how to add a feature that sounds simple yet hard to implement lol
Maybe you could
If the ball is colliding with the box and if they’re pressing E apply the same directional for to the box game object.
Not gonna lie, this pretty much sums up gamedev for me. lol.
I never used joints but that was my first thought when I saw your question.
A solution without the joint.
u trying to carry around rigidbody objects? u dont need joints.. thats over complicating it..
lol guy who’s name is Spawn replying to a guy with a profile picture of Spawn.
well nav said "i think joints will be the easiest to try and most straight forward"
If that's the case, is it not just a simple case of parent object to player, disable rigidbody?
nah, i normally agree with nav. but not this time