#πŸ’»β”ƒcode-beginner

1 messages Β· Page 435 of 1

pallid nymph
#

exactly

real falcon
#

cant it point in two opposite directions though

errant mesa
#

For my player when using keys it moves {60, 0, 0} which is forward but for my button it moves {0, 0, 60}

pallid nymph
#

not in your c... oh... eh... lets say, you detect that and use the last known value or something

#

technically it's just not defined in that case

errant mesa
pallid nymph
#

AddForce is local by default

#

not sure what's going on because too much to read... but thought I'd mention it πŸ˜„

rocky canyon
#

try using rb.AddRelativeForce

errant mesa
#

Alright for the button?

pallid nymph
#

wait, it's not local? I guess I'm misremembering something πŸ€” if it's world it should be the same

rocky canyon
#

for both

errant mesa
#

Akr

rocky canyon
pallid nymph
#

yep, you are correct... I was thinking of transform.Translate, which has a parameter for local or world, my bad

real falcon
#

I actually found the issue with my code and I think it works fine now

#

you can only move the remaining distance from your current angle to the max angle right

#

I was getting the angle from the base vector and the DESIRED vector

#

not current

errant mesa
# rocky canyon for both

Now its reversed, the key moves it sideways and the button moves it forward so i should add relative to the button and remove the one from the key?

rocky canyon
#

that'd work πŸ‘

silver lagoon
#

Hello, I want to get the position of an object. Obviously transform.position comes to mind, but this object is a prefab and therefore I can't get its position that way. Is there any way to get the position of a prefab?

polar acorn
#

That does get the position of the prefab. It'd be the value you set in the inspector for the root object of the prefab

rocky canyon
#

a prefab shouldn't have a position πŸ€” until you instantiate it into the scene. at which point u'd get a reference to the spawned prefab..

#

and that would have a position

surreal coyote
#

not sure exactly where to ask this but anyone got any idea why my script is acting like this... i cant interact with it at all.

errant mesa
surreal coyote
polar acorn
surreal coyote
#

it is, thank you. not sure why though 😭

#

nevermind forgot GUILayout.EndHorizontal(); πŸ’€

silver lagoon
polar acorn
#

If that's the prefab, then this code wouldn't be running, because prefabs don't run any code

silver lagoon
#

The prefab has been instantiated

polar acorn
#

and the values on the prefab no longer matter

vast vessel
#

hey guys!
how can i create a material instance, that is shared between several renderer components?
i tried this but it doesn't seem to be working.

silver lagoon
#

I'm trying to get the position value of a specific instance from code, but it keeps giving me 0, 0, 0. The actual position of the instance is the second image

polar acorn
#

It is entirely possible the object with that transform is at 0,0,0

rocky canyon
#

debug localPosition and you'll probably get ur values u see in the inspector

polar acorn
rocky canyon
#

no worries πŸ‘ have fun w/ editor coding

#

fun stuff

polar acorn
rocky canyon
#

hehe 😈

silver lagoon
rocky canyon
#

not sure, can't say ive tested that.. i can tho

polar acorn
languid spire
rocky canyon
#

and not the instance of hte prefab u spawn

silver lagoon
#

That's definately the issue

rocky canyon
#

need to access it thru a reference u assign when u instantiate it

silver lagoon
#

I'll try this, should work. Thanks for the help

#

Seems to have fixed it. Thanks a ton!

copper orbit
#

I have a class Player with hp. I have an Item class which has capabilities like increasing hp. How do I best send the information to increase hp to the right instance of player when an item is gained?

queen adder
#

i'm following brackey's tutorial on top down movement in unity and it says that i have to move the rigid body component there, but it won't let me. does anyone know what could be causing this issue?

rocky canyon
#

a Rigidbody and a Rigidbody2D are different things

languid spire
#

Rigidbody is not Rigidbody2D

polar acorn
queen adder
#

omg thank you so much haha

rocky canyon
#

referenceToPlayer.GetComponent<Player>().AddHP(itemPickupAmount);

rocky canyon
#

I use a GameManager/PlayerManager singleton so it has a reference to my Player / anything important I need to access frequently..

#

then its just PlayerManager.instance.AddHealthToPlayer();

#

or PlayerManager.instance.AddToInventory(item);

copper orbit
#

i have seen it in code tutorials

rocky canyon
# copper orbit it worked spawn. Just did getcomponent. I am curious about the way you implement...

Want to know how to CODE in Unity? Go here: https://gamedevbeginner.com/how-to-code-in-unity/

Learn the pros & cons of using singletons in Unity, and decide for yourself if they can help you to develop your game more easily.

00:00 Intro
00:47 What is a Singleton?
02:39 Why use a Singleton?
03:00 Drawbacks of using Singletons
05:45 Is it ok to ...

β–Ά Play video
copper orbit
#

cool

#

thanks bro!

plush palm
#

This should instantiate a bunch of trees right?

#

Instead it returns a null reference

polar acorn
plush palm
#

21

#

I did all this before, but my hdd got corrupted so im trying to remember how i did it all

polar acorn
plush palm
#

Previously i had a list of resources

polar acorn
#

what line

plush palm
#

oh i see sorry

rocky canyon
#

since u code doesnt have line-numbers we need a bit more info πŸ˜„

plush palm
#

Sorry lol

polar acorn
plush palm
#

ah lol

#

πŸ€¦β€β™‚οΈ

#

It's the gamegrid

tardy needle
#

Kinda need help with a problem I have.
I have been trying to make class that basically waits X seconds to do something, its basically a timer

public class EsperaSegundos : MonoBehaviour
{

    float _seg;

    public EsperaSegundos(float seg)
    {
        _seg = seg;
    }

    public bool Contador()
    {
        _seg -= Time.deltaTime;
        if(_seg <= 0)
        {
            return true;
        }
        return false;
    }
}

So whenever the seconds is <= 0 it returns true so the timer has finished.
The idea is that the method Contador() is going to be called inside an update of another class.
However, the problem comes when instantiating this object with a constructor in another script:
EsperaSegundos esperarSeg = new EsperaSegundos(_secondsPerAttack);
This is what I have in mind but it wont work

void Update()
{
   EsperaSegundos esperarSeg = new EsperaSegundos(_secondsPerAttack);
   if (esperarSeg.Contador())
   {
       Instantiate(_bullet, _bulletSpawn.position, _bulletSpawn.rotation);
   }
}

What am I missing. I dont know much about C# but in Java I think this is how it would work.
Any ideas?

languid spire
polar acorn
#

And any constructor in a MonoBehaviour will be ignored

tardy needle
languid spire
#

well, to be blunt, no it wont

wintry quarry
tardy needle
#

Is it possible to do it this way?

languid spire
#

no

wintry quarry
#

yes it's possible, not with your exact current code

tardy needle
wintry quarry
tardy needle
#

and if I remove it?

wintry quarry
#

something similar to this is possible

polar acorn
#

And possible doesn't mean good. This would still be incredibly wasteful even once you sort out the creation of a new class to hold the timer. It's just gonna exist forever until GC'd

wintry quarry
#

but not this exact thing

languid spire
#

you should also never intentionally pause the Update loop

tardy needle
#

it actually doesnt pauses it

#

sine it will just return false

#

but I think it is just better to use coroutine instead :P

rocky canyon
#

πŸ’―

tardy needle
#

is there a reason I shouldn't use them?

rocky canyon
#

a coroutine?

tardy needle
#

or its just objectively better?

tardy needle
languid spire
#

it's the tool Unity gives us to do the job, so take your pick

tardy needle
#

Alright

wintry quarry
rocky canyon
#

i'll write a timer in update from time to time.. but for most cases i use coroutines daily

wintry quarry
#

Besides this is barely any more convenient than just making a float variable and decrementing it yourself

#

so it's hard to really see a huge benefit here

tardy needle
wintry quarry
rocky canyon
#

small data structures are better for structs

wintry quarry
#

Structs are different from classes in that they are value types instead of reference types

#

it's kind of a subtle difference if you're a beginner

#

but it's quite important

tardy needle
#

Alright

#

Thanks for all the help

plush palm
#

Should work right? But it returns null

#

Oh right it's populating the trees but on 1 spot lol

polar acorn
plush palm
#

There isn't any, just not doing what it did previously which was a grid

#

Before it looked like this

#

let me find my screenshot

wintry quarry
polar acorn
# plush palm

That does seem to be spawning a tree at this object's location

plush palm
polar acorn
#

one for each square in the grid

wintry quarry
#

the array is definitely conceptually a grid

plush palm
#

Thats what i worked out before my corruptions

polar acorn
#

Nothing in here is putting the trees at any different locations

wintry quarry
#

not sure why you'd expect any different

wintry quarry
#

literally on the line before you assign

plush palm
#

So the grid is working in terms of it's going through from 0 -> 15 on i and j

#

but im trying to recall at each iteration of i / j is a new tile

#

within my game world

wintry quarry
#

Your code spawning all the objects at transform.position. The code is doing exactly what you wrote.

plush palm
#

Yeah i understand transform.position is just 0,0,0

wintry quarry
#

I assume you're using a tilemap here

plush palm
#

The background is a tilemap, but the gamegrid isnt

#

it's gameobjects which i lined the array up

wintry quarry
#

what's the gamegrid

plush palm
wintry quarry
#

you need a Grid to convert grid coordinates to world space coordinates

wintry quarry
#

it has no inherent connection to the game world

plush palm
#

Then i used "continue" to skip parts of the map i didnt want things to spawn

wintry quarry
plush palm
#

I'll take a look, thanks

wintry quarry
#

(Tilemap has this)

#

You can also have a separate Grid component to handle this if you wish

#

with whatever grid size/shape you want

plush palm
#

Need to sort out the layering etc

wintry quarry
plush palm
#

Presumably it would need to be a tilemap of trees and that tilemap would need to have a collider on it

wintry quarry
#

yes a tilemap collider

plush palm
#

of resources*

#

Sounds doable

#

You might cry if i told you how i achieved the above screenshot, 2 up from here

wintry quarry
#

I assume it's just a bunch of funky looking arithmetic in the loop

plush palm
#

i had it check each position for a tree:

xxx
xox
xxx

#

with the tree being the o and nothing surrounding it

errant pilot
#

eatingcoroutine = StartCoroutine(Eat(furthest));
StopCoroutine(eatingcoroutine);

guys this is supposed to end the coroutine no matter what right?

wintry quarry
#

note that it only stops the coroutine when it's waiting at a yield instruction.

#

(because coroutines only pause at yield instructions)

errant pilot
wintry quarry
errant pilot
wintry quarry
#

anyway I assume that's not the real code since it would be pretty strange to stop a coroutine directly after starting it

plush palm
#

Time to whack it now in a coroutine and watch it populate to make sure the logic is how i remember

wintry quarry
errant pilot
tardy needle
#

Need some help on rotating 2D enemies so they can constantly look at the player without oscilating in a weird way. I've tried using quaternions and also using the rigidBody method AddTorque(), can't figure out what's the best way

eternal falconBOT
wintry quarry
#

the simplest way is just:

void LateUpdate() {
  transform.right = target.position - transform.position;
}```
tardy needle
#

lock-on

#

Whats the LateUpdate method?

errant pilot
# wintry quarry !code
if(eats.Count > 0)
{
    if (furthest == null)
    {
        furthest = eats[0];
    }
    foreach(GameObject plant in eats)
    {
        if(plant.transform.position.x > furthest.transform.position.x)
        {
            if (eatingcoroutine != null)
            {
                StopCoroutine(eatingcoroutine);
            }
            furthest = plant;
            eaten = true;
        }
    }

    touchingplant = true;
    if (canEat && eaten)
    {
        eaten = false;
        Standing();
        anim.SetBool("isWalking", false);
        anim.SetBool("isEating", true);
        eatingcoroutine = StartCoroutine(Eat(furthest));
    }
}
else
{
    furthest = null;
    eaten = true;
    touchingplant = false;
    anim.SetBool("isEating", false);
    anim.SetBool("isWalking", true);
}

public IEnumerator Eat(GameObject furthest)
{
    if (furthest != null && furthest.gameObject.activeInHierarchy && currentHealth > 0 && canEat)
    {
        furthest.GetComponent<UniversalPlant>().Damage(damage);
        yield return new WaitForSeconds(damageDuration);
        StartCoroutine(Eat(furthest));
    }
}

polar acorn
#

It runs after every object's Update

polar acorn
eternal falconBOT
tardy needle
frigid schooner
#

hi

wintry quarry
frigid schooner
#

I want to ask how do I change variables in one script using another script

polar acorn
wintry quarry
errant pilot
#

ill see it thank you

wintry quarry
#

if you want to repeat code

#

just use a loop

tardy needle
#

Oh I see

errant pilot
#

thank you!

plush palm
#

This should populate the array, down then right no?

wintry quarry
#

and go to j >= 0

#

for (int j = rows - 1; j >= 0; j--)

plush palm
#

Yeah i understood, thanks so much πŸ™‚

plush palm
tardy needle
# wintry quarry do you need it to be physically realistic? Or just a lock-on effect

Also I am interested on how you can do it making it physically realistic since I have also been trying to do it but ran into a few questions.
ΒΏIf my enemy is moving using the rigidBody component, should it rotate using transform.rotation, or using the AddTorque() method? and also
ΒΏWould this be inside Update() or FixedUpdate()?
After watching lots of videos I made them rotate like this (physically realistic), its inside the FixedUpdate but not sure if it belongs there:

(Inside FixedUpdate)
Quaternion rotation = Quaternion.LookRotation(Vector3.forward, _dirJugador);
transform.rotation = Quaternion.RotateTowards(transform.rotation, rotation, _rotationSpeed*Time.deltaTime);
       

The problem with this is that I had some oscilating problems.
So what would be a correct way to make it rotate in a realistic way

wintry quarry
#

to do it realistically you would basically need to use a PID controller

#

in real life things can't rotate instantly on a dime. They have inertia

tardy needle
#

Can you rotate using AddForce?

wintry quarry
#

so there needs to be a period of acceleration, then deceleration

wintry quarry
#

it always adds forces at the center of mass meaning there will be 0 net torque

#

hence no rotation

tardy needle
wintry quarry
#

typo

tardy needle
#

Oh okay

#

And everyrhing that uses rigid body should be inside FixedUpdate()?

copper orbit
#

in class player, I have a field called totalDamage. When I instantiate a bullet, I access class Bullet with GetComponent and pass along the totalDamage for .Setup. The Bullet never receives the value of totalDamage. Is this because its a class field? Can it be cast as just an int?

#

It never gets it and I get a null reference error

wintry quarry
#

Just saying you used GetComponent is really vague

#

Can you show your code and show what line you got the NullReferenceException on?

wintry quarry
#

no need to use GetComponent at all

#

and this also makes sure you don't make any mistakes in the editor when you assign the prefab

tardy needle
wintry quarry
tardy needle
#

It is activated

wintry quarry
#

how is the Rigidbody moving

tardy needle
#

_rb.velocity = _dirJugador * _speed;

#

Inside FixedUpdate

wintry quarry
#

And _dirJugador and _speed are calculated as?

tardy needle
#

_dirJugador = (_jugador.transform.position - transform.position).normalized;
float _speed = 3.0f; (constant)

#

Btw is this the best way for a lock-in moving direction towards player?

wintry quarry
#

can you show a video perhaps?

tardy needle
#

Sure

copper orbit
#

the debug.log for totaldamage at the top works fine

wintry quarry
#

Which is a mistake my code wouldn't allow you to make

#

Part of why I recommend that approach

copper orbit
#

the prefab does have the Bullet component. appreciate the feedback, I do have to refactor a lot of this

wintry quarry
#

Feel free to show some screenshots to prove me wrong

#

Also seeing your exact error message might be helpful

polar acorn
copper orbit
plush palm
#

Why does changing 30->36 throw an error?

#

Ah the nested for loop is in the wrong order presumably πŸ€” I needed more rows than columns, so the rows couldn't be nested.

manic void
modern oxide
#

Hey guys, I'm planning on making a script that will realistically control a rocket. I'm wondering how I would go about it. I want it to go by a realistic (yet simplified) version on how orbits work. I'm not sure what channel to put this in, I'm putting it here because I'm a beginner. (I want it be like how ksp does it)

keen pecan
#

Does anyone know how to solve the sensitivity issue for exporting unity builds to WebGL?

wintry quarry
#

make sure you save your code changes and show the actual code that caused the error

#

And please share code not with screenshots πŸ™

plush palm
#

I think it was because the nested loop was running more than the outter loop

#

Making the rows the outter loop, with the columns the inner resolved the issue

wintry quarry
#

that's not in and of itself a problem

spiral glen
#
{
    [SerializeField] GameObject player;
    Vector3 playerPrevPos;
    // Saves player position on start then changes if different -5 from currentPos
    Vector3 currentPos;
    // Saves current position of the platform
    public float distance = 5;
    // Distance between the player and death platform

    void Start(){
        currentPos = gameObject.transform.position;
    }

    void Update(){
        playerPrevPos = player.transform.position;
        if ((playerPrevPos.y - distance) > currentPos.y){
            transform.position = new Vector3(currentPos.x, playerPrevPos.y - distance, currentPos.z);
            currentPos = gameObject.transform.position;
        }
    }```
Any glaringly obvious mistakes with my script that'll the current position of the platform is more then distance it'll change the platforms position into the players position - distance?
wintry quarry
#

Your problem here was actually you mixed up rows and columns @plush palm

plush palm
wintry quarry
spiral glen
#

I'm unable to check without putting it into a different unity file because I don't want to push a bugged script into my git main

wintry quarry
spiral glen
wintry quarry
#

if it works at all

spiral glen
#

it's gonna be like the death thing in doodle jump so I don't need it to follow x or z

wintry quarry
#

hard to say with all the subtraction if everything is right. It could very well work. Best to test it

ornate lynx
#

hello, is it possible to detect if a variable changed from a state to another in one frame?

eternal needle
ornate lynx
#

i wanna know when it changes from a specific value to another specific value

wintry quarry
cosmic dagger
ornate lynx
#

ok i'll see what i can do

primal rivet
#

guys can i make 3d game but with this view?

slender nymph
#

that doesn't seem like a code question. but why wouldn't you be able to

primal rivet
#

idk it is look werid

round pebble
#

So, I have a navmesh agent on an "enemy" and I have it go to the player, and that works fine, but I have a retreat coroutine that has that enemy back away from the player until a certain range, although the issue is, the agent destination is getting set properly and it can be reached, but the enemy doesn't move and just stays in place, is there something im missing?

rocky canyon
#

Probably

round pebble
#

Is there any ideas that I should be checking for? All im doing is setting the destination to behind the enemy

slender nymph
#

show code

rocky canyon
#

But yes. Share code too

round pebble
# rocky canyon Is it far enough outside it's stopping range? Distance*

It might be, I can try checking that

IEnumerator Retreat() {
        isRetreating = true;
        anim.SetTrigger("Retreat");
        GameObject closestPlayer = FindClosestPlayer();
        if (closestPlayer == null) {
            isRetreating = false;
            yield break;
        }
        Vector3 retreatDirection = (transform.position - closestPlayer.transform.position).normalized;
        lastPos = transform.position;
        while (Vector3.Distance(closestPlayer.transform.position, transform.position) < retreatRange) {
            Vector3 randomDirection = transform.position + retreatDirection * retreatSpeed;
            if (UnityEngine.AI.NavMesh.SamplePosition(randomDirection, out UnityEngine.AI.NavMeshHit hit, 10f, UnityEngine.AI.NavMesh.AllAreas)) {
                Vector3 retreatPosition = hit.position;
                agent.isStopped = true;
                agent.ResetPath();
                agent.SetDestination(retreatPosition);
                agent.isStopped = false;
            } 
            yield return null;
        }
        isRetreating = false;
    }

All of the agent reset/isstopped was me testing different things

slender nymph
#

you stop it every frame until the distance is more than retreatRange. what is the point in stopping it anyway? just set its new destination

round pebble
#

I was stopping it to maybe see if that was the issue, since I wasn't too sure what the issue was

slender nymph
#

okay well stop that. then read through your code very carefully

#

tell yourself what each step of that does. then consider why you've done that, you might figure out the issue on your own

round pebble
#

Yea, I think spawn camp kinda helped me realize the issue, I don't think its distance was getting set outside of the stopping distance so it didn't move

rocky canyon
#

U can change that on the fly too

#

Depending on if it's rushing retreating or w.e

#

To fine tune ur enemy

round pebble
#

I wanted the enemy just walk backwards as a retreat, not rushing or anything like that

rocky canyon
#

Getting on state machine territory 🫣

rocky canyon
#

So ur not stuck w a single

#

Value

round pebble
#

Yea, I might look into that as well, thank you for the help

viral hound
#

is there a way to get scriptable objects in a list quickly, or do i have to put them in a list manually?

wintry quarry
#

your question is pretty vague

viral hound
#

i have a list of items

#

i wanna put in a shop quickly and i will add more

wintry quarry
#

You could have an editor script/OnValidate that scans a particular directory with AssetDatabase to populate them all from a folder

#

or just select them all and drag them into your list

viral hound
#

ok thx

true birch
mint remnant
#

kinda weird that unity would complain about use of an unasigned int when by all rights it should default to 0

muted narwhal
#

How can I disable player input (movement, jumping, etc) when editing InputField?

mint remnant
#

use OnValidate() to validate the data before it's ready

steel stirrup
muted narwhal
raw token
steel stirrup
mint remnant
#

nah just a declared local int, I'd think maybe a warning would be ok, but an error?

muted narwhal
steel stirrup
#

No, as in the hierarchy

muted narwhal
#

Ah

steel stirrup
#

and the overall ui flow

#

if a player is either in game or in a menu, you can just check whether any menus are open before processing input and exit if yes

#

if you have UIs mixed into the world, you'd just set up a bool and add events for whenever the player starts and finishes editing text to enable or disable input

#

iirc eventsystem also has information regarding selected UI elements

#

yeah @muted narwhal all you're going to do is query your eventsystem and see if the current selected object is null or an inputfield

muted narwhal
#
        private bool IsAnyInputFieldFocused()
        {
            return _inputFields.Any(inputField => inputField.isFocused);
        }

if(!IsAnyInputFieldFocused)
    movement code here

Would something like this work?

mint remnant
steel stirrup
raw token
muted narwhal
mint remnant
eternal needle
ivory bobcat
# raw token I feel that... it is a bit of interesting decision on Microsoft's part to only i...

It would save a tiny bit of processing time. In C, it would be similar to allocating new memory and zeroing everything out versus just simply allocating new memory without zeroing.

A local variable introduced by a local_variable_declaration or declaration_expression is not automatically initialized and thus has no default value. Such a local variable is considered initially unassigned.
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/variables#929-local-variables

mint remnant
#

I guess it sorta depends on if an int is defaulted to 0 in the specification or if that is implementaion specific. If it's that way in the spec then they are both saying it will be defaulted and then expecting you to officially initialize it tool

ivory bobcat
raw token
steel stirrup
#

If you look at the lower right corner, selected only clears when I click outside of the inputfield, and not when I press enter, whcih is something you'll want to be careful of

muted narwhal
#

How can I fix that?

raw token
muted narwhal
#

Oh, wait

#

I don't need to fix that actually

steel stirrup
mint remnant
#

is there a way to hard break running code? I ended up with a tight infinite while loop and pause or play didn't cause a break. Or is end task the only way?

steep walrus
#

I am trying to teach myself c# so I can use it with unity but I cant even create a simple "hello world" program because I get this error

#

Also when I try to run it im told the file cant be found but whe I check the directory its still there?

mint remnant
#

!ide

eternal falconBOT
raw token
raw token
mint remnant
steep walrus
eternal falconBOT
raw token
steep walrus
raw token
#

Ah shucks... hmmm

steep walrus
#

I tried uninstallying vs code multiple times

#

restarting

#

could i redownload some of the sdk's?

#

i dont want to fuck up my computer obviously and im not exactly sure what is and isnt safe to download

mint remnant
#

anything interesting when you clicked Open Log in the dialog?

mint remnant
#

is this on a PC or mac?

steep walrus
raw token
#

The very limited discussion in this issue seems to indicate that it might be defaulting to whatever's found first in your environment path...

When I open a terminal and execute

dotnet --info

it provides quite the info dump, but among it I can see that the dotnet resolved on path is at C:\Program Files\dotnet\sdk\8.0.303\ and another for x86 in C:\ProgramFiles (x86).

I don't see a means to explicitly set it in the C# Dev Tools extension... If this is the case, you may need to change your environment path, or launch VSCode with batch file or some such

#

My own environment path only has C:\Program Files\dotnet\ as far as dotnet entries go

steep walrus
#

and are you saying i would just need to move my project files there?

#

also how can i identify my current environmen path

raw token
raw token
#

You could probably just add C:\Program Files\dotnet\ to the top (or move it up if it already exists and is buried in the list)

#

If something else was depending on dotnet resolving to 32-bit version, this may interfere with that functioning properly, however. It's a shame C# Dev Tools doesn't let you explicitly set the path to your choice of SDK πŸ€”

steep walrus
#

is that what im looking to do?

raw token
# steep walrus this is what comes up, does tha tmean that if i want to now do a project it shou...

When you or some other program executes a command and Window's isn't sure where it resides, it'll search all of the paths in the environment path list from the top down looking for that command.

In this case, if something's looking for dotnet, it seems something at some point added an entry that's causing one of your 32 bit SDKs to be found before the 64 bit versions. So by putting the path to 64 bit version earlier in the list, things looking for dotnet should find it first instead

raw token
#

Ah hmm

steep walrus
raw token
#

I have that same %USERPROFILE%\.dotnet\tools entry...

raw token
steep walrus
#

Im still getting the same exact issue im gonna go to bed cause its late and ill probably have better luck with fresh eyes tomorrow. thank you so much for your time i appreciate it

raw token
mint remnant
#

if it helps, there seems to be tons of people with similar issues on google searchs related to same error. Of course every solution seems to vary for each of them

raw token
#

That sounds more promising than my single-comment-inspired goose chase, at least πŸ˜…

arctic ibex
#

Anyone you what the deal is with this error? the object exist, and that refernce to it's sprite renderer works in other parts of th escript

languid spire
#

extrastars is null

arctic ibex
spare mountain
#

You're referencing a null object

languid spire
#

you csnnot add to something that is null

spare mountain
#

And trying to do something with it

#

You're trying to add to nothing basically

arctic ibex
#

ohhh, okay. So how do I add the Spriterenderer onto the list, instead of what I assume is a maths method

spare mountain
#

Just make the list not null

stiff birch
#

You have to initialize the list before adding something to it

languid spire
#

you need to initialize your list

arctic ibex
#

How? I mean I know if it was an array I would say like, = new Spriterenderer[number]

#

but lists dont work like that right?

languid spire
#

vey close to that, yes

stiff birch
#

new List<MyType>();

spare mountain
#

new List<type>();

#

Yup

arctic ibex
#

damn, you guys just racing to see who can respond first?

spare mountain
#

LOL

arctic ibex
#

oh alright, thankyou!

stiff birch
#

we're in sync xD

arctic ibex
spare mountain
#

Let's go kaihyo

arctic ibex
#

wait lemme test something...
how do I run a coroutine?

arctic ibex
robust dew
stiff birch
robust dew
#

I've just done the Junior Path On U Learn and I don't really know if I should jump into some small project and learning, searching from that or find some more course on Youtube... What did you guys choose ? I need some advices, kinda lost now notlikethis

solemn fractal
#

Hey guys, do I need to use gettes and setters for all my variables inside player etc? or just the most important ones? If you are creating a game alone should I even care about this?

queen adder
#

Hello I'm new here and I have an issue with my unity is there anywhere I can possibly get some assisstance?

barren vapor
#

You're in an entire server where you can get help. Just post your problem in the correct channel

queen adder
#

Ok thank you

#

Where exactly would this channel be?

jagged socket
#

how can i change the postive and negative buttons by code?

pine umbra
#

Hello, currently I work on a Tycoon and I struggle a bit with inability to choose way to store sprites of each building from blueprints. With my current knowledge I guess that the most optimal solution would be to use the SerializeField attribute but it may be you know better way to do that : pp

pine umbra
queen adder
#

Ok thank you It's just a problem with when I load up a project I'll look somewhere else

north kiln
jagged socket
chilly cedar
#

Hey, I am a 14YO trying to work out how all of this works haha, struggling with C# and was wondering if anyone had any tips on how to start out

north kiln
#

There are lots of tutorials pinned to this channel, just start with the one that looks most appealing to you

bitter walrus
#

Second camera wont work, black, not even the blue background colour, just black not working, I am using urp, I want to make a camera act like a TV picking up a picture from somewhere else and using the texture to put it elsewhere, but the second camera doesn’t work

#

As soon as I delete the for camera the second one starts working

#

I know this happens to hdrp

#

But not urp

teal viper
queen adder
#

how would I access a value in a game object's script from a prefab's script? I'm doing a flappy bird yt tutorial where the pipes are a prefab and I'm trying to access the variable 'birdIsAlive' in the bird game object's script from the pipe prefab's script but it says null reference when i try play the game

rare basin
#

show the error and console

queen adder
rare basin
#

what is line 22

queen adder
#

my editor doesnt say the lines so give me a sec

rare basin
#

your birdScript is null

queen adder
rare basin
#

also, you don tneed 2 separate variables

#

you can store prefab in public BirdScript bird

#

and then just instantiate that prefab

queen adder
#

the prefab is stored in a completely different game object

#

called pipe spawner

#

if I'm misunderstanding something here its because I just started, sorry

ivory bobcat
#

You need to reference the bird when you instantiate the pipe with this pipe movement script

queen adder
#

how would I do that?

topaz mortar
#

!code

eternal falconBOT
ivory bobcat
#

Show where you're instantiating the pipe

queen adder
ivory bobcat
#

Usual pattern would be cs var pipe = Instantiate(pipePrefab); pipe.birdScript = birdScript;Assuming the class that spawns the pipes have a reference to the bird via bird script.

queen adder
#

ah ok I'll try that ty

ivory bobcat
#

Reminder that you can reference an object in the scene by their specific component type. You can always access the GameObject and Transform components using the properties gameObject and transform from any component - unless you're explicitly needing nothing other than a reference of the GameObject or Transform.

topaz mortar
#

Okaj I hope I have all the code here: https://gdl.space/kolagekaki.cs
When you right click a Weapon, it checks if one is already equipped and unequips it, then equips the new weapon.
This works through the event system, but it's somehow messing up my visual equip part, where it will visually unequip the weapon after equipping the new weapon.
The stats on the new weapon do work though.
Not sure where I'm going wrong or what to look for, are my events just triggering in the wrong order or something?

amber nimbus
#

Hello, I tried using 2023.3.0a18 today and I got this message as I opened the project, they stay there even after restarting the engine. Should I just ignore it?

queen adder
languid spire
amber nimbus
#

Yeah, I mosty use LTS I just wanted to try

languid spire
#

2023 is dead. If you want to 'try' the latest use Unity 6 Preview

amber nimbus
#

Alright thanks

topaz mortar
#

Okaj I hope I have all the code here:

queen adder
neon fractal
queen adder
#

ok thanks

topaz mortar
#

My current inventory logic requires an item to know which inventoryslot it is in, but also requires the inventoryslot to know which item is in it.
Is this logic bad or wrong?
My reason behind it:

  • I save and load items on my server, but not my inventory, so when loading items, each item needs to know which inventoryslot it was in.
  • I can drag items between inventoryslots, so when I drop an item on an inventoryslot, that inventoryslot needs to know if there is an item in it already and then move that to the new item's old inventoryslot
calm brook
#

how do I toggle Intellisense in visual studio community? (NOT visual studio code)

hexed terrace
#

!vs

eternal falconBOT
#
Visual Studio guide

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

β€’ Visual Studio (Installed via Unity Hub)
β€’ Visual Studio (Installed manually)

languid spire
calm brook
#

tysm

teal viper
# topaz mortar My current inventory logic requires an item to know which inventoryslot it is in...

It's okayish. Sometimes you can't avoid it.
But you could consider some refactoring to change that:

  • instead of saving the items, save the slots data, including the items.

Ideally you want to maintain a hierarchy of one way references like below, but sometimes there're just gonna be exceptions that break the rules.
Container(character, chest, box, etc)
Inventory
ItemSlot
ItemInstance
ItemDefinition(type)
Effect
Etc...

calm brook
calm brook
#

yea 1 sec sorry bout dat

teal viper
# calm brook

Yep, that's not configured. Did you follow all the steps from the guide above that the bot shared?

calm brook
#

yea I mean by configured you mean while installing vs code, also install the unity thingy right?

teal viper
calm brook
#

oh, sorry about that, i'll look into it rn

supple ibex
#

Hello everyone, I'm a student and right now I'm working on a project to create monopoly game but I encounter some problem when following this tutorial.

https://www.youtube.com/watch?v=iy-63zudcJ0&list=PLDcwWgfSSwTgIgtBkSn3lSFjzJQOxbr5E&index=6

here I provide a preview of my project.

#ΰΉΰΈŠΰΈ£ΰΉŒΰΉ„ΰΈ­ΰΉ€ΰΈ”ΰΈ΅ΰΈ’

ΰΈžΰΈ±ΰΈ’ΰΈ™ΰΈ² ΰΈ”ΰΉ‰ΰΈ§ΰΈ’ :

  • Unity 3d
  • Visual Studio Code

ΰΈ‡ΰΈ²ΰΈ™ΰΈ­ΰΈ²ΰΈ£ΰΉŒΰΈ•:
Ipad air 3 + apple pencil 1 + Procreate

ΰΈ§ΰΈ΅ΰΈ”ΰΈ΅ΰΉ‚ΰΈ­ ep ΰΈ­ΰΈ·ΰΉˆΰΈ™ΰΉ†ΰΉ€ΰΈžΰΈ₯ฒ์ΰΈ₯ΰΈ΄ΰΈͺΰΈ•ΰΉŒ : https://www.youtube.com/watch?v=nwA17CsjlGw&list=PLDcwWgfSSwTgIgtBkSn3lSFjzJQOxbr5E

ΰΈ§ΰΈ΅ΰΈ”ΰΈ΅ΰΉ‚ΰΈ­ΰΈ™ΰΈ΅ΰΉ‰ΰΈ—ΰΈ³ΰΈ‚ΰΈΆΰΉ‰ΰΈ™ΰΈ‘ΰΈ²ΰΉ€ΰΈ›ΰΉ‡ΰΈ™ΰΉ„ΰΈ­ΰΉ€ΰΈ”ΰΈ΅ΰΈ’ΰΉƒΰΈ™ΰΈΰΈ²ΰΈ£ΰΈžΰΈ±ΰΈ’ΰΈ™ΰΈ²ΰΉ€ΰΈΰΈ‘ΰΈ”ΰΉ‰ΰΈ§ΰΈ’ unity ΰΈ–ΰΉ‰ΰΈ²ΰΈ‘ΰΈ΅ΰΉ€ΰΈ§ΰΈ₯ΰΈ²ΰΈ§ΰΉˆΰΈ²ΰΈ‡ΰΈˆΰΈ°ΰΈ—ΰΈ³ΰΉ€ΰΈžΰΈ΄ΰΉˆΰΈ‘ΰΈ™ΰΈ°ΰΈ„ΰΈ£ΰΈ±ΰΈš

β–Ά Play video
calm brook
teal viper
calm brook
wintry quarry
calm brook
#

sharing the 2nd one sec...

#

uhh what do you mean by unity workload there was no such thing in the documentation..

#

holy moly

#

there are more sections...

#

im so dumb

#

really sorry!

queen adder
#

How would I reduce the brightness of a scene when the player loses? So I can make the 'game over' popup more bright compared to the background

wintry quarry
queen adder
#

oh ok thanks

strong harness
#

Is there any attribute to exclude and strip methods that this attribute has been attached to
For example [EditorOnly]

supple ibex
calm brook
queen adder
#

I am trying to make a Physics based controller for a Momentum based Platformer game but when I press the Jump Key it only SOMETIMES works and after I move around it basically stops working all together

teal viper
wintry quarry
calm brook
# calm brook Brackeys ig

but it's not really for super advanced things, its only for begginers and to purely to understand the engine and coding

queen adder
jagged socket
#

how can i reblind a control in unity i downloaded the new input system

modest dust
slender nymph
wintry quarry
#

input needs to be handled in Update

#

Also your AddForce is commented out for jumping

queen adder
wintry quarry
atomic holly
#

Hi,
Sometimes when I follow some tutorials on YouTube, I see some variables start with an _. Why ?

wintry quarry
wintry quarry
# atomic holly Hi, Sometimes when I follow some tutorials on YouTube, I see some variables star...

Private instance fields start with an underscore (_) and the remaining text is camelCased.
https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/coding-style/identifier-names#naming-conventions

knotty tangle
#
public class VazioRoxo : MonoBehaviour
{
    public Transform playerdir;
    Transform ball;
    float distance = 0f;
    float cooldown = 0f;

    private void Start(){
        ball = GetComponent<Transform>();
    }
    private void Update()
    {
        if (Input.GetKey(KeyCode.Z) && cooldown == 0f){
            cooldown = 300f;
            distance = 0f;
            ball.position = new Vector3(playerdir.position.x, 0, playerdir.position.z);
        }

        if (cooldown <= 300f && cooldown > 0){
            distance += 1f;
            cooldown -= 1f;
            ball.position = new Vector3(playerdir.position.x + distance, 0, playerdir.position.z);
        }

        
    }
}
#

@wintry quarry

#

My cube is only moving one way. How would I make the cube move according to the player's direction?

wintry quarry
#

What's the goal here

#

because there's a lot wrong with the code here

#

it's not just that it will "only move in one direction" right now.
It's also going to sort of be "attached" to the player.
It also has a problem of being framerate dependent.

#

Is the goal to shoot a projectile that will be independent of your player after firing it?

#

Also which object is this script attached to?

knotty tangle
wintry quarry
#

please say it in english

jagged socket
#

when i reblind the controls the controls won`t change
and the player is still moving with old movement this is my code for the player
and this is in the inspector

wintry quarry
#

like "the cube attached to the player's head"

wintry quarry
jagged socket
wintry quarry
#

you would need to get that instance via InputActionAsset rebindMe = myPlayerInput.actions;

wintry quarry
#

Which is... just an object in the scene?

#

Use words

knotty tangle
calm brook
#

can someone recommend a tutorial series? unity pathways ain't working for some reason

#

same server error every time

wintry quarry
knotty tangle
#

my script is inside it

wintry quarry
#

do you understand what I mean?

#

your code that rebinds the input actions needs to be doing so to the correct instances of the actions

knotty tangle
wintry quarry
# knotty tangle This projectile will be fired according to the player's vision

ok so basically you would need to do the following:

  • When the button is pressed, record the player's forward facing direction.
  • from there on, move in that direciton.

Something like:

Vector3 direction;
float speed = 10;

void Update() {
   if (Input.GetKey(KeyCode.Z) && cooldown <= 0f){
      cooldown = 1f;
      ball.position = new Vector3(playerdir.position.x, 0, playerdir.position.z);
      direction = playerdir.forward;
   }

   cooldown -= Time.deltaTime;
   ball.position += Time.deltaTime * speed * direction;
}```
ornate lynx
#

Hello, is there a way to compare the value of a variable in one frame to the value of the same variable in the previous frame because it's changing based on the player's input.

wintry quarry
#

to do it the way you are asking, you would need a separate variable

jagged socket
ornate lynx
#

I'm working on the 2d player controller, and using the Mathf.MoveTowards, now when i change direction the player slides so i was thinking maybe if the direction (axisRaw) changes from 1 to -1 or the opposite i would change the rate of MoveTowards to the max speed of the character

wintry quarry
wintry quarry
wintry quarry
#

and wdym "using the Mathf.MoveTowards"

#

Using it for what

wintry quarry
#

that's just a sample they provide

#

it's meant to show you how rebinding works

#

not really meant to be plugged & played directly into your game

ornate lynx
wintry quarry
#

You said you're using MoveTowards but that's really vague

#

it's unclear what you're using it for

jagged socket
ornate lynx
#

This literally

wintry quarry
ornate lynx
#

Yeah but when it comes to changing direction, i don't want the character to go through acceleration and deceleration, i just want him to keep going

wintry quarry
#

You could maybe do something like:

if (dir != 0 && Mathf.Sign(dir) != Mathf.Sign(speed)) {
  speed = -speed;
}

speed = Mathf.MoveTowards(speed, dir * maxSpeed, Time.deltaTime * .3);
rb.velocity = new(speed, rb.velocity.y);```
#

a bit of a hack

#

kind of a strange movement you're describing

knotty tangle
ornate lynx
knotty tangle
wintry quarry
knotty tangle
# wintry quarry you'd have to show your up to date code

if (Input.GetKey(KeyCode.Z) && cooldown == 0f){
    cooldown = 300f;
    distance = .5f;
    ball.position = new Vector3(playerdir.position.x, 0, playerdir.position.z);
}

if (cooldown <= 300f && cooldown > 0){
    cooldown -= 1f;
    distance += .5f;
    ball.position += playerdir.forward * distance * Time.deltaTime;
}
wintry quarry
#

follow my example code and it will work. In my example, I stored the direction in a variable when launching the cube and used that.

knotty tangle
wintry quarry
#

Your code is just doing playerdir.forward always, which results in this problem

wintry quarry
knotty tangle
queen adder
#

hi, i'm trying to add an image to my assets folder but my mouse turns into this 🚫
how do i fix it?

mint remnant
#

does right click import new asset work?

queen adder
#

it does, thank you

ivory breach
#

I want to try making a screen wrap like this, but I want to customize the wrapping boundaries manually instead of relying on the camera size. Anyone know a way to do it? https://www.youtube.com/watch?v=zWy29yeFNX8&t=43s

Unity Basics - Screen Wrapping

Be sure to check out my Unity for Complete Beginners course on Udemy here: https://www.udemy.com/course/learning-unity-and-c-for-complete-beginners/?referralCode=23B51187C8A97B78D1CF

In this video I will explain how to setup a simple screen wrapping script that will allow you to have objects go off of the edge of...

β–Ά Play video
shell herald
#

im a bit confused. the first methods work like a charm, but when i do it in a foreach it doesnt seem to work. does someone know why?

#

what i want to do is to change the layer of every child

slender nymph
#

GameObject is not a component

languid spire
#

you need to use
foreach (Transform t in transform)
to get all of the children

slender nymph
#
public static void SetLayerRecursively(this GameObject obj, int layer)
{
    obj.layer = layer;
    foreach (Transform child in obj.transform) 
    {
        child.gameObject.SetLayerRecursively(layer);
    }
}

i use this extension method to set the layer of a gameobject and all of its descendents

shell herald
#

thx

hollow slate
molten dock
#

with this line private List<IDataPersistence> dataPersistenceObjects;

naive pawn
#

that's a declaration, have you assigned it to anything

polar acorn
#

Where do you create a list

molten dock
#

mb i will post the script

#

so the list is at the bottom

ivory breach
spiral glen
#

if I wanted to make a jump buffer should I use couroutines or time.delta

polar acorn
languid spire
shell herald
molten dock
#

oh so i need to move it up

#

i see ty

shell herald
slender nymph
shell herald
#

hmm, thats tough then, bc it needs to be IInteractable

slender nymph
#

mate, it's an extension method

#

if you don't know what that is, start by googling those words

polar acorn
#

You're adding a function to every game object

hollow slate
waxen aurora
#

On unity when I call an api I receive a string of base64 audio that I should then convert into an audioclip, I tried to use the method WavUtility.ToAudioClip(base64string) but the problem si that it parses only files that were WAV or PCM.
In my case the audio that arrives is MP3, is there anything else I can try to convert it?

shell herald
#

ah, now i get it

rocky canyon
ripe lichen
#

I was doing this tutorial https://www.youtube.com/watch?v=SsckrYYxcuM and after the first part when the script is done at 4:01 the guy in the tutorial can slide and i get this error anyone know a fix? my sliding script is attached

ADVANCED SLIDING IN 9 MINUTES - Unity Tutorial

In this video, I'm going to show you how to further improve my previous player movement controller by adding an advanced sliding ability, that supports sliding in all directions, sliding down slopes and building up speed while doing so.

If this tutorial has helped you in any way, I would really ap...

β–Ά Play video
wintry quarry
#

the error says exactly what the problem is

rocky canyon
#

ur rigidbody is on Player

ripe lichen
#

im just not sure how to fix it ._.

rocky canyon
#

not PlayerObj

wintry quarry
#

Your scirpt is on the PlayerObj object
The Rigidbody is on the Player object

#

You therefore can't just do GetComponent from your script to get the Rigidbody

#

why is the scirpt on PlayerObj instead of on Player?

ripe lichen
#

my sliding and playermovment scripts are on player

wintry quarry
#

You can also do playerObj.GetComponent<Rigidbody>(); but goddamn if that isn';t some confusing ass variable naming lol

wintry quarry
#

the error message says otherwise

ripe lichen
#

and sliding is down there

wintry quarry
#

see what scripts are on that

#

I bet you also attached the Sliding script there

ripe lichen
#

oh...

rocky canyon
#

then you've mixed up references.. you've asked to retrieve a Rigidbody from PlayerObj

ripe lichen
#

whelp ty

wintry quarry
austere needle
#

Hi guys, i'm making a mobile 2D golf game and the script of the arrow is not working correctly, its not showing the arrow on screen when player drag the ball... i cant send the code here because of the size but can anyone help me?
code link https://hastebin.com/share/ivomuqahap.csharp

rocky canyon
#

!code u can use third party websites to share the code w/

eternal falconBOT
rocky canyon
#

no console errors or anything? or just missing arrow?

austere needle
rocky canyon
#

check that

  • ball transform is assigned
  • the arrow has a renderer and is setup correctly and is visible when active/enabled
  • ensure arrow is not being rendered behind other objects (check/adjust its Z positioning or sorting order)
  • debug.log every step of the script to make sure inputs are acting accordingly..
                case TouchPhase.Began:
                    Debug.Log("Touch Began at: " + startTouchPosition);

                case TouchPhase.Moved:
                    if (isDragging)
                    {
                        Debug.Log("Touch Moved. Direction: " + direction + ", Distance: " + distance);
                    }
                case TouchPhase.Ended:
                case TouchPhase.Canceled:
                    Debug.Log("Touch Ended or Canceled");
                    break;```
Go into Playmode and while its running select ur arrow and everything and see if its present where it should be.. if its visible.. make sure its scaled and facing the right direction, etc.. i don't see anything that jumps out as being wrong necessarily
spiral glen
#
        {
            JumpBufferTimer = JumpBuffer;
        } else {
            JumpBufferTimer -= Time.deltaTime;
        }

        if (JumpBufferTimer >= 0){
            RefRigidBody.velocity = new Vector2(RefRigidBody.velocity.x, JumpStrength);
            JumpBufferTimer = 0;
        }
        if (Input.GetKeyUp(JumpKey) && RefRigidBody.velocity.y > 0f) 
        {
            RefRigidBody.velocity = new Vector2(RefRigidBody.velocity.x, RefRigidBody.velocity.y * JumpDamping);
        }
        RefRigidBody.velocity = new Vector2(RefRigidBody.velocity.x, JumpStrength);
    ```
```private bool IsGrounded() 
    {
        return Physics2D.OverlapCircle(GroundCheck.position, 0.2f, GroundLayer);
    }```
anyone know why my character is able to jump in the air?
rocky canyon
#

either it thinks its grounded.. or ur jumpbuffer allows it to jump

#

you debugged IsGrounded()'s return?

#

to see if its actually flipping true - false, i'd debug the jumpbuffer too

spiral glen
#

I'll check

rocky canyon
#

once those things check out u can look deeper in the code to see if its something else

languid spire
# spiral glen I'll check

if this is in Update, which I guess it is, ithe code will run multiple times before isGrounded returns false

spiral glen
#

It can't be that as I can let go of the jump key and then hold it again and it'll still fly

rocky canyon
#

why are u not using GetKeyDown?

spiral glen
#

I didn't write this code, a guy who I'm making this with did

rocky canyon
#

getkey is odd choice for jump..

spiral glen
#

I'm just trying to implement a jump buffer

austere needle
spiral glen
#

I'll change it to 'getkeydown'

#

is grounded isn't working, I just tested it

patent pollen
#

Quick question: Should I use the imported 3D asset itself or should i place the asset in the scene, unpack it and prefab it?

eternal falconBOT
slender nymph
eternal falconBOT
rocky canyon
#

well hopefully u just didnt copy and paste the entire code block i sent.. as the syntax was wrong.. i was just typing out some quick pseudo code to show where debugs could go

languid spire
rocky canyon
#

yea, the code block is iffy

spiral glen
rocky canyon
#

jumpbuffertimer is checked in the 2nd if statement w/o ever verifying if the player is grounded.. which would cause jumps to occure regardless

rocky canyon
#

if(grounded){
if(getkeydown) -> jump}

spiral glen
#

what

rocky canyon
#

but u also said the ground check wasn't working correctly

#

so id probably sort that out first

spiral glen
#

yeah

slender nymph
#

do you see errors in vs code now?

austere needle
rocky canyon
#

okay.. just making sure.. some people wildly copy and paste around here w/o noticing its not even full code

austere needle
slender nymph
#

then you are not "done"

#

you missed a step

austere needle
#

still tryna find which step is this lol

rocky canyon
#

after u install the unity development module, assign the editor in the external tools menu in unity, sometimes it requires u to "regenerate project files"

#

sometimes a restart helps seal the deal as well

#

ohh ur using VSCODE?

austere needle
rocky canyon
#

ohh then yea, that pretty straight forward

slender nymph
#

is it vs code or visual studio. they are separate programs

#

and if you are not sure, then screenshot it

rocky canyon
#

vscode <-- vscode
visualstudio <-- visual studio

austere needle
rocky canyon
#

its configured πŸ‘

austere needle
#

what should i try now?

mint remnant
#

the error is still the same Control can't fall thru? If so show hte switch statement.

rocky canyon
#

i dont see errors in the ide for the switch anymore

#

i'd use the editor to keep my eyes on the arrow object and chek its transform/scale/etc to try to work out where it is and why its not working (if ur still asking about why the arrow is missing)

austere needle
rocky canyon
#

havent tried manipulating scales and stuff.. my guess would be something along those lines are getting messed up

topaz ice
#

Hey I'm "new" to unity, You can see I suffered from common knoledge on this server already.
Finally going back here, And I wanna say, I installed visual studio, And I'm SURE I have the unity stuff downloaded. But I'm not completely sure how to check if it works.

I tried writing 'input' just. 'input'. And it didn't change color at all.

Shorter messege:

I'm sure I have unity downloaded but I'm not sure it works right now.

#

Is there any extra stuff I gotta do? Or do I just have to start trying to script stuff.

barren vapor
#

!ide

eternal falconBOT
languid spire
long jacinth
#

void OnTriggerEnter2D(Collider2D other) { if(Input.GetKeyDown(KeyCode.E)) { if(other.tag == "Gun") { Debug.Log("Works"); FirstFireRate = gunHolder.GetComponent<ShootScript>().FireRate; gunHolder.GetComponent<ShootScript>().FireRate = other.GetComponent<WeaponStats>().FireRate; other.GetComponent<WeaponStats>().FireRate = FirstFireRate; } } } why isnt this working

topaz ice
#

I installed unity, And then installed Visual Studio on the windows store.

rocky canyon
long jacinth
austere needle
rocky canyon
languid spire
austere needle
rocky canyon
long jacinth
topaz ice
#

I don't think its working right. From how.. its diffrent.

long jacinth
#

i just want it so when my player is near this object with the tag gun it gives me a debug

rocky canyon
topaz ice
languid spire
austere needle
rocky canyon
# topaz ice Oh alr.

make sure to go back and see if u missed any steps.. (off hand i can think of assigning the IDE in the External Tools section of Unity)

#

then maybe regenerating project files / restarting the IDE and Unity

long jacinth
rocky canyon
languid spire
topaz ice
rocky canyon
#

its right there..

#

where it says Open by file extension

#

change that to ur editor

topaz ice
rocky canyon
#

yes ur VisualStudio

polar acorn
eternal falconBOT
topaz ice
rocky canyon
topaz ice
polar acorn
#

Then hit browse and find it

steep walrus
#

I am trying to start a basic "hellow world!" program but im getting an error telling me that an incompatible .SDK is being targeted. Im positive I have the right SDK installed but I dont know how to change which one my project is targeting. I also found some help online but for visual studio community edition and those steps dont apply for me. If i downloaded visual studio community edition and then changed the setting would that affect my vs code as well?

languid spire
modest dust
languid spire
#

and do you have the VS package installed in your project

topaz ice
languid spire
#

and your Editor version?

topaz ice
rocky agate
#

i am sorry, but how do i change the application

topaz ice
languid spire
topaz ice
languid spire
languid spire
rocky canyon
topaz ice
languid spire
#

screenshot it

topaz ice
#

Oh wait

#

Packages isn't unity registry

rocky canyon
#

unity registry is where u'll find built-in unity type assets

#

can also use search bar to help u find it

topaz ice
#

Guessing thats wrong

rocky canyon
#

its the one on the bottom

#

install it

topaz ice
#

alr I did do I just reset unity now or something

rocky canyon
#

wouldnt hurt to re-open it

#

and see if ur visual studio shows up now

#

(in the list)

topaz ice
#

alr time to check

#

This is an insane amount of things to do just to be able to code, How do new people survive this?

rocky canyon
#

well you only have to do it once

topaz ice
#

like this is me after leaving and coming back a few times

#

alr

rocky canyon
#

i set it up 3 years ago.. and ive never had to change it

#

newer versions of unity come w/ the Visual Studio Editor plugin thing already installed..

topaz ice
#

It appeared!

rocky canyon
#

so if ur IDE has Unity Developer Tools. it just works out of hte box

topaz ice
#

Also my PC sucks enough for me to just not want to download the newer versions of unity

rocky canyon
#

thats fair

topaz ice
#

Are there any game breaking bugs I should know about before I lock in?

rocky canyon
#

not unless ur using Beta editors

#

and not even then really..

topaz ice
#

Alright. sounds good.

#

Thanks alot!

solid zodiac
#

Hello there! Can anyone help me with the little resolution problem I've got?

#

So I've got a 2D Camera with Orthographic view and when I switch between different resolutions in "Game" Tab, instead of streching it cuts the screen off

languid spire
#

that is perfectly normal because the aspect ratio must be maintained

solid zodiac
#

So what you saying it's not supposed to stretch automatically?

rocky canyon
#

you'll need to adjust ur ortho size to fill in the letterboxs

solid zodiac
#

@rocky canyon Do I change it inside of scene editor or via code?

rocky canyon
#

u can do it either way.

solid zodiac
#

but that's gonna work just for single resolution then

rocky canyon
#

my project scales my ortho camera..

echo ruin
#

May I DM someone regarding help with a script to move my character position on button press?

rocky canyon
#

ahh, its probably just because my background is soo much bigger than the camera

solid zodiac
#

I think you didn't get what I mean

What's happening is when I'm changing the playing resolution (like I choose 1920x1080 or 1024x768) in the dropping down list, the camera doesn't stretch according the choosen resolution but it just cuts the objects instead

rocky canyon
#

assuming i had things that fit perfectly it'd probably break too

#

there scripts out there that can calculate the ortho size needed to match the screensize

solid zodiac
#

like, this is what happens when it's 1920x1080

#

and this is what happens if it's set to 1024x768

rocky canyon
#

yea, ull probably need a script to caclulate the screen dimensions and change the ortho size to fit

solid zodiac
#

but orho size will change both horizontal/vertial size

#

here what happens is only horizontality changes

#

Like it doesn't being stretched but just cut

summer stump
echo ruin
summer stump
austere needle
#

How do I correct this code line?
I want to show the arrow if the ball is not moving

languid spire
#

== not =

solid zodiac
#

Like I'm not even sure whether it's intended behaviuor or it's unity bug

polar acorn
summer stump
languid spire
echo ruin
#

So.. My issue is.. I found a tutorial with a script on how to enter a different scene by pressing a button on a door, but I don't want to enter a different scene, I just want to change my position (since it's a 2D game where the next room is within the same scene, but out of view)

public class NewBehaviourScript : MonoBehaviour
{
    private bool playerDetected;
    public Transform doorPos;
    public float width;
    public float height;

    public LayerMask whatIsPlayer;

    private void Update()
    {
        playerDetected = Physics2D.OverlapBox(doorPos.position, new Vector2(width, height), 0, whatIsPlayer);

        if (playerDetected == true)
        {
            if (Input.GetKey(KeyCode.Space)) 
            {
            }
        }
    }
    private void OnDrawGizmos()
    {
        Gizmos.color = Color.blue;
        Gizmos.DrawWireCube(doorPos.position, new Vector3(width, height, 1));
    }
}```

This is the script for pressing at the door
austere needle
solid zodiac
rocky canyon
#

b/c stretching makes stuff look like sh*t

summer stump
polar acorn
polar acorn
languid spire
rocky canyon
#

maybe try using a script to dynamically modify the ortho view

austere needle
polar acorn
austere needle
polar acorn
#

There are multiple answers, you just need to decide what you intend to do and then you can worry about coding that specific one

steep walrus
#

I am trying to start a basic "hellow world!" program but im getting an error telling me that an incompatible .SDK is being targeted. Im positive I have the right SDK installed but I dont know how to change which one my project is targeting. I also found some help online but for visual studio community edition and those steps dont apply for me. If i downloaded visual studio community edition and then changed the setting would that affect my vs code as well?

austere needle
solid zodiac
#

@rocky canyon @languid spire
This script look like more of a workaround hardcoding thing.
Do I understand correctly, that this is THE WAY how it's done for every 2D orho-camera game? Or I've done something wrong?
Because if the script in the thread you sent me is an usual way to solve this "problem" and it applies 100% of time when you want to have different resolutions
then... why such an important and essential piece of camera functional is it just works like that by default, as out-of-the-box solution? there's like million of different clipping settings and whatnot but none of basic camera streching functional?

polar acorn
languid spire
uncut leaf
#

getting an error saying this is null for some reason

#

i have an audio source on the gun already

short hazel
# uncut leaf

You have another one (instance of that script) where it's not set

mint remnant
#

considering Play() isn't null, it must be the thing before it

austere needle
uncut leaf
polar acorn
austere needle
mint remnant
#

try dx/dt

polar acorn
#

You know where the ball is, that's transform.position. Now you need to find a way to know where it was

uncut leaf
#

y is it saying audio source is disabled when its on here

polar acorn
# uncut leaf

Either:

  1. The object this component is on is disabled
  2. This isn't the audio source it's talking about
uncut leaf
#

ok ill check that

austere needle
mint remnant
polar acorn
rocky canyon
austere needle
rocky canyon
#

its probably easier to start making a game w/ that in mind.. and it'd feel less like a work-a-round

polar acorn
steep walrus
silver lagoon
#

I have an enemy that will chase down the player on a 2D plane and run a method when within x distance from the player. At first, I though about using Vector2.distance, but I'm worried about potential performance problems. If I had, as an example, 100 Vector2.distance calculations running per frame, would this cause any frame rate issues. If so, are there any alternative ways to solve this problem?

long jacinth
mint remnant
#

tryGetKeyDown instead

modest dust
long jacinth
languid spire
rocky canyon
#

Stay not Enter

long jacinth
#

this is what i did

rocky canyon
#

With down it shouldn't go back n forth.. 1 key press 1 instruction

modest dust
#

Such as Debug.Log($"Triggered: {name} | {other.gameObject.name}");

long jacinth
#

in the one that checks for tag right?

modest dust
#

inner-most if statement body

#

The one which checks for the key press

#

That's where all the logic happens and where you need a log

austere needle
polar acorn
#

So you want to store the starting position, and check if the ball's current position is not equal to that

austere needle
queen adder
muted narwhal
#

Why's my list isn't appearing in inspector?

keen dew
#

Abstract classes aren't serializable

muted narwhal
#

Ah

#

Thank you!

modest dust
carmine narwhal
#

Hey IΒ΄m new to C# and im stuck it feels like iΒ΄m at my plateu, everytime i get help with something from someone they always tells me to use more classes. because you can structure you code better this way. but i cant see how to use it. i know what it is and what it does( i think). but for me this only means that you are creating a mapstructure which in my opinion is the worst thing you can do to organise something. Can someone please explain to me when and why to use different classes. I think if i can understand this i can get over my plateu.

languid spire
mint remnant
carmine narwhal
carmine narwhal
mint remnant
#

Learn to use the IDE's navigational features, it's pretty powerful

languid spire
carmine narwhal
# languid spire so this ' mapstructure which in my opinion is the worst thing you can do to orga...

no its just a real life reflections, everything that i use in my daily life is a mapstructure and i hate it cause all you do is go through the entire thing every time you need to find something. if i need to find x in a-b-c-d-e-f-f1-f2-f3- etc its gonna take me forever. and in some of my ides the code needs to back up in the structure and if im on x and want that x to be inside c3 and c5 some where i need to go back to the start of the map and find where the hell i wanted it and where it came from.

tame tapir
#

I am new to coding and C#, is there someone who could give me a helping hand and recommend me some tutorials/videos i could watch to get into it

eternal falconBOT
#

:teacher: Unity Learn β†—

Over 750 hours of free live and on-demand learning content for all levels of experience!

tame tapir
#

thanks

sage mirage
#

Hello, guys! What's up? I have a question about an issue I am dealing with. So, my spotlight in my horror game that I am making isn't working properly when I have low or very low quality level. Check below the video to understand what I mean.

slender nymph
#

this doesn't seem like a code issue

sage mirage
#

I don't think so as well

#

Because my quality settings are working properly

#

You see how quality changes properly

slender nymph
sage mirage
#

First of all, I was thinking that this was a coding issue that's why I send that in here.

slender nymph
#

and even if it were a code issue, you didn't bother even sharing the relevant code

#

but again, it does not appear to be a code related issue

sage mirage
#

Yes I am not sure 100% if it is or not but I think its not a coding issue

#

Anyway, I am going to send it there

fickle plume
#

@sage mirage Make sure to post actual details about what those option do and change.

sage mirage
#

I don't have any details thats the problem

#

Everything is working properly. My code seem to be fine without any issues.

#

Anyway, I am going to inspect it a little bit and if I won't find the solution to the problem I am going to post in #πŸ’»β”ƒunity-talk

rapid zodiac
#

I was creating a stamina bar for my player, i added the canvas and the image but when i try to drag the stamina bar image to the reference in the code, it shows the sign where it's not compatible. The stamina bar has an image componenet.

fickle plume
mint remnant
#

Little confused on how to do this properly. I have an image that I sliced up in the sprite editor. Each slice is a face of a cube. I have a mesh I created in code with uvs assigned for each face. How can I reference the sliced sprites to apply to the correct faces in code? I have a matreial on the meshrenderer, but if I slap the main sprite image in the albedo it applies the whole image to every face. It doesn't even let me drag a single slice there. https://gyazo.com/5b27732831ed6f892c56716ceaad23a2

sick jay
#

Whats a good way to code stairs? I have a capsule collider with rigidbody movement and i want to be able to walk up small steps without having to jump. My only idea is to do some sort of special collider that tells the player to snap upward when its touched

eternal needle
sick jay
#

I was thinking of that too

#

I kinda wanna know how Rockstar games makes such good movement

wintry quarry
severe forge
#

can anyone help me understand the caution at the bottom of this object spawning page?

if my script inherits from NetworkBehaviour wouldn't it already have a gameobject property?

wintry quarry
#

They're just saying make sure you do myInstance.GetComponent<NetworkObject>().Spawn(); and not myPrefab.GetComponent<NetworkObject>().Spawn();

#

where myInstance was created with Instantiate()

severe forge
#

ah I see that makes sense

cinder crag
#

so im a bit stukc here , im trying to get the enemies transforms for my turret script and im trying to find all of the enemies transform but im not sure exactly on how to do it with a list or an array

polar acorn
#

What's the point of setting targets to the same value multiple times?

cinder crag
polar acorn
#

What are you trying to set targets to

cinder crag
#

the enemies transform

#

also im trying to rotate the turret towards the enemy , how can i like do it

mint remnant
#

Asmippet of some code I have, maybe you can make it work for you

        Vector3 dir = (target.position - transform.position).normalized;
        Quaternion lookRotation = Quaternion.LookRotation(dir);
        Vector3 rotation = Quaternion.Lerp(partToRotate.rotation, lookRotation, Time.deltaTime * turnSpeed).eulerAngles;
        partToRotate.rotation = Quaternion.Euler(0f, rotation.y, 0f);
cinder crag
#

my targets var is a list lol

mint remnant
#

well you could apply the logic to a list of targets if you wanted, but that rotates a turret to look at an enemy

steep walrus
#

doe anyone know how to change the target .SDK of the c# dev kit in vs code. I found some guidance for visual studio community edition but it doesnt apply the same. I have been having some issues setting up my environment and im like 99% sure the issue is that an x86 .net sdk is being targeted instead of an x64. this is based off the error i have been getting

#

any ideas?