#πŸ’»β”ƒcode-beginner

1 messages Β· Page 809 of 1

native willow
#

Srry, didn't now that.

naive pawn
#

no, like why do this

native willow
#

Im delete my script rn

subtle mulch
#

it's not that

#

just, it's specific to their game

#

you cannot make it work out of the box for yours

#

you have to adapt it

native willow
#

Should i make my own?

subtle mulch
#

or edit that to make it work

native willow
#

Cuz, I'm mostly use ChatGPT

subtle mulch
#

oh god...

teal viper
#

I suggest learning first.

#

!learn

radiant voidBOT
subtle mulch
#

do not use ChatGPT UNLESS you know C# and Unity first

native willow
naive pawn
#

ditch the AIs lmao. they won't help you, they'll just give you a facade

subtle mulch
#

making the whole code for you is not the right usage tho

native willow
#

Bro, i ain't dumb. Someone who I've knew used to teach me about Unity. I remember the code very well.

subtle mulch
#

well, then fix the code you have

#

those are basic errors

#

and the IDE already tells you why it is throwing them

sour fulcrum
naive pawn
sour fulcrum
#

It’s very clear

subtle mulch
native willow
subtle mulch
#

that's why i said only when you already know C# and unity

naive pawn
#

it's quite counterproductive and harmful to suggest that AI would help tbh

sour fulcrum
native willow
#

Well, do i had to watch some YouTube Tutorials then and instead of using ChatGPT?

subtle mulch
naive pawn
#

that's hilarious

#

wish we still had the echo chamber to redirect this

sour fulcrum
#

They killed it? Nooo

naive pawn
subtle mulch
#

well, i do use it for stuff like that, and it's working fine

naive pawn
#

good for you.

native willow
naive pawn
#

!learn

radiant voidBOT
sour fulcrum
subtle mulch
#

as i said, if used correctly it's actually helpful

sour fulcrum
#

Nah

naive pawn
#

we do not need to have this discussion, it's not gonna be productive

teal viper
naive pawn
#

-# it's not regarded well in most if not all communities ive seen lmao

subtle mulch
#

ah ok, thx

native willow
#

Watchin this rn.

subtle mulch
#

use unity learn pls...

#

you need the basics of C# first

sour fulcrum
#

Not necessarily

native willow
subtle mulch
#

!learn

radiant voidBOT
teal viper
naive pawn
native willow
fringe fern
#

Hello, good night, could you help me?
How do I store a certain object in a variable so I can access it later?
For example, here is my code for instantiate my objects:

for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { cellPosition = new Vector3(i, 0, j); Instantiate(terrain, cellPosition, Quaternion.identity); //Stores the instantiated terrain blocks in the cells array for later access } }

I would like to store each terrain block so I could access them later easily. Any tips? Even what to read on docs would help as I am incapable of coming with a solution.

wintry quarry
#

for something like this though you'd probably want a 2D array or a Dictionary<Vector2Int, Cell>

#

so your actual question doesn't seem to be "how do I store something in a variable" it's maybe "how do I use collection types that are addressable by a 2D coordinate?"

ivory bobcat
# fringe fern Hello, good night, could you help me? How do I store a certain object in a vari...
public ...[,] terrains;
public Vector2 size;``````cs
terrains = new ...[size.x, size.y];
for (int x = 0; x < size.x; x++)
{
    for (int z = 0; z < size.y; z++)
    {
        cellPosition = new Vector3(x, 0, z);
        var instance = Instantiate(terrain, cellPosition, Quaternion.identity);
        terrains[x,z] = instance;
    }
}```<https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/arrays#multidimensional-arrays>
fringe fern
#

I figured I would need a multidimensional array, but didn't know about this "instance" command.

wintry quarry
#

that's just a variable name

#

it can be whatever you want

fringe fern
#

Indeed, I am reading the docs now and realized what you did.

#

Don't know how I didn't realize it before.

ivory bobcat
#

It's cumulative knowledge, congratulations.

fringe fern
#

πŸ™Œ

dapper ibex
#

hi, i have a superclass with a private field called name with getter and setter. i call the setter in my child class Awake() function but when i try to use the field later it is an empty string. does anyone know why

frosty hound
#

You can't modify private variables outside of the class. Make it protected instead.

#

Also is that child class being inherited by another that is overriding the awake?

dapper ibex
#

am i allowed to paste code

wintry quarry
wintry quarry
radiant voidBOT
dapper ibex
#
public abstract class Projectile : MonoBehaviour
{
    // super class for all projectile objects in the game
    private int damage;
    private int shrapnelCount;
    private float explosionForce;
    protected string projectileName;
    protected void SetName(string newName)
    {
        projectileName = newName;
    }
    public string GetName()
    {
        return projectileName;
    }

public class LeadBullet : Projectile
{
    void Awake()
    {
        SetName("Lead Bullet");
    }
    void Start()
    {
        initiate(20, 2, 5);
    }
}
wintry quarry
dapper ibex
#

im trying to display the GetName() on the screen but it comes out blank

wintry quarry
#

you need to show the full code, including the code that tries to read GetName

#

I will say though, this pattern is not ideal

grave mesa
#

Are you placing the two classes inside the same file or just pasted it all together?

wintry quarry
#

why not just:

// in the parent class:
public abstract string Name { get; }

// In the child class:
public override string Name { get { return "Lead Bullet"; } }```
dapper ibex
#

i just pasted them together

grave mesa
#

Name can be public IMO, no need for protection in some of those variables

wintry quarry
#

the backing field and the setter shouldn't be public

#

there's a public accessor, that's fine

dapper ibex
#

do you know why my code didnt

queen adder
#

can someone help me??? i keep building but my apk file isnt there and it is deleted

wintry quarry
#

It could have been lots of things

#

FOr example were you perhaps trying to get the name of a prefab?

dapper ibex
wintry quarry
wintry quarry
queen adder
wintry quarry
#

so you were never setting the name

queen adder
#

thx

dapper ibex
#

ohh ok thx for help

high mauve
#

Hi everybody
Can some one help me with map magic 2

radiant voidBOT
# naive pawn !ask

:thinking: Asking Questions

:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #πŸ”Žβ”ƒfind-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.

-# For more posting guidelines, go to #πŸŒ±β”ƒstart-here

dusky rain
#

Hey everyone Im working on learning Unity.

elfin pike
#

Don't use chat bot given code. Always when i use it, I'm going back and rewriting everything myself.

ornate cosmos
quasi fulcrum
#

Hi, how do I learn to write code? I already watched tutorials and understand what stuff in C# does but I can't write a single line πŸ₯€

silk night
#

!learn

radiant voidBOT
ornate cosmos
#

first, find a thing u wanna make, then learn how to make it, not just learn "how to write code"

#

its too broad

tired python
#

does anyone know what happens when you release from a pool internally? does the element get released from just the pool or from all collections which have that object present in them?
I just found out that,

            {
                if (size >= Vector2.Distance(enemiesInRange[i].transform.position, transform.position))
                {
                    tempListOfEnemiesToRemove.Add(enemiesInRange[i]);
                    _duckPoolContainer._duckpool.Release(enemiesInRange[i].gameObject);
                }                
            }
```will work but 

for (int i = 0 ; i < enemiesInRange.Count ; i++)
{
if (size >= Vector2.Distance(enemiesInRange[i].transform.position, transform.position))
{
_duckPoolContainer._duckpool.Release(enemiesInRange[i].gameObject);
tempListOfEnemiesToRemove.Add(enemiesInRange[i]);
}
}

silk night
tired python
ornate cosmos
#

object pool in unity?

silk night
silk night
ornate cosmos
#

in unity object pool version, release just means unactive it, not actually dispose it

tired python
ornate cosmos
tired python
#

nothing is ever "released" from the pool, it's enabled or disabled unless pool size reaches max size possible

ornate cosmos
#

yeah, release just means execute the method u put it in before like "OnRelease"

#

so u said u found a error like ArgumentOutOfRangeException

tired python
#

question remains, why does it effect other collections having the same object

ornate cosmos
#

i think maybe its other things wrong

silk night
#

in which of the lines does that error trigger?

#

yeah i think the error is unrelated to pooling

tired python
ornate cosmos
#

and u can try to use debug mode to run each code to see wut actually is happening

#

to see why there is a error

tired python
#

in this scenario, after the release happens, enemiesInRange decrements in size...

ornate cosmos
#

WUT

#

where is the part u set this object pool

silk night
#

yeah, we need to see the full code here πŸ˜„

tired python
#

sry

silk night
#

also the duck pool container please

tired python
#

as in the script which has the actual duck pool with all of its functions listed out?

silk night
#

yes, where you create the pool and stuff

tired python
#

wait

#

maybe it ends up destorying the duck or something

#

so instead of ReturningDucktoPool, OnDestroyDuck is run

silk night
#

If the pool has reached its maximum size then the instance is destroyed using the method passed as the actionOnDestroy parameter to the constructor.

tired python
#

but it does not

silk night
#

yes, can happen

tired python
#

only one duck

ornate cosmos
#

i think u triggered ArgumentOutOfRangeException cuz u changed the size then it happenes

#

but yeah, idk wut actually happen

#

u said u already debug it

#

no change with list or count of objects?

tired python
#

the count does end up changing

#

lemme show you the logs wait a bit

ornate cosmos
tired python
ornate cosmos
#

and u call SetActive in OnRelease, maybe u made a script somewhere did something like "OnDisable"

#

try to add a monitor for this list, and get in OnRelease method

#

to see when the list changed, and i wonder if there are any other scripts editing this list?

tired python
ornate cosmos
#

unlucky there is no voice chat in this server, i was thinking we can watch wut happens while u screen share it

#

but yeah, try to debug it in OnRelease method

tired python
#

oh! i never noticed this server did not have a vc

ornate cosmos
#

just check when and where the list changed

echo ruin
#

I’m curious as to whether Unity uses spatial partitioning when checking for collisions?

ornate cosmos
#

cuz "Object Pool" donest change it

tired python
#

i will add a log then

ornate cosmos
#

firstly detect by AABB box then use it

tired python
# ornate cosmos just check when and where the list changed
private void ReturningDucktoPool(GameObject duck)
    {
        //Debug.Log("This is being called to release the duck.");

        //reseting spline animate of the duck
        SplineAnimate splineAnimate = duck.GetComponent<SplineAnimate>();

        //recent omition
        // splineAnimate.Restart(true);
        splineAnimate.ElapsedTime = 0;
        duck.SetActive(false);
        Debug.Log("Disabled was called");
    }

    private void OnDestroyDuck(GameObject duck)
    {
        //Debug.Log("This is being called to destroy the duck.");
        Destroy(duck);
        Debug.Log("Destroy was called");
    }
#

i am srsly confused, why would disabling the enemy duck end up changing enemiesInRange

silk night
#

log the count of it before and after calling release

#

(or inspect with debugger)

tired python
tired python
silk night
#

where are you calling the RemoveEnemies method?

#

on trigger exit of another class?

#

no he has a dedicated RemoveEnemies method at the bottom

tired python
#

sry

ornate cosmos
#

it will be better if there is a vc lmao

silk night
tired python
silk night
ornate cosmos
#

or maybe if u can make it as a unity package then send it

#

and we can import it to debug

ornate cosmos
silk night
grave mesa
#
{
    // Instance
    public static GameManager Instance { get; private set; }

    // States
    public enum GameState
    {
        Idle,
        Building,
        Playing,
        Pause,
        GameOver,
    }

    // Events
    public class OnGameStateChangedEventArgs : EventArgs
    {
        public GameState state;
    }
    public event EventHandler<OnGameStateChangedEventArgs> OnGameStateChanged;

    // Vars
    private GameState state;

    private void Awake()
    {
        // Instance
        Instance = this;
    }

    private void Start()
    {
        // Init
        state = GameState.Idle;


    }

    private void Update()
    {
        switch (state)
        {
            case GameState.Idle:
                HandleIdleInput();
                break;
            case GameState.Building:
                HandleBuildingInput();
                break;
            case GameState.Playing:
                break;
            case GameState.Pause:
                break;
            case GameState.GameOver:
                break;

        }
    }

    private void HandleIdleInput()
    {
        GameInput.Instance.GetInputActions().Player.Build.performed += (_) =>
        {
            // Start building mode
            SetState(GameState.Building);
        };
    }

    private void HandleBuildingInput()
    {
        GameInput.Instance.GetInputActions().Player.Build.performed += (_) =>
        {
            // Going back to idle mode
            SetState(GameState.Idle);
        };
    }

    private void SetState(GameState state)
    {
        this.state = state;

        OnGameStateChanged?.Invoke(this, new OnGameStateChangedEventArgs
        {
            state = this.state
        });
    }```

Is this a good way to do a game state machine? im starting to learn and making my first game, it will be a tower defense.
#

oop, badly embeded

radiant voidBOT
radiant voidBOT
tired python
#

lol

silk night
#

i am 99% sure disabling the object triggers on trigger exit

ornate cosmos
#

if u wanna make it more better, separate all the states as a single file

grave mesa
#

how so?

ornate cosmos
#

each state is a class include reference of state machine, and also OnUpdate, OnEnter, OnExit

silk night
ornate cosmos
#

state machine manger when to switch and call them

silk night
ornate cosmos
#

lmao

grave mesa
tired python
#

what is a good practice to follow in such a case?

ornate cosmos
#

lmao

silk night
silk night
ornate cosmos
#

so u actually change the list somewhere lmao

tired python
silk night
#

Yeah i wasnt sure if you need to wait for next physics tick but it seems that disabling a gameobject broadcasts trigger exit to all current observers instantly

hardy wing
#

How would I properly start with developing stuff in Unity? I feel like I know how to use the basic infrastructure of Unity and have decent experience with programming in general as well. I just don't know where to start. I have no ideas. Moreover I don't have a game in mind to develop, I just wanna develop but have no clue what to start with 050_Sadge

hexed terrace
#

Recreate a retro game, with the intent to be learning and not release.

Something like pong, space invaders, breakout, asteroids

silk night
#

My first game that i recreated was Kirby 64 Checkerboard Chase πŸ˜„

#

was a good learning experience

grave mesa
#
{
    // Instance
    public static GameManager Instance { get; private set; }

    // States
    private IGameState currentState;
    private GameIdleState gameIdleState;
    private GamePlayingState gamePlayingState;
    private GamePauseState gamePauseState;
    private GameGameOverState gameGameOverState;
    private GameBuildingState gameBuildingState;

    // Events
    public class OnGameStateChangedEventArgs : EventArgs
    {
        public IGameState currentState;
    }
    public event EventHandler<OnGameStateChangedEventArgs> OnGameStateChanged;

    private void Awake()
    {
        // Instance
        Instance = this;
    }

    private void Start()
    {
        // Initial state
        SetState(gameIdleState);

        // Input Events
        GameInput.Instance.OnBuildingKeyInteraction += GameInput_OnBuildingKeyInteraction;
    }

    private void GameInput_OnBuildingKeyInteraction(object sender, EventArgs e)
    {
        // You should only be able to switch to build state if you are in idle state
        if (currentState == gameBuildingState)
        {
            SetState(gameIdleState);
            return;
        }
        if (currentState == gameIdleState) {
            SetState(gameBuildingState);
            return;
        }
    }

    private void Update()
    {
        currentState.UpdateState();
    }

    private void SetState(IGameState gameState)
    {
        currentState = gameState;
        gameState.EnterState(this);
    }
}```

First steps trying to implement FMS with the game manager, what do you guys think? i guess i can now handle each transition in the main class and each behavior in the respective UpdateState(); for each file
silk night
#

makes it easier to expand

grave mesa
silk night
#

easy change though

grave mesa
#

Then im really not getting the logic or how to combine FMS with that, my poor mind

#

gotta read more

tender mirage
grave mesa
#

So, dictionaries are basically tupples/maps that can handle a key/value entry, so i just can identify a state with the enum and access or handle the state by getting the value...

#

so, if i get it right, should be like...

#
public static GameManager Instance { get; private set; }

// Enum keys for states
private enum GameStateType
{
    Idle,
    Playing,
    Pause,
    GameOver,
    Building
}

// States container
private Dictionary<GameStateType, IGameState> gameStates;

// Current state tracking
private IGameState currentState;
private GameStateType currentStateType;

// Events
public class OnGameStateChangedEventArgs : EventArgs
{
    public IGameState currentState;
}
public event EventHandler<OnGameStateChangedEventArgs> OnGameStateChanged;

private void Awake()
{
    // Instance
    Instance = this;

    // Initialize states dict
    gameStates = new Dictionary<GameStateType, IGameState>
    {
        { GameStateType.Idle, new GameIdleState() },
        { GameStateType.Playing, new GamePlayingState() },
        { GameStateType.Pause, new GamePauseState() },
        { GameStateType.GameOver, new GameGameOverState() },
        { GameStateType.Building, new GameBuildingState() }
    };
}

private void Start()
{
    // Initial state using enum
    SetState(GameStateType.Idle);

    // Input Events
    GameInput.Instance.OnBuildingKeyInteraction += GameInput_OnBuildingKeyInteraction;
}```
#

forgot to indent but, this is what i get

#

im still trying to comprehend the differences, but i can see its easier to expand, instead of hard initializing them you do it on the awake and handle it differently...

ornate cosmos
#

then learn it

small osprey
#

Do developers use tutorial/forums while make they games for things they dont know how to do

cosmic dagger
small osprey
hardy wing
#

Problem with my projects so far usually was that I just get hung up on character controllers and then just drop Game Dev altogether 050_Sadge

loud pier
#

I do wanted to create my own games, problem is mentally block on what to do and relays on youtube tutorials

ivory bobcat
loud pier
#

bad english

ivory bobcat
#

Post code appropriately

#

!code

radiant voidBOT
silk night
silk night
#

that way you dont have to call from a state back to the manager

grave mesa
#

i saw something like that

#

like (currentState != previousState) { state.Exit() , currentState, state.Enter() }

something like that

#

having an exit method to handle the closure and transitioning to the next state i guess

ornate cosmos
hardy wing
ivory bobcat
ornate cosmos
#

most programmers dont have any audio sources to use

#

use default one is fine

hardy wing
#

Do you prefer if I just didnt do anything at all

#

Instead of doing some prototyping that might lack game feel for now

ivory bobcat
#

From what I've seen, most solo devs have problems creating full blown games because they focus on what they're good with rather than the necessities of the entire game development life cycle. It's usually recommended to start small and get something out there to understand the workflow (of what's important) rather than build upon what you're already comfortable with. You're eventually going to have to work on what you may not be comfortable with.

silk night
solar hill
#

I dont think thats nescessarily true

silk night
#

in theory it shouldnt be as hated, but the occurence of actual asset flips kinda destroyed that path

solar hill
#

plenty of really successful games use third party assets without issue

#

that whole "asset flip" thing really died out back in 2017

#

because before that unity itself was notorious for the exact same thing

ivory bobcat
solar hill
#

people saw any and all unity games as asset flip garbage, hilarious because something very similliar is happening to unreal engine now

ornate cosmos
#

There is no problem with using assets, it's just that some assets are too popular, which can be a bit disruptive to immersion

hardy wing
#

don't start at all?

#

because as of now i don't "get something out to understand the workflow"

ivory bobcat
# hardy wing don't start at all?

I do not understand your statement. I'm suggesting that since you're already good with programming to focus on the other core necessities.

silk night
#

only that people think ue = low performance
cause many devs think nanite = instant performance and it backfires instead

hardy wing
solar hill
#

"UE slop" is becoming a very annoying and common criticism for any and all games released in the past few years

grave mesa
solar hill
#

Thats not really true nor how that works

#

and that sort of thinking is what leads people to dismiss any and all games made with UE

#

People who dont know what they are talking about love saying things they have basically convinced themselves to be true

grave mesa
solar hill
#

Youre missing the point

grave mesa
#

huh

solar hill
#

Unreal Engine is not "unoptimized" by itself, thats not how engines works....

grave mesa
#

Who is saying UE is unoptimized? πŸ‘€

solar hill
#

thats the point

grave mesa
solar hill
#

people who have no clue how game development works

grave mesa
solar hill
ornate cosmos
#

UE is indeed quite laggy, its editor

solar hill
#

just google "ue slop" or something and be greeted with thousands of videos and posts

silk night
#

Its developers thinking that they have performance by default just cause they use a specific engine that are the problem
Nanite was promoted as the one solves all solution for insane meshes, problem is that only works if you know how to use it, and many people dont and think it still works

solar hill
#

Gamers in general have convinced themselves that because they play games they suddenly know about creating games themselves

silk night
#

I think we are going a bit offtopic here though (coding channel)

solar hill
#

You might like to eat food but that doesnt make you a chef

ornate cosmos
#

However, if a beginner uses UE to play a game, such as developing a game with blueprints, there are many things he can do at the initial stage, because many things are simplified, and UE also has many built-in functions, but it must be said that an ordinary developer can also easily create a too laggy game with UE

grave mesa
#

Well, im done implementing the FMS with what i have done in the game, working so far, need to start working on EnemyAI and player base / towers logic, but from what i got you can basically extrapolate FMS to any state machine you want, so its pretty useful for NPC_AI in general πŸ€”

ivory bobcat
loud pier
#

hmm, I guess I will try creating basic retro games

#

then try to move on 2d jrpg

#

after this school sem

ivory bobcat
#

Game development is not easy (seriously), best of luck UnityChanThumbsUp

hardy wing
loud pier
#

there is some problem Im been having in 2d rpg

#

how would I be able to create a fight mechanics

ornate cosmos
#

think

#

lmao

hardy wing
loud pier
#

I'mma go start a concept first

ornate cosmos
#

If you can't build overly complex character controllers, then make it simpler

ivory bobcat
# ornate cosmos thats how it is

Definitely. And yet you may even find yourself not even being able to finish these simple clones. Slowly increasing the difficulty of making complete games (not just templates) will eventually allow you to get a feel for what kind of game you can tackle and actually finish.

ornate cosmos
#

real

hardy wing
ornate cosmos
#

i dont play that game

hardy wing
#

I think I often tend to get hung up on recreating the exact same feel as the game I'm trying to recreating though instead of recreating the core mechanics

ivory bobcat
#

Implementing the specific physics (rb doesn't give you game physics, it gives you rb physics) is a challenge in itself - to make it feel exactly the same as the originals.

hardy wing
#

What is your implied difference between game physics vs. rb physics here?

ivory bobcat
#

Game physics implying fake physics

hardy wing
#

Or do you just mean manual velocity-based movement vs. force-based movement?

hardy wing
ivory bobcat
#

Elaborate on your question. I'm informing you that getting the physics for smb to feel right can be pretty daunting for beginners. It was pretty fun to create the animation curve for smb/platformer jump times.

gentle laurel
#

Hello, I see Unity 6.3 Modules defaults to VS-2022, is this because Unity has compatibility issues with VS-2026? Or am I safe to use VS-2026

ivory bobcat
#

I'm pretty certain your IDE version isn't a concern

gentle laurel
#

Awesome, I assumed as much but know better than to work off assumption. Thanks for confirming!

hardy wing
ivory bobcat
hardy wing
ivory bobcat
#

Kinematics

hardy wing
#

i have a rough reminder that it didnt actually check physics but i never understood how its useful then

#

does it check for collisions at least?

worn nymph
#

how do I properly add situational stuff to a shader? suppose a shader always does the color of a character but also sometimes adds blood into the mix. 90% of the time the character isnt bloody but the shader would still process the blood (and not draw any red cuz some blood parameter is 0) if its just another step. do I add a branch that cuts away blood logic if false or do I change materials between a shader with and without blood math? whats the play?

wintry quarry
#

there are probably other options too

worn nymph
grand snow
#

You use shader variants instead

#

Small branches are fine but big ones are not because the gpu must compute both cases and then pick one result

#

a branch that is just a single value selection is okay for example

#

but a lerp or multiplication to reduce a value works just the same

rapid stump
#

guys, i need to know, is there any easy way to do billboard UI which overlapping gameobjects?

polar acorn
#

Your UI should probably be on a canvas which won't need any bilboarding because it's attached to the viewport

rapid stump
grand snow
#

If its screen space overlay UI following some world pos then that will work

#

Im not sure if the render queue can be changed for world ugui

rapid stump
#

but i want something like this

grand snow
rapid stump
wintry quarry
grand snow
#

if so re read what i said before πŸ˜†

wintry quarry
#

if you want the ui intermingled or behind the objects, use screen space - camera and adjust the plane distance to be behind the world objects

grand snow
#

You want screen space UI that uses code to follow some Transform or world position

rapid stump
#

is there a way to do this or nah?

grand snow
#

Either code or shader fuckery is needed

stone oar
#

hey guys, got a question: what would be the best way to store dialogs with? currently I'm using SO's with an array of name+line elements, since they're very easy to edit and iterating, but I am not sure if they're very scale-able when it comes to translating into different languages. especially when translation might be manual (aka by hand), all things considered. should I switch to json in that case, or keep SO's and do something else? much appreciated

rapid stump
#

darn it

grand snow
#

slapping world ugui inside gameobjects is easy but not good

rapid stump
#

alr, thanks for help

solar hill
grand snow
#

But why?

solar hill
#

To force it to render on top always

grand snow
#

that is even worse

solar hill
#

Β―_(ツ)_/Β―

#

i seldom use them so i dont know was just throwing it out

grand snow
#

loads of ugui canvases in world are slower and a worse solution perf wise

#

There is opportunity for batching if all done in 1 canvas

solar hill
#

Oh wait

#

I assumed this was for some kind of hud or something

grand snow
#

The examples dont seem to have any perspective

rapid stump
solar hill
#

nvm you already linked it

grand snow
#

in ugui you can assign that to a rect transforms position property (if screen space overlay is the mode)

untold shore
#

Quick question - is it a good idea to connect UI to a script on every frame? (This is really psuedocode, because I havent written it:) So like on Update it would change a number on the canvas (UI) to the corresponding variable. Is that a good idea, or will it cause more optimization problems?

wintry quarry
untold shore
#

Gotcha, thank you!

grand snow
# untold shore Gotcha, thank you!

Events are great for this. Your ui can subscribe to be notified when something has changed.
UITK bindings respond on change and pure object binding can also be setup to do this

untold shore
grand snow
#

UnityEvents are a replica of events but allow inspector subscription (with worse performance overall)

untold shore
grand snow
#

A quick example:

public event Action<Bullet> OnBulletSpawned;
//Elsewhere
var bullet = GetNewBullet();
OnBulletSpawned?.Invoke(bullet);
untold shore
#

Thank you so much. I never wouldve even thought of something like this. Honestly sometimes forgot how big coding is, lol

rancid tinsel
#

why do these have different numbers of characters if A. there are no changes, and B. it doesn't look like there are any differences?

rancid tinsel
polar acorn
#

So, every line break is two characters in the first one. 24 line breaks = 24 extra characters

rancid tinsel
#

ah

#

I thought you meant the empty space at the end

#

interesting - why would they be different?

polar acorn
rancid tinsel
#

I mean in the sense of why would the project have two different ones?

#

like what caused the mismatch

polar acorn
#

Different programs using different line breaks.

rancid tinsel
#

also I'm surprised github doesn't pick up on this

polar acorn
#

Git even tells you when it does so when you commit it

rancid tinsel
#

oh so is it based on your local git settings?

#

its a group project so that would make sense

polar acorn
#

"[File] contains [Unix/Windows] style line endings and will be converted to [Windows/Unix] style"

grand snow
#

git and IDEs love to fight over the line endings to use

rancid tinsel
#

I've noticed that, was super confused on what it meant lol

grand snow
#

if you use git via cli it will warn about it changing the line endings next time

lost pilot
#

Hello guys i have a really good game idea in my opinion im working with cinema 4d unity and mixamo for most of the Animatios but im very new to all of that but its really fun for me to work on my Game Projekt and i wanted to ask if someone here maybe is a little smarter or knew more than me and maybe want to help me with my project

solar hill
#

If youre looking for collaborators

radiant voidBOT
#

: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**

lost pilot
#

Nah im fine for now its just a little hard to work bc i never did smt like this and for most of my questions i use the claude ai but if i have a specific question in the future i will ask here

solar hill
#

Feel free to do so, we are happy to help UnityChanThumbsUp

lost pilot
#

Thank you really much man this game is gonne be very good and now i got a place for questions xD

dire holly
#

hey can someone help me make an first person player controller πŸ˜„ ?

polar acorn
prisma shard
#

Does c# ever get fun because tbh it seems very robotic logic aside from flexible classes. Maybe it's because I lean more towards art since it's my hobby but I feel I'm going to really dislike working with this code as I get better. Just from boredom notlikethis

subtle mulch
#

if you want fun, go with ECS, lol

polar acorn
#

I mean, it's code. It's a set of procedural instructions. If it's ever not seeming robotic then you've got a major problem on your hands

grand snow
#

C# fun
C++ ehh
js 😭

#

rust πŸ¦€

subtle mulch
#

js is pure chaos XD

#

luckily ts saves it a bit

prisma shard
#

Why do people even use Java anyway. I know it was big in the 2000s. Like many browser based PC games used it. I thought C was already mature by then

subtle mulch
#

java is by far the most used language

#

SIMs use it and nearly every micro card

grand snow
#

back then WORA (write once run anywhere) was big

subtle mulch
#
  • mcus and more
prisma shard
#

Is it really though? I literally only ever heard it talked about negatively

subtle mulch
#

java is pretty much as fast as c

grand snow
#

lots of things use java
Hell android uses the JVM

subtle mulch
#

and can run nearly everywhere

subtle mulch
grand snow
#

yea its mad. Dont dvd players and other things use java too?

subtle mulch
#

prob

grand snow
#

I remember my old phones with java games too

#

Android uses java because it was a great way to support multiple instruction sets but now its kinda pointless as id say almost all android devices are ARM and then mostly arm 64

subtle mulch
#

well, you could write c++ apps for android if you want i think

#

but gl accessing android APIs

grand snow
#

Yea lots more things use the NDK including unity when using il2cpp

polar acorn
#

A C Program needs to be compiled for a specific environment. Java only needs the JVM to be compiled for that environment, then can run any java application.

#

If you're writing software for a smart toaster it's much easier to just port the JVM to it and then anyone anywhere can write code for it without you needing to release tech specs for your toaster for them to do it

hardy wing
#

you compile it once and it runs everywhere

grand snow
#

9 billion devices and stuffs wow

subtle mulch
#

i think now it's WAY more than 9 billion

hardy wing
#

but i understand why people would want to use it

grand snow
hardy wing
#

using Java just feels like you're using 2% of language features in C#

#

although i heard they actually got some language additions over the years so that's not bad ig

ivory bobcat
#

Used as-in with programmers or with applications?

ivory bobcat
hardy wing
#

But since then several years have passed so i admit that it's probably not too up2date

hardy wing
mystic flume
crimson monolith
#

I can't follow the downloaded tutorials because they have render issues that won't let me hit play.

I find one of the website tutorials for a little mouse/toy/car whirring around a living room, and the script doesn't work. I copy it to my project and it doesn't work.

Any tutorial on YouTube I follow for making a character controller doesn't work.

I download character controllers off the Asset Store, and they don't work.

Even if I find tutorials to use the new input system, they don't work.

I'm so supremely stressed out. A full week and I can't even get my project started, let alone off the ground. I'm using 6.0. Am I not supposed to be using 6.0? Are the website tutorials actually useful? Cause they start with "How to download Unity" and stuff I don't need

slender nymph
#

!learn do the pathways on the unity learn site πŸ‘‡
but if so many tutorials are not working, that means you are either not paying proper attention to them, or not paying attention to the errors that appear

radiant voidBOT
crimson monolith
slender nymph
#

ah yes "rendering errors" because that's super descriptive

crimson monolith
#

That's all it says

rich adder
slender nymph
#

so the only thing you see when you try to use these projects you are downloading is literally the phrase "rendering errors"?

crimson monolith
rich adder
crimson monolith
#

Essential Pathway

#

The material changer won't let me hit play, and the HDRP error will, but it always comes up

rich adder
crimson monolith
#

It doesn't. I just have it on attempting to get rid of the material changer/converter

rich adder
#

wdym with "get rid of the material changer"

#

why. no essentials tutorial requires you to mess with that

#

also are you using the specific unity version they have on the website

crimson monolith
#

I'm on 6

rich adder
#

you do realize there are many versions of 6..

crimson monolith
#

6.000.3. The tutorials are all 6.0. Trying to get rid of the material converter error because it's hard blocking me from the play tab

rich adder
#

if the tutorial are 6.0 why are you using 6.3

#

or very least select 6.3 on the page

crimson monolith
#

Cause I automatically downloaded the most recent version, and didn't think anything of it til I saw the tutorials are slightly lower. There are no 6.3 tutorials, highest is 6.0

rich adder
crimson monolith
#

The website tutorials

rich adder
#

what is "The website tutorials"

slender nymph
#

nav's screenshot is from that link, in the essentials pathway

brisk edge
#

follow 6.3. and install the latest unity editor version from the hub

crimson monolith
#

None of you are addressing my issue

slender nymph
#

except you've been here complaining that no tutorial works for you at all, and that was addressed

rich adder
#

you're most likely opening up the wrong version of example project with your version of editor

slender nymph
#

and it's been pointed out that you need to be using the same version that the course you are following uses if you intend to download materials from that course

jaunty wing
#

Any ideas on how I should implement the joysticks? I'm trying to think of a soluton but I'm not sure what the effective way of doing it is

#

My main idea is to have a empty game object at like the pivot point

#

and pivot it around using clamp

native seal
#

whats the consensus on how to seralize derived classes without using TypeNameHandling with newtonsoft json? its really ugly to have "MyGame.Inventory.Armor, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" or whatever in the json file, also messes up if you change class name

untold shore
#

Hey- having some problems with an ienumerator. Currently trying to get it to move through an animation, but it wont actually call that animation change (nor the Debug within in). It will work if it is a public void ():, so Im guessing it has to be because its an Ienumerator. I wanted it to be an Ienumerator so it would pause and let the animations play out, which wont happen if I change it to be a regular void function. Any ideas as how I can fix this up so it actually calls that animation change?
https://paste.ofcode.org/M3kvJrkaFLaVryQBaPhZsi
Note: It did not work either whenever yield return was placed at the end, or if there was a yield return null (I don't know why that would fix it, but when I googled it that said it may be a possible solution)

slender nymph
#

you need to use StartCoroutine to start a coroutine. calling the method directly like that returns the IEnumerator but does not call MoveNext on it so it doesn't actually do anything

untold shore
#

notlikethis I hate coroutines sometimes. Thank you, Im an idiot, lol!

prime goblet
naive pawn
#

technically it'd be rotating on x/z since it's aligned on y

#

rotating on y would be twisting

prime goblet
#

true, fixed that

prime goblet
jaunty wing
#

Thank you, I think I got it figured out

knotty river
#

yo

#

where do i i send a message to ask which category and tags my game is in ?

naive pawn
#

please don't crosspost

slender kelp
#

Guys I need a designer to make my assets

fickle plume
#

!collab

radiant voidBOT
# fickle plume !collab

: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**

vast ice
fickle plume
vast ice
blissful stratus
#

is there is a tutorial for how to make boss fight in 3d bec i cant find any thing and i dont understand that much in ai stuff?

naive pawn
#

!learn

radiant voidBOT
dire holly
naive pawn
#

start by researching/learning then

#

!learn

radiant voidBOT
dire holly
#

oki thanks

#

πŸ˜„

echo mountain
#

Is it a good practice, or a bad practice, to update Unity minor versions (from 6.3.0f1 to 6.3.Xf1) when I have a game that's currently on production and people are actively playing it? Will I fix or break more things by doing that? I don't have any particular, specific reasons to update right now, just curious if I should be updating the editor from time to time or leave it as it is ("if it aint broken, dont fix it" philosophy)

sour fulcrum
#

generally if it ain't broke don't fix

echo mountain
#

but there will never be a better moment to upgrade, so it means that, unless something comes to light, the project is going to stay at 6.3.0f1 forever?

#

and that's fine?

naive pawn
#

generally yeah

#

though, ive heard quite a few stability issues from 6.3.0f1

#

you may end up needing to upgrade

#

but honestly, don't worry about it til it becomes an issue

#

you probably have better things to worry about eg bugfixes, perf improvements

echo mountain
#

Thanks. I feel uneasy about not upgrading, I used to jump to new versions during dev time, but now game is live and it feels weird

#

I dont have a single unity-related bug though

naive pawn
#

if you have nothing else to do, sure, upgrade i guess. but it'd just be a DX thing, you wouldn't push a new version to say you bumped the editor version (unless that upgrade comes with a bugfix or massive perf benefits ig)

sour fulcrum
echo mountain
#

a related question - we had crashes related to DX12, I fixed them by defaulting to DX11. Is that okay to run in DX11 as default in year of our lord 2026?

#

(game has great performance on both DXs)

#

or would it better to upgrade Unity to newest version, hope it fixed the DX12 issue, and stay on DX12?

midnight plover
verbal dome
echo mountain
#

but I worry about those things because I have no control over it, it's something very unity-specific of course

#

Thank you!

midnight plover
stark helm
#

How do I create a for loop that waits some seconds in between loops?

drowsy sable
#

I am making a game including lotsa ducks, i want to be able to pick them up and then put them down somewhere else, how do i detect if the mouse is over a spriterenderer (and if the mouse is clicked)

#

(in 2D)

rich adder
drowsy sable
#

hmm leme take a look

empty stag
#

Hi, I am trying to make a basic connect 4 game and I am wondering how I can make a 7x6 circle grid for where the tokens drop. I tried making some grids using vids I found but the spacing is to tight.

#

I am trying to make a grid to fit into the empty areas so I can then make it an interactable area so tokens can be placed

frosty hound
#

Do you want to place these procedurally? As in, being able to define the size of the grid at runtime, or is it exactly just a connect four?

empty stag
#

Exactly as connect four. A token placing slot will be at the top of the case and then when clicked it will go to the very bottom of the case, and if any other token is placed it should go ontop of the previous token if placed in same zone

solid frigate
#

Hi, is there someone who know how playfab works ? I'm trying to do a 1v1 game and for that, I'm using Playfab. I tried to make it work with SharedGroup, but apparently is kinda outdated and Group works better. But I can't find how to save data in a group, and I'm kinda loss

fickle plume
#

Playfab has extensive tutorials for C# as I recall, they should cover everything.

sage mirage
fickle plume
chrome tide
sage mirage
#

I saw prefab

empty stag
sage mirage
#

What is this?

fickle plume
radiant voidBOT
empty stag
#

Thanks

fickle plume
#

Actual logic would be when a token stops for more than a second in one place it gets locked in in an array for example to store its final location.

empty stag
#

Makes sense. I legit only started using unity yesterday so I am just learning slowly and just copying the code I am seeing from vids and modifying the values to see what they do lol

fickle plume
#

The actual complicated part would be writing an AI for it, to play against, to make decisions about moves.

#

For your first project you might want to start with something like pong, where it doesn't have any complexity.

frosty hound
#

You'll need to learn the basics of 2D arrays which are data containers that are exactly like a grid.

#

Dropping a piece into the column would set the element of that array to whatever piece colour was dropped. Then you can check the surrounding elements to determine if a win was done.

sage mirage
# empty stag Makes sense. I legit only started using unity yesterday so I am just learning sl...

I would recommend starting with Create with Code course, its an amazing course with Carl as the instructor and don't forget to WATCH first and then DO. I have started with this Course 3 years ago when I started maybe its long like 28 hours but its an amazing course believe. You will create cool prototypes from car simulator to a 2D side scrolling game and a top down game as well.
Oh and dont forget to first learn the basics/fundamentals of Programming in C# before getting into this course , I would recommend learning the basics first because I have learned programming from school when started this course but its not a prerequisite you know I am just giving an advice.

https://learn.unity.com/course/create-with-code

Unity Learn

In this official course from Unity, you will learn to Create with Code as you program your own exciting projects from scratch in C#. As you iterate with prototypes, tackle programming challenges, complete quizzes, and develop your own personal project, you will transform from an absolute beginner to a capable Unity developer. By the end of the c...

#

There are learning pathways btw in Unity Learn Website, also I would recommend starting with Junior Programmer Pathway because it has a lot of courses with create with code included its lika a pack and then moving into Creative Core Pathway.

sage mirage
# empty stag Makes sense. I legit only started using unity yesterday so I am just learning sl...

Also, stop copy pasting and instead try doing some technical design or system design like divide and conquer try breaking the problem into smaller parts instead of focusing to solve the whole problem at once like flowcharts, pseudocode, class diagrams how your code must be structured but you are a beginner what I am saying basically try writing the logic somewhere of what you want to create thats my second advice.

#

A bit decomposition wont hurt you know

empty stag
#

I planned on making it turned base vs another player no ai

fickle plume
#

Yea, in that case it's simple enough.

sage mirage
#

for example adding more enemies

#

like types

#

each enemy type must have its own strengths and weaknesses

sour fulcrum
#

its connect four lmao

fickle plume
# fickle plume Yea, in that case it's simple enough.

Also for learning projects it's good to use as much stuff as possible just to play around with things. For example you don't need to make it physics based at all even, just calculate and animate everything, but it would be a good opportunity to use as many systems as possible for learning purposes.

silent cipher
#

help how do i add shooting to my game ?

wintry quarry
shrewd matrix
#

hi aint really good in code yet, but the player moves faster to the side then it goes to the front / back:

Vector3 input = new Vector3(Input.GetAxisRaw("Vertical"), 0, Input.GetAxisRaw("Horizontal") * -1);
        Vector3 movementDirection = input.normalized;

        if (movementDirection.magnitude > 0.1f) // checks if player is moving
        {
            // Move
            transform.Translate(movementDirection.normalized * speed * Time.deltaTime, Space.World);

            // Rotate
            Quaternion toRotation = Quaternion.LookRotation(movementDirection, Vector3.up);
            transform.rotation = Quaternion.RotateTowards(transform.rotation, toRotation, rotSpeed * Time.deltaTime);
        }

I use comments to help me understand the code better

silent cipher
#

my game is so cool but its not shooter

silent cipher
#

shootinbg

wintry quarry
# silent cipher corrected

Decide if you want hitscan or projectiles. If projectiles, you would instantiate projectiles. If hitscan, you would use raycasts

silent cipher
#

i want rotating topaz and amethist ovals

shrewd matrix
# wintry quarry show the full script

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

public class MovementHandler : MonoBehaviour
{
    [Header("Settings")]
    public float speed;
    public float rotSpeed;

    void Start()
    {
        Cursor.lockState = CursorLockMode.Locked; //Locks cursor
        Cursor.visible = false;
    }

    void Update()
    {
        Vector3 input = new Vector3(Input.GetAxisRaw("Vertical"), 0, Input.GetAxisRaw("Horizontal") * -1);
        Vector3 movementDirection = input.normalized;

        if (movementDirection.magnitude > 0.1f)
        {
            transform.Translate(movementDirection.normalized * speed * Time.deltaTime, Space.World);

            Quaternion toRotation = Quaternion.LookRotation(movementDirection, Vector3.up);
            transform.rotation = Quaternion.RotateTowards(transform.rotation, toRotation, rotSpeed * Time.deltaTime);
        }
    }
}

polar acorn
#

what is shootinbg

silent cipher
#

shooting crystals

#

are you a troll?

subtle mulch
#

huh?

silent cipher
#

ore a small typo error is a filnl boss

shrewd matrix
wintry quarry
polar acorn
silent cipher
#

i ant simple shotting for beginner swith 20-30mlines of code

solar hill
wintry quarry
# shrewd matrix

If you have a dynamic Rigidbody why are you moving via the Transform

solar hill
#

Nobody will write your script for you

subtle mulch
silent cipher
polar acorn
silent cipher
#

kuzmo what?

shrewd matrix
silent cipher
#

thets bad codestyle

solar hill
#

Btw this guy is a crypto scammer and a troll, so dont waste your time

subtle mulch
#

lol what XD

tender mirage
#

Guess we got two trolls today then.

true owl
#

Hey guys, I'm making a 2D platformer. I wondering is it good to have a movement script and a jump script in different scripts or put them under the same script. I'm just wondering cause I know it runs every frame so I'm wondering if the linVel could get overwritten when dealing with these 2 scripts.

What do you guys recommend?

wintry quarry
#

don't try to do both

subtle mulch
silent cipher
wintry quarry
true owl
solar hill
shrewd matrix
silent cipher
#

ia m just carbby not a trol trying to make small craby ganem for carbby players

fickle plume
#

@silent cipher Keep it on topic, please.

wintry quarry
silent cipher
#

ok how do i add shoting wth different rotation speed and speed increasing of bullets

shrewd matrix
subtle mulch
#

make a script that does that in update

silent cipher
#

roation speed shold be arndomized

subtle mulch
#

it's simple

subtle mulch
#

!learn

radiant voidBOT
silent cipher
#

thanx

shrewd matrix
#

still the same issue, is it some math problem i dont know about like with the sideways going that makes it go 1.4 times faster?

tender mirage
wintry quarry
shrewd matrix
wintry quarry
#

plus you said sideways, not diagonal right?

shrewd matrix
#

would you like avideo?

wintry quarry
#

Can you show a video

#

yes please

silent cipher
silent cipher
#

pls help how to fix that type of bugs

shrewd matrix
#

maybe its an optical illusion lol

silent cipher
#

nice game is it a platformer named Capsula adventure?

wintry quarry
# shrewd matrix

this looks fine to me. I think this is actually a trick of "perspective". Your character is moving the same speed in all directions. But the vertical motion moves it less on a pixel basis because of your camera angle.

silent cipher
#

or its unfinished

shrewd matrix
wintry quarry
# shrewd matrix

notice how your perfect squares look like rectangles due to the camera angle. The characvter moves the same number of squares per second in either direction

silent cipher
#

guys who knows how to wriote shooting scripts?

subtle mulch
#

!learn

radiant voidBOT
subtle mulch
#

and go look YT

#

there are TONS of tutorials

silent cipher
#

i want learn from real people not youtubers

naive pawn
#

youtubers aren't real people?

#

also, unity learn is right there

sour fulcrum
#

1:1 help costs money

silent cipher
naive pawn
naive pawn
silent cipher
#

nice i need real scripts

subtle mulch
sour fulcrum
#

can we just get to the part where they get banned

subtle mulch
radiant voidBOT
subtle mulch
#

or YT

silent cipher
#

to learn how they work

polar acorn
naive pawn
subtle mulch
#

and do not use AI pls

silent cipher
naive pawn
#

@silent cipher you've been told multiple times. stop spamming and go actually learn

subtle mulch
#

!learn

radiant voidBOT
subtle mulch
#

YT

fickle plume
#

@silent cipher Stop spamming the channel and make an effort to learn using Unity courses. You are on your last warning here.

naive pawn
#

@subtle mulch you can stop spamming those links, they clearly don't care

silent cipher
#

ok

naive pawn
#

at some point ignorance is just malice

subtle mulch
#

use this as a base and add the rotation you need

sour fulcrum
#

they dont care

subtle mulch
#

well, i gave the specific tutorial to them

hardy wing
subtle mulch
hardy wing
#

i just wanna undo whatever my eyes just witnessed

tender mirage
#

πŸ˜‚

naive pawn
#

well thanks for the warning i suppose

silent cipher
#

thanx for shooting tutorial

warm iron
#

Hello, I am pretty sure that the stamina shouldn't decrease when I did not press shift?

wintry quarry
silent cipher
#

-=1 decrases it

#

yas

warm iron
wintry quarry
#

since you don't have { } your if statement only applies to the sprinting = true; line

#

the rest will run no matter what

midnight tree
silent cipher
#

the stupidest error i think

#

why does visual studio not auto fixes that?

naive pawn
#

!ide

radiant voidBOT
warm iron
#

no idea, maybe it think I am smart but I am actual stupid

naive pawn
#

that also looks more like vsc instead of vs

silent cipher
#

i cant fix movemnt and rotation after watching tutorial

#

for a bullet

#

but it spawns

#

void Update()
{
// 1. Acceleration: Speed up over time
currentSpeed = Mathf.MoveTowards(currentSpeed, maxSpeed, acceleration * Time.deltaTime);

// 2. Movement: Fly forward (Z axis for 3D particles)
transform.Translate(Vector3.forward * currentSpeed * Time.deltaTime);

// 3. Random Spin: Rotate the gem uniquely
transform.Rotate(spinAxis * spinSpeed * Time.deltaTime);

}

#

is there an error?

polar acorn
silent cipher
#

idk probably tyes but looks nice

#

ai noyt helps

#

stupid gemini

polar acorn
#

How about you just stick to asking the spam machine instead of wasting our time

silent cipher
sour fulcrum
#

giving a shit

polar acorn
silent cipher
#

i had crab pat=rticles do not move and do not rotate

naive pawn
#

@silent cipher please stop spamming. if you have an issue you need help with, ask about it.

naive pawn
polar acorn
silent cipher
#

ok does it implemnt particles system correctly? using UnityEngine;

public class GemProjectile : MonoBehaviour
{
public GemType gemType;

[Header("Bullet Speedup")]
public float currentSpeed = 2f;
public float maxSpeed = 35f;
public float acceleration = 25f;

[Header("Random Rotation")]
private float spinSpeed;
private Vector3 spinAxis;

void Start()
{
    // Randomize the speed and axis for unique gem spinning
    spinSpeed = Random.Range(400f, 1000f);
    spinAxis = new Vector3(Random.value, Random.value, Random.value).normalized;

    // Safety: Destroy bullet after 4 seconds so they don't clutter the game
    Destroy(gameObject, 4f);
}

public void InitializeGem(GemType type)
{
    gemType = type;
    ParticleSystem ps = GetComponent<ParticleSystem>();
    if (ps != null)
    {
        var main = ps.main;
        // Ruby = Red, Sapphire = Cyan, Emerald = Green
        main.startColor = (type == GemType.Ruby) ? Color.red : (type == GemType.Sapphire) ? Color.cyan : Color.green;
        ps.Play();
    }
}

void Update()
{
    // 1. Acceleration: Speed up over time
    currentSpeed = Mathf.MoveTowards(currentSpeed, maxSpeed, acceleration * Time.deltaTime);

    // 2. Movement: Fly forward (Z axis for 3D particles)
    transform.Translate(Vector3.forward * currentSpeed * Time.deltaTime);

    // 3. Random Spin: Rotate the gem uniquely
    transform.Rotate(spinAxis * spinSpeed * Time.deltaTime);
}

}

radiant voidBOT
radiant voidBOT
warm iron
polar acorn
#

also I'm not debugging code you didn't even bother to write

#

Go ask the clanker for help

silent cipher
#

ok

#

i dont know

#
void Update()
{
    // 1. Acceleration: Speed up over time
    currentSpeed = Mathf.MoveTowards(currentSpeed, maxSpeed, acceleration * Time.deltaTime);

    // 2. Movement: Fly forward (Z axis for 3D particles)
    transform.Translate(Vector3.forward * currentSpeed * Time.deltaTime);

    // 3. Random Spin: Rotate the gem uniquely
    transform.Rotate(spinAxis * spinSpeed * Time.deltaTime);
}
twin pivot
#

This is the same code

silent cipher
#

i know

twin pivot
#

Go to learn.unity and actually learn how to write code by yourself

silent cipher
fickle plume
#

Don't spam LLM code which you have no idea how it supposed to work

silent cipher
#

i forgot to attach prohjectile code i am so stupid imho

#

to a prefab

subtle mulch
silent cipher
#

i was thinkinhg code is not corrrect

fickle plume
silent cipher
#

i forgot it lol

true owl
#

I wrote up someting small here but I'm not sure why my dash isnt working

    private void Awake()
    {
        rb = GetComponent<Rigidbody2D>();
    }

    private void Update()
    {
        if (isDashing)
        {
            rb.linearVelocity = new Vector2(moveInput.x * dashSpeed, rb.linearVelocityY);
        }
        else 
        {
            rb.linearVelocity = new Vector2(moveInput.x * speed, rb.linearVelocityY);
        }
    }

    // On X (Controls)
    private void OnMove(InputValue inputValue)
    {
        moveInput = inputValue.Get<Vector2>();   
    }

    private void OnJump(InputValue inputValue)
    {
        // print("Input value: " + inputValue);
        if (onGround)
        {
             rb.linearVelocity = new Vector2(rb.linearVelocityX, 10);
        }
    }
    private void OnDash(InputValue inputValue)
    {
        if (!isDashing)
        {
            StartCoroutine(Dash());
        }
       
    }

    // My own functions
    private IEnumerator Dash()
    {
        isDashing = true;
        yield return new WaitForSeconds(dashTime);
        isDashing = false;
    }

#

just trying to get the basic structure down

naive pawn
#

describe what actually happens and how it differs from what you expect to happen

true owl
#

player just isnt dashing like there's no change in linvel

#

its as if i didnt press anything

naive pawn
#

have you debugged to see if OnDash is being called, if Dash is being called, and if the if branch is passing as expected?

#

and check if your dashSpeed is different from your speed

true owl
#

Yeah i'll go through I know the input is being received I jsut took out the prints, but I'll try to add some more in the update block

#

Also I know im supposed to be usnig FixedUpdate instead of update right?

naive pawn
#

for the specific physics things you're doing here, it doesn't really matter

#

if it were AddForce with a continuous force then absolutely yes

true owl
#

i see

naive pawn
#

but here it's just setting the velocity, the update rate is limited by both Update (when input is received) and FixedUpdate (when it's applied to the simulation)

true owl
#

Also am I supposed to handle all the linvel setting interactions in Update() like I know it runs every frame and I have Jump here which sets the linvel in its own thing, how am I supposed to know if the update method will take prio or the OnJump linvel?

naive pawn
#

you're setting separate axes there that don't interfere

#

there's not really a concept of "priority" for just setting values

#

but fyi this is handled by script execution order and input messages will run before Update calls

true owl
#

i see

#

alright noted thanks

swift crag
#

I'm not sure exactly when coroutines get resumed

#

They may wind up before or after all other Update methods run

naive pawn
#

the execution thing specifies this.

swift crag
#

yeag

#

it's after Update

naive pawn
#

yeah that thing, i can never remember the proper name

sour fulcrum
#

just remember what an old king would use if they wanted someone dead πŸ˜„

naive pawn
#

ah no i mean the full "Event function execution order"
i keep remembering it as SEO even though that's a separate thing

meager kestrel
#

Does anyone have any good resource for the cross hatching shader?

naive pawn
acoustic sequoia
#

hey yall, hope everyone is doing well!
Just getting back into coding after a long break. I had an idea to create a 2d map of terrain and i want to use perlin noise. I have a grid of sprites that i want to color differently depnding on their height map of the perlin noise.

what is the best way to get a 2d grid of floats that will map to my grid size? thanks in advance

acoustic sequoia
#
for(var j = 0 ; j < mapHeight ; j++) {
   for(var i = 0 ; i < mapWidth ; i++) {
      var tile = Instantiate(prefabMapSprite, new Vector2(i,j), Quaternion.identity, tileParent);
      tile.name = "Tile" + i.ToString() + "-" + j.ToString();
      tileSprites.Add(tile);

      var pNoise = Mathf.PerlinNoise((float)i, (float)j);
      tile.color = pNoise > 0.45f ? levelColor : mountainColor;
      Debug.Log(pNoise);
    } 
}

i'm getting this in the log for every tile?

0.4652731
UnityEngine.Debug:Log (object)
General.MapGameBoard:Start () (at Assets/General/MapGameBoard.cs:31)

wintry quarry
#

it will always be 0.4652731 at integer steps

#

try:

var pNoise = Mathf.PerlinNoise((float)i / 1f, (float)j / 1f);```
acoustic sequoia
#

so should i divide it by the width and height of grid?

wintry quarry
#

and then add a scale factor and multiply that in to be able to control the noise scale

acoustic sequoia
#

thank you!

naive pawn
wintry quarry
#

sorry

#

yes

#

it should be (float)i / mapWidth

#

good callout

acoustic sequoia
#

now is there a way to edit the parameters of the perlin noise that i'm sourcing?

wintry quarry
#

generally what you edit are offset and scale

#

you do that by multiplying and adding to the input values you pass into the noise function

warm iron
#

Guys how do you all implement dodge/roll, I need a head up. Here is a code that call it, DodgeInput() is called in fixed update

acoustic sequoia
#

can I add a monoBehavior to a gameobject and also use that monobehaviors constructor? i'm trying to do it but it's not working

slender nymph
acoustic sequoia
slender nymph
#

Create some method on the component that you can call to pass data to it after creating it with AddComponent

#

Or if you don't need to pass anything then you can just use Awake or Start

acoustic sequoia
# slender nymph Create some method on the component that you can call to pass data to it after c...
        public class Tile : MonoBehaviour {
            public SpriteRenderer tileRenderer;
            public Vector2 tilePosition;
            public float tileHeight;
            public Color tileColor;
            public TileVariations.TileType tileType;
            TileVariations _tileVariations;
            
            public Tile(SpriteRenderer renderer,Vector2 position, TileVariations tileVariations) {
                tileRenderer = renderer;
                tilePosition = position;
                _tileVariations = tileVariations;
                tileType = tileVariations.GetTileType();
                tileColor = tileVariations.GetColor();
                tileRenderer.color = tileColor;
            }
        }
sour fulcrum
#

yeah no constructors for unityengine.objects (which monobehaviour is)

acoustic sequoia
#

so i can just change the name of the public method to something else and will work?

slender nymph
#

It needs a return type too

grand snow
#

horray for Init()

polar acorn
#

Ought to be a company slogan. "Init() -- for when you can't use a constructor"

hazy willow
#

im trying to get my character to shoot a projectile out of a wand detached from the body, but my character is shooting the projectiles from itself, but not the wand, how would i fix that?

slender nymph
#

you need to use the position of the end of the wand as the position you instantiate your projectile at rather than the object's own position

hazy willow
#

how would i do that? normally im just attaching the script to the object so im assuming its center of mass

#

also my wand is now floating away

slender nymph
#

place an empty game object at the tip of the wand as a child of it, then get a reference to that object and use its position as the position you instantiate at

hazy willow
#

would i be able to stream to you so you can see how bad i fucked up and see if you can tell me how to fix it?

slender nymph
#

no. you can share your code and screenshots of your setup if you need to

#

!code

radiant voidBOT
molten pulsar
#

hi somebody knows why this feature is making that my game dosent pass from the 60 fps per second

#

😭

slender nymph
#

EditorLoop is literally the unity editor's update loop. that won't be there in a build

slender nymph
#

that depends, do you have any assets or anything that have any editor code that would impact the performance of the editor itself? if no, then your issue is likely your hardware simply not being good enough

molten pulsar
#

btw im gonna try to build it instead of playing it in editor

#

i read that maybe that gonna help

slender nymph
#

i literally told you that the editor loop will not even be present in the build

brisk edge
#

(Spoilers cuz its a quiz question) Does ||public float Speed = 40.0f;|| or ||public float speed = 40.0f;|| follow the naming conventions?

#

I believe 'speed' to be a public field and therefore it should be PascalCase. Is this wrong?

slender nymph
#

the former would follow standard c# naming conventions, though it breaks the convention of not exposing data through public fields

brisk edge
#

Its a quiz question in a Learning Pathway.

slender nymph
#

then surely the course covered that

untold shore
slender nymph
#

you should use properties to expose data to other objects, public fields should only be used very sparingly

untold shore
#

Ive never even heard of properties. Thats interesting, Ill have to use that then. I guess I have a very bad habit of using public fields a lot then. Is properties a unity thing or just a base c# thing?

slender nymph
#

that's a standard c# thing

brisk edge
#

private float speed = 40.0f; public float Speed {get; set;} is probably the proper way.

slender nymph
#

and this convention is used in more than just c#, even other languages that don't have properties you should prefer to use getter/setter methods to interact with another object's fields (and properties are just getter and setter methods that are used like variables)

slender nymph
brisk edge
#

Ah I see.

private float speed = 40.0f;
public float Speed {
   get { return this.speed; }
   set { this.speed = value; }
}

Would this be proper?

slender nymph
#

yeah, that is a full property that uses an explicit backing field

brisk edge
#

And this would be without a backing field: public float Speed { get; set; } = 40.0f;.

#

Coming back to my original question. Why does the quiz tell me I'm wrong when I use PascalCase for a public field?

slender nymph
slender nymph
brisk edge
#

If its public, it means its a field right?

ivory bobcat
#

I just noticed you had a public field

brisk edge
#

I checked the course again and the first time it mentions naming conventions it says:
Which of the following lines of code is using standard Unity naming conventions?

naive pawn
brisk edge
# naive pawn no, those 2 things are unrelated

okay yes public is only a access modifier keyword and can be put elsewhere. If you have an access modifier infront of a variable declaration, it has to be within a class making the variable a field. Or am I wrong here?

naive pawn
naive pawn
#

it's phrased ambiguously so i can't say for sure whether you're right lol

brisk edge
#

It's a field because its within a class.

#

it has to be within a class because its public

naive pawn
#

it has to be within a class because it's a field

#

you have the right idea about what can do what, but not the right causal link

#

it can be public because it's a member - fields, props, methods, constructors, and nested types can all have the same access modifiers

brisk edge
#

no it is public because that is written in the quiz

#

there is no class anywhere. I'm assuming there has to be

naive pawn
#

are you asking about the specific quiz question or just what's legal in c# then

#

one of these seems a lot more useful than the other

naive pawn
#

the field in the quiz must be a field in a class because that's the only valid context for it to be, inferred from it having an access modifier
but the access modifier isn't what makes it a field

#

int jumpHeight = 4; this could be a field or a local, no way to tell without more info

teal viper
#

Fields were always lowercase iirc

naive pawn
#

Pascal case is a variation of camel case, where the initial letter is capitalized. Use this for class, public fields and method names in Unity development.

teal viper
#

Interesting.

brisk edge
#

I think this quiz answer is a hot take: "Player input should be handled in the Update() function."
But at least it's what the course teaches.

polar acorn
#

Yes that's correct. You want input in update, physics in fixed update

brisk edge
#

Does the new input system check input every frame?

#

Is there a way with the old input system to not have to check input every frame?

#

Oh I guess it does^^ Maybe its not that hot of a take after all.

polar acorn
# brisk edge Does the new input system check input every frame?

Kind of. The events that get fired are called in the update loop, and polling works the same as the old input manager.

Depending on how you've set up your messages, it'll be kind of weird in that it'll be in a different object's update. Whenever your input action's script updates, it'll fire all of its subscribed events, even if they're in other scripts that haven't done their update for this frame yet.

#

So, it's a little weird in cases where you're using callbacks

teal viper
warped palm
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerControllerX : MonoBehaviour
{
    public GameObject dogPrefab;

    // Update is called once per frame
    void Update()
    {
        // On spacebar press, send dog
        if (Input.GetKeyDown(KeyCode.Space))
        {
            Instantiate(dogPrefab, transform.position, dogPrefab.transform.rotation);
        }
    }
}

I want to know how can I add a time limitation to instantiate next gameobject after the previous gameobject is fired.
like in this case I have a dog when I fire it or instantiate it, I want to add a limitation to spawn next dog after some timeperiod (2sec).

chrome tide
warped palm
chrome tide
# warped palm I'm not sure how to implement it... its new for me

Make a field in the class itself (e.g. private float timer;) and add Time.deltaTime to it each frame - this way you’ll create a timer that will just add time to itself based on the time between frames. The other part is just a if statement and a value assign

warped palm
chrome tide
#

No, you need a timer I mentioned earlier. Now your code checks the time between frames - so it will fire only if the game is laggy enough to have 2 seconds between two frames

brisk edge
#

I would make a timestamp when sending. and check the difference to that timestamp when you want to send again.

chrome tide
#

That could work too

warped palm
warped palm
chrome tide
#

I described it here

warped palm
#

@chrome tide

brisk edge
warped palm
chrome tide
#

Yeh exactly like benji said

warped palm
#

let me just read it

#

thankyou guys @brisk edge @chrome tide

#
 private float timer;
 // Update is called once per frame
 void Update()
 {
     timer = Time.time;
     // On spacebar press, send dog
     if (Input.GetKeyDown(KeyCode.Space) && (timer > Time.time + spawnInterval ))
     {
         Instantiate(dogPrefab, transform.position, dogPrefab.transform.rotation);
         timer = Time.time;
     }
 }
#

I think I should use timer = Time.time in start function

naive pawn
#

you need to not do it every frame

#

the conditional check there doesn't make sense

#

timer is in the past, you're checking if it's in the future

brisk edge
# teal viper You're overthinking a bit. A few bool/value checks every frame is nothing in ter...

I've wrongfully assumed performance benefits. I didn't realize it was polling on the lower level. I often read in discussions of event driven vs polling that there are performance differences. I would say event driven would imply doing something based on events and not doing something every frame. The new input system is event driven.

A few checks every frame: You can always design a scenario / game where a few checks every frame can be detrimental.
Just increase the amount of playable characters until it is.

naive pawn
#

event driven vs polling on your level just refers to how you receive input from the input system

#

imo, just don't worry about perf/internals at this stage
if you're curious, sure, go learn that on its own and then come back to relate that to what you already know

teal viper
# brisk edge I've wrongfully assumed performance benefits. I didn't realize it was polling on...

A few checks every frame: You can always design a scenario / game where a few checks every frame can be detrimental.
Just increase the amount of playable characters until it is.

This is kinda distorting what I said. Obviously if these checks bubble up to million checks per frame, that's gonna be a bottleneck. Notice how I said "a few"? That being said, if you have a miliion of objects all running the same code(checks) in update, it's an architecture issue on a whole different level. The issue is not the checks but the fact that you're updating million of these objects per frame.

brisk edge
#

fair

frigid lark
#

how to i properly paste the code in?

ivory bobcat
frigid lark
#

post my code that is

ivory bobcat
#

!code

radiant voidBOT
ivory bobcat
#

Your options are to use an external service for large code blocks or backticks for small snippets (inline)

frigid lark
#

oh whatever so i have this code that i yoinked from dani and modified myself to fit my game + new input system:

https://paste.ofcode.org/VsHU4gkuWYfp2UwjPFvGpj

but when i land in game theres a hit of intertia. i know that the counter movement script causes this, and I know that if i put "if(grounded) return;" as a line, but if i do that then the player accelerates very quickly in air.

naive pawn
#

you should not have Time.deltaTime in those AddForce calls

frigid lark
#

yeah, like i said i just yoinked the code and modified it slightly

naive pawn
#

is that supposed to deflect or something lmao

frigid lark
#

kind of

#

ive made the change, but yeah im very new to coding

#

in c# anyway

#

ive coded like everything else in my game

#

but i hate coding movement ;-;

naive pawn
#

im giving advice, i don't particularly care how it came up tbh - it's a common beginner mistake, i understand lol, you don't need to provide explanations/excuses

#

is the unwanted inertia in question horizontal or vertical?

frigid lark
#

vertical

#

i want the horizontal stuff

naive pawn
#

it's sinking into the ground?

frigid lark
#

kind of

#

its just like, when you land, hVel halts

cunning rapids
naive pawn
#

btw, keep in mind that OnCollisionStay will trigger after the physics tick, so it'll be a step behind

cunning rapids
naive pawn
frigid lark
#

aight ill change up the oncollstay to a raycast instead

#

can i upload videos here

naive pawn
#

yes

frigid lark
#

aight 2 secs

cunning rapids
#

You land on the floor, you stop on the floor

frigid lark
#

bro i know im asking how to avoid this

#

its physics, i want physics but not physics

#

if that makes sense

naive pawn
#

it does not

#

actually describe what it is that you want

frigid lark
#

so when you land after jumping, your horizontal velocity comes to a halt

#

as it should, it makes sense physics-wise

#

but i want to find a way to make it so that it doesnt

naive pawn
#

you want to maintain momentum when you land on the ground?

warped palm