#💻┃code-beginner
1 messages · Page 480 of 1
Absolutely not no
jesus h christ so why is it in your code?
not sure what u mean by that 
I got it from a youtube tutorial
and the tutorial didnt explain what it is ?
Entity
- WalkableEntity
- Player
- ClimableEntity
hello, i have this issues and idk how to fix it.
Not really
Or I just didnt understand
shitty tutorial then.
Something on that line is null but you're trying to do something with it anyway
Yeah well I couldnt find a brackeys tut on it
that would still be a limit of 1 type per object no?
brackys is just as shite
Right. You can have multiple types per entity if you make them interfaces: IWalkable, IClimbable
https://unity.huh.how/references/singletons
okay read these and come back when you're done
https://gamedevbeginner.com/singletons-in-unity-the-right-way/
I mean like, if I have a Unity terrain, and I want to walk on some parts and climb on others, or neither on some other parts of the object
So I'm supposed to make a singleton
using tags or scripts as tags would result in the entire object only being 1 thing
I am not particularly familiar with terrain. If you want to differentiate them manually, not on runtime, you can create a script, which contains a Flags enum
the terrain is just an example
Use the suggested example if you spawn specific prefabs
please read it carefully make sure you understand what it does first.
You don't want to be using a wrench without knowing what its for
Thanks for your help before, I have fixed that issue with the input system.
I have this error now. Within the function I have:
private void HandleMovement(){
Vector2 inputVector = gameInput.GetMovementVectorNormalised();
The second one is a whole book
Seems gameInput is null
a "whole book" is a blogpost length guy have you really no attention span to learn something you bout to use 70% of your time in Unity lol
having detailed explanations are a good thing these days
The character moves around somewhat ok though (although no animations play now). I dont think I understand why gameInput would be null.
Where do you assign a value to gameInput
I don't have the attention span or the time to read all of that right now. I gotta go sleep sometimes yk
spoiler alert you wont make any type of functional game if you dont take the time to invest in yourself 🫡 goodluck with it
alright whatever
I have this at the top of my MoveController script
[SerializeField] private GameInput gameInput;
which I think calls from a function that looks like this in my GameInput script
public Vector2 GetMovementVectorNormalised(){
Vector2 inputVector = playerInputActions.Player.Move.ReadValue<Vector2>();
inputVector = inputVector.normalized;
return inputVector;
}
PS, how do I format code on here to show it better?
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 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.
Okay, so where do you assign a value to gameInput?
Sorry I am not sure I understand. I am really quite new to this.
i cant get my animations to work i can only do idle
We're fine with that. Just don't come whining about your issues, which appeared, because you had no intention on taking a reasonable advice
Where have you told this script which GameInput you want this variable to hold
I dont think I have. All I have is the code that I have put so far. I have this
[SerializeField] private GameInput gameInput;
And then in the function
Vector2 inputVector = gameInput.GetMovementVectorNormalised();
Where GetMovementVectorNormalised is returning an inputVector from my input actions.
So, which GameInput do you want that variable to hold?
i want to have basic animation i followed a turtorial but i can only get idle animation
Alright so just because I don't have time to read a whole blogpost for one thing that there is most likely an easier way around I shouldn't ask for help? Very smart
You shouldn't ask for help if you want someone to fix your issue by fully writing the code for you
So I understood that GameInput is class with the methods Awake and GetMovementVectorNormalised.
I thought that by instantiating the class at the top of my BadgerMovementController script I would be doing this.
[SerializeField] private GameInput gameInput;
then I could use the method GetMovementVectorNormalised() which is from the gameInput instantiation of the class GameInput assigning the input sytem variables to inputVector
You didn't instantiate the class there
you made a variable that can hold a GameInput
you still need to tell it which one of those you want that variable to hold
Can somebody assist in figuring out proper collisions in unity 3d?
If I make a rotating object kinematic, the player cannot push the object (which is good), but the object doesnt collide properly with the player at higher speeds.
If I make the rotating object non kinematic, the object collision with the player works, but the object gets pushed. This occurs even if I up the mass.
All I want to do is have a rotating object that collides with the player at higher rotation speed (not a very high speed)
I don't want someone to do everything for me. There is a reason to why this channel is called "code-BEGINNER"
Then read it later when you are willing to
what they mean is that the easy way isn't the way you learn, singletons are very useful and it's a good idea to understand how they work
I will when I have time
It's expected that you are willing to learn yourself. Not "I don't have the attention span or the time to read all of that right now, so I'ma just give you my code and you go fix it for me"
Yes, that's fine. Not every bug needs to be solved right away. If you can't do it right now then get to it later
Sorry but which one of what? Which instantiation of class (that I assume I have not done yet).
That isn't what I said or meant, but sure cus you know better
A class is just a blueprint. It doesn't actually exist until you create an instance of it. If that script is a MonoBehaviour, you'd instantiate it by adding it as a component to a GameObject
Well, yeah, I know how to use singletons
Yeah you probably do, but that isn't what I was talking about dumbo
The field is literally the part in unity that you can drag and drop things into?
So when we SerializeField it is kind of like making it available to the engine?
No, drag & drop is only supported by specific types
Yes, SerializeField makes it "persistent"
Yes thanks, that is what I mean. Very helpful.
SerializeField lets you set it in the inspector by dragging in an object
This makes myString visible in the Inspector
[SerializeField] private string myString;
This does not show myString in the Inspector, but still keeps it persistent across the game sessions
[SerializeField, HideInInspector] private string myString;
This makes other serialized myRef references not affected by this one
[NonSerialized] public YourClass myRef;
Yes, thank you I think I do understand this part fairly well.
I dont think my issue is as simple as just instantiating (assuming this is indeed the right way to instantiate this class) in the start method with:
gameInput = GetComponent<GameInput>();
It does not fix my issue. And this also stops the movement I had previously.
Where is the original issue?
Well the error log says it's the line:
Vector2 inputVector = gameInput.GetMovementVectorNormalised();
Since gameInput is null?
With the null reference :/
Is the reference successfully assigned after getting the component?
How would I check for that? Debug.Log gameInput in my update method?
Debug it after the assignment
Ah, no it isnt. It's null.
What does it mean?
(assuming you ask this to see if I understand something?) I think I must have something wrong with the actual GameInput class.
What might be wrong with it?
The naming is all okay.
I see that in the inspector when the game starts the game input field goes to null.
Then you have code setting it to null, or the object you set it to gets destroyed
If it's null, then there is no GameInput component attached to the object
But am I not attaching the component here?
Is the GameInput script attached to the object you're trying to get it from?
You are assigning an object to the variable gameInput.
Do you change the value of gameInput in code anywhere?
GetComponent is gameObject.GetComponent, which gets the Component, attached to the MonoBehaviour's GameObject
You don't have to use it if you are already referencing it in the inspector. Just make sure that you don't change the variable anywhere else, as mentioned by digiholic above
Press Ctrl + F and type the field's name to find its references
It was not attached. Let me take a look.
If I attach the script to the Badger Object (Is it right to call the items in the hierarchy objects?) the error goes away. Still no movement though. But I might have something wrong in between my input and actually making the object move.
Then this should work without attaching the script to class, assuming the GetComponent line is removed
You might want to show the move logic too
okay so removing the GetComponent line means the Badger moves around, I get the same Null error though, which I dont understand. How can gameInput be null but I still can use the input to move the object.
My movement logic as so:
Vector2 inputVector = gameInput.GetMovementVectorNormalised();
Debug.Log(inputVector);
Vector2 moveDirection = new Vector2(inputVector.x, inputVector.y);
// Rotate input to match isometric view
moveDirection = new Vector2(moveDirection.x - moveDirection.y, (moveDirection.x + moveDirection.y) / 2);
// Move the badger
rb.MovePosition(rb.position + moveDirection * moveSpeed * Time.fixedDeltaTime);
// Move the badger
if (moveDirection != Vector2.zero)
{
lastNonZeroMoveDirection = moveDirection;
}
}```
The debug log shows values going to 1 etc when pressing wasd
Why does the "badger" move around?
The position of the rigidbody attached to it is being shifted by moveDirection at each frame?
if gameInput is throwing a NullReferenceException but this code is still working, that means you have more than one copy of the component in the scene where at least one of those copies does not have anything assigned to gameInput
Got it. First, check whether you only have a single instance of the script, as mentioned above
Only a single copy of the script GameInput. I have a GameInput in my hierarchy, but that should not be the problem right? You can have a script the same name as the item in the hierarchy.
not multiple copies of GameInput, multiple copies of whatever the component you showed the code for
because your gameInput variable is not assigned on one of those
Did you type the script name in the scene hierarchy to see if multiple GameObjects appear?
more specifically use t:ScriptName to search for the component
the t: part is important because it searches by that type, otherwise you'd be searching for gameobjects with that name
Yes, I think I had gameInput assigned to my animator script as well.
Ok. so deleting the BadgerMoveController script resulted in errors. Attaching it back fixed the issue... I have no idea how this has worked but it's further than it was.
This is hard... haha
I am okay with programming with Python, I think I get really confused at understanding the Unity interface.
it usually helps to say what the errors are. but have you actually checked the scene for multiple copies of this BadgerMoveController component like i've been saying to do?
Yes, as I said I thought that this one was attached to both the parent object and the animation controller script.
you said that about GameInput
or did you mean that you had assigned your Animator object to the gameInput variable on another copy of the component? if that is the case, you are absolutely using the wrong type for your variable
there is almost never a need to use a variable of type GameObject. use the actual component type you want to access instead
then you'll almost never need to use GetComponent and you'll never be able to assign an object that doesn't have the desired component to the variable
https://docs.unity3d.com/ScriptReference/Collision-collider.html
I didnt understood this property. Is it the first contact?
Or is it the Collision.thisCollider and the contacts returns the colliders that Collision.thisCollider collided with as Collision.otherCollider?
Oh i believe it is the otherCollider. Yep found it. I hate the way my VS is not showing the codes always!
how can i add movement plus animations has anybody a good turtorial i can only find bad ones
well first i would recommend !learning before you dive into things like that
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
put the points in an array and use Gizmos.DrawSphere see where they appearing 
https://pastebin.com/BLbtKCeS
why isnt the collision doing anything?
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.
it doesn't say anything about contacts. it says the collider that your GameObject hit; that's pretty explanatory. "Fetch the Collider of the GameObject you GameObject hits," . . .
Do you ever get the "just collided" message in the logs?
Well that would be your answer
You're checking for a collision
not a trigger interaction
oh
https://pastebin.com/baHjxJ7e
now it says both in the log, but doesnt reset any values
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.
Does the player object have a CharacterController on it
yes
CharacterControllers do not like being teleported. You can either disable it, set the position, and re-enable it, or call Physics.SyncTransforms() after the teleport
So does this have a CharacterController or a Rigidbody?
If you want to use Maya files, you need to have Maya installed
how
how what
The same way you install basically any other program
How did you install Unity?
You went to their website and downloaded it then ran it
So do that
Ah nevermind it's another problem child wasting everyone's time
discussing pirated software is against #📖┃code-of-conduct
im not
im just asking if there is a way
to get this to work
cus its saying something about it not working
if you need maya you install it, if you dont have it buy it or dont use files reliant on it
instead of using maya files, don't
can i use a obj
then delete it
ok
or convert it
done
My enemy isnt following me what could be the reasons for that? i baked my probuilder ground btw https://justpaste.it/9x96u
Allocation of 32 bytes at 0000022CA17E1B70
Allocation of 32 bytes at 0000022CA1470BE0
TLS Allocator ALLOC_TEMP_TLS, underlying allocator ALLOC_TEMP_MAIN has unfreed allocations, size 64
Internal: Stack allocator ALLOC_TEMP_MAIN has unfreed allocations, size 64
To Debug, run app with -diag-temp-memory-leak-validation cmd line argument. This will output the callstacks of the leaked allocations.
Allocation of 32 bytes at 0000022CA17E1B70
Allocation of 32 bytes at 0000022CA1470BE0
Allocation of 32 bytes at 0000022CA17E1B70
Allocation of 32 bytes at 0000022CA1470BE0
TLS Allocator ALLOC_TEMP_TLS, underlying allocator ALLOC_TEMP_MAIN has unfreed allocations, size 64
Internal: Stack allocator ALLOC_TEMP_MAIN has unfreed allocations, size 64
To Debug, run app with -diag-temp-memory-leak-validation cmd line argument. This will output the callstacks of the leaked allocations.
Allocation of 32 bytes at 0000022CA17E1B70
Allocation of 32 bytes at 0000022CA1470BE0
what do i do to fix this
if you're just gonna plaster a bunch of stuff and expect anyone to help make a thread, spamming chat isn't going to get you help
ok thx
enable the gizmos and check whats happening in Scene view
where can i start a thread
here, its ez right click a message and Start Thread
random things not working
its twitching
@rich adder did u fix ur gizmo/camera issu?
haha naww never bothered i just chalked up as a bug
this is in playmode ?
yes
capsule collider and character controller are bigger than the GFX GameObject of the player
prob have to select the navmesh agent by itself in playmode to see the path plotted on
i mean just select the CircuitBug
try moving agent.SetDestination line by itself In Start() and see if its working
Thank you ✨ I did it to approve my thought after asking to some AI. It got so much power for giving direct answers now. It is so annoying to implement custom system for OnTriggerExit-Collision() that getting triggered whenever objects got disabled 🥺
Ohh like OnTriggerExit still runs on disabled gameobjects ?
Yes. After some researches, they didnt implemented this due to PhysX bullsht. But 2D senior developer told in one article: "I opt for OnDisableTriggerExit" so which was already what i was going to do.
With UnityEngine.Pooling system i was able to get the performance i need by not creating a list for every collision or trigger
have you tried restarting the editor?
it worked
Instantiate requires a Quaternion for the rotation parameter, luckily you can use Quaternion.Euler to create one from euler angles
i tried that and it did this
and you are certain that nothing else affects its rotation? there's no physics like a Rigidbody2D that can rotate it, or any code like assigning a parent that rotates? and that when you instantiate it with Quaternion.identity as the rotation it points exactly along an axis?
yes, No rigid body, no code affecting rotation, and it is perfectly upright with quarentation.identity.
your ide is not configured
and you typed quaternion instead of uppercase
that's still correct, it's just the quaternion struct from unity's Mathematics package
ah
it has an implicit cast to UnityEngine.Quaternion so it's fine
ive done everything the ide link told me to and it doesnt work i guess
it's configured
oh okay
if it weren't then that red underline you showed with your first screenshot would not have appeared
but you should show the inspector for the instantiated object
ideally the hierarchy too
ah, i see what the issue was now. Mathematics.quaternion uses radians in its Euler method
UnityEngine.Quaternion uses degrees
would this work as intended? trying to make it so when the object collides with another specific object, it changes colour, and stays the default colour while not colliding with it
im quite sure that colliding = true wouldnt be applicable to everything else but i have no idea to make it like a global change
You would need OnTriggerExit2D to detect the exit
Also you can just do else {
You don't need else if and a whole nother condition
do i scrap the colliding variable or
if (colliding)
{
}
else {
}```
Also yeah you really don't need Update here
You can just change the color in OnTriggerEnter2D and Exit2D
There's no need to check every frame
youve lost me i have no idea what to write here
Just put the color change stuff directly in OnTriggerEnter2D
Instead of colliding = true
i tried this exact thing before and it just took the else as like a final verdict
and kept it the same colour
like this?
if the collided gameobject has tag Player it will change to that colour, if it doesnt have the Player tag then it will run the else statement
didnt work
what didnt work, did you place a Debug.Log to make sure the code runs
Anyone know how to make semi-colon get added automatically on save using C# with VScode?
this isnt the outcome i wanted
i wanted it to change colour when touching the collider
and turn back to normal when not being touched
Debug the collider’s object’s tag in other (unless the enter code works)
i have no idea what thats supposed to mean
what do i put there
use OnTriggerExit2D to change the colour back to normal when you Stop colliding
so i dont need the else
no, doesnt even make sense
it just does if you collide with Player it does X otherwise it does Y
well i was told to use else so dont look at me gulp
you also don't need the GameObject.Find if the Renderer you want to change is on this object (or the one colliding)
no one told you to do else
you were told to use OnTriggerExit
here
thats just a tip to improve your code
instead of checking a whole else if
the main thing he said was use OnTriggerExit2D #💻┃code-beginner message
like this?
you need to check the tag in the OnTriggerExit2D also
unless you want it to just run if it exits any collision that it detects
would doing the exact same code as the top bit even work
why wouldnt it?
i dunno it just looked like it wouldnt
another thing that needs to be pointed out is that your color constructor parameters are wrong. Color uses a float from 0 to 1
i copy pasted it from a website i have no idea what else to use
Color32, also thats why you shouldnt just copy paste
divide those values by 255f if you want to use a value from 0 to 1. otherwise use Color32
i have
zero idea what youre saying this is why i copy pasted
seemed to work for me
it works 
though the objects dont collide regularly
is there a fix for that
are you moving with physics or not?
define "collide regularly"?
the two objects ive been using dont collide
also keep in mind that trigger colliders are not solid
ive got two colliders on my object
the regular circle collider for the actual object
and a second larger box collider as like a hitbox of sorts
the regular circle collider doesnt collide with the other object
trigger colliders are not solid
the circle collider isnt a trigger
the box one is
is it because the box is like overlapping the circle maybe?
no, either the other object has a trigger collider on it or you are not moving in a physics friendly way
answer this perhaps
my movement script is pretty jank
how are you moving
should i copy paste my movement script here
private float _speed = 5.0f;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
float horizontalInput = Input.GetAxis("Horizontal");
float verticalInput = Input.GetAxis("Vertical");
Vector3 direction = new Vector3(horizontalInput, verticalInput, 0);
transform.Translate(direction * _speed * Time.deltaTime);
}
thats not using physics
transform.Translate does not respect collisions
got any other scripts i can use
and idk what you mean by this, looks perfectly fine lol
it weirds out on collision
smudges into the other object a little
and is all around kinda floaty
nobody is going to just hand you working code for free. consider going through some basic courses like the pathways on the unity !learn site to learn wtf you are doing instead of expecting to just copy/paste everything
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
no, just use a Rigidbody instead of the Transform, you have the Input code already written
just adapt your code instead of trying to copy paste more scripts that you dont understand
i prefer to learn like this
then i won't help you. good luck.
i always read the script through to understand it as much as i can before pasting it
dont just assume that i blindly shove whatever i find into there sob emoji sob emoji
thats what most people do so its all we can expect
use either .AddForce or directly set the velocity .velocity with a Rigidbody, and it should be colliding fine
can you walk me through what you uh.mean by that
i replace the transform.translate with those but how do i format those
is it just the exact same but transform.translate is replaced with .addforce?
unity is being dumb again, do i restart it?
my code:
script 1:```cs
public static float player_health = 100;
script2:```cs
player_health -= 5;
error: ```
Assets\Scripts\Enemies.cs(43,13): error CS0103: The name 'player_health' does not exist in the current context
script1.player_health
oh, i forgot about that
thx
weird how it didn't tell me that there was a problem in vs code tho
Your IDE is probably not properly configured
it is, and it normall tells me when i have an error
Both should catch this
i think it's because i had vs code open for 13 days straight
lemme restart it
weird
it still doesn't tell me about errors
@deft grail sorry for the ping, tried this but i get the "Object reference not set to reference of an object" error, not sure what to do
private float _speed = 5.0f;
private Rigidbody2D rb2D;
void Start()
{
rb2D = gameObject.AddComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update()
{
float horizontalInput = Input.GetAxis("Horizontal");
float verticalInput = Input.GetAxis("Vertical");
Vector3 direction = new Vector3(horizontalInput, verticalInput, 0);
rb2D.AddForce(direction * _speed * Time.deltaTime);
}
i changed it to debug console and then back to problems and now it shows errors
weird vs code bug ig
use GetComponent
and just add it yourself in the inspector
where
instead of gameObject.AddComponent
no?
i mean adding the component to your game object...
not assigning the variable
GetComponent will assign it
bruh, the Rigidbody2D component
that you need to add to your GameObject
in the inspector
i already have rigidbody2d on my object
then why are you using AddComponent in your code?
i dont get the error anymore but i cant move
just use GetComponent and your set
i was thinking that but i didnt know getcomponent was a thing
slash forgot
dont multiply by Time.deltaTime
🤔
is this a top down game?
more of an experiment probably wont become anything
is the experiment a top down experiment
try rb2D.velocity = direction * _speed;
oh by the way is there a reason for most variables i see having a _ by the side
its a preference, but thats mostly used for private variables i think
still doesnt work 
should work im pretty sure
show the updated code and the inspector of your gameobject?
private float _speed = 5.0f;
private Rigidbody2D rb2D;
void Start()
{
rb2D = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update()
{
float horizontalInput = Input.GetAxis("Horizontal");
float verticalInput = Input.GetAxis("Vertical");
Vector3 direction = new Vector3(horizontalInput, verticalInput, 0);
rb2D.velocity = direction * _speed;
}```
because it wasnt using the Rigidbody to move lol
you are probably moving faster diagonally, if you wanna remove that you need to normalize the direction vector
how do i do that
.Normalize()
where do i put that
try it yourself, look at the docs, look at examples online
so what did you try
uhh wait i thought i had it
i tried Vector3.Normalize()
the example i saw said that
didnt work
normalize the direction vector

what does this mean
where do i put the normalize
ive tried in front of the vector and the direction
😭
on your direction vector
you can do this on a new line if you wish
to not confuse yourself
i dont know what you mean by that
do i make a new line like
direction.normalize()
and thats it
try it and see
i googled it but nothing i saw was referencing any actual examples
WOAH that fucked it up hard
what does normalize even do
show what you did
yes but show where you put it
directly under the vector3
screenshot it
whats wrong
moves a seemingly random amount after i let go
use GetAxisRaw to make it an instant 0-1
GetAxis gradually increases from 0-1 and 1-0
is it weird that C++ is easier for me than python
idk it just feels easier to pickup
how is this related at all to this server or channel 😄
wait bro it says #💻┃code-beginner
stupid
depends what you wanna do
add an enemy?
im thinkingg
the entire point of that changing colour object
was to at a very basic level copy the tables from enter the gungeon
im assuming theres a way to like
swap objects
the colour change is to highlight that its in range to be used
and id press a button to swap the object into something else
what does it do, flip over doesnt it?
you can just play an animation on the collision and add/change the properties of a Rigidbody2D to make it interactable
you can do pretty much anything in the collision
iiiii wouldnt know where to start hold on
okay basic things can i change that colour swap into more of a
highlight
just make each part in order
like a glow around the borders
think you need a shader or you can just make a sprite that has an outline
i have no idea how to play animations or use the collision or change properties of a rigidbody2d
its all pretty much the same
referenceToYourThing.DoSomething();
thinking for the future id imagine changing the sprite into an identical one with just an outline would be like
i dunno it just sounds weird
is that what most people do?
they use shaders or theres an Asset on the asset store im pretty sure
but its paid i think
the asset uses shaders, but you just dont have to make it yourself
uhhhm ill just
make sprites
gaah somehow the new movement script fucked up the colour change script
shouldnt change anything in terms of the collision
what error
assertion failed on expression: go.isactive()
Look at the stack trace. Where is it coming from?
this stuff is why you should actually make an effort to learn from a structured course instead of trying to brute force your way through this by copy/pasting everything
did you not read what i said
i dont just spam paste whatever i see
i read and look up whatever im looking at
to at least get some idea of what it means
listening to courses isnt for me it doesnt stick i like to do things from experience
Then look up what a stack trace is.
Anyways, none of this would be a problem if you were to share the details of the error correctly(by taking a screenshot for example).
it says nothing more than that and stacktrace
and id prefer to ask actual experts before blindly googling what might not even be important
how would i know stacktrace means anything
Well, then look at the damn stack trace. You said you don't know what it is.
how was i supposed to know its important before asking
You definitely sound like you know what it is here.
asking a question wont kill anyone
Are you gonna actually provide the info or not?
?? are you like insinuating i know more than i let on on a unity discord server
dlich can you like calm down im not hurting anyone
stop fighting
Ugh... Okay, I'm outta this one.
https://gdl.space/imosuresos.cpp i am doing a pinball flipper and want it to rotate until a certain point(in this case either max rotation while holding down the D key or minRotation if viceversa) but it keeps just going until +5 or -5 in the z axis and doesnt rotate until the 25 or -15 am i missing something?
This is not the error details...
this?
Yes. You can see that it's your script causing it.
The rest you can investigate on your own. Learn what a stack trace is.
looks way too complicated and i dont think its needed
looks like its an issue with my ontriggerexit
im debugging and it indeed tells me that the transform.rotation.z value is higher than the maxRotation so the if conditional should be correct which should lead to rotating it by 1 degree each frame (which doesnt happen)
wait i used transform.rotation.y instead of .z
💀
Didn't you say that you prefer to learn on the go? If so, you should be googling every single thing you don't understand and digging into documentation. If you can't do it, this is not a correct learning method for you and you should go over courses as suggested previously.
it literally gives no information on the error
but i solved it anyway
only issue is i probably need a better way to change the colour of an object
If there is no info on the error, then google the API you call on the line that throws the error. You're probably using it incorrectly
i showed you everything that the error told me
you can make 2 variables of Color and just assign the color in the inspector
so you can change it anytime without having to change the actual code too
You didn't show the relevant code though.
i need to do it within code
i didnt need to because ive solved the error
i think i know what it was anyway
the way i got the objevt was way too complicated i entirely forgot this script is only used on THE actual object
so i didnt need to find it
Not gonna get very far if you keep that way of thinking.
dlich can you hooooop oooooooff
what is your issue with me im only asking questions youre being a debbie downer
i need a better way of doing this
like i said, make a variable
kind of looking for an idea here
https://hastebin.com/share/bebarupaqe.csharp
https://hastebin.com/share/bulerapofi.csharp
how do i get it so that ItemHeld is sort of a spot to put new things in?
sorry that sounds sarcastic
make a variable of type Color and do = myColour; instead of new Color
like the idea is "hey okay now that you clicked e on this thing the raycast hit, and it qualifies as something you can indeed pick up, put it in the ItemHeld slot in the inspector"
Don't know if you solved it, but transform.rotation is a quaternion, not Euler angles. You should probably avoid using it's members directly.
is myColour an actual unity code thing or would that be the variable name
variable name
yes im trying to use transform.rotate which i think fits better
can you write out an example
oh i feel like i put too much in the thing
that is the example
i told you what to replace
okay just in general, how can i set it up where the object is intended to be removed and moved from the slot?
what i would do is just myRenderer.color = myColour;
make variables for both the Renderer and the Color
and assign the variables in the Inspector
im lost 
replace your line of code with this one... nothing complicated
as simple as it gets
You don't need to raycast at the same thing twice. You can get the hit object from the raycasthit struct.
There are no "slots" in unity by default. And the exact implementation would depend on your project needs/context.
this cant be right gaah it isnt clicking
wtf
[SerializeField] private Color myColour; and assign it in the Inspector
and for the renderer variable
what does serializefield do
and wouldnt private make it so i cant see it in the inspector
allow you to assign a value in the inspector while the variable still being private
thank you
it was giving me a message but i hadnt realized that was why
idk what to do though
not sure how id implement a field that is designed to have different things take its position
says myRenderer doesnt have a definition for color
what type is myRenderer...
renderer
show me
do you have your own script named Renderer perhaps?
nope
oh wait, look at your other code
you dont access .color from the renderer
didnt you tell me to do this
yes, but its also just an example.
and you can see thats not what you did with your other code
ive never used a Renderer so i didnt notice
seems like your ide is not configured
look at this
from what im seeing
looks configured to me
Debug.Log() should be blue and yellow no? and shouldnt collision be blue?
yes
as long as it is autocompleting you should be fine
probably just IDE visual, it has red underline though
might just be missing Unity extension on VScode i think it is
wait waitt
fatal flaw i think
i wanted to switch between the two colours
i have one option
do i change the original objects colour
so how would you solve that 🤦♂️
oh yeah it seems to be configured 😅
you need 2, you have 1, i wonder what your supposed to do
Wdym by that?
do i need a second serializefield for renderer
not showing up in inspector
im gonna have to assume so the second colour isnt either
yes, but for the Renderer you could just use GetComponent in the Start method
so serializefield works for one variable only
that seems a bit more complicated i wont lie
literally 1 line of code, which also would be error proof
if you fail to assign it in the inspector, you will error
yeah but thats a line of code that i dont know from heart
whereas i can just write what i already know
and not forget
error proof
🤔 its 1 line of code
literally 3 words
i managed to make it work 
i dont know getcomponent
its self explanatory
anyway its still signficantly easier to just copy paste serializefield
and add in the renderer
though probably not because the shit didnt work grin emoji
it turns invisible when i go up to it
then your adding a GameObject that doesnt have a Renderer
hold on
no i fixed it
they just default to transparent for some reason
yay now my little square turns a darker brown when i go up to it
joyous day
you need to set the Alpha to 255 in the inspector
isnt what paid?
shaders to outline an object
brackeys has a video on it, 1st result.
you can try watching that
you can just look up a tutorial for that
im not sure why it would be paid 🤔
okay well its sort of like this:
well the shader graph does that
so thats like 90% of the things in the engine..
i can just make another since its just a simple square
yes, the same was as you do colour
just reference the SpriteRenderer
id rather stay with the basics
- Raycast hits object
- Object has the pickup layer, so Unity returns a debug log telling you that it can be picked up.
- Clicking E, will send the debug log that you picked up the object.
the problem is that I tried to set it up in a way where whatever object you clicked on would go into a public game object class called ItemHeld
before i even know how to code
then !learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
kinda what im doing right now
my beloved....
https://learn.unity.com/project/beginner-gameplay-scripting
this is a great way to get started with learning programming in unity, and the videos are short and sweet with demonstrations
you are doing this course?
no
im learning my own way
you wont learn anything trying to follow along tutorials without knowing the basics
they're like 5 minute videos
i dont like having information spat at me
then coding shouldnt be for you
i wanna do it myself
all due respect, thats not going to work
worked for python
@queen adder Can you stop flooding this channel.
Make a thread if you're going to thought dump
oh my bad i tend to send more sentences at once than a single long one
You're also just talking nonsense. This isn't the place to spam questions just because you refuse to learn with the resources available.
ive just been asking questions and applying them? i dont see the harm
its been helping me
We don't do handholding here. If you're finding yourself asking questions for every little single beginner thing, use threads.
i always forget those exist oopsie
like when you want to do something, do you specifically look up a tutorial?
Like say you want to make a movement script, do you simply look up a movement script related to 2d or 3d unity?
yeah
i look up things and also cross reference it with questions here
ill make a thread hold on
Next time, keep it all in one message. I could easily miss this message.
What do you mean by a "public game object class"? Are you referring to a public field of type gameObject?
ye
it keeps hitting me with a "there is no reference for itemHeld" and i'm just like
well yeah the reference is supposed to be constantly swapped out. when you're not holding something, its not supposed to have anything referenced because you arent holding anything
stupid class for stupid people (kayla
What is hitting you with "there is no reference for itemHeld" and is that the exact wording?
well to be exact it says:
UnassignedReferenceException: The variable itemHeld of PickupScript has not been assigned.
You probably need to assign the itemHeld variable of the PickupScript script in the inspector.
Okay. Share the script that has that field as well as where you assign it and try to access it.
PickupScript:
https://hastebin.com/share/sofusiraca.csharp
PlayerInteract:
https://hastebin.com/share/umapicotik.csharp
something else broke and im going to try to fix that
okay idk why but the rigid body of one of my objects is no longer working 😮💨
fixed the other thing it had nothing to do with the rigidbody
nvm it broke again 👍
Take a screenshot of the error details. Or share the script+line that the error is thrown at. Just share the whole error stack trace.
It says that you've forgotten to setup the reference from the inspector in the Unity Editor.
this silly bit right here
perhaps its best if i explain what im trying to do
Yes. VS only would show compile errors. This is a runtime error. Untoggle "collapse", select one of the errors and take a screenshot again.
i want it, upon clicking e, to say that the object it just collided with is now equal to itemHeld
i dont even know if im even on the right track
By investigating the error, you could understand if you're on the right track or not.
well i understand the error, and why its giving me the error
i didnt put anything into the itemHeld gameobject variable
should i just make an invisible object and that becomes the reference 🗿
Great. So you either need to check if something is assigned to it, and avoid trying to access it if not, or avoid calling the method when you think that nothing is assigned.
Probably not. That would imply that you're holding an invisible object. Is that what you want?
i want it to stop complaining that there is no reference
i meant more like an empty parent object
but i want whatever is in the itemHeld slot to be replaceable by the another object if I click on it
and something completely unrelated broke this is rough
Then start with dealing with this issue. How can you prevent it from complaining? What does it even mean if it's complaining?
im gonna try again and take it apart
it cant be this complicated
im almost there
Don't try again. Try understanding and fixing the issue first
Answering my questions might help with that.
well if i put an empty parent object in there, it would stop asking for a reference object
its upset it doesnt have a reference because i'm telling that reference to become a child of another object
i tried slotting my flashlight into the slot and it works
sort of
it follows what the script is expecting itemHeld to do, but its still saying that there is no reference when i run the code
Why not just avoid executing the logic if no reference is assigned?
Wouldn't you think that's the most natural way to prevent it from complaining?
well by default you're not supposed to be holding anything, and when you click e, it'll pick it up
but i might be working backwards actually
That doesn't answer any of my questions. Can you actually read my messages?
Let's start simpler. What does the error mean? What value would your variable need to have for this error to appear?
i may not be understanding your questions
Then ask for clarification. What part do you not understand?
i dont know what you mean when you ask what the error means
its saying that there is no reference, which makes sense, because itemHeld is meant to be a GameObject
im gonna lay down for a bit until something loads in my head
What does it mean that "there is no reference". What value does the variable have at that time?
No. There's no such thing as a variable that doesn't have a value in code.
What value does a reference type have by default?
Have you ever heard of null?
Hi peps, wondering how am i gonna draw a grid?
Like this, just draw the lines infinitely. I just need some place to get some vague idea or tool how am i gonna achieve this.
I'd recommend going over the C# basics, as it feels like you're missing some very basic understanding of the language.
i think im doing it wrong
im going to try to create a flowchart of what im trying to do so i can better visualize what i want to interact with what
i might not even need 2 scripts for this
You most definitely are. But a bigger problem is that you don't understand the basics. You're gonna keep on facing issues until you fix that.
A custom shader probably.
I first looked at mesh honestly.
But either way, i never tried em, so gonna have to learn em first.
okay figured it out
sort of
i mean something else broke but sure
improvement
i told it to make itemHeld, whatever the game object hits (assuming you've clicked E), which then references the pickup event in the same script, that now has the information that itemHeld now has a value
and then after that, i go "well if itemHeld != null", then do the things
something completely unrelated broke but im making progress i suppose 👍
i just realized by charactercontroller you dont mean my own script
i only have rigidbody
wait a darn minute
so
defaultValues = player.transform;
makes it update even though i put it in the START method?
If you need an answer, you should provide a bit more info on what you're doing
from the single line of code i see, you're seemingly assigning a Transform to the defaultValues and probably printing out the position. Nothing about this has to do with Update, Transform is a reference type. itd be kinda weird if you stored a reference to a transform yet none of the values updated when you wanted the position
yes i guess ill have to do its values seperately to have the initial values
im making a 3D shooter game rn, working on interactions. I have my Interact() marked as override but it still gives me this error:
Assets\Scripts\Interactables\Keypad.cs(18,29): error CS0506: 'Keypad.Interact()': cannot override inherited member 'Interactable.Interact()' because it is not marked virtual, abstract, or override
any help?
`using UnityEngine;
public class PlayerShooting : MonoBehaviour
{
public GameObject bulletPrefab; // The bullet prefab to instantiate
public Transform firePoint; // The point where bullets are fired from
public float fireRate = 0.5f; // Fire rate in seconds
private float nextFireTime = 0f;
void Update()
{
// Get the mouse position in world space
Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
mousePos.z = 0; // Ignore Z axis for 2D
// Calculate the direction between the gun and the mouse position
Vector2 direction = (mousePos - firePoint.position).normalized;
// Rotate the gun towards the mouse
float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
firePoint.rotation = Quaternion.Euler(new Vector3(0, 0, angle));
// Shoot when the left mouse button is pressed and cooldown allows
if (Input.GetMouseButton(0) && Time.time >= nextFireTime)
{
Shoot(direction);
nextFireTime = Time.time + fireRate;
}
}
void Shoot(Vector2 direction)
{
// Instantiate the bullet at the fire point
GameObject bullet = Instantiate(bulletPrefab, firePoint.position, firePoint.rotation);
BulletMovement bulletMovement = bullet.GetComponent<BulletMovement>();
// Set the bullet's direction
bulletMovement.SetDirection(direction);
}
}
`
i told chat gpt to make me an bullet script but everytime i press click it dosent shoot pls anyone
and this is my bullet script
`using UnityEngine;
public class BulletMovement : MonoBehaviour
{
public float speed = 10f;
private Vector2 moveDirection;
public void SetDirection(Vector2 direction)
{
moveDirection = direction.normalized;
}
void Update()
{
transform.Translate(moveDirection * speed * Time.deltaTime);
}
// Destroy the bullet after a certain time or when it goes off-screen
private void OnBecameInvisible()
{
Destroy(gameObject);
}
}
`
that's a warning not an error, but make sure that there is no whitespace in the parameter name
Hello!
suppose i have a scroll rect
and i add some content into it at runtime
normally scroll rects do not align them automatically
what i want is to align the scroll rect automatically
with C#
how can i do that
my bad
i didnt know about the layout group
can someone help me please im trying to get a animation to work but whenever i press whats suposed to do it nothing hapens
Also make sure to take a look at the "Content Size Fitter" (goes on the same GO as the layout group) to make sure the content sizes with the children
ok thanks for the help
if i want to instantiate a particle effect before a box gets destroyed
how do i do it ?
like cuz after the object is destroyed the particle is also destroyed with it
i need help im following a tutorial but for them the debug stops and for me it continues
this is my code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class animatehandonimput : MonoBehaviour
{
public InputActionProperty pinchAnimationAction;
public Animator handAnimator;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
float triggerValue = pinchAnimationAction.action.ReadValue<float>();
handAnimator.SetFloat("Trigger", triggerValue)
}
}
it just spam this
anyone know what to do?
i get this error when i try to do a certain action with E "ArgumentNullException: Value cannot be null.
Parameter name: source" this si my script: https://gdl.space/yogonumihi.cpp
i also tried "KeyButtonDown("pickup"), and then in unput manager make one with the name pickup but that didnt work either
If the stack trace points to line 49, collectSound did not have a value (it was null). Which means you didn't drag-drop the Audio Source into the script's Inspector
oh wow i didnt know i HAD to already put the sound because i later wanted to add an other sound, but thank you so much it finally works!
if im understanding correctly you could have the box be a child
of the particle effect
problem fixed
what the hell do i do
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class animatehandonimput : MonoBehaviour
{
public InputActionProperty pinchAnimationAction;
public Animator handAnimator;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
float triggerValue = pinchAnimationAction.action.ReadValue<float>();
handAnimator.SetFloat("Trigger", triggerValue)
}
}
For starters, you read how to ask questions and share code: #854851968446365696
Then you ask the actual question correctly.
ok
https://hastebin.com/share/xamozodogu.csharp that the link to the place
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
Instructions must end with a semicolon ; in C#. Your mistake is on line 22, as the error says
...animatehandonimput.cs(22, 54) ...
Compare with what you have on the line above
Hello,
I try to create a weapon system with classes. It works but I want to put some delay between the function can be recalled. I wanted to use coroutine but I can't do this with classes if I understand. How I can do it ?
public abstract class AttackBehavior
{
public abstract void Attack();
}
public class BowAttackBehavior : AttackBehavior
{
public override void Attack()
{
BowSystem.instance.ThrowArrow();
//Wait 2 seconds after use this function
}
}
You can declare a "coroutine method" just fine, you'll have to start it from a class that derives from MonoBehaviour
im extremely sorry for the late response but no its still not working
I don't understand. the function SetAttackBehavior() works but the value of weaponcooldown is not transfered to the PlayerDamage script. Why ?
using UnityEngine;
[CreateAssetMenu(fileName = "New Weapon", menuName = "Inventory/Item/Weapon")]
public class Weapon : Item
{
public int damage;
public int reach;
public int speed;
public float weaponCooldown;
//What function weapons we will use
public weaponAttack attackType;
public AttackBehavior attackBehavior;
public enum weaponAttack
{
Bow,
Sword,
MagicBook,
Sarbacane,
Axe
}
private void OnEnable()
{
SetAttackBehavior();
PlayerDamage.instance.weaponCooldown = weaponCooldown;
}
OnEnable for scriptable objects does not work in the same way as OnEnable for MonoBehaviour. It will get called when the SO is created, not when the game starts
Ahhhhh
Is there a way I can transfer the value of the SO to a monobehaviour when the game starts ?
From the MonoBehaviour that uses the scriptable object, call OnEnable() (which you'll have to rename) from the MonoBehaviour's own Awake or OnEnable
someone added me as a collaborator on git repo. Now I made a new branch and I want to upload updated Unity project folder/files on it. How do i add my updated repo folders and files into it?
Change tracking is automatic in Git. Make sure you've checked out (ie. switched to) the branch which needs to contain the changes
I am new to git, can you explain more precisely
Are you using the command line, or some app to manage your local Git repository?
gitbash and git desktop
I cloned the repo to my local computer, now I checkout to the new branch.
Now what im thinking is copying the updated files to the local repo and replacing, once its replaced, I will commit changes
Well usually you should clone before you make any changes, and then you make the changes in the clone directly. That will catch the changes automatically. But yes if you have another copy of the files elsewhere, you can replace them in the cloned repo and they'll be tracked by Git
yeah before I downloaded the files, edited them. thatswhy
can someone pls help with this problem
navmesh is not moving
Try not setting the destination every frame.
when do i set it
When the target position changes
its always gonna be the player
Then maybe wait a few frames between setting it again. Anyways, there's no guarantee that it's the cause, so just try for now.
do i put it in start?
Try calling it once only at start
is it wrong that i baked the floor the player and the enemy?
this might be an odd thing to try to code but is there a way to basically script:
if anything falls below a certain y level, force it back up to a specific Y level?
im not worried about the player, but just in that case too, i dont want anything falling
i dont know exactly how to have a script tell everything its not allowed to fall below a certain point. I feel like I'd have to individually put that in each object that could possibly fall
ig it wouldnt be too difficult using prefabs, but just for future reference it would be nice
im not sure how to handle clipping like this
is this using rigid bodies or the character controller
could just disable the gravity honestly and set the y when you drop the item
the items specifically
oh well the player is controlled by the character controller but all the objects i pick up have a rigid body.
Right, well modifying physics using rigidbodies is a pain. What you can do though is turn off rigidbodies when the y is of a certain height and recorrect it. But, I'd probably just use character controllers in this case if you do want to modify them.
this way you can ignore setting gravity on the character controller when it is of the certain height

rigid bodies are cruel indeed
i might take a break because something completely unrelated broke too
When i hover over the pillars, i get the interact prompt, but the flashlight and cube are labeled the same way (Which gives me a debug log signifying that i should be seeing the interact prompt), but it gives me no prompt.
time to eat breakfast
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
anyone know whats wrong i put the code in hastebin
if u move the picked up item via forces or rigidbody methods it'll interact w/ ur walls
ignore my millions of gizmos
random question
is the block the cube is moving against also a rigid body?
i realized that i had set it to ignore collisions because i didnt want the player dragging everything along, (Which it does interact with the other object i try to pick up, which is... fine but i dont want them glitching objects through things because it got put in a weird spot), but i
the pickup object is a rigidbody
my player is a CC
maybe i should have the objects kinematic until they pick it up and its dropped? but then id have to have it know when it hits the ground to set it back to kinematic
to prevent them from dragging things i mean
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
what to do
wait this shouldnt even be a problem if i finish the inventory system

i cant escape it
i still havent done that but i need to
- when the object is on the ground (can collide with it)
- when the object is picked up (ignore player collision only)
for now i just have an offset forward of the player just big enough to not touch my player when im walking forward w/ the object
Are you sure the script is running. Put log in start as well , did you remove the setDest and put it from update to start? Make sure you print log in start too
do you have any idea whats wrong with my code
um i havent even looked but i can.
thx
im new to coding i got no ide what going on
welll gripAnimationAction isnt assigned correctly most likely..
YOU'RE SUPPOSED TO BE ON MY SIDE 
and ur code link didnt work
oh i can try again
eh that works
dont do that all the time tho.. mobile guys cant even see that..
makes em download it to their phone first
u talking to me?
yessir u posted code did u not?
anyway.. yea same answer
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
look at how u spell the one in update
and how u spell the one at the top
really carefully..
and this is correct 👍 (how u post the code anyway)
thx
Configure your IDE
If your editor was configured properly then you would not have these issues
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
bot thinking
wth is a ide
Your editor. Visual Studio, Visual Studio code, whatever you edit your code in.
visual studio
If it was configured properly it would inform you of your issue directly rather than having to check the Unity console
wdym configured
Click Visual Studio in the bot message and follow the steps
Click the one that suits you (if you installed Visual Studio through the Unity Hub you pick that one)
and please when you do.. follow the directions to a T
Hello everyone, I'm trying to replicate the camera movements seen in the Windows 3D Viewer application. I've attached a video to show the behavior I'm aiming for. So far, I’ve only managed to get the 3D model to rotate horizontally on its own axis, but I can't achieve the desired camera movements or vertical motion without the model doing a full rotation. I’ve also attached a video and the code I’m using. When I try to add vertical movement, the model ends up twisting and moving erratically. The model's pivot is already centered. I would greatly appreciate any help or suggestions to resolve this issue. Thanks in advance!
first I would use the bounds center as the point to rotate around otherwise different pivots will rotate the object wonky. On another point the MS 3d view looks like the opposite happens , camera rotates around the 3D object rather than 3D object itself rotating
also looking at your code, you should never multiply mouse inputs by Time.deltaTime.
the pivot / origin is offset
I have this script thats on ingredient that will drop after killing enemy, player will pickup ingredient and when he goes to another scene it will add up to amount of ingredients he had with ingredients he collected in another scene but problem is for example I have ingredient called Rotten Egg and in inspector under string name I write "Rotten Egg" as it is put in inventory script but when I play the game and ingredient is being instantiated it will have "RottenEgg" in inspector which is incorrect. Can someone pls help. Here is code:
so whats the value supposed to be
hello is it normal for screentoworld point of mouse position to detect mouse in scene in playmode
Value should be Rotten Egg and I put it like that in prefab @rich adder
but when its spawns in scene it will say RottenEgg instead of Rotten Egg
show the inspector
both prefab and spawned one
depends what you're doing. If its 3D a worldtoray for example can be better
prefab, btw Im gonna use Zombie Brain for now thats also ingredient
spawned in game
inspector
show how you spawn it in code
like in play mode if i m in the scene view and move the mouse then? should the game view be affected
things are affected when you tell them they are affected, scene to world is not just to detects clicks, its just to transform the mouse screen position to world (its just a conversion ) it doesnt have any additional logic.. Think Fahrenheit to Celsius etc
is there any function in unity to prevent the detection outside the game view
where do you set ingredientName , the one on this script
probably lock the mouse,
what do you mean prevent detection?
explain whats going on (the actual problem) rather than your attempted solution
yoo thanks that was problem, I forgot to change string name on zombie enemy
yes locking the mouse how do i do that
https://docs.unity3d.com/ScriptReference/Cursor.html
this class has the functions
thank you random person
Hi!
I'm getting some weird behavior.
I have a reference to one script. I have serialized the variable and referenced it through the inspector.
How ever, when I access it I get a working reference and a null reference at the same time.
I mean, i get to communicate with the script but I get a null reference error at the same time.
Any idea about whats happening here?
probably duplicate script with it unassigned. I would search the hierarchy like so t:yourclassname
I only have one GO with that component in my scene if thats what u mean
for clarification, they mean another copy of the component in the scene, not another copy of the script in your assets folder
you didn't use the t: to search by type so it's searching by name
Like this? (haven't done this before :_D)
and make sure to do the search at runtime when you see the Null logs in the console
yes, I finally I correct it, thank you for the mention <3
why?
becasue mouse input is already framerate independent
Also, idk, im asking for a vars value, not for objects with the component, so even if there are other objects with the component, my var should be referencing the one I've linked throigh the inspector right?
mouse input is already framerate independent, and that's the purpose of the deltaTime multiplication. so by multiplying mouse input by deltaTime you end up with stuttery camera controls
I think I see a whitespace beginning of name ? I wonder if that causes issues searching
show the stack trace for the log. but if there are other objects with that component in the scene then they would only be assigned if you have actually assigned something to that instance of the component
also would pass this inside Debug.log
Debug.Log(musicManager, this)
(this lets you click the log and it should highlight the object)
it works either way
ok guys got it
is not the music manager which is duplicated
but the menu controller
ty so much
i was going crazy
im so dumb sometimes xd
for future reference, don't just print single values. print actual log statements that make the logs actually distinct
happens to all of us 😛
like instead of Debug.Log(musicManager); you should instead do something like Debug.Log($"{name} has {musicManager} assigned as music manager");
i always cram name in there somewhere
i know, I should, but i get so impatient when basic stuff doesn't work
thanks for your help friends ❤️
does anybody know any UnityEvents alternatives that can serialize parameters in Inspector

