#💻┃code-beginner

1 messages · Page 695 of 1

slender nymph
#

considering you've barely provided any context for the error at all i don't know what you are expecting here, unless you expect everyone else to start playing 20 questions to get any basic info from you

worthy tundra
slender nymph
#

it means that fmod failed to load the file. why that happens likely depends on a number of factors.

bright kiln
#

HELPPPP IM MID GAME JAM AND CANT GET THE DIALOGUE TO WORK

#

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

public class NPCSystem : MonoBehaviour
{
bool player_detection = false;

// Update is called once per frame
void Update()
{
    
    if(player_detection && Input.GetKeyDown(KeyCode.E))
    {
        print("PLEASE WORK!");
    }

}

private void OnTriggerEnter(Collider other)
{
    if(other.name == "Player")
    {
        player_detection = true;
    }
}


private void OnTriggerExit(Collider other)
{
    player_detection = false;
}

}

slender nymph
#

!code

eternal falconBOT
vocal marlin
#

I just ended up reinstalling vscode and it worked, thanks

cosmic dagger
#

Also, use a paste site or format small code blocks for easier reading . . .

worthy tundra
bright kiln
north kiln
deep minnow
#

Does Unity Juniopr programming pathway teach you on how to do a Health system, in my case I need it as a stress level sorta thing like a percentage

vocal marlin
#

is there any way for me to set the event system first selected field with code?

ivory bobcat
slender nymph
bright kiln
worthy tundra
deep minnow
bright kiln
worthy tundra
bright kiln
#

do i need to add one to the player?

ivory bobcat
#

Try putting a log in the trigger enter and exit method

vocal marlin
#

they both need to collide

bright kiln
#

just like this?

#

or check is trigger

vocal marlin
deep minnow
#

apart from the junior programming pathway

slender nymph
north kiln
# bright kiln just like this?

You almost certainly should not be using a mesh collider. Use a capsule or something.
Doesn't your player have a rigid body setup or a character controller though? Or it is all direct transform manipulation and no physics at all?

deep minnow
eager elm
slender nymph
worthy tundra
deep minnow
#

like being specifics

slender nymph
#

if you need it you can find individual tutorials on the learn site or with google

deep minnow
#

basically 2D Game Kit Advanced Topics?

bright kiln
slender nymph
# deep minnow basically 2D Game Kit Advanced Topics?

if that is a specific tutorial, then sure i guess. i don't keep a list of tutorials to hand out to people who don't want to google for them. but focus on learning the basics first so you might have a chance of actually understanding how to do things without needing to find specific tutorials

deep minnow
neon verge
#

does anyone know the best way to do a grid of tiles where i can change the tiles during runtime

slender nymph
#

tilemap?

neon verge
#

i thought u cant change them at runtime

slender nymph
#

why would you think that?

neon verge
#

i dont know

#

i saw it online

night raptor
#

Make sure to check the scripting API page for the systems in question for the latest available tools

deep minnow
#

ahh ok

#

Will do, thanks

night raptor
#

answered to bic but the api is good place to find inofrmation in general

slender nymph
sacred verge
#

Hi, in the case that somebody boots your game and their GPU doesn't support something you require, like Compute Shaders for example... what do you normally do? Should we be querying everything we need on startup and then show a message saying "GPU not supported" and quit? Currently, we're receiving exceptions about it occasionally in the cloud reporter.

deep minnow
slender nymph
#

the api documentation has the documentation for unity's api. it doesn't have tutorials for creating different systems which is what you were asking about

deep minnow
slender nymph
#

seriously, stop worrying so much about what you may or may not need to do in the future. focus on learning the basics

deep minnow
neon verge
#

how can i access the sprite of a tile in the code

#

and change it

rain dawn
#

Heya everyone. Im kinda stuck on an issue right now. I got a giant square of 16x16x16. each time a part gets broken off I want to spawn a cube that falls of the object.

But when stress testing this I quickly come into issues with frame rates.

Ive tried object pooling
particle effects instead of gameobjects
Using drawmeshinstanced

But my frame rate always tanks. Is it just a call bottleneck. Im assuming its calling code like 2k~ time per second

slender nymph
neon verge
#

i had a look but i couldnt find what i was looking for

#

maybe i was in the wrong place

slender nymph
#

also why would you want to change the sprite of a tile object and not just change what tile is there?

#

wasn't that what you wanted in the first place?

neon verge
#

i think i mean that i have the tile map and i want to change what the image is on each tile with code

slender nymph
#

change the tile at the desired position

neon verge
#

yeah

slender nymph
#

that is what i'm telling you to do instead of trying to change the sprite on the tile itself

neon verge
#

okay

deep minnow
vocal marlin
#

yesterday I had a problem where my buttons weren't working, they weren't being highlighted, or pressed or anything no matter what I did. I still have this problem and I just don't know what could have caused it because it was definitely working before I returned to this project, the only thing I changed since then was starting to implement an inventory system into my game, so I don't know how that could affect anything

deep minnow
#

is Udemy courses worth it?

#

for learning said script systems?

#

after the course ofcourse

slender nymph
#

itdepends
but you're still getting ahead of yourself. you seem to be focusing on just getting through the basics rather than actually learning and internalizing them. if you actually learn from the junior programmer pathway then you won't really need any other courses, you might look up some tutorials for specific things you haven't figured out, but for the most part you will have the tools to make things on your own already. especially the simple "systems" you've asked about so far

#

if you keep going with this mindset of looking for the next best tutorial then you're just going to trap yourself in tutorial hell instead of actually making anything

night raptor
deep minnow
deep minnow
rain dawn
night raptor
rain dawn
#

Uhh its mostly added to give a bit of visual feedback

#

you're destroying the cube for money

night raptor
#

4096 separate gameobjects especially if with separate scripts on each can easily become an bottleneck

rain dawn
#

well how it works right now

  • a shooter shoots a bullet every frame (for debugging)
  • a corotine (or whatever the spelling is) checks over a line multiple points till it hits the part of the cube
  • the cube will break calling a script to break off the part
  • the script will get get a cube from the pool give it a force and add it to a queue to be removed and send back to the pool when timer is over

now I got 9 shooters shooting each frame at a 16x16x16 cube

grand snow
#

1000 individual Update()/coroutines will be less performant than 1 that executes over many transforms/game objects

#

unity calling to execute Update/ a coroutine has a cost

rain dawn
#

uhh I dont know if im just stupid. But... the cubes aren't the bottle neck anymore... it seems just destroying the cube itself is the bottle neck...
I dont know how I missed this I legit thought I ran it multiple times to see the fps and it seemed fine

grand snow
#

not pooling them then?

rain dawn
#

Its the reconstruction of the cube that I think is causing the issues (my apolagies I though that this ran properly

#

I think im gonna have to go back to the drawing bord and limit the updates to the cube reconstruction or make it update only chunks

#

sorry for taking all of your time

vocal marlin
neon forum
#

Is there a cleaner way of telling another game object's script to do something?
For context:
I have a game manager with a script that reads inputs, and based on that input, it tells the player object to do something(If move right then character will move right).
Currently I'm doing the obj.getComponent<Script>() method, is that what I should be using?

slender nymph
#

ideally you would cache the reference to the component rather than calling GetComponent each time you need to access it, but yes. to communicate with other components you will need a reference to that component such as by calling GetComponent or a serialized field with the component assigned to that field

neon forum
#

so I could create a serialized field of a component of a game obj?

#

Would it just be script?

#

how would I cache a reference?

#

I remembered how to call the script of the obj, so that solves that problem, but how would I cache things/

slender nymph
#

that's just storing the reference in a variable for reuse

neon forum
#

oh

#

so just [SerializeField] class myClass; and that's caching?

slender nymph
#

that's one way to store a reference to an object, yes

neon forum
#

are there better ways of doing it for future proofing/readability?

slender nymph
#

a serialized field is the best way to refer to another object

neon forum
#

alright, thanks

vocal marlin
#

idk why I'm having so many coding problems today but can someone help me understand why my room transition code is happeneing exactly 5 times every single time no matter what?

{
    public Vector3 cameraMinChange;
    public Vector3 cameraMaxChange;
    public Vector3 playerChange;
    public PlayerMovement player;
    private CameraMovement cam;

    void Start()
    {
        player = GameObject.FindWithTag("Player").GetComponent<PlayerMovement>();
        cam = Camera.main.GetComponent<CameraMovement>();
    }

    void OnTriggerEnter2D(Collider2D other)
    {
        if(other.tag == "Player")
        {
            RoomMove(other);
        }
    }

    public void RoomMove(Collider2D other)
    {
        cam.minPosition += cameraMinChange;
        cam.maxPosition += cameraMaxChange;
        other.transform.position += playerChange;
    }
}
slender nymph
vocal marlin
dusky bobcat
#

Packages/com.vrchat.avatars/Editor/VRCSDK/SDK3A/VRCSdkControlPanelAvatarBuilder.cs:2998)
VRC.SDK3A.Editor.VRCSdkControlPanelAvatarBuilder.OnBuildAndPublishAction () (at ./Packages/com.vrchat.avatars/Editor/VRCSDK/SDK3A/VRCSdkControlPanelAvatarBuilder.cs:2021)
System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) (at <27124aa0e30a41659b903b822b959bc7>:0)
UnityEngine.UnitySynchronizationContext+WorkRequest.Invoke () (at <cb81df0c49c643b1a04d9fc6ccca2433>:0)
UnityEngine.UnitySynchronizationContext.Exec () (at <cb81df0c49c643b1a04d9fc6ccca2433>:0)
UnityEngine.UnitySynchronizationContext.ExecuteTasks () (at <cb81df0c49c643b1a04d9fc6ccca2433>:0)

#

can someone tell me how to fix this?

slender nymph
#

looks like a !vrchat specific issue to me

eternal falconBOT
dusky bobcat
#

i just thought since im usibng unity to upload an avatar then id need help with unity specifically

slender nymph
#

issues with the vr chat sdk and the like belong in the vr chat server

dusky bobcat
#

i appreciate the direction to the right server

whole smelt
#

Hey guys, let me know if there's a better place to ask, new to unity but not to coding. I am creating copies of a prefab but the script doesn't appear to be applying to the copies, only to the original (which is under the copies, there's a green one in there just covered)

vocal marlin
#

toggleInventory.action.started += ToggleInventory; I'm really confused as to how this line could throw a NullReferenceException because the InputActionReference field I have is definitely filled in the inspector.

eager elm
#

Debug.Log("Is toggleInventory null? " + (toggleInventory == null), this.gameObject);

queen adder
#

can someone maybe help me with this Transparency problem

queen adder
#

sorry

polar briar
#

im learning and im making a grid for my tactics system and it wont spawn the walls around it and i think i know the problem (the walls aren't linked in the tile script) but IDK how to fix it cause it wont let me just drag the game objects to the script for some dumb reason

#

trying to drag walls on left to spots on right but it just wont let me

vocal marlin
polar briar
#

okay so thats not the probnlem them cause its attached and linked within the object

#

then why isnt my grid manager spawning the walls 😭

vocal marlin
vocal marlin
polar briar
#

i can copy and paste it in a second

#

public class GridManager : MonoBehaviour
{
    public int width = 5;
    public int height = 5;
    public GameObject tilePrefab;

    private Tile[,] grid;

    void Start()
    {
        GenerateGrid();
    }

    void GenerateGrid()
    {
        grid = new Tile[width, height];

        for (int x = 0; x < width; x++)
        {
            for (int z = 0; z < height; z++)
            {
                Vector3 position = new Vector3(x, 0, z);
                GameObject tileObject = Instantiate(tilePrefab, position, Quaternion.identity);
                tileObject.name = $"Tile_{x}_{z}";
                tileObject.transform.parent = this.transform;

                Tile tile = tileObject.GetComponent<Tile>();
                tile.gridPosition = new Vector2Int(x, z);
                grid[x, z] = tile;
            }
        }

        // Example wall between (2,2) and (2,3)
        AddWall(2, 2, "north");

        // Add outer walls
        for (int x = 0; x < width; x++)
        {
            AddWall(x, height - 1, "north"); // Top edge
            AddWall(x, 0, "south");          // Bottom edge
        }

        for (int z = 0; z < height; z++)
        {
            AddWall(0, z, "west");          // Left edge
            AddWall(width - 1, z, "east");  // Right edge
        }
    }

    void AddWall(int x, int z, string direction)
    {
        Tile tile = grid[x, z];
        tile.SetWall(direction, true);

        Vector2Int neighbor = GetNeighbor(x, z, direction);
        if (IsInBounds(neighbor))
        {
            Tile neighborTile = grid[neighbor.x, neighbor.y];
            neighborTile.SetWall(Opposite(direction), true);
        }
    }

    Vector2Int GetNeighbor(int x, int z, string direction)
    {
        switch (direction)
        {
            case "north": return new Vector2Int(x, z + 1);
            case "south": return new Vector2Int(x, z - 1);
            case "east":  return new Vector2Int(x + 1, z);
            case "west":  return new Vector2Int(x - 1, z);
            default: return new Vector2Int(x, z);
        }
    }

    string Opposite(string dir)
    {
        switch (dir)
        {
            case "north": return "south";
            case "south": return "north";
            case "east":  return "west";
            case "west":  return "east";
            default: return "";
        }
    }

    bool IsInBounds(Vector2Int pos)
    {
        return pos.x >= 0 && pos.x < width && pos.y >= 0 && pos.y < height;
    }
}
#

this is prolly rly bad code but it works up until the part where walls get involved

#

i think i got over zellous

naive pawn
polar briar
#

No write

#

Erie is

#

errors omg. I’m adding debug rn

naive pawn
#

oh what you didn't mention cinemachine before

queen adder
#

My bad

rare topaz
#

Is there a way to spawn prefabs onto a terrain like tree and grass with brush but all the component attach (like collider, script, etc) are still attach ?

rich ice
mortal spade
#

inside a function, if i put return; inside a for loop does it terminate the for loop or the function???

cosmic dagger
#

test it to see if it continues the loop or not . . .

brave robin
mortal spade
#

ty both ^^ i wanted to exit the function and wasnt sure if it was on a like, nested basis

brave robin
woeful scaffold
#

does any1 know why the text that is on this contact point doesnt show up ?

#
if (collision.gameObject.GetComponent<IDamageable>() != null)
{
    // Get damagable object and damage by the inherited weapon's damage
    damageable = collision.gameObject.GetComponent<IDamageable>();
    damageable.TakeDamage(bulletDamage);

    // Display a damage amount text on the collision area
    contactPoint = collision.GetContact(0);

    // Initiate bullet damage text onto contact point
    damageText.text = bulletDamage.ToString();
    bulletTextObject = Instantiate(damageText, contactPoint.point, Quaternion.identity, gameObject.transform.parent.transform);
    bulletTextObject.gameObject.SetActive(true);
}```
#

I'm sure its something easy i'm just missing it

#

I'm using textmeshpro

cosmic dagger
#

Is it 2d or 3d text?

woeful scaffold
#

oh..

#

LOL

#

thank you i think

cosmic dagger
#

Also, you're setting the text before you instantiate it . . .

#

Which means you're setting (changing) the prefab text . . .

woeful scaffold
#

oops i mean to do bulletTextObject thanks for noticing

#

meant.*

#
            bulletTextObject = Instantiate(damageText, contactPoint.point, Quaternion.identity, gameObject.transform.parent.transform);
            bulletTextObject.text = bulletDamage.ToString();
            bulletTextObject.gameObject.SetActive(true);```
#

that should do it

slender cypress
#

Hi! I'm trying to look online but i'm not finding anything useful, maybe I'm just bad at researching but welp

Is there a way to pause a method and wait until a key is pressed before continuing said method? if yes, how?

#

pliz ping me if anyone answers

grand snow
#

coroutines

eternal needle
slender cypress
#

How would it work?

Mymethod(){
StartCoroutine(coroutine())
Debug.Log("thing")
}

coroutine(){
wait until input
}

#

it will Debug.Log("thing") when the input is pressed?

eternal needle
slender cypress
#

ok!

eternal needle
#

Your MyMethod would not be affected in anyway and would complete immediately after calling StartCoroutine

slender cypress
#

Ohhh ok

sharp solar
#

holy siht im dyslexic

#

i cant read

#

namespaces are just folders for your code right

silk night
#

yeah, kind of

sharp solar
#

excellent

woeful scaffold
#

Does any1 know how to make a 3d text keep looking at you?

#

textmeshpro to be exact

woeful scaffold
#

I see ill check it out

vague sequoia
#

My character slides downhill when climbing a slope. How can I prevent this? (I already have a script that calculates the slope angle.)

little spoke
#

i have questions about vuforia , anyone here si good at it ?

worthy tundra
#

HELP:

when building the game error: "cannot create FMOD"

i have never used external FMOD

it works on previous builds

idk what made it happen

rough granite
worthy tundra
#

it gives this error to pretty much every sfx in the game

rough granite
#

well sending a photo of the actual error would help

worthy tundra
rough granite
#

which you must be using

worthy tundra
#

i didnt use any FMOD other than what is native to unity

rough granite
worthy tundra
rough granite
#

does it?

worthy tundra
#

failed to replicate

rough granite
#

so whats the problem then?

worthy tundra
#

i tried to replicate in the editor

#

works fine there

#

im gonna try to fuck with the import settings, setting it to preload

rough granite
#

again what error cause "cannot create FMOD" cannot be it

worthy tundra
#

*turning off preload

worthy tundra
rough granite
worthy tundra
#

wait a sec im testing something

sudden edge
#

anyone know if its possible to render a certain layer (layer 8 in this example) above another model even if its inside it so its always in front, by using a shader or script or something

rich adder
sudden edge
#

im using birp

rich adder
#

I believe you can just mess with the z-buffer depth

hollow steppe
#

does anyone know how to fix this??? it used to be in 3d but i clicked a button now its in 2d please help 😭

rich adder
rich adder
hollow steppe
#

shit

#

wrong server

grand snow
#

wrong server AND wrong channel smh

sudden edge
#

but i found i fix thankfully thanks for your help though

west obsidian
#

If I'm making a controller that is going to be snapped to the nearest surface every frame, how should I move the player? Should I use teleportation, velocity, physics, or something else? What do people generally use when moving a normal controller without charactercontroller.move

bright kiln
#

i just submitted a game for a game jam but it crashes on webgl as soon as you click play, any ideas?

#

heres the link if anyone wants to test for me

rich ice
#

this is the code channel.

eager elm
#

is it bad practice to remove all listeners from the invokers' side rather than unsubscribing from the listeners' side?

  • Normal C# event
naive pawn
#

how would the subscribers know to resubscribe on reenable?

#

im not sure about it being outright bad practice, but it definitely limits your options

#

imo just having both the subscribe and cleanup is easier to make sure it doesn't leak, but if you follow this pattern everywhere i guess that's not a problem

eager elm
#

They shouldn't. It's just in case the object gets disabled early for whatever reason.

naive pawn
#

i feel like that's more of an OnDestroy thing then

#

also, do your subscribers never get disabled/destroyed?

#

if they don't unsubscribe themselves then you'd be calling stale callbacks

eternal needle
pallid olive
#

Cause im pulling up and out of nowhere it just pushes down hard like the last part or theres the first turn when i get out of the first turn and go straight it just dips down until i recover

teal viper
#

In any case, there's not much we can tell you without knowing how your plane controller works.

polar briar
#

im trying to make walls fade in and out depending if they block a tile in my tile map but they arent fading. i have been trouble shooting for like an hour and got nothing. (i can send the code but its a giant ass wall)

teal viper
eternal falconBOT
teal viper
pallid olive
polar briar
pallid olive
#

it only sends it as a txt file...

teal viper
polar briar
#

i have a ray that checks if its in the way of seeing a tile, if it is it changes it to transparant, if its not then it resets it to oqaue (or its supposed to)

teal viper
polar briar
steel slate
#

I wish unity would use BASIC, yes BASIC like in DarkBASICpro or AppGameKitStudio. Am tired of these cryptic lenguages.

teal viper
polar briar
#

its sending opaque messages but no transparant ones so im like wtf why is it not changing

#

and ive been tweaking things for like an hour and its changing nothing

pallid olive
teal viper
pallid olive
#

yeah idk how to do this sorry im new

polar briar
teal viper
eternal falconBOT
teal viper
polar briar
#

llike when i hit play?

pallid olive
#

i think thats how you do it

polar briar
#

okay so i checked

#

it is changed type from opaque to transparant but its still visible.

#

it looks like its changing internally but not visably... like its unsynced almost

teal viper
teal viper
polar briar
#

lmao enjoy a bad video from my phone recording my screen

teal viper
pallid olive
teal viper
polar briar
#

i just found the win11 feature lol

#

this may just be a misunderstanding on how shaders work

#

cause it looks like it should work

teal viper
teal viper
# polar briar

This should be working.
Can you pause the game when it's supposed to be transparent, switch to scene mode and make sure the correct object is selected(click it in the scene view)?
It would also help if you have gizmos enabled in the game tab.

polar briar
#

sure

mild lake
#

I want to make a path in a top down 2d game that's randomly generated, but i don't want to use a tile set. Does anyone have any recommendations for a method?

polar briar
#

it crashed...

#

fuck. me.

#

time to redo a bunch of shit...

#

im going to actual do that tommorow and go to bed and have a mini breakdown

polar briar
teal viper
polar briar
#

set to 78

teal viper
polar briar
#

yes

#

its wierd 😭

teal viper
polar briar
#

everything is checked so i assume its enabled

#

what should it change visually

teal viper
polar briar
#

It looks kinda the exact same lmao

teal viper
polar briar
#

i clicked it 😭

teal viper
#

But also, it seems like that wall is transparent

polar briar
#

thats the one i changed manually

teal viper
#

Okay.

polar briar
#

the ones next to it are the exact same but just not done manually

#

all the blues are 78

#

think its on now

#

its light gray at least

teal viper
# polar briar

Yeah. But I don't see any gizmos. Which might imply that this is not the selected object.

teal viper
polar briar
#

^ thats what it feels like

#

idk man. i feel like this isnt that complicated. everything says its working besides what its actually doing

#

its like watching someone do a math problem perfectly and forget to circle the awnser

rough granite
teal viper
#

testing in .47f URP now. And it doesn't seem to work. Throws a warning in the console too.

rough granite
#

hmm odd

polar briar
#

😭

#

i just wanted to make cool walls

rough granite
#

whats the problem?

teal viper
polar briar
#

my shawty code

rough granite
#

you could've just used one of the websites !code

eternal falconBOT
polar briar
mortal spade
#

why does yloop never change??? the debug output says yloop is always 0

                    int yloop = 0;
                    int xloop = 0;

                    for (int i = 0; i < (item.sizeWidth * item.sizeHeight); i++)
                    {
                        // print("xloop is " + xloop);
                        print("yloop is " + yloop);
TilePositions celp = cellFromPos(posx + xloop, posy + yloop).GetComponent<TilePositions>();
                        celp.occupiedBy = item.gameObject.name;
                        celp.occupied = true;
                        xloop++;
                        if (xloop == item.sizeWidth--)
                        {
                            xloop = 0;
                            yloop++;
                        }
                    }
spare basin
teal viper
teal viper
spare basin
#

ok hold up

spare basin
teal viper
spare basin
#

can I send in the scipt?

mortal spade
teal viper
mortal spade
teal viper
#

Print all the relevant values in the same log to avoid confusion.

mortal spade
#

great point actually

rough granite
#

just use a
Debug.Log($"xloop = {xloop}, item.sizeWidth-- = {item.sizeWidth--}");

teal viper
#

No, don't include the decrement in the log, as that would alter the logic.

teal viper
#

Yes. You'd decrement sizeWidth one extra time.

#

Or wait a moment. I think I had a brain fart... Let me check somethign real quick.

mortal spade
#

example of what im talking about

mortal spade
#
print("sizewidth is " + item.sizeWidth + ", xloop is " + xloop);
                        if (xloop == item.sizeWidth--)
                        {
                            yloop++;
                            xloop = 0;
                            
                        }
rough granite
#

print?

teal viper
mortal spade
#

print is the same thing as debug.log as far as im aware(?)

rough granite
mortal spade
#

ye

#

either way: the if statement SHOULD be fulfilled there because 2-1 = 1

#

but its not

rough granite
teal viper
#

Also, add a log inside the if block

rough granite
mortal spade
#

THATSA THING???

#

im going to tweak if this is the solution

teal viper
#

Yes. Honestly, I'd avoid using syntax that you don't 100% know how it works.

#

Or research it.

mortal spade
#

makes sense

#

it changed the result but its still not working (as intended)

rough granite
teal viper
#

Do logs. Including inside the if block

#

And yeah, share the updated code.

mortal spade
#

discord's thing is messed up hold on

teal viper
#

Add a log/pring inside the if block

mortal spade
#

alright

teal viper
#

And share the logs where you think the condition should be true

rough granite
# mortal spade

should the item.sizeWidth be reduced by one if the if statement is true? cause it is

mortal spade
#

item.sizeWidth should not change in any case

teal viper
#

Well, it does now

rough granite
#

ok so item.sizeWidth - 1

#

example of what happens

teal viper
#

Again, don't use syntax sugar that you don't entirely comprehend

rough granite
#

and how to fix it

mortal spade
polar briar
#

i got the walls to work decenetly enough for a proof of concept (still very bugged but it should be fine. it doesnt need to be perfect it needs to be fun)

mortal spade
#

the result is ALMOST there so i think i can get the rest on my own, thank you very much

polar briar
#

if u move the camera around u can fix it easily so ima call it there and go to sleep. thx for all the help i owe u all

teal viper
rough granite
teal viper
polar briar
#

i plan on actually hiring a coder if i get good enough feedback on the beta (i doubt i will but maybe)

polar briar
#

The raytracing is being weird so I tried to make it set all connecting walls of the same orientation to also be the transparent material and that works decently enough

#

I’d say 75% of the time it doesn’t bug a little but wiggling the camera resets it

#

so it’s finnnnee

wheat oar
#

guys i beg and I plead. I'm incredibly new to coding and have been trying for 10 god forsaken hours to make a UI image literally fade in, pause, then fade out upon the game starting up. I have found absolutely 0 tutorials for this online, I have scoured the deep recesses of planet earth and I CAN'T find a way to do what seemed oh, so simple to my baby naive mind. my life is yours is you can help me

teal viper
wheat oar
#

i've already watched that video. to my dismay it teaches you how to fade when activated by a button and not automatically

#

its all activated by triggers and I don't know how to do it without

rough granite
teal viper
wheat oar
teal viper
eternal falconBOT
#

:teacher: Unity Learn ↗

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

wheat oar
#

sadly don't have the time, I'm on a time crunch and therefore am forcing myself to rawdog a lot of the subjects, it was going well until I faced the dreaded fading

#

thanks for the advice though

sour fulcrum
#

You'd be suprised

teal viper
#

I don't know what hurry you're in, but it's probably not a good justification for not learning properly

sour fulcrum
rough granite
eternal needle
wheat oar
#

i get that lads and to be completely clear my current methods of learning are a temporary measure. I'm well aware I'll get more out of it by learning from basics in the long run, only problem is my current run is incredibly short, and thus requires shortcuts to complete

#

once im out of a pressurised environment, I'll return to a more structured form of learning

eternal needle
#

it doesnt matter that your timeline is short. You have a tutorial that shows you what you need to do, and you arent using it

sour fulcrum
#

Forsure, And theres no judgement for that but the kind of help your asking for isn't really the kind of help that gets provided here

rough granite
wheat oar
#

apologies lads, wasn't really sure where else to go, also thanks a bunch magic

sour fulcrum
wheat oar
#

also i'm learning blender aside unity which isn't helping with my immense plate right now

eternal needle
rough granite
#

oh wait nvm im blind

#

oh well

#

im sure they can figure it out im about to go to bed as it's ~1:30am

frigid sequoia
#

Ouh, I didn't know that scrollbar on the list could appear. I kinda hate it, thank you, can I just tell it to not do that? lol

acoustic belfry
#

What differences actually have crossFade vs crossFadeInFixedTime

i know is that one changes Animator's states using times in seconds, but my problem is, what specific things may occur with one and the other

frigid sequoia
#

I may venture to say crossFase is based on frames on FixedTime uses the timeline instead?

woeful scaffold
#

Hey guys I need some help, I'm trying to make the 3D TextMeshPro text look at the player, and it's not working, im not sure why.

{
    // Set world object to look at
    damageTextConstraintSource.sourceTransform = Camera.main.transform;
    damageTextConstraint.AddSource(damageTextConstraintSource);

    // Enable component/s
    damageTextConstraint.enabled = true;
    damageText.enabled = true;
    damageText.gameObject.SetActive(true);

    Debug.Log("Enabled constraint.");
}```
#

For the record: I nullify the Text's parents so it's parentless for now

north kiln
woeful scaffold
#

oh, i thought that was the source number

#

lmaooo

#

The text is indeed looking at me just in a weird mirrored/inverted/rotated angle

#

@north kiln you got an idea on how to fix it?

#

I tried declaring:

damageTextObject.transform.localEulerAngles = new Vector3(0, 180f, 0);```
#

Fixed the upside down issue by unchecking "Use Up Object" but it's still inverted now, i'll try rotating it wiht a vector

north kiln
#

The world up object seems to work via the vector towards the object, not it's up

#

there's a rotation offset in the constraint settings, just use that

atomic prairie
#

can i ask what the main difference is between the old and new unity input system?

north kiln
#

The new one is properly configurable and rebindable at runtime in a reasonable way
the old one isn't, it supports everything via strings, and is pretty terrible to work with outside of basic use cases

woeful scaffold
#

I'm a beginner, should I try to learn and implement the new input system?

rough granite
north kiln
#

You can still write code very close to the old system without it being constrained by strings and other crap

woeful scaffold
#

any ideas on how to make the text be viewed regardless ?

swift elbow
woeful scaffold
#

on my main camera itself?

swift elbow
#

an overlay camera is a different camera

woeful scaffold
#

I added a camera as a child to my main camera, and put it on render type overlay

#

Where can i choose a layer?

#

volume mask?

swift elbow
#

where it says culling mask

woeful scaffold
#

oh

mental glen
#

Hey, good morning/afternoon!
I’m having a bit of trouble getting my assets to fit properly on my grid in Unity. Would anyone be able to help me out with this? I’d really appreciate it.

woeful scaffold
#

should it be inside a canvas? its a 3d textmeshpro

swift elbow
woeful scaffold
#

turns out i needed a canvas

#

which does require it to have a parent canvas

swift elbow
#

World space text doesn't need a canvas

#

Now I assume you want general UI which does need a canvas

woeful scaffold
#

ok then im just stupid

swift elbow
#

Do you want your text to be like a main menu?

#

Or do you want it to be an object in your 3d world?

woeful scaffold
#

No i jsut want the text to be displayed and not clipped by the cube itself

swift elbow
#

Then pick a type

woeful scaffold
#

a 3d text that is displayed on where the bullet hit, damage text

#

everything is working other than the text clipping with the cube itself

#

i made an overlay camera but for some reason it doesnt render the text..

swift elbow
#

So yes, you will need to use an overlay camera like I said before

#

Show you text prefab and show your overlay camera inspector

woeful scaffold
#

👍 1 sec

#

the overlay camera is the child of the main camera

swift elbow
#

Make sure that your camera excludes the UI layer from its culling mask

woeful scaffold
#

i did, ill check it real quick

woeful scaffold
#

that is my main camera culling mask

#

this is my overlay camera culling mask

#

for some reason the overlay camera doesnt seem to render

#

completely my bad

#

stuck was empty

#

XDFDD

swift elbow
#

happens to the best of us

frigid sequoia
#

Is this like.... intended? Why can I not rename this particular asset but I can all the rest?

#

Is this unity being weird or do I have something toggled that I didn't even notice?

olive lintel
#

hey guys, just a general question here, if I'm making a custom map editor for my game would it make sense to save the map data using json? the map data would consist of a couple of single channel 2d textures for the terrain, and some stuff for road nodes, building positions etc.

#

would it be a bad idea to use json considering the terrain textures might have a resolution exceeding 1000x1000? or is it fine

sour fulcrum
#

Are you implying you want to store the texture itself in the json?

olive lintel
#

but yea

#

a heightmap

sour fulcrum
#

Why not store that as an image 😄

olive lintel
#

plus eventually I want people to be able to load custom maps when they join someone elses game

sour fulcrum
#

i don't think handling a whole texture via json serialization is a good idea no

eternal needle
olive lintel
eternal needle
olive lintel
eternal needle
olive lintel
#

like if its just a 2d array of floats

eternal needle
#

Nothing is necessary. You could ask them to manually type in all 1 million floats for your 1000x1000 array.
Some things dont make sense to do regardless

#

When your users ask why they cant edit the texture in image editing software, you can gladly explain to them you opted to avoid an image so you could write 1 million floats to a json file

olive lintel
#

so if I use JsonUtility.FromJson it will still give me my map data?

eternal needle
#

Youre already loading the json file

sour fulcrum
#

you could just zip the multiple files

olive lintel
sour fulcrum
#

then its "1" file 😄

olive lintel
eternal needle
#

So you save 2 lines of code not loading an image, so you can spend a lot more time trying to process a bunch of floats as an image

olive lintel
#

the terrain sets the height of vertices in a mesh using a 2d float array

eternal needle
eternal needle
# olive lintel just a height map

Writing it and reading it as json might still be slow, but you could setup a test case pretty easily and see roughly how long it takes on your pc.
For loading the entire map, you could usually get away with a small delay of loading time with a loading screen on top

olive lintel
#

I think I'll try storing the data as integers and see if that's a lot faster

eternal needle
#

Realistically I would test a few of those 2d arrays at once, using whatever you consider the upperbound to be. Then test it with writing as an image and see if there's a difference. The profiler can easily show you if there's a difference

eternal needle
olive lintel
olive lintel
sour fulcrum
#

at the end of the day just seems weird to not store an image as an image tbh

olive lintel
#

also for a foliage cutoff map using booleans wouldn't be faster in json format right?

sour fulcrum
#

just kinda seems like if that would be better people would be doing that aha 😅

olive lintel
#

it looks like CS 1.6

sour fulcrum
#

sure but that's not really relevant to my point

#

image file types are probably just going to be better at storing images than string file types

#

if the difference matters profile sure but then the question just comes down to do you prefer doing it the worse way in order to cram an image into a json file

olive lintel
#

but ig I could convert it to a texture

charred spoke
#

Storing anything non human readable in json is a terrible idea. Just use your own simple binary format

woeful scaffold
#

does any1 have a way of coding a text animation Y to go up slowly

#

i cant use the animation tab becuase the text Y is dynamic and i want it to just go up from its own Y and not from 0

silk night
#

so you can animate the texts y in relation to the parent with the animation tab

woeful scaffold
#

and then i can use animation on it

#

ahhhhhhhhhhhhhhh

#

sidia ure the best

modest sorrel
#

hello everyone
i am new in unity .can anyone help me .i want to make a game like chagchal .
i add a ss of game. please please help me
and goat move will be an ai how to made this algorithm.

eternal falconBOT
#

:teacher: Unity Learn ↗

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

slender cypress
#

hi!

public IEnumerator PlayerDone(){
        bool flag=false;
        if(Input.GetKeyDown(KeyCode.Space)){
            flag=true;
        }
        yield return new WaitUntil(flag==true);
        MobTurn0();
    }```
Is this coroutine working as intended?
Will it WaitUntil the space key is pressed to execute the MobTurn0() method?
timber comet
slender nymph
timber comet
#

Also this

slender cypress
#

lol aight

acoustic belfry
#

hi, i have a question, this checks the player's distance from the enemy on all 2D-Sides, or only horizontally?

i mean, what if the player were in the same position horizontally but not vertically, and if is too close it changes state, it will still trigger it despite not being on the same height??

    protected void DistanciaObjetivo()
    {
        distancia = objetivo.position.x - transform.position.x;
        distanciaAbsoluta = Mathf.Abs(distancia);
    }```
cosmic dagger
acoustic belfry
#

how i can make it check the x and y axis at the same time

#

holup i think i know how

#
            new Vector2(objetivo.position.x, objetivo.position.y),
            new Vector2(transform.position.x, transform.position.y)
        );```
#

like this?

thorn kiln
#

I'm doing the junior programmer pathway on the unity site and one of the challenges is to get a planes propeller to spin, which I can do no problem, I just can't get it to spin fast. I mean, I can, just not when using deltaTime, but I know I should use that. Anyone know what I'm doing wrong?

using UnityEngine;

public class PropellerSpin : MonoBehaviour
{
    public float spinSpeed = 300f;

    // Update is called once per frame
    void Update()
    {
        transform.Rotate(Vector3.forward, spinSpeed * Time.deltaTime);
    }
}```
rich adder
#

Using deltaTime is correct

thorn kiln
#

Okay, I see. I was changing the speed in the script but I guess that doesn't update it in the inspector, which was why even setting it to 10000 didn't make a difference

#

I thought changing the script would also set the public variable when I went back into unity and it starts compiling

rich adder
thorn kiln
#

Okay, that's useful to know

#

Something I wanna understand because it's not really clear, sometimes you'll get this code with a comma after the Vector, sometimes with a mathmatical symbol. What is the actual difference?
transform.Rotate(Vector3.forward, spinSpeed * Time.deltaTime);
transform.Rotate(Vector3.forward * spinSpeed * Time.deltaTime);

#

The tutorial kinda flips around with if it wants to use a comma or not

slender nymph
#

those are using two different overloads of the same method, which you can see in the documentation. the first is using public void Rotate(Vector3 axis, float angle); which specifies the axis to rotate around, and the rotation to apply. the second is using public void Rotate(Vector3 eulers); which is just the rotation for every axis to apply

#

mathematically it is the exact same thing

glad fjord
#

Hey there, does anyone know how I could use GetKeyDown to make it so a combination of keys triggers some action (a sound), please?
Is there a way to store multiple "GetKeyDown" into a group, and then tell Unity that when this group is activated, it triggers the sound?

slender nymph
#

you wouldn't want to use GetKeyDown for that, GetKeyDown is only true for the very first frame that a key is pressed and it's unlikely that multiple keys will be pressed all exactly within the same frame.
you would either want to just check if all of the relevant keys are currently pressed at the same time, or when one of the keys is pressed start listening for the others but only within a short amount of time to ensure that it is pressed as a "combination" and not accidentally triggered by holding one key down and then several seconds later happening to press the others.
alternatively, i think the input system might have some better ways to handle key combos instead of doing things manually with the input manager (which is what the Input class is part of)

ocean loom
#
public void OnCollisionEnter2D(Collision2D collision)
{
    
    Destroy(gameObject);

    CanPortal = true;
}
#

how can i make this collision, only work after another class

slender nymph
#

what does it mean to "only work after another class"

ocean loom
#

sorry, i phrased that wrong. Basically, im shooting a bullet, and after that bullet collides with the object. I want to place a portal there. However, the adding the portal method is in another class.

silk night
#

Is the class any class or is that on the object you just hit?

slender nymph
#

so call that method on that other class in this collision message

rich adder
#

make a reference to the object you want to call method from

glad fjord
rare topaz
#

Why is it doing that with my compute shader ?

#

Density.compute inside Density

ocean loom
slender nymph
ocean loom
slender nymph
#

you're not even checking the right instance for that bool either, you're checking on the prefab but only changing it on the instantiated objects. so it's even more useless than i thought it was

slender nymph
silk night
slender nymph
#

it doesn't sound like a sequence but rather just a combo like ctrl+c

ocean loom
silk night
slender nymph
#

that was in response to me saying they cannot realistically expect to have any combination of keys pressed all at exactly the same frame because they were talking about using GetKeyDown

slender nymph
silk night
#

Ah alright, yeah if its a keycombo input system will be your best friend

glad fjord
#

like A then R then Y then O

ocean loom
glad fjord
#

I'll get to learning then, thanks

#

by the way, is Visual Scripting good for a beginner? because I feel like there really aren't that many visual scripting tutorials on a specific matter, whereas there is much content when it comes to C#

silk night
rich adder
silk night
glad fjord
#

alright, thanks

jovial bobcat
#

Guys I need help with trying to make a cutscene when the player picks up an item

silk night
jovial bobcat
#

no like how do I do it

#

because idk how too

jovial bobcat
rich adder
#

otherwise Code + Animator to do basically the same thing

jovial bobcat
#

im confused tho like how do I get the animation to play whenever you pick up the item

silk night
jovial bobcat
#

??? wydm subtask

silk night
#

There is no feature in Unity to just play a cutscene (unless you want to play a video)

#

You have to do several things to make a "cutscene" happen

jovial bobcat
#

what bruh thats dumb I cant play a cutscene when I pickup a item

silk night
#

Animate the camera, maybe remove UI, disable Player controls, enable post effects

rich adder
jovial bobcat
#

But I have a plan for it so that a door breaks down and you can enter but if the video cutscene cant do that tho for the real game

rich adder
jovial bobcat
#

I read it before tho

rich adder
jovial bobcat
#

I need a cutscene

#

for the game

rich adder
#

so make one lol

jovial bobcat
#

but I want it to start when it picks up the item

rich adder
#

so then use c# code to start the timeline

jovial bobcat
#

I dont wanna use timeline because I dont know how too

jovial bobcat
#

this is being useless

rich adder
#

sounds like you want all the benefit of a result without putting any actual work

#

if thats the case why are you in gamedev ?

silk night
waxen glacier
#

So I made an InputAction called jumpPlayer and set it to this with the key binding being space :

jumpPlayer = playerInput.actions.FindAction("Jump");

If I press space it returns a value of 1 and I use that to jump :

jumpDirection = new Vector3(0, jumpPlayer.ReadValue<float>(), 0);
rb.AddForce(jumpDirection * jumpForce, ForceMode.Impulse);

the problem is that the value stays at 1 while the key is held down, making it so my character keeps jumping as long as the key is held down. How can I make it so it only returns a value of 1 the moment I press and then goes back to 0 until I press again ?
I can post the entire movement script if you want to see it more in detail.

jovial bobcat
#

well look like I aint making a game

rich adder
#

regardless, anything you do in life requires some level of effort and learning . Otherwise pay someone to do it for you

waxen glacier
#

even with jump being set to press only it still repeats the action as long as the key is held down, can anyone help with that ?

waxen glacier
#

It's my first time using this new Input system so i'm still strugglign with it

#

I just want to make it so it registers this action only once per press and doesnt keep registering it while the button is still held down

rich adder
silk night
#

And check if the Action type is the one for started pressing

waxen glacier
silk night
#

Not sure what the name for it was rn

waxen glacier
rich adder
#
    private void MyMethodWhenJumpPressed(InputAction.CallbackContext context)
    {
        Jump();
    }```
#

obviously you want to change the name

#

its also good practice to unsubscribe events
OnDisable() / OnDestroy()
jump.performed -= MyMethodWhenJumpPressed;

waxen glacier
#

is there a way I can paste the entire script here without it taking the entire screen ?

rich adder
eternal falconBOT
rich adder
#

look where you call FindAction() literally underneath it , subscribe to its event performed after that you assign a method to it, in my example MyMethodWhenJumpPressed

#

you need InputAction.CallbackContext context in the paremeters because the method expects it

nova kite
#

Hey! I’m trying to make a 2D aiming system in a 3D space where the gun would point in the direction for the mouse, kinda like “getting over it”, how could I do that?

#

I tried using ray casting so that it would follow the mouse position but it doesn’t seem to behave the way I want it to

rich adder
#

dont see how raycast would help here

nova kite
#

What could I use instead?

rich adder
#

camera.main.ScreenToWorldPoint

#

if you're using Perspective camera though you would be better off using a Plane

nova kite
#

I tried that as well, it doesn’t behave correctly🥲

rich adder
nova kite
#

I’m not sure😅

#

I’ll look up what that means

rich adder
#

why did you put the method in FixedUpdate, nowhere in my spoon fed code did I put tat there

#

also why didnt you use the links in code bot msg.. dont use screenshots for code

#

not even sure whats going on here jumpDirection = new Vector3(0, jumpPlayer.ReadValue<float>(), 0);

#

you don't need that at all

nova kite
waxen glacier
rich adder
waxen glacier
#

it works for jumping but i still have the problem with the character continuously jumping if the button is held down

nova kite
#

Do I attach the script to the gun? Because what I did is creating a pivot point and made the gun its child

#

And the script went on the pivot

rich adder
nova kite
#

I see, I’ll try that thank you🙂

rich adder
eternal falconBOT
rich adder
#

ops wrong thing

rich adder
waxen glacier
#

That's the code before writing anything you said

rich adder
#

send the updated code with the changes I told you to make

#

and save them

rich adder
#

save , hold Jump key in the game, how many times does the log print

#

make sure collapse is unchecked in Consoel window

waxen glacier
#

what value do i put in the log ?

rich adder
#

doesn't matter in this case

#

anything will do Debug.Log("Jump Pressed")

waxen glacier
#

Shouldn't I put MyMethodWhenJumpPressed(); in update or fixedupdate ? because i'm not getting anything from the log rn

rich adder
#

no, the whole point of events is not to "poll" (continuously checking)

waxen glacier
#

nvm it gives me an error

rich adder
waxen glacier
# rich adder whats the error

There is no argument given that corresponds to the required parameter 'context' of 'PlayerMovement.MyMethodWhenJumpPressed(InputAction.CallbackContext)'

rich adder
rough granite
#

how does this work?
jumpPlayer.performed += MyMethodWhenJumpPressed;

rich adder
rich adder
#

because it is "subscribed" to that event

rough granite
rich adder
#

once you subscribe to it, it will keep subscribed until you tell it not to

rough granite
rich adder
#

like Subscribing to a youtube channel, you only do it once, not every time you want to watch a video from that channel

rough granite
#

yeah i get what you mean

rich adder
#

OnEnable happens once like Start (assuming you dont make it gameObject.SetActive = false/true)

waxen glacier
#

line 81

rich adder
#

jesus christ

#

why did you put that method in fixedupdate

#

I told you earlier you don't need that there

#

also sending the code to me different than something else you made :🤦‍♂️

waxen glacier
rich adder
#

the error happened because you put that there in fixedupdate where nowhere did I ever say to put that there

waxen glacier
rich adder
#

the error is telling you you're trying to call MyMethodWhenJumpPressed() without the required context and thats not something you should be putting manually, unity fills that in from the event

waxen glacier
#

not even logging

rich adder
waxen glacier
rich adder
waxen glacier
#

couldnt figure out a way to solve that too

#

but my movement still worked fine when i was having it so i ignored it

rich adder
#

it errors because you do FindAction in Start which is AFTER you run the subscribing to event so it has no idea which InputAction jumpPlayer is
thats why I said to put += AFTER you called FindAction.

rough granite
rich adder
#

so either put FindAction("Jump") in Awake or put the FindAction in OnEnable before doing jumpPlayer.performed

#

you might need a course on basic c# / unity

#

learning how references work

waxen glacier
#

I put all of it in start and it works now

#

void Start()
{
rb = GetComponent<Rigidbody>();
playerInput = GetComponent<PlayerInput>();

 movePlayer = playerInput.actions.FindAction("Move");
 moveCamera = playerInput.actions.FindAction("Look");
 jumpPlayer = playerInput.actions.FindAction("Jump");

 jumpPlayer.performed += MyMethodWhenJumpPressed;

 playerMovement = playerInput.actions.FindActionMap("Movement");

 Cursor.lockState = CursorLockMode.Locked;
 Cursor.visible = false;

}
private void OnEnable()
{

 playerMovement.Enable();

}
private void OnDisable()
{
playerMovement.Disable();
}

#

now the jumping works only when i press

#

it's weird tho that it logs the action twice, once on press and once on release

eternal falconBOT
waxen glacier
#

but the actual movement still works fine

waxen glacier
rich adder
waxen glacier
#

@rich adder Thanks a lot man, i'll keep trying to read about what you just showed me cuz i still dont fully understand, but atleast now the movements works

waxen glacier
#

and yes I am still very new to C# and unity

rich adder
#

are you sure its the LOG being also printed on release too

waxen glacier
#

so I removed it from action and kept it only in the binding

#

no it only logs on press

#

Do you think I should go learn C# more in depth before even attempting to use Unity or is it fine if I just kinda learn along the way ?

rich adder
#

Unity at the end of the day uses C# API so you are still using regular c# (obv) , unity has specific methods/objects to learn that are Unity only but they are still just defined as c# objects . The only thing that changes is unity specific concepts
like GameObject, Components, etc.

#

the Unity Learn courses are good introduction to both, but there is also the Microsoft learn site where you can get more in depth learning general c# (check pins)

waxen glacier
#

Dont know if my method is the best but i feel liek it could work, so far when it comes to C# i've mainly just learned how to deal with basic variables (bool, float, arrays, etc) and how to make classes and create instances of those classes

rich adder
waxen glacier
#

i'm sure it's nearly not enought right

waxen glacier
#

why is it in wayback machine tho ?

#

did they delete the tutorials ?

rich adder
#

because the one in the pins isnt working for some reason, I think unity somehow took it down or messed up redirect , as usual....

waxen glacier
rich adder
#

they're also in a Youtube playlist on the Unity channel

wooden hill
#

this isn't working either? !learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

rich adder
#

learn site is working fine

wooden hill
#

oh ok nvm then

rich adder
wooden hill
#

guess they chopped it

rich adder
#

typical unity things ™

rich ice
rich adder
#

unity likes to quietly do shit sometimes 🤷‍♂️

waxen glacier
#

In any case thanks a lot again for the help, it was really humbling. I'll go play some battlefield now, you fellas have a nice rest of your day :D

#

@rich adder one last question, what part of C# am I supposed to research to understand what you told me to add to my script, is it subscribing and events ?

rich adder
waxen glacier
fervent wind
#

I prob shouldn't have been this lazy 💔
(Yesterday i just wasted my time by reading 5 pages of the book, i read like 23 more yet (I was lazy today too)

#

(C# beginner)

rich adder
#

<@&502884371011731486>

strong wren
#

@tepid cave not sure what this has to do with programming in Unity or Unity in general. Keep it relevant to the server.

#

@tepid cave Again, not appropriate for this channel (or server, really). You can DM me about it or send a mod mail if you believe this is important. There's an AI thread on #1157336089242112090. It's a bit odd to suddenly start getting this sort of stuff from an account with no prior interaction with the server.

nova kite
#

i cant figure out why the ray isnt pointing from the "barrel"

rich adder
nova kite
#

i mean like not facing the same direction as it

#

its comign out of it then shooting upwards

#

instead of following the path of the gun

slender nymph
rich adder
#

apparently they had camera set to ortho

nova kite
#

well the game screen wouldnt show the debug ray but here

slender nymph
#

turn gizmos on in game view

rich adder
nova kite
#

still wouldnt;-;

#

oh nvm the game has to be started, it shows

slender nymph
#

and is the end of the ray at your mouse position?

nova kite
#

ohhhh i see

#

the local "right" value is facing the same way

rich adder
#

this is hella confusing , which one has the script ?

#

you should be putting that script on the pivot of the arm

nova kite
slender nymph
slender nymph
nova kite
nova kite
rich adder
#

its important which direction you scaled it / resting axis

nova kite
#

well i removed that pivot point and just assigned the aiming script to the gun itself

#

with this code

#

i calculate the direction with the mouseposition

nova kite
rich adder
# nova kite

here is how I would set it up, Make the capsule the middle, then put a pivot there, then make the gun child of that pivot and move it a bit away from the center capsule (playerbody)

nova kite
#

but the mouse movement does move the ray

#

I'll try that🙂

rich adder
#

the capusle (gun) in this case is just resized stretched on X but small on Y , without rotation so you see resting pos is (up green) (red right)

#

GameObject is where you woud put the "gun" script, or better to just put it on the Player itself root, then just make a [SerializeField] private Transform gunPivot

waxen glacier
#

How can I cap a rigidbody's velocity in any direction ? I want the character's speed to quickly ramp up to the max speed instead of instatntly reaching it

rich adder
waxen glacier
#

how can I make it into a specific direction

#

like clamping it only on the y axis ?

rich adder
#

you can also use mathf.min (current, max)

nova kite
#

idk why it doesnt work🥲 i made the pivot point when i rotate the red rotation axis it works perfectly but it wont follow my mouse correctly the script is attached to the pivot point

fading fractal
#

Hi, I'm having problems setting the gravity scale in the player data scriptable object, I keep getting an error saying that gravity scale is not a number, what do I do? (I imported a script for my player movement from github for my 2d platformer, and am having issues setting it up)

naive pawn
#

perhaps show your assignments/calls and where the variables used are coming from
!code

eternal falconBOT
hasty tundra
#

whats the site used to share scripts easily? like paste code in and send a link? i cant find it anywhere

#

nevermind its right there

#

oops

#

was WAY scrolled up in chat

hexed nymph
#

Hello guys, I'm currently working on a online game and I created the online system using Photon 2, for now I created 3 scenes: the Character Selector that transits to the Create and Join rooms and then when you joined a room it transits to the Lobby (that I called WaitingRoom)
My ideia is choose your character that is saved on a Hashtable that I called "playerProperties" (the character named: playerProperties["prefab]") and then in the WaitingRoom asign the prefab's name to an already existing static class that has every prefab on it (for ex: PlayerStorage.P1Prefab, PlayerStorage.P2Prefab etc) but this doesn't work on the game. I have 4 spawn points (one for each player) and this spawns for example "PhotonNetwork.Instanciate(PlayerStorage.P1Prefab.name, etc...)" but the game does not spawn that so I think the problem is the WaitingRoom script

fading fractal
#

nevermind, I figured it out

noble shuttle
#

Hello everyone! I'm working on my first game and have run into some errors. Does anyone know how to fix them?

naive pawn
#

try restarting the editor, if that doesn't work, try resetting the library, if they still persist try #💻┃unity-talk with that added info

rich adder
nova kite
#

3 hours on that was too much

#

ths solution if it interests you

#

very interesting actually i didnt think of getting the rotation of the end of the barrel to know the current rotation

#

to determine the bullet's path

wooden hill
#

For saving/loading (game savedata) do we use
Application.persistentDataPath + "\game.sav"
or something else?
Mostly need it for android and maybe ios builds

rich scroll
#

Quick question: can I use a 2d collider in a 3D game, where all they'd have to be there for is a raycast to detect them?

rough granite
wooden hill
#

ty

rough granite
naive pawn
#

for most systems / is used as the separator, just windows that uses \\

wooden hill
naive pawn
#

there should be a variable for that iirc, i don't remember what it is though

wooden hill
#

😄

rough granite
wooden hill
naive pawn
#

that's a different thing though

#

that's CRLF vs LF

wooden hill
#

ok fine noone can complain now

wooden hill
#

🗿

#

there are a few in there

#

btw can you even do folders (and subfolders) on android/ios when writing in an app? no clue 🙂

#

i mean i'm just going to put it at the root so .. just curious

rough granite
#

at least for android, i dont have an apple to test

wooden hill
#

also android neither since google began locking down a bit and I haven't fiddled since a long while with editing app stuff etc on there :S

rough granite
#

google did?

#

i can still edit .sav files from games i've downloaded off the play store though

wooden hill
#

i'm unsure like i did all the jailbreaking and cfw stuff long ago. i know they made stuff like spoofing root harder. maybe i'm just paranoid lol

wooden hill
#

btw favorite font for coding? @anyone

rough granite
#

does vs let you change your font?

rich adder
#

jetbraians mono ofc

rough granite
#

i've been using the default

wooden hill
#

yea it does...?

wooden hill
rich adder
rough granite
#

how i have to change it to futhark now

rough granite
rich ice
#

you're not a real programmer if you cant program in wingdings

rough granite
rich adder
#

it's even font on my phone

wooden hill
rich adder
wooden hill
#

can you see the difference? 😄

#

i'm using Consolas

wooden hill
wooden hill
#

Tools->Options->Environment->Fonts and Colors

rough granite
wooden hill
#

yea what i sent is vs2022

#

i meant vs or vscode

rough granite
#

yeah i got here no clue on how to add my own font to it though

slender nymph
wooden hill
#

select it there

#

just install a font by doubleclicking the .ttf .otf or whatever file in windows

rough granite
#

ahh

wooden hill
#

(maybe have to restart vs after installing font)

#

hmm i like cascadia too ... or maybe just because im used to it

rough granite
#

ty i got what i wanted now

wooden hill
#

when he said minecraft font he meant the readable one not the enchanting table one

rough granite
#

nah i got what i actually wanted though thank you

frigid lark
#

yo can i get some help with somethign

frigid lark
#

ok

#

mb

frigid lark
#

i need to do a top down ground check, to get the layer that it's on

#

private void Update()
{
RaycastHit2D hit = Physics2D.Raycast(transform.position, -Vector2.up * 5f);

    _movement.Set(InputManager.movement.x, InputManager.movement.y);

    Debug.Log(hit.collider.gameObject.layer);

    rb.linearVelocity = _movement * _moveSpeed;

    if (InputManager._changeAction.WasReleasedThisFrame())
    {
        otherController.enabled = true;
        cameraScript.Swap(false);

        GetComponent<PlayerMovement>().enabled = false;
    }
}

my current code

#

just to tell me what layer it is

wooden hill
eternal falconBOT
frigid lark
#

im just gonna do this no clue whats happening with paste mod gg thing

slender nymph
teal saddle
#

Alright thanks

frigid lark
slender nymph
#

okay, and what is your current issue?

frigid lark
#

im making a top down game, and i need to check the layer of the object theyre standing on

slender nymph
#

well to do that you would use some sort of physics query, perhaps a raycast, and from that you can get the layer of the object detected by said query.

frigid lark
#

im doing a raycast no?

slender nymph
#

right, so what is your actual problem

crisp radish
#

Guys, I am having the weirdest problem. "F" doesn't render for whatever reason?!?!?!? lol

frigid lark
slender nymph
#

what do you mean by that

frigid lark
#

i need to detect the layer that the player is standing on. right now, its giving me completely incorrect values of what layer its detecting

slender nymph
#

how have you determined that it is incorrect

#

also why do you need the layer? in my experience about 9 times out of 10 someone asking to check that has come up with an XY Problem

frigid lark
#

im trying to make an ice mechanic like undertale

#

where when you walk onto it, you slide to the other side without being able to move

slender nymph
#

does that need to use specific layers instead of just a trigger collider?

#

remember you are limited to only 32 layers total, reserving a specific layer for something like that means you will then be limited even further for proper usages of layers

frigid lark
#

ok

rough granite
frigid lark
#

wdym

rough granite
#

read it, wasn't specifically refering to just this case but in general

frigid lark
#

oh right mb

#

sorry

#

well how would i do the collision test?

#

im new to unity so im not sure sorry

silk night
#

add a trigger collider to your ice layer and let your player react to touching it

slender nymph
#

you can continue using physics queries for that or you can use physics messages like OnTriggerEnter2D

#

i would recommend creating a component that goes onto the trigger collider object that tells you what type of material you are on or just handles the entire interaction

frigid lark
#

ok thanks

#

so i would do all of this inside a ice sccript

silk night
# frigid lark so i would do all of this inside a ice sccript

the ice script would hold a property thats prefereably an enum

public enum SurfaceType {
  Ground = 0,
  Ice = 1,
  ...
}

public class SurfaceView : MonoBehaviour {
  [SerializeField] private SurfaceType _surfaceType;

  public SurfaceType SurfaceType => _surfaceType;
}

Then you can detect on what surface you are standing on your player like

public void OnTriggerEnter(Collider other) {
  if (other.TryGetComponent<SurfaceView>(out var surfaceView)) {
    _currentSurface = surfaceView.SurfaceType;
  }
}
#

and depending on currentsurface you can change your player behaviour

frigid lark
#

ok thanks that helps a lot lol

#

im coming from unreal engine so I have a rough idea of what things mean but unity handles things super differently

silk night
#

yeah it takes some getting used to things when switching 😄

frigid lark
#

like for example I wish id be able to see the raycast like you can in ue5. you can just set it to be visible for a certain amount of time

frigid lark