#💻┃code-beginner

1 messages · Page 844 of 1

pliant dome
#

I swear I didnt mess with the code before I went to bed so idk

frosty hound
#

It's physically impossible for your game to have change, on its own, over night.

pliant dome
#

well yeah but I did have unity running while I was playing some games last night

#

so Id assume I pressed something that changes something

frosty hound
#

When it wasn't in focus? Impossible

pliant dome
#

without realizing

frosty hound
#

Anyway, you should just figure out the problem, rather than why it happened.

sour fulcrum
#

i cant think of any hotkeys no

frosty hound
#

How are you handling the jumping now?

sour fulcrum
#

this does sound like you don't have version control?

frosty hound
#

Check the values for it, if they're something you've tweaked before.

keen dew
#

If the code isn't framerate independent then having other programs running in the background might have made the editor run at a slower framerate

#

and make it behave differently

pliant dome
#

Just double checking but the gravity on the Y axis should be -9.81 right?

naive pawn
#

yeah

rotund ember
#

Hi everyone! I'm new to Unity and game development. I want to create my first 2D game for Android (it will be a RPG. What tutorials, documentation, or learning paths do you recommend for a complete beginner? Thanks!

slender nymph
#

!learn

radiant voidBOT
pliant dome
#

Okay I can confirm that its not something in my code

#

Because I have a player 2 that hasnt been updated with all the new good code Imade for player 1

#

ITs def something within unity specifically like in the settings or inspector

slender nymph
pliant dome
#

My player 1 uses a statemachine and its own controller scheme while player is super outdated code thats the most basic getkey code with very basic functions. Im very aware that these def work and I dont touch player 2 at all

#

So if player 2 is descending just as slowly as player 1. This most definitely means that its most likely a universal unity thing that I mightve done on accident

slender nymph
#

unless you've made a similar mistake with your logic. but we won't know that if you keep making assumptions and don't share the code

pliant dome
#

I guarantee you its not but dw about it

slender nymph
#

there's an easy way to prove it isn't the code (which it almost assuredly is), and that's by showing the code

dry pulsar
#

Can someone tell me why it is spawning 2Objects and not 1?

swift crag
#

Perhaps you have two copies of FlyingObstacles in your scene!

#

Otherwise, I see no reason for this to happen

#

GetKeyDown is only true for one frame, and Update runs once per frame

swift crag
#

this will highlight every game object with that component on it

rich adder
#

there def is at least two

dry pulsar
#

I got it tysm guys

swift crag
#

i wonder if that counts two instances in a scene as one reference

#

(since that's one asset (the scene) that references the type)

errant breach
#

Hello ! So i have a small question regarding StateMachine.
Some logics, kind off..

So my enemy have a lot of states... Two of them being :

  • Moving
  • Tracking

When moving : The AI's go left and right, turn when touching a wall / getting of ledge, etc
When Tracking : The AI's walk toward the nearest player.

And im wondering how i should organise my Script... To walk, avoid hole, touching wall, i want to copy/paste the code from moving to tracking, but that would be ugly. I don't want to put too many code on my StateManagerHandler, so im wondering in your opinion what would be the most efficient way of doing that...
Thanks ! :)

autumn verge
#

i have some assets that only appear in vr mode

#

because they're tied to the controllers

#

basically its a series of lights

#

that are rendered ontop another asset

#

that is on the controller object

#

how do i locate the lights and adjust their position in space?

#

without needing to run the app in vr every single time

cosmic quail
rich adder
#

moving state is a bit vague in itself you probably just want to define what its doing
ie. Roaming/Patrolling vs Seeking/Tracking etc

errant breach
#

I get your ideas.. Thank you for giving them to me ! Ill try to see what i can do ! :)

brittle tangle
#

can someone assist me on something

naive pawn
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

naive pawn
brittle tangle
#

I am using URP

elder hearth
brittle tangle
#

when I set the "background type" under environment tab in camera to solid color

naive pawn
#

right, so as a single message please

#

what is the issue you're having

brittle tangle
#

when I set the "background type" under environment tab in camera to solid color and set the color grey I get weird rings

solar hill
#

rings?

#

Can you demonstrate with a screenshot

brittle tangle
naive pawn
#

that's a solid grey screenshot

solar hill
#

those rings are color banding

#

i see them

brittle tangle
#

all grey

short hazel
#

You have a vignette post processing effect enabled?

elder hearth
naive pawn
#

ah i see them now lmao. that's really subtle. or my screen is shit

solar hill
#

the opposite

elder hearth
brittle tangle
solar hill
#

try setting that to a higher value like 64 bits

#

i think the default is 32 so it could be causing the color banding

brittle tangle
solar hill
#

honestly i cannot even remember

#

i just know its a pain in the butt to find

short hazel
#

Seems like a bit depth issue yeah, might not be visible on other colors without checking with a color picker tool

#

(or increasing contrast on a screenshot using your go-to image editor)

#

Yeah there's like 2 bit differences between each color

#

(contrast adjusted)

brittle tangle
solar hill
#

well yeah

#

thats a good thing believe it or not

#

it just means its trying to blend more of the colors together

brittle tangle
#

wait i just realized

#

since i need flat color I can just use ui with a flat color as background

#

but that would block objects being on the screen

solar hill
#

it would not

#

is this a 2d game im pressuming?

brittle tangle
solar hill
#

this sounds like an XY problem if ive ever seen one

#

how about you tell us exactly what you are trying to accomplish and how, and there might be a better solution out there

brittle tangle
#

I just need a flat grey background and a sphere

#

Like how you render images from blender

#

it's definetly something to do with hdr

#

since messing with the setting does something

#

nvm

#

vignette was on

brittle tangle
short hazel
#

Oh well, that solves it, glad it's not some obscure bug or limitation of the engine

hallow sun
#

Using shadergraph, how can i use Image color only though code?
"Disable tint" completely shuts it off, meaning i can't get it through _MainColor
But not disabling lets it tint again after the shader's effects.

I'm making a progress bar that greyscales the texture where its consumed, but still want it to be tintable for the full part.

grand snow
pliant chasm
#

(I hope this counts as beginner, since I am) I'm trying to get a movement system, and my current method involves actions increasing specific directional speed variables and Translating my player by each variable in their respective directions. however, this has the side effect of the object's rotation controlling trajectory in air, because the code just tells it to move forward relative to the player, so when the player rotates, the trajectory changes. is there any way to not have that happen?

solar hill
#

youre going to need to maintain a seperate velocity vector in world space and rotate independently from that

#

instead of constantly using the objects current forward/right vectors

#

can you share the code you have

radiant voidBOT
pliant chasm
verbal dome
pliant chasm
verbal dome
#

Storing values in variables is common. Come back when you have the code to show

upper token
#

This script is supposed to affect only objects with a specific layer or tag. However, for some reason, it is also freezing UI elements such as buttons.
Why is this happening?

polar acorn
radiant voidBOT
polar acorn
#

!code

radiant voidBOT
polar acorn
#

Ah, wait, there's more than I saw, because it truncated (reasons why to use a paste site)

upper token
polar acorn
hallow sun
#

is it bad practice to modify other variables in setters, like this?

private int _health;
public int health {
  get;
  set {
    _health = Mathf.Clamp(value, 0, maxHealth);
    healthBar.material.SetFloat("_Progress", health);
  }
}```
teal viper
#

One functional issue that I can think of is if you want to modify health at some point when healthBar or it's material don't exist, you'll get a null reference error.

sour fulcrum
#

yeah its not too big of a difference but i tend to do


private int _currentHealth //named current because i tend to have a _maxHealth
public int CurrentHealth { get => _currentHealth; set => ModifyHealth(value); }

private void ModifyHealth(int value)
{
  _currentHealth = blabla;
}
swift crag
#

i prefer to have my healthbars watch an entity

#

rather than the entity directly telling the healthbar to update

#

(this could be done with events, or it could just be done once per frame)

swift crag
#

or maybe an enemy has 100 healthbars as a joke

sour fulcrum
#

I don't disagree with what your saying but I do think that starts to approach the "it depends on the game" point

swift crag
#

yeah – and if you do realize this is a problem, you can easily refactor

#

dlich just brought up a useful point: "hard-coding" something adds constraints to your design

#

of course, designing your game so that there are zero assumptions about anything is a recipe for disaster

#

where everything is so abstracted that you can't figure out what the game actually does 😁

sour fulcrum
#

Frl

#

Still highly depends on the game but this is one of the rarer examples where optimization stuff can potentially matter too since it's hitting ui stuff that updates often and might scale

pliant chasm
#

How would I move an object in relation to the rotation of another object? like say I had an object that is at rotation 90 degrees, and another at 0 degrees. how would I move object1 forward based on the rotation of object2 (so forward for object2, but left for object1)?

steep bronze
#

Hi guys lm new lma try and make models but ye

naive pawn
pliant chasm
pliant chasm
#

(this isn't sarcastic or anything, genuinly thank you)

winter monolith
#

does anyone know any good beginner ui tutorials i want to make a stamina thing

sage mirage
#

Hello, guys! I see Dot() has two method overloads the first one takes Vector3 lhs and Vector3 rhs so I think left hand side and right hand side, but also there is another one which takes in lhs and in rhs. So, in which case do we use the first method overload and in which the second one, basically I know about the first one it is way to find the field of view of an npc for example if its 0 its perpendicular if its greater than 1 its in front of the player if less that -1 player at the back.

naive pawn
#

i don't think you really need to choose?

#

they do the same thing

#

The in modifier is required in the method declaration but unnecessary at the call site.
so you could get that second signature even without doing anything i think, if the first signature didn't exist

#

you don't need to worry about it

#

You can gain performance optimization by defining methods with in parameters. [...] Declare in parameters to specify that you can safely pass arguments by reference because the called method doesn't modify the state of that argument. [...] You explicitly add the in modifier at the call site to ensure the argument is passed by reference, not by value.

sage mirage
#

oh, ok. So, it is used to pass arguments by reference but keep them readonly. So, I assume if you dont have to change the lhs and rhs then you use in modifier, and I cant think in which case you would have to change them to tell you the truth.

#

In which case you have to change the lhs and rhs at runtime and this is another interesting question?

naive pawn
#

you don't have to mutate the parameters (you can copy them), but it's possible, so the compiler has to make that behave correctly

#

it does that by copying the value types

#

if you know you aren't going to mutate them, in marks them as such so it doesn't have to make the copy just in case

hearty parcel
#

i unbale to fit ui on every phone screen i made in 1920*1080 after apk build it not fitting in any device screen

red rover
#

Is there a way to get the selected index of an array in the inspector, or whether the array is selected? I want to display different info depending on which index is selected.

naive pawn
#

maybe with custom inspectors/drawers? i wouldn't bet on it though

red rover
#

Gotcha... I figured this was pretty far fetched lol. There's probably a way, but it'll be pretty hacky.

sage mirage
#

Hey, guys! Why characterController.velocity is read only?

#

rb.linearVelocity is not if we compare them

naive pawn
#

CC and RB aren't the same, perhaps...

naive pawn
#

tl;dr: CC doesn't move with velocity. this one is computed from the Move that happened in the previous frame

sage mirage
#

So I have to use Move first if I want to use velocity right afterwards?

#

and it has to be assigned to a variable?

#

because its readonly

naive pawn
naive pawn
sage mirage
#

No I just wanted to see if I can do something like cc.velocity +=

#

like I do with rb

naive pawn
#

so you want to modify the velocity

#

you can't, because CC doesn't move with velocity

sage mirage
#

yes I can use move by the way

#

Move()

naive pawn
#

CC.velocity does not expose internal state like RB.velocity does, it reports what it did the last frame, caused by Move

sage mirage
#

oh ok so thats why it is readonly

naive pawn
#

that's what the docs say, yeah...

sage mirage
#

if it doesn't move with velocity then how it moves?

#

Character controller uses kinematic based movement right not physics based

#

right?

naive pawn
sage mirage
#

Heym guys! Normalize() and normalize are the same thing right? if I do moveDirection.Normalize() its the same as doing moveDirection.normalized right?

#

its just used in different context right?

naive pawn
#

(normalize is a verb, normalized is an adjective)

#

they both refer to the same concept of normalization, and both use the same math, but they don't do exactly the same thing

verbal dome
#

(But yes, it is custom editor/drawer stuff)

verbal dome
wild fox
#

does rigidbody2d variables not take .isKinematic anymore? It gives an error for me

wild fox
#

oh .isKinematic is just deprecated, it says the alternative func to use

burnt vapor
#

Indeed

#

Unity won't remove features suddenly, without a clear explanation on how to update

crystal agate
#

question, I have this script to run the enemy turn coroutine as many times as there are enemies on board, which currently works except that they all do it at the exact same time, even though the coroutine has several WaitForSeconds commands, including one at the end. How do I fix?

solar hill
#

is this script on each individual enemy?

cosmic quail
crystal agate
naive pawn
pure cypress
#

Could anyone recommend some good beginner course/resource for C# (I am doing this in conjunction with Unity learn), would appreciate any insights

slender nymph
#

there are beginner c# courses pinned in this channel

crystal agate
#

My enemies stopped spawning when the game starts for some reason? I'm not sure what happened because I didn't change the script anywhere near the battle setup part

#

lemme just find a way to paste the script

#

but there's no error messages too

solar hill
radiant voidBOT
crystal agate
#

nvm got it, it was an editor issue not the script

eager thunder
#

i saw this tab from a unity asset and i was curious what are these called? this layout in the inspecter can be added from the unitys windows menu like after you download the asset. is that what its called? Custom Unity Toolkit System is that a thing? i searching the internet rn what this is called and how to make it.

solar hill
#

its not a part of the inspector itself at least it doesnt appear to be

eager thunder
#

so i was sort of close i see

eager thunder
#

alright ill study it all soon thank you i just need what that is called lmao

elder hearth
#

Does anyone know why this is being flooded to my console? It's just print("Money in sell area: " + moneyInArea); and this didn't happen before

polar acorn
#

if you're getting multiple prints, you're running that line multiple times

elder hearth
polar acorn
elder hearth
mint imp
#

Hey guys so I have little planets in a my main menu that randomly generate with a seed.
Not anything complicated, but they each have values like "planet size" which is an enum with 3 values.
When clicking on these planets I want to to load the level WITH these stats.
Since the stats are on these monibehavior planet objects I'm not sure how I can tell the next scene what values to use.

I shouldn't be able to use scriptable objects because each planet has random stats

polar acorn
#

You could put the options onto a DontDestroyOnLoad object, and have the things in that scene read the data from that object before initializing themselves

storm matrix
#

I am new to this, what is going wrong?

rich adder
polar acorn
storm matrix
#

Fixed it. This line was ruining everything

rich adder
radiant voidBOT
frail hawk
#

not entirely sure why that namespace would cause that problem though

polar acorn
slender nymph
#

is it not a namespace from a library that isn't included in unity?

swift crag
#

I bet it has a class named "Transform"

#

huh, funny: it has a type named TransformBlock, but not just Transform...

#

A common source of this kind of problem is:

using System;
using UnityEngine;

...

float wat = Random.value;
#

System.Random and UnityEngine.Random are ambiguous here

storm matrix
#

New problem, can't get my camera to move with this script
-# this is what I get for trying to follow a 4 year old tutorial

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

public class PlayerCam : MonoBehaviour
{
    public float sensX;
    public float sensY;

    public Transform orientation;

    float xRotation;
    float yRotation;

    private void Start()
    {
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible = false;
    }

    private void update()
    {
        // get mouse input
        float mouseX = Input.GetAxisRaw("Mouse X") * Time.deltaTime * sensX;
        float mouseY = Input.GetAxisRaw("Mouse Y") * Time.deltaTime * sensY;

        yRotation += mouseX;

        xRotation -= mouseY;
        xRotation = Mathf.Clamp(xRotation, -90f, 90f);

        // rotate cam and orientation
        transform.rotation = Quaternion.Euler(xRotation, yRotation, 0);
        orientation.rotation = Quaternion.Euler(0, yRotation, 0);
    }
}

rich adder
#

then its not a bad idea to take few basic c# courses

naive pawn
frail hawk
#

so yeah fix your ide

rich adder
#

UNT0033

light glacier
#

How much do you guys rely on Namespaces? What I mean is: do you still make sure every class is named uniquely or do you rely on the namespace taking care of it?

Like imagine you could need multiple "ScreenController" classes.
Would you just always name it "ScreenController" but with a different Namespace or rather "XScreenController", "YScreenController".

I'm a little scared of namespaces now because I had twice the problem that the IDE was confused when a class had the same name.

storm matrix
storm matrix
frail hawk
#

a properly configured IDE would give you code suggestions and show you errors

rich adder
storm matrix
#

Yep, I made some adjustments, and added a few missing plugins

naive pawn
# light glacier How much do you guys rely on Namespaces? What I mean is: do you still make sure ...

make sure every class has a unique qualified name (aka namespace+class name)
they need to be unique to be valid, and also if they're different, they should be named differently to reflect the differences.
the difference in naming could be provided via a namespace, or just more descriptors in the class name.

whether you use namespaces or just extra descriptors is up to preference and whether you need grouping of other classes within the same namespace as well.
X.ScreenController,Y.ScreenController and XScreenController,YScreenController aren't that different to read.

light glacier
#

Thanks Pekora UnityChanwow

swift crag
#

I'd use the former if it's uncommon to –

[power goes out]

– use multiple screen controllers at the same time

#

that was annoying

#

(of course, you can also do both: X.XScreenController)

#

i do that for a procedural generation system

#

it has stuff like WorldGen.Sources.Floats.LiteralFloatSource

blissful stratus
#

so i want to spawn a decal on partical hit the ground but how do i make the position as the hit position

polar acorn
blissful stratus
frail hawk
#

your Instantiate method is corrupted

blissful stratus
polar acorn
#

Then the best you can do is the object's position

rough granite
#

heck it shows how to get the collision position in the doc of OnParticleCollision

mint imp
polar acorn
#

You'd make a manager that always exists, modify the data in it through static reference, and make it persist between all scenes so the ones that need it can read from it

foggy sparrow
#

Hi, i dont know why but i cant go near any of my prefab now, when i go near any object they fadeout like i have a huge hitbox and make me unable to "aproche" them
Im sure it a small editor settings but i cant find it :0

swift crag
#

The problem is that unity has your scene-view camera configured to show a very large object

#

It adjusts the near and far clipping planes (which limit how close/far an object can be and still render)

foggy sparrow
midnight summit
#

so I've been pondering something

#

I want to set a button that can activate/deactivate a set of prefabs

#

the player will land on it and that array of prefabs will deactivate, they act as a barrier

naive pawn
#

consider sending your entire thought as a single message

#

sometimes the answer pops out just while typing it all out too

midnight summit
#

well true, let me rephrase it then:

I want to set a button that can activate/deactivate a set of prefabs, the player will land on it and that array of prefabs will deactivate, they act as a barrier that will block the way. The thing is, in the array, it only deactivates the last barrier of the array.

I have an interface that controls the button logic to Activate(), Deactivate() and Toggle(). So why is it the last Prefab of the array the only one deactivating?

#
//interface code
public interface IFloorButton
{
    void Activate();
    void Deactivate();
    void Toggle();
}

//Barrier State code
public class BarrierSetState : MonoBehaviour, IFloorButton {

    private Animator m_Animator;
    [SerializeField] public BoxCollider2D m_Collider;
    [SerializeField] private bool isActive;
    private void Awake()
    {
        m_Animator = GetComponent<Animator>();
        m_Collider = GetComponentInChildren<BoxCollider2D>();
    }

    public void Activate() {
        m_Animator.SetBool("isOpen", true);
        m_Collider.enabled = false;
    }

    public void Deactivate() {
        m_Animator.SetBool("isOpen", false);
        m_Collider.enabled = true;
    }
    public void Toggle()
    {
        isActive = !isActive;
        if (isActive) {
            Activate();
        }
        else {
            Deactivate();
        }
    }
}

//Button code
public class FloorButton : MonoBehaviour
{
    private Animator m_Animator;
    [SerializeField] private GameObject[] m_AttachedObjects;    

    private IFloorButton m_Button;

    private void Awake()
    {
        foreach (var ObjectInArray in m_AttachedObjects)
        {
            m_Button = ObjectInArray.GetComponent<IFloorButton>();
        }
        m_Animator = GetComponent<Animator>();
    }

    private void OnTriggerEnter2D(Collider2D collider)
    {
        if (collider.gameObject.tag == "Player" /*|| collider.gameObject.tag == "Dynamic Object"*/)
        {
            Debug.LogWarning("Collision! Activating...");
            m_Button.Activate();
            m_Animator.SetBool("isPressed", true);
        }
    }
}
slender nymph
#
foreach (var ObjectInArray in m_AttachedObjects)
{
    m_Button = ObjectInArray.GetComponent<IFloorButton>();
}

what do you think this code here does?

midnight summit
#

well... is supposed to set the interface to every gameobject in the array

#

clearly

#

it doesn't do that

slender nymph
#

how many objects do you think that m_Button variable can hold?
-# hint: it is declared as private IFloorButton m_Button;

midnight summit
#

well can interfaces be arrays???

swift crag
#

an interface is a type

slender nymph
#

the interface cannot, no. but the variable of that interface type could be instead, yes

swift crag
#

IFoo is a kind of thing. IFoo[] would be an array of those things.

slender nymph
#

honestly though, that interface could really just be a component where it maybe has some unity events instead of method declarations, and other objects subscribe to those events. then you could drag the component references in the inspector instead of gameobject references that you then get the component from

midnight summit
#

so it would be private IFloorButton[] m_Button or private IFloorButton m_Button[]

slender nymph
#

well the latter isn't valid syntax. perhaps review the beginner c# courses pinned in this channel if you struggle with understanding the basic syntax of the language

midnight summit
#

ok thanks

languid pagoda
#

You could have just left it at "well the latter isn't valid syntax. perhaps review the beginner c# courses pinned in this channel" anything past that was just being an asshole

sour fulcrum
#

half the people here are on the spectrum

languid pagoda
naive pawn
#

"100% of people are on the spectrum, it's a spectrum"

sour fulcrum
#

real shit

#

i think people can be a little harsh in wording sometimes but that one just wasn't at all

rough granite
languid pagoda
#

nah what he said was needlessly harsh

midnight summit
#

I'm a bit rusty on c#

#

haven't been programming on it for a good while

sour fulcrum
naive pawn
#

imo it couldve been worded more gently but the content is appropriate

sour fulcrum
#

basic syntax isn't like a slight, it is what that means

slender nymph
#

literally was just "if you're struggling go review". anyone reading any further into it is just looking for a fight

naive pawn
#

i mean, telling someone "you don't understand this yet" kinda necessarily has a degree of harshness to it

midnight summit
#

honestly the last thing I need is people being soft about it, better to tell me "hey you are wrong here" than just being possitive in a way

rich adder
#

this whole convo shouldve ended 12+ messages ago

languid pagoda
midnight summit
#

if not, the toxic positivity mindset takes over and it gets everything worse

and I agree with nav

naive pawn
languid pagoda
#

nah yall are just chronically online or somet;hing

rich adder
#

its valid syntax, just not for C# . The suggestion as valid

sour fulcrum
#

i mean sure, again its a game dev server 😭

languid pagoda
#

someone would crashout on you if you said that to randoms in public

rich adder
#

you being atticus doesn't change how OP decided to take it..

languid pagoda
#

something tells me boxfiend gets punched in the mouth a lot

sour fulcrum
#

programming advice is a different context to talking to random people in public

rough granite
naive pawn
#

i agree it was harsh. telling someone "you are wrong" is necessarily harsh.

it couldve been worded more gently. quite subjective as to how important that is to prioritize.

i disagree the part about basic syntax shouldve been left off. that's useful information to the learner about what to review.

languid pagoda
#

I am just gonna drop it but yall need to stop being assholes to the newbies smh

#

its daily in here i open this chat and see the same 6 people talking down to someone who has prolly been fucking around with the engine for 2 hours

sour fulcrum
#

maybe don't use being on the spectrum as an insult if you want people to take that advice seriously

languid pagoda
sour fulcrum
#

brother

naive pawn
#

so you're saying being autistic is unintentionally being an asshole, or...?

slender nymph
languid pagoda
naive pawn
#

those "more words" were useful info bro

sour fulcrum
#

i hope you feel better man

midnight summit
#

haha yeah

mint imp
# polar acorn That is what the Singleton Pattern exists to solve: https://gamedevbeginner.com/...

I've been using singletons for a while now but i cant use those for each indiviual planet object that can be selected, only the manager that handles them.

I have 2-8 planet that can spawn at once, all with unique values.
When i select one i need to pass those values to the next scene but just dont know the best way to do that, im familar with scriptable objects but i create the values for those in the inspector, that wont work here where i need the values randomized. Is there anyway i can create a custom "Planet attributes" that holds all the values and can be stored into the next scene and read for the values.
Basically is there something like a scriptable objects that i can create in code at will and pass it around like a variable

polar acorn
#

Make a planet attributes class that holds your data, and make a list of them on your Singleton. Add a planet? Add to the list.

cosmic sable
#

currently in learn unity I think im stuck here

#

it gives me this error saying there is no definition for gameover

#

on my other code, I've already added getcomponent to connect the codes

teal viper
#

And then also share code correctly. (upload the whole script/s to paste sites).

#

!code

radiant voidBOT
teal viper
#

Also, your ide looks weird. It's like it's both configured and not configured at the same time. 🤔

cosmic sable
#

what the hell

#

now its working

teal viper
#

Likely didn't save the changes.

cosmic sable
#

I tried making a new function to add a debug log

#

it printed

#

then deleted it again then

#

added what I meant to added

cosmic sable
#

thats weird

#

anw thanks for answering my question, glad it worked out somehow

cosmic sable
#

I trie removing the particles and it worked

#

after I tried doing it again it freezed up again (without the particle)

#

nvm, camera issue, I tried switching to the game view without the dev view it worked out fine somehow

#

froze up again when I added the prticle

#

nvm I added while instead of if

#

I think im gonna sleep today geez

lofty summit
#

question, does anyone know why my shadow type on my light doesn't change it at all between shadow types? like i toggle between the soft and hard, but the light doesnt visually change.

Any help?

supple patio
#

Can anyone help me make a UI come up on my hand for a game

radiant voidBOT
# prime goblet !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**

supple patio
prime goblet
#

yea

#

click the link the bot sent

#

additionally if you need ui help (not people to make it) maybe suit #📲┃ui-ux

burnt vapor
#

They just need to use the proper channel

burnt vapor
winter monolith
teal viper
topaz gorge
minor pier
#

Heya y'all, this is probably a very basic question but how do i make it so the raycast is attached to the object instead of following it? i have mainly found people doing it this way but it kinda messes up my jump a lot where it stays stuck in the body and doesnt go back down which means no jumping..

        Debug.DrawRay(transform.position, groundcheck * 1f, Color.red);

        if (Physics.Raycast(transform.position, groundcheck, 1.1f, LayerMask.GetMask("Ground")))
        {
            IsGrounded = true;
        }
        else
        {
            IsGrounded = false;
        }```
Thought it'd be worth asking here cus like i said, i mainly saw people using a transform.position.
undone rampart
#

wdym by attaching it instead of following? Attaching implies following

naive pawn
#

it's pretty unclear what the issue you're experiencing is, could tou elaborate

minor pier
#

ah yeah sorry, basically what i mean is as if ur parenting it onto the object, same for if i would put the camera on the capsule as a first person camera, what its doing rn is following the transform by code, but its slow and follows behind with a small bit, what i want it to do is move as fast as the body itself, i might be able to record it if im still not making much sense

undone rampart
#

what is following? the ray cast?

minor pier
#

ya

undone rampart
#

where is this raycast called?

minor pier
#

fixed update

#

that might be the issue aint it..

undone rampart
#

what are you using for your character controller?

#

a rigidbody or a character controller

minor pier
#

rigidbody

undone rampart
#

then it should be fine

#

fixed update runs every physics tick which is the same as the rigidbody

#

i dont see the point of transform direction

#

you can just do -transform.up

minor pier
#

oh yeah bet

undone rampart
#

also you can simplify that logic to a property

#

public bool IsGrounded => Physics.Raycast(transform.position, -transform.up, 1.1f, LayerMask.GetMask("Ground"));

#

additionally I reccomend using a SphereCast instead of a ray cast, since the ray can give you false negatives when the character is hovering over an edge

minor pier
#

ohh yeah true

#

holdup lemme see if i can get that working :)

young condor
#

Hey does this server allow asking for help when it comes to modding an existing game?

minor pier
#
        if (Physics.SphereCast(transform.position, 0.6f, -transform.up, out RaycastHit hit, 1.1f, LayerMask.GetMask("Ground")))
        {
            IsGrounded = true;
        }
        else
        {
            IsGrounded = false;
        }```
Came to this currently, idk if i did it correctly, i did add an OnDrawGizmos but the shape it draws isn't fully 100% correct on where its at, it still stops me from jumping quite a few times.
young condor
nocturne crystal
#

i wanted to ask about how unity's tileset system works

so i have been working on a top down game

and i know about unity 2D tile set

i wanted to ask wether it would be better to create a fallback custom system for map saving
or using unity's inbuild system would be better?

naive pawn
minor pier
undone rampart
#

looks like your sphere is not correctly setup

#

it exits the player's bounds

minor pier
#

oh..

naive pawn
minor pier
#

ohhh

naive pawn
#

when i move normally the spherecast or raycast resets to its original position and
your cast is attached to the transform here. do you hvae multiple objects lagging behind each other or something?

undone rampart
#

I think a check sphere is more what you want

minor pier
minor pier
nocturne crystal
naive pawn
minor pier
#

here, its going quite alr for whatever reason now but i was spamming space bar so sometimes the raycast didnt come down for a solid sec, its been worse before recording tho

naive pawn
#

and how'd you draw that line?

#

physics visualizer or debug or gizmo?

minor pier
#
        Debug.DrawRay(transform.position, groundcheck * 1f, Color.red);

        if (Physics.Raycast(transform.position, groundcheck, 1.1f, LayerMask.GetMask("Ground")))
        {
            IsGrounded = true;
        }
        else
        {
            IsGrounded = false;
        }```
naive pawn
#

and what method was this in?

minor pier
#

fixedupdate

naive pawn
#

could just be the lag from that, perhaps

minor pier
radiant voidBOT
minor pier
naive pawn
#

if you put the debug call in Update, does it still lag behind

minor pier
#

lemme check

#

yep still lags behind

#

is it maybe easier if i just add a sphere as a child, turn off mesh renderer, add on collision enter & exit and just communicate that bool to the other script to allow me to jump n such?

naive pawn
#

that'd be one way to do a groundcheck yeah
it could be a trigger and then you wouldn't have to put it on a separate object really

#

that aside though.. this really seems like you have objects following each other, is this script on your player? and could you show the hierarchy of the player

minor pier
#

its with netcode btw, but i build the character controller before i added it so it shouldnt be that, the jump was already buggin beforehand, but thats why its a prefab basically :)

#

facing is just a small cube to show me where im facing for sanitys sake

minor pier
hearty ether
#

hi
Im trying to make grid based building system and I need to change pivot point for my buildings
is there any easy way to do it ?
(sorry for my bad english)

fickle plume
cosmic quail
river fern
#

Is AI good in C# ?

midnight tree
#

||You shouldn't have written this... run||

river fern
solar hill
river fern
#

Like for exemple claude or geminie

solar hill
#

yes

#

the issue with AI is that its short term usefulness is not worth the long term effects it can have on a persons skill

#

its simply not worth using

#

especially not for beginners

river fern
#

O ok i see

#

Thx 🙂

naive pawn
# river fern Is AI good in C# ?

for coding, it's a tool that requires a good understanding and solid experience of the environment you're working in to be effective. as a beginner, it's not going to help you learn, and you won't have the skill or knowledge to use it effectively.

rough granite
sage mirage
#

Hey, guys! I cant understand why the Unity doesn't throw an error when you are trying to pass vector2 to vector3

#

I mean syntactically its wrong and it will behave weirdly

polar acorn
#

Because Vector2 casts to Vector3

#

It just treats the Z as 0

sage mirage
#

I had a problem with animation only to realize that I have used Vector2 instead of Vector3 and I have stored on my moveInput Vector2 not Vector3

#

I mean I lost my entire day and Unity would have to throw a warning or an error at least

polar acorn
#

Casting Vector2s to Vector3s is a completely normal thing to do. MoveInput being on a Vector2 sounds completely standard, how are you inputting a Z-axis?

naive pawn
rough granite
tranquil forge
#

when i schedule a job does the job struct get copy on every worker thread for each execution or all of them able to access that one instance ?

brave compass
tranquil forge
#

dang guess i have to make it small, did you read this anywhere tho

verbal dome
#

Are you worried about the size of the struct in memory/memory bandwidth?

tranquil forge
#

just that i could do something a bit more work to avoid the memory and copy cost together, i have always thought it is shared fr

verbal dome
#

I'm just gonna say it's probably negligible compared to the overhead of starting the job/spinning up the threads

tranquil forge
#

yep probly but i could so imma do it anw fr fr

#

but any docs mention this?

obtuse hollow
obtuse hollow
# river fern Is AI good in C# ?

Yes it is okay if you are aware of many things regarding its usage. If you just rely on AI to do everything - it will fail, if you enchance your skill with AI or make it do repetitive work like generating a long simple code that needs to be written anyway - its a great tool.

errant breach
#

||Because one of the biggest pred on the french Youtube also was called Norman :(||

naive pawn
winter monolith
#

i heard of cinemachine is that any good

slender nymph
#

also yes, use cinemachine

winter monolith
#

am i just missing cinemachine now

swift crag
#

"dynamic update thing"?

winter monolith
#

for input system settings

#

moving horizontally is smooth now but camera rotations when moving is when it loooks weird

unkempt ledge
#

hola gente buenas tardes soy de argentina y estoy empezando como programador, aprendo rápido busco algún mentor que pueda ayudarme en mis primeros pasos. quiero hacer un juego en 3ra persona ¿alguien que le gustaría ayudar?

solar hill
unkempt ledge
#

Todo aquel que lea este mensaje, estoy empezando a crear un juego survival 3ra persona, pero necesito ayuda soy nuevo ¿alguien me daria con algunos consejos para empezar o que me ayude en el camino? gracias manden un mesaje y los leo

solar hill
unkempt ledge
#

i know little englis

solar hill
# unkempt ledge i know little englis

if you need to ask something use google translate, we cant and wont be translating what you are saying just to understand you, if we dont speak the same language

drowsy tiger
#

Does disabling domain reload not work with non serialized actions?

swift crag
#

i'm not sure what that means

drowsy tiger
#

(I know actions are not serialized, but I put it there to kinda force the point across just in case)

swift crag
#

if an object survives from one play session to the next, then those fields will retain their values

#

(I don't recognize the ClearOnReload attribute)

drowsy tiger
#

Yeah that

#

I plastered that too, to get it working

swift crag
drowsy tiger
#

Maybe because they're originally stored on scriptable objects?

sour fulcrum
#

yeah thats how scriptableobjects work

drowsy tiger
#

But they're NON serialized data!!

#

lol

swift crag
#

This code only works for static data

sour fulcrum
swift crag
#

so it's not going to do anything to OnStart or OnComplete, since these aren't static fields

drowsy tiger
#

Yeah I know. Those were just hail mary's

#

What's the "correct" way to clear scriptable object non serialized data on domain reload?

sour fulcrum
#

Someone might chime in with a stronger solution but i think if you have Awake and OnEnable both run a shared "init" function it should cover all the edge cases you need?

winter monolith
swift crag
#

notably, changing scenes will unload assets that are no longer referenced

#

but if you just enter and exit play mode in a scene, any assets that the scene requires will stay loaded

drowsy tiger
#

:(

#

Okay, I'll just force reset them for now

sour fulcrum
drowsy tiger
swift crag
#

They will run when the object gets loaded, but the object doesn't unload even when entering and exiting play mode

grand snow
#

never a good idea to keep runtime state in a scriptable object

#

There is some SOAP system that tries to fix this but believe me all it does is fuck up your data at stupid times 😐

swift crag
#

it's a lot like mutating any other asset, like a material

drowsy tiger
#

I was trying to store events in it

swift crag
#

one place I do store runtime data in my ScriptableObjects is for my settings system

#

each asset corresponds to a setting

#

on startup, i store a default value and then, usually, overwrite it after loading the settings file

#

therefore, it doesn't matter if the object stays alive; it gets reset by my settings system on next startup

sour fulcrum
grand snow
#

whatever subs should unsub on destroy/deconstruct (may cause infinite load)

swift crag
swift crag
#

e.g. you've created an asset out of the SO named "GameStartEvents"

#

and things in your scene reference this asset

drowsy tiger
#

Something like that. Its a bit more intertwined than just game start, as its for a Quest System

swift crag
#

right; this is just an example

#

the important thing is that you're using assets

drowsy tiger
#

Its easier for a designer to set it up with SOs

grand snow
#

A foolproof system that fixes this but keeps the ease of use would be an event bus that uses scriptable assets only for event ids/keys

swift crag
#

Do you wind up trying to execute delegates from the last play session?

drowsy tiger
#

Yeah. I cleaned them up for now, by resetting everything manually before subscribing

swift crag
#

I'm wondering why you're ever trying to call OnStart or OnComplete without ensuring that the object is configured correctly

#

ah, so it's less that you're trying to use it early

#

but the stale data from the last session still causes issues

drowsy tiger
#

I'm 100% sure its the stale data. I got the invocation list when I subscribe to it, and it was 2 for whatever reason. If I play after changing code, it works perfectly. If I play without changing code, it breaks

#

But nayway

#

Fixed it, I guess. Learnt something new

drowsy tiger
grand snow
#

by "break" did it just throw a unity destroyed/missing exception?

drowsy tiger
#

Nah, I got some logs that were a bit shady. Basically, I got multiple logs for the same objective ID on consecutive play sessions

grand snow
drowsy tiger
grand snow
swift crag
#

If this is an editor-only issue, then my first thought is to just fetch all of the assets with AssetDatabase on startup and clean them up

drowsy tiger
#

And the assets its referencing is still other SO's so 😂

swift crag
#

(since the game will...you know, close)

drowsy tiger
#

Well, that would be great. Assumes I actually make a build of this game again someday

faint scroll
#

please help me I don't understand why the color is displaying lighter than it should be

rich adder
#

unless you're coloring those with script and you can show the script

faint scroll
teal viper
#

Oh, I see you've been answered. Please avoid crossposting in the future.

faint scroll
#

okay, thanks for help

wicked stratus
#

sorry for deleting immediately after posting, I posted the wrong screenshots.
For some reason, OnEnable on a few scripts is being called before awake on a specific script. The GameObject with the script calling awake is active upon play. everywhere I am looking says awake should be calling before OnEnable, so I'm wondering if there are other common reasons why this may be the case?

I've tested with debug statements and the debug statements in OnEnable are appearing before the debug statements in awake, and it also gives a NullReferenceException error for something set in that awake that is being called in the OnEnable script.

weak hemlock
#

Hey, im fairly new to Unity, ive been watching a few tutorials and wanted to try making a dashing feature ontop of this 2D tutorial ive been watching.

It does "Work" the animations fire off, the player state is reset, gravity resets, im just confused as to why my player sometimes in the midst of their dash seems to stop or decide not to dash period (The animation still plays, but the distance they cover varies)

Im sorry if im leaving out important screenshots, I dont really ask in chats like this for help often if at all.

wicked stratus
radiant voidBOT
naive pawn
weak hemlock
rich adder
naive pawn
#

it's instructions to post code properly (not as screenshots and not as files)

#

it will make it much easier for us to help you

weak hemlock
#

Thanks.

#

no idea if I did it right

#

guess I did

wicked stratus
weak hemlock
naive pawn
wicked stratus
#

sure, give me a moment to recreate it

#

it is something I will need to have an actual fix for in the near future so I appreciate the help. i can comment out the offending code for now though.

naive pawn
#

they seem to have quite overlapping control, so they might just kinda be stepping on each other

weak hemlock
#

They are set on the animation timelines, disabled at the start of the animation, enabled at the end

naive pawn
#

right, but which animations

weak hemlock
#

playerMove has the EnableMovementAndJum

playerDash has the EnableDash, DisabledDash

#

I likely misunderstood what your asking

naive pawn
#

so it seems like perhaps DisableMovementAndJump is resetting the dash

wicked stratus
naive pawn
naive pawn
weak hemlock
#

Fuck sorry my bad... its not playerMove

#

playerAttack has those

#

my heads, sideways

naive pawn
#

gotcha

#

that makes more sense

#

in that case you could probably do away with all the canMove/etc and then set just isAttacking/isDashing and go based on those

weak hemlock
#

probably, thankyou regardless.

dull slate
#

I'm having trouble getting player movement/player controller scripts to really click for me. It seems like there's so many ways to write them using the new and old input system. Is there a sort of right way to always do it? Like specific rules to follow?

dreamy wraith
winter monolith
#

why isnt this timer working i feel like it should be working

rich adder
dull slate
winter monolith
#

it doesnt happen again

dreamy wraith
#

they can se if they understand itt

#

ill send a ss so they have to type it still 😄

rich adder
#

copy and pasting something is the same as blindly copying..

dreamy wraith
#

alr no copy and paste thenn

dull slate
#

I can type it out and write comments to see if I understand what's going on maybe?

#

without executing it

dreamy wraith
#

yep smart

naive pawn
winter monolith
naive pawn
#

jumptimer is a local variable, so it's setting that one to 0. the next time you call jumping(), it gets a new jumptimer variable, which starts back at Time.time + 0.1f * Time.deltaTime

winter monolith
#

interesting

#

this fixed it

#

thanks

wheat tangle
#

question how would I rotate a vector by a y from a Euler angle

naive pawn
wheat tangle
errant breach
#

Hello ! Im trying to give my camera to "Target", but it doesn't work wich is normal.
What can i do so that i can give a prefab the camera ? Thank you ! I tried "target = GetComponent<CameraShaking>();" which doesnt work-

sour fulcrum
#

is there a camerashaking component on that object that code is running on

keen dew
#

If the CameraShaking component is on the main camera it's a special case and you can do target = Camera.main.GetComponent<CameraShaking>();

#

otherwise put the reference on the component that instantiates this prefab and pass it on

polar acorn
rare condor
#

I'm getting this warning, why does it want this property as serializable? I don't really want it to unless necessary. It's not a data holder in a sense, that's separately. It has some runtime data.
Is it because it's public and shown in editor properties?

errant breach
#

Oh wow sorry, thanks IAmBatny, Nitku & digiholic for trying to help, but a friend already did and i forgot to delete my message, sorry for that and thanks again ! :D

polar acorn
rare condor
#

Sudoku class is not currently, error goes away if i make it

#

I don't need it editable

slender nymph
#

If it doesn't need to be serialized you can mark the variable as NonSerialized

ivory bobcat
#

Well, that's what the error is telling you. You're attempting to make it serializable with the public modifier but that would be impossible as the class isn't serialized. Thus a warning is simply given.

rare condor
#

ok this makes warning away:
[NonSerialized]
public Sudoku sudoku;

polar acorn
#

Yep, that'd do it. Basically, you got one thing saying "Serialize this" and another one saying "Don't serialize this" and the compiler was just trying to guess which end of the problem was the mistake. Generally, people want variables exposed to the inspector, so it is probably designed to give that warning first

rare condor
#

Just switched to Unity 6.6 alpha and it's giving more code guides than before, good thing i think

#

But also some things are becoming deprecated and i'll need to workaround

#

BinaryFormatter...

keen dew
#

tbf BinaryFormatter has been obsolete for at least 6 years

swift crag
#

at least it's not as catastrophically bad as, say, python's pickle

#

which will literally just run arbitrary code

keen dew
#

That's what it does though

#

That's literally the problem, it serializes methods so you can inject whatever code you want

rare condor
#

I was just using binary format because i like highscore table not easily editable. I suppose i should use some compression or format method instead then

swift crag
#

oh yeah, if you want to discourage trivial editing, just serialize to json and encrypt it or something

#

it's obviously bypassable, but it'll make it slightly more annoying

teal viper
#

You can still write binary files. Binary formatter is not the only way.

swift crag
#

yes, BinaryFormatter just happens to be one way to do so

rare condor
#

and it's supposedly super fast compared to string manipulation of JSON

swift crag
#

https://googleprojectzero.blogspot.com/2017/04/

In an ideal world we’d find that one serializable class which just executes arbitrary code for us. Sadly (as far as I know of) no such class exists. So instead we’ll need to find a series of “Gadget” classes which when chained together perform the desired effect.

#

gadget-chaining is a fun topic

#

oh, lol, but then they explain that ObjectSurrogate lets you do this as long as you can find something that runs an arbitrary delegate

night raptor
# rare condor and it's supposedly super fast compared to string manipulation of JSON

I doubt binary formatter is "super fast", writing to a binary file sure is usually faster than JSON but for you writing a score or whatever game state it won't make any difference. Even so, didn't binary formatter write a TEXT file with 0s and 1s in it? I might remember totally wrong but from my recollection, binary formatter didn't produce a binary file but a text file which is really silly to begin with

rare condor
night raptor
night raptor
# rare condor and it's supposedly super fast compared to string manipulation of JSON

All the other performance comparisons I can find seem to indicate the same, at best comparable performance to JSON and XML serializers and definitely slower than other binary serializers like Protobuf. Fastest of all would probably be your own binary writer but that you probably shouldn't worry abou the performance unless you are saving a ton of data.

#

My best guess would be that it might rely heavily on reflection but I never looked into how it works since it has been known for a long time that it is insecure

rare condor
#

Well, i know many games go the lazy way with data, at least including Civ V and so on with astonishingly slow turn change processing. You can only suspect they spend majority of time comparing strings

night raptor
#

Very possible, but again, you would need to save a ton of data for it to matter. Especially if you only need to save at the start and end of the sessions, it wouldn't really matter whether it takes 1ms or 10ms would it?

rare condor
#

no that's nothing, it's when it's 10000ms i twitch badly

night raptor
# rare condor Well, i know many games go the lazy way with data, at least including Civ V and ...

Never played the game but AI overview seems to suggest the lag in question would be caused by AI navigation and such rather than any saving or loading. Believe me, you can serialize and deserialize a huge amount of JSON data before it takes 10 seconds. Unless you have gigabytes of data to store, you can use JSON without having to worry about anything with such generous budget of 10 sec 😅

rare condor
#

well, that's not what really troubles me, it's that my json file now contains nothing but this:
{}

#

I debugged there are 12 tables that should be in it

night raptor
#

Where's the trouble though?

rare condor
#

string s = JsonUtility.ToJson(highScores, false);
Debug.Log(highScores.Length);
File.WriteAllText(highScorePath, s);

night raptor
#

Would you mind sharing the whole script? It would be really useful to see what type highScores is etc.

rare condor
#

public static HighScore[] highScores;
...
[Serializable]
public class HighScore {
public string[] name = new string[MainScript.NumHighscores];
public float[] number = new float[MainScript.NumHighscores];

public HighScore() {
    for (int i = 0; i<number.Length; i++) {
        this.name[i] = "-";
        this.number[i] = -1f;
    }
}

}
... there's some sub classes too

#

i get no hints or warnings about the codes

#

it saved perfectly when i still used the binary saving

#

only difference is json now

night raptor
rich adder
#

you're right

#

static is a no go

rare condor
#

will change

rich adder
#

BinaryFormatter or whatever else in System is not Unity so it doesnt follow Unity serialization rules

#

JSON.NET would do the same as the System one and serialize it..

#

but also do they really need to be static ?

#

i would do

[Serializable]
public class SaveData{
    public HighScore[] highScores;
}```
night raptor
rare condor
#

It's working like that, a container class that includes the table in it, + it's no longer static

#

//public static GameConfig config = new GameConfig();
public static GameConfig config = new();
Is this really the recommended way now?

rich adder
#

both are perfectly valid, the former will give you backwards compatibility with older C# versions / Unity versions if you care about that

foggy sparrow
#

Hi, im trying to make a drop system for my inventory inside a 3D game. I have a prefab made for generic item type with some script to handle picking up and some thing stuff.

How do i go about generating the prefab inside my scenes when i want to "drop" an item to the ground. i found out about the Instantiate() function but i don't really see how i can initialize some value to my newly created game object.

If anyone can link me a good article or just a page in the docs to learn how to do that that could be awsome thx ^^

#

(i have bhen at it since 2hours on and off but i cant wrap my head around it)

naive pawn
foggy sparrow
#

thx

urban cargo
#

Modder here. Is there a way to get all of the resources at runtime? I'm trying to get data from objects that are only loaded from prefabs at runtime.

solar hill
urban cargo
#

That's fine. but it is a valid runtime Unity question.

urban cargo
#

I was using that. I expected <Object> to return the MonoBehaviours and the GameObjects using that. I'm probably just doing something wrong. Doing more testing.

Thank you for the response.

wintry quarry
urban cargo
#

Luckily VS caught that for me.

urban cargo
#

Yeah, I was definitely doing something wrong. I was able to match up a MonoBehavior to a UnityEngine.Object when using FindObjectsOfTypeAll.
thanks again for the help.

wide kraken
#

thx!

north pilot
#

Breh I’m having trouble with player movement can someone help

#

Cinemachine and new input system

#

It’s like the player moves on global space not local

slim stag
#

So I’m wondering like, does scripting just get to a point where you know how to do almost everything you want to do off the top of your head or do even the experts constantly reference other material to know what they want to do the code they write?

#

Sorry, wasn’t sure if this is a question for beginner or general.

teal viper
slim stag
#

Recently learned that Unity Learn has a beginner scripting course so hopefully that’ll help.

teal viper
swift crag
#

ideally, i figure it out and start implementing it on my own later on

slim stag
teal viper
#

Then trying to implement my own "dream project".

slim stag
slim stag
still ingot
#

Hi how do I make a ray cast that is oriented with the player model? Every time I set the forward direction of the ray cast it is always facing forward and not rotating with the player object?

 [Header("Ledge Check")]
 public Transform ledgeCheckerStart;
 public float checkDistance;
 public LayerMask whatIsLedge;
 bool isLedge;

 private void OnDrawGizmos()
 {
     Gizmos.DrawRay(ledgeCheckerStart.position, ledgeCheckerStart.forward * checkDistance);
 }

 private void FixedUpdate()
 {
     isLedge = Physics.Raycast(ledgeCheckerStart.position, ledgeCheckerStart.forward, checkDistance, whatIsLedge);
 }
swift crag
#

sounds like this "ledgeCheckerStart" object is not rotating with the player!

#

Transform.forward is the world-space forward direction for a Transform, so that is the appropriate thing to use

teal viper
swift crag
#

(wrong reply)

#

I can't really remember how I started in Unity

slim stag
slim stag
swift crag
#

I have a strong programming background, so I think I just poked at docs pages and clicked on things. I've always been able to find my around new software pretty quickly.

Reading the manual is great; it will quickly introduce you to important concepts

#

e.g. "what is a GameObject"?

#

you don't need to read it cover to cover, of course

slim stag
#

Right.

#

It’s just… not that I expect to learn everything overnight, I just feel likely I’m hardly getting any grasp of this scripting thing like at all but imma keep at it.

still ingot
#

isLedge = Physics.Raycast(ledgeCheckerStart.position, this.transform.forward, checkDistance, whatIsLedge);

still ingot
swift crag
#

did you also update the Debug.DrawRay line?

still ingot
#

yeah this is what I currently have:

    private void OnDrawGizmos()
    {
        Gizmos.DrawRay(ledgeCheckerStart.position, this.transform.forward * checkDistance);
    }
swift crag
#

okay, then whatever this is isn't an object that is rotating

still ingot
#

This is code from the PlayerLedge script

swift crag
#

right, and the Player object is not rotating!

#

its rotation angles are all zero, and since it has no parent, it has no world rotation at all

#

(if it had a parent, its parent could be rotated)

#

Switch your scene view to Local, not Global, and then switch to translation by hitting W

This will show arrows for the selected object

#

red/green/blue are right/up/forward

still ingot
#

Okay I see now!

meager lodge
#

yo is there anyone who could help me on vc if they just have some time

sour fulcrum
#

nope

#

sorry

meager lodge
#

gang if you didnt want to just say nothing

sour fulcrum
#

no as in

#

theres no vc's on this server

#

no one will be doing that

rough granite
meager lodge
rough granite
meager lodge
#

mb

meager lodge
rough granite
meager lodge
#

my problem is kinda everything i just downloaded unity and i wanna make a game but i dont know what to do first

radiant voidBOT
meager lodge
#

when i create a 3d object that come up

rich adder
meager lodge
#

oh ye

#

didnt do that

rich adder
#

without knowing the tools you're going to be using you're going to struggle, start with the essentials pathway etc.

meager lodge
#

idk what that is

rich adder
#

its in the pathways found in the link I sent..

sonic egret
#

please

rich adder
sonic egret
#

mb thought answering was fine and it was just tagging

#

that was bad

rich adder
#

if someone sees the thread and have an answer they will do so..
and the grounded is most likely poorly written or using OnCollisionEnter or variants that trigger from any sides

sonic egret
#

fair point it is indeed poorly done
must I say I'm still learning
I tried a few variants but nothing very concluent and nobody's been answering for a few hours

rich adder
#

the simplest things to do is to learn things like raycast or other casts

sonic egret
#

feel kinda helpless at that point coz every forum I could found were years ago and filled of people being like "could find the answer on google in 30 seconds, skill issue"

rich adder
#

I mean technically you can, especially with this ai slop practically feeding you answers

sonic egret
rich adder
#

using colliders was the reason its too simple to work well

sonic egret
rich adder
#

hence the "complicated" solutions, you have to start getting more complex if you plan on advancing

#

everything looks complex at first glance, its not that bad

sonic egret
#

fair point
will dig into raycast then

#

I'll put updates in the thread, but tomorrow coz its late
thanks for the help

meager lodge
#

yo idk if this is how this works or not but if you go to game in the top is there a way to play the game or idk

sonic egret
#

in the middle

rich adder
#

this gotta be some type of troll post

meager lodge
#

but when i click that i still cant move

rough granite
rich adder
#

You need to start from the basics and know how to navigate the editor including potential errors you're ignoring in console

meager lodge
meager lodge
rough granite
meager lodge
#

just downloaded it

sour fulcrum
#

the come back when you have

upbeat bone
#

Can someone send me a message on discord and please get me show me how to spcirt on Roblox.

rough granite
sage mirage
#

Hello, guys! I dont know if this question is related with Unity but there is a concept in Programming called Single-Threading and Multi-Threading that we were discussing in class yesterday and a teacher told me that Unity handles everything on a single thread instead of multiple threads. What does this mean and what is the difference between them?

naive pawn
#

What does this mean
that unity is primarily single-threaded, at least for the part that you care about. multi-threading is supported with jobs/burst, that kind of stuff, iirc.
what is the difference between them
with separate threads you can have things in parallel, rather than just concurrent (at the level you're working at. in the cpu they may still be concurrent). you can look up "parallel vs concurrent" to see some diagrams explaining the difference

#

stuff like Update timers or coroutines are concurrent, for example.

keen dew
#

Didn't you just say that you attended a class yesterday discussing them and their difference?

sage mirage
#

it will be next week lecture

#

we just did a small introduction

sour fulcrum
#

imagine doing stuff irl with one arm/hand, thats what Unity mostly does

#

if you have two arms/hands you could do two things at once

sage mirage
sour fulcrum
#

The big kinda thing with Unity is most modern cpus have a fuckton of cores and thread (hands) but Unity isn’t built to use all of them

#

but ofc how fast you can do stuff with a single hand changes how much that may or may not matter

cosmic sable
#

just finished C# Fundamentals from Bob taylor and Learn Unity. Should I keep debugging challenges or go immediately to creating systems?

#

honestly very unsure haha, I was very confident I could code now, but I still get stuck a lot and stare at a wall

cosmic sable
#

whats that mean

sage mirage
#

Basically it requires skill and practice

#

you wont be good only just because you have attended a course

hard fossil
#

Learn by doing. You'll come accross plenty of challenges naturally and still be working on something you like, don't bother just doing exercises for the sake of learning.

cosmic sable
#

👍 so brute force coding, got it

sage mirage
#

Courses are very useful for foundation knowledge but after you get some experience you wont be needing them

hard fossil
#

Not brute force, learn by doing. Don't write the code if you don't understand it.

sage mirage
#

Personally, I dont need courses to learn something I just follow project-based learning approach

#

Just learn stuff you will need for your project you are developing

#

do not try to learn everything at once

rough granite
cosmic sable
#

very interesting advices, I will take note

hard fossil
#

Sebastian Lague's youtube videos are fantastic, but they're more for the advanced side.

sage mirage
#

haha

rough granite
# cosmic sable whats that mean

to re say what they've said, while you may have spent the last few hours learning a bunch of stuff at once it'll take you another few days to break down what you've learnt into manageable and rememberable information that you can reuse

rough granite
cosmic sable
#

thanks for the advice guys. ill go sleep now

rough granite
cosmic sable
#

I was pressured, but after hearing u guys Im calm now

sage mirage
hard fossil
#

Also, most of the tutorials I've seen on Youtube, like Brackeys, teach bad coding practices.

sage mirage
#

I have seen many vids about DP

hard fossil
#

DP?

rough granite
# sage mirage I mean all beginners do watch tutorials but they are trapped in tutorials hell t...

oh yeah few years back now i really wanted to try and get into game dev and i went through ai to do so "made" a few projects that turned out awful and felt like crap. ended up with me not touching unity (or any other engine) for about 3 years .When i took a proper course in school on programming and decided to get back into game dev and i can certainly say since going to school for programming i haven't needed a tutorial like i did before hand.

sage mirage
hard fossil
#

Oh yeah, actually AI, like ChatGPT is a fantastic tool for debugging or understanding code better. You can copy and paste and ask what's going wrong, or an explaination for how things are working on code you may not understand fully as a beginner, and can get deeper insight.

rough granite
hard fossil
# sage mirage Design Patterns

Brackeys is mainly tutorials on features, so it's more Unity focused, rather than C# (in general), so they kind of just teach code that works, but isn't good standards.

sage mirage
sage mirage
#

As a beginner you dont know how to code and it can be misleading

#

You have to know how to code to be able to interact with AI properly otherwise you just waste your time.

hard fossil
#

Anything can be misleading, but as an aide to coding, you'll understand more having it than not.

rough granite
hard fossil
#

I'm talking about not for generating code, as I've said in my comment, but from getting more insight into bugs, and how your code is working.

rough granite
ivory bobcat
#

I recall there being a dedicated channel for this type of discussion..

sonic egret
#

I'd argue that some practice can be useful but with AI as a complementary tool
I remember using it in python saying "what is this function" so it would explain something specific for me
Really useful to learn and comprehend, tho it shall not be used to generate code

rough granite
hard fossil
#

AI is just searching a database of all the code it stole from GitHub, to simplify. So to just disregard it as a tool is unwise. It is powerful if used correctly, and not overrellied on, as well as understanding, it is trained on data from humans, and just like humans, it will tell you incorrect things sometimes. More often than not for simple code for beginners (e.g. solved problems, not so novel) it will be able to explain deeply or answer deeply questions you have about code you wrote. I don't suggest using AI in your IDE but copy/pasting into ChatGPT can help you question your code.

naive pawn
#

it's definitely a tool you need experience for to use correctly. a beginner would not have said experience

sonic egret
#

indeed

naive pawn
#

also, yknow... it's been trained on the stackoverflow questions too

sonic egret
#

and as useful as it can be, overall the less you use is the better, both from a learning point of vue and a ethics point of vue

sonic egret
hard fossil
sonic egret
#

sure, but it is to be taken in account imo
thats why I try my best not to use AI

#

but yeah its a whole other debate

hard fossil
hard fossil
sonic egret
naive pawn
hard fossil
#

That's true. But if we're talking about whether LLM's are useful or not, I don't think that's really debatable. ChatGPT I do use, but shouldn't if I'm fully aligning with my morals, but their are other alternatives, like Proton's Lumo, that fully encrypts and doesn't collect data. These LLM's are going in a better direction I think.

naive pawn
#

they are not useful for learning, and that's what's important for a beginner

hard fossil
#

Ok, sure we'll agree to disagree.

sonic egret
hard fossil
#

Completely agree with you in terms of how companies are using the technology. The technology itself though, is very powerful.

naive pawn
#

it is, but it's incredibly easy to misuse without experience

hard fossil
naive pawn
#

both are required

sonic egret
#

also I think that its hard to blame people for using it, its a very convenient tool and it has a lot of great usage so its understandable

hard fossil
# naive pawn both are required

They aren't. By that logic, LLM's wouldn't be able to answer questions. Learning is the asking of questions and getting answers.

naive pawn
#

LLMs were not built for truth, my logic leads to that conclusion, yes

sonic egret
sage mirage
#

@hard fossil how much experience do you have in the industry?

#

both programming and game dev?

sour fulcrum
#

We probably don’t need to continue this

upbeat hinge
#

can someone help with my script, the jump and double jump aren't working

frail hawk
#

post the code and use a code bin !code

#

!code

radiant voidBOT
upbeat hinge
frail hawk
#

one of the links shown above

upbeat hinge
#

ok

ionic flax
#

I was told to null check unity objects like SO's I don't need to use != null and can instead just bool check(?) it like this, but my IDE/the nullable package does not really like this
is there a way other than adding != null or doing moonInfo.RouteNode!.itemCost to suppress the warning more naturally?

naive pawn
#

what's the warning you're getting?

ionic flax
#

just the one you'd expect i think

naive pawn
#

i would not expect anything in particular because i have not used nullable lol

ionic flax
#

oh fair lol

#

it's pretty neat, but can be annoying with unity objects since I like to not include the != null part (partly because rider also yells at me for that iirc)

naive pawn
#

that warning on rider is kinda over-eager tbh

#

it's not technically wrong but it usually doesn't matter, some things you just have to do

#

i would guess that the bool check doesn't "inform" the nullable static analysis that it's been checked

ionic flax
#

yeah :/ was wondering if there was a way for it to but might not be

pseudo hull
#

Hey, does anyone know why my camera sometimes behaves weirdly as in teleporting to "random angles" in my first person 3d game?

Playercam.cs

using UnityEngine;

public class PlayerCam : MonoBehaviour
{
    public float sensX;
    public float sensY;

    public Transform orientation;

    float xRotation;
    float yRotation;

    private void Start()
    {
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible = false;
    }

    private void LateUpdate()
    {
        // get mouse input
        float mouseX = Input.GetAxisRaw("Mouse X") * Time.deltaTime * sensX;
        float mouseY = Input.GetAxisRaw("Mouse Y") * Time.deltaTime * sensY;

        yRotation += mouseX;

        xRotation -= mouseY;
        xRotation = Mathf.Clamp(xRotation, -90f, 90f);

        transform.localRotation = Quaternion.Euler(xRotation, yRotation, 0);

        if (orientation != null)
        {
            orientation.rotation = Quaternion.Euler(0, yRotation, 0);
        }
    }
}

naive pawn
pseudo hull
#

im so stupid tysm

keen acorn
#

Hiya guys, I've been trying to code a wheelofnames style roulette wheel on unity. Right now, the wheel just chooses a random z for the rotation, and lerps to it. Obviously not the right choice, it rotates forwards and backwards, and at different speeds. But I also tried giving it a RigidBody and setting its angularVelocity, which seems fine, but I don't know how random it really is. Besides, I'd like to be able to set the result via code in some way. How should I go about implementing the wheel?

#

Here's the current script i've got

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

public class RotatingWheel : MonoBehaviour
{
    public int outcomes;
    public float rotational_force;

    float target_z;

    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            target_z = Random.Range(0, 360);

            int result = calculate_result(target_z, outcomes);
            Debug.Log($"Target: {target_z}, result {result}");
        }

        Quaternion target_rotation = Quaternion.Euler(transform.rotation.x, transform.rotation.y, target_z);
        transform.rotation = Quaternion.Lerp(transform.rotation, target_rotation, rotational_force * Time.deltaTime);
    }

    int calculate_result(float rotation, int outcomes)
    {
        rotation = rotation % 360;
        int result = outcomes + 1;
        while (rotation > 0)
        {
            rotation -= 360f / outcomes;
            result--;
        }
        return result;
    }
}
keen dew
#

Don't read the rotation from the transform, store it at the start and use that instead.

Vector3 currentRotation;

void Update()
{
    if (Input.GetKeyDown(KeyCode.Space))
    {
        currentRotation = transform.eulerAngles;
        target_z = Random.Range(0, 360) + currentRotation.z;

        int result = calculate_result(target_z, outcomes);
        Debug.Log($"Target: {target_z}, result {result}");
    }

    currentRotation.z = Mathf.Lerp(currentRotation.z, target_z, rotational_force * Time.deltaTime);
    transform.eulerAngles = currentRotation;
}
naive pawn
#

you could set a target as something in the range of like, 720 to 3600, and then you can smooth a value up to that value, then only set it the rotation to the transform

keen dew
#

The "wrong lerp" isn't great but that should fix the immediate problem

naive pawn
#

you should not read back transform.rotation components

#

especially not like that, since transform.rotation is a quaternion lol

hard fossil
hard fossil
naive pawn
#

i know how LLMs work, thanks.

night raptor
#

You are not, it is very common mistakes which a lot of tutorial makers have made as well making it very common among beginners. DeltaTime is often required but mouse input just happen to be an exception as it is already the delta of the mouse movement (how much it moved since the last frame)

rare condor
#

LLM's are amazing, you just need to push them for answer a little bit and not trust the first thing it spills out. Doubt its discovery etc, it will more often than not end up giving something really useful

#

I have a 20b gpt model installed on desktop PC offline, and yesterday gave it some long sequence of base-64 encoded string. It just happily analyzed its json format out. Did not take more than a minute

cosmic dagger
pseudo hull
#

Btw, does anyone know why the version control doesnt seem to detect scenery component changes, as i just changed a value and it still tells me im up to date

naive pawn
#

make sure you've saved

pseudo hull
#

yea it seems to now have sent the scenery but only the changed part. for some reason on his end the components are not set correctly though, is there anyway i can send the entire scenery and have him force pull it

hard fossil
naive pawn
#

LLMs are perceived as a source of truth to beginners yes

naive pawn
hard fossil
pseudo hull
#

yeah but for some reason the scenery doesnt seem to carry over correctly, i just modified a number in the components of my player and uploaded the scenery, after he pulled it though nothing changed for him

naive pawn
# hard fossil Ok, so a source of information that is often correct shouldn't be used because y...

LLM usage is private. when a beginner gets a wrong answer, they may not have enough experience to see any part that may be inaccurate.
in sources like wikis, any user who knows something is wrong can fix it. in youtube tutorials, mistakes can be pointed out in the comments. in docs, PRs are made to fix inaccurate content. in community forums or servers, other helpers can challenge the incorrect answer. this is what makes them more reliable.

#

inaccurate base assumptions cause a lot of pain as you get into more complex stuff, and honestly it is an incredible pain for us as helpers

#

very few people, and even fewer beginners will share their entire thought process that would reveal the incorrect assumption. it wastes months of time just to learn something basic.

hard fossil
#

I can't really argue with something like, oh but someone out there might misuse it, so therefore it bad. So I'll leave it at that. They have their strengths and weaknesses just like any other way of getting information.

naive pawn
#

95% of the usage from beginners ive seen here, in other servers, in real life, have been misuses.

hard fossil
#

It seems like you don't really have any argument against LLM's, only what you think people's perceptions of them is.

naive pawn
#

just hedging my bets there, i don't recall any proper usage of them to actually learn

#

my arguments have been against.. beginners using LLMs, not against LLMs as a concept.

hard fossil
#

To be more specific, your arguments are only against LLM's being misused. My argument is that LLM's are a good teaching aid. Every teaching aid in the world can be a bad teaching aid, if it's misused or taken as gospel, that is obvious.

naive pawn
#

wow another strawman

#

LLMs aren't even a teaching aid to begin with

hard fossil
# naive pawn wow another strawman

I'm not sure you understand what a strawman argument is. I didn't make one. I didn't assume your position and argue against it.
LLM's have been a teaching aid for me, so to say they cannot aid in teaching something is just plain wrong.

somber lantern
#

why does this happen, can someone please explain?

naive pawn
#

you've made several assumptions about my position lmao. i'm not interested in discussing this

dry pulsar
#

Anyone has a hint?

hard fossil
# dry pulsar Anyone has a hint?

Create a cooldown variable, and add time to it, when the time is past a threshold, allow the player to spawn it, and reset the cooldown variable again.

dry pulsar
hard fossil
#

What do you have so far?

cosmic dagger
# hard fossil So beginners in any field of knowledge take everything as truth? Therefore they ...

I didn't say any field of knowledge. I assumed we were talking about beginner programmers (hence the channel). It's "better" to use when they have learned knowledge of the subject bcuz they'll know, or at least have an idea when it gives wrong/incorrect results

We've seen, too often, incorrect AI code, or even code they can't use bcuz they don't understand it

This makes it harder for us to help . . .

cosmic dagger
hard fossil
# cosmic dagger I didn't say *any* field of knowledge. I assumed we were talking about beginner ...

I never advocated to use AI to generate code. I'm talking about getting a deeper understanding and explanation of how your code is working, how it can be improved, and what potential bugs it could produce, AI is excellent for this. For example, following many of Brackey's tutorials, one of the biggest Unity tutorial channels, solely, would lead to bad programming practices. If you follow the tutorials though, I'm sure you would learn some helpful things. Now if you took your running code, and wanted to learn more, you could copy and paste parts into say ChatGPT, and it would tell you how you could improve it by doing certain things, why doing things the way you were doing could lead to errors, and why another way is an improvement. If someone doesn't check multiple sources when learning new information, I think that's a whole other issue. I don't think that other issue nullifies the point that LLM's are useful as a learrning aide.

hard mantle
#

For someone that has 0 coding experience, would the junior programming pathway on the unity learn site give me/learn me the basics of unity c# coding? If it does wha would you recommend me do afterwards. And if it doesn’t where should I start

rich adder
keen acorn
rich adder
#

They definitely assume you know the basics

#

basic code structuring, variables etc.

keen acorn
#

I later did the CS50x course online, which i recommend quite a lot. Won't do much advertisement, but it's free, assumes no previous experience, and features quite some good problem sets

hard fossil
# hard mantle For someone that has 0 coding experience, would the junior programming pathway o...

Welcome to this introduction to game development. We'll be starting from the beginning, so no prior knowledge of programming or the Unity game engine is required.

Unity can be downloaded here: http://unity3d.com/get-unity

Watch episode 01: https://youtu.be/9iCnjdXEfMA

If you'd like to support these videos, you can make a recurring monthly don...

▶ Play video
rich adder
twin pivot
twin pivot
cosmic dagger
hard mantle
sour fulcrum
#

aside from velocity being renamed everything in old tutorials should work

#

Feel free to ask about specific problems your running into

hard mantle
#

Oki thanks man

naive pawn