#πŸ’»β”ƒcode-beginner

1 messages Β· Page 90 of 1

shell herald
#

thats it

#

thx

bleak vale
#

Take that in mind that some ppl are understanding things through examples and not just a text and that I need just a simple answear to make me realize how something works and how I should use that so sending me a whole documentation is not really gonna help me with understanding how line of codes works

polar acorn
bleak vale
#

And there is a saying that u shouldnt fix something that dont want to be fixed. Wich means that if I need a help with understanding why something isnt working then I am not really intrested in a whole comentations wich is like asking about grass and getting a book about biology

queen adder
#

Or maybe use the debugger to see where something breaks/doesnt behave the way you expect it to?

polar acorn
#

There will come a time where you're trying to integrate an asset and your only sources are the code itself, an auto generated GitHub documentation page, and a 400 page forum thread

bleak vale
queen adder
#

Tbh, unity documentation, is while really helpful, not that good imo

bleak vale
#

And my expierence with ppl "helping" is that noone really helps you but demotivate you

proper flume
#

Could anybody help with this? I'm getting a CS0019 error for 65,12 and I'm not sure why since I've used //&& isGrounded // on an if statement before. https://hastebin.com/share/xugiqoyoxu.csharp

polar acorn
verbal dome
polar acorn
verbal dome
#

Also I linked to the unity.huh.how page which is not official documentation, it's maintained by vertx

bleak vale
# bleak vale And my expierence with ppl "helping" is that noone really helps you but demotiva...

Demotivating through sending so many infromation with link when someone want a simple answear or like when ppl were telling me that I should make my first game just a simple singleplayer something instead of making multiplayer and that multiplayer is something I should do with minimum 1 year expierience. I dont want to put u down or something but try to realize that there is ppl who are diffrent than you and they can learn faster than you and dont need a whole documentation to realize something because they can just see thing how they work and learn

verbal dome
bleak vale
polar acorn
bleak vale
polar acorn
verbal dome
bleak vale
polar acorn
polar acorn
bleak vale
verbal dome
#

I'm not hurt. I just don't tolerate bullshit

ivory bobcat
#

Accessing the game object property from a null reference will throw nre

polar acorn
bleak vale
frosty hound
#

Let's move on

queen adder
#

Unity docs is one of the bests if not the best docs out there tho

verbal dome
#

Yeah, it's good, but some features lack examples I agree

frosty hound
proper flume
#

Could I get help with my problem now? πŸ˜…

frosty hound
#

!mute 915967054421581846 3d Really can't help yourself. You can return when you've settled down.

eternal falconBOT
#

dynoSuccess dwiezaby was muted.

rich adder
#

make sure you run the latest build after u saved and all that

proper flume
rich adder
#

eg. compare its value to something else

#

you missed a step basically

polar acorn
#

What do you want to check about jump input? What is the thing you want to know about it that'd answer "yes" to your statement

rich adder
#

wait no sorry jumpinput is a bool

proper flume
#

That's weird. Is it because it's using the Input.GetButton("Jump")? I figured that would be a bool, considering it would take extreme precision to press the spacebar halfway lol.

rich adder
#

you're right myb i misread the code

polar acorn
proper flume
#

You're okay lol. I'm basically trying to say, if the key is pressed for jump, and the player is on the ground, then.

polar acorn
#

It's defined as a float up top

rich adder
#

ahh yes wtf

#

this threw me off
jumpInput = Input.GetButtonDown("Jump");

#

so the error was correct

#

as usual xD

proper flume
#

Oh snap, okay. My B. Okay, so just change it to a bool, got it.

rich adder
#

xD

proper flume
#

I don't know how I had jumpInputReleased set to a bool RIGHT beneath it, and somehow still missed that lol

polar acorn
#

I'm surprised that other line isn't throwing an error itself

proper flume
#

Which one?

rich adder
#

jumpInput = Input.GetButtonDown("Jump");

#

you should be getting a CS0029

#

Cannot implicitly convert type 'type' to 'type'

fathom ether
#

How would i go about implementing a static message log which maxes out at like 24 messages? The code part should'nt be the problem, rather the choice of Unity object. Not sure if i should have like 24 pre-positioned gameobject in which i just change the text, or if there is a cleaner way to do that

rich adder
fathom ether
#

I think so, you told me to use a List, but thats not quite the answer to the question i have

proper flume
rich adder
#

anyway I would use a Vertical layout group

#

inside a scrollview

fathom ether
#

My wording was probably bad, my bad

#

I'll look into layout groups, thanks

rich adder
#

before the line 65

#

since you cant convert bool to float

proper flume
#

So, using that same code I had before ( I already updated to bool) it's working now, but for some reason it's missing inputs. I can sit on the ground for like 6-7 button presses (spacebar) and it will only register once.

proper flume
polar acorn
proper flume
#

Ah, it was because I was on fixed update. Somebody told me that movement should be restricted to FixedUpdate that way framerate doesn't cause issues. Is there a reason why jumping doesn't apply to that?

rich adder
proper flume
#

That's how I had it before, but for some reason having it there caused missed input. I moved Jump() to update instead, and now it works fine.

rich adder
proper flume
proper flume
#

Well, I thought all problems were solved but using this is causing me to space jump. If I attach //isGrounded = false anywhere in my jump statement, my player begins floating away. What's causing this? https://hastebin.com/share/nimaseroxa.csharp

wintry quarry
proper flume
#

Well crap, that causes a huge issue.

shell herald
#

right now, when i instanciate an object with this script, it has a z value of 51, but i need it at 0. how would i set that? https://hastebin.com/share/weviqozocu.csharp

summer stump
#

new Vector3(transform.position.x, transform.position.y, 0);

shell herald
#

thx

proper flume
#

Is it possible to have an empty modified? As in I have a player character jumping midair after falling off of a ledge because there's no trigger midair to set isGrounded to false. Could I add a // OnCollisionEnter2D(Collision collision) and then make collision.gameObject.CompareTag(//and somehow leave this empty to denote that the player isn't on the ground?)

wintry quarry
#

OnCollisionEXIT tells you when you EXIT a collision

#

if you want to know when you are leaving a collision you should use OnCollisionExit

proper flume
#

Oh sweet, didn't know that was a thing. Thanks. I'll google that.

wintry quarry
#

remember to use the 2D version if you're doing 2D stuff

summer stump
shadow junco
#

Hi guys, i need help

#

How to make unity 2d game have 3d effects(parralax doesnt work on my game)

swift crag
#

Parallax will happen when different objects move at different speeds.

#

normally, perspective does this for you

#

If you have an orthographic camera (which you usually do for a 2D game), there is no perspective at all

wintry quarry
swift crag
#

so you have to artificially create the parallax

shadow junco
#

I have 2d platformer type game, the theme is like castle dungeons and i want to make it 3d(when i move my camera i start to see the side of the walls

swift crag
#

oh, that's not parallax

wintry quarry
shadow junco
swift crag
#

yeah, you can mix 2D and 3D renderers just fine

wintry quarry
#

The answer is to use 3D art models and a perspective camera, that's all

swift crag
#

maybe you want something like Paper Mario

#

that's a mostly-3D world that just has some flat stuff in it

shadow junco
#

Btw im rly beginer

shadow junco
polar acorn
eternal falconBOT
shadow junco
#

And also can all of this be done in 2d project?

wintry quarry
swift crag
shadow junco
swift crag
#

I haven't actually touched that yet, mind you

#

But yeah, there's generally no difference between 2D and 3D

wintry quarry
swift crag
#

beyond which kind of renderer components you use

shadow junco
polar acorn
shadow junco
#

I have the map, player, boss, enemies, meniu...

wintry quarry
wintry quarry
#

and redoing all of your art basically

polar acorn
shadow junco
#

Its pixelart

wintry quarry
#

there's no magic button you can press to turn your 2D art into 3D lol

shadow junco
#

Maybe that makes it easier

wintry quarry
#

it makes it easier to tell you that you will need to redo all of the art if you want it to be 3D

shadow junco
#

I made my map using tile map, would it still work?

wintry quarry
#

No. You will need to use 3D models instead of 2d sprite art

sand harness
#

hello im having troubles with referencing between scripts, could someone take a look?

burnt vapor
eternal falconBOT
wintry quarry
#

You have basic syntax errors - seconded you must configure the IDE first

polar acorn
# sand harness
  1. You are trying to store a Character instance in a GameObject variable
  2. If it's public why not just drag it in
  3. Configure your IDE
shadow junco
burnt vapor
burnt vapor
#

And these are not coding questions but "how do I make a game" spoonfeeding questions

burnt vapor
#

They helped you with providing suggestions but please don't continue pinging them for completely different questions

sand harness
polar acorn
polar acorn
shadow junco
#

Also z axis and x axis bc i need roof and floor

polar acorn
#

There is no built in 3D tile map. You would need to make one

dusk hornet
polar acorn
eternal falconBOT
dusk hornet
#

objects like closet doors and doors

frosty hound
dusk hornet
polar acorn
#

!code

eternal falconBOT
buoyant knot
polar acorn
#

||Damn slow bot making my sarcasm not work||

dusk hornet
#

yeah kinda ruined it

buoyant knot
#

but idk if it has proper support for 3D renderring and collider generation

#

Tilemap itself stores everything with Vector3Int

polar acorn
#

but it doesn't deal in Voxels

buoyant knot
#

Tilemap as a component is mostly just a container

#

you need TilemapCollider2D and TilemapRenderer to actually use it. I do not think Unity has equivalent 3D tools

#

to use tilemap like minecraft. But maybe someone made an asset or package etc for that

#

digiholic is probably right, tbh

queen adder
#

Hey y'all. So im making a match 3 type game.
I was wondering does anyone know how i could add boosters?
Eg. Color bomb booster (auto generates on the board at a random position when selected and player can use it to destroy desired color they chose)
Hammer booster (allows the player to destroy a selected block without using a move)
Arrow booster (auto generates in a random position on the board and removes a whole row or column when used)

These boosters will be purchased using in game currency or given to the player at random times like after completing an event or something like that

buoyant knot
#

that is a very broad question

#

your blocks should be represented as a base class from which specific types of blocks derive

polar acorn
queen adder
proper flume
#

So, I've been trying to google this but can't seem to find exactly what I'm looking for. I'm making a Hollow Knight clone demo, and I've got the movement down pretty good, but now it's time for the more advanced movement options like dashing, double jumping and wall jumping. The problem is while I can find the code for making the actions themselves, I don't want them to be something you can do right away, and want to impliment them as object upgrades you can pick up later down the line. Would anybody be able to point me in the right direction for finding something like that?

frosty hound
#

Wrap the movement of those actions in a bool check that IsDoubleJumpUnlocked

#

Set it to true when they unlock it, done.

proper flume
#

Thank you

queen adder
# polar acorn This is a lot of question. Which specific part did you need, and what do you alr...

I have to board setup.
So i can adjust the layout of the board. The amount of different dots/candies. The amount of obstacles like blank spaces, comcrete tiles, slime tiles etc.
I can create different bombs when a certain number of the same dot is matched.
I can set score goals to tell the player what they need to collect to win the level.

I basically have a working game. I just have no idea how to add those boosters.
There is a tutorial on Godot to add boosters in a candy crush clone game. But it uses GDscript so i dont know how to change it to c#. Because that stuff looks complicated lol.

Also my levels are scriptable objects.

Not sure if any of this helps

#

Sorry for spelling errors im on my phone and seem to be misspelling things alot today

solid verge
#

just GetButtonDown works for me

polar acorn
broken tendon
#

for things like collisions, is it more sensible to do using layers or interfaces? Like if i want my bullets to collide with enemies, walls and doors, but not my player, my bullets, enemy bullets etc.

frosty hound
#

Use the physics layer matrix to do general ignoring of collisions

queen adder
# polar acorn "Adding boosters" is still a vague and undefined question. Break it down into sm...

See i know that i will need a button that will apply that booster to the specific level the player is on. If they exit the level then the booster is lost.

Also if they purchase a booster then it will have to apply to that booster button that they now have another booster to use.

Its just the fact of how to actually implement the booster on the board once the player clicks on that booster button.

frosty hound
#

You keep adding to the list of things you need to do, which is what's making your question too big. IF you know you need x, y and z, start with one of those an work on it.

If your main issue is how to get boosters to appear on the board, then don't worry about how they get the booster, just start with a "press Space bar and a booster appears on the board". Figure out that logic first before handling the player actually owning the boosters.

solid verge
#

how to add text on a gameobj

frosty hound
#

TextMeshPro

solid verge
#

doesn't work

frosty hound
#

Yes it does

solid verge
#

well why am i not seeing the text on my game object

frosty hound
#

Presumably because you have no idea what you're doing, not that it's broken.

jolly latch
#

Right click, 3d object, text mesh pro

frosty hound
#

This isn't a coding question.

shadow junco
#

How to make parralax?

frosty hound
#

Make sure you're using the right version of TMPro as well.

jolly latch
#

its int own object

#

you need to move it around into position

solid verge
summer stump
queen adder
#

hi, what's the difference between checking for an object like this

if (object)
vs
if (object != null)
tender stag
#

how can i reset scroll rect to the top?

jolly latch
#

they both check if the object is set

queen adder
#

both accomplish the same?

queen adder
#

okay thanks

jolly latch
#

you would do...

queen adder
#

if (!object)?

tender stag
#

yup

jolly latch
#
if (object)
{
  //Code
} else
{
  //Code
}
queen adder
#

oh, so use else instead, got it

jolly latch
#

just use else, or else if ()

summer stump
jolly latch
#

after its true

summer stump
tender stag
#

or do they have like a specific thing for that

#

cause scrollRect.StopMovement() just stops it

#

but doesnt disable it

frosty hound
#

Yes you can just disable the component

tender stag
#

alright thanks

echo badger
#

Why don't AI open doors? There are sounds, but no animation.

summer stump
echo badger
hexed terrace
#

ffs @echo badger .. delete that huge block of code, you've just been told about this

#

!code

languid spire
#

because of this
if (inReach && Input.GetButtonDown("Interact"))
it will only be true for 1 frame

eternal falconBOT
echo badger
#

The animation is ok

queen adder
#

not me typing if object!=null every time

#

🀫

remote hound
#

Hey guys, how can I fix this issue? I wanted to add a sprint functionality for my game, which replaces the movementSpeed variable with a sprintMovementSpeed variable. I set sprint movement speed to 10% more of movementSpeed, but I can't put it in update (it'll keep increasing to infinity) or start (it gives out some error). Thanks in advance πŸ˜„

fossil tree
#

hi everyone i have try to test a thing for check if a value are on my list the problem is my condition be executed but i dont have the value in my list this is my list:
public List<int> boutonListe = new List<int> {2, 3, 5, 9};
and this is my condition:

    {
        if(boutonController.boutonListe.Contains(1))
        {
            rend.color = Color;
        }
        
    }```
polar acorn
summer stump
#

Ohhh, I see, it IS changing

fossil tree
#

sry i explain bad im french x)

summer stump
remote hound
polar acorn
summer stump
#

Use Awake

remote hound
#

got it, so should I create a set function for these two variables?

remote hound
#

but don't explain it i'll google it πŸ˜›

balmy sky
#

hey everyone ! i have this code thaths whenever my player gets under a sprite renderer(i.e a tree) the tree lowers his alpha color over the course of "fade time" to be transparent so the player is visible under it , howhever the tree wont go transparent at all ! how come ? help would be much appriciated

fossil tree
remote hound
modest dust
#

Awake is called when the script.. awakens (for the first time, once per instance)

remote hound
#

thanks for the help guys!

summer stump
remote hound
fossil tree
polar acorn
#

Don't make new variables, set the ones you already have

modest dust
summer stump
remote hound
summer stump
fossil tree
remote hound
modest dust
summer stump
summer stump
remote hound
fossil tree
modest dust
# fossil tree but if she is private i cant use it on my other script no?

Actually, the more programming I do the less public fields I use - from my experience it's better to just keep most things private and if you really want to expose something to other classes then either a method or property is good. It's easier to control what's actually happening to that field

summer stump
fossil tree
#

my brain gonna explode wait

balmy sky
summer stump
summer stump
balmy sky
rough tundra
#

Hi dont know if this is right channel to ask but would be appreciated if anyone know why this happens. made a model in blender rigged it with mixamo. Downloaded rig with idle animation made it to humanoid put it in scene. Downloaded another walking animation. When transitioning from idle to walking everything looks weird. But when i change the avatar to the walking avatar it works but then the idle animation looks weird / crooked

rough tundra
#

ok ty

raven hazel
balmy sky
summer stump
summer stump
#

You move it a tiny bit from start value, cache that in newValue, then move it FROM the start value again

#

It doesn't ever go anywhere, because you never update the start point

#

float newValue = MoveTowards(1, 2, .1);

This will return 1.1 over and over

float currentValue = 1;
currentValue = MoveTowards(currentValue, 2, .1);

This will return 1.1, 1.2, 1.3, 1.4

balmy sky
#

really ? but the a value gets incrimented by the t value

summer stump
rare basin
#

πŸ˜†

balmy sky
#

so i sohuld cache 1 in my newAlpha?

#

ill try that

summer stump
true heart
#

i have a prefab item that is tying to instantiate a button ontop of itself, it gives that button aces to 2 scripts but for some reason the button is only getting the invitem script and not the inventory script. im not sure what could be the problem. also the prefab that trying to summon the button does have a refrence to the 2 scripts its trying to give to the button.

tender stag
#

is it possible for an event to return a value?

tender stag
#

can u link me like a documentation

#

or anything at all

rare basin
#

google: how to return a value with event unity

summer stump
balmy sky
#

much appriciated

modest barn
#

I have a script named Dropdown.cs and it obviously has its associated .meta file. I'm trying to rename the script to DropDown.cs, but whenever I do that, Unity gives me a warning about the .meta file having inconsistent casing, and lets me know it has reverted the name back to the "correct" name, which is not what I want. I know that I can't rename meta files, so how can I rename this script?

polar acorn
#

And you probably shouldn't use either of those names

modest barn
#

Yeah I know I shouldn't be using those names, but I'm just renaming it within the Unity Project window

polar acorn
#

Renaming the file in unity should rename the meta file as well

modest barn
#

Nah

#
Asset file 'Assets/Scripts/DropDown.cs.meta' and meta file 'Assets/Scripts/Dropdown.cs.meta' has inconsistent casing.
Renaming meta file succeeded.
polar acorn
#

And if you know both names are bad, why are you still using them

polar acorn
modest barn
polar acorn
#

Windows file system is case insensitive

modest barn
#

So how can I rename the file to DropDown if I wanted to

silk night
#

Rename it different

#

then back to DropDown

polar acorn
#

if you actually change the name, then it will work

modest barn
polar acorn
#

But also don't do that

#

because it shouldn't be called DropDown

modest barn
#

error CS2001: Source file 'C:\Users\s9316622\Documents\GitHub\CipherDecoderApp\Assets/Scripts/DropDown.cs' could not be found.

polar acorn
#

You should give it an actually descriptive name that matches what it does

polar acorn
# modest barn <@153950686088921088> as I said ^^

The answer is: According to windows, those two names are the same. Unity and C# care about the capitalization, but windows does not. As long as you are renaming something in a way that is just capitalization, it's not going to work, so you should give it a real name

modest barn
#

I renamed the file to DropdownMenu

silk night
#

Did you rename it in windows or unity?

modest barn
#

Unity

loud topaz
#

I dont know if this is a weird one: I want to make a fancy "Mover" and show the start and end position in the editor when the object is selected and update accordingly. The Problem is: The End Position right now is on the World Origin, even when i do something like:

endPosition = startPosition + someVector

Question: Where do i put these? Hope you get it, my english isnt the best.

PS: I know how to do it. Vector.MoveTowards with a step Variable, so thats not the problem. Just where to update this Gizmos and dont get confused with the "normal" code. thx in advance

summer stump
# modest barn Unity

Did you rename it to the same as the meta file before changing it to DropdownMenu?

modest barn
silk night
summer stump
modest barn
#

Nope, not in play mode. Let me start Unity.

loud topaz
summer stump
loud topaz
#

but where do i put the line?

#

in update and it only works ingame, in the gizmo selected and it only works when i select the cube.

#

im confused

silk night
#

What will be setting your endposition? the mouse, some pre-set value?

loud topaz
silk night
#

if you set it in inspector you dont need to change it at all in code, just change the inspector

modest barn
loud topaz
#

red cross where it should be, cube where it is. changed the inspector value to Vector3(0, 2.5, 0).

modest barn
silk night
loud topaz
modest barn
frosty hound
#

So you can keep things private but also expose them to the editor.

loud topaz
silk night
vale blade
#

To var or not to var?
I used to do specific Types everywhere but I pretty much exclusively var nowadays.
A company I applied to mentioned how they specifically Type everything to 'prevent' bugs but that didn't make much sense to me. what do you guys think?
not that it matters, just looking for opinions haha

frosty hound
#

Functionally it doesn't matter

silk night
frosty hound
#

For readability, it obviously makes it more clear if you include the Type

shadow junco
violet verge
#

my ranged enemy bullets pass through my player.

public class EnemyAIRanged : EnemyAIMelee
{
    public Enemy_Projectile projectilePrefab;
    public float ProjectileSpeed;
    public Transform projectileSpawnPoint;
    public Sprite ProjectileSprite;
    public float stopDistance;
    protected override void MoveTowardsPlayer()
    {
        float distanceToPlayer = Vector2.Distance(transform.position, playerTransform.position);
        if (distanceToPlayer > stopDistance)
        {
            transform.position = Vector2.MoveTowards(transform.position, playerTransform.position, Speed * Time.deltaTime);
        }
    }
    private bool IsPlayerInRange()
    {
        return Vector2.Distance(transform.position, playerTransform.position) <= Range;
    }
    protected override void Attack()
    {
        if (Time.time < lastAttackTime + AttackCooldown)return;
        if (IsPlayerInRange()) Shoot();
        lastAttackTime = Time.time;
    }
    private void Shoot()
    {
        Enemy_Projectile newProjectile = Instantiate(projectilePrefab, projectileSpawnPoint.position, Quaternion.identity);
        Vector3 targetPos = playerTransform.position;
        targetPos.z = 0f;
        Vector3 shootingDirection = (targetPos - transform.position).normalized;
        newProjectile.SetProperties(Damage, ProjectileSpeed, shootingDirection, ProjectileSprite);
        newProjectile.SetLayer(9);
        float projectileAngle = Mathf.Atan2(shootingDirection.y, shootingDirection.x) * Mathf.Rad2Deg;
        newProjectile.transform.rotation = Quaternion.Euler(0, 0, projectileAngle);
    }
}
frosty hound
#

Your IDE is auto completing for you, so you're not saving time by typing var instead of the type, really. If one allows for more readability, why not just use it?

shadow junco
#

I shouldnt be able to move when its pause and the pause meniu open when i press play

#

It should only open when pressing esc

vale blade
violet verge
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Enemy_Projectile : Projectile
{
    protected override void OnTriggerEnter2D(Collider2D hitInfo)
    {
        if (hitInfo.gameObject.CompareTag("Player"))
        {
            Debug.Log("Hit Player");
            IDamage damageable = hitInfo.GetComponent<IDamage>();
            if (damageable != null)
            {
                Debug.Log("Applying Damage");
                damageable.takeDamage(Damage);
            }
            else
            {
                Debug.Log("IDamage component not found on Player");
            }

            Destroy(gameObject);
        }
    }
    void Update()
    {
        Debug.Log(transform.position);
    }
}
#

ranged enemy bullets pass through player and do not damage him

vale blade
shadow junco
polar acorn
eternal falconBOT
shadow junco
loud topaz
#

works πŸ˜‰

polar acorn
eternal falconBOT
shadow junco
#

Oh i cant acces discord trough my pc rn(dont ask why) ik there is internet version

polar acorn
violet verge
#

Anybody see why my enemy projectiles pass through my player without damaging him?

shadow junco
polar acorn
shadow junco
polar acorn
violet verge
polar acorn
# violet verge

So, the bullet is a trigger, meaning it does not physically collide with anything. It's not going to stop when it hits a collider

violet verge
polar acorn
#

There's no On trigger anything in this code

violet verge
# polar acorn So, the bullet is a trigger, meaning it does not physically collide with anythin...
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Enemy_Projectile : Projectile
{
    protected override void OnTriggerEnter2D(Collider2D hitInfo)
    {
        if (hitInfo.gameObject.CompareTag("Player"))
        {
            Debug.Log("Hit Player");
            IDamage damageable = hitInfo.GetComponent<IDamage>();
            if (damageable != null)
            {
                Debug.Log("Applying Damage");
                damageable.takeDamage(Damage);
            }
            else
            {
                Debug.Log("IDamage component not found on Player");
            }

            Destroy(gameObject);
        }
    }
    void Update()
    {
        Debug.Log(transform.position);
    }
}
#

sorry that's the one i meant

shadow junco
violet verge
#

ontriggerenter2d on my projectile. And i'm basically using the same logic on my player and his bullets are working

short hazel
#

Trigger colliders do not use (as much) prediction compared to regular ones, as such projectiles can pass through without reporting if they're fast enough

polar acorn
violet verge
#

that's a debug log of the transform of the bullets next to my player inspector and they are on the same z coord

polar acorn
# violet verge

Hm, then it seems like SPR2 might be onto something, it might be moving so fast it's passing through?

violet verge
#

and test it

#

that broke my game in interesting ways lol

buoyant knot
short hazel
#

No

buoyant knot
#

then that is probably a good start. takes literally no effort to test

short hazel
#

Non-triggers collision messages are reported from the Rigidbody, that's probably not the case for triggers

buoyant knot
#

i’ve never fully understood how the message broadcasting works

violet verge
#

lol now my enemy bullets hit me, but my bullets no longer hit them. IDK what i did.

honest idol
#

Can someone help me with my animations when I my character walks it keeps glitching back and forth and then the animation will randomly stop

rare basin
#

you need to show the code for the animator

formal escarp
#

Hey guys i have a question. I have a script which allows the player to "recollect" objects when you collide with them, it makes a sound and gives you +1 score. How can i make it so it also grants you, lets say an ability? like jumping.

honest idol
shell herald
#

how do i fix this. i know why it doesnt work, but how do i get a bool value thats specified on a different script from an object?

polar acorn
#

Assuming RangedEnemy has a bool called BowShoot

north kiln
#

You never assign enemy

shell herald
north kiln
rare basin
#

also i think you got the structure wrong, shouldn't BowEnemy inherit from RangedEnemy? why are they separated classes?

honest idol
#

does this error have to do something with my code, it says i do but my code shows that it is right

rich adder
rare basin
honest idol
rich adder
#

i know its not null ref

#

but check how to read the error, you can expand the error and see where its coming from

shell herald
#

i serialize field the first one and now i get an error from a different, completely unrelated script giving me this and im turbo confused

timber tide
#

could have been there before your previous problem

wintry quarry
rich adder
wintry quarry
#

Get used to seeing NullReferenceException. It's both the most common error you will see and the easiest to diagnose / fix

shell herald
#

im just turbo lost, i accidentally assigned the player arrow to the enemy bow and the player ammo is tied to ammo count

wintry quarry
#

I assure you, you are dealing with trivial errors that are simple to fix when you look at them systematically and calmly

polar acorn
shell herald
sage mirage
#

Hey, guys! How to load my volume slider text when saving it and when loading the options scene?

#

Do i have to use OnSceneLoaded method maybe?

wintry quarry
sage mirage
#

I mean i click save button and I change my volume slider value to 0 but when I load back my menu scene and then loading again settings scene this value is 1 and not 0

#

I hear no sound and and I have programmed it correctly only the text is not updated after the scene load

wide vault
#

Top 10 most difficult concepts in unity programming: 1. Generics
2. Interface
3. Encapsulation
4. Interface
5. Delegates
6. Lambda
7. polymorphism
8. inheritance
9. Singleton
10. Struct

polar acorn
timber tide
#

if chatgpt is good for one thing it's giving me some great alternative class names

polar acorn
timber tide
#

oh u

polar acorn
#

That is unironically one of the good things to use it for

summer stump
wide vault
#

Just make what you name a bit longer

shell herald
#

right now, my script makes the enemy go between two points and be idle for a while. now i want to change it up so that the enemy always stays at the point closest to the player. i am not quite sure how to achive it. i guess compaing the difference between enemy. pos.x and the player, both points and the player and then let the enemy go to the one with the smallest difference, however idk how to approach that

https://hastebin.com/share/avomocejik.csharp

solemn fractal
#

Hey guys, I only have this IF here to check if I can spawn the boss. 100% of the time I play it.. it works.. sometimes when some friends play it, they spawn the boss at level 28..30.. 32.. and that should not happen.. how can i debugg this ? with me always works and I always spawn him at lvl 50 or 15m game. cs if (_player.playerLevel >= 50 && _canSpawnLastBO || Time.time >= 900 && _canSpawnLastBO)

short hazel
#

they spawn the boss at level 28..30.. 32..
Technically it's possible, if they've been playing for more than 900 seconds

#

Also the condition can be simplified down to if (_canSpawnLastBO && (_player.playerLevel >= 50 || Time.time >= 900))

#

Do note that if your user hangs around in the main menu for 14 minutes, then plays, then the boss will spawn after 1 minute!

autumn bane
#

Hey, I am trying to create a GUI with images however, even after i have assigned the image in the inspector, im still getting the error

short hazel
#

Ah yes, The Errorℒ️

autumn bane
short hazel
#

Ah the log!

#

I thought you were getting an exception or something

autumn bane
#

nope

#

i dont understand why im getting it πŸ˜…

short hazel
#

Are you sure you didn't attach this script to something else by accident? Tip, you can do Debug.Log("stuff", gameObject); and upon selecting the log in the console, it will highlight the object that sent it in the Hierarchy

polar acorn
short hazel
#

Good. Change the log messages so you know which of the two the code sees as not assigned

autumn bane
#

its says only image 1 but i have assigned it

short hazel
#

Now post the one that's attached to an object in the scene - as the message suggests, these will only be applied in Edit Mode

vast salmon
#

yooooo

#

basically i installed a 2d dating sim so that i can rebel against the greedy devs and hack it for unlimited diamonds but its all encrypted

#

plz helpe

short hazel
#
  1. That's not encrypted, that's binary.
  2. Cracking is not something we discuss about here
vast salmon
#

but its fun

short hazel
#

Go have fun somewhere else, this is not the place

vast salmon
#

fine, ig when i decide to make my own game ill come back

real falcon
#

I have a character controller that gets moved with a velocity value every tick but for some reason it likes to stick on ceilings

#


        

        // Hit Ceiling
        if (hit.normal.y < 0f) {
            playerVelocity.y = -1f;
            Debug.Log("Hit Ciel " + hit.normal);
            return;
        }```
#

like it works if I'm not moving horizontally it seems but if I have a tiny bit of horizontal movement you like stick to the ceiling and float down slowly for a second before unsticking and falling at normal speed

polar acorn
autumn bane
short hazel
#

Even when you enter Play Mode while still in the editor

tribal minnow
#

hey guys, is there anyway to make a vector3 or a quaternion using floats or doubles ?

polar acorn
tribal minnow
real falcon
polar acorn
real falcon
#

yes im intending to skip the rest of the code if it hits the cieling

tribal minnow
real falcon
#

actually I thikn I fixed it because I think I know what's happening

polar acorn
real falcon
#

the character controller isn't perfect and it collides multiple times when you hit the ceiling while moving

solemn fractal
real falcon
#

and the vent is asynchronous probably

#

so I think it's setting the velocity to -1 more than once, which means it falls slowly, and it collides multiple times because it must be like intersecting the wall or something idk

#

but regardless making it so it sets it to the minimum of playervel.y and -1 works

#

im assuming it's because the collider somehow is touching the ceiling, then moves down a bit, and then touches the ceiling again

#

or that collision event can be called multiple times between each update

short hazel
# solemn fractal no they were playing for 5minutes level 28 and that happened..

Can't verify that myself. Does it display the time somewhere as they play it?
If not, what you can do is make a "debug text" with a UI TextMeshPro text, and display all three values of _canSpawnLastSO, playerLevel, and Time.time, as well as the result of the if statement.

Then build and ship your game to your friend, and have them note the values when the boss spawns

solemn fractal
solemn fractal
fathom ether
#

I'm kinda lost. Whats the proper way to reference a Handler class creating and destroying objects? Do i create a empty gameobject, add the script,- and lookup the gameobject + attached script every time i need something executed in the handler?

#

I'm trying to execute the functions from different classes attached to gameobjects

valid pulsar
#

redoing some code to allow for remaping keys and im trying to use the input system to run a function with an input when a key is pressed and i cant figure out how to do it i wrote some code that i think should work but it dosent. its giving me Delegate 'Action<InputAction.CallbackContext>' does not take 0 arguments

polar acorn
short hazel
#

The delegate Action<InputAction.CallbackContext> will only accept methods or functions that have the following signature:

void Method(InputAction.CallbackContext);

Or in other words, a method or function that returns void and takes one argument of type InputAction.CallbackContext

#

The lambda function you've given here takes no argument! It's not compatible.

maiden current
#

Guys silly question, I have an NPC with a capsule collider 2d only and a sprite in a custom layer, I created a raycast for my player that is in the same layer. It debugs the gameobject hitted but its not hitting on my npc. Any idea?

maiden current
#

dont tell me that is because its inside the player

rich adder
maiden current
rich adder
solemn fractal
#

any ideas?

short hazel
#

Debug text will help

maiden current
rich adder
solemn fractal
tawny cave
#

hello, how do you get the direction of an object and turn it into a vector ?
(I'd like to make it move with charactherController.Move() function)

rich adder
rare basin
#

just transform.forward

meager gust
rich adder
#

you can just do (currentpost-lastpos).normalized also

tawny cave
#

thanks for the answers πŸ™‚

rich adder
#

depending on ur sprites direction the equivalent would be transform.right or transform.up

tawny cave
#

I am using 3D objects not sprites so transform.forward does actually work ^^

vernal bronze
#

hello I need some help with this script for my class project. The class is for Audio and I know literally nothing about coding nor do I want to know but I wanted something simple to make my lights flicker in the project and just found something online. Someone was helping me last night and said I just need to add a Class to fix my error but I forgot to mention I have 0 experience and need to be babied through the whole process so unfortunately I've made no progress and I feel very stupid having to ask the same question again. here is the script and error:

north kiln
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)

north kiln
#

Then, you need to re-create your script, because you've removed the fundamental body of the class, and it would be easier to just recreate it

solemn fractal
# short hazel Debug text will help

Now I remembered I have the level, the time already in the screen all the time.. and its always correct. and there shows I am on lvl 38 for instance, 10m int o the game and the boss appears.. the only one I dont have yet is the bool

vernal bronze
#

maybe it's more trouble than it's worth

short hazel
short hazel
summer stump
vernal bronze
rare basin
#

no one will do the project for you

#

you could already learn unity very basics instad of asking 2 days the same question

solemn fractal
vernal bronze
rare basin
#

no you dont

summer stump
short hazel
solemn fractal
# short hazel Show the code that updates all that UI
    public void UpdateLevel(){

        levelText.text = "Level: <color=yellow>" + _player.playerLevel + "</color>";
        levelUpScreen.SetActive(true);
        RandomSkills();
        _player.canShoot = false;
        fillEXP.fillAmount = _player.playerExperience  / _player.playerExpNextLevel;
        Time.timeScale = 0;

    }``` Here when I level up is one method I use to update it.  for the time it is this one:  ```cs
    private void UpdateUITimer(){

        int minutes = Mathf.FloorToInt(currentTime / 60);
        int seconds = Mathf.FloorToInt(currentTime % 60);
        countdownText.text = string.Format("{0:00}:{1:00}", minutes, seconds);

    }```
short hazel
#

Time scale set to zero, intentional?

solemn fractal
#

yes, when I level up appears in the screen some stuff to choose, so I stop the time to give time to the player to choose

#

when player chose it time is 1 again

short hazel
#

I see

#

What's the value of currentTime and how do you update it?

solemn fractal
#

in update method: cs currentTime += Time.deltaTime;

#

this is inside my UIManager that is an object that is always on the hierarchy since start

short hazel
#

You might want to use that everywhere instead of using Time.time as a quick reference. These might differ with time scale, but as long as you don't spend 3 minutes between each level it should be alright to keep as is
I don't see any issues, can you post the code that triggers the boss spawn?

#

The whole class

solemn fractal
#

yes sure, thank you for your time. I can try to maybe try something. Thinking now. I normally get to level 47 sometimes 50 when is close or at 15m.. so I can remove the time check as its the same as I am already almost 50 close to 15m.. and if the bug stops. that was the thing..

solemn fractal
short hazel
#

In a paste website then

#

!code

eternal falconBOT
vernal bronze
#

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

maiden current
#

How can my object hitted by raycast know it? I want to launch a function every time a raycast hits him or leaves him

polar acorn
maiden current
polar acorn
maiden current
polar acorn
maiden current
#

thanks both!!

maiden current
polar acorn
maiden current
polar acorn
maiden current
#

oh I see

polar acorn
#

you call it whenever it goes from hitting this thing to hitting something else

maiden current
#

thanks digiholic

#

Also, I remember you helping me for dozens of times literally like 2 years ago

#

Thanks for everything

#

master

true heart
#

im spawning 2 prefabs using this script and then trying to make the button prefab a child of the first prefab but when i run the code they both spawn in but the button is not a child of the item

#

im not sure whats wrogn with my code

polar acorn
true heart
#

oh bruh

#

i might be blind mb

#

i read over it too i swear i just didnt see that

south current
#

How do I access a bool variable saved to a script which is attached to a game object, from another game object using GetComponent?
I tried this:

{
    public GameObject ObjectWithScript;

...

if(ObjectWithScript.GetComponent<MyScript>(boolVariable))
        {
            //Code
        }```
polar acorn
south current
#

Can GetComponent be used not just on GameObjects?

ivory bobcat
#

Get component doesn't take an argument btw

#
..<MyScript>().boolVariable```
polar acorn
ivory bobcat
#

But preferably what digi said

polar acorn
#

just make your variable the type you actually want

#

and then get your bool from that

south current
polar acorn
#

It's whatever you called it

ivory bobcat
#

iecs public MyScript myScript;//Exposed to the inspector ... if(myScript.boolVariable) ...

#

The object you drag in from the inspector will need to have the appropriate component script attached to it.

#

And it should be something from the hierarchy-scene unless you're really wanting to evaluate/modify prefabs.

south current
ivory bobcat
#

It's whatever you've named the script (yes, the class)

#

Referred to as the type

south current
#

does that mean I have to use the same class for the script I wanna access too?

polar acorn
ivory bobcat
#

Each component on an object in the scene refers to an instance of the script.

#

The script that you originally wrote can be thought of as a template or blueprint for many other objects to own their own instance of.

#

You should not be creating multiple identical scripts with different names

ivory bobcat
south current
#

alright, thank you very much!

ivory bobcat
#

Reference the most useful component to avoid having to call excessive get-component calls.

timber tide
ivory bobcat
#

Every component would have the gameObject and transform properties, so you shouldn't be referencing those unless the reference solely only uses either of the two components only.

south current
#

Thanks for the tips and help πŸ™

vernal bronze
#

holy fuck I've done it. After configuring I tried a few things that didn't work, tried one last time before giving up, simplest solution worked ahhhhhhh thank you to all those that helped me I appreciate it so very much

polar acorn
#

What is a GameObeject

north kiln
#

Configure your !ide so you can't make basic spelling errors

eternal falconBOT
polar acorn
#

It's a step by step guide

north kiln
#

If you're finding it difficult, ask a question

static cedar
#

Oh wait.

polar acorn
#

Consider it the tutorial boss. It's significantly harder to try to code blind than it is to follow some steps to configure an IDE

#

It is, quite frankly, pointless to attempt to code without it

summer stump
#

I don't understand what part of that could possibly be confusing at all

north kiln
#

Well good thing we don't need to speculate, if someone's confused they can elaborate and get an answer

slender nymph
#

they refused to elaborate when they were having trouble with it yesterday so i doubt they will today

north kiln
#

well, if it continues it'll be a mute, so feel free to @ me if it's still unconfigured next time

static cedar
#

One thing I really hate with step by step guides is that it points to something in the UI and I have no idea where it is.

summer stump
violet verge
#

I have a function that pauses my game by changing Time.timeScale = 0, then is suppsed to open my pause menu. but my pause menu wont open if the game is paused.


    public void WinGame()
    {
        StartCoroutine(HandleWin());
    }

    public void LoseGame()
    {
        StartCoroutine(HandleLoss());
    }

    IEnumerator HandleWin()
    {
        //PauseGame();
        WinPanel.SetActive(true);
        yield return new WaitForSeconds(2);
        WinPanel.SetActive(false);
        OpenPauseMenu();
    }
    IEnumerator HandleLoss()
    {
        //PauseGame();
        LosePanel.SetActive(true);
        yield return new WaitForSeconds(2); // Wait for 2 seconds
        LosePanel.SetActive(false);
        OpenPauseMenu();
    }
    private void PauseGame()
    {
        Time.timeScale = 0; // Pauses the game
    }
    private void OpenPauseMenu()
    {
        PauseMenu.SetActive(true);
    }```
polar acorn
violet verge
#

the pause games are commented out that's how i know everything is working as it should if i dont pause the game

#

ohhhh, should i do waitforrealseconds?

timber tide
#

I think you'd want to use unscaled time I believe

polar acorn
#

The real solution is "don't use timescale to pause" but that works for this specific problem

timber tide
#

maybe that

violet verge
#

Yeah that's what i did that worked.

#

thank you!

teal viper
#

Visual studio is the ide, so that question doesn't make much senseπŸ€”

#

You don't have to. VS 2019 should work.

round sentinel
#

why doesnt it work

summer stump
#

!code

eternal falconBOT
round sentinel
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Init : MonoBehaviour
{
    // Start is called before the first frame update
    async void Start()
    {
        await UnityServices.InitializedAsync();

        if (UnityServies.State == ServicesInitializationState.Initialized)
        {
            await AuthenticationService.Instance.SignInAnonymouslyAsync();

            if (AuthenticationService.Instance.IsSignedIn)
            {
                string username = PlayerPrefs.GetString(key:"Username");
                if (username == "")
                {
                    username = "Player";
                    PlayerPrefs.SetString("Username", username);
                }

                SceneManager.LoadSceneAsync("MainMenu");
            }
        }

        
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}
strong path
round sentinel
#

i dont understand

teal viper
#

If you don't know what namespaces and packages are, you might need to go back to learning the basics.

round sentinel
#

everything, i dont code. i just followed a tutorial on yt

#

im a game artist

polar acorn
teal viper
#

Try looking for an up to date tutorial. Assuming that the tutorial is outdated.

#

Otherwise hire a programmer or learn it yourself.

slender nymph
#

do you see errors underlined in your code now?

polar acorn
#

Do you see errors underlined in your code now?

slender nymph
#

wdym it "went black"? your high contrast setting is doing that

#

and it was like that in your screenshots yesterday

teal viper
#

The VS window is super tiny, so it's hard to say, but it seems like it's not configured.

somber herald
#

what am i looking at

#

who hurt-

shell herald
#

i have a background picture i want to move with the cameras x achsis, but stay in y,z .
i wrote a simple script which has

public Camera cam;

as a parameter and in the void update sections its

gameObject.transform.position = new Vector3 (cam.transform.position.x, gameObject.trans.pos.y, gameObject.trans.pos.z);

and the background image is following the camera, but its not exactly on the same position on the same frame and its also very jittery.

what would be the proper way to do that?

slender nymph
shell herald
#

aight, thx

#

weird, even with constraints its very jittery

slender nymph
#

have you removed the other component you had controlling its position? and are you certain it isn't actually the camera's movement that is jittery?

shell herald
#

yes, the script is removed and the cam is buttersmooth, however i am using cinemachine and pixelperfect camera which might be the cause of this

mystic oxide
#

can someone help me why it's didn't show the content of the string...?

#

also this error, (i'm using 2d mobile project)

summer stump
mystic oxide
#

yes its worked, thanks

summer stump
# mystic oxide yes its worked, thanks

The inspector "wins" over the initializer in code if it is ever changed. If you want to make sure that doesn't happen, you can assign the value in Awake or Start.

left glacier
#
public class ParticleTray : ScriptableObject
{
    
    public struct PTEntry
    {
        public string Name;
        public Particle Particle;
        public PTEntry(string name, Particle particle)
        {
            Name = name; Particle = particle;
        }
    }
    public List<PTEntry> particles = new();
}```
how do i make this list display in the inspector?
gaunt ice
#

serialize the struct
system.serializable

left glacier
mystic oxide
#

i disabled/temporary makes it as comment but the button still direct me to scene 1, it's doesn't show where the error was when i didn't input anything, it's preventing me to load into another scene last night....

near knot
#

can i ask something bout VScode??

#

whats happening?? :<<

slender nymph
near knot
#

Fixed it:>

mystic oxide
formal escarp
#

hey guys

#

making a simple pistol is complicated?

frosty hound
#

No? Is that a question or a statement

formal escarp
viral hemlock
#

is there a class or method i can use to get two random numbers?

frosty hound
frosty hound
viral hemlock
#

ok

clear seal
#

i need help for this script

frosty hound
#

None of this code makes sense

clear seal
#

i dont get it

frosty hound
#

You need to start by configuring your !ide for error detection

eternal falconBOT
clear seal
#

oh

frosty hound
#

Then following that, you need to do !learn to actually learn the basics of coding and Unity.

eternal falconBOT
#

:teacher: Unity Learn β†—

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

unreal imp
#

So guys, tell me what would be the best solution to make a functional crouching system that allows you to crouch but if you have an object above you that is less than the player's height, will the player continue crouching until he has air of the same height? (I already asked this but now I'm paying attention to them) https://gdl.space/ivujivuvuj.cs

clear seal
frosty hound
unreal imp
#

No, I just asked at the wrong time

clear seal
# eternal falcon

i have already installed visual studio why would i have to install it again?

clear seal
#

how do you know i didnt installed it?

formal escarp
frosty hound
#

I don't, I'm answering your question about not having to reinstall it.

clear seal
#

oh ok i musunderstood it srry

eternal needle
#

That is visual studio code, and your ide isnt pointing out the very clear errors that exist. Which it should be

eternal needle
formal escarp
#

If you add what you were suggested to, your visual studio should look like this. (The botom part will tell you if your code has errors)

clear seal
#

but it doesn't

frosty hound
#

Hence !ide

eternal falconBOT
formal escarp
#

It is pretty useful.

#

It makes you save lots of time.

frosty hound
#

Also mandatory for question here

clear seal
#

i will test it but not for long cuz it'S like 10pm rn

amber spruce
#

so i set this up for a combo system so it would do the first attack animation then if you click again the next and so on but if i click before the animation finishes it just skips it how do i add it so it waits till the previous animation is done to let you continue
https://pastebin.com/nRAM5wnW

formal escarp
#

Hey guys i have a question. I have this script which destroys any gameobject which touches. I was thinking how could i add a CompareTag? Also. I have a script for picking up and dropping stuff. But even when this is dropped it shoots when i click, and i dont have any clue on how to unable that unless i pick it up.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Gun : MonoBehaviour
{
    public Transform BulletSpawnPoint;
    public GameObject Bullet;
    public float BulletSpeed = 5;
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            var bullet = Instantiate(Bullet, BulletSpawnPoint.position, BulletSpawnPoint.rotation);
            bullet.GetComponent<Rigidbody>().velocity = BulletSpawnPoint.forward * BulletSpeed;
        }
    }
}
#

(This is my script for the gun)

slender nymph
#

disable its Gun component when you drop it and enable it when you pick it up

formal escarp
#

i am not sure how to do that, but i just had an idea to avoid that problem.

proper flume
#

So, I'm trying to write a dash script following a tutorial, but it looks like me and the tutorial guy used a different way to flip our sprites. I tried calling //currentScale from my Flip() method but I get the error CS0103. I tried making the //currentScale.x public and private, but it breaks my script. Is there another way to do this? https://gdl.space/yopopiyadi.cs

slender nymph
#

if you want your currentScale variable to be accessible to other objects you need to declare it in the class as public. Right now it is declared inside of a method which makes it a local variable so it cannot be public.

proper flume
#

So if I just remove it from that method and place it at the start as a float then I can call it in another method?

slender nymph
#

well you'll still want to assign to it in that method, but otherwise yes. as long as it is declared in the class it can be used throughout the entire class. and if you make it public it can be accessed by other objects

proper flume
#

Well, I'm trying to call on it's transform properties in my Flip() method, basically trying to write the dash so that it see's my currentScale.x at that exact moment, so it can tell which way to dash.

slender nymph
#

realistically you don't need to use the currentScale variable for that, just access its transform.localScale

proper flume
#

So I guess I'm still confused. If I assigned it to a float, say as private Vector3 currentScale = gameObject.transform.localScale; as long as the remainder of my Flip() method remains the same, would calling it in my Coroutine still allow it to see those changes?

slender nymph
#

also it isn't a float. you literally have the correct data type on the line you originally declare it on

proper flume
#

Oh whoops. That's not what I meant. Just assigning it as a Vector3 var, would that still work?

#

Oh nevermind, I see what you meant.

proper flume
#

So, now I have the dash working, and I moved on to a double jump which I want to operate the same ( only being able to double jump when it's unlocked outside of the script) and I adjusted my code as correctly as I could with his code based off of what I had ( he didn't have a jump buffer or coyotetime on his script) but nothing happens. I don't get an error, my jump isn't broken, but my character also isn't double jumping whether the bool for the unlock is true or false. Where did I go wrong? https://gdl.space/lovareluqi.cs

cosmic dagger
daring crane
#

Anyone with no experience and looking to learn together to create a game with unity

proper flume
eternal falconBOT
slender nymph
proper flume
cosmic dagger
slender nymph
cosmic dagger
#

That's subjective; it could be either. It depends on the person making it and the complexity . . .

proper flume
slender nymph
#

what have you done to ensure that your variables are in the state you expect them to be? have you printed any useful logs or set any breakpoints?

cosmic dagger
polar acorn
#

Depends. Have you configured your IDE yet

proper flume
cosmic dagger
#

You can follow tutorials. There are videos and step-by-step guides . . .

proper flume
#

the coyote time and variable jump are still functioning too.

proper flume
slender nymph
#

you can still log useful info. don't forget you can create strings that are more than just useless statements like "here"

cosmic dagger
cosmic dagger
proper flume
#

Oh okay lol. Lemme code it up and see what happens.

cosmic dagger
#

You don't store the number of jumps?

proper flume
#

No.. Am I supposed to? I haven't seen anything about that when it comes to making a PlayerController

cosmic dagger
proper flume
#

I dunno, that's never really fit my needs. It's just a Hollow Knight clone demo. Keeping track of the number or jumps or especially limiting the amount of jumps would seriously hinder my platform game with jumping in it lol. Also, I'm having a hard time trying to find out how to make a counter.

cosmic dagger
#

When you shoot from a gun, you decrease the amount of available bullets in the magazine. When there are none, the firearm is empty, and you can no longer fire (until you reload). It's the same concept . . .

#

I don't understand how tracking the number of jumps would hinder the game. You're just storing a value . . .

proper flume
#

I had misread what you said. I thought you were saying that I needed to have a finite value for how many times a player can jump.

#

Running that, allows it to pass through the scripts and the jump counter goes up while normal jumping as expected, but with doubleJumpIsUnlocked set to true, there's no double jump, and it doesn't count a second jump midair.

cosmic dagger
proper flume
#

So if my jump counter is going up, and I can jump but not double jump, does that mean maybe that the conditions for the double jump are being met actively all the time? I'm confused lol.

cosmic dagger
#

You're logic (and its order) seem to be the issue . . .

proper flume
#

Is it maybe because I called isGrounded twice technically? On line 167 I call coyoteTimeCounter which is an if statement of isGrounded, then I call isGrounded on the second if statement on 168.

cosmic dagger
#

You only need to check the jump buffer and coyote time when grounded. They don't matter when airborne . . .

#

Also, it doesn't make sense to call Jump every frame. It's an action that requires input. It should execute when jump is pressed . . .

proper flume
#

Yeah, but because Jump() calls on jumpInput, trying to put it in FixedUpdate() results in missed inputs.

cosmic dagger
#

I didn't say anything about FixedUpdate; Jump doesn't call jumpInput. Not sure what that means . . .

#

Basically, check for jump input. If it occurs, call the Jump method . . .

fierce shuttle
slender nymph
#

your !IDE is unconfigured

eternal falconBOT
flint wind
#

Hey, how would have my dust particle play if speed is above 0.1 but stop when speed is at 0

slender nymph
slender nymph
teal viper
#

Share screenshots showing the unity workload installed and the correct ide selected in the unity external code editor setting.

flint wind
slender nymph
#

how would that work? if speed is set to 6 then speed >= 0 would be true

slender nymph
#

the unity workload is something you were supposed to install when going through the configuration guide

teal viper
#

If you don't understand, you probably didn't go through the config guide. These things are mentioned in it.

#

Then either you looked at the wrong guide or wasn't paying attention.

slender nymph
#

it's literally the first set of steps in the guide

teal viper
#

Here's a quote mentioning it

Select the Workloads tab, then select the Game development with Unity workload
#

Why would you ask the yelling people about it?πŸ˜…

#

Also, configuring the ide is a direct answer to your question.

cosmic dagger
#

i don't see anyone yelling, and configuring your IDE is not dumb, its paramount to programming with Unity and C# . . .

slender nymph
#

ah yes "some dumb thing"
aka the tool you use to write code. that's certainly not important at all, especially since it definitely doesn't do useful things like help you fix errors and even provide autocomplete /s

teal viper
#

You asked:

why arent my line numbers showing

The answer to which is: you don't have the ide configured properly.

slender nymph
#

then you don't want to make games πŸ€·β€β™‚οΈ

teal viper
#

You only need 10 min of concentration.

#

Damn, life was harder than we expected.😬

flint wind
slender nymph
#

which part?

flint wind
slender nymph
#

those are two different options that would achieve the same thing. which one would you like to do?

slender nymph
#

alternatively you could just grab the magnitude of your moveDir vector. since it is normalized it will either be 1 or 0

#

or rather your direction vector, in fact you are already checking its magnitude. throw the Play in there and just stick an else on it to call Stop

slender nymph
#

i would only call Play if it isn't already playing, but yes.

flint wind
slender nymph
#

surely you know how to type else

timber sundial
#

Hello! I was wondering why my VS code is not code hitting? I have some stuff I am using from other packages and everything compiles but nothing is code hitting/stuff like I cannot right click and go to definition

slender nymph
#

make sure it is configured πŸ‘‡ !ide

eternal falconBOT
flint wind
slender nymph
#

just use else

timber sundial
slender nymph
# flint wind well I meant in the parenthesis after if

you do not need an else if there because if direction.magnitude is not greater than or equal to 0.01 then it is going to be 0 because direction is normalized so it's magnitude is going to be either 0 or 1 with no in between

timber sundial
flint wind
slender nymph
#

it's likely that you need to prewarm your particle system or some setting you have set wrong on it

shrewd gazelle
#

Do you have any suggestions for that

slender nymph
#

don't ping people into your questions

shrewd gazelle
#

Excuse me Im new

#

The reason I did that is because you seemed knowledgable

#

But Ill meep that in mind

slender nymph
#

you also didn't say what the problem actually is

shrewd gazelle
#

so its just I wanted recommendation to how to do a script that makes the player hit the object and then whenever the player dies they respond from it

slender nymph
#

there are plenty of tutorials for setting up respawn points/checkpoints

summer stump
eternal needle
shrewd gazelle
#

Ok so i want to make a game object that has the ability to save the game whenever its hit I hope what I said isn’t confusing

slender nymph
#

what is a "saver"

shrewd gazelle
#

Save spot

slender nymph
#

be specific that can mean many things

shrewd gazelle
#

A collider in which whenever it get touched the game gets saved and the player respawns from there

slender nymph
#

well have you got a system to save the game yet?

shrewd gazelle
#

No thats what I need help with

slender nymph
#

have you bothered googling how to set up a save system in unity? because there are plenty of tutorials for that

fierce shuttle
#

Tbf, there are many ways data can be saved, and some tutorials may use BinaryFormatter to save, which is no longer a safe way of saving, any other type of saving tutorial may be useful though

flint wind
slender nymph
#

well i don't know a whole lot about setting up particle systems, but i'm sure the folks who hang out in #βœ¨β”ƒvfx-and-particles do πŸ€·β€β™‚οΈ

flint wind
#

I rlly appreciate it

proper flume
#

Okay, I'm confused. I'm getting a CS0414 warning for 36,18 but I referenced isWallSliding in my WallSlide() method. Why isn't Unity seeing that? https://gdl.space/utusijexap.cs

eternal needle
proper flume
#

It is, I'll post a screenshot.

eternal needle
#

well it is unused basically, you are never actually doing anything with the value

proper flume
eternal needle
#

it is private, no methods or properties return it as a value, you dont use it to check anything, you could remove it and your code would function the exact same

proper flume
#

Removing private and just leaving it as void WallSlide() returns the same error. :/

eternal needle
#

your WallSlide() method is used

proper flume
#

What about line 150?

eternal needle
# proper flume What about line 150?

Yes you are setting it to false, but what affect does that have in your program? What line of code checks the value of isWallSliding and does something based on it

proper flume
#

Well that part hasn't been written yet. But at this point in the tutorial I'm following he's still able to go back into the editor to assign values to public Transform wallCheck;
and public LayerMask wallLayer; and it's not updating those fields for me because it's returning this error. Is he just on an older build or something that lets him bypass that?

eternal needle
#

the warning is not a problem

proper flume
#

Ah okay, that makes sense. I had some spelling issues that needed fixed, now it's updating. I appreciate the help.

neon ivy
#

how do you check if something is on your screen? UnityChanThink I saw OnVisible but that's not entirely it

#

I need to be able to check from an empty game object aswell

rare basin
#

OnBecameVisible for renderers, but for empty game objects you would need your own function the check if its on screen or not

#
    void CheckIfOnScreen()
    {
        Vector3 screenPoint = mainCamera.WorldToViewportPoint(transform.position);

        bool onScreen = screenPoint.x > 0 && screenPoint.x < 1 && screenPoint.y > 0 && screenPoint.y < 1 && screenPoint.z > 0;

        if (onScreen)
        {
            Debug.Log("Object is on screen!");
        }
        else
        {
            Debug.Log("Object is off screen!");
        }
    }

sth like that

neon ivy
#

ah that makes sense

#

thanks

maiden current
#

I have an NPC which I explicitly assigned this gameObject. Is there a way from my GameObject to know who owns him without explicitely putting the npc in its public variables?

frosty hound
#

You can create some Initialize function on your GameObject that gets called and you pass in the NPC to store as a reference

split dragon
#

Hi. How can I use an object by its name in a script?

static cedar
#

hit.collider.gameObject pretty sure.

split dragon
static cedar
#

Don't u have intellisense suggesting it to you? UnityChanThink
if not, it's probably not configured properly.

verbal dome
#

Yeah, with intellisense it takes extra effort to type it wrong

static cedar
#

!configure

#

Ok wrong lol.

verbal dome
#

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

verbal dome
#

(Thats vs right?)

static cedar
#

I think so.

#

VSC would colour the crap out of everything in cyan.

nimble scaffold
#

How to make a system that when the user points mouse to a certain gameobject then there will be a text pop-up on the screen

broken timber
nimble scaffold
#

You guys are better than internet

static cedar
static cedar
split dragon
#

What am I writing wrong?

teal viper
static cedar
#

Real. UnityChanThink

split dragon
teal viper
#

Damn, I though the question was"what am I doing wrong".

teal viper
languid spire
split dragon
static cedar
teal viper
split dragon
languid spire
#

then do that

static cedar
#

When you get hit by stuff like this, you gotta know what you're recieving, using, and the types.

split dragon
#

English is difficult for me, that's why I suffer

teal viper
#

There are plenty of learning resources for most languages.

static cedar
#

Aye.

languid spire
#

pretty sure C# documentation is in Russian as well

teal viper
#

I know for sure there are resources for your language.

split dragon
#

Programming itself is difficult for me

static cedar
teal viper
languid spire
# split dragon Thanks πŸ™‚
static cedar
#

Isn't there any Russian youtubers or something?

#

Cause damn, starting out with docs can be a pain.

teal viper
#

There are plenty

languid spire
static cedar
split dragon
teal viper
#

That's because you didn't learn it..?

static cedar
#

Woah, any tutorial should be telling you what something does no?
Unless it's like the first parts where you only really focus on variables and making Console.WriteLine();

split dragon
teal viper
static cedar
#

Plenty of people seem to think that learning unity and c# are different. They are, but unity literally use C# and it's what you code in.
If you did find some C# tutorials, try to learn as much as you can before you go to unity again.

fierce shuttle
# split dragon I thought it worked differently with names (I tried it: "", (), <>, etc.

It does work differently, those symbols have different meanings depending on where they are used, if C# confuses you I would suggest maybe going through the C# courses on w3schools, most of them are interactable on their site, they also break down the language into various subjects, which may help as keywords when searching up what things do, or if you prefer, you could find a "beginner C#" playlist on YouTube and follow along their (likely Console) examples on various topics like functions, properties, classes, etc

static cedar
#

"" - string notations.
<> - generic parameters.
() - argument parameters.
Docs wouldn't say this out loud i think, except for the brackets where youtubers, for some reason, explain functions as calling through a telephone or something. UnityChanLOL

#

Anyways, you're kinda just expected to understand what these are after a while. UnityChanPanicWork

fierce shuttle
#

Seeing them in context helps as well over time, for example SomeFunc() is different from if(condition), they both use the same symbols but mean different things to the compiler

static cedar
#

Yeah () is used really often. But they're always used as parameters, always.

#

Even more so with {}, I could call them as code blocks but can do more than that such as in pattern matching.

bold nova
#

Hi, people. In game manager in Update method i have a whle(gameIsOn) loop where i update score. By deafult it is set to false. I have a method StartSession(), where i change gameIsOn to true. By some reason editor just freezes on that while loop. Can someone explain why?

tough lagoon
slender nymph
#

you realistically just need an if statement not a while loop

bold nova
#

i initialized it with false

static cedar
#

There's not a lot of ways to freeze.

tough lagoon
#

A while statement will keep executing what is inside until untrue. It won't allow rendering or anything else. while is dangerous and will lock your game

slender nymph
bold nova
#

ooooh, got it

#

thanks

slender nymph
#

also Update is called every frame. so just swap your loop for an if statement since it's something you want to happen per frame rather than all in one frame

bold nova
#

the code should work as a timed score, when every 3 sec it adds up 3 * multiplier, so i think it sould all be completed in one frame

#

looks like this

#

if (timer > 3)
{
if (score > 120)
scoreMultiplier = 2f;
score += (int)(3 * scoreMultiplier);
scoreText.text = "Score: " + score;
timer = 0;
}

#

timer = Time.deltaTime

slender nymph
#

yes so you do not want a loop for that. just the if statement

#

also you do not want that to complete all in one frame. imagine getting 3 seconds worth of points in 0.016 seconds

languid spire
slender nymph
#

oh yeah that too

bold nova
#

yeah, finally works! thanks

queen adder
#

Its literally just

float maxSeconds = 3f;
float timer += Time.deltatime;
if (timer >= maxSeconds) {
  // do your logic here
  timer = 0;
}
queen adder
#

Bc you want to add up Time.deltatime (its 0.00something, a really low number) and if your timer is always = time.deltatime, it'll never be 3

queen adder
slender nymph
#

float timer += Time.deltatime;
this is not valid

languid spire
#

because you've made timer a local variable

torn quail
#

hey im trying to make a 2d game, but iv a problem with my game cam, anyone know how to fix this?