#💻┃code-beginner
1 messages · Page 114 of 1
srry no
So it isn't..
correct
following 1 by 1 ... i already checked my code from the beginning ... its only this LogicScript variable names logic that did not show up on unity
Show us the inspector for your rigid body component
@unborn gale and are you sure that you have assigned tar tag to whatever gameobject you are colliding with.
Nothing prints so likely no collision is occurring at all
They're either not touching or cannot touch
dis
yeah I didnt read that he changed his answer from yes to no
Because you haven't created it yet. Is this the first tutorial in a series or the second, third, or fourth, etc., video?
first
well I can see the bullet going over the target
That's the collider. Show us the rigid body component
Send video link plz . . .
GMTK is powered by Patreon - https://www.patreon.com/GameMakersToolkit
Unity is an amazingly powerful game engine - but it can be hard to learn. Especially if you find tutorials hard to follow and prefer to learn by doing. If that sounds like you then this tutorial will get you acquainted with the basics - and then give you some goals to learn ...
No I am not talking about that you need to set the tag of a gameobject as well.
like this
yeah if the debug msg is not printing then this could be the only thing happening
im slightly confused, by using the code public LogicScript logic dont i defined the variable type LogicScript and name logic already?
So who are you supposed to be colliding with?
green ball
Show us the inspector for the green ball
nah LogicScript is probably a custom class defined by the user previously.
In this line you just create a variable of that type.
For eg int is a class previously defined by unity and you create a variable of type int by writing public int score
Did you create a script called LogicScript? You only defined a variable that holds a LogicScript type . . .
Does it have a collider?
yeah that's what I am saying
You missed where they created the LogicScript class; go back and watch. I found it by skimming . . .
it has colision and rigid bdy
Show us the collider from the inspector
ah i see wheres the problem now i thought LogicScript is a variable type ... my naming for variables and classes are different thus resulting in runtime error
It is a type. When you create a new script, you create a class (of the same name). Therefore, it becomes a type . . .
Uncheck is trigger
yeah the 'type' i named was logic_manager ... i typed LogicScript
does nothing
It'll make it so collision can occur
The class name and the file name must match . . .
they said one of the objects should have is triger on
ah finally match and syntax error go bye bye
nothing changes nitherway
Trigger colliders cause the on trigger enter message to occur. For on collision enter, you need a non trigger collider.
yeah originally i though LogicScript is a variable type like int and float. now i learnt that when i create script the public class that comes along with the code means a new variable type is created
isTrigger will not cause the on collision enter message to occur.
nothing happens when I turn it off
is it turned off on both
Well, it can't be on. You've eliminated one issue.
For collision to occur, both objects must have colliders and at least one must have a rigidbody.
Your IDE would've highlighted that, pointing out the issue. This could have been avoided entirely. You need to set that up . . .
It's actually required to get help here - seriously.
does this count
That's part of it. Unity needs to be connected with your IDE. Intellisense and autocomplete should work . . .
Can someone give me an explanation as to why one would handle the rotation of a rigidbody in Update() and the elevation in FixedUpdate() when using the rb for a player character?
Saw it in an article on Medium.
its wrong, both should be handled in fixedupdate
Typically you want your player to rotate instantly based off the camera direction. If using torque which respects physics, it might feel laggy if it doesnt rotate instantly.
If they use update, then they arent using torque and just rotating it directly
wait @eternal needle has a good point, if you move your mouse (first person game) then doesnt it interpolate it instead of being instant?
I have a cannon that shoots a projectile towards the player but when it reaches the players position on the frame that it the projectile was shot, it stops. How can i make it travel in that direction without stopping. This is the current code:
If the game is supposed to fully respect physics then you would want to use torque still.
You can probably imagine how bad it would feel in competitive shooting games if the aim interpolated to where you moved
Also, you need to process input in Update. And rotation is perfectly fine to do there as long as you take Time.deltaTime into account
rotating a rigidbody in update, you mean?
definitely do not want interpolating aim in ANY game, not just competitive
Mouse input returns an absolute X/Y position, but there are other things in can return or you can access such as velocity
guys how i can make the bullet get the rotation of the gun forward and go to the forward direction? var bullet1 = Instantiate(bullet, bulletSpawn.transform.position, Quaternion.identity); bullet1.transform.localRotation = Quaternion.LookRotation(-bulletSpawn.forward); bullet1.GetComponent<Rigidbody>().velocity = (bullet1.transform.forward - bulletSpawn.transform.position).normalized * shootForce;
i wanted to generate the bullet from the gun and after center it into the crosshair
i have the idea to manage that by set the bullet to the rotation of the gun
but i had this
Usually you want to just match the rotations, or you can use transform.forward or transform.lookAt.
But typically you just copy the gun rotation to the bullet and apply force to its transform.forward
dont understand what this means, accessing rigidbody's velocity in update?
Is there a way to see if an object is visible or not?
You can check gameObject.isActiveInHeiarchy. or with the renderer you can check .isVisible. keeping in mind that usually says yes to objects just out of sight too and counts for the editor camera
It won't be moving so that's fine
why is my sprite pixalated?
could anyone help me please?
is this on start?
update
update the position of the player every frame, it is only updating once (when the bullet was shot)
thats what its doing currently
i told you it was on update
MoveTowards only moves towards the second parameter. So just either make a different point further than the target or use a different method
No they mean the position of the player
transform.position is the cannon round, right?
srry am just as a noob as you
yep
its alright dw, its good trying to help
its a vector2
So the value won't update as the player moves
It is just the point when the value was captured
yep
i thought of capturing the direction as a vector2 and then making the projectile move in that direction but idk how to do it
I think that is what Ashimry was talking about
Vector2 dir = playerTransform.position - transform.position
That will give you a direction vector
ik that, but idk how to move it in a certain direction
chat gpt told me to add a rb to the projectile and add speed to it, you think that would work?
transform.position += dir.normalized * speed * Time.deltaTime
Yes, that would work better imo.
Just use AddForce using the direction and a speed value
how do I convert a number without rounding to an int like 1.89 = 1, 10.1 = 10, ...
it says you cant use += with anything other than v2 and v3
you need to cast vec2 to vec3
(int) will do a floor round
it says ambigious, i guess thats what it means
ok ty I will try
how?
It just chops off everything after the decimal. Which is what you wanted?
(Vector2)
cant i just make the variable a v2
I don't know what you mean?
Which variable
What I posted only used V3s already
Don't use gpt. It is awful.
But sure try making it a Vector3
public class PlayerAnimationManager : MonoBehaviour
{
public Animator animator;
public PlayerStateData state;
void Update()
{
BaseMovement();
TransformedMovement();
}
public void BaseMovement()
{
if (state.isAttacking)
{
if (state.isFacingUp)
{
animator.Play("CastingRight");
}
else if (state.isFacingDown)
{
animator.Play("CastingLeft");
}
else if (state.isFacingLeft)
{
animator.Play("CastingLeft");
}
else if (state.isFacingRight)
{
animator.Play("CastingRight");
}
}
else if (state.isMoving)
{
if (state.isFacingUp)
{
animator.Play("WalkingNorth");
}
else if (state.isFacingDown)
{
animator.Play("WalkingSouth");
}
else if (state.isFacingLeft)
{
animator.Play("WalkingLeft");
}
else if (state.isFacingRight)
{
animator.Play("WalkingRight");
}
}
else // When not attacking or moving
{
// Set the animator to idle states based on facing direction
if (state.isFacingUp)
{
animator.Play("IdleNorth");
}
else if (state.isFacingDown)
{
animator.Play("IdleSouth");
}
else if (state.isFacingLeft)
{
animator.Play("IdleLeft");
}
else if (state.isFacingRight)
{
animator.Play("IdleRight");
}
}
}
What am i doing wrong? when the charactetr is not moving it doesn't play the idle animation and the issue seems to be here
you might be the new yanderedev
i might become a yandere yes.
when i make it a v3 the code rb.MovePostion doesnt work
is it rigidbody2d?
Nah, to vl4d9
yes it is
how can you expect any of that to work, it does not make sense
which seems to have made it worse because now the projectiles are affected by gravity
Rb2D takes a vector2
Wouldn't addforce work better?
no
btw you should check the value of player state, and where you update the state
Yeah, a dynamic rigidbody is gonna be affected by forces
If you don't want that, just do this
#💻┃code-beginner message
but can i move a static one?
how would you do it in a better way? the unity animator doesn;t fit my needs, it would bug out sadly
your code is nonsense so fix that
Sounds like you just don't want a rigidbody
#💻┃code-beginner message
Or you can make it kinematic
i made direction a v3 and it doesnt complain now
is this what u were telling me earlier?
Yeah
jeez sorry for asking for help in a code beginner channel i guess
are you making a topdown game? if so there are plenty of tutorials online on how to make the animations
Just to start
if (state.isAttacking)
{
if (state.isFacingUp)
{
animator.Play("CastingRight");
}
how do you expect the second if to ever be true?
yep its topdown!
Problem they all use animator and let it manage transitions and everything, i tried that but it doesn;t work so i have in mind so the only way is "bruteforcing" it :/
its always facing a direction and the movement script registers the last direction it was facing before stopping
perhaps thats the right way to do the things, maybe you should rewrite your animations scripts if that means avoiding bad habits later on
If it is in Attacking state, it will of not be in isFacingUp state
you miss the point
state cannot be isAttacking and isFacingUp at the same time which is what would be required to Play the Anim
@summer stump it works but now i gotta make them destroy on impact with anything
i think isFacingUp and isAttacking are independent boolean
same state variable
its the same but it has multiple bools
i know it sounds horrible but trust me the animator won;t do what i need it to do
so i need to build a base myself
so where are you update the value, the booleans are not toggling is not the problem of where you check them
So state is a struct or something?
That name made me think enum
its an SO
Oof
Ok, the second problem is you are doing this in update, so once a set of states is run you are Playing the anim again every frame
what will happen if script name in unity is different from class name it contains?
Well, you can do spatial queries or (and sorry to jerk you around here) you'll need a rigidbody on the round
OnTrigger and OnCollision require a rigidbody on one of the two object
you'll get an error when you try to use it
if i try to use it as component?
yes
is it ok to name it like that to make it look more clear in unity's explorer, like if i open some folder and i see Actor(that i use as component) and to the right there are scripts with classes Actor inherit from, all of them in sequense that matches iheritance chain?
it wont work if the rigid body is static right?
Not unless the OTHER object has a dynamic rigidbody
@fluid kiln btw a much better way of doing this would be to use a Flag Enum so it can contain multiple states, an array of your Animation names then use the Enum as an index into the array. No more huge if statements required
Thanks I’ll try!
i kinda fixed it, i made the rigid's body mass 1 and everything else 0, then gave the gun a tag "Gun", then did this code:
but now the projectile shoots a little from above the gun
Good afternoon. New member, eager to learn more because I know enough that I don't know enough and lastly I love creating something even if it's just for me and hopefully close friends to enjoy.
I’m using unity’s new input system and using just a gamepad. I’m using the left stick as movement. I needed to hold the left trigger to activate a cursor and move the cursor with the left stick. Do you recommend creating a new Action Map for the cursor and treat it like a UI or just put a condition in the movement script that says roughly “if the left trigger move the cursor and don’t feed rb.velocity”. With the second choice since this is my first game I’m starting to predict this might get very messy/conditional (lot of if/else). Thanks for the experience!
Ps. Feel free to let me know if this or there is a more appropriate area to ask questions such as this. Thanks!
try making a gameobject and set it into the position of where you want to shoot, then take its position and instantiate the bullet in the gameobjects position
nope it still the same var bullet1 = Instantiate(bullet, bulletSpawn.transform.position, Quaternion.identity); bullet1.transform.forward = gun.forward; bullet1.GetComponent<Rigidbody>().velocity = (gun.transform.forward - gun.transform.localPosition).normalized * shootForce;
right click Text, your IDE should tell you how to fix it
by "where you want to shoot" you mean where i want the shot to be shot from?
do you use TMP text? or just regular text?
yeah
not precise enough
im currently using the transform.position of the gun so idk how much more accurate i could make it
using UnityEngine.UI; ?
anyone knows how to make my bullets more precise to the crosshair?
try making an empty game Object as a child, and use its position, i guess this can help
oh it says that you need to fix the mistakes in the scripts before starting tha game
what about this one?
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
• Other/None
cuz its SetActive not setActive
SetActive with big S
!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
• Other/None
read what the bot says
if setActive doesnt have a red underline then your ide is not configured
send a screenshot of the code
still doesnt work
well... try looking it up on youtube, youtube will surely help
i dont think it will when the problem is this specific
wait
Make sure that your gun shoot logic is running after all the animations/transformations to the gun have been applied that frame
LateUpdate + late execution order if needed
Or a coroutine + WaitForEndOfFrame
You said you are using the gun's position for the bullet spawn pos... I doubt your gun's pivot is at the gun's muzzle
how do i do that?
Do what
set the pivot
You don't want your gun's pivot to be at the end of the muzzle, somewhere around the rear grip is ideal
Put an empty there
Looks like you tried that already so what went wrong?
where?
i have no idea honestly
i just found another huge problem
how can i set the pivot there?
Idk what you mean. You don't want the gun's pivot to be at the end of the barrel.
You just want an empty gameobject there and use that object's position to spawn the bullet
alright i get it now
nope, still doesnt work
i think its something with the rigidbody on the projectile
because it kinda does a curve before going to the player
ill show u wait
and i can confirm its because of the rb, when i removed it, the bullet goes straight
u cant get red underlines and stuff to appear?
u using visual studio?
did u get it through the unity package manager or what?
do u have this here?
!ide
This guide will walk you through it
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
• Other/None
i gave it to him earlier but he says he followed it and it didnt work
didnt u say u reinstalled it like 5 min ago?
Ah alright. Btw, you have an out of date Visual Studio package, and unnecessary Visual Code Editor and Rider packages here
#💻┃code-beginner message
If you can't remove them, it's because you have the engineering feature installed
oh no thats not a screenshot from me, i got it from the ide bot's link
do u have it in your package manager
window > package manager
is it installed too? has "Remove" in the bottom right corner?
@summer stump sorry to bother you but do you have any idea of whats happening?
edit > preferences
show a screenshot of ur code
maybe it is working?
did you try restarting?
well i have no idea what to do. usually the ! ide bot just solves the problem
both of them?
maybe some molecule from space hit your hardware and now it doesnt work properly
it happens
bit flip
rarely, but it happens
I'm not sure. Show your current cannon code
Show your external tools window
its because of the rigidbody in the projectile, when i remove it, the bullet travels normally
I thought you were using VS, not VS Code
Show your extensions in VS Code
And do you have any error regarding an SDK in the editor?
It will just say that word in a popup. If you don't see it, ignore that
Maybe the bullet is just hitting the cannon's collider or some other collider?
@pallid verge If that's the case, then check the Physics 2D tab in the settings and change the layer matrix so that bullet layer doesn't collide with your gun
projectile and gun scripts
Or manually ignore collisions between them with Physics.IgnoreCollision
is that a method?
Lol, the example script does exactly that
Ignores collisions between the gun's collider and the bullet's collider
Don't just switch randomly. Stick with VS and stop flip flopping.
Ok, so close VS, click regenerate project file in the external tools window and reopen vs
Having a working ide is a requirement to get help here btw
if nothing ends up working u can just completely delete unity and vs and everything, and download them again (back up ur project tho)
look at this tho, my gun doesnt shoot even when im in range of it (the circle)
it also doesnt detect me only when im right of it
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
• Other/None
what doesn't work?
did you regen Project files in External Tools?
open script, screenshot Visual Studio open with Solution Explorer
Go through this video guide. It goes over a bunch of potential issues that could make it not work https://youtu.be/kI6H3_Ry49k?si=VRR-Ciob2IEVNR_c
Right click on Assembly and do Reload with Dependencies
screenshot vs again

well not you don't have to do it again 🙂
unless you reinstall OS or sum
xp++
bugs are part of the job
I would recommend follow a structured path , the c# or unity learn ones are good
check the pins in this channel
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.UIElements;
using Image = UnityEngine.UI.Image;
[CreateAssetMenu(fileName = "Humanoid", menuName = "Humanoid")]
public class Humanoid : ScriptableObject
{
public static float Health = 100;
public static float maxHealth = 100;
public static float walkSpeed = 5;
public static float sprintSpeed = 10;
public static float jumpPower = 7;
public static string deathReason;
public static string deathMsg;
public static Image dmgOverlay;
public static Image skull;
// Start is called before the first frame update
void Start()
{
deathReason = "Suicide";
}
// Update is called once per frame
void Update()
{
Health += 0.0001f;
Health = Mathf.Min(Health, maxHealth);
dmgOverlay.color = new Color(dmgOverlay.color.r, dmgOverlay.color.g, dmgOverlay.color.b, Mathf.Max(dmgOverlay.color.a - 25 * Time.deltaTime, 0));
}
public static void SetHealth(float hp, string DR, string DMSG)
{
Health = hp;
deathReason = DR;
deathMsg = DMSG;
dmgOverlay.color = new Color(dmgOverlay.color.r, dmgOverlay.color.g, dmgOverlay.color.b, 255);
}
}
here is my code for a fading damage overlay screen effect
when i run the game, nothing happens except i get this error
NullReferenceException: Object reference not set to an instance of an object
Humanoid.SetHealth (System.Single hp, System.String DR, System.String DMSG) (at Assets/Scripts/Humanoid.cs:41)
DeathCube.Interact () (at Assets/Scripts/Misc/DeathCube.cs:11)
Interactable.BaseInteract () (at Assets/Scripts/Misc/Interactable.cs:16)
InteractionHandler.Update () (at Assets/Scripts/Player/InteractionHandler.cs:47)
um we can't read lines on discord
sorry
!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.
where do you assign dmgOverlay
also static variables cant be seen in inspector therfore cannot be assigned that way
having static vars on SO is odd anyway
well
wait nvm
im using a so to make a universal humanoid health for the player
wellll
if i were to make it non static
i'd have to declare this SO in every script i have making it reference a different health value wouldnt it do that?
anything that references this can copy the values over sure, but they cannot modify them because if they do it changes it for all the instances
but still no reason for it to be static at all
just make them regular public
or property with a backing field
yes they are meant for non-mutable
copy the values over to another class like a poco then mutate them
well static would have the same side effect
if you change 1 static, you're changing the same one as only 1 exist of that field
yup
statics vars and SO act very similar in that matter
so no need to make it static
nope
thank you
I should have said parameters . . .
Yeah dont think those events support more than 2
in the inspector anyway, ofc with delegates you can do whatever.
But arguments are variables passed in (used) for the parameters of a method . . .
Then you should learn some basic c#. That's beginner stuff . . .
I just showed you an example
public void Method(string thisIsParameter)```
what is the parameter type?
these are basic c# questions my guy
a type defines the object and its Type
eg. string, bool, int etc..
those are value types
etc
well then you should prob follow better teachings and learn this stuff
check the pins in this channel
no one is saying instantly , if you plan on doing any dev you have to know the basics
you're trying to enter a spelling contest without knowing words
Hi, I have an issue with basic assignment I was given. I went step by step on the guide and had objects with Rigid Body and Box collider 2D, but for some reason it doesnt interacts with any other objects with Box Collider 2D. So far what I found online are not related to my issue. It just looks like they arent working? But they are enabled.
This is box collider settings. I think all is correct here?
hi
show your rigidbody
does anyone know of any prebuilt inventory systems?
follow this
https://unity.huh.how/physics-messages
it will guide you through a fix
I tried changing discrete and active
search this exact stuff on this discord
the amount of times its been asked its almost like..
You will see on the website why its not working
dayummm
Yeah Im looking into it.
cause i think the last thing i want/need functionality-wise is an inventory system and thats it
"an inventory and thats it"
like its a trivial thing lol
On triggerEnter and OnCollision are different methods. I should have set the Trigger enabled?
is your box a trigger?
an inventory that acts as a "zelda" inventory, you collect/unlock items that you can equip and use
No its not
so then no
an inventory is just a collection of items. Now you need to just define what an item is and you're done
im still a major beginner so i dont know really how to code this sort of stuff yet
what wowuld you suggest for what i want
Dictionary is something you should learn in general for other stuf so I'd suggest that one. List is easier though
there are many guides out there so you just need to experiment. Im not a fan of premade systems like this (since thats what you initially asked) because you'll very rarely find one that does exactly what you need. A lot of the premade systems on the asset store are garbage too
yeah theres no tutorials for prebuilt ones
@rich adder @eternal needle @tough lagoon Thanks for your guys' answers. @eternal needle is correct that in the article the rb is rotated by changing the localRotation (image is from the article). Since the article is about using the input system for a player controlled drone, using torque might even be the better way, since quadcopter drones dont turn instantly. Lets say I use torque for the rotation and addForce for the elevation I would put both in FixedUpdate() because thats where rigidbodys go? Edit: Added link to the article: https://gamedevdustin.medium.com/drone-controls-with-the-new-input-system-in-unity-2021-f990bc0f1d47
did you try googling for any? there are definitely tutorials out there lol
like I said earlier, I would recommend using Torque / MoveRotaion or even rb.rotation
inside of FixedUpdate
yea it would go in fixed update in this case, anything directly relying on physics goes there
Ah yes. Medium , the most trusted source
im trying to look everywhere but i cant seem to find the one i need
pretty sure its in the last step
well your guide sucked ass then
Yeah this why I normally dont bother reading them and always google
But then my professor goes WhY It FeElS ThAt YoU DiDnT rEaD My GuIde
if i explain the type of inventory im looking for do you guys think you could tell me what the style is that im looking for?
there isnt really much to tell you tbh. if you dont know how to code one, and cant find a tutorial for your exact need, then you simply need to experiment with more coding.
then you should say "wHo gIvE yOu a LiCeNse tO TeAcH"
shit must've come out a cereal box
cause im looking for an inventory that as i collect items it "unlocks" it in the inventory, so that whenever you need it you open your inventory, and equip in, in turn equiping the item in game
I havent worked with C# in like a year and fogror so much its sadge.
Last I remember trying to implement DI interface.
this isn't a c# thing btw. its Unity API
scripts are in C#
thats just the langauge used to interfacte with API
Rigidbody / Colliders are specific to unity in this case
we've already told you, regardless of what kind of inventory you are making, an inventory is gonna be a collection of items. The inventory is not the hard part, you must define what an item is. This part is going to depend massively on your game. And realistically no ones gonna want to hand hold you through the entire process for free, you simply need to just start coding.
unity is mainly C++? Or C# is enough?
Unity Editor runs on C++ hence why we need an API to communicate with engine in c#
what are we looking at and where is the code relation
this is a screenshot of like 4 colors lol
2 box colliders are overlapping and idk why
not a code question #💻┃unity-talk
Hey! I'm trying to achieve the sort of puppet combo style to my game, and for my enemy, I'm trying to make it so that when the player gets closer to the AudioSource, the pitch either increases or decreases. I found a video on youtube, but it's too low quality and I think he was speaking german, so I had no Idea how to follow along. Can anyone help me make this?
reference the audio source, do a distance check. Grab the audioclip from audiio source, change pitch as desired
in like 440p
thanks for the info, unfortunately, I don't know how to do that in code. Which is why I'm here
yeah. he put 3 seconds worth of a brackeys tutorial and then his loudass mic starts blaring
no hate against the germans tho
we chillin
true, but that was back in the 40s. welcome to the modern day society
awh okay, i was looking at some last night and it was referring to items as ID's? so i refer to it as a sprite, name, and ID?
alrighty then! good luck, my friend. I will also attempt to struggle with this predicament I am currently in
you would want an item to be its own class, inside that class you can hold all those things yes
Oh. You're that beginnner. All good. I hope I can explain. We'll move to private dms if that's ok. I would be happy to help you with that
I don't have too long. Gotta go to a christmas party
or I could already have all these items "accessible" and then set the pickups as "events" so that once that event is triggered, the script/button is enabled in the menu?
"yep. That's me. you're probably wondering how I got into this situation"
so, you want me to help you in dms?
i have no clue what you mean by this, or what that has to do with what i said above
I posess the knowledge to make a sprite appear on button press, but I do not know how to change audio pitch relative to a gameobject's position
i will attempt to explain as best I can in simplistic ways
well what do you have so far
should be fairly simple
I honestly got nothing. I don't yet know how to do stuff like that
clamping and things like that
lol at least you want to help
i gotta go. I'll be back maybe tomorrow. then we can figure this out
see ya!
im just trying to figure out how i want this to work, cause im not making an open world type game where you can have a sort of random inventory depending on howw you play the game, no matter howw someone plays it the inventory will always be the same, like old zelda games, you go through the dungeon, go through a trigger, wwhich would be the chest, and then that unlocked it in the inventory, in which the player would be able to equip and unequip whenever they wanted
right click on the component you want and click Properties
i got a tutorial from chat gpt, if i send a paste bin of what it said can you lemme know if its viable?
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.
heroToControl.transform.Find("HeroInventory").gameObject;
won't find that gameObject if it's not active, right?
in fact im pretty sure i have valid code from last night
No, that is against #📖┃code-of-conduct sorry
Pretty sure it will. Not positive though
crap i do apologise
All good!
one way to find that out 😄
can i use a button as an inventory slot?
Can't do that there, have to do the = part in a method
ok
Sure. The botton can have components added, so adding a inventory slot class to it is perfectly valid
ofc
but silly
just make it a regular UI element and attach button component to it
its the same thing ig but you can better customize it this way
im really trying to understand how to put together this inventory from watching this video but hes being so vague about it
inventories are not trivial, i told you
start with a baisic one..a collection
work your way up to UI n stuff
Inventories are a broad topic for sure. Lots and LOTS of different ways to go about it. From a simple list, to slots, to diablo-like grids, and many variations on all three of those
Then there is the conversion between inventory item to gameObject or effect which is tough too
yeah its definitely frustrating to deal with haha
https://gdl.space/ovemopafud.cs
how do i assign these variables in my SO?
i defined them in the declaration, and it was null
the inspector
the only ones that can be null is Image component
you should probably not have reference types outside an SO there
what is skull a texture ?
rawimage/ Image component displays the sprite/texture
When I am instantiating my hero, I want to reference those 2 gameobjects... and I am doing it like this:
uiinput.inventoryPanelGameObject = heroToControl.transform.Find("InventoryEquipmentCanvas").gameObject.transform.Find("HeroEquipment").gameObject;```
which is giving me null reference exception. Why?
skull is a image
then you should store that not an Image component
skull shows up when you are below or equal to 50 health and you are being hurt
akin to postal 2's UI
store?
yeah store the image you want to swap although dont see a reason why those two can't just be inside a UI manager
yeah when you create a variable you store info inside of it
UI manager?
how do we know
you havent even gievn the lines
I guess I did?
thos two?
uiinput.equipmentPanelGameObject = heroToControl.transform.Find("InventoryEquipmentCanvas").gameObject.transform.Find("HeroInventory").gameObject;
yeap
thats a lot of stuff to check
and you should never use transform.Find, if the item is on the child just make a direct reference to it
ill look at my code real quick and get back to you
I guess I will just refference those 2 game objects in character script anjd pass it to uicontrol. Will be easier 🙂
yea you can also make them props
yeah, that's what I thought about. THank you
im sorry navarone im actually confused as to what you are doing
ohh I got where I made mistake anyways 😄
actually it makes sense my code is actually kinda broken when it gets to the images
on the UI
i dont know what a UI manager is, is it a class?
anyways, when i declare the damage overlay and the skull, it shows a error saying that there are two types of images
the one declared in unityengine.ui and the one declared in unityengine.uielements
so i chose unityengine.ui because it let me edit the alpha of the two images
however this doesnt work
among many other errors
i have an idea for an inventory thats "not" an inventory, if that makes sense?
it seems that all of the variables listed in humanoid is null given that all that happens when i access these variable is that i get an error like this
hi, I am trying to make an animation, when making a perimeter and referancing it in code it says there isnt a perimeter named (name of perimeter)
where
huh
whats on DebugHandler line 21?
i have an idea for an inventory in which when you start the game its empty, but then as you progress through the game, you trigger an "event" in which unlocks a button in the inventory, therefore revealing the image, name, and ability to click, therefore allowing access to the item, then rinse and repeat, so the inventory would have all of the buttons premade but just disabled, and the events enable the buttons
its like unlocking keys for mobile doors as you progress through the game
also told you this is the wrong type to store texture/sprite
iv spent way more time on this than I should
let me know if this makes sense @rich adder !
does soemone know why the character cant walk with this code. I know using the input manger would be easier but I wanted to try it just keys.
well then do it correct
yes I understand
where is there a Building parameter
I haven't assigned uiinput in inspector
so whats the actual problem ? 🤔
make what work
so reference that
then do .enabled = false on the renderer or GameObject.SetActive(false)
idk what to tell ya then
follow the tutorial better 🤷♂️
guys: 1.happy christmas, 2.how do i get the position of a collision between 2 objects? its for my bullet holes: ContactPoint contact = col.contacts[0]; Vector3 positionCollision = contact.point; var bulletHole1 = Instantiate(bulletHole, positionCollision.normalized, Quaternion.identity, col.collider.transform); bulletHole1.transform.LookAt(-gameObject.transform.forward);
btw never use use contacts array
use the method
GetContact / GetContacts
GetContacts(1)?
GetContact(0).point
my first raycast took a whole day to figure out (and thats AFTER blindly copying)
with time it will take you less and less
🏅
this will get you disqualified from medal
I also got stoked when I made a sprite follow my cursor 😄
i get sidetracked when UI is involved.
Making the buttons juicy leads to dopamine hits just when clicking 😄
clean Console 🤤
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerScript : MonoBehaviour
{
Rigidbody rb;
public float speed;
public float jump;
bool jumpable = true;
private FootstepController footstepController;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody>();
footstepController = GetComponentInChildren<FootstepController>();
}
// Update is called once per frame
void Update()
{
if (Mathf.Abs(Input.GetAxis("Horizontal"))>0 || Mathf.Abs(Input.GetAxis("Vertical")) > 0)
{
if(rb.velocity.y == 0)
{
if (!footstepController.isWalking)
{
footstepController.isWalking = true;
}
}
}
else
{
footstepController.isWalking = false;
}
rb.velocity = transform.right * Input.GetAxis("Horizontal")*speed + transform.forward * Input.GetAxis("Vertical") * speed+transform.up*rb.velocity.y;
if (Input.GetKey(KeyCode.Space) && jumpable)
{
rb.AddForce(Vector3.up*jump*Time.fixedDeltaTime,ForceMode.Impulse);
jumpable = false;
footstepController.isWalking = false;
}
if (rb.velocity.y == 0 &&!jumpable)
{
jumpable = true;
}
}
}
it works well but the jump is not always working with the same force
zero out ur Y velocity prior to the jump
if ur travelling downwards (negative in the y) ur jump will have to fight against it.. draining off some of the Y velocity
if ur travelling upwards it compounds and makes the jump higher
and take out FixedDelta time
zero'ing it out just before the jump will fix those issues
oh wait
i will try to make it else if
it's better now
wait
nvm
jump force is not the same
guys would it be possible to when i pick up my flashlight, it equips it, and it unlocks the button in my inventory, in which i can then click the button in my inventory to destroy object?
and again to equip it?
u mean like
rb.velocity= new vector3(rb.velocity.x,0,rb.velocity.z)
```???
Anything is possible if you believe hard enough
But you basically described what you need to do, so there's no need to believe, just do it
i just drew this, do you think this is viable?
First I'd have to decode half of what's written there
im not the best at drawing but does it make sense?
not if we can't read it 🤣
okay lemme remake it and ill come back
Easiest logic I can think of is:
- Have flashlight prefab
- On Flashlight pickup, auto-equip it and unlock button
- Once the button is unlocked do what you want
There's nothing much to really think about here
Is there even really a code question to this? makes sense in what context? like yea you can code it to work like this
well the thing is itd have to be the same object, cause if it just spawns a new one everytime you reclick it, itd just create infinite flashlights
its abit of both, like would this be codeable?
no this exact sequence is impossible to code, its never been attempted
Yes of course its possible to code, you just have to do it
like 99% of the time when someone asks "is this mechanic possible to code" the answer is yes. you just need to code it
I don't quite follow
itd probs be important to mention that i can drop objects too
so if i drop the object then just spawn a new one, rinse then repeat, then yano
infinite flashlights
unlesssss
i destroy the previous flashlight when its clicked again
I still don't quite follow
If you drop the flashlight then it no longer exists in your inventory
Only on the ground
There's always just one if implemented correctly
well nah the thing is im trying to do a legend of zelda style inventory
once its unlocked its unlocked
if that makes sense
its like "abilities"
so then maybe dont drop stuff on floor?
So basically either disallow dropping a flashlight or disable it once again if dropped.
or is this unlimited behaviour expected?
nah cause i wanna be able to use that later on for potential puzzles or another feature i need to tackle
nah so you could drop it
but then when you click it again in the inventory
it teleports it back to your hand
and if you click the button again whilst your holding it, then just destroy it aka "unequip"
you still dont need to spawn a bunch of items. just spawn one, everytime they want the item again just teleport it back to the player
Then just reference the dropped flashlight and use that to handle the problem.
yeah thats what im saying
but in the case that they switch to another item, or despawn the item by unequiping it, i need to be able to spawn a new one when i click it
Can't say much without seeing the actual code.
no you dont, just disable/enable the game object
It's either private or you're trying to access it as a static field
if i disable the game object, am i not still technically "holding" it? its just not there?
or is that just an easy way of destroying it
yea basically, but the user wont see it and it wont cause any problems realistically. Its better actually because destroying and spawning a new one is worse in terms of performance (although performance doesnt matter at all in this case). By not spawning a new one, you also get to save certain information like flashlight battery percentage for example
okay i know what you mean
that makes sense
Then what isn't working?
You have to have a reference to that class instance and access it via that instance.
imma work on it real quick
cause i already technically have the code
i just need to slap it on the button
void Update()
{
walking(Input.GetAxis("Horizontal"));
if (currentState == CharacterStates.walking) Debug.Log("walking");
}
public void walking(float direction)
{
if (direction != 0) currentState = CharacterStates.walking;
rd.velocity = new Vector2(direction * walkSpeed * Time.deltaTime, rd.velocity.y);
}
Does someone know why the character with this script wont move?
What's the context of what you're trying to do
You said something about clicking on things. Presumably you'd get the reference through whatever that clicking mechanism is. But you haven't shared anything about that
@eternal needle do you by chance know which object id put into my button clicked function?
cause i need to reference a piece of code
not an object
Don't multiply by deltaTime and check your walkSpeed
whats wrong with multiplying by deltatime?
Also FixedUpdate (probably)
whichever method handles showing/teleporting the object to the player
It's velocity, not distance
but it only lets me drag in objects?
wait ignore me
A button? One button? This is confusing
I thought you multiplied velocity by deltatime so it would work the same at every frame rate
Basically 4m/s is 4m/s. You don't multiply it by time.
If you set the position directly via transform.position
ok ty
wait dont ignore me
i need to fill in the thingies
like the rigid bodies, box colliders etc
how could i run code only when a switch statements has nothing true in it
to do what with
default:
to be able to find and teleport the torch to my ObjectLocation on my player
whats the button got to do with that
the button needs to activate this ^^
doesnt seem to work, says
show me the code you're adding it to
ah thanks
can i make a script with the same code but instead of allowing myself to drag and drop, i directly reference it all in the script?
this would then do the job, without the major effort
are you talking about the button?
yeah
clicking the button would allow me to equip the torch from anywhere, as if i unlocked it
so what imma do is set it to when i pick up the torch for the first time, it unlocks the button, and that then gives me access to the torch
like an ability in the game
alright so whats the problem make an EQUP method
actually your right
its just kinda similar to what my regular pickup script does
you already have the Item in the inventory/player
just equip it
SetActive(true)
or some
if i click the button, change the parent of the torch to Item location
thats how my currect code works
i mean my pickup code
Gizmos.DrawSphere(transform.position, col.bounds.extents.y);
does someone know why I keep getting an error when I try to put this code segment in update. it keeps saying "Gizmo drawing functions can only be used in OnDrawGizmos and OnDrawGizmosSelected" but I don't know what that means
cause as you said i already have the code to drop and pick it up
i just need to be able to teleport it to my hand
so make a seperate method just for button that only equips it if its already picked up
!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.
if you already picked up something its technically should be on the player already as child and SetActive to flase
imma make it so that when i pick it up it unlocks the button, if its already in my hand when you click the button then it will hide the gameobject, if im not holding it, it will equip it for me
right thats basically what I said
Hi
I have Remote config (field "BuildingsResources"):
{
"MetalMine": {
"baseProductionPerHour": 30,
"baseMetalCost": 60,
"baseCrystalCost": 15,
"baseEnergyCost": 10
},
"MetalStorage": {
"baseCapacity": 1000,
"baseMetalCost": 500,
"baseCrystalCost": 300
}
}
Plus I have those structs (also tried with classes):
[Serializable]
public struct BuildingsResources
{
public BuildingMine MetalMine;
public BuildingStorage MetalStorage;
}
[Serializable]
public struct BuildingMine
{
public int baseProductionPerHour;
public int baseMetalCost;
public int baseCrystalCost;
public int baseEnergyCost;
}
[Serializable]
public struct BuildingStorage
{
public int baseCapacity;
public int baseMetalCost;
public int baseCrystalCost;
}
Then I'm getting this json by:
var jsonString = RemoteConfigService.Instance.appConfig.GetJson("BuildingsResources");
BuildingsResources = JsonUtility.FromJson<BuildingsResources>(jsonString);
OnLoadConfig?.Invoke();
But in action I have empty parameters inside MetalMine and MetalStorage.
What i'm doing wrong?
but wouldnt your method then say that when you drop it it also disables it from the inventory?
if you want it to be dropped then you only keep the bool that it was unlocked
i think i know what you mean
if you dropped it you gotta pick it up again anyway no?
nah, thats what im saying
button doesnt come into play unless you are holding it already
if its dropped then itd just teleport the object back to my hand
like the skateboard from skate 3
well we call that Design Feature that you should clarify before 😛
you drop it and then whenever you want you can just thors hammer it back
i probably should
so keep the reference to the object
so you can easily teleport it back
and what is even the point of dropping it if you can just teleport it back in your hand xD
really quick before i do any of this i probably should mention i dont know how to open my inventory yet, as well as freezing my camera and unlocking my mouse 😭
cause later on i wanna add a sound detection feature
cause its a horror
i wanna do a thing where you can throw stuff and a monster will hear it and run to it
@rich adder this is the furthest ive ever got in a project so im really scatter brained lmaooo
well try to do one thing at a time
first thing is to be able to enable the inventory using Tab
@rich adder how would i code that if i press tab AND the gameobject is active, then disable the gameobject?
u say, ```cs
void ToggleThingAndObject()
{
thingToToggle = !thingToToggle;
if (objectToToggle != null)
{
objectToToggle.SetActive(thingToToggle);
}
Debug.Log($"ThingToToggle is now: {thingToToggle}");
}```
wouldnt that be void update?
u call it whenever u want
void Update()
{
if (Input.GetKeyDown(KeyCode.Tab))
{
ToggleThingAndObject();
}
}```
void Update()
{
if (Input.GetKeyDown(KeyCode.Tab))
{
Inventory.SetActive(!Inventory.activeSelf();
}
}
would this work?
u have extra (
u could also just check the thing..
//do stuff that u want to do when the thingToToggle is true;}
else
{
//do stuff u wanna do when thingToToggle is false
}
Inventory.SetActive(!Inventory.activeSelf); should work fine
i know this works, but it doesnt work the other way around
would i just disable it in else?
think about why the else statement would run.. in that situation where the conditional is Inventory != null
oh and 
im dying here 😭
so i can get it to disable
but then i click it again, and it doesnt enable
whats the right type?
did you assign debugUI and humanoid ?
i told you
Sprite or Texture
depending on the image
ah ok
how do i edit the color?
in this tutorial, the damage overlay is image type and the color is editable
bro i must be doing something wrong
You would change the color of the sprite renderer
how?
Like that, but with a SpriteRenderer instead of an Image
this code is only turning OFF my canvas and once its off it wont come back on
Is this script on the inventory object
So if the object is disabled, how do you expect the code to run
im sorry i only wanted nuance
HALF AN HOUR THIS TOOK ME
WHYYYYYY
now i add to the inventory some code that essentially says, when this is active, freeze my camera and unlock my mouse
There's no nuance. SpriteRenderer has a color property that changes the tint color of the rendered sprite.
It's all explained in the docs.
what chat do i go to for help regarding github with unity
#💻┃unity-talk I'd say.
do you by chance know why i cant drag and drop my playercam script into mt little drop down on my script?
i click on it and its only looking in my heirarchy
What type is PlayerCamScript
Two images and neither contains what I asked
What type is the variable PlayerCamScript
uhm, where would i look?
Where you typed the variable
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.
Why is this variable of type MonoBehaviour
i set it to that
i dont know how to set it to a script
I can see that. My question is why
Make the variable of that type
Whatever type you actually want
i dont know why im so confused
What script do you want to reference
i wanna reference a script called PlayerCam which is attached to my camera
Then use that
i did
Okay, show the updated code
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.
Okay, good. Now drag in whatever object has the PlayerCam you want to reference
how is it weird
No you haven't
not reference the script THROUGH an object like that
Neither of those are scripts.
im an idiot lolll
Those are both objects
Seems pretty straightforward
Well, considering that's a custom error message you wrote, where did you put it and what causes it to print?
Well, it's in two places so it could be either of those conditions.
Is there a reason you're doing this manual null checking? Are these fields not being set a common occurrence you expect to happen in normal play?
well i havent been able to disable the script, otherwise id be successful so id assume its the top one
im kinda using chatgpt, and reading through it
How about instead of assuming you check
stop doing that
im assuming id just change the debug message
Again, why do you have those debug messages
im not sure
sorry if i seem slow
So why not just remove them
They only make errors harder to find
If those are null, they should throw an error. You aren't doing anything useful by hiding the error and replacing it with a text message that doesn't give you any context
i never wrote it, like i said chatgpt
this entire block was given to me
i just customise it to what i need
imma try to stop using it
Correction then:
That's your spam bot generated text spam that serves absolutely no purpose but to confuse that you nonetheless put in your code base
i understand
It's in your project, it's your code
well its giving me the error cause the camera script is null?
or is that because its NOT null?
Doesn't matter get rid of it and read the much more useful error message unity provides
i got rid of them and im getting no errors?
Then you're good
So the ball bounces down perfectly on to last plane i was thinking of making it reset to its original position it dropped and basically make it infinite loop ive figured out i can just loadthe scene backup to make it infinite but what would be a good way to get rid of the bounciness it carries from the last plane
but its not doing what its intended for 😭
The issue was it was giving it unpredictable bounce because of the last plane is bounced off
I cant figure it out lol

If you reload the scene it won't have any carryover momentum, it's a whole new ball
Yeah that works perfect but i want a do it without
What should it be doing and what is it doing instead
Reload
it should be disabling the script when the Inventory is open
Set the balls velocity and angular velocity to 0
Ohhh
Along with resetting the position that should zero out any momentum it has
Show the updated code
THANK YOU i was trying to turn off the bounce after it collides with last one no wonder that wasn’t working
It still had motion carried over
I am dum
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.
Get rid of the null checks
If there's an error just let there be an error
Don't null check somethig unless there's a legitimate use case where those should be null
wdym?
I mean get rid of the null checks
okay i get you
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.
and heres my new code
Then this object does not have a PlayerCam script on it
need some help with a problem. im trying to make my player teleport when entering a trigger. Im using this code and the debug.log gets executed but the player doesnt teleport to the destination. the teleport target is assigned and getting no errors
prob a stupid solution im overlooking. any help is appreciated
{
public Transform teleportTarget;
private void OnTriggerEnter(Collider col)
{
col.transform.position = teleportTarget.position;
Debug.Log("Hit");
}
}```
log the name of the collided object to see what GameObject it is . . .
i changed the code to other.CompareTag("Player") and the script is attached to the "teleporter" object
when i imported a fps controller from asset store the script works but with my own character controller it doesnt? I've tried adding colliders and still nothing
your own character controller? are you using the CharacterController component from Unity?
or did you create a custom script that you use for your character controller?
a custom script
your previous code will set any collided object to the teleport position because you don't check what the collided object is . . .
Did you try logging the name of the collided object?
Collided with Player
log the position of the player and the position of the teleport GameObject (after you assign it) . . .
Hiii Is there a way to set default values for inspector objects? I have a serializable class and I want the default values to be different, but setting default values in the class just doesn't work in the inspector for some reason
are you sure you're looking at the correct GameObject?
but it does though?
Show the inspector of it
I don't see the InventoryState script on this object
lemme check where i put it
because the whole point is that its on the inventory i think, and its "looking" at player cam
Also looks like you gave a render pipeline/shader issue.
(Pink textures)
oh nah, im making invisible walls but i kept them pink so i could see theyre location
cause i keep biting off more than i could cheww
so i go through level design to more functionality on the player
to some more level design
so im focusing on my character fully before i do level design
i just tried adding it and it didnt fix it
it just disabled it off the bat
Show the inspector
of the object
Inventory?
The one with the script that threw the error
This object has no PlayerCam script on it, as I said before
yeah but what im saying is, is its looking at the Player Cam object, to then turn off the script, sort of reaching over to it and remotely turning it off, i just tried adding it to the actual camera and it just reversed all my controls and turned off the script without letting me turn it back on
You're getting the PlayerCam script from this object
this object has none
ohhhhh
so in Start you set the variable to null
so how would i remotely turn off the script i need to turn off
Don't try to set the variable to a component on this object
Drag in the object you want, then don't overwrite it in code with one that doesn't exist
i dragged in the correct object originally?
It doesn't matter what object you dragged in because you change it in the code
im not sure i understand?
i mean on my next step
Look at your code
You are specifically setting that variable to the PlayerCam component on this object
Why are you doing that if you don't want to do that
Yes and what do you think that line does
im assuming its just a loop thats doing nothing?
literally just setting itself to itself
What could possibly be a "loop" there
No, it isn't
oh okay
it's setting the variable to the PlayerCam component on this object
which does not exist
so it's null
okay i think i kinda understand
so what would i be looking to do exactly
PlayerCamScript is referring to the script
Instead of setting the variable to an object that doesn't exist, don't
thanks for the help. i found it is teleporting technically but you have to disable the character controller then reenable after teleportation. really weird but im guessing its because my controller doesnt use rigidbody or collider.
and i set whether its active or inactive?
That's got nothing to do with the error right now
okay well doing as you said did what i needed it to
but it wont turn back on now
Show the updated code
So, every frame, if this object is active, disable playerCamScript. If this object is not active, enable playerCamScript
Is that what you want to happen?
wait so isnt that infinitely turning it off and on
so if its on turn it off and if its off turn it on?
Is it? Do you have anything disabling this object?
!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.
nothing but what im trying to do
Why are you trying to toggle this object, when it's disabled Update isn't going to run
cause im trying to set it so that if my inventory is open, it takes that and turns off my camera
i tried the same fix as the other script but i think its doing what i said originally
i moved it onto my player because its not gonna be turned off
So why are you still checking if this object is disabled or not
to toggle a different object
Right now what this script does:
Every frame, check if this object is enabled. If it is, disable the playerCam script. Otherwise, enable it.