#💻┃code-beginner

1 messages · Page 575 of 1

trail heart
#

Most tend to be blobnodslow

inland cobalt
#

If i have a collider referenced in a script as so:

    [SerializeField] private SphereCollider _grabTrigger;

How can i check for OnTriggerEnter on _grabTrigger, rather than the collider of the object the script is attached to?

wintry quarry
#

you can have that script call this one

#

or fire an event

#

or whatever

cerulean badger
#

i've done a simple trigger zone script, that used to work perfectly playing the right music at the right places. But then I've removed the music and left an empty placeholder to avoid errors, so I put the music back and reconfigured everything as it was before, and its not working

#
using UnityEngine.Events;
using System.Collections;

public class ZoneTrigger : MonoBehaviour
{

    [SerializeField] private GameObject musica;
    bool TaTocando = false;

    void OnTriggerEnter2D(Collider2D collider){
        if(TaTocando == false){
            TaTocando = true;
            musica.GetComponent<AudioSource>().Play();
        }
    }

    void OnTriggerExit2D(Collider2D collider){
        TaTocando = false;
        musica.GetComponent<AudioSource>().Stop();
    }
}
polar acorn
cerulean badger
#

actually my problem is that all musics are playing at the same time when I play the game, but I'll do these both

#

oh I realized my autistic brain forgot to deactivate Play on Awake, sry for wasting ur time

#

but tysm for those tips btw, mainly the second

mental palm
#

well thats whats confusing me theres no line given

#

its just the error

opaque mural
#

So i recently started to make an project, its an indie game and i am also signed in IT school where i am learning C language and just a question. With which language should i make games?

slender nymph
#

if you're using unity then you'll use c#

opaque mural
#

Yes

rich ice
opaque mural
#

Seems simple for me

rich ice
#

well, you'll be using c# then. like boxfriend said

opaque mural
#

Alright

#

The game is like about car building life simulator things like that, mainly about a car, like it has mechanisms of each part, condition of each part

#

I am worried about suspension i dunno how to do that

slender nymph
#

start by learning the basics of the engine before diving in and creating something

forest summit
#

why cant i apply .drag to a rigid body? unity said i had to use lineardamping instead but nothing works. Its supposed to apply to my character and slow them down. Are .drag and .lineardamping the same?

slender nymph
#

yes, it's literally just a rename

rich ice
#

are you using unity 6? (i think they just changed the naming of a few variables in the rigidbody, in unity 6)

forest summit
#

yeah ok

#

thank you thats what i first suspected

violet glacier
#

Hi, I'm making a 2d turn based game.

I need to have enemy information (lv, hp, atk, def, sprite, animation controller alive, etc.) somehow stored. I need to show the user the base information (base atk, def, animation, etc.) in the menu, and also show in battle (e.g. atk may be different than base atk based on buffs). What's the best way to store this data? Prefabs, scriptable objects, json?

I can provide more info if needed

cerulean badger
opaque mural
cerulean badger
rich ice
opaque mural
#

For example the mechanics from My summer car indie game if you ever heard of it

cerulean badger
opaque mural
#

But not too much realistic

cerulean badger
#

there's smth similar to that in mobile but with pc instead of car

#

I think the name is PC Simulator 2

opaque mural
#

And when you fix the car and start driving the conditions of parts will wear down which requires maintenance of car

cerulean badger
#

you could try it to get inspiration

opaque mural
#

First of all

#

I need to get the car into game

#

The model how i am gonna get it i don't know.

cerulean badger
#

yeah prepare to struggle a lot with modeling the pieces from the car lol

#

what im doing rn is saving money to hire a 2d artist as I suck at it

opaque mural
#

I will just get the car and engine and if i get it working i will model it piece by piece

#

I can send you an example of what i mean

#

In dms if you want

cerulean badger
#

dont worry i got it

opaque mural
#

Idk if links are allowed here

cerulean badger
#

my game is a 2d RPG with story and stuff

opaque mural
#

I will send an example of what i want

#

This is what i meant

cerulean badger
opaque mural
#

( a game from an driffent dev)

opaque mural
#

That was made in unity

cerulean badger
#

oh i played smth like that in roblox

#

i forgot the name

opaque mural
#

My summer car

#

Great game from indie dev

#

So yeah i need to do similiar to that

#

But driffent car

#

Now I don't know how i am gonna import the sounds of idle rpm, and sounds of rpm as u give gas

cerulean badger
#

you can buy in the internet or download some free stuff, or hire someone to do the sounds, or do it by yourself

opaque mural
#

I already found sounds for temporary car

#

And 3d model of it

#

Now I dont know how i am actually gonna get the engine running

cerulean badger
#

idk, just study more about unity 3d physics or smth

opaque mural
#

Seems i will spend a lot of time im this server

mystic lark
#

Is there a method so i can create multiple clones\copy of my game object

thorny basalt
#

Or is it Transform.Instantiate?

#

One of the 2.

mystic lark
#

thanks

verbal dome
#

It's actually UnityEngine.Object.Instantiate but both GameObject and Transform inherit from Object so anything works

mystic lark
#

ok

verbal dome
#

If you have a monobehaviour then you can just call Instantiate because MB is also an Object

rich ice
willow shoal
#

why its not working? error (5,43) and (5,65) does not implement interface member

using UnityEngine;
using UnityEngine.EventSystems;
using System.Collections;
using System.Collections.Generic;
public class pressclick1 : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
{
    public GameObject HoverPanel;

    public void onPointerEnter(PointerEventData eventData)
    {
        HoverPanel.SetActive(true);
    }
    public void onPointerExit(PointerEventData eventData)
    {
        HoverPanel.SetActive(false);
    }
}
#

unity 6 i using

verbal dome
#

Capitalization mistakes

willow shoal
#

oh

#

what wrong

verbal dome
#

You don't really even have to manually type in the method names. When you add an interface like , IPointerEnterHandler, you can use your IDE to auto create the needed methods

willow shoal
#

what IDE meen

#

Integrated development environment okey

verbal dome
#

Your code editor

#

Click on IPointerDownHandler and then click the 💡

rich ice
#

i've never used IPointerHandler before. is there any reason to use that instead of just using OnMouseEnter(and the other mouse functions)

verbal dome
#

OnMouseEnter works only with colliders IIRC

north kiln
#

It's how you write event code for UGUI.
OnMouse functions also don't work with the new input system so they're generally to be avoided

rich ice
rich ice
#

atleast i know where to start now lol

west radish
#

@hollow zephyr no () after the method name

#

PlayGame()

hollow zephyr
#

public void PlayGame() {
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
}
}

hollow zephyr
#

im getting this error now @west radish Assets\MainMenu.cs(8,9): error CS0103: The name 'SceneManager' does not exist in the current context

north kiln
#

Use your IDE to import the namespace

hollow zephyr
north kiln
hollow zephyr
#

doesnt do that for me

#

can you just show me what to do if i press a button it takes me into the game

north kiln
#

Screenshot your IDE

hollow zephyr
north kiln
#

so what happens when you click the lightbulb?

#

Also that colour scheme is atrocious—maybe it's actually unconfigured still?

hollow zephyr
north kiln
#

It's weird to see the references listed but have no error underlining

hollow zephyr
#

can you just show me how to do this: press a button and takes me into the game

north kiln
#

You need to fix your IDE before continuing

slender nymph
north kiln
#

!vscode

eternal falconBOT
#
Visual Studio Code guide

If your IDE is not underlining errors in red or autocompleting code,
please configure it using the link below:

https://on.unity.com/vscode

swift crag
#

it can do some basic syntax highlighting, yes

#

even without working analysis

slender nymph
north kiln
hollow zephyr
slender nymph
#

if that were the case then you'd be able to use the quick actions to add the correct using directive

rich adder
hollow zephyr
#

i set it up as my external editor

rich adder
verbal dome
hollow zephyr
slender nymph
#

follow all of the instructions

rich adder
#

did you look at the link ?

hollow zephyr
verbal dome
#

Did you also open the link and did you also read the whole page

#

Or did you just look at it

#

It has about ~5 steps

hollow zephyr
rich adder
# hollow zephyr yes

okay do this, close VSCode, go to Unity Preferences -> External Tools, click Regen Project files button. Double click script from unity once more, wait a few mins till it loads

#

check Output tab for any errors

hollow zephyr
rich adder
hollow zephyr
#

bro im literally in external tools

#

i found it

verbal dome
#

Show the package you installed in unity

hollow zephyr
#

nvm

rich adder
#

you manually linked VScode didnt u

#

make sure its the one that shows the version

hollow zephyr
rich adder
hollow zephyr
#

still gives me this:
Assets\MainMenu.cs(8,9): error CS0103: The name 'SceneManager' does not exist in the current context

rich adder
#

fix that error first, IDE doesnt configure well with compile errors

slender nymph
#

and do you see the error in vs code?

hollow zephyr
slender nymph
#

congrats! you've not configured vs code!

rich adder
hollow zephyr
hollow zephyr
#

i set it up as external tool

rich adder
#

close VSCode and do the regen thing,
Its either gonna work or show you .NET SDK error

verbal dome
rich adder
#

also yeah make sure no compile error

hollow zephyr
#

what is it supposed to do when i press regen

rich adder
#

should be loading bar at bottom

hollow zephyr
#

ok i opened it

#

should i uncomment it out

#

it gave me the error when i uncommented it

rich adder
hollow zephyr
#

i got a .NET error tho in my vs code

rich adder
#

ok there you go

hollow zephyr
#

the .net core sdk cannot be located

rich adder
#

I told you was either going to work or give .net sdk error

#

so download it now

#

restart PC after install , and do the regen thing again

#

maybe 9 works too but idk yet

hollow zephyr
rich adder
#

use default folders if possible

hollow zephyr
#

wait but i need to comment out and close VScode and then i do regen and then open VScode and uncomment

rich adder
hollow zephyr
verbal dome
#

Nice, try the light bulb now

hollow zephyr
rich adder
#

thats weird you tried doing Quick Fix ?

hollow zephyr
#

quick fix tells me to add Unity scene management

#

it removes the error when i do scene management

rich adder
#

yes

hollow zephyr
#

yea

rich adder
#

good

#

you're finally set

hollow zephyr
# rich adder

wait but even when i press one of my buttons it doesn't take me to the main virtual environment

#

like the main scene

#

i think my script is maybe incorrect

rich adder
#

well now we can look at script issue lol.

#

idk the setup tho , I just got here when i smelled unconfigured VSC

hollow zephyr
#

i created a Button TMP and im trying to attach the script in the field on the On Click

rich adder
verbal dome
#

See anything in the console after you click the button?

hollow zephyr
rich adder
#

make sure you drag that one, not the one from the Project view

hollow zephyr
#

i did it

#

even tho i put cursor lock on None

slender nymph
#

are you certain that line of code is running?

rich adder
hollow zephyr
#

no i haven't done that

rich adder
#

check if that function runs at all first

#

check that with log, n make sure you don't have something else overriding it again

#

some character controllers put it in the Update method with a check

hollow zephyr
#

i cant check if the function works because I can't press the button

#

because my mouse just disappears when i click the button

#

im pretty sure the problem is the visible not on true

rich adder
hollow zephyr
#

what do i search my files for

#

to put it to visible

rich adder
#

Cursor class

#

I sent the property yesterday

#

Cursor.visible =

hollow zephyr
#

i found the Cursor.lockState one

rich adder
#

you need both, no point in unlocking if you can't see it

hollow zephyr
#

Cursor.visible = !lockState;

rich adder
#

that can work sure

#

maybe you can do Cursor.visible = Cursor.CursorLockMode!= CursorLockMode.hidden also

#

but looks like you got variable for it anyway

hollow zephyr
#

i found a Cursor.visible = true;

#

and Cursor.visible = false;

#

private void ToggleSettings()
{
if (_panelCanvasGroup.alpha == 0)
{
ToggleSettingsPanel(true);
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
}
else
{
ToggleSettingsPanel(false);
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
}

rich adder
#

ok well try not to spread that function all over the place

#

handle it in 1 class so you avoid confusion / unexpected values

hollow zephyr
rich adder
#

some type of GameSettings script or something

hollow zephyr
#

is it not this:
private static void LockCursor(bool lockState)
{
Cursor.lockState = lockState ? CursorLockMode.Locked : CursorLockMode.None;
Cursor.visible = !lockState;
}

rich adder
#

sure

hollow zephyr
hollow zephyr
rich adder
rich adder
#

now you just call this function when you have to

hollow zephyr
#

theres a bunch of Cursor

rich adder
#

you dont want that though..

#

keep it in 1 script so you don't confuse the values

#

just the ones that do =

hollow zephyr
#

but then wont i have to reassign everything again

rich adder
hollow zephyr
#

so like for example this:
void Start()
{
Cursor.lockState = CursorLockMode.None;
}

#

i just delete this as a whole?

rich adder
trim moon
#

guys am i allowed to send videos here?

rich adder
#

mp4s

#

but you should attach a question to the video 😛

trim moon
rich adder
trim moon
#

oh ok

hollow zephyr
#

how about this:
if (Cursor.lockState != CursorLockMode.Locked) return;

rich adder
trim moon
#

but i wanted to ask what should i try and learn next

#

and if this is good

#

i am using unity for maybe 2 weeks now

rich adder
hollow zephyr
#

private void ToggleSettings()
{
if (_panelCanvasGroup.alpha == 0)
{
ToggleSettingsPanel(true);
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
}
else
{
ToggleSettingsPanel(false);
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
}

    /// <summary>
    ///     Toggle the settings panel on or off
    /// </summary>
    public void ToggleSettingsPanel(bool value)
    {
        if (value)
        {
            // Fade in the settings panel
            ActivatePanel();
            FadeInSettingsPanel();

            // Check if the alpha of the appearance canvas is at its maximum
            const float MAX_ALPHA = 1;
            if (_uiAppearanceSettings.GetCurrentActiveAppearance().GetCanvasGroup().alpha >= MAX_ALPHA)
                // If true, fade out the current appearance canvas
                _uiAppearanceSettings.FadeOutCurrentAppearance();

            // Set the cursor lock state to none
            Cursor.lockState = CursorLockMode.None;
        }
        else
        {
            // Fade out the settings panel
            _fadeCanvas.OnCurrentFadeCompleted += DeactivatePanel;
            FadeOutSettingsPanel();

            // Check if there is an active Convai NPC
            if (ConvaiNPCManager.Instance.GetActiveConvaiNPC() != null)
                // If true, fade in the current appearance canvas
                _uiAppearanceSettings.FadeInCurrentAppearance();

            // Set the cursor lock state to locked
            Cursor.lockState = CursorLockMode.Locked;

            // Save values when the settings panel is closed
            UISaveLoadSystem.Instance.SaveValues();
        }
    }
rich adder
trim moon
#

❤️

rich adder
hollow zephyr
rich adder
#

you see how its spread out too many places setting it

hollow zephyr
#

so this entire thing goes to trash:
private void ToggleSettings()
{
if (_panelCanvasGroup.alpha == 0)
{
ToggleSettingsPanel(true);
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
}
else
{
ToggleSettingsPanel(false);
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
}

rich adder
#

correct

#

but you have to replace it if you still want to use ToggleSettingsPanel

green tusk
#

What is a good way to go about dealing damage to a specific clone of an Instantiated prefab? Is there an easy way to make a game object identify itself?

hollow zephyr
#

how about this:
public void ToggleSettingsPanel(bool value)
{
if (value)
{
// Fade in the settings panel
ActivatePanel();
FadeInSettingsPanel();

            // Check if the alpha of the appearance canvas is at its maximum
            const float MAX_ALPHA = 1;
            if (_uiAppearanceSettings.GetCurrentActiveAppearance().GetCanvasGroup().alpha >= MAX_ALPHA)
                // If true, fade out the current appearance canvas
                _uiAppearanceSettings.FadeOutCurrentAppearance();

            // Set the cursor lock state to none
            Cursor.lockState = CursorLockMode.None;
        }
        else
        {
            // Fade out the settings panel
            _fadeCanvas.OnCurrentFadeCompleted += DeactivatePanel;
            FadeOutSettingsPanel();

            // Check if there is an active Convai NPC
            if (ConvaiNPCManager.Instance.GetActiveConvaiNPC() != null)
                // If true, fade in the current appearance canvas
                _uiAppearanceSettings.FadeInCurrentAppearance();

            // Set the cursor lock state to locked
            Cursor.lockState = CursorLockMode.Locked;
rich adder
eternal falconBOT
hollow zephyr
#

now what do i do

#

theres just this left

#
        {
            Cursor.lockState = lockState ? CursorLockMode.Locked : CursorLockMode.None;
            Cursor.visible = !lockState;
        }```
rich adder
hollow zephyr
#

so i can click the buttons

rich adder
#

so call the function

polar acorn
rich adder
#

going to have to kinda use common sense here lol

#

you literally made this function for lock/unlock. What else did you think you needed to do

hollow zephyr
hollow zephyr
#

its locked rn

#

how do i unlock

rich adder
polar acorn
rich adder
#

have you called a function before no ?

polar acorn
#

so if it's locked, and you want it to flip

#

you should probably

#

call that function

hollow zephyr
#

CursorLockMode.Unlocked?

hollow zephyr
rich adder
polar acorn
rich adder
hollow zephyr
#

i probably have called a function but just dont know whats the term for it

rich adder
#

ok lol now you know

#

to call static function you must precede the function with the Class name it belongs to

#

since statics belong to classes and not instances (object created from class)

rich adder
#

stick to what you have

hollow zephyr
#

what do i change in this code

        {
            Cursor.lockState = lockState ? CursorLockMode.Locked : CursorLockMode.None;
            Cursor.visible = !lockState;
rich adder
#

you don't touch that anymore

#

you just CALL(USE) the function now when you need to lock and unlock

hot laurel
#

the name is misleading, its more like toggle

hollow zephyr
#

ok so I want to unlock the cursor now what would i do

polar acorn
#

why would you need to change it

rich adder
verbal dome
#

It's not really a toggle

#

You provide it the lockstate you want to have

#

Perhaps you guys misread this part Cursor.visible = !lockState

rich adder
#

more of a setter than traditional flip/toggle yes

hollow zephyr
#

Assets\Convai\Scripts\Runtime\UI\SettingsPanel\UISettingsPanel.cs(51,59): error CS0103: The name 'ToggleSettings' does not exist in the current context

hot laurel
#

ok ok 2 state cursor setter

rich adder
#

show code

hollow zephyr
#

ConvaiInputManager.Instance.toggleSettings += ToggleSettings;

#

thats line 51

polar acorn
hollow zephyr
#

i did the quick fix

#

it fixed it

rich adder
#

ok so its working now?

hollow zephyr
#

i pressed the button but it just brings me back to the position im standing in

#

how do i make it so that the main menu disappears

#

ill watch a video

rich adder
#

you should create an event

hot laurel
polar acorn
#

!learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

rich adder
#

make a static event you can Invoke from the LockCursor function

#

any script that needs to know, can listen to this function

hollow zephyr
#

basically theres this. When i press the button, i want the menu to disappear so i can go inside the environment

rich adder
#

eg activating UI panels n shit

rich adder
#

event is the cleanest

hollow zephyr
rich adder
hot laurel
#

!learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

hollow zephyr
rich adder
#

if you had an event, then you can easily "react" from other scripts, EG a script that deals with Panels

hollow zephyr
#

like the script i attached to the main menu

#

the gameobject

rich adder
#

you have to try to make 1 script do specific things..

#

UIManager only deals with Panels, UI menus etc.

#

this way you know where to find something eeasily

hollow zephyr
#

like this?

rich adder
#

you arent gonna learn well if you use AI..

#

this literally has compile errors too

hollow zephyr
#

so i have to create a new script

rich adder
hollow zephyr
#

can u just make me the script

#

for this only

#

like pressing the button closes the menu

polar acorn
#

Do you actually intend on learning anything or letting us make your project for you one script at a time

hollow zephyr
#

im almost done with my project

#

im crying rn

#

😭

rich adder
#

you're skipping rock on water through different systems with no exp and expect everything to just work, not realistic

golden oxide
#

hello can someone explain to me why i cant see the newsoft in the package manager or the asset store how do i download it

rich adder
#

com.unity.nuget.newtonsoft-json

#

add by name

rich adder
#

don't ask me why Unity didnt add those startup / quick setup instructions in docs

golden oxide
#

ok thank you that worked what a round about way of doing things. is their any think else i need worry about

#

dependences and or quirks ?

rich adder
#

na

golden oxide
#

i dont need to delete json utility's

rich adder
#

nah

golden oxide
#

ok thank you very much

rich adder
#

they belong in different namespaces / assemblies they dont even see each other

golden oxide
#

ok thanks

hollow zephyr
#

what does this error mean:
Scene with build index: 6 couldn't be loaded because it has not been added to the build settings.
To add a scene to the build settings use the menu File->Build Settings...
UnityEngine.SceneManagement.SceneManager:LoadScene (int)
MainMenu:PlayGame () (at Assets/MainMenu.cs:9)
UnityEngine.EventSystems.EventSystem:Update ()

slender nymph
#

did you bother reading it?

hollow zephyr
slender nymph
#

and what was not clear?

hollow zephyr
#

i need to do something with build settings

#

i think its telling me to add a scene

#

so that it can go there when i press a button?

slender nymph
#

yes, you're trying to load the scene at index 6 but there isn't one there

hollow zephyr
#

what do i do in build settings

rich adder
#

if you plan on going to a scene , it needs to be in the Build

rich adder
hollow zephyr
#

build?

#

or build and run

rich adder
#

it just needs to be added to switch scenes in Editor

#

you dont have to build now, only if you want to test it without unity

hollow zephyr
rich adder
hollow zephyr
rich adder
#

why do you want to put at 6 lol just use 5 in the script.

hollow zephyr
rich adder
hollow zephyr
#

is it cuz i did buildIndex + 1

#

SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);

rich adder
#

so its not Unity that did it lol

#

scripts dont magically do things

hollow zephyr
#

should i just delete the + 1

rich adder
#

are you trying to reload the same scene or the next scene?

hollow zephyr
#

same scene

rich adder
#

then yea.

#

+1 moves to next scene

#

should be obvious

hollow zephyr
#

i watched a video and for him it just took him into the scene when he pressed Play

polar acorn
rich adder
hollow zephyr
#

took me to the scene i wanted

#

why doesn't it get rid of the panel

rich adder
#

the scene already starts with panel on or you have statics not resetting

polar acorn
hollow zephyr
polar acorn
hollow zephyr
# polar acorn Then why would you expect the panel to be hidden

i just have this:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class MainMenu : MonoBehaviour
{
public void PlayGame() {
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}
}

polar acorn
eternal falconBOT
hollow zephyr
rich adder
polar acorn
hollow zephyr
#

im dumb

polar acorn
#

it's reloading the scene

polar acorn
#

Then what's the problem

hollow zephyr
#

just need to figure out the code to hide the panel

#

would it be gameObject.SetActive(false)

rich adder
#

break down the problem into smaller ones

#

gameObject may or may not be correct, we don't know where you plan on using this

#

but thats the function to hide gameobjects

hollow zephyr
#

hows this look

#

MainMenu is the game object btw with the panel and buttons

rich adder
#

its bad

hollow zephyr
#

what to fix

rich adder
#

not a gameobject

hollow zephyr
#

its a gameobject and script

hot laurel
#

A Component

rich adder
#

then use the function to disable gameobjects

polar acorn
#

Why do you have a function whose entire purpose is to throw an exception

hollow zephyr
rich adder
slender nymph
hollow zephyr
#

imma pick up on this tomorrow i gotta sleep

polar acorn
#

As I have tried for several days now

#

Someday it'll work

slender nymph
#

i mean, they refuse to just go learn the basics. i doubt they'll learn anything from this

rich adder
#

"just this one time"

hollow zephyr
#

can u say inappropriate stuff in this server

#

or nah

#

just rly wanna say something

#

ive been wanting to say it for rly long

rich adder
polar acorn
#

Go for it. Either it's allowed and you're fine, or it's not allowed and then you won't be on this server to have us do your homework for you. Win-win

hollow zephyr
#

yea i doubt its allowed

#

its js something rly funny

#

its a joke

#

that u may or may not find funny

#

i can dm u with ur permission

#

anyone want me to dm them

#

i know @rich adder wants it

polar acorn
#

I doubt anybody does

north scroll
#

whats the difference between a Ray and a Raycast? is there a use case I should be using for each? Im trying to move the player based on screen input and not sure if there's a difference between the 2

rich adder
slender nymph
#

the Ray struct just holds data, particularly a starting point and direction. a Raycast is a physics query that takes data like origin, direction, distance, etc to query the current state of the physics engine to find out if there is a collider in the path desired

acoustic belfry
#

hey i have this script wich technically works fine, but for an strange reason Unity says somethings odd, i mean, it works, but it advises me that a part of the script is empty, what this means?

using UnityEngine;

public class rifle_bullet_script : MonoBehaviour
{
    public int riflebulletdamage = 5;
    // Start is called once before the first execution of Update after the MonoBehaviour is created
    private void OnTriggerEnter2D(Collider2D collision)
    {
        EnemyBase enemy = collision.GetComponent<EnemyBase>();
        if (enemy);
        {
            enemy.TakeDamage(riflebulletdamage);
            Destroy(gameObject);
        }
    }
}
timber tide
#

if (enemy);

acoustic belfry
#

whats wrong in it

#

that is innecessary?

#

or smt like that?

wintry quarry
#

wdym by this

timber tide
#

semi colons denote seperation of code, but you're going into a statement here

wintry quarry
#

ah yep that's it

#

get rid of that semicolon

acoustic belfry
acoustic belfry
#

thx, it always bugged my brain that...advise? i mean cuz, the script still works, its just like a...recommendation?

timber tide
#

It's valid code

#

just not what you expect

wintry quarry
#

it's only working because the component is there

#

you're getting lucky

acoustic belfry
#

o h

wintry quarry
#

it will be an error if GetComponent returns null

#

basically your if statement is not doing anything at all

echo ruin
#

Hmm. Does (enemy) not imply EnemyBase is a bool?

#

I wasn’t aware that you could do it like that

wintry quarry
#

It can be implicitly converted to a bool

#

All UnityEngine.Object - derived types can

#

It works the same as if (enemy != null)

echo ruin
#

Yeah that’s how I usually do it

tawny grove
#

is there a way to change like the actual unity icons you can set within the scene in script? like these things

echo ruin
#

Tmyk

rich adder
tawny grove
tawny grove
#

oh no i meant like if i have it already set to the green diamond icon, later during runtime being able to set it to a different icon

rich adder
#

that one I think you need reflection for

rich adder
#

oh nicce

verbal dome
tawny grove
#

oh that is perfect! thank you.

rich adder
#

nice. for some reason google brought me to this weird forum post
.GetMethod("SetIconForObject",

tawny grove
verbal dome
#

That's 11 years old

rich adder
#

glad they added it then 😅

crisp olive
#

Looking for a quick chat with someone who uses blender

#

I don’t want all my problems solved I just want a push in the right direction so I can continue to make this stupid idea I have

eternal falconBOT
crisp olive
#

This is going to be harder than I thought

#

Wait for the coding part can you tell a 3d model what color to be?

#

Like make this entire object this color through code?

wintry quarry
#

You can set the color on the material, if the material supports such a thing, sure

crisp olive
#

This is my first time using 3d so I’m trying to break it down into the most logical way for what I’m trying to accomplish

#

I think I know what to do, I guess I’ll keep trying till I get the result I’m looking for

wintry quarry
#

What are you trying to do

crisp olive
#

I’m trying to rotate an object with 3 sides

wintry quarry
#

A triangle?

crisp olive
#

That would be 3 different animations or can I use code to go through the frames of animation

wintry quarry
#

You're honestly all over the place with your questions

crisp olive
#

A tetrahedron

wintry quarry
#

I suggest focusing on one thing at a time

#

What does Blender and colors have to do with rotating an object?

#

In what way do you want to rotate the thing?

#

And why does its shape matter to the way you want to rotate it?

crisp olive
#

Left and right with button presses

#

It’s a game mechanic I have

wintry quarry
#

left and right aren't meaningful descriptions of a rotation

#

something like "clockwise around the world y axis" would be a meaningful way to describe a rotation, for example

crisp olive
#

3 colors I wanna rotate between

wintry quarry
#

Now I can't tell if you're talking about physical rotation, or changing colors

crisp olive
#

Do color all 3 faces in blender then animate 3 diffrent animations or can I use 1 animation and cycle through frames with code?

#

Can I dm you a photo of the thing

wintry quarry
#

Why can't you just put it here

#

or in a thread

crisp olive
#

I don’t want my idea taken

#

I got the code to work for the basic part I just need the artwork to match up

#

I guess it doesn’t matter what I do, you can make something work multiple ways I just wanted to know the best way about doing it

#

The hardest part about being a beginner is being lost in the sauce

wintry quarry
#

You haven't actually explained clearly what you want to do yet

#

This is the number one thing I feel beginners struggle with - just stating in a clear sentence what they are trying to accomplish

crisp olive
#

Imagine a tetrahedron split into 2 I wanna rotate the top that has 3 colors with a button and rotate the bottom that also has 3 colors with a different bottom, one color at a time can be used

wintry quarry
#

I don't understand the color part at all, other than the fact that the different faces of the object have different colors

#

Sounds like you would just have two different objects

#

and rotate them independently

crisp olive
#

Okay yes sorry

#

I want that

wintry quarry
#

you can rotate an object by setting the rotation on its Transform, or its localRotation, or by calling Rotate on it

#

the exact code depends on the exact nature of how you want to rotate the thing, and when

crisp olive
#

So no need to animate in blender I can do all that with code?

wintry quarry
#

You can do anything in code

crisp olive
#

I’m used to 2d

#

This is great news

wintry quarry
#

You can do anything in 2D with code too

#

2D really isn't all that different

crisp olive
#

3d rotation is animation

wintry quarry
#

I don't understand what you mean by that

crisp olive
#

I just assumed wrong

wintry quarry
#

Yes it sounds like you have some weird assumptions about things

crisp olive
#

It’s okay you did great and answered my question I appreciate your time sorry for the riddles

wispy grotto
#

Hi, question from someone new to C# (and honestly OOP) in general. I'm trying to make a simple program where players can draw lines between nodes on the screen. The images should clarify what I mean to some extent. My issue is that I don't know how where I should write what the player is doing. I can kind of imagine dividing it into three classes, but then where do I program the actual state machine? A separate class?

astral falcon
wispy grotto
#

I googled it

#

Couldn't find anything

#

Obviously I could dive deep into the rabbit hole, but that's not very motivating if my only goal is to find where I should put the state machine right?

astral falcon
#

Sounds like you are fighting with more than just "where to put the statemachine". thats no offense but you seem to be overwhelmed already by "what the player is doing". So I suggest going to some unity tutorials from !learn and figure out, how things are done more commonly and go from there

eternal falconBOT
#

:teacher: Unity Learn ↗

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

wispy grotto
#

I'm asking a very simple question.

astral falcon
#

Okay, state machine in a separate class? For the whole game flow, yes, separate class. Simple answer

wispy grotto
#

Thanks. That's all I need. Could have saved me the AI helpdesk automated response.

violet glacier
#

Is it possible to have only one static class script in one scene?

astral falcon
violet glacier
burnt vapor
violet glacier
#

It seems that singletons can be accessed anywhere, including across scenes. But I need static class for a single scene

burnt vapor
#

Same thing, but generally you should make a provider that handles providing instances. Ask the provider for an instance, and it checks if it made an instance for that scene before

#

Should also make sure to invalidate instances when the scene gets unloaded

#

This applies in general. You should always have a single provider providing instances

violet glacier
#

Thanks!

clever idol
#

Whats the difference between Time.fixedDeltaTime and Time.DeltaTime?

cerulean badger
#

is there a list of the basics that I can check and learn? I cant find a list at anywhere and I'd want to have defined what I need to learn (dont need a specific order tho)

frosty hound
#

You can run through !learn and there are other beginner tutorials pinned to this channel as well

eternal falconBOT
#

:teacher: Unity Learn ↗

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

cerulean badger
#

seems really interesting, ty

night raptor
echo ruin
#

Does any of you know if lists .AddRange() can have for more than two conditions?

#

I want to merge these two


units.AddRange(unitPool.GetComponentsInChildren<MovementBehaviourTroop>().Where(units => !(units.movementStates.currentState == MovementState.Dead)));
units.AddRange(unitPool.GetComponentsInChildren<MovementBehaviourTroop>().Where(unit => !units.Contains(unit)));

First one checks that nobody with the state MovementState.Dead is added to the list, the second one makes sure the same object doesn't get added twice.
I can't seem to get the syntax right to merge them

astral falcon
#

why not just use foreach?

echo ruin
#

Becasue I run this

    public void UpdateList()
    {
        units.RemoveAll(unit => (unit.movementStates.currentState == MovementState.Dead));

        units.AddRange(unitPool.GetComponentsInChildren<MovementBehaviourTroop>().Where(unit => !units.Contains(unit)));
    }```
#

To update a list, and removing an object from a list that is being iterated in a foreach loop will throw errors

zinc pewter
#

what happens if I use a constructor in a monobehaviour?


public class TestPlayer : MonoBehaviour {
  
  public string name;
  public static TestPlayer Instance { get; private set; }

  public TestPlayer() {
    Instance = this;    
  }
}
astral falcon
night raptor
visual linden
astral falcon
astral falcon
night raptor
burnt vapor
astral falcon
#

So Union merges and removed duplicates 😄 confused

burnt vapor
#

The real answer would be to just apply a proper filter before you add the units

#

I never heard of Union. If it does that then that's a better approach, yes

echo ruin
#

I could honestly just try a for loop

#

Since it can work with a dynamic size as opposed to foreach

burnt vapor
#

I would make an IEnumerable method that returns the units you want to add to the list, and put all of it in there

burnt vapor
#

If the point is to order based on that state then just use OrderBy

astral falcon
night raptor
echo ruin
echo ruin
burnt vapor
#

AddRange is a List method. Where is a LINQ method

echo ruin
#

Also found an answer. I can literally just use &&

astral falcon
#

😄 Okay, you do you

burnt vapor
#

Perhaps you should look into equality in your classes, and make sure adding duplicate classes is not possible in general

#

If your List is not allowed to have duplicates, use a Hashmap. Also override equality checks on classes so you can accurately compare against other classes to ensure it's not the same

rich ice
#

you would just have to change the if to whatever you need

echo ruin
rich ice
#

oh right, good point.

astral falcon
#

You can also compare things with union, just saying 😉

rich ice
#

then use union to remove any duplicates

astral falcon
#

Or just chain .Where().Union(Where())

#

so many ways to do it, you decide 😄

languid spire
swift crag
#

that is precisely how you're intended to use LINQ, so it seems at least tolerable

swift crag
#

This is preventing you from accessing units inside of the anonymous function

burnt vapor
#

I mean the approach is generally fine, but they should just add proper distinction between the objects instead of implementing some obscure filtering system

swift crag
#

It does feel more than a little weird to reference units whilst in the middle of units.AddRange, though

burnt vapor
#

Not to mention Hashtables would be much faster over a list

#

At least, from the context these collections are always unique

#

If not then you can't do this

swift crag
#

a HashSet would make uniqueness checking faster, yes, at the cost of not having an order

echo ruin
#

I might change a lot on the run

swift crag
#

which is probably fine here

echo ruin
#

This is just a practice project to better myself and trying stuff out

#

Mainly familiarizing myself with List<T>

swift crag
#

that line of code is making me upset

echo ruin
#

Okay

swift crag
#

😛

final kestrel
#

https://hastebin.com/share/ququwexoyu.java
Hi. I managed to do this. Rotate my camera on X and player Y because thats how my playerController handles mouse movement. My issue is that, when slerping, the camera does not looks at the target precisely. It is as if with offset. Just like in the picture. Doesnt it have to look directly at the center of the cube?

swift crag
#

It's so long

#

unitPool.GetComponentsInChildren<MovementBehaviourTroop>() is also alarming me a bit

echo ruin
#

I think I've asked questions 2 or 3 times in here and it's generally disencouraging

swift crag
#

Sorry, I shouldn't be jabbing at people immediately

#

The rest of the logic seems fine now -- you're filtering out all units that are already in the list, removing all units that are dead, and then adding all of the results to the list

astral falcon
echo ruin
#

I like that there are many ways to approach it. I appreciate the help. I know I make a lot of spaghetti, but as for my question, I was genuinely just curious if it was possible to add multiple conditions in .Where(), as a part of troubleshooting updating a list where objects don't get added multiple times to the same list

#

I could jump on to a different solution. I want to understand the roadblock first. Why it does what it does

swift crag
#

and yes, you can write an arbitrarily complex predicate

#

You just can't throw two or more predicates into the Where function

echo ruin
#

As in what I just did?

astral falcon
#

reminds me of mysql queries, which I hated either, when they got longer and longer 😄 But for debugging and filtering, why not as long as you clean up code afterwards

swift crag
#

A "predicate" is a function that takes an item and returns a bool.

#

You can make that function very complicated

#
bool NumberPredicate(int x) {
  if (x == 3)
    return false;
  if (x == 6)
    return true;
  return x % 2 == 1;
}

var sequence = numbers.Where(NumberPredicate);
#

I'm unclear what you were trying to do that resulted in a syntax error

echo ruin
#

Did I say it threw an error?

swift crag
#

I can't seem to get the syntax right to merge them

I presumed you had tried to do something and gotten a compiler error.

echo ruin
#

I didn't understand the syntax of the language well enough to make one line of code do what those two lines of code both meant to do

swift crag
#

ah, okay, that makes sense

echo ruin
#

The line I have now, as terrible as it may look, works as intended

swift crag
#

This can be a good idea for longer conditions.

swift crag
echo ruin
#

I will eventually try out different ways to do different things

#

But sitting down to work with and manipulate Lists specifically kinda defeats the purpose of me using ways that don't use lists

#

So I understand the need to respond to my question by asking me why I don't use a different approach

swift crag
#

Hash sets could actually be inappropriate here, too.

I would expect newly-selected units to appear at the end of a list, rather than appearing at random places amongst the existing units

#

(which is what you'd probably observe with a hash set)

echo ruin
#

I had planned to incorporate hashsets into this practice project by assigning objects uniquie IDs, but I know I will get disencouraged by having too many balls in the air at the same time. I'm still a beginner

swift crag
#

You don't have to do anything special to make that possible.

I was about to say that any reference type can be used in a hashset, since they all have a default hashcode implementation, but it looks like you can just stick any struct type you want in, too

#

But yes, no need to juggle too many plates

#

You should focus on writing code that is easy to understand, even if it's a little more verbose than it could be

#

(and a little less efficient)

#

Especially when you're a beginner, gamedev can feel like bailing water out of a sinking ship: the project inevitably gets more and more complicated until you're unable to make any forward progress

#

so, best to keep the complexity low!

final kestrel
swift crag
#

targetRotation is a world-space rotation, whilst initialRotation is a local-space rotation

#

If you want to convert it to a local-space rotation for the player camera, you can do...

#
Quaternion.Inverse(playerCamera.parent.rotation) * targetRotation
#

Also, I'm not a huge fan of this...

#
//playerCamera angles
    targetEuler.y = initialRotation.eulerAngles.y;
    targetEuler.z = initialRotation.eulerAngles.z;
#

Fussing with components of euler angles tends to cause surprises

#

Euler angles can abruptly flip by 90 or 180 degrees

#

I would suggest just flattening the direction you're trying to look in

#
Vector3 direction = // ...
direction = Vector3.ProjectOnPlane(direction, Vector3.up);
#

in this case you could've also just done direction.y = 0;

#

If the player's body can get tilted to the side, then you'd want to use Vector3.ProjectOnPlane(direction, playerController.transform.up)

#

which would work for any orientation

proven matrix
#

I am trying to create a log in system using playfab and get this error and dont know how to fix it

deft ridge
#

how you you handle two-player controller input using the old input system? I'm making a two player fighting game, and i want it so that one controller controls one character (obviously lol) but I can't figure out how to get Unity to tell the difference between the two controllers or which mapping is correct for the second player

proven matrix
#

I am following a tutiroal and they dont seem to have that error despite me following everything

astral falcon
eternal falconBOT
final kestrel
frigid sapphire
#

Is there a way to disable mouse collision on a gameobject? I have some text over a button and it's making me unable to click the button

swift crag
#

You can uncheck "Raycast Target" on the text component. It's in the "Extra Settings" section

frigid sapphire
#

Tysm will try that

swift crag
#

I try to do that for anything that isn't supposed to be interactive

swift crag
#

you are calculating a world-space rotation

final kestrel
#

All right. I will look into it. Thanks.

frigid sapphire
swift crag
#

okay, add a Canvas Group and uncheck "Blocks Raycasts"

#

I couldn't remember if turning off Raycast Target was sufficient or not

tender stag
#

i got this method in my LobbyManager

frigid sapphire
swift crag
#

On the same object as the text, yes

#

In that case, there must be something else getting in the way

tender stag
#

to still have the LobbyEnter_t

#

and be able to use it

#

how do i do that?

swift crag
#

If you are using the old input manager (so, you aren't explicitly using the new input system), you can look at the EventSystem's inspector to see what the mouse is currently hovering over

#

you'll see that info in the preview pane at the bottom

#

which might be collapsed

tender stag
#

and this isnt working

swift crag
#

HandleLobbyJoinSuccess is a method.

#

you're trying to treat it like it's a UnityEvent or something

tender stag
#

oh yeah shit

swift crag
#

Perhaps you meant to subscribe to LobbyManagerEvents.LobbyJoinSuccess ?

#

But that takes no arguments

frigid sapphire
#

Oh wait seems like the text is not blocking clicks but its the actual text box

swift crag
#

Is this an input field?

#

I'm not sure what "actual text box" means here

frigid sapphire
#

Its a tmp text

swift crag
#

You'll need to show us what you're doing (ideally in #📲┃ui-ux , since this is not a code problem)

final kestrel
swift crag
#

I don't really know what I'm looking at here

final kestrel
#

Ah sorry. The block on the ground is my lookTarget. And you can see my crosshair. When the slerp is done shouldnt I be looking at the center?

#

This is how the code looks now

swift crag
#

so you're rotating both the player's body (around the Y axis) and the player's camera (around its X axis)?

final kestrel
#

Yes

#

Thats how my mouseLook works.

#

I wanted it to look natural thats why I did it that way

swift crag
#

This can be a bit tricky. You have to decompose a rotation into two different pieces.

Vector3 flattened = Vector3.ProjectOnPlane(entity.transform.forward, Vector3.up);
yaw = Vector3.SignedAngle(Vector3.forward, flattened, Vector3.up);

Vector3 rotated = Quaternion.AngleAxis(-yaw, Vector3.up) * entity.transform.forward;
pitch = Vector3.SignedAngle(Vector3.forward, rotated, Vector3.right);

Here's how I did that in my game.

final kestrel
#

also playerCamera is sitting at my player object with x 0.25 and y 0.75

swift crag
#

I first find the yaw.

final kestrel
#

so its with an offset

swift crag
#

Then I use that to adjust the forward vector so that I can figure out how much up-and-down angle it has

frigid sapphire
swift crag
#
Quaternion turnRot = Quaternion.AngleAxis(yaw, Vector3.up);
Quaternion lookRot = turnRot * Quaternion.AngleAxis(pitch, Vector3.right);
#

here's how I compute the rotations later on

#

If you want a local rotation for the camera, lookRot would not have turnRot multiplied into it

swift crag
swift crag
#

unless everything is rotated weirdly and local +X is actually the direction you are facing

final kestrel
#

Wait why is it .25 on the x. Damn

#

Okay after resetting it to 0 it looks fine now

#

It was sitting wrong at my player

#

I'll still take a look at how you've done it in your game. Gotta study signed angle and project on plane first though. Now my main issue is to clamp the axis so i dont turn 180 degrees upwards.

#

Thanks a lot for the help!

swift crag
#

np!

#

you can use Mathf.Clamp for that

swift crag
final kestrel
#

Yes I already have my upper and lower look limit decided on my playerControls. But clamping it seems tricky to me while slerping!

#

When I try to use the same values it does weird stuff 😄 but again I havent taken a look into it completely yet!

final kestrel
runic crypt
#

hello, so i want to add lights to my 2d urp project but whenever I add a point light or spotlight, it doesnt affect the scene. the only thing that affects the scene is my global light. Am I doing something wrong?

wintry quarry
#

point lights and spotlights are 3D lights

storm cloud
#

Hello, does anyone know how I can reset the camera view in "Scene" ? :c

rich adder
storm cloud
#

Omg

#

I feel dumb, Thank you xD

proven matrix
#

those anyone know why i cant move the email and password to the input fields in the inspector?

swift crag
#

Input Field is the legacy UI component

swift crag
#

you'd want TMP_InputField

proven matrix
rich adder
#

eg TMP vs legacy Text/Input

swift crag
proven matrix
#

so what would i change it to

rich adder
#

scroll up

proven matrix
#

do i change these?

rich adder
#

correct

proven matrix
#

those produce errors tho

rich adder
#

yes have your IDE correct it

#

ctrl + .

proven matrix
#

fixed it thanks #

true owl
#

Apparently I'm supposed to be using the new input manager methods but it's a little confusing. I am still using the new input manager for most of the stuff but

wanton hearth
#

After upgrading to Unity 6 and Visual Studio 2022 recently, VS has started adding namespaces to scripts automatically. But the namespaces aren't even necessary (they are greyed out seeing how they are unsued). Causes a bunch of errors when I remove some unneeded packages from my proj.

Is this a feature or a bug?

umbral bough
#

Hi, I am using the this script to generate fonts at runtime.
It works fine, except for the fact I can't figure out how to include special symbols etc.
When I am using the Font Asset Creator, I can simply select Extended ASCII(or something else), and it will work fine.
However, the function for creating fonts doesn't appear to be having any parameters(such as CharacterSet), so I don't know what to do.
Thanks in advance!

grand snow
#

Tmp can dynamically add at runtime anyway

brave compass
#

This can happen even if you only write your using directives manually. I would suggest you find the shortcut to remove unused directives and memorize it.

umbral bough
wanton hearth
strong wren
#

Undoing instead of erasing accidental suggestions should also get rid of the using

cosmic dagger
true owl
#

oh

grand snow
# umbral bough huh?

I'm confused about what the issue is. Do you want to load a font at runtime?
Or are you still configuring it in editor?

true owl
#

okay thx

#

i'll work on tweaking it

cosmic dagger
grand snow
#

If it's dynamic mode it will do it itself

#

Ofc if the font supports the symbols

cosmic dagger
#

when generating the font from the editor, there is an option for this. i believe they want to have that ability during runtime . . .

umbral bough
swift crag
#

oh, I see -- the script uses TMP_FontAsset.CreateFontAsset to generate the asset

#

the rest is just there to help you find a font by name

grand snow
umbral bough
grand snow
#

And often fonts can have many versions for different weights and stuff

umbral bough
#

I am generating the font from Courier Prime Code during runtime too

runic lance
#

there's a TryAddCharacters in the TMP_FontAsset class, maybe that's useful?

grand snow
#

It should work either way

umbral bough
#

that's interesting, will take a look

#

it could make my current implementation cross platform+simplify the workflow

grand snow
#

But is that tmp?

umbral bough
grand snow
#

I swear tmp fonts could source from the os already if you set it too

#

Yea but the function above is for the old text

umbral bough
#

I mean idk, it could work, just gotta figure this part out

grand snow
#

You can't mix the old text/font with text mesh pro stuff, 99% sure.

umbral bough
swift crag
#

I’d guess you just shove in a bunch of characters

runic lance
umbral bough
umbral bough
grand snow
#

I've used dynamic fonts and that function just add some ahead of time. It still adds characters not present later.

#

If they never show then let's presume the font doesn't have em

umbral bough
#

ok, let me try to generate the font asset with that and see if it works

grand snow
#

In edit mode the texture in the font will update so you can see what it has added

loud vault
#

Something about my game's resolution is off. In windowed mode the game looks good, but in full screen the edges are jagged
Another thing is that to take a pic of the jagged graphics I had to take a pic with my phone, because if I take a screenshot it looks like in the windowed version
Maybe it has something to do with the monitor resolution settings?

slender nymph
#

not a code question, and this just looks like aliasing

loud vault
slender nymph
#

no, i mean the effect you are seeing is called aliasing. you need to use some sort of anti aliasing if you don't have it enabled to prevent that

loud vault
#

I don't get why the anti-aliasing wouldn't work on full screen*

slender nymph
#

have you even confirmed if AA is enabled?

loud vault
#

Yes

#

If I take a screenshot of the game in full screen, the screenshot is not jagged even tho the gameplay is

umbral bough
# grand snow I've used dynamic fonts and that function just add some ahead of time. It still ...

Ok, so I've been trying to get the AtlasPopulationMode to work but I couldn't.
It would just tell me that it couldn't resolve the atlasPopulationMode:, so I tried to look at the api for the latest tmp version(since I'm using unity 6), and that led me to this function being outdated and saying that I should use this instead, but that gave me the exact same error and it's not even compatible with the TMP_FontAsset from what I can tell so I am lost to say the least.
Any clues as to what I'm supposed to do?
Also, should I make a thread to stop spamming the main chat?

grand snow
#

Tmp dynamic font

true owl
slender nymph
#

those are incredibly small values, it's just in scientific notation. those values are so small they are effectively 0

true owl
#

interesting

#

do you mind taking a look at this

       if (Mathf.Abs(rb.linearVelocityY) < jumpPeakThreshold && Mathf.Abs(rb.linearVelocityY) > Mathf.Epsilon)
        {
            Debug.Log("float a bit...");
            Debug.Log(rb.linearVelocityY);
            setGravityScale(gravityScale * gravityHangTimeMult);
        }

slender nymph
#

why

true owl
#

i wanted it to kinda have a little float near the apex of the jump

#

but it seems to always run even if im just on the ground

slender nymph
#

check your conditions and also consider checking if you are also grounded

true owl
#

grounded is a good idea

cosmic dagger
#

if it happens while you're grounded, then check and make sure you're not . . .

cosmic dagger
true owl
#

that's true

#

mb

cosmic dagger
# true owl Hey all, I'm running into an issue where only sometimes the jump modifier second...

another note: your methods are both camelCase and PascalCase, which is confusing when reading the code. i'd stay consistent with one style. prefer PascalCase, especially, since all your methods except for 2 are not

you commented these are used for getters and setters. this is what properties are used for

// Old code
    void setGravityScale(float value)
    {
        rb.gravityScale = value;
    }

    float getGravityScale()
    {
        return rb.gravityScale;
    }

// New code
    public float GravityScale
    {
        get => rb.gravityScale;
        set => rb.gravityScale = value;
    }

you can do the same to create the IsJumping property . . .

naive pawn
#

do you even need GravityScale there
you could just use rb.gravityScale
the original wasn't exposing it to outside classes or anything

true owl
#

i just thought it'd be nicer to reference it using getter and setter

#

for readability honestly

naive pawn
#

are you from java

true owl
#

i kinda code all

swift crag
#

It is reasonable if your user doesn't have a reference to the rigidbody

true owl
#

i did my first 2 years in java tho lol

slender nymph
wintry quarry
swift crag
#

(but yes, use a property)

true owl
#

i guess that's true

naive pawn
#

getters/setters in that way is kind of java-specific

true owl
#

lol u got me

naive pawn
#

(maybe c++ too? i didn't really get that far)

true owl
#

alright i'll just access it using the property

naive pawn
#

the concept still holds, it's just written/used differently

cosmic dagger
#

i was only showing that using a property is better and easier to do, especially for readability and to save time. they can easily make it private, if needed . . .

true owl
#

i really hate the PascalCase

naive pawn
#

but if you don't actually need to expose rb.gravityScale, i'd recommend just using that directly

true owl
#

especially for methods it ticks me off so hard

wintry quarry
slender nymph
true owl
#

😔

slender nymph
#

it's just unity decided not to follow the standard for properties in their engine code for whatever reason

true owl
#

thats why im using it, but... I'll always look down on it lol

#

anyways thanks all for help

naive pawn
# true owl i really hate the PascalCase

you'll get used to it
it helps with uniformity with built-in methods
if you're familiar with something else, not being comfortable with the new pattern is pretty normal
but you aren't working alone alone here, you have to work with the standard library, unity's library, and any other 3rd party libs you might use
once you do get used to it, the uniformity will help in the long run

also be prepared to get stuck with it if you go use something else after using unity

cosmic dagger
true owl
cosmic dagger
#

especially, when looking through dot notation, you can see what should only be exposed for you to access . . .

naive pawn
#

well different languages have different structures
for example, in languages where functions are first-class citizens (eg c, js, py), it might make less sense to distinguish variables and functions

naive pawn
still elm
#

I have made a DDOL singleton for my settingsmenu, so that it can be used in more than one scene. The issue arises when I change back to the scene where the object originally is from. How do I solve the issues with this?

naive pawn
#

The issue
what issue exactly?

swift crag
#

yes, complete the thought :p

#

I presume the issue is that there are now two menus

cosmic dagger
#

a took a look at C++ and people use a few different styles (standards) for their coding. i guess it's different between the old and the new style . . . 🤷‍♀️

swift crag
#

Alternatively, use [RuntimeInitializeOnLoadMethod] to instantiate a menu prefab as the game starts

cosmic dagger
swift crag
#

(you can pull the menu prefab out of a Resources folder)

still elm
# naive pawn > The issue what issue exactly?

So. I don't exactly know what is causing the issue. But when go back to the original scene were the DDOL singelton pattern is on I can't press the options menu to open the settings. The settingscanvas is a gameobject being a DDOL singleton. The settingscanvas is supposed to have be activated/deactivated on button press.

swift crag
#

Oh, I know what you're doing

#

so the canvas lives in scene A

#

something else in that scene has a reference to the canavs

#

This is fine until you exit scene A and then return later

#

The object in the scene still references the canvas that lives in scene A

#

not the canvas that has been moved to the DontDestroyOnLoad scene

#

If that's the case -- don't store any direct references to the canvas. I presume you made it a globally-accessible singleton, so just reference it that way!

still elm
#

🤔

swift crag
#

perhaps you are forgetting to reset your timescale

#

e.g. if you set it to 0 when pausing

still elm
#

oh

#

I wish I had your brain

#

why did I not think of this

swift crag
#

because you hadn't run into the problem before 😛

#

you'll want to start thinking about state that can survive from one play session to the next

#

anything static is a prime suspect

trim moon
#

hi guys i have a question, when i am making a movement script should i use character contoller?

still elm
trim moon
#

i mean everything is working fine without it but i see that people is using it often

swift crag
#

one: whoever set it to 0 should set it back to 1 before they give up control
two: whoever needs it to be 1 should set it to 1 when they take control

still elm
swift crag
#

The second one is a better idea, IMO

#

It's proactive: I need this to be correct, so I will make it correct

#

rather than trying to catch every place you could forget to reset the timescale

#

You could also consider having a singleton game controller that constantly decides the timescale

slender nymph
still elm
swift crag
#

Those are two separate concepts

#

You do often throw singleton objects into the DontDestroyOnLoad scene, though.

#

My GameController bootstraps my entire game. It loads itself from Resources as the game starts