#💻┃code-beginner

1 messages · Page 562 of 1

azure bridge
#

so like my bunny character moves with the keys a and d but the animation is not the walking one its the resting one also do i just copy and paste my script here or

#

also its 2d game

naive pawn
#

so you have 2 parts, the movement and the animation

#

is the movement working fine?

wintry quarry
azure bridge
#

so its not script problem?

wintry quarry
azure bridge
#

oh thx

wintry quarry
plush sentinel
#

hello

#

i would like a little help since ive bin stuck on my problem for 3 days and i dont find anything on google

naive pawn
#

!ask

eternal falconBOT
plush sentinel
#

so i want to import my character with clothes accessories and i dont know how i should set it all up, like how to export and import it right

lethal meadow
#

here?

rich adder
#

oh i was thinking infinite like a inifinte world, like super mario but you couldn't go backwards instead of like "open world" whereyou can revisit the older areas. I misunderstood the gametype though i think lol

ornate aurora
#

Yes it's essentially an infinite map

rich adder
#

Unity Arduino C# and Unamanged C++ structs

rich adder
verbal dome
#

You could go with only saving the changes that the user has made. So you first generate the chunk from the seed and then load and apply the changes to it

ornate aurora
#

I heard about quadtrees. Is that useful here?

vast kettle
#

hello, how can i load a lightmap from a png file inside the unity editor and assign it to a scene?

timber tide
heady mesa
#

can anyone help me make a interact script

rich adder
heady mesa
rich adder
#

you'd have to show what you tried for far and what isn't working exactly.

heady mesa
rich adder
heady mesa
#

also when i do type the same thing, the tutorials letters some up as different colors to mine, is that because i did something wrong?

rich adder
eternal falconBOT
heady mesa
heady mesa
rich adder
heady mesa
rich adder
swift crag
#

"integrated development environment"

#

Which one are you even trying to use?

#

Show us a screenshot of your code editor

heady mesa
heady mesa
rich adder
#

is that vs 2019 or 2022

swift crag
#

The entire window.

#

you've cut off some parts

heady mesa
#

that open automatically

heady mesa
swift crag
#

You are still cropping out the title bar.

#

It's clearly Visual Studio, at least

#

(people very frequently mix up Visual Studio and Visual Studio Code, and I can't exactly blame them)

heady mesa
#

what should i use?

hot laurel
#

a better screnshoot

rich adder
#

use whatever is installed already

swift crag
#

If you didn't manually download Visual Studio and run an installer, you want the "installed via unity hub" option

heady mesa
rich adder
#

then more than likely you already have the workload part if thats installed through hub, you just need to link it in the External Tools part and possibly click Regen Project Files in that same page

#

You should see it in the guide

heady mesa
rich adder
#

not at all no

swift crag
#

Unity doesn't care about your IDE at all -- it compiles the code on its own.

rich adder
#

you should already have that ideally(all new projects come with it) thats the least important step

#

linking it in External Tools is most important step

#

the package version there is more important for vscode VSC which your not using here, it expects at least 2.0.20

quick epoch
#

hello guys could i ask a question real quick ? im not sure im in the right place here but im having a problem with the universalpipelinerender ... with the built it you could use the transparency with the Axis but this universal one i cant find where i can change it .... could someone give me a hand with this pleasE? its a 2d sprite game so im following a tutorial but my rendered is different

rich adder
#

this is a coding channel

heady mesa
rich adder
quick epoch
swift crag
rich adder
swift crag
#

and yes

#

follow the guide to configure this properly

heady mesa
#

which one do i change to?

rich adder
#

probably 2022

#

seems both might be configured

heady mesa
#

is that right?

rich adder
#

you dont need all those checked, the first two are fine and default

#

only check off first top 2, then click Regen Project Files (make sure VS is closed first)
then open a script from unity

#

You will have tons of unnecessary csproj/sln files otherwise

rich adder
heady mesa
rich adder
#

wait a moment until the bottom bar says Done

rich adder
heady mesa
#

in the bottom left it says ready

rich adder
#

go to View and open Solution Explorer

swift crag
#

You have no files open right now.

heady mesa
daring heath
#

i know i'm doing something dumb, but i'm trying to fix this:

public string enabledIfTrue; bool SpecialCondition = DialogueLua.GetVariable("" + enabledIfTrue).asBool;

where i need to get the public string value of enabledIfTrue to appear in the GetVariable

rich adder
#

try double clicking a script again, or open View -> Solution Explorer and click a file that way

rich adder
slender nymph
#

right click and reload with dependencies

swift crag
daring heath
swift crag
#

Yes

heady mesa
swift crag
#

"Foo" + "Bar" concatenates two strings

daring heath
rich adder
# heady mesa do i jus install this?

seems you dont have the Unity Workload for 2022 .
Go back to Visual Studio Installer, find 2022 hit Modify make sure the Unity Workload is checked off and installed

swift crag
#

compiler error?

#

runtime error? does nothing at all?

#

and is that second line of code from somewhere inside of a function?

#

or is it a field declaration just like the first line?

daring heath
#

as in, it doesn't seem to "get" whatever i put into the enabledIfTrue's inspector field. If I manually put the string in the place of enabledIfTrue in the script it works, but i want it to get the value from the inspector

daring heath
heady mesa
swift crag
#

!code

eternal falconBOT
rich adder
swift crag
#

It's trying to install features that are used for an unrelated kind of work, yes.

daring heath
#

@swift crag here's everything relevant, thanks for checking it out

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using PixelCrushers.DialogueSystem;
using UnityEngine.UI;

public class UniversalButtonDestroyer : MonoBehaviour
{
    public bool oneTimeUse;
    public string enabledIfTrue;
    //public GameObject button;
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        bool IsInConvo = DialogueLua.GetVariable("IsInConvo").asBool;
        bool SpecialCondition = DialogueLua.GetVariable("" + enabledIfTrue).asBool;
        Button button = GetComponent<Button>();
        Image image = GetComponent<Image>();

        if (SpecialCondition == false)
        {
            button.interactable = false;
            image.enabled = false;
        }
heady mesa
swift crag
daring heath
#

hmmm i don't, but would that be a problem if i did?

swift crag
#

You could check by searching the hierarchy for t:universalbuttondestroyer at runtime

swift crag
daring heath
#

for example the "IsInConvo" works totally fine

swift crag
#

Right, because every single instance will have the same string there

heady mesa
#

nvm i can't even load up my scripts cuz it said i need to install?

swift crag
#

would the installer still be available?

swift crag
rich adder
#

yeah it automatically installs it via that
VS doesn't install without the hub/installer as its how it updates too

violet glacier
#

Should I use MVC to separate UI from game logic? Is there a general way of separating them?

grand snow
#

I swear the most common issue here is people not having their ide setup correctly (usually vs)

rich adder
#

it would solve probably 70% of the questions / issues here

#

Quick Actions is godsent lol

heady mesa
rich adder
# heady mesa

how can I tell anything if you cut off the titlebar

#

looks like VS 2019 .

heady mesa
#

hold up

rich adder
#

looks like shitty brackys code lol

#

that time.deltaTime on the mouse inputs is dead give away or maybe someone copied that bad code

heady mesa
slender nymph
#

also the colors shown there are just a theme

rich adder
#

those looks like VS2019 icons

wintry quarry
#

It's absolutely incredible how much staying power that Brackey's bug has had on the Unity tutorial space.

#

That bug will never die

swift crag
#

I divide mouse input by deltaTime four or five times to compensate

#

💥

wintry quarry
#

You can never be too safe.

swift crag
#

(for those unaware: mouse input is not a velocity; it's an absolute amount of movement. multiplying by deltaTime makes no sense!)

heady mesa
#

this is my origonal problem, i jus dk this tut as i said ealier dont work for OntriggerEnter adn exiy

rich adder
#

but you should really fix your IDE before anything..

slender nymph
rich adder
#

true that, nothing a simple Raycast or other type of Physics query wouldn't solve neater

heady mesa
eternal falconBOT
#

:teacher: Unity Learn ↗

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

rich adder
#

this way its more structured

#

You wont be copying your "dream game" right away, its more about learning all the building blocks at your disposal before you build your house

heady mesa
#

btw i've installed 2022 now so what do i do now, will it work?

rich adder
# heady mesa w quote

You wont be making your first project the game you always wanted to make, its something you build up to

rich adder
hot laurel
heady mesa
heady mesa
#

it was like 1.8 gb

rich adder
heady mesa
rich adder
#

don't do that lol

#

easy way to corrupt your install

rich adder
heady mesa
rich adder
#

there we go

#

now you're coding like a pro , almost

heady mesa
#

whats the last step

rich adder
#

probably learn the basics before you do such complex systems like interactions

#

eg what does it mean to Get a Component etc.

#

yes you're using correct thingslike Raycast but do you know why? or what it is?

heady mesa
#

it tutorial

#

i just copied it

rich adder
#

I know but you're copying without understanding why you need that

#

copy and paste you wont learn anything

#

if you must copy and paste, learn why it is you need those

heady mesa
#

cuz i just dk it

#

and it dont work so idk how imma do it

rich adder
#

so learn

heady mesa
#

but how

#

that my issue

swift crag
heady mesa
rich adder
heady mesa
#

cuz im so far away

rich adder
#

trifecta of success

rich adder
#

so your raycast is infinite

heady mesa
#

how do i give the distance

rich adder
heady mesa
#

also is this a good movement script?

rich adder
#

lol its all collapsed

#

if its moving, its probably fine

heady mesa
rich adder
#

its fine..

#

I woudnt worry about that too much.

heady mesa
#

okay last thing lol jus to make sure, i do go down teh junior programmer pathway, i dont wanna waste my time lol

rich adder
#

yea

#

essentials wouldnt hurt either if you still dont know the editor

slender nymph
#

if you're new to the engine entirely then start with the essentials

heady mesa
slender nymph
#

okay then don't start with the essentials?

heady mesa
#

ok

#

thanks frrr

cosmic dagger
rich adder
#

I think other .net frameworks are more strict with MVC and MVVM

cosmic dagger
#

It's like a copy, honestly, it's kinda creepy how close you csn get to smth else someone has done with no knowledge of it . . .

rich adder
#

I only learned a few years ago that I was abusing events and the pattern was called "observer" lol

cosmic dagger
#

For MVC, I'm actually testing out using a C# class/struct instead of a MonoBehaviour, so it's pure data. Hopefully, it'll be better for null checks, and using the modern conditional operators. Plus, it's pure data, not tied to a separate MonoBehaviour. I'll see if it works out . . .

#

The tutorial has an error. It uses the null-conditional operator on a MonoBehaviour to check if health is null before calling Increment and Decrement, which is incorrect. That will not correctly check for Unity's null . . .

rich adder
#

maybe it was meant regular class

#

nah wait that wouldn't make sense cause you couldn't put it on a object

#

well actually if you do Serializable it

#

and its a SerializeField, it should work as its own health

#

maybe they got lazy lol

#

nvm HealthPresenter having an instance of Health would probably be going against the whole mvc thing

cosmic dagger
#

Because you could turn the controller into a generic class with T being any stat, like Health, Stamina, Dexterity, and the different fields for those C# classes/structs would appear in the inspector for your controller . . .

rich adder
#

yeah idk someone got lazy to write if (health != null) for the rest lol

#

also they use early return pattern in the same method and then go into a nest if statement :\

#
   if (health == null)
            return;

        if (healthSlider !=null && health.MaxHealth != 0)```
#

when it could just be
if (health == null || healthSlider = null)
return;

#

weird inconsistencies lol

astral falcon
cosmic dagger
cosmic dagger
#

Using a C# class/struct would remove having a second MonoBehaviour, but you're right, it would tie the data (Model) with the controller (Presenter) since they wouldn't be separate classes (layers) you csn access individually . . .

robust harness
#

!code

eternal falconBOT
cosmic dagger
#

Just imagine having two classes for a bunch of Controllers. That's a lot . . .

heady mesa
#

hey guys, anyone know how i get this pop up menu for auto correct for my IDE?

slender nymph
#

if it is configured that should appear automatically when typing

#

unless you've intentionally turned that off in the settings

heady mesa
#

do i need a plugin or something because i don't get that pop up

slender nymph
#

no, it's a built in feature

rich adder
slender nymph
#

is that not the example image of what they want?

rich adder
#

oh I thought that was theirs lol

#

didnt we configure their ide earlier?

slender nymph
#

yeah which means it should be working just fine unless they've intentionally disabled intellisense

rich adder
#

lets hope not lol

heady mesa
#

There's does that

#

mine does this

rich adder
#

wtf how did you undo what we did before

#

Monobehaviour was green here

heady mesa
rich adder
#

wat

heady mesa
#

modified it on teh unity development

#

and laucnhed it

#

and now it like that

rich adder
#

it was working fine

#

you must've done something

heady mesa
#

since idrk how to script

rich adder
#

I understand, but did you not open your script through unity?

heady mesa
#

i did im making a different script

#

for a different game

#

that hes teaching me to make

rich adder
#

show your external tools page again in Unity and solution explorer in VS

#

if you did a new project maybe the Preferences didn't save..

heady mesa
rich adder
#

yup..

#

iirc you have to open and close unity a few times before it saves those

heady mesa
#

ohr okay

rich adder
#

Okay so back to doing what you did before, select it

#

and regen etc.

#

close unity a few times

heady mesa
#

so now if i just load it it will work?

rich adder
#

make sure it saves your setting

#

do it a few times until unity opens with it saved

polar briar
heady mesa
#

thank you

rich adder
polar briar
#

I have to install it?

slender nymph
polar briar
#

Wait nvm

eternal falconBOT
polar briar
nova ivy
#

hello! i'm having issues with an animation transition

#

it's oddly delayed for some reason

#

has exit time is unchecked, transition duration and offset are at 0

#

no empty frames at the beginning of the animation

#

don't really know where to go from here

rich adder
#

unless its code you want to share

nova ivy
#

it runs inside a coroutine if you think that could be relevant?

#

but other stuff also runs inside it and they work instantly so back at the beginning

nova ivy
#

i'll try in the other channel

rich adder
#

Triggers are pretty wonky, if the transition is too long iirc they repeat

nova ivy
#

but yes i should absolutely find a better way to reference that player lol

rich adder
nova ivy
#

what's DI, also will take that into account

#

don't really know the practical differences between Start and Awake either i just use whichever

cold elbow
#

is there a better way to handle null reference exceptions other than try and catch and if else

cold elbow
wintry quarry
#

because it's extremely slow

#

and it hides actual programming errors that you need to fix

cold elbow
#

I guess is there any other way around if else statements

wintry quarry
#

Generally a NullReferenceException is a great thing

#

it tells you that you failed to set up or configure something about your scene or your data model

#

the best way to fix it is to make the thing not null

#

by properly setting things up

#

In the rare case where it's acceptable for a variable to actually be null, you just need to check if it's null before you use it.

swift crag
#

exceptions should be exceptional

wintry quarry
#

I mean - the program is in a good state even if that thing is null

swift crag
#

I know that Python encourages you to just YOLO it

cold elbow
#

oh ok

swift crag
#

I've been getting rid of more and more "maybe null" variables

#

and factoring those out into separate components

polar briar
#

I got a maybe dumb question

#

2 actually

rich adder
# nova ivy what's DI, also will take that into account

Dependency Injection. Like if you spawned this object from something in the scene that could have reference to player, you "pass it " to the new spawned object. That is passing your Dependency or "injecting it" the term is a bit loose In Unity though.

Also Awake is basically constructor for gameobject, it runs regardless of gameobject (unless the whole thing is disabled). Start has a checkmark, if its disabled then it doesnt run

cold elbow
#

in our java programming class our professor was telling us about how excepetions are the best way to handle errors or at least better than if else

polar briar
ripe shard
wintry quarry
ripe shard
#

he certainly didnt mean to use them for logic flow and fixing sloppy coding

slender nymph
wintry quarry
nova ivy
cold elbow
cold elbow
wintry quarry
cold elbow
#

bruh I hated that ide so much

rich adder
cold elbow
#

I just used intellijide

polar briar
#

I need to find a way to get a shit ton of points or trace the cursers ray hits.

polar briar
#

Specifically draw since actual placement during the movement is important

#

So you can make your char move In a straight efficient line or a long detour line

wintry quarry
#

then have your character follow the list of points

#

You could do every .1 seconds or something instead for performance reasons

polar briar
#

Okay that what I was kinda planning

#

But it’s the actual execution I need to figure out

#

Like what to type and stuff. So research time!

astral falcon
#

cant you use navmesh to get the path and then show the line accordingly?

wintry quarry
#

They don't want the fastest path to a point

#

they want the character to follow the path the mouse traced out

astral falcon
#

ah okay, thought they gonna track just start (character) to end (mouse pos) and then let them walk there, my bad

wintry quarry
#

you probably still want to have navmesh involved though - to handle pathfinding to the mouse points, because the mouse may trace out a path that goes through a wall for example

astral falcon
#

Just was thinking of the mentioned baldurs gate movement, where you just set the destination, not the path itself. But something to clarify by the questioning person

polar briar
#

(Think yomi hustle X BG3)

astral falcon
#

Ah, so you need specific distance points your player can "use" to move?

polar briar
#

Kinda. I’m having it so you draw the line and then as the frames advance you run it, unable to stop. Risk and reward type thing

wintry quarry
astral falcon
#

I am sure, you can split up the found path into some "sub"paths and go from there. But as you said, that really sounds like a prototyping thing to test what works for you

polar briar
#

Sigh I am realizing this project is a bit big scope for a first every game. But motivation is motivation

astral falcon
#

Think of systems, not the whole game and things get smaller.

rich adder
#

one piece at a time

polar briar
#

Hence why I’m starting on movement and not the combat or the environment shit

#

Or the… online comparability

#

I do plan on having about 300~ abilities in the game but again, that’s an issue for later

astral falcon
#

Just keep in mind, its your first game so even if you fail, you gain knowledge. And if you dont fail, congratz. Just look at it as research for your career path rather then trying to be the next AAA title. Be proud of smaller achievements like learning navmesh in this case and other things, that will come up while you realize, what you need for the systems you want to include.

polar briar
#

I pray this isn’t a AAA game.

#

🤮

astral falcon
#

Back in the days when I wasy ounger, AAA was good 😄

polar briar
#

I hope it’s a functioning shit show

polar briar
astral falcon
#

more like before 2000s childchood 😄

polar briar
#

I think what I need to learn first is. Raycasting. Navmesh. And saving points

polar briar
astral falcon
#

Sounds like a plan 🙂

polar briar
#

Quarter of a decade ago damn

astral falcon
#

So, time for me to get some sleep, getting late here 😄 Best of luck for you and have fun learning and researching! 🙂

cold elbow
#

Ive been having this error show up on my console since I started my project before I even started coding anything

Unity.PlasticSCM.Editor.ViewSwitcher.OnDisable () (at ./Library/PackageCache/com.unity.collab-proxy/Editor/ViewSwitcher.cs:205)
Unity.PlasticSCM.Editor.PlasticWindow.ClosePlastic (Unity.PlasticSCM.Editor.PlasticWindow window) (at ./Library/PackageCache/com.unity.collab-proxy/Editor/PlasticWindow.cs:1096)
Unity.PlasticSCM.Editor.PlasticWindow.OnDisable () (at ./Library/PackageCache/com.unity.collab-proxy/Editor/PlasticWindow.cs:283)```
rich adder
#

you can remove the VC package and restart unity

#

if you use unity VC idk then lol

tired junco
#

Hey, im having an issue with this rotation handling im calling in fixed update which results in a jitter effect of the whole character

eternal falconBOT
wintry quarry
#

and share the full script as we're missing context here such as where is this running

tired junco
wintry quarry
#

Where and when does this HandleKeyoardMovement get called

#

Is it in Update?

tired junco
#

fixed update

#

but the camera jitter does only appear if i call HandleRotation method

wintry quarry
#

ok well I would say a few possible issues here:

  1. Your use of transform.eulerAngles.y in several places. Euler angles cannot be isolated individually from a Transform and expected to be relied upon for game logic
  2. Potential lack of interpolation on the Rigidbody
vapid ledge
#

is there a simple way to dynamically resize text to fit inside a gameobject? i'm trying to make a function that, given a gameobject (with a child tmp_text), maximises the size of the text whilst not letting it get bigger than the size of the object itself

wintry quarry
vapid ledge
#

i have tried that

#

it doesnt seem to account for the length of the text string itself

#

or some other variable i'm probably missing

wintry quarry
vapid ledge
#

oh ok

#

ty

charred lake
#

Any chance someone can help me with this script? As far as I know this is all right, but after the objects are assigned it doesn't seem like the script effects anything

rich adder
#

debug.log your EventStarter before Wait see if it even enters the Coroutine

cosmic dagger
charred lake
#

Correct

rich adder
#

put log on each step see where it fails

charred lake
#

I'm new new chief, how do I do that?

rich adder
#

above each Wait for seconds

charred lake
#

I've never had to debug. Where, how, what? (I apologize)

cosmic dagger
charred lake
#

AH

charred lake
#

Forgive me, but I'm so lost, this right?

rich adder
charred lake
#

It doesn't recognize it

rich adder
cosmic dagger
rich adder
#
Debug.Log("step 1");
yield return new WaitForSeconds(2);
Debug.Log("step 2");
etc..```
charred lake
#

Uno momento

cosmic dagger
charred lake
#

Right

#

👍🏾 ?

rich adder
#

save it. then run the code again, check the console tab

charred lake
#

Thank you

#

One moment

rich adder
#

ok so its working

cosmic dagger
#

it does work!

charred lake
#

And that's what's confusing me

rich adder
#

so are sure you referenced the correct objects you are lookking to disable / enable

cosmic dagger
slender nymph
#

did you do something silly like drag prefabs into the slots in the inspector?

rich adder
#

hehe yeah that would be bad

cosmic dagger
#

make sure you dragged the correct GameObjects in each slot. check if they are activated/deactivated during runtime . . .

cosmic dagger
slender nymph
#

what part of the question do you not understand?
also your screenshot shows you allegedly did not do that anyway so 🤷‍♂️

cosmic dagger
# charred lake

we can't see where these GameObjects are. they look like UI GameObjects; are they in the scene view or off-screen?

inland cobalt
#
        public static Collider GetCollisionOnUpdate(Rigidbody self, float maxDistance = Mathf.Infinity)
        {
            float distancePerFrame = self.linearVelocity.magnitude * Time.fixedDeltaTime;
            Ray ray = new(self.position, self.transform.forward);

            // Based on estimated position next physics update, check if there is a collider there
            UnityEngine.Physics.Raycast(ray, out RaycastHit hit, Math.Min(distancePerFrame, maxDistance));
            return hit.collider;
        }```
Anyone know what im doing wrong here? I'm trying to predict whether a collision will occur or not in the next physics update, and will return the collider that it hits (which will end up being null if there is none), except it never seems to return the collider when i would expect it to

```cs
Debug.DrawRay(ray.origin, self.linearVelocity * distancePerFrame, Color.green, Time.fixedDeltaTime);

I've added this for debugging, and it looks as expected, so i have no clue what im doing wrong

rich adder
# charred lake

you realizing that charSirDummy and charLadyDummy are already enabled, what sense would it be to set them as active again

charred lake
slender nymph
eternal falconBOT
#

:teacher: Unity Learn ↗

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

rich adder
#

they start Active, why are you setting Active = true in code ?

#

perhaps you wanted to HIDE them ?

#

or you're just misunderstanding what SetActive does

#

its not gonna magically make them appear if they're offscreen

charred lake
cosmic dagger
rich adder
charred lake
#

Apologies, let me explain

inland cobalt
charred lake
#

And I've fixed it

rich adder
charred lake
#

Yeah I pressed the wrong button

charred lake
#

Mayhaps I shoulda worked on this when I got a proper sleep

#

Thank you all very much for your assistance though

#

The debugging will definetly be helpful. I've been lucky up till now that I haven't needed it, but it'll be good to know👍🏾

rich adder
cosmic dagger
inland cobalt
#

Sorry i realised i probably used the word frame when i shouldn't, i'm just talking about physics here, not rendering

tender wren
#

I am having trouble understanding why scriptable objects are used the way they are.

I read the docs for them and noted in other tutorials it should be used as a data container, but the data shouldn't be changed.

Additionally, other uses for it have scriptable object is communicate through events?

If I wanted to use a scriptable object for a global variable to reference through events, should that variable never change?

Anyone have a video that explains them with an example that makes sense.

polar acorn
near wadi
#

I cannot seem to find the code to align center the Button

        if (GUILayout.Button("Select Output Folder", GUILayout.MaxWidth(250)))
        {
            baker.SelectOutputFolder();
        }
tender wren
cosmic dagger
polar acorn
near wadi
#

can't you change them, but have to write them out to a save file..

rich adder
cosmic dagger
inland cobalt
polar acorn
#

Think like, a TCG card. Every Grizzly Bears is a 1G 2/2 Creature with no abilities. This never changes. If you play a Grizzly Bears and then buff it with Giant Growth, it doesn't change the file that says "Grizzly Bears is a 1G 2/2 Creature with no abilities", you are just changing this Grizzly Bear

rich adder
inland cobalt
near wadi
rich adder
cosmic dagger
near wadi
inland cobalt
hot laurel
# cosmic dagger the problem is, you *can* mutate the values of an SO during runtime, but it *mus...

The Asset SO is a serialized ScriptableObject instance:

In Editor: Mutable and savable as a standalone file. Changes are serialized and saved via the AssetDatabase and Unity's serialization system.
In Build: Read-only. Runtime values can change but cannot be saved back, as it is part of the build.
On scene reload, the ScriptableObject resets to its original state.
To Save Runtime Changes: Use external files or systems that are not included in the build.

cosmic dagger
hot laurel
#

its clarification, so its bound to your post for follow up

hot laurel
inland cobalt
#

For more context the reason im doing this is because i want physics based rotation control in my game, but i dont want my character to spin out when hitting something, so i am constraining rotation when i suspect i will hit something

        if (PhysicsUtils.WillCollideOnUpdate(rb, out _)) rb.constraints = RigidbodyConstraints.FreezeRotation;
        else rb.constraints = RigidbodyConstraints.None;
hot laurel
#

just estimate the position after 50 frames

inland cobalt
hot laurel
#

it wasn't the point

#

20 ms estimations are usless

inland cobalt
hot laurel
#

just increase the frame value, thats the solution, explaining it is effortless

inland cobalt
hot laurel
#

do math with real numbers, and you will understand how the distance ray looks just for 1 frame, 1 frame is equivalent of 0.02, put the numbers, calculate

#

like this, not in code block to don't copy paste

rocky canyon
#

what IDE are u using?

hot laurel
cosmic dagger
# inland cobalt But the point is i want it to check for the position it is the next physics upda...

Maybe your confusion comes from seeing the distance as a measurement per frame or per second

First, when dealing with movement in FixedUpdate, since it's frame-rate independent, you don't multiply by deltaTime (we already know this)

Second, the distance is a measurement of space, not time; i.e., 1 is 1 unit, 10 is 10 units (a unit is one grid space in the scene). It's independent of time. Multiplying by fixedDeltaTime will only change the measurement of distance in space, not on a per frame or per second basis . . .

inland cobalt
plain imp
#

Input System Newbie:
I've been adapting the Smartfox Shooter demo which has walk, run, jump etc all set up.
It has the Input System - Custom Character Controller - Animator already in place.

I'm now trying to add dance animations for my not-shooter game.
I've gotten a key working to toggle dancing on and off but I think it's not switching the boolean Dance.

To keep the UI simple for now, I've made an Animator layer that (I think) can progress from one animation dance loop to the next to the next as long as Dance == true.

I think the boolean Dance isn't activating when my key press toggles it on, although I can see that it's activating the reset of the other booleans. Maybe it's getting switched of by the other functions which check the move/jump functions.

Also the two original layers have a blue line under them but my new third dance layer doesn't.

I'll experiment with adding my Dance == false rule to the other layer, but any advice would be welcome.

cosmic dagger
# plain imp

i'm unsure about your issue, i just wanted to point out a piece of your code: dance = dance ? false : true;

it seems you want to flip its value, if that is true, you can simplify it with dance = !dance;; it's more readable and shows your intent more clearly . . .

plain imp
#

Thank you. I'm working on understanding this demo's controller logic, so I can add my own additional animations.

  1. Having dance anims on a separate Animator layer is preferable b/c their walk/run/jump graph is a web with every state connecting to every other state.
  2. The logic seems to be:
    (for example) Tap shift to toggle run on - update RunForward bool on Animator to true - send animation change to SF2X multiplayer network - Animator changes state to RunForward b/c that bool is true.

I can see the bool changes for their walk/run/jump in Animator. Now I'm figuring out how to add my dance animations correctly.

near wadi
#

Intro to my new series on Editor Scripting!

This is intended to be a very basic introduction into Editor Scripting and customizing assets to be more clean and usable inside of the Unity Editor.
Keep in mind... the first few videos will be covering a few basics that aren't Editor Scripting proper, but are necessary to build off of as we move to ...

▶ Play video
#

i put it here because it covers concepts that are used all the time. it is Not Editor Scripting specific.

compact monolith
keen owl
#

Don’t think that’s a code question but you just layer another sprite

compact monolith
keen owl
#

Oh I thought you were talking about the holes on top. You would probably use a tag based approach to have some colliders ignore other colliders maybe

compact monolith
keen owl
#

You just said it collided with another object, did you mean overlap?

inland canopy
#

!collab

eternal falconBOT
#

:loudspeaker: Collaborating and Job Posting

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

tiny wind
#

hi, im new iin coding, what does this meaan?

frail hawk
#

show some of the code maybe

tough plinth
#

Hello Everyone, having trouble with the script below:

So I need to rotate Instantiated object by 90 degrees on X axis, but it says that it can't convert void to Unity.GameEngine.Quaternion

#

Tried using variable, didn't work

frail hawk
#

rotation probably instead Rotate

tough plinth
#

Yeah, that what I was here for the first time, but as I said, it spawns that object below 90 degrees on X axis

astral falcon
#

Rotate is a method, not a quaternion, which it expects

#

You are instantiating whatToSpawn (bad namings btw) and you set it to the position of the whatObject and then you Rotate the target object with nothing. Thats your code currently doing

#

It does not make sense at all, because your instance created is not parent of your whatObject, so you rotate it but nothing happens to your instance

tough plinth
#

How do I rotate with something?

frail hawk
#

do you wan to have the same rotation as an gameobject at that time

astral falcon
frail hawk
#

or will the rotation always be the same

#

orr do you want the initial rotation of the prefab

tough plinth
#

So it will look not straight, instead, it will look up

#

Because if I leave with rotation, it will look straight

#

Just need to rotate bit a bit

frail hawk
#

Quaternion.Euler(90, 0, 0); try this

astral falcon
#

Thats not taking into account the whatObject rotation tho

frail hawk
#

he did not say that anywhere

#

he only said the position of the main object

astral falcon
#

Ah my bad, it was just position, true

tough plinth
#

Ah

#

Thank you, it worked!!

#

ty guysblushie

frail hawk
#

you are welcome

#

you could also just have the prefab rotate 90 degress on x before instantiating and then simply use Quaternion.identity

tough plinth
#

Oh, and @astral falcon, you said namings were bad, was it because it was hard to understand what they mean?

Renaming to:
confettiVfx
plrBody

Is more solid and understandable?

astral falcon
tough plinth
frail hawk
#

yes

tough plinth
#

Oh I got it, thanks

tiny wind
#

my character wont move anymore after I put the animations, pls help

#

im just using the code from the tutorial im watching

frail hawk
#

post it as code , it is easier to inspect

#

also do you have any error messages in the console

tiny wind
#

using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
[SerializeField] private float speed;
private Rigidbody2D body;
private Animator anim;
private bool grounded;

private void Awake()
{   
    //Grabs references for rigidbody and animator from game object.
    body = GetComponent<Rigidbody2D>();
    anim = GetComponent<Animator>();
}

private void Update()
{
    float horizontalInput = Input.GetAxis("Horizontal");
    body.velocity = new Vector2(horizontalInput * speed, body.velocity.y);

    //Flip player when facing left-right.
    if (horizontalInput > 0.01f)
        transform.localScale = Vector3.one;
    else if (horizontalInput < -0.01f)
        transform.localScale = new Vector3(-2, 2, 2);

    if (Input.GetKey(KeyCode.Space) && grounded)
        Jump();

    //sets animation parameters
    anim.SetBool("RUN", horizontalInput != 0);
    anim.SetBool("GROUNDED", grounded);
}

private void Jump()
{
    body.velocity = new Vector2(body.velocity.x, speed);
    anim.SetTrigger("jump");
    grounded = false;
}

private void OnCollisionEnter2D(Collision2D collision)
{
    if (collision.gameObject.tag == "Ground")
        grounded = true;
}

}

tiny wind
frail hawk
#

line 32 looks weird to me

frail hawk
hot laurel
frail hawk
#

that is why i asked which tutorial they are following, maybe just a simple typo

tiny wind
tiny wind
# frail hawk what tutorial is it that you are following

In this video we're gonna focus on how to animate a 2D player in Unity. We're upgrade our graphics, create animations and make them work from our code.
● Unity Asset Store: https://assetstore.unity.com/
● Dragon Warrior Asset: https://assetstore.unity.com/packages/2d/characters/dragon-warrior-free-93896
● Pixel Adventure Asset: https://assetstor...

▶ Play video
frail hawk
#

he used lower case "run"

#

same for "grounded"

tiny wind
#

i have it in uppercase because the parameter's name on mine is RUN, same for GROUNDED

frail hawk
#

do you still have any errors

tiny wind
#

on the console, no

hot laurel
#

transform.localScale = new Vector3(-2, 2, 2); this doesn't look right

#

comment the if with that line out

#

and check if its working

frail hawk
#

wha is the value of speed in your inspector

tiny wind
#

10

hot laurel
# tiny wind 10

fix line 26 to transform.localScale = new Vector3(-1, 1, 1);

#

dont see anything else wrong

tiny wind
#

also, i just noticed, it also isnt falling even with gravity

burnt vapor
#

Scale has nothing to do with gravity anyway

#

Can you log body.velocity?

#

Loks, check what it is. I assume that it is constantly 0 or a weird value

hot laurel
#

and show inspector screnshoot of the character with uncolappsed rigidbody2d

burnt vapor
#

Are there errors in the Unity console?

tiny wind
burnt vapor
#

So this script is probably not even attached, or something else isn't

#

Click the message, it will point to the missing component

#

Assuming it's this script, add it

tiny wind
burnt vapor
burnt vapor
# tiny wind

Regardless, I can see the script is included here so that's probably not the issue anyway

hot laurel
#

the Component looks ok, thought you freeze one of axis by mistake but no. You can Debug.Log(horizontalInput) right after you assign value to it

burnt vapor
#

Does the scene play with no errors?

tiny wind
#

no but something new happened

#

the running animation now plays when I press trhe arrow keys

#

but im still not moving or falling

#

and the character now flips depending on the direction (which was a problem i was trying to solve earlier but ig its fixed now)

hot laurel
#

and its reacting to input so you doesnt need to debug the horizontal input anymore

burnt vapor
#

Like I said, debug the velocity

burnt vapor
hot laurel
#

i think its still may be line 26 fault, the flipping x axis may collide with physic system

frail hawk
#

unlikely

burnt vapor
#

Apart from it still being as lot of guesswork due to lack of debugging results, this is very unlikely to be the issue

burnt vapor
hot laurel
# frail hawk unlikely

it alreeady affected animator and physics when it was scaled up, now its just flipped on x axis, thats from where that guess coming from

#

few debug.log would solve it easy

burnt vapor
#

If it has anything to do with flipping then the unflipped variant would not have any issues

#

Again, bunch of guessing while there is no actual proof of anything so this is pointless

hot laurel
burnt vapor
#

You guess huh

feral moon
#

The object that the code is linked to should become invisible when another object taken from the scene is visible.

Can you help me with writing this code? Because mine don't work out.

toxic pine
#

i got this on the triggerenter of my object to move the camera up but nothing happens: if (other.gameObject.tag == "trig")
{
Debug.Log("itsworking butnot");
camera1.transform.position += new Vector3(0, (float)cameramove, 0);

       // Camcontroller.moveup = true;
    }
#

i get the debug message

#

but the camera doesnt move

burnt vapor
#

I suggest you debug what it returns

frail hawk
#

cause you are only doing this in one frame.

toxic pine
frail hawk
#

then you would have to do that in the update or maybe in a coroutine.

#

rn you are doing this in the OnTriggerEnter

toxic pine
#

its okay if it happens once i dont want it to keep happening

burnt vapor
#

I thought it wasn't moving at all?

#

So does it move but only slightly or not at all?

toxic pine
#

its not moving but its suppose to

burnt vapor
#

What does cameramove return then?

burnt vapor
toxic pine
burnt vapor
#

1 is not much

#

Does Y of camera1.transform.position change then?

toxic pine
#

not at all

burnt vapor
#

How did you debug it?

#

Show the code

toxic pine
#

f (other.gameObject.tag == "trig")
{
Debug.Log("itsworking butnot");
camera1.transform.position += new Vector3(0, (float)cameramove, 0);
Debug.Log(cameramove);
// Camcontroller.moveup = true;
}

burnt vapor
#

What does it log when you do Debug.Log((float)cameramove);?

#

Alternatively log camera1.transform.position before you add cameramove

#

I don't see how this doesn't properly mutate the value

verbal dome
#

Something else could be modifying the camera pos

verbal dome
#

Like cinemachine, a script, or even an animator

burnt vapor
#

Yes, then it's probably being reset if you're certain it's being added

toxic pine
#

could be cinemachine but its a normal camera

burnt vapor
#

You see cameramove is a valid value that would update the position, and the code looks correct.

#

What you can also do is log camera1.transform.position in an update function to see what it returns each frame

#

If correct it will show the new value, then go back to the previous value

toxic pine
#

alr ill see

#

i maybe know why

#

the object the script is on is a prefab

#

and i made the camera a prefab

#

and the position of the prefab changes instead of the camera in the sccene

#

bc in the debug its shows its moving up

#

could that be it?

tiny wind
# burnt vapor

I just got back, how exactly do I do this? i still dont get how to log

burnt vapor
verbal dome
toxic pine
verbal dome
#

I suppose you are Instantiate-ing the camera somewhere? That method returns the instantiated object. You can store that reference

toxic pine
#

but how can i store an instantiated object?

verbal dome
verbal dome
toxic pine
#

ah

#

its worksss!!!!!

tiny wind
# burnt vapor

i dont think im doiung this right because its saying all compiler errors must be fixed before entering playmode

tiny wind
languid spire
#

I think the first error is pretty obvious

tiny wind
#

this showed up after i tried to debug

willow shoal
#

Hi

languid spire
#

ok so show me line 21 of the PlayerMovement script

tiny wind
#

still tryna figure out how to use debug.log

languid spire
#

And what does the first error message say?

#

this has nothing to do with Debug.Log. It is absolutely basic C# syntax

burnt vapor
#

I don't see how the link is unclear, it explains it properly

#

And like Steve said, this is basic c#

#

Actually, take a step back because your editor is nog configured

#

So configure it first, and then continue with the issue

#

Because it's obvious the editor is not helping

eternal falconBOT
tiny wind
#

i just started using unity 12 hours ago, theyre all pretty hard for me to understand rn lmao

burnt vapor
#

Properly configure VSCode first. I suggest you switch to Visual Studio or Rider however

tiny wind
#

ight

near wadi
#

Junior Programmer Pathway on the !learning site is a good start

eternal falconBOT
#

:teacher: Unity Learn ↗

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

burnt vapor
#

It can't even detect a missing semicolon so if you have trouble writing code you should definitely get the extra help

languid spire
#

end of line 21

#

if the error message is not understandable then learning C# basics is an absolute necessity

tiny wind
languid spire
burnt vapor
#

I am very aware of the issues, that wasn't the point of configuring it. You are going to have a hard time yourself

near wadi
#

they are going to laugh when they finally configure it, and watch it start auto-completing code for them

tough plinth
#

Hello!
So I've encountered a problem with music (SFX) not playing when player collects collectible object.

Script works fine, with VFX (explosion) being played, but for some reason music is not.

Any thoughts?

hexed terrace
#

you play the audio and then immediately destroy the game object

tough plinth
#

So, it doesn't have time to fully play?

hexed terrace
#

how can it? It no longer exists when you destroy it..

tough plinth
#

Yeah, I agree

#

Fresh look helps a lot

#

Thank you!

cinder schooner
#

you should call destroy like this, Destroy(gameObject, Audio.clip.length);

hexed terrace
#

That's a good way to delay the destroy, but not the only thing that will need doing for this. The visual will still be present until the clip finishes, and that needs to disappear straight away.

cinder schooner
#

or stop it once you know it should stop. e.g. delay

hexed terrace
#

yes, so making it disappear straight away

willow shoal
#

Is there another script/option in unity than animator.Play("StateName");? like play.this.animation ? i have a lot of animation and i need just add for inspector my animation. I have to do it faster

#

every time type ur animation in script is boring : / i just need add for inspector my animation

#

just this

tough plinth
#

So. Another question.

How do I tell the script which one I want it to play?

#

Since you can't rename them, what's the option?

burnt vapor
#

Why do you have 2?

verbal dome
#

Make serialized fields and drag them into different slots

willow shoal
#

ooo

tough plinth
#
  1. For Win SFX
  2. For Collecting SFX
burnt vapor
#

That is assuming you have two separate audio sources because you want to avoid cancelling eachother. This would fix it.

tough plinth
#

Wait wait. I'm completely confused.

If there is a problem with using 2 same components in Unity, how do people manage to play multiple audio on a single GameObject?

burnt vapor
#

There's not, I am just suggesting a simpler alternative if this is the reason yo have two audio sources

#

It is perfectly possible to have multiple channels. PlayOneShot has its own limitations

#

But if you want to simply be able to play sounds without them cancelling eachother out, you can have a single channel and use this method

#

But to answer your question, generally you'd make a sort of manager that maintains the audio sources and balances sounds between them. Specifically by using specific channel groups

#

Don't make a source for every single sound, make them for a category in that case

tough plinth
#

Is it beginner friendly?

burnt vapor
#

I guess

#

Alternatively just use GetComponents in a script to get all audio sources and use one of the returned instances

tough plinth
#

So the idea is just to play a sound when player collects an object, but the thing is that player body is already using one of the AudioSources, so that's the problem

burnt vapor
#

Yes so PlayOneShot would fix this

tough plinth
#

Also, what about Empty GameObject with Box Collider? Since empty GameObject is actually nothing and does not Collide, you can make lots of them and use like a hitboxes?

#

The problem with Destroy() as said

#

Even with PlayOneShot(), sound doesn't have enough time to play

hexed terrace
#

so think about it logically..

#

You want to:

  • hide visual
  • play sound
  • destroy after sound has finished
burnt vapor
#

I didn't see the chat about destroying it

#

Yeah considering it's more or less a fire and forget thing, you can't check if it finished

tough plinth
#

I think I will just make it to send a signal to play that sound on the Player model

#

So it doesn't destroy with the sound

hexed terrace
#

no, it shouldn't be on the player.. it has nothing to do with the player

tough plinth
#

Play sound on the player model?

#

Instead of particle?

hexed terrace
#

I literally just said do not do that

tough plinth
#

Alright I won't

burnt vapor
#

You could, but it just couples a sound on the player which has nothing to do with the actual player

#

So you really should not

hexed terrace
#

Collectable parent should be an empty gameobject, with the components on it.. the visual should be a child of this.
collect -> disable visual + play sound -> destroy parent when sfx finished

tough plinth
#

Maybe I can try with Get components ()?

hexed terrace
#

🤔

tough plinth
hexed terrace
tough plinth
#

Thanks for a tip

#

Uh, it does the thing but. Collectible is no longer destroy..

#

Nvm, I fixed it.

#

Thank you guys for your help! @hexed terrace @burnt vapor @cinder schooner

azure bridge
#

hello im doing a score UI where the player collects things and the score updates, the score is changing but its not displaying in the screen i need bit of help

leaden pasture
#

How are you currently updating the UI?

burnt vapor
eternal falconBOT
azure bridge
# leaden pasture How are you currently updating the UI?

using UnityEngine;
using TMPro;
public class ScoreManager : MonoBehaviour
{
public TextMeshProUGUI scoreText;
private int score = 0;

   public void AddScore(int points)
{
    score += points;
    UpdateScoreText();
}

private void UpdateScoreText()
{
scoreText.text = "Score: " + score.ToString();
}
}

leaden pasture
#

Though actually I'm not sure if you can access the text from TextMeshProUGUI itself. I tend to use TMP_Text anytime I want to edit the text. Don't quote me on that though (I don't think I've ever tried accessing it through the UGUI type) but could possibly be that

burnt vapor
#

Also check for errors in the console, which could prevent compilation of newer code

frail wind
#

guy i'm using this very simple player running code

 {
     playerSpeed *= 2f;
 }
 if (Input.GetKeyUp(KeyCode.LeftShift))
 {
     playerSpeed /= 2f;
 }```
it kinda work when holding the key but i feel like this code gonna going to break any time soon. do you think this code is ok?
azure bridge
azure bridge
#

im frying my brain

#

i tried everything

leaden pasture
#

Huh. And the score Text variable is assigned to the correct one right? (I've had it before when I've spent ages tryna work out why my text isn't showing and it turns out I had the TMP_Text variable set to an invisible component 😭)

azure bridge
#

this my first game i have no clue what im doing icl

burnt vapor
#

Does it point to the correct component?

#

And also, is this the component actually written to the UI?

leaden pasture
# frail wind guy i'm using this very simple player running code ``` if (Input.GetKeyDown(Key...

Looks good to me. A couple potential things though:

If there's ever a case where somehow it registers like the get key up twice but get key down only once or something (seems unlikely but it could potentially happen if Input is ever switched off for whatever reason), then it could end up with the walk and run speed both doubling or whatever. I would recommend setting it to specific values

I would also suggest using the new input system. Not necessary but it's definitely useful for adding and changing bindings if you ever wanna do that in the future (plus if you use PlayerInput components you can much more easily pause the game with anything not tied to deltaTime by switching them all off)

burnt vapor
leaden pasture
burnt vapor
#

Instead, set up a system of decimal speeds and get the average from them

#

So base speed 1, then sprint speed 2, final speed is 2

#

When anything mutates player speed, apply this list of modification, and use the final result as the speed

#

For example, slimy floor slows you down with 0.75

#

List is now base 1, add sprinting 2, remove slimy floor 0.75

#

Final speed is now 1.5

burnt vapor
#

Is there no visual indication of text at all, or is there text but it doesn't update?

tough tartan
#

https://youtu.be/6Ai0xg6xTUk?si=tiFtvSInPkJHFYRX i follow this tut and my enemy is somehow at the speed of light

In this video, you will learn how to make an enemy object that will follow your player. The first thing you need to do is to make a cube that will resemble an enemy. I have set this cube to be red colored, just by making a material and choosing the base color to red. You can also download the script files.
DOWNLOAD THE SCRIPT: http://github.com/...

▶ Play video
#

I even increase mass and decrease speed

languid spire
#

please do not post photos, use screenshots

tough tartan
languid spire
#

And your code? This is a !code channel after all

eternal falconBOT
tough tartan
#

enemy follow script

languid spire
#

read the bot message

tough tartan
#

normal follow script

#

ok

#

followscript

#

enemyfollow

languid spire
#

firstly why are you using SetDestination EVERY frame?

tough tartan
#

whatthe tutorial said

languid spire
#

wrong

#

if that is what the tutorial did, it is crap, find a better one

tough tartan
#

how would i fix that?

languid spire
#

think about it.
irl, if you have to go to several places at what point of your journey do you decide where to go?

tough tartan
#

start

languid spire
#

exactly, not 200 times per second

leaden pasture
#

I'd argue that it's not quite so simple in this case as the AI is moving to the player, which would theoretically be moving so you would have to call SetDestination at other points to move to where the player now is. But yeah ideally using something other than Update because that's probably not very preformant

tough tartan
#

hes still zoomiung off at the speed of light

languid spire
#

also, if this code

transform.position = Vector3.MoveTowards(this.transform.position, targetObj.position, 10 * Time.deltaTime);

is from a tutorial, bin the tutorial because it is a waste of space and find another one

leaden pasture
tough tartan
burnt vapor
#

I swear this whole day has been people asking something and then just disappearing without a solution

leaden pasture
# tough tartan the enemy

I think both scripts are attempting to do the same using different methods (one using the navMesh and one using transform) so then the movement from both kinda add onto each other if you're using both

languid spire
leaden pasture
#

Judging from a quick glance at the tutorial anyways

tough tartan
burnt vapor
leaden pasture
#

Which is what the navAgent stuff is also doing

languid spire
tough tartan
leaden pasture
#

Presumably remove the follow script and just keep the nav agent one on the enemy

swift crag
#

you should first figure out what you're actually trying to do here

leaden pasture
#

The enemy follow one

swift crag
#

Does the enemy slide directly towards the player, or does the enemy use the navmesh to navigate towards the player?

#

You probably don't want to be doing both

tough tartan
#

ok ok thank you

#

it worked

#

hes slow as hell which is good

frail wind
#

guy what does this error mean?

NullReferenceException: Object reference not set to an instance of an object
Unity.PlasticSCM.Editor.ViewSwitcher.OnDisable () (at ./Library/PackageCache/com.unity.collab-proxy/Editor/ViewSwitcher.cs:205)
Unity.PlasticSCM.Editor.PlasticWindow.ClosePlastic (Unity.PlasticSCM.Editor.PlasticWindow window) (at ./Library/PackageCache/com.unity.collab-proxy/Editor/PlasticWindow.cs:1096)
Unity.PlasticSCM.Editor.PlasticWindow.OnDisable () (at ./Library/PackageCache/com.unity.collab-proxy/Editor/PlasticWindow.cs:283)
UnityEditor.GenericMenu:CatchMenu(Object, String[], Int32)

swift crag
#

the Version Control package is throwing up again

wintry quarry
wintry quarry
#

You don't fix it. Unity needs to fix it

swift crag
#

are you actually using Unity Version Control?

#

if not, you can remove the package

tough tartan
tough tartan
#

good advice

swift crag
#

but -- as a rule, if the enemies aren't fighting over a shared resource, duplicating them will work just fine

languid spire
swift crag
#

So it would break if you did something ridiculous like this

frail wind
#

the only thing i Rember before this error happen is i spam on the undo history tap

swift crag
#

...actually, I'd have some trouble writing an example

frail wind
#

maybe i'm clicking to much

languid spire
frail wind
#

but i'm trying to undeleted an object

languid spire
frail wind
#

which it doesn't work so spam on it

#

then the error come

languid spire
#

no, wrong, this is NOT a game

frail wind
#

ok i reset the unity now everything fine

swift crag
#

mashing undo should never cause the editor to malfunction. it should behave exactly correctly.

languid spire
queen adder
#

if i use == operator on class with the overload for that operator, which overload is chosen, left hand side or right hand side?

languid spire
swift crag
#

It generally is

#

except when the Version Control package becomes involved, apparently

wintry quarry
languid spire
swift crag
queen adder
wintry quarry
#

well that depends

#

what do the overloads look like

#

which types do they take?

#

and what's the relationship between Foo and Bar? Is there a conversaion operator between them? Is one a derived class of the other?

queen adder
wintry quarry
#

I mean it will pick whichever one it can coerce the types into

#

I assume you didn't define it as:

public static bool operator== (Foo obj1, object obj2)```
#

presumably you did

public static bool operator== (Foo obj1, Foo obj2)```
queen adder
#

maybe it is better for me to just look at the exact rule for it but i haven't found it on google

wintry quarry
#

Basically the question doesn't have enough information

#

we need to see the type definitions in question

#

but it doens't work any differently than any other function in terms of overload resolution afaik

#

same as:

public void MyFunction(Foo f) {}
public void MyFunction(Bar b) {}```
queen adder
#

suppose both of the overload have the same type, which one is selected

wintry quarry
#

it will be a compile error

#

assuming the types are not related

#

if one type is a child of the other then the parent class one will be chosen

hard mist
#

Hey there, i have a question.

I have a public float variable named motor_torgue with value of 20f. I would like to change this value in my game menu (on other scene) via input field method. How can i do that please?

wintry quarry
#

because the parent cannot be coerced into the child automatically

queen adder
#

Uhh nvm i only get more confused instead of getting the answer. I better off reading ecma c# specification

wintry quarry
hard mist
wintry quarry
#
public void OnTorqueFieldChanged(string input) {
  if (float.TryParse(input, out float parsed)) {
    motor_torque = parsed;
  }
}```
For example
swift crag
# queen adder suppose both of the overload have the same type, which one is selected

so, first, at least one parameter of the operator method must be your type. You can't do this:

    public class Foo
    {
        public static bool operator ==(object lhs, object rhs)
        {
            return true;
        }
    }

second, the order of the arguments matters. If you do this:

    public class Bar
    {
        public static bool operator ==(Bar lhs, object rhs)
        {
            return false;
        }
    }

then the compiler will not find it if you do this:

if (foo == bar)

It only knows about an overload that takes a Bar on the left-hand side.

leaden pasture
# hard mist Okay, will try. thanks!

What Praetor said & I would recommend changing the input field settings. Can't remember exactly what it is but you can change what it accepts as input, and you should be able to confine it to only numbers iirc. Should prevent the player trying to input anything that wouldn't parse

swift crag
#

third: the compiler will pick the most specific overload possible. If Bar derives from Foo and both Foo and Bar define an equality operator with themselves on the left side, then this will pick Bar's method:

if (bar == foo)
#

If there is no most specific method, you'll get a compile error

hard mist
azure bridge
#

let m try

burnt vapor
#

Good 😠

swift crag
#

did you bring enough to share with the class

echo copper
#

may i ask you a question?

burnt vapor
#

Assuming it's coding related, of course

echo copper
#

ok, just a habit

#

Well, when my body have 0 degrees z rotation, i give him velocity 75, 0, 0. How to do, if your object have another z rotation (not a 0) it will be given another velocity. As an example: if my object has z rotation = 0, it will get velocity 75, 0, 0, but when it will have x rotation = 90, it will get velocity 0, 75, 0

swift crag
#

are you trying to fire a projectile?

#

you're describing this a bit weirdly

wintry quarry
swift crag
#

yeah, just multiply the rotation with the vector

#
Vector3 rotated = transform.rotation * original;

e.g.

wintry quarry
#
Vector3 localVelocity = new(75, 0, 0);
Vector3 rotatedVelocity = theObject.transform.rotation * localVelocity;```
#

(beat me to it)

#

or the more "formal" way:

Vector3 localVelocity = new(75, 0, 0);
Vector3 rotatedVelocity = theObject.transform.TransformDirection(localVelocity);```
swift crag
#

you'd want TransformDirection

#

zap

wintry quarry
#

🙂

#

(The difference is TransformVector would modify the vector magnitude if the object is scaled)

echo copper
#

ow, okay... im a rookie in unity, sry...

azure bridge
#

@burnt vapor i did the debug thing what am i supposed to check i dont understand

#

in the console it writes score: 1 when i get it

azure bridge
swift crag
swift crag
#

My main concern was how you were asking about a really fussy detail (exact rotation angles) instead of thinking of the bigger picture (shooting a projectile in the direction you're facing)

echo copper
swift crag
#

You can do that too

#

But I do almost no triginometry in my code

#

You've got lots of methods in the Vector3 and Quaternion types

#

Check this out, for example...

leaden pasture
echo copper
#

i tried cos and sin, but it gave me a lot of errors

swift crag
#
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);

Given an entity's look direction, I can recover the pitch and yaw needed to get that exact direction.

I use this when the player takes control of an entity

#

No trig!

echo copper
#

thanks, gonna learn it... it's really nice of you

leaden pasture
# azure bridge this?

Yeah. I'm not entirely sure but with a quick glance, it looks like your text element will be being positioned out of the screen with the current anchors. If you switch it to be the centre of the screen (click the anchor, then alt+shift click the centre one should automatically position it as well), does the updating score text show then?

leaden pasture
#

It may also end up positioned weirdly based on your canvas UI Scale Mode. I tend to set it to Scale with Screen Size, set the reference resolution to whatever my display resolution is, then get it to match height over width

leaden pasture
azure bridge
#

it doesnt disappear but like

#

it goes somewhere to ofar

#

i think

#

mny braincells are disappearing

leaden pasture
#

Ohhh right hmm

azure bridge
#

u can see it in scene (i f i dont anchor it like that)

leaden pasture
#

So it's anchored in the middle with a position of 0,0,0 right? What's your current game view display resolution at?

swift crag
#

so close to fhqwhgads

leaden pasture
#

Oh wait are you trying to get it to show screen space or world space?

swift crag
#

if so, is that Canvas in "Screen Space - Overlay" mode?

azure bridge
#

@leaden pasture i want it to be shown anchored at the camera like if the player moves the score doesnt

burnt vapor
swift crag
#

In that case, the apparent position in the scene does not matter