#💻┃code-beginner
1 messages · Page 816 of 1
not really
because, after the first time it runs, grabJoint will then not be null
so the if will go to the else statement
and start applying force to the object that is now attached to the joint
while, with the edit i did, if the distance is close enough to be attached, it will always go in that case (and then check if a joint needs to be created)
This is hard... to learn i use ai, and ai told me to make this code (obviously i didnt copy + paste, i can explain all the things that are there), and many times makes wrong things, do you recommend something else to learn Unity or am i just using it wrong?
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
tho that code should work
but i would check the distance calculation
that is probably what is wrong there
bc the object gets attracted
but it doesn't get merged
so check the distance
can someone help me with this string?
using UnityEngine;
public class PlayerController : MonoBehaviour
{
private Rigidbody2D rb;
private float walkSpeed = 1;
private float xAxis;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
Rigidbody2D = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update()
{
GetInputs();
Move();
}
void GetInputs()
{
xAxis = GetInputs.GetAxisRaw("Horizontal");
}
private void Move()
{
rb.linearVelocity = new Vector2(walkSpeed * xAxis, rb.linearVelocity.y);
}
}
i would print the distance to Debug.Log and check what is the min distance it can reach, and then use that value
Yeah I tought that too, but if in the future I want to make different size object it will be a problem, i think
i think distance will check between the center of the objects
the way you are doing
so maybe get the length or width, cut it in half and sum it to half the width of the magnet
and then maybe add a + 0.1 to that
and use it as the min distance to merge
!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.
and what's the issue, don't wait for us to read your mind
i tried to boot it up but it says: Assets\PlayerController.cs(25,13): error CS0119: 'PlayerController.GetInputs()' is a method, which is not valid in the given context
But where and how?
in the magnet code
you could ask ai maybe, or look it up on YT
Ok thanks
i don't even see that line there
exactly
xAxis = GetInputs.GetAxisRaw("Horizontal");
what is GetInputs
did you save the script?
oh it's there
Finished the getting started with unity tenplate
{
xAxis = GetInputs.GetAxisRaw("Horizontal");
}```
🧐
i turned autosave on
youre calling a method within itself
not even
it's not calling a method
it is missing ()
and it also returns void
im so confused as to what this code is supposed to do ngl
this seems like an overcomplicated way to make a simple input system using legacy input
movements for a metroivania i'm making
just use the new input system first of all
second, that function is completely wrong
I'm confident enough to make my own thing
Hello ! So im trying to make the following system :
- i can give to a GameObject "
Sphere" the amount of child (called "Muzzle") i want (1, 2, 100...)
When i run the a function "Shoot" in the "Sphere", all of the "Sphere"'s child (the muzzle) run a fonction.
So im trying to understand the getChild function but it doesnt work. Without having to give the Cube all muzzle as a gameObject, how can i make so that all the Cube's child called "Muzzle" (or with the same tag) can run the same function ? Thanks !!
you could iterate over all the children of a transform by iterating the transform
okay now the error is fixed but it says this now:
Assets\PlayerController.cs(11,21): error CS0118: 'Rigidbody2D' is a type but is used like a variable
That's a great idea ! Do i have to do it with FindObjectbyType ?
change this to rb
that's not what i said to do, is it...
you could use that if you want specific components though
how do i fix it?
change it to rb...
so i have to add rb at the end?
Hmm, i only want to run a function (Sphere > Muzzle > Shoot())
but i guess it is proper (and more useful) to learn how to do it properly now ?
you cannot assign a value to a type
and how would you get that function if you don't have the component that defines it
which one? there's like two of them
the one that's highlighted as an error. is your ide configured?
in that line, the start...
Right, that's the question. I don't really know how to make a loop that get a new muzzle (muzzle1, muzzle2, ...) everytime and then execute a function 😅
You did and you are right, the thing is that i don't know how to write it on C# 😅
(iterating the transform without using FindObjectbyType. Even with FindObjectbyType idk how to it, actually...)
option 1: iterate over the transform to get its children (which you could getcomponent on)
option 2: use FindObject**s**ByType to get all relevant components in the children
option 3: use a serialized array/list
do you know how to write loops in general? for and foreach?
I do know how to do loop ! Not for "foreach" but i guess it's easy to understand 😅
But you are right, "foreach" look way more convenient actually !
How do i make vs code my default editor for scripts?
why vscode btw
!vscode
If your IDE is not underlining errors in red or autocompleting code,
please configure it using the link below:
Because i always use it and it's the only thing i like to use
Edit > Preferences > External Tools
i will still suggest you to take a look at Rider tho
make sure you've configured it, that would include setting vscode as the preferred editor in unity
if you're referring to the default in your OS, that would be done however it is done normally for your OS
@subtle mulch honestly can you stop with this
it's quite unnecessary and frankly annoying
we don't need IDE wars here when they're all perfectly capable
No i mean for unity when opening scripts up in unity
yeah in preferences
like Zeni said
Wall check
also, i would suggest you keep auto file saving off
it can give you some problems, lol
you might
Why?
it helps with debugging
you have to make sure the unity classes and functions show up
They do
Actually i done everything in the link already
oh for link you meant the message link, lol
i tought you meant like an extension XD
Do i have to install dotnet with elevated priveleges?
Hey, so i'm trying to understand FindGameObjectsWithTag to get my Muzzles. But the print only give me GameObject[] despite 4 elements in the scene having the tag "Muzzle", may i have done something... Wrong ? 😅
Nope
i think so
that's just the type of the array, as the default ToString implementation. it doesn't give any info about the contents
Im currently updating form 6 to 10 which isn't a problem for my personal computer but when i wanna work on projects elsewhere that may be an issue
log out the length or loop to log the contents if you want to check that
shouldn't have to, no. you could even just use the .net installer tool from in vscode
Ahh yes that's what i want, and then, i want to execute the shoot() function in every of them. Am i in the good way ?
you shouldn't use tags tbh, magic strings are always a candidate for subtly messing up with no feedback or logs
I downloaded the installer from the microsoft website
Okay, here we are !
But now, how can i only scan the Sphere's child instead of the entire scene ?
use Transform.FindX (on the desired Transform) instead of GameObject.FindX
Ah, scary.. I should use FindGameObjectsByType as you've suggested ?
sure, or a serialized list/array
Are you talking to me ?
you need the latest SDK for vscode only.. other than that unity has its own version of .net you're using
but also with latest sdk you can make other / latest .net apps without unity. Like console apps etc
yes
runtime/cross scnes FindGameObjectsByType or DI
compile time , serialized reference
:(
'MuzzleScript' is a type, which is not valid in the given context
"FindAnyObjectBy__Type__" but "type" is not valid i don't understand 😅
right, that's not how FindAnyObjectByType works
read the documentation
you can't pass types as values in c#
Alright, i'll check the docuentation then !
types aren't first-class
Ohh that was the sdk i downloaded?
it takes arguments like GetComponent
or use serialized list/array as you've suggested if it's simpler ?
ideally
it's not simpler nor more complex, just a different way
I see, thanks for you're time ! I will try then after reading the documentation :)
btw If they are in the same scene and are not spawned in, Find is overkill
searching through all object when you can easily link through inspector ya kno
(this is in the prefab so serialized could work, but also it's in a shared object so this also makes sense in a way)
I couldn't save it to this shelf or add it.
you still didnt configure your IDE
How do I configure it? What happens when I configure it? What are the advantages?
you were linked to how
you get error highlighting telling you what's wrong and sometimes how to fix it in your ide
you get meaningful intellisense (autocomplete) suggestions
how do i do it
If your IDE is not underlining errors in red or autocompleting code,
please configure it using the link below:
and dont crosspost
stay in one channel
tbh you're in way over your head with project type rn..
does not appear
you're only looking at the packages that are in your project
Where do I look then?
in the unity registry. have you never installed a package before?
hint: you clearly have considering you have cinemachine installed
I'm going to install visual studio editor, man, it doesn't appear here, where can I find it?
prove that it doesn't appear there
My friend, shut up, I think you can go to sleep.
i told you where to find it, you said it doesn't appear there. so prove that.
ok buddy, just shut up
lmao telling people who are actively trying to help you to shut up is a good way to not get any help at all
i agree
this behavior isn't tolerated here, you better straighten up. You lucky you get even this far with help
hows it make sense to be an asshole to people who even try to help you
I asked this same thing 30 minutes ago
why are you bothering to help someone actively insulting you
yeah I just chalk some people to "hopeless to help" and move on . Its too bad it keeps showing me new messages in chat and have to read this crap
he did to me too XD
Hey again, so i've finally managed to get all my GameObject's with the Muzzle tag.
I know this is a pretty messy way to do it but i'm too bad to understand any other way of doing it :(
void Start() { MuzzleAmount = GameObject.FindGameObjectsWithTag("Muzzle"); print(MuzzleAmount.Length); }
The issue is that it look for the entire scene (as it should), but i only want my "FindGameObjectsWithTag" to look for the Sphere's child. How can i achieve this please ?
didn't i already answer this
I would be ashamed if it was the case, i had to go very quick so i probably missed something.. Sorry ! I'll read the conversation !
Oh, you did. The reason why i didn't used it is because 'Transform' does not contain a definition for 'FindGameObjectsWithTag' and despite watching tutorials about FindGameObjectsByType i did not manage to make it work so i was lost...
Sorry for the inconvenience 👍
make sure you're using an instance and not the actual type Transform
it's an instance method
also weren't you using FindObjectsByType
hm wait hold on
Following the documentation, i did this :
`public class EnemyScript : MonoBehaviour
{
public int shootAmount;
public int shootLoop;
public GameObject[] MuzzleAmount;
public Transform myTransform; // Doesnt work
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
MuzzleScript MuzzleAmount = (MuzzleScript)Transform.FindAnyObjectByType(typeof(MuzzleScript));
}`
Here, my goal is to store every game object that are a muzzle.
Which give me no error, but does not really work whatsoever...
ah ok, i misremembered, only Find exists as a analogue just for children
this would be GetComponentsInChildren
for asking about mesh generation should I ask in #1390346827005431951 or #1390346776804069396 lol
code general i think
it's not a code question per se, but about how unity renders tris so thats why i didnt know
ill just ask in code general and see what happens ig
ive never done anything with mesh gen so
ah yea, i just can't find a straight answer online about what the winding order is
some say CW some say CCW, but in the same thread people say it's CW people say CCW isn't common when afaik it is
and see how it comes out
I would but both seem to work and I don't know how to visualize the normals, and I don't want to run into issues if using a shader that needs normals, etc.
the order should just "flip" the triangle
oh actually I can just write a shader that colors it based on the dot of the view to the normal why didnt I think of that
on which side you can see it
yea, what confuses me is that I can see it with either order lol
try to make a cube and see
I'm only on quads lmao
also im doing it in burst which is a little nasty compared to normal probably
nah
ok well I figured out both work for me since the quad I'm drawing is done with a cross product so it can face Camera.main, so CW or CCW depends on the cross product lol... question not answered but problem solved i guess
Hello, i've written this code :
{
allChildren = new GameObject[parentObject.transform.childCount];
for (int i = 0; i < allChildren.Length; i++)
{
if (parentObject.transform.GetChild(i).gameObject.tag == "Muzzle")
allChildren[i] = parentObject.transform.GetChild(i).gameObject;
}
}
public void UseMuzzle()
{
for (int i = 0; i < allChildren.Length; i++)
{
if (allChildren[i] != null)
allChildren[i].Shoot();
}
}```
> allChildren[i].Shoot();
Im trying to access the "Shoot" function of the Children with the "Muzzle" tag, but it does not work. How can i fix this please ?
how exactly does it "not work"?
that is not useful info
are you getting a compiler error, a runtime error, wrong behavior, no behavior?
Sorry, i have the error :
'GameObject' does not contain a definition for 'Shoot' and no accessible extension method 'Shoot' accepting a first argument of type 'GameObject' could be found (are you missing a using directive or an assembly reference?)
right, so you're storing gameobjects and then treating them as if they were something else
or.. just use GetComponentsInChildren to begin with....
@errant breach i gotta ask, why are you asking here if you're not gonna use the advice lol
did i say something wrong or why the double reaction
that's not correct, and that's not a transform
of course you can call methods on transforms?
was there meant to be another qualifier there
without using the Componeent name?
transform.GetComponent is itself a method
I completly forgot due to the rush sorry 😅 i'm now using it !
you can call methods on transforms, you can't call methods that transforms don't have on transforms
and same for GameObjects which were actually used there
It finally work after 5 hours...
Gif of a crying dog
It's so beautiful when it dare to work..
Thanks guys for helping beginner and be patient :) i will now try to be more careful with suggestion and be less precipitated !
Is there a faster way to build for android? It takes up to 13 minutes to build for android.
thats just not what it says it does
wdym
can anyone help me get rid of this status because it's preventing autocomplete from autocompleting unity part of the code
!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
thanks
Hey I'm trying to make a Third Person character controller for my Survival Horror game in the style of Resident Evil 2 Remake, if anyone can help I would appreciate it, I tried looking at tutorial after tutorial and none of them work or are not in the current version.
if you are new to unity, learn it through the Essential Pathway
Help with what specifically?
Making a Third Person Character Controller in the style of the Resident Evil 2 Remake.
Well for that youre really going to have to rely on tutorials or guides on how to create third person character controllers
nobody here will sit with you and guide you directly on what to do
we can help if you get stuck at any point, or have any bugs or errors you cant solve
but other than that, youre either going to have to find a suitable tutorial, or use an asset
Well all the tutorial's that cover this are out of date with the current version of Unity.
in what way
Out of date in which capacity
really the only major difference would be the input system
but thats a non issue
In terms of the code and don't cover the current input system, as well as the code on how to implement that into the game.
right, so it is a non issue
because A. you can just use both input systems
and B. its really simple to refactor it for the new input system
Also when it did end up getting there, there was a bug.
right, and thats what we are for
if you have bugs and issues in existing code, we can help you solve them
When it comes to the speed and movement I set it to 5.0f and 10.0f
before you continue, if its something specific
we would need to see the code first
understand what you are trying to do
what behaviours are happening etc.
Give me a minute.
📃 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.
👆 use the sites
You know what I'm going to do the essentials pathway again, so that I can get it right.
quick behaviour question: for some reason if the variable in the conditional branch node is false, the behaviour graph gets stuck like this forever. why is this?
it should just go through the false node shouldn't it?
if the variable is true it works fine
If your IDE is not underlining errors in red or autocompleting code,
please configure it using the link below:
• Visual Studio (Installed via Unity Hub)
• Visual Studio (Installed manually)
Wrong one. There was a command for visual scripting I think. 🤔
this is the behaviour package, not visual scripting (not sure how similar they are)
Oh, alright. Well, might want to check their docs for what that wait node does.
wait for any "activates its child when any parent starts this node." it's doesn't start when the parent's status is successful/true, but when the parent starts it irrespective of its status
Not familiar with the visual scripting nodes so best I can say is #1390346878394040320 or what dlich is looking for.
Also your deciding and performing actions using nodes, which is visual scripting (?) I still have more to learn.
but the branch on node gets stuck in status.waiting forever as can be seen in the screenshot
ah ok, I'll post behaviour questions there in the future
i dont think that channel is what this is for
Yeah, I assumed it was visual scripting, but that's different
I've never done visual scripting in unity so I'm not familiar with the look of it. Figured it was Unity's visual scripting thing
My bad
Never used the behavior package. Might want to Google or look through the forums.
sadly google rarely has good results for the behaviour package, it seems a bit under-used
I've also done pretty much the exact same thing in a different BT and it works, so I'm a bit lost lol
is this a help channel?
Yes. This is the beginner coding help channel.
If it's not related to code, you can #🔎┃find-a-channel or ask in #💻┃unity-talk if you're unsure.
what is this system?
unity behaviour
i never hired about it it's something exist only in last unity version ?
to be fer the so many unity package it's only natural i don't know shome off those.
or it's in astets store ?
yap it needs unity 6 and the project I'm working now use unity 2021 or something.
probably this 1 off the reason i don't using it alose for what i have seen this spefide mostly for npc behavior if understanding correctly.
hey heyy, apparently my visual studio isnt connected with unity, because it doesnt show me options to choose from :/ anyone know how I can fix that?
!vsc
There's no command called
vsc.
!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
thx thx
You're very likely missing a step. Check to see if you've got the Visual Studio Editor package.
im literally sweating because of all those stupid tabs and windows and cookies and all that omg
Another thing is to click the "Regenerate Project Files".
it works noww thanks yall
you are funny
**I do not understand are the async methods/tasks adapted for use in Unity? **As I know not. They seem to take more resources to summon, right? Or do I not understand anything?
For instance I use Coroutines and search an answer to my question 'cause IEnumerator is just simple and seems... not wrong and not correct used in common situations I guess? They are done for reading List, arrays and another shit in System library.
I use them as timers(sometimes not) and I think its wrong.
And yes I know about UniTask's, I want find a solution within the limits of possibilities of Unity self.
guys i have a code like this:
press a = left
press w = up
press a & w = up&left ( diagonally )
but the press a & w doesnt work :/ what do I need to do?
if (Input.GetKeyDown(KeyCode.W) == true)
{
myRigidbody.velocity = Vector2.up * 10;
}
if (Input.GetKeyDown(KeyCode.A) == true)
{
myRigidbody.velocity = Vector2.left * 10;
}
if (Input.GetKeyDown(KeyCode.W) & Input.GetKeyDown(KeyCode.A) == true)
{
myRigidbody.velocity = Vector2.left * 10;
myRigidbody.velocity = Vector2.up * 10;
}
Youre setting the velocity to those values so they overwrite each other for diagonal inputs
how do I make it diagonally then :o
just & in between or is that something else
Ig for the way youre doing it now you could add the vectors together
damn I'm too stupid for that, I have to learn all that first
float up = 0;
if (Input.GetKey(KeyCode.W)) up = 10;
if (Input.GetKey(KeyCode.A)) left = 10;
//if (Input.GetKey(KeyCode.D)) left = -10;
//if (Input.GetKey(KeyCode.S)) up = -10;
myRigidbody.velocity = Vector2.left * left + Vector2.up * up;
what does float do?
and how you make the message boxy?
It creates a variable, so you can reduce the amount of code.
ah damn I only put 2
thx thx
i dont understand at all tbh
If you don't know what variables do, I would highly recommend learning the very basics of C# before starting to code in unity
yeaa I am trying to learn that rn
Also .normalize the vector so that walking diagonally doesn't make you walk faster than just forward/sideways.
Yes, that's the next step.
... or just use the new input system which can do the normalization automatically and you don't need all those ifs either
And even if you want to do it that way, ClampMagnitude is probably better than .normalized
Either input system would be a step up from here but I think if they dont know what a variable is what they have is fine haha
That should be the first step, if you don't know variables, start by learning those and the other basics programming stuff (variables, functions, loops and branching, basics of OOP potentially)
Anyone?
You have the answer right there, Unitask fixes those issues, you can ofcourse rewrite what UniTask does but you would be reinventing the wheel
Unity has Awaitable for async methods but its still miles behind UniTask
Tasks in general work... dont expect them to work with everything though
Another method would be to use Unity's job system, which can offload work, but its not in the async style
I have this here:
if (Input.GetKey(KeyCode.W) & Input.GetKeyDown(KeyCode.Space) == true)
{
myRigidbody.velocity = Vector2.up * 10;
}
if (Input.GetKey(KeyCode.A) & Input.GetKeyDown(KeyCode.Space) == true)
{
myRigidbody.velocity = Vector2.left * 10;
}
I dont want to be able to spam it, is it possible to put 0,25 sec cooldown in it?
You will be needing a new variable for that.
soo float pause = 0,25 at the beginning?
it's not that simple, no
:c damn
you have to write the behavior you want to achieve
(honestly that seems like poor UX though, you're basically introducing input lag)
in other programming stuff I could do "pause all = 0.25" at the end of the if function, and it would pause the script for 0,25s
in coroutines? you could do something like that, sure
ohy what is coroutines?
wait hold on, i mightve misunderstood
is this for debouncing movement input, or having cooldown for a specific action?
what's "space" supposed to do there
w a s d is for direction and space is to activate the dash
and I want to have a cooldown so I cant dash unlimitedly
ah ok, you could have a timer variable deciding when you can dash then
there's quite a few ways to do it
a timer based on the Update loop could store the next possible dash and check the current time against that, or store the previous dash and check if the current time is past the cooldown after that
a timer based on a coroutine could use WaitForSeconds to set a boolean field
they're pretty much all the same difficulty, just different ways of doing it
in my head I thought of something like:
dash as a variable = 10
and something like if I press space -> dash variable -10 & wait 0.25 -> dash variable +10
well with that you wouldn't be using a number
i dont understand :o
if you just had 2 states for the variable you'd just use a boolean
the logic you described would be the third option
Uhh what is a boolean
Hello, im trying to make my enemies rotate toward my player but for some reason, they look at the opposite way
{
Quaternion targetRotation = Quaternion.LookRotation(playerGameObject.transform.position - transform.position, Vector3.up);
transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, 0.1f);
}```
After many attempts, i don't understand how to fix it. Do you have any idea ? Default enemy rotation is (0, 0, 0) in game, it is (0, 174.45, 0)
it's a type that holds true or false. you should probably go learn c# basics
there are resources pinned in this channel
btw, that's wrong lerp
Applying lerp so that it produces smooth, imperfect movement towards a target value.
what camera position is this? is this in a 3d world pointing straight down
Yes it is !
is the forwards direction of the enemy correct, relative to the mesh?
Oh its.. Not..
But i can't fix that because it will break the animations. Can i just change the Quaternion.Slerp(transform.rotation, targetRotation, 0.1f); with like a -180 somewhere so that it rotate correctly ?
you should fix that, this'll probably keep coming up lol
you're right..
if the animations are self-consistent to always be backwards, you could have the mesh have a parent that faces the right direction, and the mesh is backwards in the parent
static class MessedUpValuesManager
{
public static float wrongRotationForAnimations = 180;
}
😉 Its a joke, dont! 😄
the actual workaround would just be to negate the direction before you put it in the LookRotation
or apply another Euler rotation
If its coming from something like blender, it might also just be as easy as reexport with correct axis selection
yeaaa but learning the basics is something that comes along the way
no amount of experience can compensate for the absolute fundamental knowledge.
Hello anyone can help me ?
!ask
:thinking: Asking Questions
:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #🔎┃find-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.
-# For more posting guidelines, go to #🌱┃start-here
yeaa but I just want to make a tiny little minigame :o learning all the basics eventho I only need 5% takes way too long
to whom ?
just ask
and trying to enlighten yourself to the 5% whilst refusing to actually go learn will take even longer.
like here, you didn't know about booleans until i told you
if you went ahead and worked on it without doing any research, you'd just be shooting yourself in the foot, making your own project harder
like i am programming my own game on unity platform soo while i was renderring it out my electricity goes and and that time my rendering was not completed soo i lost my game data how cna i recover it ?
🥺
the rendering data was lost? or what exactly?
yeaa but that makes it funnn c:
artificially giving yourself problems is fun? there's enough problems to solve already lmao
i am new how can i check like my maps of my game and alot of things
us needing to help you with your own self-imposed challenges is not fun
no no, I just love learning on the way yk?
with trial and error
your maps should be saved as a scene file
while that process i was not using any cluade just using my hard disk for storage tho
that's cool for more advanced stuff when you already have some experience. you need fundamental knowledge in order to actually get anything useful out of trial and error.
for programming full game
@naive pawn sir can you help me figure out thats means me alot from you
Please dont randomly ping people
anyone who passes by
Anybody who has time right now, there is no specific person
the thing is I learnt all those programming stuff already 3 years ago, so on the way I am just refreshing yk?
...you asked what a boolean was...
Describe what you were doing before your power went out and then describe what you are not finding now
never heard that in my life tho

if you've already learnt some stuff, then sure, skip over the parts you know. but at least go actually check the fundamentals.
can someone help me fix this issue? i litterally followed the instructions of the tutorial correctly
InvalidOperationException: You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings.
UnityEngine.Internal.InputUnsafeUtility.GetButtonDown (System.String buttonName) (at <bb2309881ca84e6d8dece79bc84459be>:0)
UnityEngine.Input.GetButtonDown (System.String buttonName) (at <bb2309881ca84e6d8dece79bc84459be>:0)
PlayerController.Update () (at Assets/_Unity Essentials/Scripts/PlayerController.cs:26)
(ignore the rigidbody part)
!input
To set Active Input Handling, go to:
Project Settings > Player > Active Input Handling
• Input Manager (Old): Use the original Input settings.
• Input System Package (New): Uses the new input system package.
• Both: Use both systems.
thanks
sir are you there ?
you gotta give us some info to work with
Don't pester people please, you haven't actually asked a question.
i want a serious help sir i am not able to find someone who can actually help me to figure out from
if you ask the question and provide info, we might be able to help
Ask a question, or don't post. Simple as that.
is he the only guy who can help
no-one can help you if you don't give any info about your issue
just do what i did here
So ask the question and people who know it might answer.
what's vector2 and vector3?
when my ufo bumps into a wall it starts spinning around, how do I disable that it rotates?
One has 2 numbers, the other has 3.
You can probably figure out which is which
(x,y) and (x, y, z)
thanks
lock the rigidbody rotation
soo basically i was rederring my game data in between my power gone off and due to in between shutting off my pc my data of my game was lostt
how can i recover it ?
Unless you have version control, you cannot.
4 - 5 months cannot literally go poof in 1 second
unless the whole drive got nuked
Are the files literally gone off your PC?
yes from harddisk
30gb around
HOW
Might be a hard drive failure
yeah but it still boots
Lost sectors
Well, take it to a shop and see if they can recover anything. But otherwise, there's nothing you (or we) can do.
no just during renderring my pc shut down
It still could
Hard drives can fail incrementaly
best bet is to take it to a shop that specializes on that
also, is it an HDD or SSD
things change there
Also how do you work on a project for half a year without any version control
Or at least any local back ups
That was just a disaster waiting to happen
i still find it strange that ONLY those files got nuked
this may sound obvious but have you tried recovery apps
and not anything else
Did they say that?
Or you were baking lighting?
did you lose ANY other file on the pc?
What
i think he means scene
yes
it's the only file left there
scene
Theres no other files in the project?
how can you lose a whole 5 month project like that
which other files?
the file was of 30gb and only 7gb data left
i find it very strange in fact
Just read up its like 15 messages...
aren't scenes text files
how do you get a 30gb scene
adjust folder
are they completely gone or are they corrupted? maybe check with a special app
what is the adjust folder...
yes I read and I don't understand
Guys i think the entire project was 30gb
yeah
yea
Neither do we tbf
he just lost 23 gb worth of game storage
for some reason
but i dont getting you guys i just can say that during baked and renderring time my pc gonna shut
sooo what to do ?
my maps files audio files
alll gone
take it to a repair shop or try with recovery apps
try to recover the files
Well i think it was almost certainly a drive failure
how ?
Try some recovery programs, other than that, its a lesson learned
only on the project files tho?
with an app like recuva or something
They said they lost other files 
alright I thought for a moment it's a scene
he just said "adjust folder"
What does that even mean
idk
but that's the other folder that it was gone
also, i never seen drives that nuke specific sectors when a power surge occurs
you could easily try to repair the filesystem tho
1 in a million i guess
the thing i think happened is that the indexes to those files got nuked
and windows now does not see the files
while they are actualy still there
20 GB can not disapear
it is from my disk
after power off
not before that
google how to run windows filesystem scan and repair
and it will prob help
you have to make it repair all the indexes to those files
prob not
if it is an HDD try to hear it when working in case
if you hear a clicking sound, move ALL the important data out ASAP
if it's an SSD, idk, prob check SMART
just backup anything to another drive
i have 2 HDDs that i use for games and backups
while my os and dev stuff resides in 2 NVMEs
my all unity work projects and file were saved in my hdd soo right now its not in that it almost contains of 30-40gb of materials , texture , scripts, prefab, UI, UI images, doo die sprities and more
how can i find them to re assemble ?
i told you
google how to repair the windows filesystem and its indexes
whats help by doing it ?
in recovering ?
but sir my hdd is working fine and it have like no damange it just because of power off the pc during that process
Basically: if you think it’s worth the money then take it to a professional to see if the data is recoverable. Otherwise just take this opportunity to reflect and learn why you should use version control
it's NOT the hdd
pls read
it's the filesystem
I checked in CrystalDiskInfo, both SD and HD are correct.
well, that's a separate thing
Okay, this is beyond Unity at this point, and it's not even a #💻┃code-beginner related question.
pls re-read what i said
Don’t bother
@sharp cedar Make a thread in #💻┃unity-talk if you want to keep this going, thanks.
let us help him
And you can
ok sure because solution not done yet
we are this close
@subtle mulch buddy can you come in thread?
why not screen share? that may speed up the process
not really
done see unity talk
it wont jump for some reason, could someone just have a look at this pls?
well, maybe if you send the script
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
!screenshots
No
Be mindful, if someone requests your code as text, don't send a screenshot!
you should only have 1 Move call per Update
check if the if condition is passing when you expect it to. if not, check which part is false.
is it fine if i replace Update with FixedUpdate?
prob not
they do different stuff
what do you wanna put in it?
a collectible rotating
if it's physics stuff, then yes it was made for it
nah it's just transform.Rotate
then keep it into normal Update
is there a particular reason? cuz i don't want it to turn at the speed of sound when you have 300 fps
that's why you use Time.deltaTime
ooooh that's why it's multiplied by that
yep
depends on what you're using it for
hello, how do i make the object i grab be more attached to the magnet? I used a fixedjoint for the object, and i cant make that the magnet will have more force because it has similiar results, and changing linear damping doesent work either
set the object as the parent maybe?
no or else the object will trapass walls and be too rigid too
higher mass for magnet with added force?
doesent work and makes the magnet movement really ugly and hard to control
u should probably ask the peeps in #⚛️┃physics
how can i make night more dark? i want the objects to appear darker when the Directional_Light faces north (already fixed skybox)
this is a code channel, try #1390346776804069396
Why can't I destroy my gameobject...?
using System;
using Unity.Mathematics;
using Unity.VisualScripting;
using Random = UnityEngine.Random;
using UnityEngine;
using System.Collections.Generic;
public class MapTileGeneration : MonoBehaviour
{
public GameObject Tile;
public Material TileMaterial;
public float ColorVariation = 3f;
public int MapSize = 0;
public Transform Map;
private Transform CurrentMap = null;
[ContextMenu("Generate Map")]
private void GenerateMap()
{
if (Tile == null) return;
CurrentMap = new GameObject().transform;
for (int x = 0; x < MapSize; x++)
{
for (int z = 0; z < MapSize; z++)
{
float CellDiameter = 2;
Vector3 TilePosition = new Vector3(x * CellDiameter, 0, z * CellDiameter);
GameObject NewTile = Instantiate(Tile, TilePosition, Quaternion.Euler(-90,0,0), CurrentMap);
NewTile.GetComponent<Renderer>().material = TileMaterial;
float RedA = TileMaterial.color.r + Random.Range(-ColorVariation, ColorVariation);
float GreenA = TileMaterial.color.g + Random.Range(-ColorVariation, ColorVariation);
float BlueA = TileMaterial.color.b + Random.Range(-ColorVariation, ColorVariation);
float AlphaA= TileMaterial.color.a;
Color32 NewColor = new Color(RedA, GreenA, BlueA, AlphaA);
NewTile.GetComponent<Renderer>().material.color = NewColor;
}
}
}
[ContextMenu("Destroy Map")]
private void DestroyMap()
{
if (CurrentMap != null)
{
Destroy(CurrentMap.gameObject);
}
}
}
When I try to destroy CurrentMap, nothing happens
I debugged.log and it did print something so the condition is met
But it isnt getting destroyed
if you add a debug.log containing context, does it point to the gameobject you expect? also consider giving that gameobject a name so it's easier to identify
Unless you serialize the reference to CurrentMap, you're going to lose the reference when the domain reloads.
It is not null
that's not what i asked
anything in the console window? Show it
No errors there bruh
I dont know what you asked
but what is?
when is GenerateMap called?
you said you put a log - where?
so it's probably just null then
I removed it because it was printing
but... we're in the middle of debugging
No bro, it went throgh the condittion
I think the fix here is to serialize this reference
Watch the video man
Guess I will try that
How tho
make it public or add [SerializeField]
I did, but the function GenerateMap is never called based on the code you provided
I pressed the button
Hard to tell, the drag click made me think 'destroy map' was selected, my bad.
i asked, if you add context to the debug.log, does it point to the right gameobject
context is the second argument
I just printed the gameobject
And it printed its name
how
This ticks up to 18 when you try
click on the thing I screenshotted
OH MY
I dont know what half of those mean bruh
Ok so it tells me that materials are wrongly used
ah misread initially thought you had an issue with GenerateMap not destroymap
and that I should do this during play mode
well, there's your answer
wait let me try in play mode
Ok it works
Thanks guys
I could not have figured this out without you
I mean, this part is pretty clear
*once visible. <- coming from the guy who misreads lol
Any idea why setting Camera.scene does not limit the rendering to the assigned scene?
From Unity Docs "scene - If not null, the camera will only render the contents of the specified Scene."
I am creating a new scene in code, moving the camera and objects I want to render to that scene and then setting camera.scene to that scene
The camera outputs a render texture, which I display in UI
But it always renders from every scene, not just the one I am trying to limit it to
Currently, only Scenes created by EditorSceneManager.NewPreviewScene are supported.
You didn't read the rest of the page
It's basically an editor only feature they hacked in to support the editor preview scene stuff
The correct way to cull things is to use layers
Ah yeah I should have clicked through
Sucks that its not useable outside of editor preview
I was hoping to avoid having to resort to layer masks
That would certainly be an interesting feature to have
The way I usually do it is I just offset the transform root by a large number
Like 10,000
I was hoping this would be a cleaner approach 😛
YOu can do that too but that has floating point precision issues doesn't it?
Not really
at least with a super high distance like that
Yeah if I had like 1,000 cameras I want to render and offset them by a crazy high amount then maybe
The 10,000 was an exaggeration anyway
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
I'm having a problem with my object rotation not being moved. I use [[[ transform.rotation = Quaternion.RotateTowards(transform.rotation, targetRotation, roombaRotateSpeed * Time.deltaTime); ]]] and for some reason the rotation it does is so small that it's basically not even rotating to the target. Can someone help me figure how what's going on with it?
a rotate speed of 2 means "2 degrees per second" with the code you have
that means it would take 90 seconds (a full minute and a half) to fully turn around which is 180 degrees
Not only that
but you are only calling transform.rotation = Quaternion.RotateTowards(transform.rotation, targetRotation, roombaRotateSpeed * Time.deltaTime); ONE TIME
so you are only getting one frame worth of rotation. So you'll only really rotate something like a fraction of a degree, and only once.
Then you're waiting 6 seconds and doing the movement
you need to use a loop here (with a yield return null inside it to wait one frame each time) to continue rotating each frame until it is complete
so you have two problems - your code is wrong, and your rotation speed is tiny
Hah! I realized I can just slice on Z axis using camera clipping planes
A lot cleaner than adding a crazy offset since I can just increment by 1
that works if your game is 2D or can be confined to small z areas, yeah
Yes, which it is 🙂
Hello everyone, where can i ask questions about Splines ? I cannot find documentation online so i dont know how to start my splines when StartOnAwkae is false ! Thanks
splines documentation: https://docs.unity3d.com/Packages/com.unity.splines@2.8/api/index.html
and presumably you are referring to the SplineAnimate component, which does have a PlayOnAwake property (which you referred to as StartOnAwake) as well as the Play method
how do i make this work? private float jumpForce = 45;
make it work how? that's just a declaration of a float variable
do i need a following string to it?
wtf does that mean
be more specific dude
You declared a variable, what people need to know is how you use it. Within update, etc.
if you want other classes using it, make that class a child class or set the variable to public
i don't know how to write the line for it to work fine
what does it mean to "work fine" here?
context is king
bro explain how do you use that variable
using UnityEngine;
public class PlayerController : MonoBehaviour
{
private Rigidbody2D rb;
private float walkSpeed = 1;
private float jumpForce = 45;
private float xAxis;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start() => rb = GetComponent<Rigidbody2D>();
// Update is called once per frame
void Update()
{
GetInputs();
Move();
}
void GetInputs()
{
xAxis = Input.GetAxisRaw("Horizontal");
}
private void Move()
{
rb.linearVelocity = new Vector2(walkSpeed * xAxis, rb.linearVelocity.y);
}
}
!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.
do i missed something?
There's no command called
screenshot.
can you provide literally any context at all
i don't see jump force ANYWHERE
jumpforce is never used in the aforementioned script.
I think he's trying to jump
but doesn't have a listener for spacebar or any up input
What are you actually trying to do? That's where you need to start.
i'm making a metroidvania. i was making the jump code but i don't know how to write the rest
Ok then why didn't you ask "Hi how do I make jumping work in my metroidvania"?
sorry
did you set up the input action map correctly
input action map? you mean input manager? then yes i did
they aren't using the input system
oh ok
First you need to listen for the input, there are different solutions for this. Either the new input system or Input.GetKeyDown(Keycode....) etc.
Then have that trigger a function.
Said function should move the player / play an animation / etc.
how do i write it?
if you just want someone to write it, why not look up a tutorial?
if(input.getkeydown(keycode.a) { // do thing }
i did but it only wrote this single line
no, definitely not true
unless the tutorial was just an ai overview of something, then you didn't actually pay attention tot he tutorial. there's no way an actual tutorial would only show a single variable declaration as "how to jump"
what kind of tutorial was it? a video or a website?
Download the project files here: https://www.patreon.com/posts/81074402
Read the accompanying article here: https://blog.terresquall.com/2023/04/creating-a-metroidvania-like-hollow-knight-part-1/
Ever wanted to create a Metroidvania like Hollow Knight? In Part 1 of our tutorial series, we will go through how to create the basic walk and jump mo...
this was the video
There's 5 whole minutes of the viddeo in which they set up the jumping stuff. Making that variable is only at the very end of it
this video is only basic movement (walking and jumping) and camera
maybe he said something he forgot in the comments or the other parts
Seeems like you didn't watcht the video
because it's all here
My suggestion, go back and watch the whole video
i'm literally watching step by step
he wrote jumpforce 45 nd then he showed it jumping
"I did it exactly like the tutorial so why does theirs work and mine doesn't" counter:
Number of times it wasn't exactly like the tutorial: 201
Number of times it was exactly like the tutorial: 5
Number of times the code literally did not exist: 1
2022-07-19 to 2026-03-02
maybe you put the code in the wrong brackets
Yeah and then after that he shows you how to make it work.
Keep watching lol
most of the times, tutorials have code on GH
Yes, this is what we like to call a "demonstration"
You should try actually listening to the words instead of just vomiting the code onto your IDE
okay and? it's my first time coding. a little bit of understanding on my side instead of making fun of me
honestly, if you think that declaring a single variable and doing nothing else is enough to make it jump you should really consider learning the fundamentals of the language because you seem to be at a level of understanding below where you need to be in order to follow this tutorial
maybe keep your fingers off the arrow keys next time

"And then he set the oven to 400F and showed a cake. I tried it, but when I opened my oven, there was no cake inside."
I'm not sure what it is about game development, but in any other skill, following the instructions from the start just seems like the most common sense thing to do.
I don't think anyone is meaning to make fun of you.
Aside from etiquette, it's moreso that you should fully inform yourself and research the topics your covering as they can be found inside of the unity forum, etc.
@zenith temple Please consider starting with https://learn.unity.com/pathway/unity-essentials You'll get better understanding of the engine and basics of programming before jumping into a project.
And you'll know how to ask correct questions as well
Expanding on this, The Counter™ isn't just made up. It's an actual running tally of the number of times that's been said, mostly as a way of showing just how common it is for people to say that
Every single number is an actual person doing the same thing that I, personally, have seen in this server
Hi all!
You're using a Rigidbody, so to 'Jump' would be rbody.AddForceY(jumpForce) upon input.
i fixed it but now it says this: UnassignedReferenceException: The variable GroundCheckPoint of PlayerController has not been assigned.
You probably need to assign the GroundCheckPoint variable of the PlayerController script in the inspector.
UnityEngine.Object+MarshalledUnityObject.TryThrowEditorNullExceptionObject (UnityEngine.Object unityObj, System.String parameterName) (at <dc764b59c049482b93bebc78a7e33a04>:0)
UnityEngine.Bindings.ThrowHelper.ThrowNullReferenceException (System.Object obj) (at <dc764b59c049482b93bebc78a7e33a04>:0)
UnityEngine.Transform.get_position () (at <dc764b59c049482b93bebc78a7e33a04>:0)
PlayerController.Grounded () (at Assets/PlayerController.cs:43)
PlayerController.Jump () (at Assets/PlayerController.cs:57)
PlayerController.Update () (at Assets/PlayerController.cs:28)
have you assigned the GroundCheckPoint variable of the PlayerController script in the inspector?
You probably need to assign the GroundCheckPoint variable of the PlayerController script in the inspector.
that is not the inspector, nor is it the variable you need to assign
If you did, show the inspector of your player controller
Jsut FYI the tutorial tells you how to do this at 8 minutes 13 seconds
The key is to just follow the tutorial closely, don't skip anything
this part?
no
the part where he assigns it in the unity editor
at 8 minutes 13 seconds
this looks like it isn't configured
yeah that's vscode isn't it. vs would have white fields
!vscode
If your IDE is not underlining errors in red or autocompleting code,
please configure it using the link below:
configure your ide @zenith temple 👆
please check where my angular math isn't mathing
oversimplification:
centripetal_force = getHomingVector(target);
centripetal_force = Vector3.ProjectOnPlane(force, rb.linearVelocity);
if(centripetal_force.magnitude / speed) > max_angular_velocity * Mathf.Deg2Rad)
{
Vector3.ClampMagnitude(centripetal_force, max_angular_velocity * speed * Mathf.Deg2Rad);
}
rb.AddForce(centripetal_force, ForceMode.Acceleration);
rb.linearVelocity = rb.linearVelocity.normalized * speed;
turns much sharper than
Vector3 to_target = target.position - transform.position;
Quaternion target_rotation = Quaternion.LookRotation(to_target);
transform.rotation = Quaternion.RotateTowards(transform.rotation, target_rotation, max_angular_velocity * Time.fixedDeltaTime);
rb.linearVelocity = transform.forward * speed;
while I expect that to be the other way around
if(centripetal_force.magnitude / speed) > max_angular_velocity * Mathf.Deg2Rad)
{
Vector3.ClampMagnitude(centripetal_force, max_angular_velocity * speed * Mathf.Deg2Rad);
}
trying to clamp angular velocity here
should that work like that?
I might need sleep, shouldn't it be centripetal_force = Vector3.Clamp etc
Hello everyone !
I have a script, EnemyScript that make private AttackScript attackScript; on start.
EnemyScript & AttackScript are both on the same gameObject.
But when i try to do :
attackScript.timeSinceLastAttack += Time.deltaTime;
I get the error :
NullReferenceException: Object reference not set to an instance of an object
EnemyScript.FixedUpdate () (at Assets/_Scripts/Enemy/EnemyScript.cs:114)
Which is surprising as the link is well made... Do you have any ideas how to fix it please ? As always, thank you !
yeah right, I might need sleep...
components don't magically fill references just because there on the same gameobject
you need to connect them via assigning in inspector or in code with getcomponent
@errant breach
oh i might have misunderstood how it work then, thanks !
Where do you assign a value to attackScript
just like that, hoping that "components magically fill references just because there on the same gameobject "
yeah youre either going to have to manually assign it in the inspector if its a serialized field, or assign it in the code
you just created a field for attackScript, its current value is null
you can also do both via assingning components on OnValidate
OnValidate() is not ideal for that
nullcheck and then trygetcomponent
what would be better?
public assignment or in awake
if by public assigment you mean assinging that in the inspector, onValidate would do that?
noticable downsides?
Start or Awake
but why
OnValidate() runs common-ish enough to where it's unneccasary code being run that could scale up in certain scenarios
Because OnValidate runs in the editor which can slow down your editing, and can lead to stale references for things like prefabs getting copied around
I don't get the stale reference thing but I guess it make sense that OnValidate runs freuqently but... I thought it's meant for that sort of stuff
you would use Reset for doing serialized references automatically, OnValidate runs way too frequently
what for is it really
validating inspector values
Im also breaking my mind on such a werid error...
AttackScript tries to acces a function in EnemyScript with a parameter.
The EnemyScript is supposed to take the parameter, and use it to change the animation.
- Usually, i don't have to put the parameter as "string". I tried but it got me error "cannot find animation with that name". Do you know why it happens ?
⚠️ i TRIED using string !!
Not : es is the reference to EnemyScript, and it's not properly defined 👍
If you move a prefab without actually opening it, OnValidate hasn't run yet, and so that value won't update to the one on that object. If you run the game, the variable is pointing to the old component (the one on the original prefab)
like what Range/Min/Max do, but with more control
Like they said it's an editor only thing
What is ATTACKLOAD?
oh no
by "moving a prefab", do you mean renaming/moving the file?
Yes, in the file system
Sorry, i went too fast. Here's how it work
doesn't unity watch for that and move the meta file too, so you wouldn't have to set any new references, including within the prefab?
But if it gets set in OnValidate and isn't actually serialized it won't be in the meta file
where's this defined, and where's AttackStart defined?
So then what's the problem
ahhh i thought this was in regards to a serialized field, misunderstood
The issue being that i have this error..
So, then you haven't actually set those. Is that block of code you've sent in the same file?
@errant breach answer this
And putting "es.<function>" give me that
Hold on, please 👍
well, that's quite straightforward then
It's a constant, it doesn't belong to an instance of EnemyScript (the variable es), it belongs to the EnemyScript class itself
amazing
so bad I haven't saw it on any guide or any place really
This is defined in the EnemyScript.
AttackStart is defined in AttackScript
so they're separate contexts, hence the initial error
Hmmm, a lot of new words for me to learn i guess 🤔
const is similar to static+readonly
Alright, i understand my mistake. Thank you for explaining.
But this is really new for me... In order to execute the function with the parameter, do i need to make something like... That ? Or something completly new and different from the usual ?
IDLE belongs to the class. ChangeAnimationState is not static or const and belongs to es
oooh, so i can only read it (as said by Chris) but i cannot modify it or execute it in any way ?
that's unrelated to what digi's saying
stuff that's static or const belong to the type, aka EnemyScript in this context
stuff that aren't static nor const belong to the instance ("instance members"), aka es here
Could be wrong but is the enum public?
it's not an enum.
They are ! But i think i don't really understand the logic behind all of this
c# enums are backed by integrals, that could work for managing transitions but not for playing specific states as they're used here
IDLE is const, so it's static and readonly. It belongs to the class.
ChangeAnimationState is an instance member, and belongs to a specific instance of that script
consts are a little confusing if your newish to c#, so if it feels a little scary thats normal
Hmmm... So in my case, what would be the proper way to make my code work so that es (EnemyScript) can change the AnimationState ?
this is one of them
this is a shot in the dark but can we/I see the ChangeAnimationState function?
Ahah gotta say it really give me headache x)
you're already pretty close to one working solution
Sure, here it is :
{
// Prevent the same animation from interrupting with itself
if (currentAnimationState == newState) return;
// Play the animation
currentAnimationState = newState;
animator.CrossFadeInFixedTime(currentAnimationState, 0.2f);
}
yeah this was already really close to working, idk why you'd change the part that didn't have errors so it had errors
just learning things
I FOUND IT !!!!
(as explained here lol)
I always overcomplicate things... So sometimes, simples things become... Very hard for me, i think that as a future developper this is something i have to work about
learning a whole new language is hard
Or stress, maybe. ATP im developping 10 hours a day to give the game on Thursday so.. Maybe it make me take bad decisions 👍
Thank to you guys, it become easier
So again
thank you 🫶
IDLE belongs to the class. The function belongs to es
I try to help, I tend to not know, but the more I ask the more I learn.
Ahah i do learn a lot here, which is something AI cannot replicate so im happy there's still community centered about helping :)
people here are happy to help anyone willing to learn and putting effort into their questions/responses
it's no biggie 😄
That's a good thing, maybe one day i'll help too 💪
is Awake not called after a domain reload for AlwaysExecute scripts?
whenever my code recompiles or domain reloads I need to delete and ctrl+z my object with the script on it
have you tried Start
Awake and Start only get called once at runtime, perhaps it's the same for during edit mode with that attribute too
i wonder if scene reloading bool plays into it?
oh yeah, i'm pretty sure i ran into this recently
ExecuteAlways my guy
whats the difference of saying private void or js void
private is the default access modifier for methods, so effectively nothing
If you want to learn more about access modifiers, read here: https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/access-modifiers
I would suggest the verbose option every time
Hey I need some help
Is any one avalible
I want to detach parts of plane that collide with the ground but don't know how to do it for physics I am using rb and applying for at different position like wings tail ets but if I am to remove a wind like during crash the rb freaks out and the plane start uncontrollably spin
What should I do
You'd need to show more of your setup, like what youre doing to actually remove these objects in the first place. The hierarchy before and after would matter too
Ideally a removed piece would have its own rigidbody completely unparented from the main plane object
All movement script and rb is on the aircraft game object and I am using the gasgiant airplane physics from git
😄 random paste from old device
materialInstance = new Material(colorMaterial);
materialInstance.SetColor("_BaseColor", Color.red);
for some reason I can't manage to get a script to change the color of this material texture. On a different script I changed the texture the same way with the BaseMap property but it seems like neither _Color nor _BaseColor work for this. Any ideas?
there's no reference errors or anything
i think #1390346776804069396 may be able to answer better
thanks I'll try there
Also need more context, you made a variable and assigned a value to it. As far as I know you just set a value to a variable and never applied it to the actual material/component.
Dj brewing up a correction, lmao
Hello !
So i want an Enemy to collide with everything that has the "aiZone" tag.
Here's the code :
{
if (other.gameObject.tag == "aiZone")
{
print("collision");
inTheGameZone = true;
}
}```
It doesn't work. Both `Enemy` and `aiZone` have :
> - A RigidBody
> - A BoxCollider (Trigger ✅) (tried disabling it)
When i tried creating a random box and giving the collision script, it worked **perfectly**.
By the way, the entire code is actually the following. For the playerProjectile it work fine so i can't explain my incomprehension.
Do you know how i could make it work please ? Thanks !
I think what you're looking for are layers.
This code, that i just copy pasted, work just fine btw
Log outside of your if statements, does it run?
You can use code and tags to determine things but if you're talking about physical interactions, bouncing off of, colliding with, etc. I'd point to layers.
No it's just to determine things, no colliding 👍
Let's see..
- other.gameObject.CompareTag(tag);
- Are you sure its trigger(collider with toggle), right?
Here's the box !
Okey, and colliding object also?
(CompareTag is just a minor optimisation, it won’t be your problem)
Here's the colliding object !
Does this object have a rigibody aswell
Disable trigger by this one
Trigger detects objects with collider, not a trigger
triggers are collliders and afaik triggers should react to other triggers
I don't understand.
if (other.gameObject.tag == "PlayerProjectile") work PERFECTLY FINE
if (other.gameObject.tag == "aiZone") is NOT DETECTED
Shooting work (damage) ✅
Level doesnt work ❌
I could be wrong but from my experience, triggers do not interact or trigger other triggers.
By me the same
Actually with the player projectile it work perfectly fine 😅
So that's very strange like... I dont understand
Let's see what get returned if i remove all "if" and just wait for any collision..
does it...?
Yes, both have a rigidBody !
Are both set to IsTrigger = true?
Do you have any collision matrix settings changed
The collision is not even detected
But the collision with everything else is (His own bullet, player's bullet, other enemies, ...)
Also fr I'm wrong on the both being triggers not interacting? I had an issue recently related to that... huh, my bad.
🥲 Ah, kinematic was my issue
Oh my fcking skibidi god
is there any api let me toggle these 2 in code
i just lost 30 minutes and your time on this
you spent 30 minutes learning to check it next time 🫡
First day we did remove collision between wall-type and enemies and i completly forgot about that 😭
It happens
AAAAAAH you're right 😭
Thats why you should debug without conditions asap to see if it’s code or object setup related then work from there
Hope no one in my class will see this conversation because otherwhile... I'll look dumb xd
Im starting to get the "debug" logic i guess.. I completly forgot it could be external causes like that, not code. Overtime i hope ill get more independant... Thank you for your time and for the help ! guys ! :)
Ah don't fret over it. I find it funny that the more I say wrong, the more it seems Batby wants to correct me lol
We all learn here i guess ahah x)
sorry for the super late reply
No worries but where/how are you applying the value to the object's material?
well I tried two different places. One is the Awake function in the script itself on an object in the scene
the other was in a function tied to a button
basically just creating a new instance of the material and then attempting to change the property
I would have gotten the renderer component of the object and tried to do it that way, but I'd like this material's color changed for every object that uses it
I hate to be a broken record but if a person did
int _reference
int a;
Start()
{
a = _reference;
// then said
a = 2;
// _reference would still be it's original value
}
yeah I figured it was the instancing that was the issue so I tried just setting the original reference's color without making a new material instance and that doesn't work either for some reason
is it possible you need to set both the _Color and _BaseColor properties for it to take effect? I was looking in the .mat file itself and saw that when the color was changed in the inspector both of those properties reflected the change
I don't really understand the difference between them in this case
Change the property itself, or the variable you made?
But when are you putting this material on the relevant renderer?
it should be the property itself since it's the .SetColor() method which takes a property name
Batby may correct me, but if I made a Transform 'A' and A.SetPosition, I'd only be adjusting the position of A, not the actual object.
the actual object's position is the transform
I'm not really sure how to answer this. The material is on an object in the scene, and there will be more like it that use said material
@alpine dew batby is asking what you're doing with the material after you've changed the color
If your making a new instance of a/the material, you have to actually use that material somewhere. Otherwise it’s a random material unrelated to any renderer
If your attempting to modify a material that is actively being used by many objects, you wouldn’t be making a new instance of a material, you’d be modifying that material directly
GameObject _thing;
void Start()
{
Transform A = _thing.transform;
A.SetPositionAndRotation(etc);
}
won't affect _thing
it will
because Transform is a reference type
that's the same as doing _thing.transform.SetEtcEtc directly
You're making a variable and setting it's value equal to the other, then adjusting it...(?)
You're never applying that new value to the _thing itself(?)
well, you're applying it to _thing.transform
that's a fair point. I've gone ahead and did away with the instancing of a new version of the material. For some reason just changing the material itself doesn't seem to want to work
A and _thing.transform don't actually hold the transform. Transform is a reference type. the actual transform is somewhere on the heap, and _thing.transform/A hold references to that transform on the heap
when you do A = _thing.transform, you're just copying that reference. so when you mutate A, you're mutating that object on the heap, which is shared by _thing.transform
this is how reference types work
Well as said if you make a new material you’d need to make renderers use that material via code, they don’t know about it.
Changing the material directly in theory should work, if you show attempted code we can maybe help troubleshoot that
hang on I'm trying something
Am I going insane? Lol, I'm also gonna try something
Is this not fine as is?
colorMaterial.SetColor("_BaseColor", Color.red);```
to be blunt, you seem to not understand how reference types work, so i'd suggest go brushing up on that
Seems fine in isolation
and is colorMaterial used?
yes it's what's shown in the inspector here
I feel like something weird is happening with it
