#💻┃code-beginner

1 messages · Page 676 of 1

winter plover
#
  IEnumerator MoveMonsterJumpscare()
    {
        JumpscareSound.Play();
        canvasGroupV.alpha = 1f;

        

        while (Vector3.Distance(Monster.transform.position, TargetEndPos.transform.position) > 0.1f)
        {

            Monster.transform.position = Vector3.MoveTowards(Monster.transform.position, TargetEndPos.transform.position, monstermovespeed * Time.deltaTime);
            yield return null;




        }


        
        

    }
naive pawn
#

where it checks if the collider was the player
you could probably just use layers for this but that's a separate topic

#

still haven't gotten an answer for this though..

winter plover
#

which script?

#

like that whole

#

thing

#

in the trigger?

#

wym

naive pawn
#

the one i replied to

#

what object is this component on

winter plover
#

the trigger

naive pawn
#

should it not be on the canvas/vignette/whatever

#

so anything that needs to do the FadeOutVig doesn't need the extra script

#

that way it manages itself

winter plover
#

so, what are u implying i should do

naive pawn
#

i.. literally suggested it?

#

should it not be on the canvas/vignette/whatever

winter plover
#

ok one sec

#

well

#

time.deltatime isnt freezing anymore

#

and everything else is working but the fadeout again..

naive pawn
#

again, debug values, next to where you use them

#

check deltaTime and elapsed within the coroutine, so you can also see if the coroutine stops prematurely

winter plover
#

ok so

#

im as close as i can be

#

    IEnumerator MoveMonsterJumpscare()
    {
        JumpscareSound.Play();
        canvasGroupV.alpha = 1f;



        while (Vector3.Distance(Monster.transform.position, TargetEndPos.transform.position) > 0.1f)
        {

            Monster.transform.position = Vector3.MoveTowards(Monster.transform.position, TargetEndPos.transform.position, monstermovespeed * Time.deltaTime);
            yield return null;
        }


        yield return StartCoroutine(FadeVig(1f, 0f, 2f));


        Destroy(Monster);
        Destroy(Trigger);

    }

#

ive done this

#

but it works

#

it just doesnt fade out

#

like it just disappears instantly

#

in 2 sec

naive pawn
#

i don't think you'd want to wait for the vignette to fade before destroying the trigger/monster

#

anyways, do some debugging then lol

humble briar
#

`using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class Touching : MonoBehaviour
{
public string scene;

void OnCollisionEnter(Collision collidedwith)
{
    if (collidedwith.gameObject.tag == "Player")
    {
        SceneManager.LoadScene(scene);
    }
}

}
`

Does anybody know why this might not work?
The player has the Player tag and scene is set on the object

rocky canyon
#

-# testing...

rocky canyon
#

hmmm omg there might be a wall of embeds 😬

naive pawn
#

Attachments and embeds broken
• Impact: major
• Affected Components: API
Investigating (11 minutes ago)
We are investigating an issue with attachments and embeds not being rendered in the app.
from discord status

humble briar
#

oh what it just worked?? i littererally didnt change a thing??

humble briar
#

ah i dont think i saved

#

well done me

frail hawk
naive pawn
frail hawk
#

rubber duck

marsh bough
#

hey guys idk if this is right place to ask questions as a complete freshie to game development but where should I get started? I watched some yt vids and nothing seemed to help me understand anything or how to get started. sorry if this is the wrong channel to ask in

naive pawn
#

!learn and see pinned resources

eternal falconBOT
#

:teacher: Unity Learn ↗

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

marsh bough
naive pawn
ivory bobcat
marsh bough
#

thanks idk if ill persue this if I cant figure out anything by the end of the day

timber tide
#

No one becomes a professional in a day

rocky canyon
#

-# if ur already moving forward with that mindset then game-dev probably isnt gonna be right for you anyway

#

now, if u enjoy puzzles, hard work, and learning how things work.. its great

marsh bough
real grail
rocky canyon
#

as long as u stay in "pursuit" u'll be fine

rocky canyon
#

one of those self-fixing problems

#

i never get those! 😦 lol

naive pawn
#

fixes itself as soon as you ask for help

#

or try to show someone else the issue

rocky canyon
#

oh.. thats them 👻 issues.. no one believes they exist

low lotus
#

Should I use individual sprites (png images) or spriteatlases? I don't really get witch one to use

frosty hound
#

Functionally, they don't do anything differently. You use the sprite (either single or from the sheet) on your SpriteRenderer component.

#

The difference is that a sheet is considered one thing for performance consideration, and it just displays part of that sheet/texture to make it look like it's just one sprite.

#

So which you use is up to you. For things that are closely related to each, such as something with animations, you would use a sheet.

#

Tiles are also a common usecase for sheets, if they are all part of the same environment.

low lotus
#

I use non pixel art images in my games. Should I pack my 6 characters in atlas or leave then separate png files?

polar acorn
#

Whether they are pixel art is 100% irrelevant to anything

low lotus
#

So leaving them separate files won't effect performance?

#

Actually my game runs good on webgl in 7 years old chromebook so I guess I should not be worried 😄

frosty hound
#

It does affect performance in some way, everything does.

#

But if you're micro optimizing, you may as well just stop and continue doing as you're doing. There's no point stressing if it's not a problem.

real grail
real grail
low lotus
#

Ok, thanks! One more question. When I place my 400×400 image into a Sprite Renderer, it appears as 391×396. Why does this happen? I made all the png divisible by 4 in photoshop. Does this effect something?

I also cropped the transparent pixels around a PNG before importing it into Unity. Is it ok?

polar acorn
low lotus
#

My original image from photoshop. Second one what spriterender uses. it destroys the divisible by 4

#

Does it matter?

grand snow
#

to be able to use DXT or ETC it needs to be a pow2 size

#

so 512 is the closest to 400~

low lotus
#

But why does my sprite go from 400x564 to 393x550

#

when it's in the sprite renderer

#

it destroys the divisible by 4

grand snow
#

er no idea tbh

#

are you sure this is the same sprite?

low lotus
#

The one on the right is 393x550

#

And sprite renderer uses that

glad ibex
#

Whats this object called in scripting and which namespace is it?

short hazel
glad ibex
grand snow
short hazel
#

Works as well, the UGUI is a derived class of TMP_Text

#

So if you ever change to a 3d text, use the base TMP_Text

grand snow
#

if writing ugui code its very unlikelly

#

I do lots of ugui code so im very used to writing this

short hazel
#

Both work so whatever

grand snow
#

👍

glad ibex
#

Could someone ples help me why doesnt this attribute doesnt worky?

timber tide
#

Never heard of that one. Use [HideInInspector]

rich adder
glad ibex
timber tide
#

[NonSerialized] works too assuming you're not changing the value beyond the default in the inspector

timber tide
#

Ah, I'm assuming that just applies to all instances then

rich adder
glad ibex
#

Like a public getter?

#

ima google one sec

glad ibex
#

Oh wait internal exists

#

Thx

rich adder
#

ohh why is it public at all

timber tide
#
public bool CurrentlyUp { get; set; } = false```
Prevents it from serializing too
glad ibex
#

🤷

rich adder
#

this wont show in inspector and a cleaner pattern

glad ibex
humble briar
#

ok why does text mesh pro look different what did i do

slender nymph
slender nymph
#

also not a code question

humble briar
#

ooooh

#

thanks

#

also yeah sorry wrong channel my b gang

glad ibex
#

meow

#

But alr

#

I can expose it in a wrapper ill soon do

#

Actually yeah ill do that

#

cuz nono wanna backing fields

slender nymph
#

can you finish a thought before sending a message instead of spamming one thought across 7 messages
#📖┃code-of-conduct

glad ibex
#

Will the standart constructor of a component run when creating a gameobject with a said constructor?

slender nymph
#

the parameterless constructor will be called, yes. but you really shouldn't be using that unless you have a good reason for why you would be. just use Awake instead for 99% of cases

glad ibex
shy hollow
#

hey!! dont post here usually but looking for some advice regarding exporting data to text files :)

excuse the absolute mess of the code - im trying to just get it working 😭, im wondering how id go about storing these lists as a text file (to be imported / exported to other players), specifically the "listofpositions", "list of rotations" and "timestamp". Ideally these values would be read at runtime too in order to simulate a "ghost".

Lmk if any more context is needed :)

slender nymph
#

exporting data to text files
look into json serialization. unity has JsonUtility built in which can handle that data easily

shy hollow
#

yeah ive looked into JSONs - just really struggled to get them working / wrap my head around them. Documentation seems pretty complex and im not finding any solid tutorials for them. Could just be looking in the complete wrong place though

slender nymph
#

well if you need help with it then you'll need to show what you actually tried

shy hollow
#

truth be told everything ive tried has ended up in deleted code 😭 , do you know of any recourses that explain them in a more simple manner?? would be really helpful

#

back to google it is then, thanks anyway :)

glad ibex
#

Is there any way to Monobehaviour:Invoke() a method and give args to it?

#

Except storing them externally

slender nymph
#

no. if you need to delay a method call you can use a coroutine instead, the coroutine can accept an Action as a parameter and the time so you can reuse it for any method call delays

glad ibex
#

Ah, thx

versed fjord
#

Hey

visual wraith
#

Trying to increase a variable from OnCollisionEnter2D, but it keeps getting set back to its default value every time it runs

eternal falconBOT
slender nymph
visual wraith
#
public class BirdController : MonoBehaviour
{
    private GameObject birdObject;
    private Rigidbody2D _rb2d;
    private float moveSpeed = 6f;

    private float _maxTIme = 3f;
    private float _Timer;

    public GameObject _PipePrefab;
    private Vector2 _PipeSpawnPos = new Vector2(0, 0);

    public float HighScore;
    //public float CurrentScore;
    public float score;

    public GameObject _scoreText;

    void Start()
    {
        birdObject = gameObject;
        _rb2d = birdObject.GetComponent<Rigidbody2D>();

        HighScore = PlayerPrefs.GetFloat("HighScore", 0f);
        //CurrentScore = PlayerPrefs.GetFloat("CurrentScore", 0f);
    }

    void FixedUpdate()
    {

        if (_Timer > _maxTIme)
        {
            SpawnPipe();
            _Timer = 0;
        }
        _Timer += Time.deltaTime;
    }

    public void OnFlap()
    {

        _rb2d.linearVelocityY = 1 * moveSpeed;

    }

    public void SpawnPipe()
    {

        GameObject ClonedPipe = Instantiate(_PipePrefab, _PipeSpawnPos + new Vector2(15, Random.Range(-2, 2)), Quaternion.identity);
        Destroy(ClonedPipe, 8f);

    }

    void OnCollisionEnter2D(Collision2D collision)
    {
        //if the bird hits a pipe
        if (collision.gameObject.tag == "Pipe")
        {
            Debug.Log("bird hit pipe");

        }

        //if the bird passes the enters a pipes border
        if (collision.gameObject.tag == "PipeBorder")
        {
            Debug.Log("bird passed pipe");
            //increase current score by 1 when player passes a pipe
            score += 1;
            _scoreText.GetComponent<TextMeshProUGUI>().text = score.ToString();
            Debug.Log(score);

            //if the current score is greater than the high score, save the current score to the high score save
            if (score >= HighScore)
            {
                PlayerPrefs.SetFloat("HighScore", score);
            }
            
        }
        
    }
}
#

making flappy bird

#

been trying all sorts of stuff but I have no Idea whats wrong

polar acorn
visual wraith
#

I want the score to increase whenever the player passes through a pipes border (gap between the two pipes), however the score isnt being increased at all, everytime it runs i just see 1 in the console.

whole osprey
polar acorn
visual wraith
#

Yes

#

The debug logs are doing their job for sure

polar acorn
#

How about logging score?

visual wraith
visual wraith
#

As in debug log?

polar acorn
#

which you already seem to know the meaning of since that was my previous question

visual wraith
#

yeah Ive been logging score, and its 1 every time

polar acorn
visual wraith
#

just the bird

#

been trying to reduce the number of scripts I make

hallow sun
#

How many times does it trigger on each Play?

visual wraith
#

just once when the player passes by a border

polar acorn
hallow sun
#

You do know variables reset on each Play right? I think this is the issue

#

"Play" as in starting the game not on each trigger of the function

wintry quarry
#

Trigger colliders would be using OnTriggerEnter2D

#

Not OnCollisionEnter2D

visual wraith
#

Well I have the border set to IsTrigger so the player can pass through it, and with OnCollisionEnter2D on the bird it'll detect whatever it collides with, in this case the pipe border. Im using tags to tell the pipes border and the pipes themselves apart

#

its working pretty well besides my issue with the variable

wintry quarry
#

something is fishy about your story here

visual wraith
#

Just deleted an old script from the pipe border before I decided to make the logic on the bird script.

#

think that may have been apart of the problem

wintry quarry
#

definitely

#

because this code will not have been running

whole osprey
#

When you're cleaning things up, you should probably switch all of your score stuff from floats to ints. This way will work, but you'll be doing string formatting and other crap you don't need to waste time on.

visual wraith
#

Okay so I've managed to fix it by making the bird IsTrigger and swapping OnCollisionEnter2d with OnTrigger, and I think the variable was being affected by the remaining c# float score; I had on an older script.

#

well but now the bird doesnt collide against the pipes.

polar acorn
#

The space between them should be triggers

whole osprey
#

Bird - has rigidbody, has collider, not Is Trigger
Pipe - has collider, not Is Trigger
Pipe Pass Through - has collider, Is Trigger

#

Then have an OnTrigger method for passing through the pipes and an OnCollisionEnter2D method for hitting the pipes.

visual wraith
#

oh sweet lord it WORKS

#

yeah this is getting noted down for sure.

verbal dome
#

I dont know about that attribute but sounds useful if it exists

sour fulcrum
#

fair call

#

i saw it somewhere randomly and found it neat

naive pawn
#

bruh i just thought i found it lol

verbal dome
#

Iirc

sour fulcrum
#

yeee, just for this i dont have any

#

i dont mind worstcase but wouldnt mind avoiding if i can

verbal dome
#

Its a hack anyway yeah but its the only way I know apart from custom property drawers

slender nymph
#

ah wait, nevermind the page for that property is being used for the base class so that's probably not it

#

if such an attribute does exist then it does not appear in the list of attributes in the docs

sour fulcrum
#

yee :/

#

i appreciate the looking

slender nymph
#

are you certain it wasn't from a package/asset?

sour fulcrum
#

I think I saw that and just was yet to test it

naive pawn
naive pawn
thick sedge
#

we can use return; to go in situation like this

if (something == true) { do something return; }

but is there any other uses for it?

slender nymph
#

return; is used to exit early from a method that returns void, that's it

thick sedge
slender nymph
#

you can return an object, yes. but not by just typing return;
you need to actually specify what you return. but that wasn't your question, your question was about return;

thick sedge
slender nymph
#

how would i know what you are actually asking about if you don't actually ask about that thing?

#

your question specifically used return; and the example included was about returning early. if you wanted to know all of the uses of the return keyword then ask that next time

thick sedge
#

never mind it

rocky canyon
#

early returns i think are useful

naive pawn
#

can use it for guard clauses too

twin pivot
#

I'm not sure why this is giving an error

public bool Test(GameObject _enemy, int enemyWalkRange, int enemyAtkRange)
{
    for(int i = 0; i < 49; i++)
    {
        if(Mathf.Abs(Vector2.Distance(_enemy.transform.position, _tileData._tileArray[i].transform.position)) <= enemyWalkRange)//sees if enemy can walk to that position
        {
            for(int j = 0; j < _tileData._playerUsingTile.Length; j++)
            if (Mathf.Abs(Vector2.Distance(_tileData._tileArray[i].transform.position, _tileData._playerUsingTile[j])) <= enemyAtkRange)//checks if valid attack
                {
                    return true;
                }
        }
    }
}```
slender nymph
#

the first would be due to where you call this method. the second is because not all paths return a value. you only return anything in that inner if statement. what happens if that is not true?

twin pivot
#

also kinda unrelated but should i use Mathf.Approximately to avoid float problems or does Mathf.Abs already do that for me

ivory bobcat
twin pivot
slender nymph
#

you don't need to Abs the distance, the distance is always positive

#

but you should log some info to make sure you are checking the position of the correct object(s)

pliant abyss
#

So I invented a data structure I am calling a Fan -- as in a peacock fanning it's display

twin pivot
slender nymph
#

show the current code, both objects involved in the check, and how you've confirmed you are getting the position of the correct objects

twin pivot
runic quartz
#

I am trying to access the Tracking Target field through scripting by

    private Transform player;

    private void Awake() {
        player = GameObject.FindGameObjectWithTag("Player").transform;
        TPP_cam_settings.Target = player;
    }

and the error that i am getting is Cannot implicitly convert type 'UnityEngine.Transform' to 'Unity.Cinemachine.CameraTarget

How can i set the tracking target during runtime?

slender nymph
runic quartz
#

yes, this solved my case

        player = GameObject.FindGameObjectWithTag("Player").transform;
        TPP_cam_settings.Target = new CameraTarget{TrackingTarget = player};
    }```
runic quartz
slender nymph
#

it is not the same, that is object initialization syntax because the CameraTarget struct does not define a parameterized constructor. you could have alternatively done this:

var target = new CameraTarget();
target.TrackingTarget = player;
TPP_cam_settings.Target = target;
#

another option would have been to just copy the current value in the Target property, assign the TrackingTarget field on that copy, then assign the copy back to the property (assuming Target is a property and not a field. if it is a field then you could just directly assign its TrackingTarget field without making a copy)

runic quartz
slender nymph
#

yes, but it's not exactly the same as invoking a constructor with arguments

#

the syntax you have is basically the same as the example code I wrote, it's just done inline

runic quartz
#

yes, i see

#

that makes it clear. Thanks for your time

slender nymph
runic quartz
#

thank you

late burrow
#

the hell json is so slow, i stored 50mb ish base64 in it and it takes like 15 seconds to parse and with string split its under second

sour fulcrum
#

50mb of text is pretty big, no?

late burrow
#

no 50mb of pcm for audioclip

#

i thought it turns into class like structure right away but it appears it scans through strings live time

sour fulcrum
#

i mean it is a big string at the end of the day

eternal needle
#

if you can process it directly using string.split, then it doesnt make sense why you were using json in the first place considering that wouldnt be a valid json format.

late burrow
#

because im limited to 1 string and holding it inside json would be much easier to manage than glue some base64 outside of it

eternal needle
late burrow
#

just i remember lot of people were saying that string split is bad and to not use it

#

meanwhile json is even worse

eternal needle
# late burrow just i remember lot of people were saying that string split is bad and to not us...

i havent seen the context of who said this or why they said it but i can firmly say you have a big misunderstanding. you cannot compare a json parser and string.split in any world.
string.split works exactly how it should. if you need to process a string and split it by a certain character every time then .Split is made for this. This takes a string and gives you an array
Json is a format and to simplify you can use it to parse a file to get structured data back. this might represent an instance of a class

#

you were more likely told that its bad because you shouldnt have been using strings in the first place, since we've seen you use it for pretty much every feature.

late burrow
#

possible

eternal needle
#

a json framework is doing way way more than searching for a character and creating an array based on it so yea itll be slower. if your 50mb file can simply be read by string.split, and all you need to do is store this in an array then by all means do that.
If suddenly you need to do more like process data on each line of the file, you'll notice your code will also slow down

#

i might be wrong here but a 50mb file should be 50 million characters.

late burrow
#

i do need to do that as well, just json is good for small things but not big, so i stick them together and later separate with split so i can still run my json

#

i could do everything with split but then i would clog up my ram by splitting 50mb string 10 times

charred spoke
#

Why the fuck are you working with a 50mb string in the first place

late burrow
#

eh going offtopic again

sour fulcrum
#

If I have two tri’s (two sets of 3 world space positions) is there any suggested way on checking if they intersect?

charred spoke
#

I think thats a very googleable question.

sour fulcrum
#

two be honest the results i got where either not related to my question or stackoverflow posts full of fairly math heavy responses where people disgree with eachother

#

i didn't do high school so maybe the math is more simple than i think but i did look around

late burrow
#

math is surely fastest solution but if you dont know it then just check if meshcolliders colliding

sour fulcrum
#

i dont have meshcolliders in this context

charred spoke
#

Well a simply solution would be to check if each point of a triangle is inside the other one. This has the literal edge case of failing if a point lies exactly on an edge of a triangle. For more precision you can implement the Separating Axis theorem

sour fulcrum
#

i see, i'll google that but i don't actually know how to do that which probably explains why im not sure how to approach it 😄

livid anchor
#

Hey folks, I'm having a small issue with the flappy bird game I'm trying to recreate. I'm using time.timeScale = 0 to stop the game on gameover, and reset position after. But for some reason the bird seems to keep momentum, so if I hit gameover on a pipe it's okay, but if I let it fall repeatedly it accelerate and it becomes unplayable

#

Any idea what's happening ?

keen dew
eternal needle
livid anchor
#

How do I reset velocity ?

#

I have a very basic :

`void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
playerMovement = Vector3.up * FORCE;
}

playerMovement.y += GRAVITY * Time.deltaTime;
transform.position += playerMovement * Time.deltaTime;

}`

keen dew
#

playerMovement.y = 0

livid anchor
#

That did the trick, it was that simple thanks

#

Now I can work on progressive difficulty 👍

keen dew
#

!collab (in reply to the now deleted message)

eternal falconBOT
#

:loudspeaker: Collaborating and Job Posting

We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
Collaboration & Jobs

keen dew
#

but you do need to !learn to code if you want to make a game, there's no going around that.

eternal falconBOT
#

:teacher: Unity Learn ↗

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

fickle plume
#

@exotic laurel ^^

exotic laurel
#

Hi, thank you, i completed the pathways for beginners, that is why i made some progress in my 'game' but i am not hidding that i use ai for coding. Anyway, thanks

fickle plume
exotic laurel
#

I agree, that is why i participate in the unity pathways and follow some YT tutorials too! but i guess i am to excited and eager to do my own project that i cant help myself and use ai to speed things up! And now im stuck, so i guess it backfired heh. thanks again

fickle plume
#

Looking up answers in the manual you get a lot more information than getting a digested word salad.

exotic laurel
#

any particular manual you have in mind?

#

i appologise if i misunderstood, english is my second language

fickle plume
#

The Unity manual. The answers you get from when you use search engine.

exotic laurel
#

Thank you kind sir!

candid garden
#

Hey, I'm making a system for storing all available characters in my game and all their associated stats etc, I want to be able to access it across scenes so I can update for example if a character dies in a fight. I was looking at SO's or a list in a monobehavior attached to a instanced don't destroy on load gameobject but I was wondering what's the better approach? Or if there's a better way to do it I'd love to hear, thanks!

sour fulcrum
#

sounds fine yeah, personally as someone who probably overuses so's i'd maybe even have some sort of ScriptableManifest type thing that holds the list of characters on that so, and have it referenced in a core manager that relates to its usage

candid garden
#

Sorry could you explain what you mean by ScriptableManifest type thing?

sour fulcrum
#

basically just a SO that holds that list of SO's

#

suggestion more out of preference than superiority but i find the list of available characters itself also feels more like a job for an SO asset than on some prefab somewhere

candid garden
#

Sweet thanks, I'll give that a go 🙂

full kite
#

!code

eternal falconBOT
full kite
#

Hello, I got this error with nothing else and I dont know where it's from . Does someone know what did I do?
Parser Failure at line 2: Expected closing '}'

#

I went to see any unclosed brackets, but all of them were closed, on all the scripts, idk what to say

hexed terrace
#

you didn't ask a question, and this is a code channel.. so if it's not code related, delete from here and actually ask in #💻┃unity-talk

full kite
hexed terrace
#

you have a missing bracket, even though you think you don't

full kite
#

i checked every single bracket of every single script, i cant find any missing bracket

hexed terrace
#

At a guess.. your IDE isn't setup correctly to show you errors within it, and you're seeing that error in Unity console?

full kite
#

indeed

hexed terrace
#

double clicking the error will take you to the problem

#

!ide

eternal falconBOT
full kite
#

aint working

hexed terrace
#

^ get your IDE setup correctly

full kite
#

it supposed to led me to problem, but it doenst

#

its just an error and Idont have a line, it doesnt led me anywhere

hexed terrace
#

care to share screenshots

full kite
#

double clicking is not working

hexed terrace
#

haha, I've just opened Unity and look

full kite
#

is not ledding me anywher

hexed terrace
#

ignore it

#

clear the console -> gone

full kite
#

indeed

#

its not stopping me

#

but its annoying me

#

shouldnt we report it somewhere?

hexed terrace
#

I could not care any less about it

#

I'm also not on the latest version of 6, so it may not be present anymore anyway and I'm not updating to find out

full kite
#

indeed, so it shouldnt disturb us?

#

and if so, is it a channel to report a problem like this?

#

idk, where some admin will look?

hexed terrace
#

in the editor help -> report bug, same as every other bug you need to report

#

There is no reporting issues on here, it would be a nightmare to organise and track.

full kite
#

i mean yeah, but this thing appeard to me yesterday so its something that they did recently

#

so it wouldnt be that hard to track

#

ig

#

and its something on the using System.Collections.Generic;

hexed terrace
#

you misunderstand what I mean by track

full kite
#

probably ))

#

!bug

eternal falconBOT
#

🪲 To make bug reporting as quickly as possible, we made a bug reporting application for you. When running Unity choose Help->Report a Bug in the menu, or you can access it directly through the executable in the directory where Unity is installed. It will also launch automatically if you experience a crash.

📝 If your bug report is to do with Documentation, either an error, typo, or omission, you can report it by scrolling to the bottom of the page where you found the issue and click ‘Report a problem on this page’!

💡If your report is to do with a new feature idea, you can check the Unity Product Roadmaps page to see if your idea has already been planned.

For more complete instructions on how to report bugs, access: https://unity3d.com/unity/qa/bug-reporting

winter plover
#

guys help, how do i bake a navmesh

#

i cant find the bake tab or object tab like it says in the learn.unity site

winter plover
#

ok i found it

winter plover
pseudo ermine
#

Good afternoon, I am having trouble with grabbing something via a tag. Everything else is grabbed fine, but this one thing just does not want to work. Any help is much appreciated.

lavish plover
verbal dome
#

Also avoid using the ?. operator with unity objects (gameobject, components, scriptableobject)

naive pawn
#

also give more details about how exactly it's not working

pseudo ermine
naive pawn
#

?. just doesn't work as you might expect with unity objects, there's no direct replacement

clear juniper
#

you have to do if (someGameObject == null) - unity doesn't override the ? operator so you can occasionally end up with the underlying C++ object being destroyed but the C# object being alive, or vice versa, can never remember which way around it is 😂

pseudo ermine
naive pawn
#

it's gonna cause issues later

#

for unity objects, == null and is null are different

#

you almost always want == null
but ?. uses is null

#

get rid of it now and either:

  • let it fail-fast if this is something that should always be available (you get an error that you can see)
  • handle it properly with == null if this is something that may or may not be available
honest star
hexed terrace
#

a third party console

sacred ingot
#

hello i have made a vfx that sends a slash, now my problem is what should i do to make it usable as an ability and affect some damage if it touches an enemy for example i want to make a hit area like that image shows. if any professional in that field could guide me a little i will appreciate it

sacred ingot
rich adder
#

a ray could work but might be too thin

sacred ingot
#

yeah

thorn stone
#

Does anyone know where is that? I have no idea in which channel should I ask for help so I am asking here.

rich adder
thorn stone
sacred ingot
rich adder
#

Parameters don't magically exist

thorn stone
#

I know that LastY, X is missing

#

But where do I add them

wintry quarry
#

in the animator state machine

slender nymph
thorn stone
#

Oh alright thank you

rich adder
sacred ingot
#

yeah

rich adder
thorn stone
#

Could anyone please tell me where is in this script anything about "LastX or LastY" like wth...

#

I only have for X and Y

sacred ingot
#

that may work

wintry quarry
rich adder
wintry quarry
#

yep, not saved

thorn stone
#

Alright warning is gone.

#

Thanks for help.

slender nymph
eternal falconBOT
thorn stone
#

which one

slender nymph
#

surely you can use your eyes and logical reasoning to figure out which link you need to click

rich adder
#

and they been told already few times which, but somehow have amnesia now

viscid girder
#

How does this make sense? How can my capsule of height 1.9, be at rest on the floor of (0,0,0) and have a center of (0, 0.50, 0)? Should it not be (0, 0.95, 0). For reference I am using capsuleCollider.transform.position.y

frail hawk
#

you probably want the pivot of your player at the center of the feet instead. this should be the case when you import

viscid girder
#

Or can it be changed in unity?

frail hawk
#

looking good here but it seems like it has not been applied

eternal needle
sacred ingot
eternal needle
sacred ingot
#

on the canvas

eternal needle
sacred ingot
#

if interested

eternal needle
#

i googled and saw a few tutorials exist but dont really have time to check it out now

#

thanks though

viscid girder
#

Why is my floor saying it's y position is at 0, yet when I move it down by -0.5, all game objects appear to be at the position they should be? Its like they have a different world transform???

viscid girder
frail hawk
#

nah it is something on your side. in blender your pivot point looks right.

#

but anyways, it seems like it is fixed now

rotund hull
#

!code

eternal falconBOT
rotund hull
#

does anyone know a fix

wintry quarry
#

print out the hit point, print out which tile pos that's being converted to. See what's going wrong there. DOuble check your raycast as well

rotund hull
#

i did and the best thing i was able to do was add that if statement

wintry quarry
#

then you need to keep trying

#

I don't see any log statements in the code at all

rotund hull
#

i removed them

wintry quarry
#

you should be printing all the relevant info - and drawing things with gizmos, until you find what is off

wintry quarry
#

nobody is going to be able to just eyeball this code and tell you the issue offhand

rotund hull
#

alr

queen adder
#

how is the mining supposed to work? A raycast from the player to the mouse and it destroys whatever block is hit?

wintry quarry
#

I would expect subtracting half a grid unit in opposite direction of the normal before converting to tile coords though

#

not converting to tile coords and then subtracting a whole unit

ruby python
#

Hi all, would anyone know of a tutorial/guide (ideally video) for creating a quadtree for a simple plane object? All of the ones I've found and tried to follow are heavily interwined with other code etc. and I'm finding it all very confusing. 😕

green copper
#

if I'm tweaking something like the perameters of some physics objects to get a good feel, e.g. tweaking and working while running, how can I make those changes stick once the simulation stops? The best thing I've been able to figure out so far is just screenshotting the settings before I end the sim

queen adder
green copper
#

ah, thank you!

onyx geyser
#

when the error 'Object reference not set to an instance of an object' occures when a 2D body collides with a 2D collision object, and i'm trying to make it so a death screen appears, would it be that the interaction between the body and the object has an error or that the object to death screen has an error?

#

i'm not getting the debug message for when death screen is happening, so it seems like it's before that happens but after a collision happens

slender nymph
onyx geyser
#

private void OnCollisionEnter2D(Collision2D collision)
{
Debug.Log("pipe hit");
logic.gameOver();
}
(probably not enough to go off of but heres this anyways)

naive pawn
#

might be inside gameOver, check the actual stacktrace

#

also see below for posting !code

eternal falconBOT
onyx geyser
#

now that i think about it, it probably is logic

#

aghh

#

when calling for a deathscreen activation, what else can i use you think?

slender nymph
#

why not just fix the error instead of trying to bypass it by doing something else?

naive pawn
#

i have no context on what your code architecture currently is, i cannot possibly answer that lmao

slender nymph
#

you've come to the conclusion that the logic variable contains 'null' so make it contain a reference to the correct object instead

green copper
#

how can I tweak the accelleration curve of an object?

I'm using addForce and a custom function to add drag, and those two combined give me an okay top speed and stopping speed, but I'd like to tweak the rate at which I reach top speed and I can't find any resources that specifically cover this

naive pawn
green copper
onyx geyser
naive pawn
onyx geyser
#

that being, one i had already made for a different object that didn't exist at the beginning of the script either

#

actually pretty proud of myself for understanding that one

green copper
naive pawn
lime idol
#

Hey! I have a question - How can I learn to code in Unity without relying on memorizing every line? After watching tutorials, I try to write scripts on my own, but I keep forgetting the exact syntax or what to type

sour fulcrum
#

you gotta remember the syntax and slowly learn a lot of the function names but that doesnt mean remembering every line

naive pawn
#

you aren't supposed to memorize lines of code, you're supposed to understand them and then write your own

#

(in general) there's 3 major parts to programming:

  • Language - The syntax, structure, and paradigm of each language
  • Library - The interfaces and utilities that each environment or toolset provides
  • Logic - The algorithms to do work at runtime

Logic is almost completely transferrable between each language and environment, you just have to learn the specific Language and Library that you're using
Language is also shared quite a bit between languages

of course, learning 1 part at a time is easier than learning everything at once, which is why tools like scratch or code.org are popular as coding courses for beginners, especially kids, because it only focuses on the Logic aspect

lime idol
#

Ohhh I see, this makes way more sense. I didn't know about these 3. I appreciate that 🤝

naive pawn
#

the core of "learning to code" is the logic - the language and library aspects can be looked up
there are other skills (knowing where to find info, what to search, terminology, reading docs, etc) that help with looking up syntax or method names - none of us remember everything single thing we use
but the most common parts of language/library, in this case methods, conditionals, loops, GameObject and Component methods, unity messages, those you will get better at remembering as you write more code, akin to muscle memory

lime idol
#

Gotcha, yeah. I understand now

naive pawn
#

ultimately the skills you need to practice are problem solving (the logic aspect) and finding and understanding technical information (c#/unity docs)
the rest you'll pick up along the way as you get more experience

lime idol
#

Yup, that sounds awesome. Thanks

late burrow
#

is there any good way to align animation with audioclip time or should i do it manually in code

naive pawn
#

there are several ways to achieve this, which one fits probably depends on what exactly those clips are

#

you could use animation events if the audio accompanies the animation, for example
or use a timeline to sequence them together
or you could trigger them both at the same time in code

tranquil forge
#

Im brand new to game development. Could someone help me with my camera system. In the game when you press WASD, the camera moves to the direction in which you turn in. Could someone give me a basic run down on what to do in my situation

i opened the language, got scared. and joined the discord server bc theres no shot im doing this all on my own

rich adder
tranquil forge
#

i didnt ask for that. i simply wanna know a basic run down. and do it on my own

tranquil forge
rich adder
eternal falconBOT
#

:teacher: Unity Learn ↗

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

rich adder
#

start small, build your way up to more complicated game

tranquil forge
#

uuuuugh

#

as much as i didnt wanna do this

eternal needle
tranquil forge
#

i have to

tranquil forge
sour fulcrum
#

its very much public information

tranquil forge
#

being hyperbolic

rich adder
#

development is about breaking down larger problems into smaller ones, you might have searched too specific

sour fulcrum
#

you don't learn how to drive from your local mcdonalds to your local chemist right?

you learn how to drive

tranquil forge
#

its just. for how simple my game is, i woudnt think id have to "get my feet on the ground" type thing

rich adder
#

no game is simple

tranquil forge
#

im also a 1 hit wonder so. yyyeeeah

#

i wanna do this one thing and never do it again

sour fulcrum
#

your learning an entirely new language here that slaps your fingers with a ruler and tells you to go home if you pronounce something wrong. you gotta learn from the start

tranquil forge
rich adder
tranquil forge
#

i wanna make a passion project and call it a day

eternal needle
#

if you want to call it your best because its your only work, then sure it is technically your best. I can absolutely guarantee you will be writing some horrible code.

sour fulcrum
tranquil forge
#

work on it for a few months or smth

tranquil forge
tranquil forge
#

but hey my game works. sorta

#

yeah im not satisfied with that nvm

#

i mean, im willing to stay up for days on end just to get this done so i can rest knowing my idea is finally alive

eternal needle
#

if you want to realistically make a project in a few months from knowing nothing, then dont start by immediately making the foundation of your project. Go practice basic c#, learn the basics of how the engine works.
and then yes break down your problems into smaller manageable chunks. You dont google "how to move using ABCD keys". You research how to move, then research how to check for the input you want, then combine the two

eternal needle
tranquil forge
#

so even if its excessive? the breaking down part. orr does it get to a point

tranquil forge
#

taking notes

#

and here i was thinking my little room with camera movement would be simple and easy. damn

eternal needle
#

break it down as far as you want. you'll know when its excessive if you're starting to break it down to "how to add"

rich adder
#

there are premade controllers you can plop in if you just want to move around, but you still need some basics of the editor

tranquil forge
#

im not saying i wont make games. but i just cant see myself willfully crafting something for weeks just for it to not work properly in the end

#

idk

#

its like a gamble, for my time

#

like if i really wanna do this who knows it just might not work at all

rich adder
#

find a hobby that you actually enjoy sinking hours into

tranquil forge
#

or i lose this spark of energy and give up all together

tranquil forge
eternal needle
#

if your only goal is a camera moving around a room then sure thats feasible, i wouldnt call it a game. If you're talking about anything with actual gameplay then change that weeks into years

#

especially if you dont know c#

tranquil forge
#

and then the next day. work on the walking animations type shi, and then the next. creature animations, so on and so on

#

im solo, and im aware of the complications that holds

eternal needle
#

then weeks isnt feasible at all

tranquil forge
#

holy shit

#

id give myself 8 months maximum

#

anything above that, why work on it

#

i mean, the person who made my favorite fan game deleted his 3-4 years of work in 5 hours.

well, just to fix stuff from the constant lash out form the players due to how difficult it was, but still that had to make the dev feel a certain way

#

hats off to those individuals but in my case. i dont see how making something so simple in mind could take possible years, it could be you dont know my standards but still

#

im not abt to make the newest Ray tracing software only playable through a certain graphics card, i just want a shitty fnaf 4 remake with movement and a 3D environment with my own creatures.

ive had this idea since childhood, and now that im older, making it a thing would be fire asf.

but i do have a few standards i wanna meet for myself, and how knows if i learn it and wanna add more

#

animation isnt too hard, ik how to do that. pretty well actually, but that isnt gonna cut the rest of the 98% of my project

#

my main main question (my friend asked me to ask)

if i were to make a game. camera movement, movement to doorways, and animations leading outside the doorways, creature AI,
and modeling as a solo dev with no experience, how long would you say it would take

eternal needle
# tranquil forge hats off to those individuals but in my case. i dont see how making something so...

depends on what you're trying to exactly make. obviously it wont take a full year of everyday hard work to make camera movement and characters use animations. if I had models and animations already, it's really a 1 hour setup to get something prototyped.
the difference for you is that you need to actually learn c# and unity. lets say you write some script which helps you play animations per character. In the future, you realize this script doesnt suit your needs because you hardcoded all the strings. Suddenly you got to rewrite it. Anything referencing this script might also need an update. It takes awhile because you need to learn and will likely have to redo lots.
it doesnt really matter if the overall game is silly or simple. the code has to work at the end

tranquil forge
sour fulcrum
rocky canyon
#

building a game is simple..

#

the hard part is finishing it..

#

and having a full game-loop

tranquil forge
sour fulcrum
eternal needle
tranquil forge
sour fulcrum
rocky canyon
#

the last 20% takes 80% of the time

tranquil forge
tranquil forge
tranquil forge
#

it really was

#

the thing is, the enviorment is my own ROOM, so recreating it shouldnt be that hard?..

#

well. i gotta make 3 more rooms.

#

for, for the movement.

sour fulcrum
#

do you know how to model

tranquil forge
#

yeeeah im starting to see wtf is happening

tranquil forge
#

asset packs

#

planes

#

...materials

#

i can animate a model

sour fulcrum
#

(planes are the only one out of those three that are actually modeling but fair response)

tranquil forge
#

i made a chair so

#

yay?.

#

to think ur not even close to finishing it. damn.

rocky canyon
#

what sucks about solo developing

#

is u have to do everything

tranquil forge
rocky canyon
#

by the end of it all, ur a modeller, a graphics artist, a programmer, a music engineer, and the list goes on

tranquil forge
#

ok so for me. animation, music, sound effects, i can do that, programming, and MAYBE some modeling i gotta learn

sour fulcrum
#

The real trick is that solo devving is fake and games are collaborative 😄

tranquil forge
#

i dont see modeling being too hard unless im shooting for the stars

rocky canyon
tranquil forge
#

but if i can turn a cat into a humanoid figure then thats all the modeling i need

rocky canyon
tranquil forge
#

ur aura gives me hope

rocky canyon
#

but it also depends on whether ur a perfectionist, or just wanna get something done and out the door

#

it could be less i suppose

tranquil forge
#

... forgot to uh, tell you that

#

i cant do something unless i do it right

rocky canyon
tranquil forge
#

i will not stand for it unless it is perfect

sour fulcrum
#

perfection sucks

tranquil forge
#

so i gotta fight that, along side my capabilities

rocky canyon
#

oh ya.. ull def have a multiplier added onto ur time-management then 😄

tranquil forge
#

damn

#

idc atp

rocky canyon
#

try to be less perfect

#

especially when ur learning

tranquil forge
#

and it just, urks my soul

sour fulcrum
#

perfect games don't come out

rocky canyon
#

exactly! lol

tranquil forge
#

i dont wanna accept that rn

rocky canyon
#

if u keep at it.. you'll def adapt. and adjust ur expectations

#

so i wouldnt even worry about it anyway

tranquil forge
#

music already enough is a headache as a perfectionist so.. oh shit

tranquil forge
rocky canyon
#

u make music? wanna throw me some free soundtracks 😉 hehe

tranquil forge
rocky canyon
#

tbh i feel like music and sound design can make or break a game..

#

thats why i'll probably end up purchasing all that

tranquil forge
#

YES

#

100% AGREED

rocky canyon
tranquil forge
#

Post Shift 2 wouldnt be Post Shift 2 without its sound design

tranquil forge
#

hold on

#

i got you

rocky canyon
#

oh, this is the code channel.. just noticed.

tranquil forge
#

yeeeah i added you

sweet iris
#

` void Start()
{
moveVector = new Vector3(0, 0, 0);
rb = GetComponent<Rigidbody>();
animator = GetComponent<Animator>();
}

private void FixedUpdate()
{
rb.MovePosition(moveVector * Time.deltaTime * 15);
}

public void OnMove(InputValue value)
{
//animator.SetBool("isWalking", )
Vector2 moveValue = value.Get<Vector2>();
moveVector = new Vector3(transform.position.x + moveValue.x, 0, transform.position.y + moveValue.y);
Debug.Log(moveVector.ToString());

}`

There's a few issue with my code to move my character :

  • moveVector is set to 0, 0, 0 so at the start it moves my character to the origin
  • the character is reset to 0, 0, 0 when releasing the movement keys, I can't figure out why, I make sure that the new moveVector contains the position of the character before adding the movement.
    -because of using the player input component I have to make the movement in different parts (what movement in OnMove and the actual movement in FixedUpdate) and it's confusing to me
rocky canyon
#

specifically the parameter's MovePosition( ) is using in that example

glass dagger
#

so im currently trying to use a spring joint, attached to a player, to pull him towards a kenimatic object, the thing is even tho i set the min distance to 0 and max to 1, my player is like stuck and isnt getting pulled towards the object

rocky canyon
#

is it a rigidbody player?
when testing what if u were to disable the movement script.. wonder if it gets pulled in then..

sweet iris
rocky canyon
#

well it isn't

#

his vector has his position added into it..

#

urs does not

sweet iris
#

that's what I'm doing here :
moveVector = new Vector3(transform.position.x + moveValue.x, 0, transform.position.y + moveValue.y);

rocky canyon
#

does that run?

sweet iris
rocky canyon
#

btw u dont need to ToSring() variables

#

Debug.Log(moveVector);
Debug.Log($"my vector is: {moveVector}"); or even string interpolation like this <-

sweet iris
#

oh okay thanks

rocky canyon
rocky gale
#

is that temu olimar

rocky canyon
#

it may have something with how the actions are set up

#

no clue sorry 🍀

sweet iris
#

moving the character is supposed to be the easy part that's so frustrating :c

rocky canyon
#

ya, see that doesn't make sense to me.. b/c the code only has u setting it to 0 in teh Start() and it only runs Once

#

debug the position and the inputs in ur OnMove

#

then check the console. make sure its logging often enough (as u expect)
and that the values are what u expect

sweet iris
#

I will, thanks

sweet iris
rocky canyon
#

get that information and come back if u find anything.. or cant figure it out.. someone with some more knowledge of the input system + rigidbody might come around

glass dagger
rocky canyon
#

i would try with other objects besides the player for testing purposes..

#

maybe smaller ones, less weight, frictionless materials, etc.. just to see whats causing the issue in general

glass dagger
#

yeah ill go give that a try, just weird ive used spring joints in the past on this character so im not rlly sure whats different

sweet iris
#

it seems like the issue is with transform.position, I don't know why tho

slender nymph
#

make sure you have no other code or components that modify the transform.position, including an Animator component with a state that modifies the position even if that state is not active. if you have a state that modifies the position then you need to make sure your animator is set to not write the defaults (or whatever that property is called)

rocky canyon
#

ohh shoot ye i forgot about animation

sweet iris
#

I'm not sure if there's something wrong

rocky canyon
#

check the animation clip of idle for example.. or walk.. see if its animating the transform

#

you can view them in the animation window.. what ur showin is the animator

tranquil forge
#

where can i learn how to use C#

slender nymph
#

there are beginner c# courses pinned in this channel

untold shore
#

Hey! Having some problems with my characters 1st person camera.
The camera is supposed to move whenever the mouse is detected to move, but it won’t register even the mouse input (if so, OnMouseMove would show in the inspector when it would be played). Note that this is horrible code- I’ve never done 3d game development before so I’m dragging my foot with this 😅 feel free to say if anything looks off on the code.
Please @ me if you respond. Thanks!
https://paste.ofcode.org/tcKZUrqV3i9FKg7rZhzL3

random sand
#

do all scripts just automatically run on start and do they run per frame or delta time

wintry quarry
#

deltaTime is literally the amount of time that has elapsed since the previous frame

random sand
#

so high fps gets no advantage

wintry quarry
random sand
#

like i want something to run 60 times a second no matter frames

eternal needle
eternal needle
random sand
#

also how should i structure project? i just put everyhthing in scene

eternal needle
#

everything running is a script in your game. usually when we see beginners say they want to run at 60 times per second, they are doing something very wrong

random sand
#

i don't know how it works, i press play and stuff starts running

eternal needle
eternal falconBOT
#

:teacher: Unity Learn ↗

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

random sand
#

will try, thanks

random sand
#

btw anyone have experience with a fully physics based active ragdoll? would this be a good first project?

eternal needle
eternal needle
random sand
charred spoke
#

At least like 2 uni courses of physics worth

#

On top of being a competent coder

random sand
#

it can't be that hard

#

and humans do it from birth

teal viper
sour fulcrum
#

Real life has a faster cpu 😄

eternal needle
# random sand how much physics knowledge would i need to do this

you should be very familiar with the engine and how objects should move. its not a question of physics knowledge unless you plan to make your own physics system or a real life simulation for a character.
an active ragdoll is a LOT to setup to get it to work properly. A lot of your game is going to be designed this physics based character, that is the point of every game that uses an active ragdoll. dont be fooled, these type of games are silly and look simple because that is the design. it is not trivial to make and they are usually made by teams

#

if you try to jump into this, expect to waste a few months with a character that isnt playable

random sand
random sand
eternal needle
random sand
#

yeah probably won't try it yet

random sand
random sand
sour fulcrum
#

you would be making a physics simulation

#

or a very shit game, respectfully

eternal needle
random sand
sour fulcrum
#

What do you want this for

random sand
#

it looks cool

sour fulcrum
#

fun making yes? like is there an actual game here or do you just want to learn

random sand
#

yeah i'm looking for a first project

eternal needle
sour fulcrum
#

if its your first project then just based on all the information available for people making their first project

#

it won't finish

#

or get close

eternal needle
#

if you also think you're going to be doing anything remotely close to real life physics, you wont

#

its all through force and painfully setting up configurable joints. This wont be fun, im telling you from experience

#

after you learn the basics of how the engine works, you could maybe set up a basic ragdoll through the existing tutorials but there are not many great resources on this. It will look like complete shit and not move in any way that you want it to

random sand
#

are the animations for the ragdoll premade?

sour fulcrum
#

the kinda selling point for a ragdoll is that it's not premade

random sand
#

i thought that was what the fake ragdolls did

#

1 animation body and 1 physics body

eternal needle
# random sand are the animations for the ragdoll premade?

an animation could be premade but it doesnt matter if it is. this is the same concept as my message above for moving with IK. You dont actually move via animation. You use it to get an idea where each limb should be then move it via physics

#

this is not a fake ragdoll. what you're expecting to do with realistic physics (friction, gravity, counterbalancing) is never done in games

#

this is what i was saying is still being solved in real life

#

the "fake" ragdolls are when the actually move via animation. like people say your character in GTA is an active ragdoll which is wrong mostly. You only ragdoll when you lose control of the character

random sand
#

thanks for the help all anyone rec some starting resources?

random sand
#

and the outside forces just pushed it

onyx geyser
#

kind of an outside 'just need these checked to see if they make sense', do these make sense, i'm taking some notes and want to know if i got them right

eternal needle
# random sand i thought the animation did nothing

i could be wrong but in games like GTA, it looks moved by animation until you lose control. You can tell if for example the hand goes through a wall during a punch animation. GTA is made in a different engine so it is hard to compare, i just didn't have another example for a unity game where people claim its an active ragdoll online. I do not call this an active ragdoll myself.
In a character thats moving entirely via physics, yes the animations should not actually move the limbs. If you were to punch, the hand would stop upon hitting the wall

sour fulcrum
onyx geyser
#

understood understood

#

adding that to the notes so i don't forget

random sand
#

should i take like a course

sour fulcrum
onyx geyser
#

at least that's what i got after i finished the flappy bird

#

it got to the point i was able to solve most everything on my own after awhile

#

also probably the DIY aderall i took

eternal needle
onyx geyser
#

i feel ashamed.

#

(also just wanted to show off my silly naming conventions of 'hedgehog')

#

(i haven't figured out the use of string yet because i haven't used it yet, so it is a dedicated Mock the eggman button)

random sand
#

script can always refer to self.transform and self.gameobject? then other stuff you need to make a variable with it and drag it in

sour fulcrum
#

A script inheriting from MonoBehaviour can because those values we’re already defined there

eternal needle
ruby python
#

Hey all, I'm experimenting with generating terrain chunks and I'm having a bit of an issue that I can't seem to figure out and it's really confusing.

Can anyone take a quick look at this code snippet and see why the 'newTerrainChunk' object isn't getting passed to the BuildTerrain method on the second 'loop' iteration please? I know it's going to be something really stupid that I've missed but just can't see it.

private void GenerateGrid()
{
    xOffset = 0;
    zOffset = 0;

    for (int x = 0; x < worldSize; x++)
    {
        for (int z = 0; z < worldSize; z++)
        {
            //GameObject newWorldChunk = Instantiate(chunkPrefab);

            GameObject newWorldChunk = new GameObject("Terrain Tile " + x + z);
            newWorldChunk.transform.position = new Vector3(xOffset, 0, zOffset);
            newWorldChunk.transform.parent = transform;
                
            BuildTerrain(newWorldChunk);
            
            GameManager.Instance.GetManager<DataListsManager>().terrainChunks.Add(newWorldChunk);

            zOffset += chunkSize;
        }
        zOffset = 0;
        xOffset += chunkSize;
    }
    CenterGrid();
}

void BuildTerrain(GameObject newWorldChunk)
{
    Terrain terrain = newWorldChunk.AddComponent<Terrain>();
    TerrainCollider terrainCollider = newWorldChunk.AddComponent<TerrainCollider>();
    // Everything about the terrain is actually stored in a TerrainData
    TerrainData terrainData = new TerrainData();
naive pawn
ruby python
#

Sorry, newWorldChunk

#

My bad.

naive pawn
#

anyways you should probably just do some debugging

#

log some stuff before you pass it into the method

keen dew
#

What do you mean isn't getting passed? Does it throw an error? How do you know it isn't getting passed?

ruby python
#

It's okay, I think I've figured out the issue. Looks like the called method wasn't finishing before the next loop iteration. Seem to have fixed it by using coroutines.

hidden marten
#

!code

eternal falconBOT
hidden marten
#
    private void OnDrawGizmosSelected()
    {
        Gizmos.color = Color.red;
        Gizmos.DrawWireSphere(transform.position, attackRange);
        Gizmos.color = Color.yellow;
        Gizmos.DrawWireSphere(transform.position, sightRange);
    }
hidden marten
glad ibex
#

Can I somehow get list of all Input Axis?

naive pawn
polar acorn
final kestrel
#

!ide

eternal falconBOT
nimble apex
#

can you redefine the path/linking of an assembly?

#

u see i packed all of my external plugins nicely in a folder

#

but some plugins cannot be put inside that folder maybe

#

i just dont want to take out all of them and scattered them everywhere

rocky canyon
rocky canyon
#

nice!

nimble apex
#

ofc all lies onto delete/regen library folder, but assembly links just broken after i do that

rocky canyon
#

chatgpt mentioned Symbolic links

#

that sounds liek a can of worms i wouldnt wanna open tho lol

naive pawn
#

symlinks are just files that act like other files

lilac cape
#

Hey all, I'm watching a youtube video about interfaces to learn more about them and thought of a question during the video. In the video, it's making an IEnemy interface for the enemies and then each enemy needs to have a Attack/Defend method in the class. The video includes making a Dragon class that has an attack/defend method but what if you have different types of dragons? Would you just make a class like normal with their own attach/Defend method or is there a better way to organize this all? Maybe inheriting the dragon class with override methods? OR, maybe use a scriptable object?

public interface IEnemy
{
    void Attack();
    void Defend();
}

public class Dragon : IEnemy
{
    public virtual void Attack() { /* Default dragon attack */ }
    public virtual void Defend() { /* Default dragon defense */ }
}

Maybe do something like this to keep things organized more? Any recommendations from personal experience?

public class FireDragon : Dragon
{
    public override void Attack()
    {
        // Fire-specific attack
    }

    public override void Defend()
    {
        // Fire-specific defend
    }
}

public class IceDragon : Dragon
{
    public override void Attack()
    {
        // Ice-specific attack
    }

    public override void Defend()
    {
        // Ice-specific defend
    }
}
ruby python
#

Hey all,

I'm trying to build a grid spawning system for my game world, but I'm struggling a bit with the maths involved.

Attached pic is the layout I'm going for (needs to be scalable)

private void GenerateGrid()
{
    xOffset = 0;
    zOffset = 0;

    for (int x = 0; x < worldSize; x++)
    {
        for (int z = 0; z < worldSize; z++)
        {
            GameObject newWorldChunk;

            if ((x % 3 == 0)  || (z % 3 == 0))
            {
                    newWorldChunk = new GameObject("Terrain Tile " + x + z);
                    newWorldChunk.transform.position = new Vector3(xOffset, 0, zOffset);
                    newWorldChunk.transform.parent = transform;
                    BuildTerrain(newWorldChunk);
            }
            else
            {
                newWorldChunk = Instantiate(flatChunkPrefab);
                newWorldChunk.name = "Terrain Tile " + x + z;
                newWorldChunk.transform.position = new Vector3(xOffset + chunkSize / 2, 0, zOffset + chunkSize / 2);
                newWorldChunk.transform.parent = transform;
            }

            GameManager.Instance.GetManager<DataListsManager>().terrainChunks.Add(newWorldChunk);

            zOffset += chunkSize;
        }
        zOffset = 0;
        xOffset += chunkSize;
    }
    CenterGrid();
}

This is the latest version of the code I have, it's very wrong (was trying to get it to spawn the first version of the terrain tile every 3rd 'slot' but didn't work. 😕

Would anyone have any ideas/directions to point me in please?

naive pawn
#

if they don't share anything at all then the intermediate Dragon class would be wholly unnecessary for example

naive pawn
ruby python
green copper
#

Does anyone have any advice for achieving something akin to "normal" physics when coding values and materials?

As an example

One object, weight 40, addforce 20, linear drag 10

And the other, weight 1, addforce 0.5, linear drag 5

Will both behave roughly the same when controlled

But if you multiply the addforce by a throttle, to add in an engine power mechanic, suddenly they behave completely differently

Any tips or guides to reccomend in this area beyond just plugging in values and trying different orders of magnitude until something works?

twin pivot
naive pawn
#

also that yeah

ruby python
naive pawn
#

that would make them behave differently yeah

fickle plume
twin pivot
green copper
green copper
sour adder
green copper
#
private void FixedUpdate()
{
    updateTankDriving();
    updateDragForce();

    currentSpeed = rb.linearVelocity.magnitude;
    revFactor = currentSpeed / maxSpeed;

    currentEnginePower = Mathf.Lerp(minEnginePower, maxEnginePower, revFactor);
}

private void updateDragForce()
{
    Vector2 localVelocity = transform.InverseTransformDirection(rb.linearVelocity);

    localVelocity.x *= 1f / (1 + sidewaysDrag);
    localVelocity.y *= 1f / (1 + forwardsDrag);

    rb.linearVelocity = transform.TransformDirection(localVelocity);


}

private void updateTankDriving()
{
    if (currentSpeed >= maxSpeed)
    {
        rb.linearVelocity = rb.linearVelocity.normalized * maxSpeed;
    }
}

public void forward()
{
    rb.AddForce(transform.up * throttle * currentEnginePower);
}

public void backward()
{
    rb.AddForce(-transform.up * throttle * currentEnginePower * reverseMultiplier);
}

public void left()
{
    rb.AddTorque((0.1f * throttle * turnForce) * speedTurnFactor);
}

public void right()
{
    rb.AddTorque((-0.1f * throttle * turnForce) * speedTurnFactor);
}```
#

up, down, left, and right are called in the player controls manager's FixedUpdate script

#

I plan on using the same prefab to make player, client player, and AI tanks, so I wanted the control functions to be not intrinsicially linked

fickle plume
green copper
rocky canyon
twin pivot
#

is there a better way to write this?

if(Mathf.Round(Mathf.Abs(myGameObject1.transform.position.x - myGameobject2.transform.position.x)) <= myInt && myGameObject1.transform.position.y == myGameObject2.transform.position.y)
{
  Debug.Log("working");
}
slender nymph
#

utilize more local variables so your lines aren't 90% just chaining property accessing

green copper
#
public void setControls(float receivedThrottleControl, float receivedTurnControl)
{
    forwardControl = receivedThrottleControl;
    turnControl = receivedTurnControl;
}

private void FixedUpdate()
{
    updateTankDriving();
    updateDragForce();

    currentSpeed = rb.linearVelocity.magnitude;
    revFactor = currentSpeed / maxSpeed;

    currentEnginePower = Mathf.Lerp(minEnginePower, maxEnginePower, revFactor);
}

private void updateTankDriving()
{
    if (currentSpeed >= maxSpeed)
    {
        rb.linearVelocity = rb.linearVelocity.normalized * maxSpeed;
    }

    if (forwardControl > 0)
    {
        rb.AddForce(transform.up * throttle * currentEnginePower);
    }
    else if (forwardControl < 0)
    {
        rb.AddForce(-transform.up * throttle * currentEnginePower * reverseMultiplier);
    }

    if (turnControl != 0)
    {
        rb.AddTorque((-0.1f * throttle * turnForce) * turnControl);
    }

}

private void updateDragForce()
{
    Vector2 localVelocity = transform.InverseTransformDirection(rb.linearVelocity);

    localVelocity.x *= 1f / (1 + sidewaysDrag);
    localVelocity.y *= 1f / (1 + forwardsDrag);

    rb.linearVelocity = transform.TransformDirection(localVelocity);

}
green copper
#

I would have preferred the avoid the if statement making the forward control part longer, but I couldnt think of a better way to make sure I only implement the 50% power reduction in reverse

thick spoke
#

facing a lil problem, any ideas?

rich adder
#

doesn't make much sense what you wrote

#

also you don't write the variable again when you assign the value

thick spoke
#

ajh

scenic ginkgo
#

my character keeps getting stuck on the tiles

rich adder
#

put composite mode on the collider

scenic ginkgo
#

oh

rich adder
# thick spoke facing a lil problem, any ideas?
public class Person
{
    public string Name;
    public int Age;
    public Person(string name, int age)
    {
        Name = name;
        Age = age;
    }
}
public class TestClass : MonoBehaviour
{
    public void TestMethod()
    {
        var person = new Person("Joe", 42);
        Debug.Log($"new person: {person.Name} age : {person.Age}");
    }
}```
scenic ginkgo
rich adder
#

rgardless this is a code channel

scenic ginkgo
#

ok thx anyway

rich adder
#

also you would need to check the "Used by Composite" option

naive pawn
scenic ginkgo
#

im using unity 6 they removed
used by composite

naive pawn
rich adder
#

needs both but you select it on collider2d now ig

scenic ginkgo
scenic ginkgo
naive pawn
#

it just changed from "used by composite -> true" to "composite operation -> merge"

rich adder
#

yeah basically now its in an enum or whatever

naive pawn
#

it's still on the non-composite collider

rich adder
#

yeah idk I don't use 2D often lol

untold shore
naive pawn
untold shore
rich adder
untold shore
#

Ohh, I have that on the player object (not on camera). Let me screenshot it real quick.

#

Should I add it to the camera as well?

rich adder
#

if you're using Messages mode you need on the same gameobject that has the script

untold shore
rich adder
#

also I dont see OnMouseMove method there exists

#

i only see OnCamera

untold shore
#

Completely forgot it was like that. Thought it was similar to a naming scheme of functions, fixing that now. Thank you so much! Let me see if that fixes it all

rich adder
#

yeah SendMessages mode basically calling OnCamera or OnPlayerMovement then you capture inputs from there

#

btw don't multiply mouseInput with Time.deltaTime

#

only if you are using a controller

#

mouse input is already frame independent since you normally get the returned delta (movement since last frame)

untold shore
#

Gotcha. So remove Time.DeltaTime from these, correct?

       float MouseyCamera = PlayerCameraVector2.y * mouseSensitivity * Time.deltaTime;
rich adder
#

if it were also controller then you would add
if(controller)
input * sens * time.deltaTime
else
input *sens

untold shore
#

Thank yall! Finally getting it to work now. Yall are a huge help!!!

silver fern
#

Hi, does anyone know what kind of values ReadValue<Vector2>(); on a move action in the new input system will return?

silver fern
naive pawn
#

depends on what it's from

silver fern
#

I'm trying to migrate a script from the old input system to the new one and I'm not really getting it yet

naive pawn
#

it could be [0, 1], [-1, 1], {0, 1}, {-1, 0, 1} - but generally it'll be within -1 and 1

naive pawn
naive pawn
silver fern
#

the old script was using GetAxisRaw so it would be either -1, 0 or 1

#

and then multiplying that with speed

naive pawn
#

well no GetAxisRaw gives results in [-1, 1]

silver fern
#

ah I see

naive pawn
#

using digital inputs means you don't get the in-between values

silver fern
#

that makes sense

#

so I suppose I will have to write different movement methods depending on the input device being analog or digital

naive pawn
#

but yeah Vector2 could represent a lot of things, what values it can give depends on what it represents

rich adder
#

Debug.Log

naive pawn
#

some things you'll have to though yeah, like mouse movement vs controller input

silver fern
#

interesting

#

ok thank you

visual girder
#

Hey im looking for some help on how to find the code window or where my code is gonna be for my character

#

Most tutorials say make a script folder but after that I dont know how they pull up coding window

naive pawn
#

there's no "code window", it's an entirely separate app
do you have an IDE installed?

#

visual studio/visual studio code/jetbrains rider

silver fern
#

is .wasPressedThisFrame the only way to check if a button (specifically the jump key) was pressed?

silver fern
rich adder
#

wasPressedThisFrame typically used in polling instead fo events

silver fern
#

I see

rich adder
#

This method will disregard whether the action is currently enabled or disabled. It will keep returning true for the duration of the frame even if the action was subsequently disabled in the frame.

The meaning of "frame" is either the current "dynamic" update (MonoBehaviour.Update) or the current fixed update (MonoBehaviour.FixedUpdate) depending on the value of the updateMode setting.
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.2/api/UnityEngine.InputSystem.InputAction.html#UnityEngine_InputSystem_InputAction_WasPressedThisFrame

visual girder
ashen arch
#

!paste

#

!code

eternal falconBOT
ashen arch
#

and cs void OnJumpCanceled(InputAction.CallbackContext ctx) { isJumping = false; }

silver fern
ashen arch
#

It subscribes the 'void OnJumpPerformed()' method to that action event 'performed' You can call it whatever you want, but the event is called 'performed'

safe socket
#

Yo so im using a tilemap in a 2d game and want to rotate this thing but Idk how could someone pls tell me how pls thanks

ashen arch
#

Yup

safe socket
#

*and can it be solved using code

rich adder
#

also tiles don't get rotated, you have to put a rotated tile there.

#

they are not gameobjects, they don't have transform. They are just a sprite with some basic data

silver fern
ashen arch
silver fern
#

that did it, thanks!

warped ginkgo
#

Is it normal that when this code debugs like 50000 it gives off heavy lag? Around 30ms


 float minX = Mathf.FloorToInt((position.x - radius) / voxelSize) * voxelSize;
 float maxX = Mathf.CeilToInt((position.x + radius) / voxelSize) * voxelSize;
 float minY = Mathf.FloorToInt((position.y - radius) / voxelSize) * voxelSize;
 float maxY = Mathf.CeilToInt((position.y + radius) / voxelSize) * voxelSize;
 float minZ = Mathf.FloorToInt((position.z - radius) / voxelSize) * voxelSize;
 float maxZ = Mathf.CeilToInt((position.z + radius) / voxelSize) * voxelSize;

 for (float x = minX; x <= maxX; x+=voxelSize)
     for (float y = minY; y <= maxY; y+=voxelSize)
         for (float z = minZ; z <= maxZ; z += voxelSize)
         {
             Vector3 voxelPos = new Vector3(x, y, z);
             float distance = Vector3.Distance(position, voxelPos);

             if (distance > radius) continue;

             float delta = Mathf.Clamp01((distance / radius));
             updates.Add(new VoxelUpdate(voxelPos, delta, VoxelUpdate.Type.Min));
         }
 Debug.Log(updates.Count); ```
#

its just a loop and some random calculations basically, but still, 30ms? just for 50000 iterations?

rich adder
#

i mean also depends on the operations you're doing

#

Vector3.Distance can be quite expensive too

#

square root calc aint so cheap

warped ginkgo
#

hm
i guess so

#

but then its not looking good for my game...

warped ginkgo
#

Maybe i could optimise such stuff with unity jobs or sth like that, do you think that could help (if youve heard of it)?

rich adder
#

its possible but not 100% sure also just guesstimating its square rooting, there could be more. Also you'd have to profile it in a build too and see if its same lag

warped ginkgo
#

yeah i get it, but theres generally a lot going on later with my code. The updates are getting applied and some other things happen which leads to like 120ms lag in total, which is terrible. So fixing the square rooting wont really help that much

#

I guess i just need a quantum computer for my project lol

copper jasper
#

Why cant I use .enabled on anything Im trying to disable a objects component

rich adder
copper jasper
rich adder
rich adder
#

its probably not a component

copper jasper
#

its a image

rich adder
#

the type

copper jasper
#

also i tried with other objects too

#

e.g rigidbody

copper jasper
rich adder
#

rigidbodies dont have such property

rich adder
copper jasper
#

like the normal image object

night raptor
rich adder
copper jasper
rich adder
#

in the code...the inspector is irrelevant

rich adder
eternal falconBOT
rich adder
#

not a screenshot

#

this is not the Image from UnityEngine.UI

copper jasper
#

wdym

rich adder
#

you can hover over it in IDE and you should see the original definition and which namespace is from

rich adder
#

hence the missing namespace

copper jasper
#

but i cant use enabled on anything

rich adder
#

only from Components that inherit Behavior

copper jasper
#

like even in my movement code

#

the tick thing

rich adder
#

yes I understand but thats not the Image you referenced.

#

that tick only exists and does anything if the Object has one of the MB methods

untold shore
#

Hey, sorry for another question in same day - having some problems with wasd and the input system.
Whenever the camera turns, the player still has the wasd (1,0) as if it was the previous direction. So if they turned west and pressed a for left, they would walk forward.
I’ve attempted to rotate my player model(the player object) as well, yet that does nothing. Here is the script for player movement and the input system.
https://paste.ofcode.org/KrKFmfzZiXa8H5zYCn7xGa
Is there any reason for this? (Please @ me if you respond, thank you so much!)

copper jasper
#

nvm

#

im so confused

rich adder
copper jasper
#

idk 😭 i just wanted to disable the image and get its SourceTexture to change it via script

rich adder
#

UnityEngine.UI

copper jasper
#

But I get the image like this Transform hotbarSlot = hotbar.transform.Find(avalibleSlot.ToString());

#

how am i supposed to get the image

rich adder
#

thats a different thing entirely

#

we're talking about the code for Image

#

where did you put the code?

copper jasper
#

player

#

its a hotbar system

rich adder
#

no the one you sent in the discord..

copper jasper
#

ye

#

player

rich adder
#

lord

#

where did you put the code you sent on discord

#

did you delete the message

copper jasper
#

ye

rich adder
#

why

#

I'm trying to show you something and you deleted it lol

copper jasper
#

didnt want people seeing lol

#
using System.Collections.Generic;
using JetBrains.Rider.Unity.Editor;
using Microsoft.Unity.VisualStudio.Editor;
using UnityEngine;

public class InventoryHandler : MonoBehaviour
{
    private GameObject currentItemHeld;

    [SerializeField] private Canvas hotbar;
    [SerializeField] private int maxSlots = 1;

    private Dictionary<string, int> inventory = new Dictionary<string, int>(); // Current items in slots
    int getAvalibleSlot()
    {
        for (int i = 1; i < maxSlots; i++)
        {
            if (!inventory.ContainsValue(i))
            {
                Debug.Log("Slot " + i + " is empty");
                return i;
            }
            else
            {
                Debug.Log("Slot " + i + " is not empty");
            }
        }

        return -1;
    }

    void addItemTooSlot(GameObject item)
    {
        int avalibleSlot = getAvalibleSlot();

        if (avalibleSlot < 0) { Debug.Log("No slots" + avalibleSlot); return; }

        inventory[item.name] = avalibleSlot;

        Debug.Log("Picked up: " + item.name + " Into slot: " + avalibleSlot);
        Debug.Log("Current slots occupied: " + inventory.Count);

        Transform hotbarSlot = hotbar.transform.Find(avalibleSlot.ToString());
        Transform itemPreview = hotbarSlot.Find("ItemPreview");
        Image itemPreviewImage = itemPreview.GetComponent<Image>();

        itemPreviewImage.enabled = false;
    }

    public void pickUp(RaycastHit itemHit)
    {
        GameObject item = itemHit.collider.gameObject;

        addItemTooSlot(item);

        Destroy(itemHit.collider.transform.gameObject); // Destroy the item cause its in ur inventory now
    }
}
rich adder
#

not to worry , it aint special..

#

especially broken

copper jasper
#

😭