#πŸ’»β”ƒcode-beginner

1 messages Β· Page 172 of 1

terse yacht
#

ik i had to pick between a senior IT game design class and cyber

#

i work i dont get time to

polar acorn
proper flax
#

the player is not moving

polar acorn
polar acorn
proper flax
#

ik i want to know what are those errors

polar acorn
proper flax
#

just ide

polar acorn
#

Then you probably need to regenerate project files. It's on the page where you set your IDE in Unity on that guide you were following a while ago for configuring it

safe root
#

!code

eternal falconBOT
terse yacht
polar acorn
#

I've given you plenty of ways to find the answer but you are just refusing to learn the basics to the point you can even understand my answers

#

I'm not writing the code for you. Come back when you've done the bare-bones basics and can understand the answers you're given

terse yacht
polar acorn
terse yacht
#

ya you literally just said the exact same thing the site said and i said i didnt under stand the site and what they were saying and that i needed you to dumb it down or give me an example of it being used because i wasnt sure how to apply set color to my context and my use

polar acorn
# terse yacht ya you literally just said the exact same thing the site said and i said i didnt...

You call SetColor on a material.
You can get a material from a renderer.

This is the answer. But you literally do not know the language so you don't know the answer. I cannot help you if you do not know the first thing about C# syntax. I'm not going to write it for you and I'm not going to give you a personal tutoring session on how code works when there's plenty of resources out there for you to read on your own. Go learn how to write C# code and then come back when you understand how to type literally anything into a script and have it compile

terse yacht
# polar acorn You call `SetColor` on a material. You can get a material from a renderer. This...

i do understand these are scripts i made and also i never asked you t do it for me nor do i want u to i wanted an example cause i would rather have a visual example i can base off of and i dont need you to tutor me because if i would have asked you to while i might not know the language im currently trying to learn it and one the new things was the set color and i didnt understand how to use it because i had no pervious work with material colors

slender nymph
#

there are plenty of visual examples of how to create a variable, assign a reference to it, and call a method on it in each of those scripts

polar acorn
#

your issues are "not knowing how to call a function" and "not knowing what a variable is"

#

which have absolutely nothing to do with materials or colors

#

You are wandering around Seoul, getting angry that everyone is giving you directions in Korean

#

You do not speak the language to understand the help you're being given

scarlet skiff
#

what dis entail

#

i got a script named "Reload"

polar acorn
scarlet skiff
#

damn lemme check

terse yacht
slender nymph
# scarlet skiff what dis entail

the error means exactly what it says. you cannot have a variable, method or property called Reload inside a class or struct called Reload

polar acorn
#

then change the function to SetColor

safe root
scarlet skiff
#

had a method named same as class

slender nymph
scarlet skiff
#

ty gang

polar acorn
#

This has been going on for nearly an hour after I answered the question

slender nymph
scarlet skiff
#

why da game doesnt understand Time.time?

safe root
slender nymph
polar acorn
scarlet skiff
#

dis what i got

slender nymph
eternal falconBOT
terse yacht
slender nymph
#

once it is configured and the error is underlined you'll probably see your mistake

scarlet skiff
slender nymph
#

your code editor

scarlet skiff
#

i use VS

slender nymph
#

congrats. get it configured

slender nymph
terse yacht
slender nymph
polar acorn
polar acorn
dark sluice
terse yacht
polar acorn
dark sluice
polar acorn
#

You have not even gotten to the part where you need to know how to change a color

slender nymph
polar acorn
terse yacht
slender nymph
#

the context for which you would use the SetColor method on a material is when you would want to set a material's color

dark sluice
languid spire
scarlet skiff
#

btw i was just missing this

slender nymph
slender nymph
scarlet skiff
#

idk i dont get any errors now

slender nymph
#

and your IDE is still unconfigured

scarlet skiff
#

idk

#

i just looked at my other project where it was working

slender nymph
scarlet skiff
#

andsaw what was missing

slender nymph
#

you can search the hierarchy with t:PlayerCharSelection

#

also not really a code question

dark sluice
slender nymph
#

getting that information absolutely will tell you that though

dark sluice
dark sluice
#

it just tells me location ray hit 😦

slender nymph
#

obviously knowing what was hit and where it is as well as the starting location will provide you with the context for why the direction is the way it is

slender nymph
terse yacht
# slender nymph stop wasting your time and go learn the basics of C#

dumbass thats why im here is to learn what i need this is the BEGINNER chat and what both you two have sent me links for is not what need i have repeatedly said that i need help with set color not methods or variables i understand what they are and that you guys need to send me an example because the ones that were provided on the unity site for set code didnt make sense and that i needed them in a different context not that i need what it done ik it sets the color of a material and if you didnt want to help send me to a channel on discord that can and will instead of being stuck up and think that people in a BEGINNER should know every thing and try blaming them that they dont know stuff

slender nymph
dark sluice
# slender nymph yes. exactly.

im thinking its the way the canvas is, maybe needs to be world space and set in front of the player? i get what your saying tho πŸ™‚

slender nymph
terse yacht
#

This is the beginner chat help me with the basics

slender nymph
#

stop wasting your time and go learn the basics of C#

scarlet skiff
#

ye this piece of code did not work

vast vessel
#

hey guys, im using a premade package called kinematic charachter controller to set up my player controller and im facing some issues.
as you can see the Y rotation of the player is not acting like how it should.
any ideas where the issue is? im guessing it has something to do with the ProjectOnPlane things in the code snippet down below but i cant figure it out.

code snippet related to setting the player rotation:

//Calculate camera direction and rotation on the character plane
            Vector3 cameraPlanarDirection = Vector3.ProjectOnPlane(targetCamRot * Vector3.forward, Motor.CharacterUp).normalized;
            if (cameraPlanarDirection.sqrMagnitude == 0f)
            {
                cameraPlanarDirection = Vector3.ProjectOnPlane(targetCamRot * Vector3.up, Motor.CharacterUp).normalized;
            }
            Quaternion cameraPlanarRotation = Quaternion.LookRotation(cameraPlanarDirection, Motor.CharacterUp);

            if (cameraPlanarDirection.sqrMagnitude == 0f)
            {
                cameraPlanarDirection = Vector3.ProjectOnPlane(targetCamRot * Vector3.up, Motor.CharacterUp).normalized;
            }

all the code i found related to setting CharachterUp seen in the previos code snipper:

public Vector3 CharacterUp { get { return _characterUp; } }
private Vector3 _characterUp;
...

_characterUp = _transientRotation * _cachedWorldUp;
dark sluice
terse yacht
slender nymph
vast vessel
# vast vessel hey guys, im using a premade package called kinematic charachter controller to s...

this is where i set the targetCamRot used in the first code snippet

            // NOTE : Do NOT Use time.Deltatime, beacuse the mouse input that is coming from the new input system is already a delta. more info : 
            https://unity.huh.how/programming/input/built-in-input/mouse-delta-time
            // Rotate the camera based on mouse input
            float mouseX = lookInput.x * sensitivity;
            float mouseY = lookInput.y * sensitivity;
            //we use the lookInput values to rotate the camera horizontally and vertically using the transform.Rotate() and Quaternion.Euler() functions 
            //respectively.
            rotation.x -= mouseY;
            rotation.x = Mathf.Clamp(rotation.x, -90f, 90f);

            rotation.y += mouseX;

            camHolder.transform.localRotation = Quaternion.Euler(rotation.x, 0f, 0f);
            Character.targetCamRot = rotation.y;
slender nymph
#

and stop making assumptions about the issue. you need to verify what is happening. hence the instructions to print useful information like what is being hit, where it is, and where the bullet originates from

slender nymph
dark sluice
slender nymph
#

my dude, i cannot see your screen. i have no information about what is actually happening except for what you tell me. how can i help you debug your issue if you refuse to provide the information that we are literally attempting to debug

dark sluice
slender nymph
#

what part of "show it" leaves that up to interpretation?

delicate zinc
#

im having a rly weird bug in vs

dark sluice
delicate zinc
#

where only some stuff just is refusing to autocomplete

slender nymph
#

!vscode

eternal falconBOT
#
Visual Studio Code guide

If your IDE is not underlining errors in red or autocompleting code,
please configure it using the link below:

https://on.unity.com/vscode

cosmic dagger
delicate zinc
#

my vscode was working fine last time i used it

#

its just started doing this randomly

scarlet skiff
#

but ill read through the site now

slender nymph
delicate zinc
#

wait do i need unity 2021

polar acorn
slender nymph
delicate zinc
#

cos my game is on 2020

terse yacht
slender nymph
# delicate zinc cos my game is on 2020

ah yeah, the new c# plugin requires 2021 to work properly. you might be able to find some guides for using an older version with the million other extensions you need to get it working πŸ€·β€β™‚οΈ

scarlet skiff
dark sluice
scarlet skiff
#

but not with the scripts from this one

slender nymph
delicate zinc
#

oh

polar acorn
slender nymph
cosmic dagger
languid spire
meager steeple
#

would it be worth having every action logged?

slender nymph
#

can you be more specific about what you mean

meager steeple
#

like every time a button is pressed, a scene is loaded, specific collisions occur

slender nymph
#

that's really up to you πŸ€·β€β™‚οΈ
if you think that would be useful information to have then do it. if you feel it would just clutter the console/log files then don't

cosmic dagger
meager steeple
#

if i were to add audio for a button press to multiple buttons, would i add that audio to every button individually?

slender nymph
buoyant knot
#

which is probably what you want

#

like to play Jump SFX only when you jump, and not just whenever you press jump

meager steeple
slender nymph
#

i mean you will need an audiosource either way

cosmic dagger
meager steeple
#

what do you mean by SO?

cosmic dagger
meager steeple
#

πŸ‘

cosmic dagger
#

As you see from all of our responses, there are multiple ways to create this functionality . . .

meager steeple
#

which way would you say is the simplest

eternal needle
# meager steeple which way would you say is the simplest

Depends entirely on the use case. Something simple may be like having a monobehaviour that lets you plug in the audioclip, then all the buttons just pass that clip to an audio source and play. but then if you want to add functionality where you can play different sounds from a list of clips, a SO wouldve been better from the start.

#

Simple may make it tedious to add functionality later

meager steeple
#

ok

cosmic dagger
green copper
#

I'm trying to instantiate a sprite, and the sprite is being parented to another sprite with scale 1, 1, 1. That sprite is parented to a canvas set to Screen Space Camera. The new sprite, the one generated by instantiating, is generated at scale 240, 240, 240.

polar acorn
#

because SpriteRenderers shouldn't be children of a canvas

green copper
#

it's an image

#

the image inside's type is Sprite

polar acorn
#

Okay, just making sure

green copper
#

TextureType, rather

polar acorn
#

Can you show the inspector of the prefab you're spawning?

green copper
#

and I haven't touched the Pixels Per Unit, the scale itself in editor reads 240

#

first image is spawned item, second is raw prefab

polar acorn
#

First off, you should probably spawn the object directly as a child of the object you want it to be a child of, rather than spawning it at the top level, then setting the parent, that could cause some scale problems

cosmic dagger
green copper
green copper
stuck palm
#

what if i want to use the other handlers? how do i add on more?

green copper
honest haven
#

            sprite.enabled = true;
            speed = 3;
            Vector3 newtemp =  myTransform.position + Vector3.down * speed * Time.fixedDeltaTime;

            myRigidbody.MovePosition(newtemp);``` can any one tell me why this is moving so fast. I mean its like the speed of a bullet
stuck palm
#

i thought u couldnt

honest haven
#

even if i change speed to 1 its same speed

green copper
polar acorn
polar acorn
#

Or another canvas of the same size

vague ingot
#

Hey I've been having a problem that I just haven't been able to figure out. If I exlpain the proble, would I be able to get help in this channel

polar acorn
polar acorn
honest haven
#

hmmm yes...

vague ingot
#

I'm trying to align my player game object with the surface it's standing on so that it's always rotated towards the normal of the surface (makes the player look perpendicular to surface). My character can move well on slopes (increase and decrease top speed on slopes as well as keep momentum) but it doesn't rotate yet. I've been trying lots of different ways to do this but I haven't been able to achieve this (problems that arise are: the camera jitters and changes angle (not settings) of my cinemachine, no changes in rotation, wonky rotation, and immediate jitter rotation followed by instantaneous reset of normal rotation (at least that's what I think happens, it's a bit too fast for me to tell confidently) ).
The code I currently have is this:

private void SurfaceAllignment()
    {
        RaycastHit hit;
        if (Physics.Raycast(transform.position, Vector3.down, out hit, playerHeight * 0.5f + 0.2f, whatIsGround))
        {
            // Calculate the target rotation based on the ground normal
            Quaternion targetRotation = Quaternion.FromToRotation(Vector3.up, hit.normal);

            // Gradually rotate the player towards the target rotation using Slerp
            transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, rotationSpeed * Time.deltaTime);
        }
    }

I've tried different things like RotateTowards and such, but the problems persist.
I'm starting to think that it may have to do with me using cinemachine. I think it may be messing with the rotation. It may not, but I can't really think of anything else. Does anyone know if there's something I'm missing?

slender nymph
#

are you using a CharacterController?

vague ingot
#

no, rigidbody

#

I put that method in a seperate script and placed it in the player capsule (child object of player. GFX holder), the problem still remains :/ I did notice one thing tho. I disabled said script and manually rotated the object during play time. This gave the same effect as when the script was enabled. So now I'm thinking it's most likely the camera script. These are the only scripts after all

slender nymph
#

if the issue is camera jittering, then you might be updating the camera on the wrong time step

vague ingot
#

I'm not really messing with the camera itself tbh, The freelook cinemachine has a script but the script just switches the orientation of the player (player has another child called orientation which dictates whats forward. It's for movement)

stuck palm
#

whats the event for when a button is selected? like iPointerselect or whatever

vague ingot
#

Right, but my code itself is the issue

honest haven
polar acorn
honest haven
polar acorn
#

Gravity is not a requirement to set an object's position

vague ingot
# slender nymph if the issue is camera jittering, then you might be updating the camera on the w...

heres the cinemachine script in case you wanna see it. But like I said, I don't think it actually does anything to the jittering of the player rotation. Player has rigidbody, where my movement script is located, along with 2 child objects. One is the GFX holder, which is just a fancy way of saying the capsule (later I'll replace it with an actual 3d model), and the other is the orientation. which is rotated through this script to determine the forward (movement direction based on camera forward).

slender nymph
#

!code

eternal falconBOT
vague ingot
# slender nymph !code

I tried sending it as code, but the message is too long so I had to send it as a text file

slender nymph
#

gee, that's a shame. too bad there are no instructions for sending large code blocks

robust kelp
#

does anyone know how to make falling speed gaining velocity further down while falling?
private void customGravity()
{
if (rb != null)
{
rb.velocity += Vector3.down * gravityStrength * Time.deltaTime;
}
}

#

do i have to put in in square or something

slender nymph
#

if you have a dynamic rigidbody, why are you calculating gravity manually? why not just let it do it automatically for you

robust kelp
#

becasue forcemode.accelerate doesnt work for some reason

vague ingot
robust kelp
#

i stole source physics and i thing the friction calculation is also effecting y value

#

and i dont want to change anything because it might not work πŸ‘

stuck palm
vague ingot
slender nymph
stuck palm
slender nymph
#

well you have access to exactly the same link i would be looking at so πŸ€·β€β™‚οΈ

stuck palm
#

found it, it was submit

vague ingot
pearl lodge
#

Does this argument that is passed inout var networkedClientdeclare a variable right there and then?

what is this syntax called?

languid spire
little cradle
#

hi, I can't figure this out, can someone help me?
I have a boolean private static bool x;
which then I use for a method call (from another class) CreateAxisOverlay.CreateX(x);
that method for now just sets the boolean value to true: c# public static void CreateX(bool x) { xAxisInitialized = true; }
but then if I try to use the boolean in the "original class" it returns false, it only returns true inside the called method, how can I get the method to change the value of the one boolean I passed as parameter?

#

with the "original class" I mean the one in which I called the method

#

btw I'm not sure if you say invoke or call for a method

strange peak
#
if(roomController.rooms>0)
        {
            foreach(Transform roomConnLoc in roomConncections)
            {
                int roomRand = Random.Range(1,4);
                switch(roomRand)
                {
                    case 1:
                        Instantiate(room1, roomConnLoc.position, Quaternion.identity);
                        roomConncections.Remove(roomConnLoc);
                        roomController.rooms -=1;
                        break;
                    case 2:
                        Instantiate(room2, roomConnLoc.position, Quaternion.identity);
                        roomConncections.Remove(roomConnLoc);
                        roomController.rooms -=1;
                        break;
                    case 3:
                        Instantiate(room3, roomConnLoc.position, Quaternion.identity);
                        roomConncections.Remove(roomConnLoc);
                        roomController.rooms -=1;
                        break;
                    default:
                        Instantiate(room1, roomConnLoc.position, Quaternion.identity);
                        roomConncections.Remove(roomConnLoc);
                        roomController.rooms -=1;
                        break;
                }
            } 
        }``` can someone help? the foreach seems to not work, only one transform is being removed from the list
polar acorn
polar acorn
strange peak
#

lemme see

polar acorn
strange peak
#

one for every thing that spawns

polar acorn
#

You cannot modify a list you are looping over

little cradle
strange peak
#

ill find a workaround then

little cradle
#

I'm pretty new to using static variables, methods and all that so I'm not fully sure how it works yet :[

polar acorn
little cradle
green copper
#

I cannot get touchPhase.ended or .canceled to trigger, any idea what I am doing wrong?

#

began works fine

polar acorn
green copper
wintry quarry
#

show the rest of the code

green copper
honest haven
#

            sprite.enabled = true;

            Vector3 newtemp =  myTransform.position + Vector3.down * speed * Time.fixedDeltaTime;
            newtemp.x = 0;
            newtemp.z = 0; 
            myRigidbody.MovePosition(newtemp);``` how do i make that go in the y direction only but i dont want to x and z to be rest. thinking like dropping a bomb from the sky the x and z will be the position it dropped but and only move towards at y
little cradle
modest dust
strange peak
honest haven
polar acorn
#

Disable gravity and then do this manually with a smaller number

honest haven
polar acorn
#

in whatever direction you give it

honest haven
#

thanks ``` var sprite = GetComponent<SpriteRenderer>();

        sprite.enabled = true;

        Vector3 newtemp =  myTransform.position + Vector3.down * speed * Time.fixedDeltaTime;
  
        myRigidbody.AddForce(newtemp * speed);``` no shoots up in the air. do i also have to turn on the gravity on the rigid body?
polar acorn
honest haven
#

i thought i would not and add force would push in directio

green copper
#

this is currently the entire script contents

modest dust
# little cradle yup yup

Either pass it as a ref or out or return the value and assign it in the calling class

When you make a call to a method, the passed variables get copied. In case of value types, well - you copy only the value. It's not the same variable but a local copy of it. In case of reference types (classes) you also make a local copy, but the way classes work is that they hold a reference to the actual data instead of holding it directly - so it's fine to pass classes and modify their fields since they point to (reference) the original data, but for value types you gotta do it differently.

honest haven
polar acorn
honest haven
#

if so still moving left and right on the way down

polar acorn
green copper
little cradle
#

Either pass it as a ref or out or

polar acorn
#

that's probably because you only check for the touch phase ending if the touch count is above 0. If you release it, then the touch count is 0, and it never reaches that code. You should probably put your "touch ended" outside that condition

wintry quarry
#
Debug.Log($"Touch phase is {touch.phase}");```
green copper
polar acorn
green copper
wintry quarry
#

How are you doing the touching?

#

Is this simulated with a mouse?

green copper
#

Unity remote app

wintry quarry
#

oh that's why

green copper
#

Samsung Galaxy S10

wintry quarry
#

try in the editor itself

#

Unity Remote is crappy

#

especially when it comes to touch handling

green copper
#

ah

wintry quarry
#

or try a dev build

green copper
#

Simulator editor is still not running an ended event

green copper
#

would it be something like this?

strange peak
polar acorn
green copper
wintry quarry
strange peak
# strange peak would switching it for a for loop work?

if(roomController.rooms>0)
Β Β Β Β Β Β Β  {
Β Β Β Β Β Β Β Β Β Β Β  for(int i =0; i<roomConnections.length;i++)
Β Β Β Β Β Β Β Β Β Β Β  {
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  int roomRand = Random.Range(1,4);
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  switch(roomRand)
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  {
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  case 1:
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  Instantiate(room1, i.position, Quaternion.identity);
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  roomConncections.Remove(i);
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  roomController.rooms -=1;
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  break;
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  case 2:
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  Instantiate(room2, i.position, Quaternion.identity);
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  roomConncections.Remove(i);
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  roomController.rooms -=1;
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  break;
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  case 3:
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  Instantiate(room3, i.position, Quaternion.identity);
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  roomConncections.Remove(i);
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  roomController.rooms -=1;
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  break;
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  default:
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  Instantiate(room1, i.position, Quaternion.identity);
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  roomConncections.Remove(i);
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  roomController.rooms -=1;
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  break;
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  }
Β Β Β Β Β Β Β Β Β Β Β  } 
Β Β Β Β Β Β Β  }``` something like this? (wrote it on my phone so something will deff not work as it is but you get the idea)
wintry quarry
#

why remove them inside the loop

#

just do the loop and roomConncetions.Clear(); at the end
Also no need to triplicate your code like this

honest haven
green copper
strange peak
wintry quarry
strange peak
#

doesn't matter the order, basically if theres a connection for a mew room then add a room to that

wintry quarry
#

What's the Random.Range about?

#

and why use a switch?

strange peak
#

choosing which room to add

#

response to both questions

wintry quarry
#

get rid of the switch

strange peak
#

in the future id rather use a percentage based system rather than the switch

wintry quarry
#

with the rooms in an array then you can just do this:

                int roomRand = Random.Range(0,rooms.Length);
                
                Instantiate(rooms[i], roomConnLoc.position, Quaternion.identity);
                roomConncections.Remove(roomConnLoc);
                roomController.rooms -=1;```
#

no need for switch at all

strange peak
#

true

#

ill do that

#

wait

#

nvm got it

wintry quarry
#

As for a percentage based system just look up weighted selection algorithm - commonly used for loot tables but you can use it here for the rooms too

strange peak
#

alr ty

potent echo
#

Hey guys, I'm trying to detect if there is a collision with any object on a certain layer, but even though I *visually *see the raycast colliding (with the correct object, with the correct layerMask), it's still not detecting any collision. Here's my code any ideas?

https://gdl.space/japujijami.cs

strange peak
wintry quarry
#

something like that yes

strange peak
#

alr

wintry quarry
#

but it's more like rand(0, sum_of_all_probabilities)

#

better thought of as "weights" really

strange peak
#

yeah

#

also what is the last line for? i dont understand it

wintry quarry
#

let's say you have items with weights 3, 8, and 5.
so you do rand(0, 16) (16 is the sum of all the weights)
Let's say the random number picked is 7.
Then in the loop you do:

first item - weight is 3
7 < 3 ? no
so 7 = 7 - 3 = 4
second item - weight is 8
4 < 8 ? yes
so you pick the second item```
vast vessel
#

Any way to do something similar to on trigger enter when none of my colliders(trigger, and the object that will pass through it) have a rigidbody?
My players physics are custom and handled via a script so it dosnt have a rigidbody, but i still need triggers.

wintry quarry
#

If you have moving objects with colliders though,m they should really have a rigidbody

vast vessel
#

Oh! Didn't know thats a thing. Ill check it out

wintry quarry
#

you can use a kinematic rigidbody

#

and still use OnTriggerEnter

vast vessel
#

Also its just unneded overhead

#

And performance cost

wintry quarry
#

pretty sure KCC uses a Kinematic Rigidbody anyway

vast vessel
#

I dont think so, i cant see a rb component on my gameobject, even with debug mode enabled in my inspector

toxic latch
#

For some reason, I can't seem to get a very simple text display to work. I have a text UI element named TextBox and a script named DisplayText which is attached to a game object. My understanding is that I need to drag TextBox from the hierarchy to the component on the game object but I'm not able to.

rich adder
toxic latch
#

Nope, just a game object wit hthe DisplayText script attached.

rich adder
#

or maybe the types don't match at all.

toxic latch
#
{
    public Text TextBox;
    public string textToDisplay = "My Text";

    void Start()
    {
        TextBox.text = textToDisplay;
    }  
}```
rich adder
#

and you have TextMeshPro component as your UI?

toxic latch
#

TextBox is a from the UI/Text - Text Mesh Pro option in the dropdown

rich adder
#

yes types dont match

toxic latch
#

I've looked at a couple of guides and really don't see why this isn't working.

green copper
#

Touch Ended will only run reliably on the first instance of the game running, and I cannot figure out why

rich adder
#

because its the wrong type

toxic latch
toxic latch
#

There we go. πŸ‘ Thanks much.

#

Is it normal that I don't have a standard Text option in the UI dropdown? I only have the TMP version.

rich adder
#

Yes

twilit pilot
#

I'm sure Unity will get around to properly integrating TMP and fix all the weird third-party plugin naming and feel of it all any decade now

#

I think it's a rite of passage basically everyone has to go through to realise Text is not actually text (well, it is, but not the one you thought it was)

paper plaza
#

a good youtube playlist to learn basic of physiscs for unity?

ripe shard
languid timber
#

I have a question regarding the Scriptable Object.
here is my plan: I have buttons in my clicker game that are different upgrades. for instance I have a +1 (reward) per tap. if the player presses this the cost should go up on the upgrade and how many you have owned. this is basically the same mechanic for every button, but with slightly faster upgrades like 1+ (reward) per second, or +10 (reward) per second. could I make this in a scriptable object, or should I just use normal code to make this happen? I am reusing them, but I am unsure if this is even worth going for. if it is, can someone also provide me some tips? because I do know how to do it without scriptable objects, but just not with the scriptable objects. thanks for all the help I can get!

warm condor
#

Hey, I am trying to make the player allow to move a little in the air but does not exceed the maximum speed limit that he can move at. My problem here is that when the character is moving faster then that speed, the speed would stay the same and will not allow the player to move in the air. Here is my code:

        if (Math.Abs(rb.velocityX) <= maxRunningSpeed){
            rb.AddForce(new Vector2(direction * speed_mid_air, rb.velocity.y));
        }
        else if(Math.Abs(rb.velocityX) > maxRunningSpeed){
            rb.velocity = new Vector2(direction * Math.Max(maxRunningSpeed,initialHorizontalSpeed), rb.velocity.y);
        }```
I am pretty sure that it is because of my if statement, but I just can't seem to have an simple idea to fix this. Can someone help?
warm condor
wintry quarry
#

Do you need one?

scarlet skiff
#

am i missing something or is this a bad example from chatgpt? im just tryina figure out what mathf.min does, and if it returns the lower value between 2 variables.. wouldnt it just.. well.. return the lower value there, even if its under the preferred min height?

warm condor
timber tide
languid timber
wintry quarry
languid timber
north kiln
warm condor
#

oh sorry I was looking at another link to know what the length is...
here ```Vector2 ClampMagnitude(Vector2 vector, float maxLength);```` the maxLength

wintry quarry
timber tide
#

if it's billions then I assume you're generating them, so perhaps SOs aren't what you're looking for

wintry quarry
#

But Max won't work for leftwards velocity.

timber tide
#

you can do it in combination of SOs like perhaps option profiles for generating them

warm condor
languid timber
timber tide
#

liar liar machine

north kiln
languid timber
north kiln
#

Except that it continually is shown here that it doesn't work

#

"probably" isn't something I want when I'm learning

languid timber
timber tide
#

it's just bad with unity

lusty thicket
#

hello everyone, how are you?
I am new to Unity and I am still learning a lot of things... let me know if this is not the right channel to ask for help.
I have an Animator Controller with one animation for my UI(initial menu), I created a New state in animator controller to become the default state and a trigger for the transition between "empty default state" and "Closing" state, it is firing after I click a button and works fine!
But when I try to LoadScene again(come back to the main menu scene), and click the same button, it looks like both states are "Stuck" and nothing happens...

Anyone know what I could do to fix this?

north kiln
scarlet skiff
#

oh dang

languid timber
#

really?

#

I did not know

warm condor
timber tide
#

like you can actually get some legit code using it with glsl, but once you add any unity macros and method calls, it spews out a bunch of shader garbage with hlsl

north kiln
#

What it's good for is generating a whole bunch of vaguely legitimate looking text

calm coral
#
async void Update()
{
    await Awaitable.MainThreadAsync();
    await Awaitable.BackgroundThreadAsync();
}
```Hey, what is the difference between these two methods? Is that something I can use to ensure other async methods have completed before I move on?
teal viper
#

Move on where/what?

#

You can't ensure that other async methods are complete with this.

calm coral
# teal viper You can't ensure that other async methods are complete with this.
async Awaitable TimerStart(float startPoint)
{
    while(true)
    {
        // doing some other stuff here

        try
        {
            await Awaitable.WaitForSecondsAsync(1, destroyCancellationToken);
        }
        catch(OperationCanceledException e)
        {
            Debug.Log("Coroutine canceled successfully: " + e.Message);
        }
        catch(Exception e)
        {
            Debug.LogError(e.Message);
        }
    }
}
```Alright. Well, I have this method that I call once and it keeps looping forever during game play, and when I want to stop the game it'd be good to ensure this method completed first before I entirely exit the game
north kiln
calm coral
north kiln
#

I'm not having this conversation again

calm coral
#

Aight, thanks

teal viper
lusty thicket
#

hello everyone, how are you?
I am new to Unity and I am still learning a lot of things... let me know if this is not the right channel to ask for help.
I have an Animator Controller with one animation for my UI(initial menu), I created a New state in animator controller to become the default state and a trigger for the transition between "empty default state" and "Closing" state, it is firing after I click a button and works fine!
But when I try to LoadScene again(come back to the main menu scene), and click the same button, it looks like both states are "Stuck" and nothing happens...

Anyone know what I could do to fix this?

teal viper
calm coral
teal viper
teal viper
calm coral
scarlet skiff
#

Im tryina make an object that moves towards the player (player = blue) (movement path = yellow) have a new movement path (red) (so a sort of "reflect" vibe) when hitting the player, im trying to do it with moving the object, rather than with a rigidbody n stuff, and this is my method

tho like as soon as it bounces the Y pos goes wild, talking about -200 as soon as it hits the player, anyone got any tips?

craggy oxide
#

can someone explain this line to me step-by-step
it's kinda glazed over in the course

swift crag
#

that's a for loop.

#

the example on the page I just linked is nearly identical to your code.

craggy oxide
#

ooooh thank you

#

that explains everything

#

sweet

eternal needle
#

A simpler way would just be using rigidbody though, or an animation

swift crag
#

subtracting the square of deltaTime makes no sense

#

this kind of looks like a kinematic equation of motion

#

but those use elapsed time

eternal needle
#

i was assuming the goal was some upside down quadratic equation raised slightly

#

which would follow -x^2 + some X

#

hm but that'd be + a constant actually so yea idk what the goal is here. Likely just magic numbers

craggy oxide
#

oki i think i get it now

so
"for (int i = 0; i < 3; i++)"
translates to
"i is worth 0, if it's worth less than 3, increase i's value by 1"

#

so for arrays it goes through the list one-by-one using that

#

right?

swift crag
#

not exactly: it's not just that it checks if i < 3 and increments i if that's true

#

if i < 3, the loop body runs

#

after the loop body is done, it increments i

#

then it checks again if i < 3

craggy oxide
#

once i < 3 it stops working?

swift crag
#

you mean once i < 3 is false?

craggy oxide
#

...yes?

#

i think :P

swift crag
#

you wrote "once i < 3"

#

that would mean "once i is less than 3"

craggy oxide
#

oh right yeah

#

hahahaha

#

my bad

swift crag
#

the loop will stop once i >= 3 is true

#

or when i < 3 is false, equivalently

craggy oxide
#

oki thank you Fen this helps a lot

swift crag
#

It increments the index value, i, until it's not smaller than the array's length

#

if the array has 5 elements, i will be 0, then 1, then 2, then 3, then 4

#

it will then be incremented to 5

#

this will cause the condition to fail, so the loop stops running

swift crag
#

This formula is only necessary if you want to compute exactly where an object will be at a specific point in time.

#

you generally just do iterative methods in a game (i.e. you use the current velocity and position to calculate a new velocity and position every frame)

lusty thicket
#

when I tap the button, it simply does not run the closing animation

#

But it already worked previously(before I leave the Scene for the first time)

teal viper
lusty thicket
#

yes

teal viper
#

But it looks consumed? Did it transition to Closing and back?

lusty thicket
#

it does not, nothing happens, only in the animator tab it is changed to "Closing" State

teal viper
#

So it does change to the Closing state?

lusty thicket
#

yes, but the animation does not happen

teal viper
#

Even when the issue occurs

teal viper
lusty thicket
#

oh, I think I figured it out....

#

I just ResetTrigger in Start function and it looks like it is working

#

Not sure if it should be like that(maintain state of the animator even when I leave the Scene)

teal viper
#

Assuming the object with the animator is destroyed, it shouldn't maintain any state.

lusty thicket
#

it should be destroyed... but the button that fires the trigger is a prefab, do you think it can be the problem?

#

but, thanks anyway!!

teal viper
vernal minnow
#

I feel like this should be easy and yet I can't seem to figure it out... how do get an objects script component? When I make an object into a prefab, it removes the script that it should be pulling info from and sharing info with

#

Can you not just use get component on a script or am I missing something?

teal viper
teal viper
vernal minnow
#

Indeed

vernal minnow
rare urchin
#

aye. i have Question GUI and i want it check answer and show score at Text. what Type of code i can use?

teal viper
teal viper
shell sorrel
#

i often have a SetData method on my scripts that i call immediently after instantiate so i can pass in all the stuff it needs

shell sorrel
#

much more prefable to finding the references through other means

rare urchin
#

i dont need code to receive answer right.just check from button and increase point

teal viper
swift crag
#

I almost never set fields on things I instantiate now

rare urchin
shell sorrel
#

really managing depedencies is like the thing unity is worst at. since you dont got usable constructors in 90% of things

tight saffron
#

hello thank you for those who helped me from my problem yesterday

buoyant knot
#

unity’s weakness is the devs’ fetish for sealed classes

young smelt
#

I am trying to normalize the point of contact between my meshes in my terrain generator and it isn't working well

There are 2 differnt ways I try doing it. one is commented out though but u should see it

https://paste.ofcode.org/bwfJavBP5yL7kreiWquy5f

#

I am having problem with the normalization for when I set it to globally. It still doesn't make a smooth transition in height data between 2 chunks

swift crag
#

i don't see why normalizing each chunk would ensure that the transitions are smooth

#

it would just ensure that the lowest point in the chunk is height X and the highest point in the chunk is height Y

shell sorrel
swift crag
#

waiter! waiter! more undefined behavior please!

young smelt
swift crag
#

don't normalize the random data

#

if chunk A's minimum value is -100 and chunk B's minimum value is -200, then a height of 0 in A and B will remap to different values

buoyant knot
swift crag
#

it's hard to tell you much more than that, since this is a lot of code and you haven't shown us an example of the problem in action

buoyant knot
#

oh wait, but we can extend rule tile, we’re expected to extend rule tile, and it just works

#

who would have thought, if you don’t seal the class, and write it in a non dumbass way, shit just works

young smelt
swift crag
#

by showing us the generated data?

young smelt
#

pictures?

swift crag
#

sure

#

something to go on

swift crag
#

there are a few [RequiredByNativeCode] attriburtes in TileBase, which are mysterious

buoyant knot
#

my computer is fried rn, so I literallt can’t look through code rn

#

but I remember it being in SetTile

#

as RuleTile derives from TileBase

#

and SetTile is injected. And an extremely important method, core to how tiles work

swift crag
#

yeah, that's in Tilemap

#

and Tilemap is sealed

#

SetTile is not implemented in RuleTile

buoyant knot
#

oh right

swift crag
#

the parts you need to extend are kept in plain C#

young smelt
#

Holes like this inbetween some areas instead of just sliding down

swift crag
#

so that you don't suffer a case of computer explode

young smelt
buoyant knot
#

i would still like to extend basic shit

#

like CustomCollider2D. It’s literally designed in a way that would be perfect to extend.

swift crag
shell sorrel
#

other reason for a lot of sealed things, is the more that is exposed the more unity needs to keep stable and un changing between versions as to not totally break other peoples code

young smelt
# swift crag I'm unclear what "global" normalization is. Is it supposed to remap to between t...

Oh that was just incase I want to just generate the full map at once for smaller map or in chunks as player move for bigger maps. Local is to only normalize the map based on it's own map data (in the case of the smaller maps generated once), while global is to ask it to take consideration of other chunks ( in the case of big maps which would be broken down) so I could try getting rid of the holes between the chunks

timber tide
#

I think what I've done for this is create a padding of a few pixels where it would lerp from the first to second chunk

teal viper
#

You need to sample some extra positions outside the chunk bounds.

young smelt
young smelt
#

Tnks I should go play around with these

#

hopefuly not die while I'm at it

teal viper
#

Because they have it all covered

young smelt
#

It just gets me confused some times. So I decided to go mess around a bit

teal viper
#

What doesn't work?

young smelt
#

not breaking

#

even this part of his tutorial that explains this is good. I don't like the result much. So I wanted to learn other ways to do it

#

Asked Chatgpt and it gave a pretty good response. Still trying to problem solve some more. So basicaally creating problems where I shouldn't

silent valley
#

Hi. I'm stuck on something and cannot find a solution. I have a simple attack animation for an FPS prototype. I have done what I've done 100s of times. Left click to play the animation but it seems like half a second delayed. I've checked the animation and it starts when it should. So I'm guessing it's code or a bug? Is it because I'm using a trigger and not boolean?

#

in Update

#

Would also like to add that fixed duration and all that stuff is also 0

wintry quarry
silent valley
#

I'm assuming it's a bug.

north kiln
#

Watch the state machine with the animator selected while you perform the attack

wintry quarry
#

What do you mean about it being delayed exactly

north kiln
#

It's very unlinely that there's a bug in this like, decade+ old animation system

silent valley
#

I think I'll redo it all. Just wanted to try and figure it out. Won't take me long UnityChanThumbsUp

north kiln
#

Out of interest, is the attack's animation speed 1?

silent valley
#

Well, It's working now. I screenshotted every setting do with with the animation. Using the same code too. Nothing is different atwhatcost

frigid sequoia
#

If I use blendShapes, the meshColliders do not update to the new Shape right?

#

Cause without that I don't truly know how to do the collider that I want

solemn summit
frigid sequoia
#

So I have to bake the new mesh with every blendShape update?

solemn summit
frigid sequoia
#

I want to do the typical ring in the floor that expands over time and you have to jump over to avoid it

#

I had to do it with blendShape instead of just normal scale to mantain the ring thickness over the scaling

#

That seems incredibly demanding if I want to use a good chunk of them isn't it?

solemn summit
frigid sequoia
#

Weird cause it seems like something that many people would want to do

#

Maybe I am terrible at searching answers XD

eternal needle
#

most beginner lessons or tutorials are pretty shit to begin with. but in this case it doesnt really matter what you do. You'll get the same result. Running switch statements on ints like this is pretty weird tbh, usually you would use an enum

static cedar
#

Dunno, but I can say that whenever you do [], you're creating a new object. The preferred way to do is to put the response array outside the function as a static readonly ig, so you're not making a new array everytime that method is called.

eternal needle
#

well this array should be created outside the method but it really doesnt matter

static cedar
#

I think VS will suggest it.

north kiln
static cedar
#

Ok.

warm depot
#

hello, i'm having trouble with MoveTowards; this is my code:

Vector2 C1target = new Vector2(-668, -2124);
void FixedUpdate()
{
Cashout1.transform.position = Vector2.MoveTowards(Cashout1.transform.position, C1target, 300 * Time.deltaTime);
}

so instead of moving to -668, -2124, it goes to -1448.5, -2563

warm depot
#

how would I go about doing that

teal viper
#

Debug.Log or use the debugger thinksmart

warm depot
#

er like, what am I debugging for

#

I can see them slowly drift across my screen

#

here's a little snippet of a debug log of the position

#

wait that's actually weird

charred spoke
#

Are you perhaps moving a UI element?

warm depot
#

ok its because my canvas is pushing the x and y values

#

yea i figured it out

charred spoke
#

Dont move ui with transform

#

Use its RectTransform

lean basin
#

how do I know if T is null or "" or 0?

minor spindle
timber tide
#

gives you a clue there: it is a type parameter which is not known to be a reference type

lean basin
#

like try catch? I'm not sure how to use it.
but for some reason (result == null) doesn't give compiler error.... hmmmmmm, what if it's a string

timber tide
gaunt ice
#

you need generic constraint

lean basin
#

oh nice thanks!! yes looks like constraint is what I needed. I only need it for reference type.

trail verge
#

Hi there I just wanted to add a c# script as a component but there is an error which says that the script canΒ΄t be added because the script class cannot be found. Does anybody have an idea?

gaunt ice
#

file name and class name mismatch

trail verge
gaunt ice
#

compile errors

keen dew
#

The error message tells what the problems can be. If there are no errors in the console, post a screenshot of the editor while the file is selected and visible in the inspector

trail verge
#

Ok I donΒ΄t really know how, but I think I fixed it accidentally. Thank you anyway @gaunt ice and @keen dew

frigid sequoia
#

I am having a issue with a transition sometimes doing some flickering when more of one instance of the Enumerator is called

#

Like, to stop ALL instances of a couritne I have to just type StopCouritne("CouritineName"); rigth?

frigid sequoia
#

That explains the flickring

#

How do I stop them all?

stiff birch
#

You should store references to your coroutines somewhere if you want to keep track on what's running

#

Like an list. you'll just have to parse it and call StopCoroutine on each of them to make them all stop

frigid sequoia
#

I have to create a variable for each Couritne?

#

Is not like I want to keep a track of each one

#

Just stop every single one

stiff birch
#

If that's the only coroutine one the object, you also can call StopAllCoroutines

lucid path
#

I'm trying to implement a heart system into my game. Full hearts worked fine, but adding quarter hearts has lead to a bug where every time you are hit, your health gets set to 1.25/3 hearts.

public void subtractHealth(int healthSubtracted)
{
    playerHealth -= healthSubtracted;
    int index = 0;  // Variable to keep track of the index
    foreach (GameObject heart in hearts)
    {
        Image image = heart.GetComponent<Image>();
        if (index >= playerHealth / 4)
        {
            image.sprite = heartSprites[0];
            Debug.Log(heart + "set to empty.");
    }
        else if (index <= playerHealth / 4 && index %4!=0)
        {
            image.sprite = heartSprites[index%4];
            Debug.Log(heart + "set to 1/" + index%4 + ".");
    }
    else
        {
            image.sprite = heartSprites[4];
            Debug.Log(heart + "set to full.");
        }
    index++;
    }
}

Let me know if additional information is needed.

stiff birch
#

But if you happen to have 2 coroutines that do different stuff at the same time and you only want to stop the 1st one, it won't suit your need

frigid sequoia
stiff birch
#

StartCoroutine return a reference to the coroutine, you should store it in a list of running coroutines, that way you can keep track of what's running

#

And stop exactly what you want, like all coroutine with a specific name whatsoever

lucid path
frigid sequoia
lucid path
#

I have it like that.

frigid sequoia
#

But ok

#

Thx

stiff birch
#

But in the 1st place, if this coroutine is supposed to run one at a time, you should check if there's one running before starting a new one

frigid sequoia
#

This is the courtine; it makes a fade out transition of an image in the UI; I have a boolean telling if a Couritine of this type is in execution

#

This happens if you try to call the couritine but the boolean says that it is still running; which should set all images to 0 alpha and stop the corutine in progress

#

It doesn't seem to be stopping the couritine properly though

languid spire
#

that is not how you stop a coroutine

stiff birch
languid spire
#

save the return value from the start coroutine and pass that to the stop coroutine

frigid sequoia
languid spire
#
Coroutine cor = StartCoroutine(myMethod());
...
StopCoroutine(cor);
gaunt ice
eternal needle
stiff birch
#

Furthermore, if ResetScreenOverlayEffect is called on each coroutine you start, you're boolean will be reset even if the actual running coroutine isn't finished. This makes possible the call of another coroutine that will alter your effect

frigid sequoia
#

If I start a new coroutine with the same name, it is replaced then?

stiff birch
#

nope

languid spire
#

no

stiff birch
#

It adds a new one

#

The name doesn't guarantee uniqueness

frigid sequoia
#

And stop only a random one with that name when I call it to stop?

stiff birch
#

The 1st one the method find yes

#

Unless you pass a ref instead of a name, then it will stop the exact coroutine you give

frigid sequoia
#

So if I want to stop all of them I could just do a while (couritneName != null) loop rigth?

stiff birch
#

In that case just call StopAllCouroutine since it will have the same effect

opal ridge
#

So when having a script which can make do certain things (for example make a new enemy), I can make a scriptable object instead of having it to hard code every single one of them right?

eternal needle
opal ridge
#

I can't drag a prefab in the game when playing

earnest atlas
#

You can I belive?

#

You might as well spawn them

slender nymph
opal ridge
earnest atlas
#

I mean it would, but you can for testing

opal ridge
rare basin
opal ridge
eternal needle
slender nymph
verbal dome
opal ridge
craggy oxide
#

The Foreach loop doesn't get explained at all in the Unity Learn course, can someone take me through it step-by-step

rare basin
#

it's a basic C# you need to learn

craggy oxide
earnest atlas
#

yeah foreach is C# basic

craggy oxide
#

they explain 3 other loops

rare basin
#

you can just google C# foreachloop

craggy oxide
#

and then just don't explain the Foreach

craggy oxide
#

yeah alright then

rare basin
#

and find out yourself lol

timber tide
#

foreach is not looping but iterating brainfart, usually in c++ you use a forloop with an iterator, but technically foreach is both combined so technically it is a loop

#

which is why it probably wasnt explained there

#

unless you're thinking of for loop

#

I guess technically it is looping? Maybe I'm overthinking it

earnest atlas
#
startLoop:
        if (i < 5)
        {
            Console.WriteLine(i);
            i++;
            goto startLoop; 
        }```
Best loop
timber tide
#

forloop is mostly used in iteration, but you can always give it parameters to act like a normal while loop

#

ah ok, it is defined as a loop. Never really thought of it that way though

gleaming nymph
#

I have problem because
public InputField CharacterName;
isnt showing in unity inspector.

I need to assign inputfield because i wrote script and getting error "it is read only".

slender nymph
#

what is the actual error

gleaming nymph
#

Property or indexer 'string.Length' cannot be assigned to -- it is read only

slender nymph
#

yeah you need to fix that. you cannot assign to the length of a string. perhaps you mean to compare it using == rather than assign with =

gaunt ice
#

this is a compile error and you have to solve it first

gleaming nymph
#

ohh thank you

#

you are best

craggy oxide
#

foreach(string item in strings)
{
Debug.Log(item);
}

just to make sure, the foreach loop is basically saying

"for every string present in the 'strings' array, print to the console"

#

right?

#

i already looked it up i just want to be sure

gaunt ice
#

yes

craggy oxide
#

yayyy i get it

gaunt ice
craggy oxide
#

is the official name "AnotherClass" ?

I'm confused as to how this works

#

shouldnt it just be Class

#

if its defining the type of variable

verbal dome
#

AnotherClass is the type name

craggy oxide
#

that's an actual type name? not "NewClass" or "Class" or anything?

gaunt ice
#

you can name it whatever you want

#
public class Struct{
  int iAmNotStruct;
}
craggy oxide
#

yeah I know you can name the class whatever you want

#

but AnotherClass is the actual type?

#

the name of the variable is myOtherClass

verbal dome
#

Please dont name a class 'Struct' lol

verbal dome
fathom bramble
gaunt ice
#

<type name> <variable name>

fathom bramble
#

Well I guess not an object yet until you use new

#

I believe it's on the stack till then

craggy oxide
#

that's weird lol

fathom bramble
#

Well

#

it's either a type name

#

or the IDE you're using

verbal dome
fathom bramble
#

is assuming it is

verbal dome
#

Its not a standard class in C# or Unity or anything

nimble apex
#

transform child or getchild will include inactive gameobjects right?

teal viper
abstract finch
#
    {
        1Door,
        2DoorDiagnol,
        2DoorAcross,
        3Door,
        4Door,
    }
    public enum CardinalDirection
    {
        Up,
        Down,
        Left,
        Right,

    }```
For some reason im getting an error for the values in the enum for RoomType.
Identifier expected
#

Ok so I switcehd the numbers to chars and the error went away.

#

I would like to use numbers if thats possible

languid spire
#

identifiers cannot begin with a number, move it the the end

slender nymph
#

also maybe consider giving those better names

abstract finch
#

i see thanks

abstract finch
slender nymph
#

i don't know what their purpose is for so i cannot possibly provide a suggestion

abstract finch
#

The arrows represent the doors

#

ok np

languid spire
#

just use cardinal points. N, S,W, E etc

abstract finch
#

the thing is that im rotating the doors if that makessense. Lets say theres an 1 openinig south. I will pull the tileset containing one door then rotating it south therefore its not a static direction. The variable represents the tileset prefabs that contain X door

languid spire
#

gotcha, then you are probably ok with those names although it would be nice to spell Diagonal correctly

abstract finch
#

haha oops will do

limber stone
#

hello

#

i kinda need help

slender nymph
limber stone
#

so i follow a tutoral and he put rigid body on sb but i cant see the rb place on mine i have exactly the same code

slender nymph
#

show the relevant code

rare basin
slender nymph
#

!code

eternal falconBOT
limber stone
#

using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
public float moveSpeed;

public Rigidbody2D rb;
private Vector3 velocity=Vector3.zero;

void FixedUpdate()
{
 float horizontalMovement = Input.getAxis("Horizontal") * moveSpeed * Time.deltaTime;

 MovePlayer(horizontalMovement);
}

 void MovePlayer(float _horizontalMovement)   
 {
 Vector3 targetVelocity = new Vector2(_horizontalMovement, rb.velocity.y);
 rb.velocity = Vector3.SmoothDamp(rb.velocity, targetVelocity, ref velocity, .05f);
 }

}

slender nymph
#

read the message directly above yours. then get your !IDE configured and fix your spelling errors

eternal falconBOT
rare basin
limber stone
#

huh how do i use that

limber stone
slender nymph
rare basin
limber stone
#

but on unity he put rigid body as a rb but i cant

rare basin
#

what does that mean

#

he put rigid body as a rb but i cant

slender nymph
slender nymph
rare basin
#

ah

limber stone
rare basin
#

on how to configure your IDE

#

just read it/translate to your language if needed

slender nymph
limber stone
rare basin
#

this is not going well πŸ˜„

slender nymph
rare basin
limber stone
#

i did fix two error and config it but nothing apear as error it just dont show the litl thing were you choose the rb

tawdry quest
slender nymph
earnest atlas
#

Who broke eng?

rare basin
#

dont lie

limber stone
#

i just dont anderstand the coding word i can very welle anderstand

limber stone
rare basin
#

your IDE is not related to the errors shown in the console

#

do you know what IDE is?

tawdry quest
earnest atlas
#

His english isnt that bad lmao

rare basin
#

You don't need to help if you don't want to

earnest atlas
#

My guy havent read much webnovels

rare basin
#

"you" can stop helping him (you didin't start yet but :D), not "we"

limber stone
#

bro are you a dumb ass i cant anderstand special word of the comunity if you cant stand aving a bad person in coding asking help go tf out and talk to the general

tawdry quest
rare basin
#

then speak for yourself mate

#

not for everyone

limber stone
#

i totaly speek engl

#

but dont anderstand idl and shit

earnest atlas
#

I mean your english is bad

#

but not un-understandable

tawdry quest
rare basin
#

configure .. your.. ide

tawdry quest
#

but they also dont understand us either

earnest atlas
#

Yeah I read a lot of MTL things

limber stone
#

yh i have problem envent in orthograph event in french but with voice i totaly anderstand and can talk

earnest atlas
#

Lmao

slender nymph
tawdry quest
rare basin
earnest atlas
#

An IDE (Integrated Development Environment)

gaunt ice
#

ide=your colorful text editor
after configure it, it can be helpful and help you check your syntax and provide suggestions

earnest atlas
#

Unity/Visual studio

limber stone
#

i have bad writing and eror in what letter and werre to put them even in my native laguage

earnest atlas
#

Considered u have code issues its visual studio

tawdry quest
earnest atlas
#

Google exists btw

limber stone
limber stone
tawdry quest
#

then dont put your google in fricking french

earnest atlas
#

Do you mean its in french like you speak french or u put it in french on accident?

tawdry quest
#

He doesnt understand the results in french is what they said

limber stone
limber stone
earnest atlas
#

Coding is like 60% of looking things up

tawdry quest
limber stone
#

ik but im only 14 not very good english very different native laguage and beguiner

tawdry quest
#

THEN USE A TRANSLATOR

earnest atlas
#

Omg its a kid

tawdry quest
#

its free

limber stone
#

yh but it translate word that dont make sense in french

languid spire
tawdry quest
earnest atlas
#

Wdym it makes no sense

limber stone
#

the word dont make the phrase have snese

#

sense

tawdry quest
#

Which i already said they should use

earnest atlas
tawdry quest
#

lol

earnest atlas
#

It took me, googling IDE, pasing that meaning into google asking for wikia, changing wikia language to french

tawdry quest
#

even Xaxup gave up helping you, the one that told me that im in the wrong, wanting you to use translater or we stop helping.
Lol

craggy oxide
#

"method must have a return type"

earnest atlas
#

yeah you need or void or what it returns

tawdry quest
earnest atlas
#

void = returns nothing

slender nymph
tawdry quest
#

also you dont need to "return;" a void anyways

earnest atlas
#

poor box he is just sending people to c# courses XD

slender nymph
#

i'm gonna guess that random return was their attempt at fixing the issue

tawdry quest
gaunt ice
#

function declaration:
[unsafe?] [access modifier] [static?] <return type> <the name>
and consider have an online c# course first

earnest atlas
#

I think that second one is class bracket

#

So dont give him a hint to delete that too πŸ˜„

tawdry quest
#

then its indented wrong

earnest atlas
#

Proabaly he has barely any idea of coding

slender nymph
earnest atlas
#

Hellow world is not a sign of experience

tawdry quest
earnest atlas
#

Uuu unsafe??/

#

Ah pointers

tawdry quest
#

mem pointers

slender nymph
craggy oxide
#

Please leave me alone

tawdry quest
earnest atlas
#

Its UNITY channel

gaunt ice
#

ah, static is access modifier (define whether it is instance method or class method), mb

tawdry quest
#

it leads to memory leaks

earnest atlas
#

Yeah I know

slender nymph
earnest atlas
#

I also read that most of pointer stuff not really needed anymore with compileres

tawdry quest
earnest atlas
#

wait is he the guy who came with " move player left"?

slender nymph
slender nymph
#

yeah i wasn't gonna list them all lmao

earnest atlas
#

What for is protected used?

#

So far had no reason to use it considered my apps cared little for haking

slender nymph
#

protected is basically like private but allows inheriting classes to access it too

tawdry quest
#

I honestly have never used it in my life

#

xd

earnest atlas
#

I get it

slender nymph
earnest atlas
#

I mean it sounds secure πŸ˜„

earnest atlas
#

i bet someone used it thinking that

slender nymph
tawdry quest
#

our prof just told us to use private or public and ignore the others, that most of the time they are the better thing to use

gaunt ice
#

microsoft just call static as static modifier, yes, it is not access.....

slender nymph
earnest atlas
#

Is unity mostly script driven? I remember being told its c++, but so far I only coded in C#

slender nymph
#

that question does not make a lot of sense

tawdry quest
#

using unity is 100% C#

#

its made with C++ tho

earnest atlas
#

I mean the fact that U can make everything with scripts and they are written in C#.

languid spire
slender nymph
earnest atlas
#

JavaScript?

tawdry quest
#

C# is still code that gets compiled

#

not like a script that just gets read at runtime

slender nymph
earnest atlas
#

Who wants to rewrite unity in java script?

tawdry quest
#

noone cuz js is ass

languid spire
#

Don't forget there is still Emscripten for .jslibs targeting WebGL

tawdry quest
#

typescript was basically invented cuz javascript sucks so much to code with

#

lol

earnest atlas
#

when one same language has like multiple different branches cause it sucks so bad

tawdry quest
hexed terrace
#

JS (UnityScript) got removed around v2017..? IIRC

earnest atlas
#

If someone wants some coding help they are free to ask

#

box gonna send them to C# courses anyway xD

tawdry quest
#

me 2

#

this channel should just autoreply to questions with a C# & basic unity tutorial

#

xd

slender nymph
earnest atlas
#

Wasnt like most of people who came here like that?

tawdry quest
#

indeed

hexed terrace
#

nah, you're expected to know how to write a method

tawdry quest
#

60% or more times a question in here its answered by a basic tutorial video

earnest atlas
#

I mean everything is googlble

#

This chat is mostly for "why this no work"

#

with most dominant answer "you forgor" smth

#

With appearence of A"I" tools learning coding at least on begginer to medium levels became even easier.

slender nymph
#

and yet people still refuse to learn

hexed terrace
earnest atlas
#

Depens how you use them

#

Its a tool

slender nymph
#

i've blocked dozens of people at this point who just outright refuse to try learning the basics. many of them still come in here with super basic questions that even a shallow understanding of how to write code would fix even after a year or more

hexed terrace
earnest atlas
#

I liked chatGPT, when it just got out it was really good.

#

Helped a lot explaining what something does

#

With time it got worse

hexed terrace
#

It doesn't know good code

tawdry quest
earnest atlas
#

I mean who does?

hexed terrace
#

Experienced people who've been programming for years?

tawdry quest
earnest atlas
#

Reminds me of that video of valve coders complaining in the code about something

tawdry quest
earnest atlas
#

Well exp comes with time

#

Someone always starts with spaggeti

tawdry quest
#

yeah and not from blindly using AI code

#

xd

earnest atlas
#

Negatives of AI tools that got over hyped

tawdry quest
#

you learn how to code and understand what does what and how to archive what

#

thats how you learn, you never learn just using AI code

earnest atlas
#

I learn well from examples so for me it proven really usefull

tawdry quest
#

also the AI code has a high chance of beeing wrong or the wrong approach

earnest atlas
#

Yeah it loves hallucinate

limber stone
#

back

slender nymph
#

is your IDE configured yet

limber stone
#

leme try i was eating

#

just i does work with visual studio code bcs the origina lvisual studio dont work with so i use this one

slender nymph
#

screenshot your entire code editor

limber stone
#

can i send the image in this chanel

slender nymph
#

yes

limber stone
slender nymph
#

not configured. πŸ‘‡ !IDE

eternal falconBOT
slender nymph
#

it is a requirement to get it configured in order to receive help here

limber stone
#

ok ty leme do it

#

thats what i wasnt anderstanding and a litl phrase like you did could of explain me of the start wat was ide ty

hexed terrace
#

Keywords and phrases can be easily highlighted and googled.. you can do that yourself when you come across a word/phrase you don't know

kindred halo
#

is this the right way to do this?
the firing becomes false when I stop holding the mouse button

limber stone
#

it wont select Visual Studio Code as External Script Editor.

#

i dont have the choise

slender nymph
slender nymph
limber stone
#

ok or can i just restar unity ?

slender nymph
#

you need to restart after installing the .net sdk anyway so restart the whole pc

limber stone
#

ok

stuck palm
#

Can you crash an audio source? If I run my mouse really fast along buttons which are configured to playoneshot a sound on hover eventually they stop making sounds

slender nymph
#

you sure you're not hitting the max number of sounds playing at once or something?

limber stone
#

still not leting me the choise of visual studio code