#💻┃code-beginner

1 messages · Page 564 of 1

wintry quarry
#

spliut the script up

#

looking around and aiming should be on the character

echo kite
wintry quarry
#

not on the weapon

#

what about it

echo kite
#

weapon sway

wintry quarry
#

waht about it

echo kite
#

idk how to add it

wintry quarry
#

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

echo kite
wintry quarry
#

no... if you did you wouldn't be here asking this question

echo kite
#

i have other script too but i wanna integrate it

echo kite
# wintry quarry no... if you did you wouldn't be here asking this question

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 ...

▶ Play video
#

look

#

this guy does same

wintry quarry
echo kite
wintry quarry
#

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

echo kite
# wintry quarry so, if it's not working, you did something differently from the tutorial, or the...
    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);
    }
wintry quarry
#

this is also not even all of the code

echo kite
wintry quarry
final gazelle
echo kite
#

it starts at 18:22

wintry quarry
#

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

echo kite
#

and he writes code

wintry quarry
#

there is the setup in the scene and hierarchy

final gazelle
#

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

echo kite
# wintry quarry it's absolutely just poorly designed - having the player look script on the weap...
    {
        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

wintry quarry
#

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

echo kite
wintry quarry
echo kite
wintry quarry
#

try again

#

or show what you have so we can point out where you went wrong

final gazelle
# echo kite i did

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

echo kite
wintry quarry
#

And why are there two objects called "Player"?

#

This isn't showing us the setup from the other tutorial you tried

echo kite
wintry quarry
echo kite
#

empty is supposed to be folder

wintry quarry
#

what doe sit do

#

why does it exist

echo kite
#

one holding ak47

fringe plover
#

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?

wintry quarry
# echo kite

you should not have additional colliders on a CharacterController

#

it will mess things up

whole cliff
#

where are they?

wintry quarry
whole cliff
#

where are c# lesson guys?

burnt vapor
whole cliff
#

where?

burnt vapor
burnt vapor
#

Coroutines run off the main thread

#

It's also generally solving problems in a very basic and bad way

burnt vapor
#

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

echo kite
#

but i cant look to sides

#

with this script

burnt vapor
#

Doesn't seem related to the weapon

echo kite
burnt vapor
#

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?

echo kite
#

i also have seperated script

burnt vapor
#

Putting it all together is the mess

burnt vapor
#

And it doesn't work

echo kite
#

just model changed

burnt vapor
#

Your player has a behaviour to move around, which relates to movement and looking

#

Your weapon should worry about being a weapon

echo kite
# burnt vapor 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

burnt vapor
#

playerCamera.transform.localRotation = Quaternion.Euler(rotationX, 0, 0);

#

This sounds like it handles looking sideways

echo kite
#

it does but it cant look up and down

burnt vapor
#

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

burnt vapor
#

Look at that code

#

BTW why is it in a if (canMove) check? Can you not look around when standing still?

echo kite
burnt vapor
#

Pretty much

final gazelle
frail hawk
#

seems like you also have to use more singletons in your project @final gazelle

final gazelle
#

events are cheats as well

burnt vapor
#

That's not going to work

west garnet
#

how could i make the player fly upwards when press w and downwards when pressing down
i honestly have no idea

echo kite
#

ye

#

it doesnt look up

#

it just moves screen

burnt vapor
#

I also hope you realize this yourself that this is not the correct way to do this

burnt vapor
west garnet
cosmic quail
vast fern
#

I am super confused about how i can make one gameObject get another objects rotation after a button click could someone help me

wintry quarry
vast fern
#

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

wintry quarry
vast fern
#

but since my camera is slightly looking downward, when i do what u wrote it makes the player look down

#

let me try that

frail hawk
#

assuming it is a 2d envoirement

vast fern
#

it is a 3d project

#

but that worked hahah

wintry quarry
#

Rotating on the y axis would not be a thing for a 2D environment

vast fern
#

Would u mind explaining what projectonplane means?

frail hawk
#

well Praetor sensed it 😉

wintry quarry
#

Like here the vector a is being projected on the plane and the result is d

#

Maybe a better picture

vast fern
#

ohhhh

#

i get it yeah

wintry quarry
#

The dark blue is being projected on the plane and becomes the hollow blue

vast fern
#

Thank you so much! 🙏

#

that makes alot of sense

fair badge
#

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

frail hawk
#

doesn´t sound good when you say at runtime

fair badge
#

yes i am making it at runtime

echo kite
#

wait it can look up

#

but how do i make ak47 look up too

fair badge
final gazelle
arctic shore
#

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

naive pawn
#

go into the scene view

#

there's 2 tabs up there, scene and game view

arctic shore
#
    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?
wintry quarry
#

what's distance -= Mathf.Min(pixelSize, distance); about?

#

and what's the point of the while loop

arctic shore
wintry quarry
#

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

arctic shore
#

how close the raycast origin can get to a solid atleast thats what i think

wintry quarry
#

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

echo kite
arctic shore
#

i dont understand why it doesnt updates

#

this is setup of that block

#

anyone any idea?

echo kite
#

how do i add weapon sway?

verbal dome
#

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

teal viper
arctic shore
teal viper
teal viper
#

It returns distance 2, since that's the length of the cast that you do.

arctic shore
#

and my collision is still false even tho they collide

verbal dome
arctic shore
teal viper
arctic shore
#

that figure and that platform

teal viper
#

What "collision is still false"?

arctic shore
#
 {
     return Physics2D.Raycast(raycastOrigin,direction,distance, layer);
 }```
teal viper
#

And I already explained why it's returning false.

arctic shore
teal viper
#

I don't understand this question

hexed terrace
#

use colliders

teal viper
#

For starters, you cloud use the correct collider: box2d. Not the 3d box collider

strong wren
#

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

burnt vapor
#

Then lerp towards it

verbal dome
#

That would still rotate on other axes too

teal viper
burnt vapor
#

I have no idea what axes apply here

#

So I assume it doesn't matter

verbal dome
#

what i need is for it to rotate only its y

burnt vapor
#

You can just use the Y component of it

verbal dome
#

That would work. There are many ways to do this

#

(As long as it's the euler Y not quaternion Y)

burnt vapor
#

Can even use Vector3.RotateTowards and limit how far you rotate I believe

wintry quarry
#

Looks like you had a 3d box collider you need a 2d collider

arctic shore
verbal dome
#

What did you change?

#

And show your character's components

arctic shore
#

my component and i changed box collider to 2d on that box

#

and i dont want this do happen

echo kite
hexed terrace
# echo kite

you already had an answer, but if that wasnt enough google -> unity how to add weapon sway

verbal dome
# arctic shore

What other components does the character have? Does it have a Rigidbody or a Character Controller?

verbal dome
arctic shore
echo kite
verbal dome
#

Weapon sway is quite literally animation

echo kite
#

like in lua

verbal dome
#

Yes?

#

Did you even read my answer

#

Or stopped reading at "animation"?

strong wren
#

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
quaint lotus
#

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

echo kite
winged seal
#

hey i need some help making a main menu where it teleports you to a plane

verbal dome
#

Your code assumes that its forward (z axis, blue arrow) points along the barrel, but seems like that's not the case

leaden pasture
verbal dome
#

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

cosmic quail
verbal dome
#

If you want it to rotate horizontally only, that is

verbal dome
echo kite
#

he did it with 1 lines of code

#

and i have different one

verbal dome
leaden pasture
verbal dome
leaden pasture
verbal dome
#

If you want to rotate on the Y axis, your direction should be only on the X and Z axes

bold swallow
#

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

verbal dome
#

You have a transition which gets triggered here

leaden pasture
# bold swallow

It looks like your animationOpen state automatically transitions back to your default state, which presumably would be the main screen in its original position

bold swallow
#

thats why I didn't think that would be a problem

verbal dome
#

Not sure though.

arctic shore
#

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?

verbal dome
arctic shore
#

no now added it and restart it

verbal dome
#

So the colliders are 2D, is the rigidbody also a rigidbody2D?

#

The next question would be how are you moving the character, show code

arctic shore
verbal dome
#

Trigger colliders will not collide with anything

#

They just detect when something overlaps them

arctic shore
#

so i should uncheck it?

#

but i feel like i might need it

hexed terrace
#

Why

#

Don't do things by "feeling", research and understand what things are

arctic shore
#

beacuse you see those steps and want to jump and climb back so that why i think i might need it

verbal dome
#

You mean like going through platforms?

arctic shore
#

see and now i want to jump up again on that grass

naive pawn
#

sounds like you want platform effectors

quaint lotus
#

yo guys does the index number on a list begin from 0 or from 1?

naive pawn
#

have you tried googling that at all

#

a quite small set of languages start with 1, most start with 0

quaint lotus
#

but then does the last item's index on a list = List.Count - 1, or just List.Count?

naive pawn
#

count-1

quaint lotus
#

aight thanks

naive pawn
#

the countth element would be the "past-the-last" element

quaint lotus
#

just wanted to make sure I don't mess this up

naive pawn
#
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
arctic shore
verbal dome
#

Or with raycasts if you want

covert flower
#

im having some trouble understanding how to fix the issue or whats wrong with this, the warning is shown below

naive pawn
#

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
covert flower
queen adder
#

I asked in another server and got redirected here

verbal dome
#

Rotate does not set the rotation, it adds to itcs axePrefab.transform.Rotate(0f, 90f, -45f); // Reset rotation

queen adder
#

so how would I set it then?

#

sorry I got no idea what I would do

verbal dome
#

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

queen adder
#

ok thanks

quaint lotus
#

since I'm guessing you don't want to deal with quaternions

queen adder
#

ay thanks it works

#

I need to refine the angles but the setting the angle ect works

#

thanks

ivory bobcat
#

Or cs ...transform.localRotation = Quaternion.Euler(...);

echo copper
#

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?

frail hawk
#

not really

brittle maple
#

Does anyone know how I can make some objects ignore collision with each other?

leaden pasture
#

You can use collision layers

echo copper
frail hawk
echo copper
#

and i can turn him backwards by changing y rotation

echo copper
#

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

leaden pasture
#

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

verbal dome
#

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

echo copper
#

without normals?

verbal dome
#

Why not use normals from the collision or ground check?

#

Are all your slopes 45 degrees?

echo copper
#

no, i have even loop-da-loops in my game

#

i made rotators that checking rotation of player

nocturne kayak
#

Is there a quick way to check if a raycast is hitting an untagged UI element?

whole cliff
#

is there a channel for people to playtest someone elses game?

#

i wanna play some underrated games

frail hawk
cosmic quail
nocturne kayak
#

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

whole cliff
#

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

nocturne kayak
#

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

nocturne kayak
naive pawn
nocturne kayak
naive pawn
#

but the important thing is the logic, breaking mechanics into parts

#

you're gonna have the same job in unreal

cosmic quail
whole cliff
# nocturne kayak why

wanna learn game development but feel like unity coding is more confusing and harder

naive pawn
whole cliff
#

really?

cosmic quail
whole cliff
#

i tought it did

naive pawn
#

it uses c++, and it has better support for blocks (called blueprints)

whole cliff
#

okay nvm, unity it is

nocturne kayak
#

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#

naive pawn
#

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

whole cliff
#

maybe really stupid but is starting off with luna (roblox studio) easy

#

just to get a feeling of codinjg

nocturne kayak
#

Blueprint helps a lot with learning the logic without having to worry about syntax and recompiling

naive pawn
#

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

cosmic quail
naive pawn
#

oh misread that

naive pawn
whole cliff
#

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

naive pawn
#

start small and build up to making your own stuff

naive pawn
#

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

whole cliff
#

but every tutorial i follow after 20 minutes the code just doesnt work for me even if i follow it step by step

frail hawk
naive pawn
whole cliff
#

@naive pawn for example, how did you learn coding?

maiden relic
naive pawn
nocturne kayak
#

is there a way to compare layers the same way you compare tags? like a hit.collider.CompareTag, but for layers?

naive pawn
naive pawn
#

there's no method for comparing layers, but there is a layer property you can use

frail hawk
#

layermask shoudl fix your problem yes, it will only detect the objects you want and ignore anything else

naive pawn
#

i would not advise it though as that is an int and you could easily mess that up

whole cliff
#

whenever i feel like im to stupid for this ill probally come back here

naive pawn
#

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

whole cliff
#

yeah it just feels like a whole job

naive pawn
#

well, it is

whole cliff
#

i just hope later in my life it will help me with finding a job'

#

it will probaly look pretty cool on my portfolio

naive pawn
#

gamedev is programming, writing, drawing/modelling, animating, composing, sound engineering, level designing, ui designing etc.. all in one

whole cliff
ivory bobcat
whole cliff
#

bc thats the only fun thing i like that uses coding features

nocturne kayak
whole cliff
#

maybe both

#

im still young idrk what i wanna do later

naive pawn
whole cliff
#

is that an actual code

naive pawn
#

not c#, but yes

whole cliff
#

that just seems like real depression

nocturne kayak
#

programming? nah

whole cliff
#

dont even know what a terminal is yet

nocturne kayak
#

i prefer Pro gamming.

nocturne kayak
whole cliff
#

i dont have a lot of hope in myself

#

and yall are making it a whole lot worse

naive pawn
whole cliff
#

but atleast when i get a error thats not on reddit yaal are here for me🫡

ivory bobcat
#

Wrong server for this kind of discussion - off topic

whole cliff
#

holy f*ck

naive pawn
#

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

whole cliff
#

tf is the difference

#

i was thinking it was the same thing

naive pawn
#

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 😅

whole cliff
#

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)

naive pawn
#

oof, it's kinda a meme that programmers/cs majors don't get any lmao

#

not that that's true but shrugsinjapanese

whole cliff
#

yeah it was a joke tbf]\

#

wait wait wait

#

are u a boy or girl

naive pawn
#

not saying, sorry.

whole cliff
#

oh sorry

cosmic quail
frail hawk
#

lel

whole cliff
#

ohh smartypants

frail hawk
#

Jules learn programming you will not regret it,forget blueprints

whole cliff
#

SIR YES SIR!

naive pawn
#

(i mean blueprints are also programming but if your end goal is unity then just go with that)

cosmic quail
#

wait why did you change your name 🤔

whole cliff
#

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🫡

cosmic quail
whole cliff
#

yeah im doing it

#

ill get some chips probaly

#

with some coke zero

#

that sounds good

#

ill be back

eternal falconBOT
hybrid tapir
burnt vapor
steep rose
burnt vapor
#

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

hybrid tapir
#

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

burnt vapor
#

Something wrong because there's an issue? I'm still confused? Do you just want a review?

#

What is bin 1?

hybrid tapir
#

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 😦

placid shard
#

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

verbal dome
#

Show the material that the flashlight uses

#

Wait this isn't a code problem

placid shard
#

i dont think so i just know that post process layer makes it transparent for no reason

#

where do i post this then?

whole cliff
#

thats the slogan they use

nocturne kayak
#

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

verbal dome
#

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

nocturne kayak
#

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:

verbal dome
#

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

nocturne kayak
#

Oh man, i wanted that gift link

verbal dome
#

Bot snatched it for itself 😔

winged seal
#

uh when i play the game i get 999+ issues

north kiln
#

then resolve them

winged seal
#

very gut help 👍

sharp abyss
north kiln
#

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");
    }
}```
signal raptor
#

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

forest harness
#

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

rocky canyon
rocky canyon
#

load scenes in and out along-side that master scene

#

thats just my little two-cents.. best o luck @signal raptor ☝️

forest harness
#

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

rocky canyon
#

i replied to the wrong person festive

#

srry

#

lol.. Unity dropping the "Kiss" principal cracks me up a bit

rocky canyon
eternal needle
rocky canyon
#

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..

signal raptor
rocky canyon
#

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

rocky canyon
#

ive always found third-party documentation

signal raptor
#

That’s kinda my idea. I understand a lot of things change heavily from SP to MP

rocky canyon
#

very much true 👍

#

i belive this is called "Composition"

signal raptor
#

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

rocky canyon
#

when u break up ur mechanics and stuff into simple scripts...

#

makes it very modular

rocky canyon
signal raptor
#

I though. Might as well give it a try on my pet dream project

rocky canyon
#

👍 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

signal raptor
#

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 🙂

rocky canyon
#

ya, u seem to be reasonable..

#

i'd say go for it

signal raptor
whole cliff
#

GUYS, I HAVE HUGEEE NEWS

rocky canyon
#

its 2025..

#

have u heard?

whole cliff
#

me?

rocky canyon
#

lol.. just wanted to share my news

whole cliff
#

i was just excited😔

rocky canyon
#

whats up?

whole cliff
#

i just wrote my first script

#

its not huge

rocky canyon
#

niiiice!

#

u want a code-review?

whole cliff
#

but its something

rocky canyon
#

!code

eternal falconBOT
whole cliff
#

dont get too impressed alr

#

its probaly not your level

#

just so u dont get offenden

rocky canyon
#

no problem.. i wouldn't expect it to be

whole cliff
#

offended

whole cliff
rocky canyon
#

i wrote my first script 3 years ago.

#

so i got a bit of an advantage

whole cliff
#

dont think so

#

just need to find out how to send it

rocky canyon
#

post it up... we'll give it a look 👀

whole cliff
#

!code

eternal falconBOT
signal raptor
rocky canyon
#

read this embed

patent verge
#

why does my flashlight move around instead of stopping me?

whole cliff
#

u ready?

patent verge
#

im trying to make it so my flashlight doesnt go through the walls

whole cliff
#

told u dont get offenden

rocky canyon
#

it wont

whole cliff
#

offended

rocky canyon
ivory bobcat
whole cliff
ivory bobcat
#

Describe what's happening and not happening.

patent verge
#

1sec

whole cliff
#

what do u think @rocky canyon

#

told u

whole cliff
#

he got offended and left

rocky canyon
#

lol. nah.. im a very busy person (most of the time) gimme a sec

whole cliff
#

populair boy i see

rocky canyon
#

are u trolling?

#

lmao

whole cliff
#

noo dead serios

#

wow my spelling is bad

winged seal
#

what does this mean?

rocky canyon
#

OHH.. i see.. at first i only saw the PlayerController w/ a single translation in update

whole cliff
#

but it took me a whopping 4 days😁 👍

winged seal
#

any idea how i can fix this.

rocky canyon
#

looks like ur .meta files may have gotten fuggered up

rocky canyon
#

i'd try re-importing the model/prefab'

whole cliff
#

ur telling me my only script is BROKEN

steep rose
rocky canyon
#

i didnt notice there was a second file

winged seal
winged seal
#

1 is a menu

#

It wont even fade out

#

right eye is glitching

steep rose
whole cliff
rocky canyon
#
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?
whole cliff
#

yeah man

#

wait one sec

#

''ctr-c ctr-v''

#

wow look what ii wrote today

winged seal
#

@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

rocky canyon
#

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

rocky canyon
# winged seal <@317141358894645248> im a new user to unity dont mind me if i dont really under...

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

whole cliff
#

@winged seal can i see it we are the same age just wondering how much ahead u ar on me

rocky canyon
#

soo.. i can't really help specifically

whole cliff
#

can i see your vr game?

winged seal
#

sure

#

here is the menu

whole cliff
#

working menu is crazy for me

rocky canyon
# winged seal any idea how i can fix this.
#

maybe it can help u out

rocky canyon
winged seal
#

cool 👍

#

i watched a tutorial where he made a ui

rocky canyon
#

anywho.. check out that link i sent..

#

it may help ur situation.. since its more of a project-specific type of error

rocky canyon
#

aye i was right

#

it is a .meta issue

winged seal
#

let me try to find how to open the meta file

#

probably take me 10 mins :P

rocky canyon
rocky canyon
winged seal
#

i mean im trying to find the meta.file

rocky canyon
#

the meta's wont be visible in the project window

#

right click anything in ur project folder

#

and go to Open in Explorer

winged seal
#

also where is the reimport button or am i just blind

#

oh wait

rocky canyon
#

👀

winged seal
#

yuh got it

rocky canyon
#

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..

winged seal
#

what is a guid?

rocky canyon
#

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.

winged seal
#

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

arctic shore
#

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?

whole cliff
#

my bus moves slower now!

#

very cool!

rocky canyon
winged seal
#

i just changed the code

#

that it needed

rocky canyon
#

did it fix it?

winged seal
#

yep it works!!!

rocky canyon
#

hell ya 💪

winged seal
#

yeeah!

rocky canyon
#

that wasn't a beginner flavored error either..

#

good job 🙂

winged seal
#

kewl hands

rocky canyon
#

now.. do not delete XR Origin

#

or anything inside it

winged seal
#

but also why is the right eye so glitchy

#

i think i made a screenshot

rocky canyon
winged seal
rocky canyon
#

and animate it as well..

winged seal
#

i see that on the pc on the right side but i dont see anything in my right eye in the headset

rocky canyon
#

add keyframes and change out sprites as needed

winged seal
rocky canyon
#

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 🍀

winged seal
#

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?

lofty mirage
#

Anyone has an idea why knockbacked isn't effective ? (player not being moved on collision)

leaden pasture
arctic shore
#

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

swift crag
#

If you set the velocity based on player input every FixedUpdate, the velocity caused by the knockback goes away

lofty mirage
#

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)

arctic shore
#
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?

rocky canyon
# arctic shore ```using System.Collections; using UnityEngine; public class PlayerController :...
  • Is playerOnPlatform being set correctly when you land on the platform?

    • Have you confirmed this with a Debug.Log?
  • Does the tag on your platforms match exactly what your collision logic checks for?

  • Is Input.GetAxisRaw("Vertical") < 0 being 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.enabled before and after disabling it to confirm.
  • Platform Effector 2D settings:

    • Have you double-checked the Surface Arc? Is it set wide enough to allow the drop-through behavior?
  • 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

covert obsidian
#

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?\

covert obsidian
#

thanks 👍

rocky canyon
# covert obsidian 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..

covert obsidian
#

yeah imma do that

rocky canyon
spring skiff
#

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.

teal viper
#

Can't really help you without you sharing the details.

spring skiff
# teal viper 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.

teal viper
spring skiff
#

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.

spring skiff
#

and only this specific toggle, all my other UI buttons, sliders work perfectly on android.

teal viper
#

There's no point in confirming it on platforms that you know it works on, is there?

patent verge
#

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?

frosty hound
#

You can have scenes of anything. They're just a collection of objects that you load and unload.

patent verge
#

so yes I could do that?

swift elbow
#

ideally youd have a seperate scene for the tutorial, team deathmatch, ffa, main menu, etc

patent verge
#

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

swift elbow
#

yeah thats how most games do it, but there are other options ofc

patent verge
#

would that be better?

#

like more optimization

mild reef
#

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.

swift elbow
patent verge
mild reef
#

💀 yall laughing

patent verge
#

it helps sm

frosty hound
#

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.

bitter apex
#

i intend on solely using scenes, but are there practical alternatives to scenes

patent verge
frosty hound
#

No, that's not what I mean

swift elbow
frosty hound
#

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.

bitter apex
patent verge
#

oooooo i see what you mean now that is useful thank you!

swift elbow
#

think of something like another crabs treasure if youve played that before. it has everything in one giant scene and uses LODs for everything

patent verge
#

should I use URP or HDRP?

swift elbow
#

this allows players to glitch into areas that they shouldnt get to before certain checkpoints

#

(since everything is always loaded in)

bitter apex
#

ahhh yeah that makes logical sense, that's quite cool

swift elbow
#

well another crabs treasure isnt an open world game but it works as an example

steep rose
patent verge
#

does this matter?

#

everytime I change it my stuff changes

teal viper
teal viper
patent verge
#

like for differnt displays will it pop up differently?

teal viper
patent verge
#

so I would have to make everything compatible with them?

#

or could I have my game just be 1 of them

teal viper
patent verge
#

hmm okay thank you!

maiden relic
#

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);

polar acorn
#

Is it a variable, or a property?

maiden relic
#

vector 3 variable Im pretty sure

#

Vector3 m_Movement;

rocky canyon
#

i hear its miniscule performance gains. important for an optimized codebase but irrelevant for smaller projects.

maiden relic
#

Thats what I figured

forest harness
# maiden relic just started the John Lemon course and it is saying to add this line of code to ...

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

rocky canyon
#
public Vector3 m_Movement 
{ 
    get; 
    private set; 
}

m_Movement.Set(horizontal, 0f, vertical);``` //dont think set works here
maiden relic
#

thank you guys

rocky canyon
#

i had to look it up

#

lol i didnt know the difference until digi asked

maiden relic
#

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.

rocky canyon
#

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

maiden relic
#

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.

nocturne kayak
#

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

maiden relic
#

okay, yea I tried starting with unreal, hell with that for trying to learn.

nocturne kayak
#

Personally i found it easier to learn shit with unreal thanks to blueprint

maiden relic
#

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.

nocturne kayak
#

Honestly, no joke-

#

I learned Unreal through youtube

#

and kind of made a career out of it

maiden relic
#

thats awesome

nocturne kayak
#

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

maiden relic
#

yea, why did u switch?

nocturne kayak
#

For me it was wall-running stuff at first, which taught me a surprising ammount about vectors

nocturne kayak
#

at least that's my impression of it

maiden relic
#

I thought the same thing when I was trying to learn.

nocturne kayak
#

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

maiden relic
#

alright, thank you

lilac plinth
#

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?

lilac plinth
#

so I've just reopened to proj file and ignore to use safemode, and now the scene lost all of it's objects

feral moon
#

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

obtuse quarry
#

how do I destroy everything inside of the list and then clear the list?

naive pawn
obtuse quarry
#
foreach (Brain organism in list) Destroy(organism.gameObject);
list.Clear();
``` isnt working
naive pawn
#

that's how you do it. how isn't it working?

obtuse quarry
#

but it does clear

charred spoke
obtuse quarry
#

wait i fixed it 💀

naive pawn
obtuse quarry
lilac plinth
naive pawn
naive pawn
lilac plinth
#

or it's not, it just went into safe mode and when i ignore it, i got put in a new scene file

naive pawn
#

why is it not in c:

lilac plinth
#

i just went back in old scene file

lilac plinth
naive pawn
#

how did you get an A drive
i thought those were for floppy disks...

lilac plinth
#

but i got all the software recognized with unity though, except .net sdk

lilac plinth
#

hdd

naive pawn
#

yeah don't those usually go to D

lilac plinth
#

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

naive pawn
#

jesus christ

lilac plinth
#

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?

naive pawn
#

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

lilac plinth
#

okay I do believe it's because the .net sdk is not recognized by vsc

naive pawn
#

have you set vsc up according to !ide ?

eternal falconBOT
lilac plinth
#

because there's a giant pop up everytime i open it

lilac plinth
#

but yes

#

i downloarded

#

and installed

naive pawn
#

did you install the extensions in vsc and unity?

lilac plinth
lilac plinth
#

I'll take it to unity talk

naive pawn
lilac plinth
naive pawn
lilac plinth
#

so i install all of these?

naive pawn
#

no

lilac plinth
#

include jetbrains rider?

naive pawn
#

click the one labelled vscode and follow the instructions given

lilac plinth
#

wow that's very complicated

#

Chris, do I need to do the attaching the unity debugger to a uinity player step?

teal viper
lilac plinth
#

ah

#

I've already have

#

before joining the server

teal viper
lilac plinth
#

concurrently, I'll install visual studio, see if it works for me

teal viper
lilac plinth
teal viper
lilac plinth
teal viper
lilac plinth
#

yes

teal viper
lilac plinth
#

okqay

lilac plinth
#

no more complier error

#

thanks a lot dlich

obtuse quarry
#
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
lilac plinth
#

@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

teal viper
teal viper
obtuse quarry
#

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

feral moon
teal viper
final gazelle
#

but yeah debug it first

teal viper
feral moon
obtuse quarry
#

I'm debugging with Debug.Log($"{list.Count > 0} {list.Count}");

obtuse quarry
obtuse quarry
#

oh right 🤦‍♂️

feral moon
teal viper
lilac plinth
teal viper
obtuse quarry
#

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 🤣

teal viper
#

As well as the updated code

feral moon
# teal viper Return camera rotations to where?

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

obtuse quarry
#

now im even more confused...

final gazelle
#

send the updated code

obtuse quarry
#
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];
}
final gazelle
#

int rng = Random.Range(1, list.Count) - 1;

obtuse quarry
#

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

naive pawn
#

Random.Range(0, list.Count) should work

naive pawn
#

for ints the max is exclusive

final gazelle
obtuse quarry
languid spire
#

is it not null?

naive pawn
#

you aren't doing like, 0f or 0.0, right?

obtuse quarry
#

ill change it back and see if it magically works again

languid spire
#

put your debug before the random.range

obtuse quarry
#

sometimes unity does that 🤣

teal viper
languid spire
obtuse quarry
languid spire
#

so put that after. I want to see the list contents before you use it

obtuse quarry
#

oh you want to see what's in the list

languid spire
#

I want the count basically

teal viper
obtuse quarry
#

i put it behind length

obtuse quarry
#

its essentially the same

#

i just put the check into a bool

#

oh

#

omfg

#

i just realised

#

🤦‍♂️

teal viper
languid spire
#

wait. yhatsd 2 different lists

naive pawn
#

you're using different lists lmao

obtuse quarry
#

omg

teal viper
#

That's why share the actual goddamn code

obtuse quarry
#

100% lol, i didnt see the difference

#

thank yous anyway 🤣🤣🤣🤣

final gazelle
#

I was like it should work with the changes

obtuse quarry
#

omfg im stupid 🤣

final gazelle
#

but yeah double check your variables next time

languid spire
whole cliff
#

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?

naive pawn
#

you don't have a horizontal axis

#

by default the axis is called Horizontal

whole cliff
#

where do i change that?

naive pawn
#

either in your script or in the settings mentioned

#

normally you would use Horizontal

#

just fix the axis reference in your script

whole cliff
#

thanks i just made everything a capital H