#💻┃code-beginner
1 messages · Page 564 of 1
what about sway
weapon sway
waht about it
idk how to add it
none of this should be on the weapon
that's a separate problem
get your basic movement working first
and weapon sway shouldn't go on the weapon either
i did
no... if you did you wouldn't be here asking this question
i have other script too but i wanna integrate it
Hey guys, this time around I wanted to show you all how to make a simple gun in Unity. This was done with a model that was made by JovisSE, special thanks to him for providing it! His info is below if you want to check out his video on how to make it. If you have any questions, feel free to leave them in the comments below. Any tips? Leave them ...
look
this guy does same
because he's making a quick and bad tutorial
also i did as u said but now i cant look up and down and gun looks like picture, theres no sway
anyway if you're following a tutorial
the answer is to just follow the tutorial exactly
and it will work
assuming the tutorial isn't shit
so, if it's not working, you did something differently from the tutorial, or the tutorial is broken.
those are the only possibilities
void DetermineRotation()
{
Vector2 mouseAxis = new Vector2(Input.GetAxisRaw("Mouse X"), Input.GetAxisRaw("Mouse Y"));
mouseAxis *= mouseSensitivity;
_currentRotation += mouseAxis;
_currentRotation.y = Mathf.Clamp(_currentRotation.y, -90, 90);
transform.root.localRotation = Quaternion.AngleAxis(_currentRotation.x, Vector3.up);
transform.parent.localRotation = Quaternion.AngleAxis(-_currentRotation.y, Vector3.right);
}
there is more to a tutorial than just the code
this is also not even all of the code
he doesnt do different
Prove it
yeah I actually watched this and its only good if you only follow this specific weapon system
it starts at 18:22
it's absolutely just poorly designed - having the player look script on the weapon object is backwards. He's just doing that so there's only one script for the tutorial
and he writes code
there's more to this than writing code
there is the setup in the scene and hierarchy
I suggest you try something else where the sway or movement on the gun is accessed from a mouse script rather than the weapon script itself
{
Vector3 forward = transform.TransformDirection(Vector3.forward);
Vector3 right = transform.TransformDirection(Vector3.right);
bool isRunning = Input.GetKey(KeyCode.LeftShift);
float curSpeedX = canMove ? (isRunning ? runSpeed : walkSpeed) * Input.GetAxis("Vertical") : 0;
float curSpeedY = canMove ? (isRunning ? runSpeed : walkSpeed) * Input.GetAxis("Horizontal") : 0;
float movementDirectionY = moveDirection.y;
moveDirection = (forward * curSpeedX) + (right * curSpeedY);
if (Input.GetButton("Jump") && canMove && characterController.isGrounded)
{
moveDirection.y = jumpPower;
}
else
{
moveDirection.y = movementDirectionY;
}
if (!characterController.isGrounded)
{
moveDirection.y -= gravity * Time.deltaTime;
}
if (Input.GetKey(KeyCode.R) && canMove)
{
characterController.height = crouchHeight;
walkSpeed = crouchSpeed;
runSpeed = crouchSpeed;
}
else
{
characterController.height = defaultHeight;
walkSpeed = 6f;
runSpeed = 12f;
}
characterController.Move(moveDirection * Time.deltaTime);
if (canMove)
{
rotationX += -Input.GetAxis("Mouse Y") * lookSpeed;
rotationX = Mathf.Clamp(rotationX, -lookXLimit, lookXLimit);
playerCamera.transform.localRotation = Quaternion.Euler(rotationX, 0, 0);
transform.rotation *= Quaternion.Euler(0, Input.GetAxis("Mouse X") * lookSpeed, 0);
}
}
}
i also have this
but i deactivated it to put that code
this cant look up or down
and it has no sway
It can absolutely look up or down
that's what this does:
playerCamera.transform.localRotation = Quaternion.Euler(rotationX, 0, 0);
if it's not working it's because you set up the scene incorrectly
how do i set up scene correctly
by copying the tutorial exactly
i did
If it's not working, you did not
try again
or show what you have so we can point out where you went wrong
how about this, just start with a basic weapon system, a gun that can shoot no more no less
worry about its rotations and sway later
this is basicest
This is only showing the GunController thing
And why are there two objects called "Player"?
This isn't showing us the setup from the other tutorial you tried
this one is empty and player controller is deactivated because i was trying to put player controlling in gun
THat's one object... what about the other one?
its a capsule
empty is supposed to be folder
It says that its called when object is clicked in collider space or GUIElement space.
But when i assigned script with OnMouseDown on UI object (with image) it didnt work, am i doing something wrong? I know IPointerDown exists but im just curious why does it say that it is possible to use it in GUIElement space?
you should not have additional colliders on a CharacterController
it will mess things up
where are they?
GUIELements are not UnityEngine.UI objects and components like Image. they are part of IMGUI
where are c# lesson guys?
Check the pinned messages
where?
oh okay, thank you
This tutorial is really bad, the guy doesn't know how half the features work
Coroutines run off the main thread
It's also generally solving problems in a very basic and bad way
what else can i do
Divide your problem into separate parts and look for help on them
Instead of generally "How do I make a weapon", ask for the best way to do parts of them
Firing delay, recoil, weapon swaying
The tutorial just half-asses it and barely explains it
i already understand those
but i cant look to sides
with this script
Doesn't seem related to the weapon
this script is about that
Looking around is something implemented on the weapon?
A weapon is a weapon, it's not your visual behaviour
Wtf
You should separate the two, it's a mess to put it on the weapon
What if you change weapon? Does it have its own instance of looking around?
that creates bigger mess
i also have seperated script
Putting it all together is the mess
i will put same script
And it doesn't work
just model changed
Your player has a behaviour to move around, which relates to movement and looking
Your weapon should worry about being a weapon
{
Vector3 forward = transform.TransformDirection(Vector3.forward);
Vector3 right = transform.TransformDirection(Vector3.right);
bool isRunning = Input.GetKey(KeyCode.LeftShift);
float curSpeedX = canMove ? (isRunning ? runSpeed : walkSpeed) * Input.GetAxis("Vertical") : 0;
float curSpeedY = canMove ? (isRunning ? runSpeed : walkSpeed) * Input.GetAxis("Horizontal") : 0;
float movementDirectionY = moveDirection.y;
moveDirection = (forward * curSpeedX) + (right * curSpeedY);
if (Input.GetButton("Jump") && canMove && characterController.isGrounded)
{
moveDirection.y = jumpPower;
}
else
{
moveDirection.y = movementDirectionY;
}
if (!characterController.isGrounded)
{
moveDirection.y -= gravity * Time.deltaTime;
}
if (Input.GetKey(KeyCode.R) && canMove)
{
characterController.height = crouchHeight;
walkSpeed = crouchSpeed;
runSpeed = crouchSpeed;
}
else
{
characterController.height = defaultHeight;
walkSpeed = 6f;
runSpeed = 12f;
}
characterController.Move(moveDirection * Time.deltaTime);
if (canMove)
{
rotationX += -Input.GetAxis("Mouse Y") * lookSpeed;
rotationX = Mathf.Clamp(rotationX, -lookXLimit, lookXLimit);
playerCamera.transform.localRotation = Quaternion.Euler(rotationX, 0, 0);
transform.rotation *= Quaternion.Euler(0, Input.GetAxis("Mouse X") * lookSpeed, 0);
}
}
}
how do i make this look up and down and weapon sway
playerCamera.transform.localRotation = Quaternion.Euler(rotationX, 0, 0);
This sounds like it handles looking sideways
it does but it cant look up and down
Also, your weapon sway can just be done without having this logic merged with the weapon. You just have to add a proper dependency. For example, but calling an event if the player's movement state changes. If it changes from stationary to walking, start swaying the weapon
Imagine merging all scripts together because they depend on eachother. What a mess. Would not even be possible anyway
I get that, I practically gave away the issue
Look at that code
BTW why is it in a if (canMove) check? Can you not look around when standing still?
do i write same one but with y axis
i think i can
Pretty much
learnt this the hard way, making scripts dependent on each other is a nightmare when your project is large
seems like you also have to use more singletons in your project @final gazelle
I mostly use it for manager scripts
events are cheats as well
That's not going to work
how could i make the player fly upwards when press w and downwards when pressing down
i honestly have no idea
I also hope you realize this yourself that this is not the correct way to do this
Increment/Decrement the player's Y Transform.Position value
ah okok!
thank you! thought abt that option but completly forgot abt that haha tyty
whats a correct way
if you want to make it so you can look around with the mouse, there are tutorials for it on youtube
I am super confused about how i can make one gameObject get another objects rotation after a button click could someone help me
object1.transform.rotation = object2.transform.rotation;
Right that does work, but i forgot to add that i want to happen only on the y axis i believe
What i want to do is when i press down right click i want the player to look towards where the camera is looking
Vector3 projectedForward = Vector3.ProjectOnPlane(cam.transform.forward, Vector3.up);
player.transform.rotation = Quaternion.LookRotation(projectedForward, Vector3.up);```
but since my camera is slightly looking downward, when i do what u wrote it makes the player look down
let me try that
assuming it is a 2d envoirement
Rotating on the y axis would not be a thing for a 2D environment
Would u mind explaining what projectonplane means?
well Praetor sensed it 😉
SImple vector projection on a plane
Like here the vector a is being projected on the plane and the result is d
Maybe a better picture
The dark blue is being projected on the plane and becomes the hollow blue
does scriptableobject being recognized automaticly by unity during the game becuase i am deleting one and making second as player and it could not be recognized
doesn´t sound good when you say at runtime
yes i am making it at runtime
make ak47 main camera child
show code
hmm deleting scriptable objects are not really a good thing
hello i am new to unity and i would like to ask you how can i grab my game object in this case that figure and move up and down when my game is running
meaning i want this arrows when my game is running
public float jumpHeight;
public float gravity;
public float pixelSize;
public LayerMask solid;
private float hsp;
private float vsp;
private bool KeyLeft;
private bool KeyRight;
private bool KeyUp;
private bool KeyDown;
private bool KeyJump;
private bool KeyAction;
private Vector2 topLeft;
private Vector2 topRight;
private Vector2 botLeft;
private Vector2 botRight;```
``` void Update()
{
CalculateBounds();
Debug.Log("Collision" + CheckCollision(botLeft, Vector2.down, 2, solid) + " " + CheckCollisionDistance(botLeft, Vector2.down, 2, solid));
GetInput();
Move();
}``` ``` private bool CheckCollision(Vector2 raycastOrigin,Vector2 direction, float distance, LayerMask layer)
{
return Physics2D.Raycast(raycastOrigin,direction,distance, layer);
}
private float CheckCollisionDistance(Vector2 raycastOrigin,Vector2 direction,float distance,LayerMask layer)
{
int i = 0;
while(Physics2D.Raycast(raycastOrigin, direction, distance, layer))
{
Debug.DrawRay(raycastOrigin, direction * distance, Color.red);
i++;
distance -= Mathf.Min(pixelSize, distance);
if (distance > pixelSize) distance -= pixelSize;
else distance = pixelSize;
if (i > 1000) return 0;
}
return distance;
}
private void CalculateBounds()
{
Bounds b = GetComponent<BoxCollider2D>().bounds;
topLeft = new Vector2(b.min.x, b.max.y);
botLeft = new Vector2(b.min.x, b.min.y);
topRight = new Vector2(b.max.x, b.max.y);
botRight = new Vector2(b.max.x, b.min.y);
}```
hello What could be wrong when i moving my player object but my distance to solid layer is still same and not updating as i come closer?
Not clear what this code is trying to do but your logic in CheckCollisionDistance is a bit confusing
what's distance -= Mathf.Min(pixelSize, distance); about?
and what's the point of the while loop
Reduce distance by pixelSize or set it to pixelSize if it's smaller but i removed it
but what's the whole point of the method
doesn't the raycast just directly give you a distance back?
I don't really get what the point of the loop is
how close the raycast origin can get to a solid atleast thats what i think
Physics2D.Raycast returns this: https://docs.unity3d.com/6000.0/Documentation/ScriptReference/RaycastHit2D.html
You are ignoring it mostly
but it has a https://docs.unity3d.com/6000.0/Documentation/ScriptReference/RaycastHit2D-distance.html distance field
which tells you how far away the thing you hit was
I recommend using that
RaycastHit2D hit = Physics2D.Raycast(raycastOrigin, direction, distance, layer);
if (!hit) return distance; // we didn't hit anything
Debug.Log($"We hit {hit.collider.name}!");
return hit.distance; // this is the actual distance to the thing we hit```
Something like this
{
RaycastHit2D hit = Physics2D.Raycast(raycastOrigin, direction, distance, layer);
if (!hit)
{
return distance;
}
return hit.distance;
}
{
CalculateBounds();
Debug.Log("Collision" + CheckCollision(botLeft, Vector2.down, 2, solid) + " " + CheckCollisionDistance(botLeft, Vector2.down, 2, solid));
GetInput();
Move();
}
still same distance
i dont understand why it doesnt updates
this is setup of that block
anyone any idea?
how do i add weapon sway?
With normal animation or procedural animation
An example of procedural would be to modify your weapon's transform in LateUpdate each frame
You can sample AnimationCurves and mix in some randomness like perlin noise if you want.
Some sort of "springs" are also often used. You didn't specify what kind of sway you mean though
What's the actual question? And what is that console screenshot supposed to show us?
here is updated distace between player and solid object and that 2 second is players postion as you can see i moving but my distance is still same
One thing that I'd say right away is that you're mixing 2d and 3d physics. That's not gonna work. Box collider is from 3d physics.
Because it doesn't hit anything.
It returns distance 2, since that's the length of the cast that you do.
and my collision is still false even tho they collide
Who they?
And what collision is false?
that figure and that platform
What "collision is still false"?
{
return Physics2D.Raycast(raycastOrigin,direction,distance, layer);
}```
This is a raycast. Not a collision.
And I already explained why it's returning false.
so what should i do so i dont fall tru that platform but and i could walk on her?
I don't understand this question
use colliders
For starters, you cloud use the correct collider: box2d. Not the 3d box collider
how can i make it so a gameobject is looking at another game object?
LookAt() is good but it look exactly at a gameobject, but what i need is for it to rotate only its y
Use Quaternion.LookRotation instead
Then lerp towards it
That would still rotate on other axes too
You could get the normalized direction from object A to B, then take transform forward of the object, assign the x, z of the normalized direction to that vector and assign it back to transform forward.
what i need is for it to rotate only its y
You can just use the Y component of it
That would work. There are many ways to do this
(As long as it's the euler Y not quaternion Y)
Can even use Vector3.RotateTowards and limit how far you rotate I believe
Yes, docs have an example https://docs.unity3d.com/6000.0/Documentation/ScriptReference/Vector3.RotateTowards.html
Isn't the Raycast just not hitting anything?
Looks like you had a 3d box collider you need a 2d collider
it works now but now that player can go thru that block down and i want when collide cant go down tru it
my component and i changed box collider to 2d on that box
and i dont want this do happen
you already had an answer, but if that wasnt enough google -> unity how to add weapon sway
What other components does the character have? Does it have a Rigidbody or a Character Controller?
where
Right below your message... 1 minute after you asked
box collider 2d and sprite renderer
what do animations have to do with weapon sway
Weapon sway is quite literally animation
why is turret (thing on the left) facing up?
Vector3 NewDirection = Vector3.RotateTowards(TurretBarrel.transform.forward, targetDirection, 1, 0f);
NewDirection = new Vector3 (0, NewDirection.y, 0);
TurretBarrel.transform.rotation = Quaternion.LookRotation(NewDirection);``` in my code i told it that the x value should always be 0, but its always -90
is there a way to safely make a looped int, ranged from one to ten, that goes from 10 back to 0 when you add 1, and goes from 0 to 10 if you substract one?
I heard about a %= thing which I used for an elapsedtime float in my game but I don't really know the true definition of it, nor how to implement it here
also I don't want to use "if" statements like if int > 10, then int = 0 in the update method because that means the int could go to 11 for a single frame
i dont rly understand what u said
hey i need some help making a main menu where it teleports you to a plane
What is the orientation of the turret's barrel? Select it with gizmos in Local mode and show us
Your code assumes that its forward (z axis, blue arrow) points along the barrel, but seems like that's not the case
Is the turret barrel parented to something? You're setting the global x rotation to 0 but it may need to be the local x rotation that you ened as 0
Wait why are you setting y to zero NewDirection = new Vector3 (0, NewDirection.y, 0);
I think you got that backwards
You want X and Z, but not Y
add to it through a method where afterwards it checks it and immediately changes it
If you want it to rotate horizontally only, that is
Just look for a tutorial
i went off course tho
he did it with 1 lines of code
and i have different one
This will look awful without any smoothing
You could do something like
int CheckRange(int current, int changeBy) {
// Alter value
current += changeBy;
// Loop int
if (current < 0) {
current = 10;
}
else if (current > 10) {
current = 0;
}
return current;
}
You are confusing a direction vector with rotation. NewDirection is not angles. It is the direction used to create the rotation.
You could also use like a Vector2 as another parameter for your min and max (0 and 10) so that you can also use it in other cases where you'd want this kind of functionality
If you want to rotate on the Y axis, your direction should be only on the X and Z axes
I have 2 menus that I want to make a transition changing from one to the other. I have created the animations, but every time they they play, the frame after they finish the position of each menu gets reset to their default one. To be more precise, I play the opening animation, the 2 menus change positions and as soon as the animation finishes their positions reset to the default ones.
I have done something like this in another place in my game, so I don't get what is different this time
You have a transition which gets triggered here
It looks like your animationOpen state automatically transitions back to your default state, which presumably would be the main screen in its original position
That is an empty state
thats why I didn't think that would be a problem
If the state has Write Defaults checked, that might affect it
Not sure though.
why if i have box collider on both of objects figure and platform and also i have rigidbody on figure shouldnt that mean my figure shouldnt fall tru that platform?
Did it have a rigidbody this whole time?
no now added it and restart it
So the colliders are 2D, is the rigidbody also a rigidbody2D?
The next question would be how are you moving the character, show code
Trigger colliders will not collide with anything
They just detect when something overlaps them
beacuse you see those steps and want to jump and climb back so that why i think i might need it
You mean like going through platforms?
see and now i want to jump up again on that grass
sounds like you want platform effectors
Unity has a component for this https://docs.unity3d.com/6000.0/Documentation/Manual/2d-physics/effectors/platform-effector-2d-reference.html
yo guys does the index number on a list begin from 0 or from 1?
have you tried googling that at all
a quite small set of languages start with 1, most start with 0
but then does the last item's index on a list = List.Count - 1, or just List.Count?
count-1
aight thanks
the countth element would be the "past-the-last" element
just wanted to make sure I don't mess this up
also I feel like this isn't a question serious enough to ask on #archived-code-general
Count = 5
-1 0 1 2 3 4 5
[ a, b, c, d, e ]
5-5 5-4 5-3 5-2 5-1 5
so thats why i was thinking i need it beacuse i will make enemies that will shoot and my player so i thought i might need if bullet overlaps with my player or colliding will work well too?
You can still detect bullet hits with OnCollisionEnter2D, so no problem there
Or with raycasts if you want
im having some trouble understanding how to fix the issue or whats wrong with this, the warning is shown below
7 >= 0 is true, you have an infinite loop.
you probably want y >= 0 there
also you shouldn't use those hardcoded 7 and 99 in case you plan to expand in the future
consider something like this
for y from 0 to potionBoard height:
if potionBoard @ x, y is null:
return y
return -1
ty appreciate this
im gonna work on this, currently following a tutorial so wanna go look afterwards and readjust stuff
Rotate does not set the rotation, it adds to itcs axePrefab.transform.Rotate(0f, 90f, -45f); // Reset rotation
Probably similiar to how you are setting localPosition, but use localEulerAngles instead
Make sure to do it after SetParent, assuming you want to set the rotation in local space relative to its parent
ok thanks
you should try setting it via transform.EulerAngles
since I'm guessing you don't want to deal with quaternions
ay thanks it works
I need to refine the angles but the setting the angle ect works
thanks
Or cs ...transform.localRotation = Quaternion.Euler(...);
Guys, I have a question
Well, if your player's z rotation equals 0, you can rotate him backwards by just changing y rotation, right?\
well, how to rotate him backwards if your z rotation is not a zero?
did you understand me?
not really
Does anyone know how I can make some objects ignore collision with each other?
You can use collision layers
player has 0 z rotation
sure, you can do that in the layer collision matrix or https://docs.unity3d.com/6000.0/Documentation/ScriptReference/Physics.IgnoreLayerCollision.html
and i can turn him backwards by changing y rotation
That wasnt appearing, thanks
but now, the player has 45 z rotation
and if i will try to change his y rotation, this happens
how to rotate him this way
If you want it to look down in the direction it's facing, you'd also need to invert the z rotation so it would end up at -45 instead of 45
A decent way to do it would be to first set your Y rotation and then set your transform.up to the ground normal direction
without normals?
Why not use normals from the collision or ground check?
Are all your slopes 45 degrees?
no, i have even loop-da-loops in my game
i made rotators that checking rotation of player
Is there a quick way to check if a raycast is hitting an untagged UI element?
is there a channel for people to playtest someone elses game?
i wanna play some underrated games
that sounds really weird. what you trying to do there
there are some playable ones in #1180170818983051344
i'm working on a XR application here, for context
So, i have a sellectable object (in this case, that chair there), which is currently selected, i've programme it so if you click the trigger while the controller ray is not aimed at a selectable object, it deselects any selected object
is phyton easier to learn then c#
because i basicaully understand evrything in unity but just not the coding
so maybe im gonnna switch to unreal engine
the thing is, due to the smoothbrained way i implemented it, whenever i interact with the UI it deselects the object, so i'm trying to get if the controller ray is hitting an UI object, then do NOT deselect object
it is
depends on your experiences and such
why
but the important thing is the logic, breaking mechanics into parts
you're gonna have the same job in unreal
i didnt know unreal uses python
wanna learn game development but feel like unity coding is more confusing and harder
it does not
really?
unreal engine has c++ which is way more difficult than unity's c# by the way
i tought it did
it uses c++, and it has better support for blocks (called blueprints)
okay nvm, unity it is
However
It has blueprints, which is a lot easier to get into than straight up coding
i spent learns doing Unreal stuff with blueprints and it helped a lot when moving over to a language like C#
BUT the main thing you'll have to practice, the main thing in programming, is the logic of what you're making
you gotta break problems into parts
you can't escape that
Yeah
maybe really stupid but is starting off with luna (roblox studio) easy
just to get a feeling of codinjg
Blueprint helps a lot with learning the logic without having to worry about syntax and recompiling
the syntax of a c-family, OOP language might look scary, but there's really not that much to it. it'll be a few hours to a few days of learning
the main thing will be about learning the semantics of the unity (or unreal) interfaces and the logic to link it all together as mentioned before
i mean you can start off with python like you mentioned earlier. it doesnt need to be a game engine
so you know some programming already?
oh misread that
i mean, just start at whatever tool you want to use at the end. the language is not gonna be the main chokepoint
no but i watch a lot of videos of programming and a lot of it makes sense but whenever i try it myself i just blank out even with a tutorial
unity is my main goal to use
start small and build up to making your own stuff
then start off with c#
i know it looks scary, and it probably will be for a bit, but there's not that much to it
and unity, at least at the basic-intermediate level, doesn't really use advanced c# features
but every tutorial i follow after 20 minutes the code just doesnt work for me even if i follow it step by step
@nocturne kayak #🥽┃virtual-reality
you might want to consider asking about those
@naive pawn for example, how did you learn coding?
User error
go onto unity learn and junior programmer, I learned the basics in a week.
started small and worked my way up
Unfortunately the virtual reality channel is as dead as the vision pro, so i'm trying to break my problem into smaller coding problems to actually get some help , such as:
is there a way to compare layers the same way you compare tags? like a hit.collider.CompareTag, but for layers?
uh if you're using raycasts just use a layermask
ill do it rn
there's no method for comparing layers, but there is a layer property you can use
layermask shoudl fix your problem yes, it will only detect the objects you want and ignore anything else
i would not advise it though as that is an int and you could easily mess that up
whenever i feel like im to stupid for this ill probally come back here
we can't fix stupid, but that's usually not the problem! it's usually inexperience, and that can be fixed with time and effort
yeah it just feels like a whole job
well, it is
i just hope later in my life it will help me with finding a job'
it will probaly look pretty cool on my portfolio
gamedev is programming, writing, drawing/modelling, animating, composing, sound engineering, level designing, ui designing etc.. all in one
yeah but then i already have some good basics of coding because of game development
The member is directly accessible. Compare tag method is recommended for tags because string comparison can be slow.
bc thats the only fun thing i like that uses coding features
in GameDev or programming?
aw cmon, you're telling me opening a bunch of terminals and running while true; do printf $'\033[32m%04X\033[m' $RANDOM; sleep 0.001; done on someone else's computer isn't fun?
is that an actual code
not c#, but yes
that just seems like real depression
programming? nah
dont even know what a terminal is yet
i prefer Pro gamming.
it's where your dreams go to die.
but atleast when i get a error thats not on reddit yaal are here for me🫡
Wrong server for this kind of discussion - off topic
result of this script
holy f*ck
programming lets you get up to some shenanigans lol
though to be pedantic; this is more of scripting than programming, kind of a different style
it's a pedantic difference in what the end goal is, it doesn't matter too much tbh
and it's a really fuzzy boundary so i don't think i can properly explain it 😅
i hope i get some more girls with coding (i will lose all my hope in life and never want to live but atleast i made a cool game with a rolling ball that never ends)
oof, it's kinda a meme that programmers/cs majors don't get any lmao
not that that's true but 
not saying, sorry.
oh sorry
their name is literally That_Guy
lel
ohh smartypants
Jules learn programming you will not regret it,forget blueprints
SIR YES SIR!
(i mean blueprints are also programming but if your end goal is unity then just go with that)
wait why did you change your name 🤔
hey! chris changed his name
now will never know what gender he is
(his username is still that_guy btw) 🤫 '
okay lets get watching hours of coding🫡
dont just watch, you gotta follow along
yeah im doing it
ill get some chips probaly
with some coke zero
that sounds good
ill be back
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/ , https://paste.ofcode.org/ , https://paste.myst.rs/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
https://paste.mod.gg/snhakrbdhbom/0
why cant it find anything i try to put in bin 1? (check the add sample data function)
A tool for sharing your source code with the world!
I have no idea what you're asking
Average Linux users screen
And even if I did, I don't think I'm feeling like dissecting 400 lines to figure it out unless you explain the specific part to look at
first, look at the class i have on top named ClothingData and look at the variables i have in it. collapse all of the overrides and the functions in my monobehavior class so you can search through easier.
private Dictionary<int, List<ClothingData>> bins = new Dictionary<int, List<ClothingData>>();
thats my declaration of my dictionary.
expand the AddClothingToBin and SearchBins functions.
then look at my AddSampledata and then look at SampledataUnitTest.
i know im doing something wrong but i definitely need someone else to check my logic
Something wrong because there's an issue? I'm still confused? Do you just want a review?
What is bin 1?
for some reason in my unit test, the logs said that the blue shirt and the yellow shirt cannot be found.
bin 1 is key 1 in the dictionary
cuz the dictionary has int as the keys
i feel like im not iterating through the dictionary properly since nothing i ever put in bin 1/key 1 in the dictionary seems to ever exist
i gotta go to work ill be back tmrw 😦
does anyone have good knowledge of post-processing? I added post-process layer to my overlay camera to make the flashlight react with the environment but it made the flashlight a bit transparent (hard to show) and I have spend way too long trying to find a solution to not have it be that but nothing have worked. IM crashing out
better example
i dont think so i just know that post process layer makes it transparent for no reason
where do i post this then?
whats, then do\
thats the slogan they use
Hey, i have a singleton calling all these events
`public static event Action<PointableCanvasEventArgs> WhenSelected;
public static event Action<PointableCanvasEventArgs> WhenUnselected;
public static event Action<PointableCanvasEventArgs> WhenSelectableHovered;
public static event Action<PointableCanvasEventArgs> WhenSelectableUnhovered;`
how would i subscribe to them in another script?
because this:
private void OnEnable() { Action.WhenSelectableHovered += TestMethod; }
doesn't seem to work
What about it doesn't work? Is the class containing those events called Action?
Since you are trying to access WhenSelectableHovered as a member of Action
that makes sense, the class i'm to get the event from is called pointableCanvasModule, but when trying to access it through that, i get this:
It is static, so you'd have to access it via the class/type name: PointableCanvasModule.WhenSelectableHovered instead of the instance
I'd suggest learning about how static works before continuing tbh
Oh man, i wanted that gift link
Bot snatched it for itself 😔
then resolve them
very gut help 👍
https://paste.ofcode.org/6GZciJZ6DCKkw9ZUHp5PSi
problem is that I want it to unequip the weapon if it is the same weapon in the same handler but it removes then equips back
this photo is when I equip the same weapon on the same handler.
Generally that sort of thing happens when you're doing everything in subsequent ifs instead of if else/else if s
This kind of thing, where you immediately do the next thing, instead of isolating subsequent logic
void Do(bool shouldDoThing = true)
{
if (shouldDoThing)
{
Debug.Log("Doing thing!");
shouldDoThing = false;
}
if (!shouldDoThing)
{
Debug.Log("Not doing thing");
}
}```
Any good sources on general unity architecture concepts/best practices?
Like, hierarchy player script concepts vs having a monoscript
Where should I manage my players respawn ideally in a multiplayer game? In a global game manager, or in each individual player scripts?
Not sure if these kinds of questions make sense
I'm working on my first game, and although I fully understand that I am on an early beginner's path, I'd like to try and learn and work with best practices as much as possible
I am an experienced programmer, but rather new to Unity, hence my questions I guess
honestly i would say there is not a single 'best' way to do these things, it's really up to your preference in how you like to organize things and there are pros and cons to each approach
personally i like having managers to handle things like player respawn as I find it easier to implement the types of logic you often need
for example if respawn was handled in the player controller, it might be difficult to implement something like respawning players sequentially, or waiting for a whole team to die before respawning them, etc
SOLID
Async - Additive scene loading..
- master scene that stays persistent and holds all ur managers/singletons UI/ Data or w/e
load scenes in and out along-side that master scene
thats just my little two-cents.. best o luck @signal raptor ☝️
regarding player controller i like to have the player always 'drive' another character controller, such that you could have another script like an AI drive instead
even if you don't intend to have NPCs i think its a nice way to organize things
i replied to the wrong person festive
srry
lol.. Unity dropping the "Kiss" principal cracks me up a bit
good point.. this would be the "S" in solid
Ideally you shouldnt even be doing multiplayer as your first game. No matter how much experience you have in other fields
also.. sorta in the same realm.. i think what ur saying is.. 'the enemy should be able to do everything the player can do"
oh snap.. this is MP?? oh yea if this is ur first endeavor.. id maybe re-think that..
Much obliged! Going to give this a thorough read
if not.. then ur actually on a better track then alot of other newbies...
thinking about Multiplayer as u build ur project is the only way
some ppl coming in here like: "I built my game.. now i want to add MP"
face-palm hard lol
im reading it as we speak.. i didn't know Unity had their own E-book about solid
ive always found third-party documentation
That’s kinda my idea. I understand a lot of things change heavily from SP to MP
I’m experienced and an architect on enterprise high level software development
Which I understand is almost a polar opposite world when set against Unity
when u break up ur mechanics and stuff into simple scripts...
makes it very modular
eh, theres some correlations to be seen
I though. Might as well give it a try on my pet dream project
👍 don't feel like u have to work on that project every day..
save it.. keep backups.. but dont be afraid to make a few experimental projects along the way
I don’t ilude myself thinking it’s going to be a highly polished and amazing piece of work though, but it’s a good motivator
And I can always build a sequel one day in the future 🙂
That’s a surprise. Though I’d get a different opinion on this
GUYS, I HAVE HUGEEE NEWS
me?
lol.. just wanted to share my news
i was just excited😔
whats up?
but its something
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/ , https://paste.ofcode.org/ , https://paste.myst.rs/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
yes please
dont get too impressed alr
its probaly not your level
just so u dont get offenden
no problem.. i wouldn't expect it to be
offended
ohhhh youl see
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/ , https://paste.ofcode.org/ , https://paste.myst.rs/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
Thanks. Will do
read this embed
why does my flashlight move around instead of stopping me?
u ready?
im trying to make it so my flashlight doesnt go through the walls
b/c unless its being moved with Physics functions..
it wont
offended
ohh.. thats simple.. Draw the Flashlight (weapon) on top of the rest
I'm assuming it doesn't but instead moves back towards you? 
it took me a whopping 4 days for any script to work
Describe what's happening and not happening.
kinda it like just starts moving ill try and send a clip
1sec
he got offended and left
lol. nah.. im a very busy person (most of the time) gimme a sec
populair boy i see
what does this mean?
OHH.. i see.. at first i only saw the PlayerController w/ a single translation in update
but it took me a whopping 4 days😁 👍
any idea how i can fix this.
looks like ur .meta files may have gotten fuggered up
wait what
wait
i'd try re-importing the model/prefab'
ur telling me my only script is BROKEN
I mean it's simple, all you are doing is translating the transform of the object the script is currently on in local coordinates
no.. this is all i seen at first
i didnt notice there was a second file
i only used a source 🤔
dont care🖐️
its perfect
it wasn't supposed to be offending lmao
just joking👍
using UnityEngine;
using UnityEngine.InputSystem;
public class RigidbodyController : MonoBehaviour
{
public float moveSpeed = 10f;
public float maxSpeed = 5f; //Maximum movement speed
public float jumpForce = 5f; //Jumping force
public float movementMultiplier = 5f; //Multiplier
public float groundFriction = 10f; //Friction
public LayerMask groundLayer; //Check ground collision
private Rigidbody rb;
private bool isGrounded;
Vector3 moveDirection;
private void Awake()
{
rb = GetComponent<Rigidbody>();
}
private void Update()
{
playerInput();
}
private void playerInput()
{
float moveX = Input.GetAxis("Horizontal");
float moveZ = Input.GetAxis("Vertical");
moveDirection = new Vector3(moveX, 0f, moveZ).normalized;
}
private void FixedUpdate()
{
HandleMovement();
}
private void HandleMovement()
{
//For showcase purposes
rb.linearVelocity = moveDirection * moveSpeed + new Vector3(0, rb.linearVelocity.y, 0);
//AddForce movement
//rb.AddForce(moveDirection * moveSpeed * movementMultiplier, ForceMode.Impulse);
//movedirection
Debug.Log(moveDirection);
// Add Drag
}
}```
is this urs too?
@rocky canyon im a new user to unity dont mind me if i dont really understand what you are saying i know the basics i even made the vr work on my headset but its eh
the structure is okay..
seems u have an understanding of the update loop vs the fixed update loop..
too many comments for my taste.. (try to use good naming and u wont need as many comments)
good code can kinda be read like a book
float moveX = Input.GetAxis("Horizontal");
float moveZ = Input.GetAxis("Vertical");```
i typically use `GetAxisRaw`
but nothing wrong w/ GetAxis if it works for you
one has built-in smoothing and the other doesnt..
i'd rather do smoothing myself if it needs
no worries..
there seems to be missing references...
when u create a file in unity..
say a prefab for example... the prefab is saved in the project folder.. but also a .meta file
that meta file holds stuff like settings for that object..
say i built a script and it had a few references i could drag in.. (if i did that the meta would always update it so the values are correct)
this applies to lots of things..
and it seems to me by the error that its just looking for some things that may not be there..
i actually know very little about VR tho
@winged seal can i see it we are the same age just wondering how much ahead u ar on me
soo.. i can't really help specifically
what
can i see your vr game?
working menu is crazy for me
https://docs.google.com/document/d/1GJODylszZKtniA9I4bcbh-WyBQ8JAqznT-TkHJvG8zM/edit?pli=1&tab=t.0 i found this
How to fix missing prefab or asset references (gameobject asset/prefab refs) E.g. STEPS Find the asset that the gameobject was referencing (prefab, model file, etc) Protips: If that prefab or model file is a blank symbol/icon (like white paper), then it's a surefire sign that the prefab or...
maybe it can help u out
heres mine 😈 lol. just the current project that i have open
anywho.. check out that link i sent..
it may help ur situation.. since its more of a project-specific type of error
this is mine.
make them buttons not bland.. and it'll be solid 👍
right click -> open with Notepad
i mean im trying to find the meta.file
the meta's wont be visible in the project window
right click anything in ur project folder
and go to Open in Explorer
👀
nice 👍 just follow that article..
i cant say if it works.. but its the best thing i could find
heres the thread i took it from..
what is a guid?
theres more info in that if u need
its the ID number
every object has a unique GUID
In Unity, a GUID (Globally Unique Identifier) is a unique identifier assigned to each asset in the project to ensure references remain intact even if the asset is renamed or moved.
this is what i need to find
there it is
wait i clicked on scenes then clicked on open in explorer
thats right?
or do i need to find the left hand
hello i gave animator to player object and i i have separated legs and chest how can i animate legs and chest together beacuse it seems that only legs work?
it looks like the prefab was unpacked at one point.. and parts of it deleted maybe
did it fix it?
yep it works!!!
hell ya 💪
yeeah!
idk.. i think that may be a #🥽┃virtual-reality type question now
you'll have to select the Chest object
and animate it as well..
i see that on the pc on the right side but i dont see anything in my right eye in the headset
add keyframes and change out sprites as needed
is this an asset? it may be worth asking the developer..
but i don't know squat about VR.. soo imma politely throw in the towel for ur issue 🍀
lmao im tall
i zoomed in and i see this 😆
hey also something?
so if i have both the hands having that issue like currently the right hand do i have to go somewhere else or the exact same text file?
Anyone has an idea why knockbacked isn't effective ? (player not being moved on collision)
What happens if you drastically increase the force? Like if you change it to 1000 or 10000 or something instead, is it still not working?
hello how can i implement if i on platform and click arrow down my figure will move to platform that is other that previous platform if i use rigidbody for that figure
Well, how do you move your player?
If you set the velocity based on player input every FixedUpdate, the velocity caused by the knockback goes away
Yeah actually the issue was not about the velocity (I even debugged the fact that it was stored permanently even after the player regained control ??)
It was about the fact the player's position was overriden by MoveMC() called everyFixedUpdate
not the velocity though (if I don't set rb.velocity = Vector2.zero here, the player's velocity stores each knockback, making each successive knockback stronger in force; not sure why rb.velocity doesn't go back to 0 after player move input)
using UnityEngine;
public class PlayerController : MonoBehaviour
{
public float moveSpeed = 5f;
public float jumpForce = 10f;
public float jumpCooldown = 0.2f;
public LayerMask groundLayer;
public float groundCheckRadius = 0.2f;
private Rigidbody2D rb;
private Animator anim;
private bool isGrounded;
private float jumpCooldownTimer = 0f;
private Collider2D collider;
private bool playerOnPlatform;
void Start()
{
rb = GetComponent<Rigidbody2D>();
rb.freezeRotation = true;
anim = GetComponent<Animator>();
collider = GetComponent<Collider2D>();
}
void Update()
{
HandleMovement();
if(playerOnPlatform && Input.GetAxisRaw("Vertical") < 0)
{
collider.enabled = false;
StartCoroutine(EnableCollider());
}
}
private IEnumerator EnableCollider()
{
yield return new WaitForSeconds(0.5f);
collider.enabled = true;
}
private void SetPlayerOnPlatform(Collision2D collision, bool value)
{
var player = collision.gameObject.GetComponent<PlayerController>();
if (player != null)
{
playerOnPlatform = value;
}
}
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.tag == "Ground" || collision.gameObject.tag == "Platform")
{
isGrounded = true;
}
SetPlayerOnPlatform(collision,true);
}
private void OnCollisionExit2D(Collision2D collision)
{
SetPlayerOnPlatform(collision, false);
}
}
guys i added platform effector 2d i can jump tru plafroms but i cant jump thru down platfrom when i press arrow down any idea why?
-
Is
playerOnPlatformbeing set correctly when you land on the platform?- Have you confirmed this with a
Debug.Log?
- Have you confirmed this with a
-
Does the tag on your platforms match exactly what your collision logic checks for?
-
Is
Input.GetAxisRaw("Vertical") < 0being triggered as expected?- Did you confirm this works with a debug log when pressing the down arrow?
-
When you press down, is the collider actually being disabled?
- You can log
collider.enabledbefore and after disabling it to confirm.
- You can log
-
Platform Effector 2D settings:
- Have you double-checked the
Surface Arc? Is it set wide enough to allow the drop-through behavior?
- Have you double-checked the
-
Does the coroutine that re-enables the collider run before you’ve fully dropped through?
- Maybe the timing is off—try adjusting the delay to see if that helps.
Final thoughts: Simplify and isolate the issue. For example:
- If you temporarily remove unrelated code like the jumping logic, does the issue still occur?
This can help narrow down the problem—if you remove something and it magically works, then you know that piece of code was likely the culprit.
TLDR: debug ur issue
is it fine to do a music mute button like this
or should i do it in like with just this on click thing by going to the audiosource and pausing and unpausing like this and is there a better way to do it in the script so it pauses instead of mutes that doesn't require too much stuff
-# realized late this is easily googleable
oh wait just remembered yes the script is needed for resizing cuz it moves
but is there a way to pause it?\
aSrc.Pause();
aSrc.Play();
thanks 👍
use w/e feels natural for ur game..
i personally hate when games mute the audio.. and then when it starts back its like 2 minutes into a song or something
i much prefer Pause..
yeah imma do that
there was a bit of "asking for opinions" in that question as well.. soo no worries bout the google thing
Damn, I hate those bugs that appear for no reason, even if you did not changed the code of it.
Last time, I was able to solve it just by upgrading the unity project from 6000.0.23 to 6000.0.24 and everything was fine without changing anything in my code, my Gameobjects or Inspector.
Can't really help you without you sharing the details.
I don't even know the details, I could send you a picture of a toggle but there is nothing to see, the code is perfect and it even works for all the PC platforms, and it even did work on android, but now its happen again that android doesn't want to run the Script I have added in the inspector in the OnClick event of my toggle.
But the strange thing is it does work, why should a onclick inside of a toggle only work for PC especially if it also did work for android just 2 days ago and I did not changed anything related with this toggle.
For starters, you could add logs or step through the code with the debugger, to see if the event is called/subscribed to at all.
It did not even want to play my audio source for this specific toggle that doesn't want to apply my value to the game.
I mean at least the mp3 sound of the button click should play and in debugging it does get executed, otherwise PC would also have this issue.
I did and it worked perfectly like it should, only in the android build, its dead. but on windows and linux, I get my outputs
and only this specific toggle, all my other UI buttons, sliders work perfectly on android.
Do what I mentioned in the android build
There's no point in confirming it on platforms that you know it works on, is there?
so what exactly are scenes?
for example I can have a scene called startPage for game options and stuff. Then another one called "Map1" for map #1, "Map2" for map #2 etc
or is not how they work?
You can have scenes of anything. They're just a collection of objects that you load and unload.
so yes I could do that?
think of scenes like levels in games youve played before
ideally youd have a seperate scene for the tutorial, team deathmatch, ffa, main menu, etc
okay so basically if I were to make diffenent maps for my game, I would make a different scene for the Main Menu, Map1, etc
as Dlich said because it loads and unloads objects
yeah thats how most games do it, but there are other options ofc
I decided to do something like this to change an audio when a player enters a zone. now I couldve done like 20 other methods but I decided to do this. does anyone have any suggestions to change the line in red so it changes overtime? kinda like in the green circled one. the reason why I cant copy the green circled is because the pitch could be either positive or negative. I would like a simple one line fix, if you dont have one dont suggest I cant remember if I did something like this with a simple math equation and thats why im asking. I think it should just be one line of math to fix it.
yeah it would improve resource usage as well
okay then from using scripts I can load other scenes for example:
when [PLAY] button is pressed it goes to Scene2 from MainMenuScreen
then when player dies gos back to MainMenuScene
💀 yall laughing
yeah exactly
To be clear, scenes are not only for "levels"
You can have scenes for anything in your game. A scene specifically for UI that is loaded asynchronously so you don't have to have the same UI prefab in every level for example.
i intend on solely using scenes, but are there practical alternatives to scenes
yes so like only have my MainMenu UI in my MainMenu scene so it doesnt bother any other scene
No, that's not what I mean
wdym practical alternatives. what are you trying to achieve
I mean having a scene for your gameplay UI only, that is loaded asynchrously atop your level scene. You can have multiple scenes loaded at once.
i'm not trying to achieve anything, as i said i only intend on using scenes, it was more just a curiosity thing since you mentioned there were other ways to do it
oooooo i see what you mean now that is useful thank you!
the only other reason you would use one giant scene is for open world games afaik
think of something like another crabs treasure if youve played that before. it has everything in one giant scene and uses LODs for everything
should I use URP or HDRP?
this allows players to glitch into areas that they shouldnt get to before certain checkpoints
(since everything is always loaded in)
ahhh yeah that makes logical sense, that's quite cool
well another crabs treasure isnt an open world game but it works as an example
you would have to choose that yourself, look up what each of them offers and choose via that
https://unity.com/srp/universal-render-pipeline
https://unity.com/srp/high-definition-render-pipeline
Matter in what way?
It's changing the rendering resolution, so of course it's gonna change stuff
like for differnt displays will it pop up differently?
Yes. This allows you to see how the game would look at different resolutions and aspect ratios
so I would have to make everything compatible with them?
or could I have my game just be 1 of them
You can make game with only 1 aspect ratio in mind. In this case, you'll need to decide what would happen on monitors with different aspect ratio(stretch or show black bars).
Or you could make your game flexible such that it works okayish on most aspect ratios. It's up to you.
hmm okay thank you!
just started the John Lemon course and it is saying to add this line of code to set a variable m_Movement.Set(horizontal, 0f, vertical); is this different than m_Movement = new Vector3(horizontal, 0f, vertical);
What is m_Movement in this case?
Is it a variable, or a property?
i hear its miniscule performance gains. important for an optimized codebase but irrelevant for smaller projects.
Thats what I figured
they are more or less functionally the same as far as the m_Movement Vector3 is concerned, but one thing to consider is where the Vector3 is coming from, like digiholic mentioned
For example, transform.position.Set(0, 0, 0) won't work as expected because you're modifying the returned Vector3 which does nothing (because transform.position is a Property and not a field)
whereas transform.position = new Vector3(0, 0, 0) modifies the Vector3 stored on transform as expected
If m_Movement is a plain Vector3 field (not a property getter) then they will work the same, but if it's a property it might be returning a copy of a vector
public Vector3 m_Movement
{
get;
private set;
}
m_Movement.Set(horizontal, 0f, vertical);``` //dont think set works here
thank you guys
I am trying to learn unity but theres so many different things and ways I can make stuff work. I feel like my brain is full.
just start making stuff.. the more u do the more u learn bout whats important to u and ur game.
dont worry about optimizations until u need to
^ thats some advice i was given when i was green
yea, I have been copying the code that I follow on courses into ai and telling it to make comments and explain what each thing is doing in depth to try to get a better understanding.
Don't do that, AI will sometimes bullshit their way through an answer in a way that might sound reasonable and you might internalize, but can be factually incorrect
Understand the basics of programming logic, and build up from there
start with a small project
don't get it? try a smaller project
don't get it? try a smaller project...
The official Unity tutorials gave me a bit of a hand when i started, i was transferring over from Unreal
okay, yea I tried starting with unreal, hell with that for trying to learn.
Personally i found it easier to learn shit with unreal thanks to blueprint
oh, I was opposite, I found that there was a lot more courses for unity, I couldnt find many places to learn unreal other than youtube, but I also didnt look to much into it.
Honestly, no joke-
I learned Unreal through youtube
and kind of made a career out of it
thats awesome
I know just enough to stay at my job
But following tutorials on youtube isn't bad
i find it pleasant because you can get bite-sized projects that teach you things you are interested in learning
yea, why did u switch?
For me it was wall-running stuff at first, which taught me a surprising ammount about vectors
Unreal's kind of becoming more of a visualization\movie making software rather than a game engine
at least that's my impression of it
I thought the same thing when I was trying to learn.
RN i'm working on a XR project and unity is a lot more lightweight for that
This is getting #💻┃unity-talk levels of off topic, so if you wanna keep talking, let's move there, but bottom line is
it IS a lot of stuff, don't think about making your dream game, learn through small projects and don't increment projects by size, but by complexity
take one project and learn about vectors, the one about interfaces, the next about events, etc
alright, thank you
hi, I'm learning through the Roll-a-ball game tutorial, and was struggling in scripting, and apply force to the Player. I'll drop my code here.
there's also a problem when i start unity that my windows 10 need to be at proper build version. Is that an issue?
so I've just reopened to proj file and ignore to use safemode, and now the scene lost all of it's objects
Help me please... I'm desperate...
when I win, I can't make the camera turn in any way... I'm providing clean code now.
The code check winning: https://hastebin.com/share/inirevaqex.csharp
Camera: https://hastebin.com/share/afusunonev.csharp
how do I destroy everything inside of the list and then clear the list?
you mistyped AddForce
foreach (Brain organism in list) Destroy(organism.gameObject);
list.Clear();
``` isnt working
that's how you do it. how isn't it working?
it doesnt actually destroy the objects
but it does clear
Iterate over the list with a for loop or foreach, call Destroy with each element then call Clear() on the list
wait i fixed it 💀
make sure you've saved, make sure you're looking at the right objects
try debugging what objects you're destroying, make sure they're what you expect
yea, sorry I was just being stupid and was clearing the list elsewhere before doing the foreach
but the file already corrupted, should I redo a new one?
okay, I fixed it, anyone know the meaning of this error log?
how is it corrupted?
uhhhhhh is your unity on a floppy disk
or it's not, it just went into safe mode and when i ignore it, i got put in a new scene file
why is it not in c:
i just went back in old scene file
c drive full
how did you get an A drive
i thought those were for floppy disks...
but i got all the software recognized with unity though, except .net sdk
it's a hard drive
hdd
yeah don't those usually go to D
I already have a D
so it's C D Z A
Z is full D is for documents
so I partitioned 14TB as A drive
storage solution
jesus christ
also, I lied a bit a bout C drive, it was full, I cloned it to a slightly* larger space now
but I don't feel like uninstall things and bring it to C
unless i reeally have to
so Chris, anything else I can provide?
i think it's a problem with how you've set it up but im not on windows and idk what it should be, sorry
i wouldn't say this is really a code issue
so maybe try #💻┃unity-talk
okay I do believe it's because the .net sdk is not recognized by vsc
have you set vsc up according to !ide ?
If your IDE is not autocompleting code
or underlining errors, please configure it.
Select one:
•
Visual Studio (Installed via Unity Hub)
•
Visual Studio (Installed manually)
•
VS Code
•
JetBrains Rider
• :question: Other/None
because there's a giant pop up everytime i open it
i didn't do it through the discord link
but yes
i downloarded
and installed
did you install the extensions in vsc and unity?
C# in vsc, and i installed diffmerge in unity too
I'll take it to unity talk
there's more than that, see the link above
what link sorry?
this
so i install all of these?
no
include jetbrains rider?
click the one labelled vscode and follow the instructions given
wow that's very complicated
Chris, do I need to do the attaching the unity debugger to a uinity player step?
That's for debugging. You only need to go through the setup steps.
Take a screenshot of the external tools and the package installed
And the package?
where is it?
It's in the setup guide. If you don't know, then you didn't do that step...
ive passed this part before, just not the the guide's order
Ok. Did you reboot after all the steps?
yes
Try regenerating project files in the external tools.
okqay
heyyy it worked
no more complier error
thanks a lot dlich
if (list.Count != 0) {
GameObject example = list[Random.Range(0, list.Count]);
}
```is saying "**index was out of range**" and I have no idea why
@teal viper turns out it doesn't work, the components just get deleted when I turn on playmode
the components that connect the object to the script is gone that's why it's booted but nothing running
I'm not sure what you're talking about and how it's related to configuring the ide.
Do you understand what index out of range means?
I know what it means, but I think lists start from index 0
either way, the code only runs if the count is not 0 so I don't know why it would say index out of range
Guys, who can help me, please? 🙂
Debug the index that you're using and the length of the list.
the condition can check if the list is greater than 0 rather than checking if its not 0
but yeah debug it first
Add logs to your camera turn logic and see if it executes/executes correctly when the issue happens.
I have different problem - I don't understand how to return the camera rotations during game over
oh yea and I changed it to
if (list.Count > 0) {
// ...
}
Wdym by "return"?
Debug the index
oh right 🤦♂️
Didn't understand your question
Return camera rotations to where?
I'm just saying somehow the components of the Player object is removed
Then there must be some code that's doing it. It's your project. You should know better than us.
so when i debugged the index it was 1 more than the length of the list, so i just minused 1 and now its always equal to -1
oh, ofcrouse
wait
might be another dumb moment 🤣
You'll need to provide actual debugging data. We can't read your thoughts or see your screen.
As well as the updated code
From the start of the scene, the camera moves along the x-axis in the rotation section. But as soon as I interact with an object and then stop interacting with it, the camera doesn't move along the x-asis in the rotation section
int rng = Random.Range(1, list.Count) - 1;
Debug.Log($"IS NOT EMPTY: {list.Count > 0} LENGTH: {list.Count} INDEX: {rng}");
if (list.Count > 0) {
GameObject example = list[rng];
}
int rng = Random.Range(1, list.Count) - 1;
originally it was int rng = Random.Range(0, list.Count) but then it was always returning a number more than the length
then it was int rng = Random.Range(0, list.Count) - 1 but that was always returning -1
so i changed it to how it is now
Random.Range(0, list.Count) should work
this is correct
for ints the max is exclusive
does your list have items in it?
yea
is it not null?
you aren't doing like, 0f or 0.0, right?
not in that line of code
ill change it back and see if it magically works again
put your debug before the random.range
sometimes unity does that 🤣
So I'll repeat again: debug your camera logic properly.
so remove the rng bit
the rng bit is the index im debugging
so put that after. I want to see the list contents before you use it
oh you want to see what's in the list
I want the count basically
Is that the actual code or are you omitting something?
its essentially the same
i just put the check into a bool
oh
omfg
i just realised
🤦♂️
You're using 2 different lists there...
wait. yhatsd 2 different lists
you're using different lists lmao
omg
That's why share the actual goddamn code
I was like it should work with the changes
omfg im stupid 🤣
but yeah double check your variables next time
one of the most difficult skills of a programmer. To read code and see what is there not what you think should be there
ArgumentException: Input Axis horizontal is not setup.
To change the input settings use: Edit -> Settings -> Input
UnityEngine.Input.GetAxis (System.String axisName) (at <725079647fb443ecb43bc12e4add9ae7>:0)
PlayerController.Update () (at Assets/Course Library/scripts/PlayerController.cs:19)
how do i fix?
where do i change that?
either in your script or in the settings mentioned
normally you would use Horizontal
just fix the axis reference in your script
thanks i just made everything a capital H