#πŸ’»β”ƒcode-beginner

1 messages Β· Page 367 of 1

swift crag
#

for example: a spring pulls harder when you stretch it further

void thicket
#

When the size matters. Such as velocity you'd want both size and direction.

dense root
#

Oh I see

void thicket
#

Or position where the direction does not matter.

#

Vector can represent many things

dense root
#

But for player movement, in general we would want to normalize right? Because size is irrelevant?

swift crag
#

the length of the input vector is important

vernal thorn
#

no my code does not do that it jumps too the cursor and when i max out the jump force and the cursor is on Y 0 it jumps lower then when the cursor is at Y 10 at max jump force

swift crag
#

a joystick can be tilted slightly or all the way

void thicket
#

Not in full speed

upper forge
#

can i have controller support without using the new input manager?

swift crag
dense root
#

Thank yo so much for the explanation

swift crag
upper forge
swift crag
#

you have to use Input.GetAxis with the right axis names

#

you want "Vertical" and "Horizontal", I think

vernal thorn
vernal thorn
#

Of the cursor

swift crag
#

the direction of the cursor and towards the cursor

vernal thorn
#

but when it goes the in the direction and has max jumpforce it goes beyond the cursor even when the cursor is beside the player

#

I can show a video of what i mean

swift crag
#

Yes. Show me a video.

upper forge
#

is c# made by microsoft??

swift crag
# vernal thorn

This looks normal. You jump towards the cursor, and the longer you hold the mouse down, the bigger your jump is.

vernal thorn
void thicket
swift crag
#

oh, I think I know what's going on here

#

Vector3 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);

upper forge
swift crag
#

The Z part of this position is probably -10

verbal shard
#

Hello, sorry for interupting here but is there anyone who could help me with my scene colors?

void thicket
swift crag
#

you will have to show us what you're trying

swift crag
#

Set the z part to 0 before you calculate direction

#

That's causing the jumps to be weaker when the mouse is closer

upper forge
swift crag
#

most of the jump is towards the camera (which can't happen)

swift crag
void thicket
upper forge
#

nvm

swift crag
vernal thorn
# swift crag ```cs mousePosition.z = 0; ```

like this? ```void Jump()
{
Vector3 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
mousePosition.z = 0;
Vector2 direction = (mousePosition - transform.position).normalized;
float appliedForce = Mathf.Lerp(minJumpForce, maxJumpForce, Mathf.Clamp01(holdTime / maxHoldTime));
rb.AddForce(direction * appliedForce, ForceMode2D.Impulse);
}

swift crag
#

or you can do mousePosition.z = transform.position.z, in case the player isn't at Z=0

vernal thorn
#

The player is at z=0

#

ok thank you so much

#

It works perfectly

upper forge
#

I want this flame thing to only show when i press W, how could i do this?

rich adder
#

you need a reference to the object first ofc

#

though if its a particle system you can just call play/stop

upper forge
#
using System.Collections.Generic;
using UnityEngine;

public class showFlame : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        gameObject.SetActive(false);
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey(KeyCode.W))
        {
            gameObject.SetActive(true);
        }
    }
}
``` i did this, but it doesnt work, for some reason
tall torrent
#

how can I create a looking around feature for my character

tall torrent
#

Iv already programmed a wasd movement system

tall torrent
upper forge
#

do you want a clamp on it

languid spire
upper forge
#

it just doesnt show at all, assuming because of the Start() function?

compact nymph
#

Does anyone know an easy way to check if all items in a list are active and return something as true if they are?

tall torrent
languid spire
upper forge
upper forge
tall torrent
#

Yeah sure, i can always configure it later.

languid spire
upper forge
rich adder
languid spire
rich adder
#

actually this script wont work at all

#

gameObject is set to Active false, Update doesn't run

rich adder
# upper forge yep mb

first you need a proper reference to the Flame object.. this is disabling the current object script is on

upper forge
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class showFlame : MonoBehaviour
{
    public GameObject flame;
    void Start()
    {
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey(KeyCode.W))
        {
            flame.SetActive(true);
        }
        else
        {
            flame.SetActive(false);
        }
    }
}
#

i've changed it to that

rich adder
#

that should work

#

assuming you assigned flame in the inspector

tall torrent
# upper forge yep mb

also, for some reason my character just floats up into the air, it was working perfectly fine earlier for some reason

upper forge
#

might make it a bt better πŸ€·β€β™‚οΈ

tall torrent
# upper forge provide code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerMovmentScript : MonoBehaviour
{

    public float movementSpeed = 15f;

    void Update()
    {
        if (Input.GetKey("w"))
        {
            transform.Translate(Vector3.forward * movementSpeed * Time.deltaTime);
        }

        if (Input.GetKey("s"))
        {
            transform.Translate(Vector3.back * movementSpeed * Time.deltaTime);
        }

        if (Input.GetKey("a"))
        {
            transform.Translate(Vector3.left * movementSpeed * Time.deltaTime);
        }

        if (Input.GetKey("d"))
        {
            transform.Translate(Vector3.right * movementSpeed * Time.deltaTime);
        }




    }
}
upper forge
rich adder
upper forge
#

the one that is hilighted

rich adder
upper forge
rich adder
# upper forge

so you're putting script on an object that disable itself and u want update to run after ?

polar acorn
# upper forge

So then any time you ever are not holding W, this object disables forever

#

Because it would be disabled, and therefore unable to run update to re-enable itself

rich adder
#

ShowFlame goes on the root object, not the one being disabled

upper forge
rich adder
#

how did you get that out of that

#

lordy

upper forge
rich adder
#

no idea how you got that thought from what digi said

polar acorn
upper forge
#

oop

#

okay

dense root
#

Anyone use Vim/Neovim with Unity as their editor?

void thicket
upper forge
#

i put it onto a empty gameObject and then added the flame onto the Flame object, works now, thanks @rich adder @polar acorn

tall torrent
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerMovmentScript : MonoBehaviour
{

    public float movementSpeed = 15f;

    void Update()
    {
        if (Input.GetKey("w"))
        {
            transform.Translate(Vector3.forward * movementSpeed * Time.deltaTime);
        }

        if (Input.GetKey("s"))
        {
            transform.Translate(Vector3.back * movementSpeed * Time.deltaTime);
        }

        if (Input.GetKey("a"))
        {
            transform.Translate(Vector3.left * movementSpeed * Time.deltaTime);
        }

        if (Input.GetKey("d"))
        {
            transform.Translate(Vector3.right * movementSpeed * Time.deltaTime);
        }




    }
}

for some reason this makes my character object float into the air, any suggestions on why?

rich adder
dense root
tall torrent
swift sedge
#

a Rigidbody wont change anything

rich adder
#

the rigidbody is floating if its not constraint locked, collided with something and has no gravity

rocky canyon
#

weeeee

#

and its more of a question... he said he has a rigidbody.. w/ is helpful b/c hes using translation for movement..

#

not rigidbody forces

hardy vortex
#

hey, I have a question, I'm trying to change multiple gameobjects all having their own textfields from a single gamecontroler gameobject having a single script. how do I go about doing this?

#

how do I reference the gameobject in the inspector, everything I have tried so far is giving me errors

rocky canyon
#

well if he's wanting to change text he might be better to make a list of TMP_Text objects intead

#

to save a bit of trouble of grabbing the component from every object

swift crag
#

you should always try to use the most specific type possible

rocky canyon
#
public TMP_Text[] textObjs;
        
foreach (TMP_Text textObj in textObjs)
{
   textObj.text = "Hello";
}```
hardy vortex
#

Im getting this error?

swift crag
#

your IDE should be suggesting a fix

willow scroll
sullen wraith
#

Hello. I get this error when calling and already instantiated gameobject with obj.getComponent<LineScript>() ;

NullReferenceException: Object reference not set to an instance of an object
LinkManager.UpdateLineAndNodePositions (UnityEngine.GameObject obj1, UnityEngine.GameObject obj2) (at Assets/Scripts/LinkManager.cs:49)
GameManager+<SwapPositions>d__6.MoveNext () (at Assets/Scripts/GameManager.cs:55)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <e8a406da998549af9a2680936c7da25a>:0)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
GameManager:Update() (at Assets/Scripts/GameManager.cs:36)

its a prefab with a script attached to it. See the image below.
I am missing someting ? Help appreciated πŸ™‚

dense root
#

What does locking the inspector window do?

languid spire
brave compass
sullen wraith
languid spire
dense root
tall torrent
dense root
#

While navigating to other inspector windows

sullen wraith
#

unless....

#

jeeez

languid spire
void thicket
sullen wraith
void thicket
sullen wraith
void thicket
#

One of the cursed properties Unity has

sullen wraith
#

fuuuuuuuuu, really?

#

thats kinda dumb

void thicket
#

Beacuse it's actually saved in C++ side and needs to allocate when you use in C# side

sullen wraith
#

i give all my objects GUID, time to read the docs then...

swift sedge
sullen wraith
#

Should i use tags then or can i somehow get a reference that the compiler gives the object?

void thicket
#

GameObject.tag also does the same

#

But you can use GameObject.CompareTag to not allocate

#

Tags suck tho

slender nymph
languid spire
#

or compare instanceID

swift sedge
void thicket
#

Only reason really

sullen wraith
slender nymph
#

if it is in the list already, why do you need to find it in the list

void thicket
#

Are they actually different object with same name? πŸ˜„

sullen wraith
#

i could also just use var link_1 = linkObjectList.Find(obj => obj == obj1); but i like to give my objects IDs

#

πŸ˜„

void thicket
#

If you can do that..

void thicket
#

var link_1 = obj1

sullen wraith
slender nymph
#

instead of shitposting, you should provide an actual response so that your misunderstanding of what is happening can be corrected

swift sedge
#

I'm sure people care about performance more than extra code

dense root
# tall torrent

Hmm I cannot detect what would be causing your player to float

slender nymph
dense root
#

I am trying to transpose these setters and getters however I am running into method must have a return type error. Yet in the original script it works just fine without one. Thoughts on where I went wrong?

latent sedge
#

Where is the best place to learn to read and write C#? It's hard to explain, but i'm not looking to understand what "GetComponent" does, i want to know why "<>" follow it. I understand what all the functions and methods do, i simply don't know when to write parathesis or less than symbols?

rocky canyon
#

and !learn

eternal falconBOT
#

:teacher: Unity Learn β†—

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

dense root
rocky canyon
#

is ur IDE configured?

latent sedge
rocky canyon
#

even if u dont know when to use <> or () etc.. a configured IDE should autocomplete and guide u to correct syntax

void thicket
rocky canyon
dense root
latent sedge
rocky canyon
#

it'll help know when to use what.. but you should still supplement that with learning thru some of the sources i posted

latent sedge
#

I'd like to understand WHY they are there so i can understand when to use them

rocky canyon
#

and in the pinned sections

#

<> is related to Generics

#

its basically allows u to define classes, methods, and wha-not that can operate on any data type

#

<DataType>

#

that way getcomponent can grab a Rigidbody.. or it can grab a Transform.. or w/e

#
public T GetComponent<T>()
{
    // Method implementation
}
``` for example
#

this would be the function ur referencing.. where it can handle any Component type you pass into it

latent sedge
#

GetComponent<SpriteRenderer>().color

this line of code is absolutely baffling me. It uses all 3 syntax methods and i have no idea why they are used seperately of each other. What are the parenthesis used for in this scenario?

GameObject.Find("Player")

This line seems like it would be comparable to GetComponent, but instead of "<>", a "." is used?

rocky canyon
#

ya, its a bit of an explaination.. i could summarize it for you but that wouldn't help you understand it much better

#

the () are there.. b/c the method takes no parameteres..

#

but its part of the syntax and has to be included

languid spire
rocky canyon
#

^ thas a pretty short and sweet explaination

#

when u use GameObject.Find() its a method that returns a gameobject.. u dont need to tell it a type..

#

but the GetComponent can be called on multiple types..

#

it needs to know what to return..

#

so thats why it has the extra <Type>

vernal thorn
latent sedge
# rocky canyon so thats why it has the extra <Type>

Ohhhhhhhhh! Okay! So <> is used to specify a certain part of something. This isn't always necessary like in the case of "GameObject.Find()" because GameObject is specific enough that it doesn't need further clarification?

rocky canyon
#

ya Find() is a function within the GameObject class..

#

it knows to return a GameObject

rocky canyon
#

but GetComponent could be anything

latent sedge
#

And GetComponent could refer to any number of components

#

I see!

rocky canyon
#

soo u need to pass in a type for it to change its return type

#

dont want GetComponent<Rigidbody> returning a Box Collider for no reason

#

when i was learning the . was the best thing i learned about..

summer stump
rocky canyon
#

ohh i want to access a property of a component.. its component.thingyIwant

#

a lot of stuff in Unity i still chaulk up to being "magic"

#

all i needs to know is how to execute that magic

latent sedge
#

I suppose im still a little confused why "<>" are used instead of "." since in my experience "." is simply used to specify further... But now at least i know when at least one is needed.

Why wouldn't GetComponent.Rigidbody work?

swift sedge
# dense root I am trying to transpose these setters and getters however I am running into met...

It's called a constructor. Every class has an optional constructor and destructor which is a special method that has no return type and gets called when the class gets instantiated... and deleted, which is done automatically. The original class is fine because that is the constructor of the class, however, the other "constructor" is not fine because the class is not named "Move", which is where the compiler thinks that it should be a "normal" method, and thus must have a return type.

This is the beauty of statically typed languages :)

rocky canyon
summer stump
rocky canyon
#

If you wrote GetComponent.Rigidbody, it would imply that GetComponent has a member named Rigidbody, which is not the case. Instead, GetComponent<T>() uses generics to specify the type you want to retrieve. . .

rocky canyon
#

honestly a good question for a beginner.. its more thought out than lots of hte questions i come across lol

swift sedge
summer stump
#

Agreed. This is a good thing to be asking

rocky canyon
#

intellisense and autocomplete ruined me

#

it just works Β―_(ツ)_/Β―

summer stump
#

Inb4 steve says it ruins everyone

swift sedge
#

i swear visual studio is magic

rocky canyon
#

i use VSCode now..

#

w/ AI extensions

#

its terrIble now.. i can type a class name and a few variables.. and boom

#

it wants to fill in my entire script

languid spire
rocky canyon
#

i did my time in notepad before css was even a thing

#

i deserve the relaxation!

languid spire
#

true. but you first pay the dues, then you get the benefit

latent sedge
#

I think i understand

#

Thank you :)

rocky canyon
#

sometimes u cant force it.. just expose urself to it.. and it'll click eventually

latent sedge
#

Would you guys reccomend AI integration and stuff for a beginner?

rocky canyon
#

absoultely not

latent sedge
#

Ah fiddlesticks

rocky canyon
#

as a beginner u can't point out errors... or even find when it goes off track

#

before u know it u have spaghetti that no one wants to touch

latent sedge
#

Well im learning to code for funsies, idk if anyone will ever see my code but me

summer stump
rocky canyon
#

once u start learning how to code im not anti-ai

#

its super helpful for some things... like refactoring code..

latent sedge
#

But if its making errors then i could see how that may be an issue

rocky canyon
#

or writting long boring boilerplate

rocky canyon
#

very often

#

even has a disclaimer w/ most of em lmao

#

just use ur own discretion

latent sedge
#

Yeah thank you for listening to me btw! I usually use ChatGPT but this question was too confusing and difficult to word for an AI to understand what i was asking

rocky canyon
#

plus chatgpt is a yes man..

#

i hate that.. lol

latent sedge
#

Thats how you get terminator'd

summer stump
#

That's a good point. The benefit of asking here is people will tell you that what you want to do is dumb and suggest a better way

ionic plank
#

!code

eternal falconBOT
summer stump
latent sedge
#

Welp im off to make more horrendous sloppy code that is slightly less horrible and sloppy than last time! See ya!

upper forge
#

what game should i make???

#

note: i only started with unity and c# a week ago

rich adder
#

lol

#

saw that

dense root
#

What did I do wrong? How come it's missing a referencee?

rich adder
#

oh its back.

#

well do you have a type named ElementType

dense root
#

I think so, yeah

rich adder
#

where did you define it ?

dense root
#

I thought it was defined in my base

rich adder
#

according to your IDE it doesn't exist, unless you are missing the namespace if you used those or another assembly?

dense root
#

I don't know how to use another assembly so that might not be it

summer stump
languid spire
#

just show where you define a type ElementType

rich adder
#

You then never made the ElementType πŸ€·β€β™‚οΈ

dense root
#

What do I need to do in order to change what game objects are selectable here? Right now it is able to select the undesired moves

[System.Serializable]
public class LearnableHiraganaMove
{
    [SerializeField] HiraganaMoveBase hiraganaMoveBase;

    public HiraganaMoveBase Base
    {
        get { return hiraganaMoveBase; }
    }
}
deft grail
#

but in the HiraganaMoveBase class

dense root
#

This is the base class

slender nymph
#

your list is a List<LearnableMove> which is, notably, not a list of LearnableHiraganaMove

#

those classes aren't even related

rocky basalt
#

Having a strange problem, Dictionary.ContainsKey is not working I think.
I have a Dictionary of crafting recipes defined like so:

static readonly Dictionary<ItemType[], ItemType[]> craftingRecipes = new Dictionary<ItemType[], ItemType[]>
{
    {new ItemType[3]{ItemType.Rope, ItemType.Stone, ItemType.Stick}, new ItemType[1]{ItemType.Axe}}
};```
And later code to check if a provided recipe exists
```cs
void CraftRecipe(CraftingQuery craftingQuery)
{
    Debug.Log("breakpoint");
    if (craftingRecipes.ContainsKey(craftingQuery.recipe))
    {```
And I'm *sure* that the recipe I'm providing exists in the dictionary, as shown in the pictures, but the if statement is returning false.
slender nymph
#

you're using an array as the key. it's not checking the contents of the array, it is checking the reference. so when you check if it contains the key and you pass a different array object that just happens to have the same elements, it is going to return false because it is not the same array object

rocky basalt
#

Ohhhh

#

Any ideas for a workaround?

#

Maybe tuples?

slender nymph
#

create a struct that holds a list of ItemType, and override GetHashCode on that struct to combine the hashes of the list elements or something πŸ€·β€β™‚οΈ

rocky basalt
#

Hmm okay, I'll see what I can do. Thanks 🫑

vast ivy
#

can someone help me reference this child image named "Crosshair" under the canvas "defaultCanvas"?

I tried to put in a variable but I think something is wrong: public GameObject crosshair = defaultCanvas.transform.Find("Crosshair").gameObject;

error: error CS0236: A field initializer cannot reference the non-static field, method, or property 'MyFirstPersonController.defaultCanvas'

deft grail
#

you cant do it where you actually make the variable

#

also if you can, just drag it in the inspector

slender nymph
#

assigning it via the inspector is the best option

vast ivy
#

ok so I just assign it as a gameobject in the inspector then I can set it to active or whatever

vast ivy
#

alright thxs

final kestrel
#

Can you serialize scriptable objects to store them as json?

dense root
#

Shoot where did I go wrong here?

deft grail
slender nymph
#

i'm guessing that HiraganaMoveBase does not inherit from MoveBase despite the name implying that it does

#

just like how LearnableHiraganaMove did not inherit from LearnableMove

dense root
#

Hmm let me do some digging

#
[System.Serializable]
public class LearnableHiraganaMove
{
    [SerializeField] HiraganaMoveBase hiraganaMoveBase;
    [SerializeField] int level;

    public HiraganaMoveBase Base
    {
        get { return hiraganaMoveBase; }
    }

    public int Level
    {
        get { return level; }
    }
}

Did I declare something wrong in this HiraganaBase script?

slender nymph
#

this is not the HiraganaMoveBase class, nor is it the HiraganaMove class

dense root
#

Here's my HiraganaMove class

public class HiraganaMove
{
    public MoveBase Base { get; set; }
    public int PP { get; set; }

    public HiraganaMove(MoveBase pBase)
    {
        Base = pBase;
        PP = pBase.PP;
    }
}
#

Sorry I'm new to constructors so I really appreciate this

slender nymph
#

notice how your constructor expects a MoveBase parameter

dense root
#

Omg thank you so much

slender nymph
#

you really need to start reading your own code

flint python
#

Hello, I have a function, used in different script of different game objects, but I don't want to copy past this function to every script, is it a good idea to create a static class, i.e static public class Functions, and call the function Functions.MyFunction() in any script? Don’t want to use gameobject.find

Or there is alternative way to do this in unity?

rich adder
#

you can't use any other fields in that function unless the fields are also static, its get messy

#

another option is to use a static instance of a regular MB instead , to access its methods easily those are best suited for like game managers and alike though

wintry quarry
flint python
#

for example this function, i ll call the function Functions.FindAvailableGameObjectFromList() in any other script if I needed, and is there an alternative way to do this, without using static and gameObject.find().getcomponent.FindAvailableGameObjectFromList()?

rich adder
#

FindObjectsOfType etc.

flint python
#

currently static is giving me issue, when two scripts calling the function at about the same time, it messes up the value

narrow escarp
#

@rich adder hey can u help me with smtng

narrow escarp
#

i'm having a problem with a 2D AIM

#

system

rich adder
#

what about it?

#

also next time don't @ someone not in active convo / helping

narrow escarp
narrow escarp
rich adder
#

well I know nothing of your setup , I can't possibly know what it is

narrow escarp
#

can i stream f y

rich adder
#

You can record a video if you want

#

and share relevant !code

eternal falconBOT
narrow escarp
rich adder
#

start with the code and some screenshots

flint python
# rich adder huh mess up the value how ?

in the ChangeAnimationState() function, I swap animation state using .Play(), between enemyActive and enemyDied, from the console, you can see a hash that is not belong to enemyActive nor enemyDied

flint python
rich adder
#

@flint python why do you even need that static function in the first place, I don't even know why

#

!code

eternal falconBOT
narrow escarp
flint python
rich adder
#

this smells like an XY issue

rich adder
narrow escarp
rich adder
#

o haven't used the 2D ik package yet

#

is your right hand target not paranted to the gun ?

narrow escarp
#

i put the gun inside the Rbicep

rich adder
#

have to show the video or I can't tell whats even happening instead

narrow escarp
#

wait i'll make avideo

#

the left arm ain't reaching the gun position

#

and the flickering thing

#

i created a new animator layer

#

with shooting animation

#

holding the gun

#

and in the script i switch the weight to 1 when i aim

rich adder
#

which one controls the chest IK. I have to brushen up on 2D IK since I've only done the 3D one

narrow escarp
#

what u mean by which one controls

#

the chest ik

narrow escarp
rich adder
narrow escarp
#

so what i'm gonna do

#

the bones r aiming towards the cursor actually

#

this is the aim animation

rich adder
#

yeah you probably dont want to aim alll thse bones though

narrow escarp
#

there's any way to rotate the arms

rich adder
#

you need a root bone that rotates multiple bones

#

Ie both arms inside 1 common parent and rotate that

narrow escarp
#

like that

rich adder
#

yeah but you probably just want to do the spine2 bone

narrow escarp
dusty ember
#

If art school says nein, then the world is mein

rich adder
narrow escarp
#

when i rotate the chest

#

everything glitch out

rich adder
#

Ill try to see how 2D IK work and report back

narrow escarp
#

thank y

grizzled fulcrum
#

So my player has a script that allows him to pick up specific objects by holding E, but I think it's making trouble with other scripts, and preventing them from working. I have another script that is as simple as "If this object overlaps with another of a specific tag, an inactive object is enabled", and it doesn't work when the two are clearly overlapped. Can anyone spot anything here that might be the prob?

The code for the box mechanic is this one
https://gdl.space/xuxowurige.cs

And here's the simple one that's just for the empty box detection

using UnityEngine;

public class PortaPainelSolar : MonoBehaviour
{
    public GameObject objectToActivate;

    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.CompareTag("LuzSolar"))
        {
            if (objectToActivate != null)
            {
                objectToActivate.SetActive(true);
            }
        }
    }
}
#

I tried dding debug logs to find out the issue, and for some reason he is not detecting when it collides with the other object with the specific tag

#

Could it perhaps be an issue with how he picks up the box?

valid roost
#

Hiya, basically I have implemented a script that made sure, whenever my player touched the wall while jumping, my player wouldn't get stuck to the wall instead the falling animation would commence and the player would cease any movement until i moved in the opposite direction but after i implemented it and started the program again my character just gets stuck in one spot.

Here is my script

queen adder
#

is there a way i can access an object from code just code no assigning through a variable?

queen adder
#

ima be honest

#

i asked chatgpt and it worked

#

thanks anyway though

void thicket
#

What did GPT say

queen adder
#

i asked it the same question

#

and it gave me find gameobject options

#

sorta like you did

#

in this case i did by type

#

which was an audio source

void thicket
#

Yeah those are not the best performance but if you don't want inspector there are not much options

queen adder
#

well i was trying to assign it to a prefab

#

but while it was a prefab

#

it said the type was wrong'

#

but when i inserted the prefab and manually assigned it it worked

void thicket
#

Hm probably something was wrong in the process

#

Well it works then it works

queen adder
#

now i can hear a clunk sound with all of my bread πŸ™‚

shy ruin
#

The LoadData method gets called when scene starts, and then it calls the DelayedPositionChange method. This waits a bit and then sets the position of the player and rotation of the camera. For some reason, the rotation of the camera will not be set. I printed out the rotation in the data object and it was correct, but it seems the rotation of the camera holder cannot be set at start! Why is this?

rich adder
void thicket
shy ruin
#

I've just fixed it myself, sorry. I had a variable as a Vector2 that was 2 floats that stored the rotations in floats, just had to change it to a vector 2 in my save class.

#

It was being overridden.

rich adder
#

ur saving the euler angles ?

#

cause rotation is a quaternion

shy ruin
#

I have a Vector2 called, camera rotation, it stores the X and Y rotation of the camera.

#

I don't need the Z

#

When you move your mouse it does cameraRotatio.X + mouseX value

#

So, it started off at 0,0 and I had to just change it

rich adder
#

im hella confused

#

you're saving quaternions

shy ruin
#

No

#

Not anymore

rich adder
#

oh ok

dense root
#

Has anyone tinkered with GitHub Copilot with Unity scripting? Any thoughts on it?

rich adder
#

its alright from what I saw, nothing impressive other than simple autocomplete

dense root
#

I see I see

shy ruin
#

Not worth it, I've tried.

stuck palm
#

is there an early update?

#

theres a late one

rich adder
#

not really

#

idk what you're trying to accomplish with a "pre/early update"

void thicket
#

This frame's late update is next frame's early update πŸ˜„

stuck palm
void thicket
#

There is a hidden attribute too

#

DefaultExecutionOrderAttribute

stuck palm
#

what are the benefits between using a hashset and a list?

solid rampart
#

Is there a way to make a dictionary that is accessible by all objects without needing to be created on an object?
I think that it would have something to do with classes, but I'm not really sure. Any help would be appreciated.

void thicket
stuck palm
#

i see

#

u cant serialise a hashset though, annoyingly

rich adder
#

nope

summer stump
void thicket
#

Can't Unity-serialize ℒ️

stuck palm
rich adder
#

always wondered, why can't decimals be serialized in the inspector

stuck palm
#

but i've had severe perforamnce issues with that installed

stuck palm
#

i dont use them but

void thicket
summer stump
rich adder
solid rampart
void thicket
solid rampart
rich adder
#

put it on a scriptable object πŸ™‚

void thicket
#

Noooooo

solid rampart
rich adder
#

if it was a list I'd say do so, but cant even serialize dictionary anyway so keep it static

void thicket
solid rampart
void thicket
#

I see then I think static should be fine, you might need to handle cleanup tho

rich adder
#

if you're like me and also use domain reload off be careful
all the sudden your dictionary has thousands of entries xD

solid rampart
#

Alright, sounds good, I'm just researching static variables right now, since I very seldom use them, but thanks for the help.

shy ruin
#

How do I stop a memory leak (if that is what it is), I accidently started an infinite loop and now even when the game isn't running I'm getting errors!

zenith cypress
#

Restart the editor

shy ruin
#

I've already fixed the code but it is still leaking something.

#

Thanks

tacit pumice
#

Does anyone have a site/app that will help me understand and know how to use c#

vast ivy
dim wharf
#

how do I disable those gray text suggestions?

#

Tried googling but idk what they're called in the first place

vast ivy
#

like learning how to do lists or dicts?

vast ivy
#

can i ask why u think so? not saying ur wrong just curious

summer stump
vast ivy
#

Yea I guess thats fair, its important you know how to read through the docs

summer stump
#

Plus people generally end up watching brackeys or code moneky or someone else that has a good personality and gets monitized but is not great

dense root
#

How come my Hiragana bar isn't populating?

public class HiraganaBattleHud : MonoBehaviour
{
    [SerializeField] Text hiraganaNameText;
    [SerializeField] Text hiraganaLevelText;
    [SerializeField] HiraganaHPBar hiraganaHpBar;

    public void SetData(Hiragana hiragana)
    {
        hiraganaNameText.text = hiragana.HiraganaBase.Name;
        hiraganaLevelText.text = "Lvl" + hiragana.Level;
        hiraganaHpBar.SetHP((float)hiragana.HP / hiragana.MaxHp);
    }
}
rich adder
tacit pumice
#

Just my luck?

dim wharf
#

oh vscode but thanks

rich adder
dim wharf
#

ohhh intellicode

rich adder
#

disable the extension

dim wharf
#

cause intellisense would clear other things I use as well

rich adder
#

intellisense is more like the star on variables or your most likely to use method/field from class you referenced

tacit pumice
dim wharf
#

never knew it was AI

#

so thats why it spits out nonsense 60% of the time

rich adder
#

yeah it was broken on VSCode for a while

#

the one on Visual Studio is far superior

#

but at the end of the day is just fancy "autocomplete"

summer stump
dim wharf
#

it really is

rich adder
#

like the one on their site, microsoft has one too or Dotnet fiddle

vast ivy
#

I have 2 different canvas' here and Im sure theres a better way to do this. Currently I have "Default" canvas which holds crosshair, 3 sliders, and hotbar. On the "Inventory" canvas it holds a copy of the 3 sliders, copy of hotbar, inventory slots, avatar holder, and armor slots. Just copying these elements into the other canvas makes me put multiple copied lines which do basically the same thing because I have to then update the slider values and text values on both canvas'. Would it be better to put them both on 1 canvas and toggle the gray background along with the other elements? I made 2 canvas' because I only needed the background on the inventory one

#

This works fine but I feel like I prob shouldnt have just copied the elements over and copied some lines of code to make sure both were updated

#

might bring up problems when I actually implement inventory because I would then be writing 2x the code

#

actually yea I figured out a better way I think

timber tide
#

you'd write the same amount of code no matter the amount of canvas

#

do you want two or one is up to you

vast ivy
#

I just remade it, Ill show u the code I had vs what I have now..

// AFTER CHANGE
    public Slider healthSlider;
    public Slider chargeSlider;
    public Slider usabilitySlider;

    public TMP_Text chargeText;

// BEFORE CHANGE
    public Slider healthSlider;
    public Slider invHealthSlider;
    public Slider chargeSlider;
    public Slider invChargeSlider;
    public Slider usabilitySlider;
    public Slider invUsabilitySlider;

    public TMP_Text chargeText;
    public TMP_Text invChargeText;

I moved the components of the 2 views together onto 1 canvas and just set the inventory to toggle and made sure the background was in the right position

#

this was just the variables but I had more lines where I was changing the same thing just on 2 different canvas'

tacit pumice
fringe plover
#

Idk if its unity bug or not, but when i try to instantiate something null, it creates infinity ammount of objects from other list in script and soft locks editor

#

I cant even look in Console what causes this

#

And i have to stop editor trough task manager

teal viper
fringe plover
teal viper
#

Yes.
!debugger

#

Damn, there's no command for that

fringe plover
#

nvm i found what was glitching

twilit sundial
#
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class LogicScript : MonoBehaviour
{
    public int playerScore;
    public Text scoreText;
    public GameObject GameOver;

    [ContextMenu("Increase Score")]
    public void addScore(int scoreToAdd)
    {
        playerScore += scoreToAdd;
        scoreText.text = playerScore.ToString();
    }

    public void restartGame()
    {
        SceneManager.LoadScene(SceneManager.GetActiveScene().name);
    }
    public void gameOver()
    {
        GameOver.SetActive(true);
    }
}

how do i disable a function after another function happened in a different script

summer stump
dense root
#

Where did I go wrong? I'm getting an object not sent to an instance of an object error yet I set the values in the inspector as intended

public class HiraganaBattleHud : MonoBehaviour
{
    [SerializeField] Text hiraganaNameText;
    [SerializeField] Text hiraganaLevelText;
    [SerializeField] HiraganaHPBar hiraganaHPBar;

    public void HiraganaSetData(Hiragana hiragana)
    {
        hiraganaNameText.text = hiragana.HiraganaBase.Name;
        hiraganaLevelText.text = "Lvl" + hiragana.Level;
        hiraganaHPBar.SetHP((float)hiragana.HP / hiragana.MaxHp);
    }
}
void thicket
#

Or you are referencing wrong object

dense root
#

Double checked but I'm not sure that's it

gaunt ice
#

check if there is some duplicate instances of that script

viral shadow
#

hello, i've come back for yet another question

#

im trying to change the outline of TMP through code, anyone knows how to do that?

#

particularly the color

dense root
twilit sundial
dense root
eternal falconBOT
dense root
#

Oh

twilit sundial
#

ah thanks

dense root
#

Tagging it. c#

twilit sundial
#

oh

#

yh lol

ivory bobcat
dense root
#

Block with three ` and then c# added to it

twilit sundial
#

yh

dense root
twilit sundial
#

wait how am i tagging

#

cs


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

public class pipeMiddle : MonoBehaviour
{
    public LogicScript logic; 
    // Start is called before the first frame update
    void Start()
    {
        logic = GameObject.FindGameObjectWithTag("Logic").GetComponent<LogicScript>();
    }
    // Update is called once per frame
    void Update()
    {
        
    }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.layer == 3)
        {
            logic.addScore(1);
        }
    }
}
#

yea tagging not going too well

ivory bobcat
twilit sundial
#

how though

dense root
#

Learn something new everyday

twilit sundial
#

omfg

#

yea learn nothing new everyday thanks

eternal falconBOT
twilit sundial
#

c# love life

ivory bobcat
#

That would be configuring your ide. !code would be how to properly post code on discord.

rich adder
#

cs not c#

eternal falconBOT
twilit sundial
#

i did that bruh

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

public class pipeMiddle : MonoBehaviour
{
    public LogicScript logic; 
    // Start is called before the first frame update
    void Start()
    {
        logic = GameObject.FindGameObjectWithTag("Logic").GetComponent<LogicScript>();
    }
    // Update is called once per frame
    void Update()
    {
        
    }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.layer == 3)
        {
            logic.addScore(1);
        }
    }
}
#

nvm

#

what

#

i cant type there

#

it blocked me from saying there

summer stump
# twilit sundial

No need to comment about it or post an ss. Kinda defeats the purpose

twilit sundial
#

what purpose

ivory bobcat
#

Spam block - excessive short sentences as a pattern (in this case, a single word)

twilit sundial
#

oh

summer stump
twilit sundial
#

well its kinda nessasary if you didnt know what i meant

#

oh well

#

huhuhuhuhuhhuh

twilit sundial
ivory bobcat
twilit sundial
#

i didid ididi

#

ok

#

ahhhuajdfhwefh

#

it blocked it again

summer stump
ivory bobcat
#

What in particular are you trying to disable? What's occurring in the other script?

summer stump
#

Just set it false, and if it is false, don't run the function

Hard to say more with that little detail

twilit sundial
#

ok but

#

hold on

#

tryna disable point script for a object thingy

#

trigger

#

i made a logic function

#

no

#

script

#

and its got the functions in

#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class LogicScript : MonoBehaviour
{
    public int playerScore;
    public Text scoreText;
    public GameObject GameOver;

    [ContextMenu("Increase Score")]
    public void addScore(int scoreToAdd)
    {
        playerScore += scoreToAdd;
        scoreText.text = playerScore.ToString();
    }

    public void restartGame()
    {
        SceneManager.LoadScene(SceneManager.GetActiveScene().name);
    }
    public void gameOver()
    {
        GameOver.SetActive(true);
    }
}
#

and the player script in the other

#

hold on

#

and a trigger script

#

using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using UnityEditor;
using UnityEngine;

public class birdScript : MonoBehaviour
{
    public Rigidbody2D myRigidbody;
    public float flapStrength;
    public LogicScript logic;
    public bool birdIsAlive = true;
    public double deadzonelow = -8.36;
    public double deadzonehigh = 8.36;
    // Start is called before the first frame update
    void Start()
    {
        logic = GameObject.FindGameObjectWithTag("Logic").GetComponent<LogicScript>();
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space) && birdIsAlive)
        {
            myRigidbody.velocity = Vector2.up * flapStrength;
        }

        if (transform.position.y < deadzonelow) 
        {
            logic.gameOver();
            birdIsAlive = false;
        }

        if (transform.position.y > deadzonehigh)
        {
            logic.gameOver();
            birdIsAlive = false;
        }
    }
    private void OnCollisionEnter2D(Collision2D collision)
    {
       
        logic.gameOver();
        birdIsAlive = false;
    }


}
#

but thats the player one ofc

rich adder
#

this exactly why that bot exists btw
(You can like have a thought before hitting enter)

summer stump
#

Just clearly state what you want, preferably in one message

#

Is it when the game ends you want to stop adding to the score?

twilit sundial
#

correct!

#

mate im so new

summer stump
#

if (gameOver) return;

twilit sundial
#

its impossible to word this

#

in what script

summer stump
#

In gameOver() set gameOver to true

viral shadow
summer stump
twilit sundial
#

of course!

viral shadow
#
mainMenuTitle.color = Color.HSVToRGB(bgCamPartyHue % 1, pulseColor * 10, 1f);
mainMenuTitle.outlineColor = Color.HSVToRGB(bgCamPartyHue % 1, pulseColor * 10, 0.45f);
#

I know pulseColor is working because the color of the text is changing

#

but the outline doesn't

#

i honestly don't know what im doing wrong

twilit sundial
#

in where i put it

#

oh i get it

#

wait so it ends that function

#

Holy MOLY!

#

t riffic

drifting onyx
#

can anyone help me with making hipfire sway system just like Insurgency Sandstorm?

charred spoke
#

That is a very broad question. To get help you would need to start things off and ask about specific problems

drifting onyx
viral shadow
charred spoke
drifting onyx
#

like insurgency sandstorm

charred spoke
#

Please read what I wrote again πŸ˜ƒ

drifting onyx
#

but I didnt found any

eternal needle
charred spoke
#

Read it just one more time please

drifting onyx
#

maybe I am not understanding because its 10 AM and I didnt sleep

charred spoke
#

Then get some sleep. A rested brain is the first thing you need to program

frank zodiac
#

what does get; private set; do?

gaunt cosmos
bright violet
#

I'm having kind of a weird tricky problem:

I'm trying to set up a character controller + third person camera, the camera is a child of the playerGO and is a cinemachine camera with Look At and Follow set to an empty sitting on my playerGO , that rotates according to player input. My inspiration for this camera setup is something like what Genshin Impact got, where the camera doesn't rotate based on where the player faces, but the rotation axis of the player changes based on camera direction. I got the latter working, but i can't get the player to look at any direction cause then the camera changes rotation too. I can't have the camera as a separate object cause I'm on netcode and it would be an hassle to do so. Any ideas?

vernal thorn
languid spire
#

Maybe add a grounded check and kill the velocity when it's true

vernal thorn
#

ok thanks πŸ€

willow scroll
static cedar
vernal thorn
willow scroll
#

When you just, update a boolean isJumping.

languid spire
willow scroll
vagrant zealot
#

hey! i have 2 different scenes, but i want to protect my character's stats, also things like the health bar and coin count. How can i achieve that between my scenes ?

languid spire
vagrant zealot
#

resetting my character's coin count and resetting health is not an issue, it wont be problem but i always want to see the health bar and the coin ui

vagrant zealot
languid spire
vagrant zealot
#

thanks

languid spire
#

Does not look' glitchy' to me. Define 'glitchy'

vernal thorn
#

i mean that the player jumps a bit high instantly when hitting edges

languid spire
#

I see it now, that is an artifact of the physics system. Again you can cure that by killing velocity oncollision enter

vernal thorn
languid spire
#

may be better to set a flag and do that in FixedUpdate

vernal thorn
#

ok

languid spire
#

your other option is to use the physics materials and set bounciness to none if, that is a general behaviour you want

vernal thorn
languid spire
eternal falconBOT
vernal thorn
languid spire
upper forge
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using static UnityEngine.EventSystems.EventTrigger;

public class Movement : MonoBehaviour
{
    public float moveSpeed = 5f;
    public float rotationSpeed = 5f;
    void Update()
    {
        if (Input.GetKey(KeyCode.W))
        {
            transform.Translate(Vector3.down * Time.deltaTime * moveSpeed); 
        }
        if (Input.GetKey(KeyCode.A))
        {
            transform.Translate(Vector3.right * Time.deltaTime * moveSpeed);
        }
        if (Input.GetKey(KeyCode.S))
        {
            transform.Translate(Vector3.up * Time.deltaTime * moveSpeed);
        }
        if (Input.GetKey(KeyCode.D))
        {
            transform.Translate(Vector3.up * Time.deltaTime * moveSpeed);
        }
        Vector3 mousePosition = Input.mousePosition;
        mousePosition = Camera.main.ScreenToWorldPoint(new Vector3(mousePosition.x, mousePosition.y, Camera.main.transform.position.z));
        Vector2 direction = new Vector2(
            mousePosition.x - transform.position.x,
            mousePosition.y - transform.position.y
        );
        float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
        Quaternion rotation = Quaternion.AngleAxis(angle - 90, Vector3.forward);
        transform.rotation = Quaternion.Slerp(transform.rotation, rotation, rotationSpeed * Time.deltaTime);
    }
}```
i have a movement code and the rotate to where the mouse position is code, but the movement gets affected when i move around my mouse, i want it so if my spaceship is looking to the left and i press W, i still want it to go up instead of it going left, how could i do this?
languid spire
#

also !code

eternal falconBOT
upper forge
bright violet
#

Is there a way to not make a child object inherit the parent's rotation?

languid spire
verbal dome
#

Thats a bit unusual though

bright violet
# languid spire dont make it a child

..yes, but having it a child would make my life so much easier. I have a per player camera in my (networked) game, and having it spawn along with my characters would make my life so much easier

languid spire
bright violet
upper forge
#

negative?

languid spire
#

yes

upper forge
#

whats the difference between them?

languid spire
verbal dome
#

Execution order matters here. Nothing else should rotate the parent after you update the child rotation each frame

bright violet
languid spire
#

so move the rotate logic to Child 1 as per my example

bright violet
# verbal dome How are you doing it

my aimPoint 's rotation is updating from player input in update, and aimPoint's parent object (the player object) rotates it's transform based on WASD so aimPoint's rotation ends up switching from the player input rotation to the one overlapped by the parent's rotation

bright violet
bright violet
#

tysm

stuck crest
#

hello guys

#

i have a small problem

#

i cant refer to my script (which is in assets) but i can refer to a prefab, is this intentional or am i doing something wrong

obsidian parcel
teal viper
stuck crest
#

oh wait i forgot to say

solar arrow
#
gameplayMusic.loop = false;
gameplayMusic.playOnAwake = false;```

is there a way to simplified this code?
teal viper
teal viper
stuck crest
teal viper
# stuck crest

This is a script asset. Not an instance of the script. You can't reference it.

stuck crest
#

it is attached to the prefab

teal viper
#

Take a screenshot of the prefab.

storm pine
solar arrow
stuck crest
teal viper
teal viper
#

If it's an object in the scene, you can't reference it from outside the scene.

stuck crest
teal viper
# stuck crest

Ok, close the prefab edit mode and try to assign that prefab to the serialized field.

stuck crest
#

ok

#

it works what

#

tysm

#

i was using the + symbol to refer

teal viper
#

I don't know what you were doing, but probably something wrong.

teal viper
stuck crest
teal viper
#

Aah. I see. Don't know why that wouldn't work if you selected the correct object.

solar arrow
teal viper
teal viper
#

In C# functions and methods are basically the same thing.

#

Method is the official terminology though

solar arrow
#

hm alright

#

thanks for the help

queen adder
#

did unity c# syntax changed so big that tutorials made 10 years ago wont work?

queen adder
ocean wren
#

my game runs in the editor but not in the build, can anyone help?

#

the UI gameObjects doesn't appear

languid spire
primal lintel
#

Does anyone know why when I give it a build and run in the game it's a different speed and in the scene it's different from what it is

wintry quarry
#

You would have to share your code for us to get into more detail than that

queen adder
#

Yo.
I have a small problem with code for animation/moving character

This code looks serviceable, but Unity gives an error

NullReferenceException: Object reference not set to an instance of an object

And character can move, but without animation

languid spire
queen adder
languid spire
wintry quarry
#

yep wrong script entirely @queen adder

languid spire
#

nobody actually bothers reading the error messages. It really pisses me off

ocean wren
languid spire
# ocean wren how do i do that?

you make a development build by selecting that option in the build settings. you read the player log by looking at !logs the docs

eternal falconBOT
#
πŸ“ Logs

Documentation

Editor logs

Windows: %LOCALAPPDATA%\Unity\Editor\Editor.log
MacOS: ~/Library/Logs/Unity/Editor.log
Linux: ~/.config/unity3d/Editor.log

Unity Hub

Windows: %UserProfile%\AppData\Roaming\UnityHub\logs
Mac: ~/Library/Application support/UnityHub/logs
Linux: ~/.config/UnityHub/logs

queen adder
#

Now there's no error. But animations still don't work.

queen adder
#

Sorry.

primal lintel
#

@queen adder acc

zinc jewel
#

i am stuck when i try launch ms vs with a component in unity i am greeted w normal vs instead of ms vs what do i do thanks

slender nymph
#

Wdym by "normal vs" and "ms vs"? Visual studio is made by Microsoft

wintry quarry
languid spire
#

I think he means VS Code. He needs to regenerate project files

zinc jewel
#

im so confused im rlly new to game dev

#

i can ss

languid spire
#

yes, screenshot External Tools window from Unity

swift crag
#

that will help us to know what you're talking about

zinc jewel
#

is this what u want or sm else?

languid spire
#

does that even look like it may be the 'External Tools Window' ?

zinc jewel
#

idk

#

tell me

languid spire
#

Edit->Preferences->External Tools might be a good place to start

zinc jewel
#

this it?

languid spire
#

Does it say 'External Tools' ?

zinc jewel
#

yh

#

what now

languid spire
#

then it is isn't it

#

change VS Code to VS. Press Regenerate Project Files

zinc jewel
#

so should i select the other one

languid spire
#

omg. Did I not just say that?

wintry quarry
zinc jewel
lime leaf
#

How do I link my VSCode to my Unity?

languid spire
#

!IDE

eternal falconBOT
coral void
#

Quick question. If I want to do things as in "systemic design", can I put for example main thing and label it as fire and then refer to it when I use it in projectile for example? Like I have "big" mechanics separate and just refer to them in smaller things?

swift crag
#

i don't understand your question

#

it kind of sounds like you're describing object oriented programming as a whole

rocky canyon
#

like a master class? full of variables or structs that u can reference later?

coral void
teal viper
#

Sounds like the definition of encapsulation

#

And abstraction I guess

coral void
#

So the easiest thing explanation I can think of would be it.

We have 3 main structures that have X, Y, Z under them like when you label enemy as a enemy in game.
For example we have enemy. I put label on him that he is enemy, player can damage him etc, but I also want to label him Fire.
When I label him Fire I want to everything that is under Water (other enemies, player attacks or environment) to make something happen when it came to contact with objects with label Fire (whatever I put as reaction between Water and Fire).

The question is would such "label system" work?

swift crag
#

I'd call these "traits". It's a decent strategy for creating complex behaviors

coral void
#

Are the other ways to creating such things?

eternal whale
#

i just created a script why does this happend?

languid spire
eternal whale
#

ohh ty, for some reason the script was duplicated

inland canopy
#

!collab

eternal falconBOT
vagrant zealot
#

Hey! I made my game with levels. When i finish one level, i go to the another scene. it goes like that. I made a game over menu and i rotated it to my main menu scene, but as far as i understand i cant return to the scene that i already visited. is it true ? how can i solve this problem

rocky canyon
#

you can load into any scene as many times as u wish

vagrant zealot
#

i forgot to write the variable xd

#

thanks my bro

swift crag
#

the really wild part is that you can load more than one scene at a time, too!

#

(but that can come later)

rocky canyon
#

πŸ’―

fallow frigate
#

good afternoon guys, I am starting playing with Unity and i am currently following a great tutorial The Unity Tutorial For Complete Beginners and i have been stuck for the past 5 hours understanding why i am not able to get the same result as he is. 31 minutes in, everything works. but once it is time to get everything to work at 35:45 minutes in, it doesn't work... i have failed to find the reason even after looking back 50 times and i have no code error either in Unity please help

swift crag
#

we can do very little if you don't show us what you're doing, what's going wrong, and what you've tried

fallow frigate
#

alright, do i put screeshots?

dense root
#

Either post small code snippets of the problem area or use the following tool for large ones

#

!code

eternal falconBOT
dense root
#

Also describe (or post screenshots) of what is happening and what is your intended behavior would help

fallow frigate
#

public class LogicScript : MonoBehaviour
{
public int playerScore;
public Text scoreText;

[ContextMenu("Increase Score")]
public void addScore()
{
    playerScore = playerScore + 1;
    scoreText.text = playerScore.ToString();
}

}

#

this works

dense root
#

For inline code please use three back quotes (`)

fallow frigate
#

sorry... i am new to this and i find it tricky

dense root
#

So i am assuming you are trying to make a score keeper? What seems to be the problem?

fallow frigate
#

yeah

rich adder
fallow frigate
#

english is not my first language

dense root
fallow frigate
#

visually speaking, because the bird has passed to pipe, the number should be 1

rich adder
fallow frigate
rich adder
rich adder
eternal falconBOT
fallow frigate
#

that is the next part of code linked to it

rich adder
#

Debug.Log the trigger

lethal smelt
summer stump
rich adder
#

see if its even happening

#

I suggest u double check this ^

fallow frigate
#

alright, thanks. i will check that

fallow frigate
lethal smelt
#

did u set the logic manager to logic tag like he said?

fallow frigate
#

yeah

dense root
#

Have you Debug.Log the trigger yet? Make sure it's firing?

fallow frigate
#

i will do that now and see what is happening

dense root
#

Okay take your time

silent vault
#

Hello, how do I change the value of an attribute in a XmlNode? Google search says to use node.Attributes[code] but Attributes is get only, not set. So I can't edit it...

rich adder
#

are you deserializing an xml file ?

silent vault
#

I'm creating a UI to edit Xml so players can create mods directly in the game, standardizing stuff

#

I use XmlDocument to load the xml

rich adder
#

why XML and not JSON ?

#

json far faster

silent vault
#

Well, I didn't know that and I'm used to Xml so I went with it...

rich adder
#

oh ok

#

you are trying to change what exactly I'm not familiar with XML formatting in c#

#

seems like node.Attributes is the way to go

silent vault
#

Well, let's say I have a simple XML file <e><event code="blabla"></event></e>. I just want to change blabla to blibli for example.

#

Attributes is get only

rich adder
#
 XmlAttribute attribute = node.Attributes["YourAttributeName"];
            if (attribute != null)
            {
                attribute.Value = "NewValue"; 
            }
            else
            {
                Debug.LogError("Attribute not found.");
            }```
#

I think

#

Im quickly scanning through unity Forums πŸ˜›

silent vault
#

Will the XmlAttribute be an actual reference to the attribute in the xmlnode or a copy ?

rich adder
#

you probably forgot the .Value

#

node is XmlNode node = xmlDoc.SelectSingleNode("//YourNodeName");

silent vault
#

I didn't try this way cause I thought Attributes would not return a reference.

#

I'll give it a shot, thanks.

rich adder
#

np. lmk if works. I can test it myself too rq when I'm back on pc

dense root
#

How do you determine the order of precedence for which systems you program? Say I am making a Pokemon style game would I program the camera first then gameplay? Do them simultaneously? Any insights appreciated

fallow frigate
# dense root Any luck?

well... my lack of coding knowledge is currently beating me good... i am still trying to figure out how to run that

rich adder
#

you should at very least be able to verify if logs are printing

dense root
#

Start here @fallow frigate

private void OnTriggerEnter2D(Collider2D collision)
{
  logic.addScore();
  Debug.Log("Triggered");
}
wooden minnow
#

i dont have a DisplayName avariable inside of my Oculus.Platform.Users.GetLoggedInUser().OnComplete(getname)

private void getname(Message msg)
{
    name = msg.GetUser().DisplayName; // i dont have DisplayName but i DO have ID and OculusID
}``` please help
silent vault
dense root
fallow frigate
#

nope

dense root
#

Do you have collider attached to the game object?

lethal smelt
#

did you resize the collider right?

rich adder
fallow frigate
fallow frigate
lethal smelt
#

boxcollider2d right?

rich adder
wooden minnow
#

a string

rich adder
#

no shit

wooden minnow
#

but it doesnt exist

rich adder
#

and ?

wooden minnow
#

i physically cannot get the display name

dense root
#

Can you link the documentation? I can't find it anywhere

wooden minnow
#

me?

dense root
#

Yes please

fallow frigate
wooden minnow
dense root
rich adder
fallow frigate
#

yeah exactly

lethal smelt
rich adder
#

you got 3D colliders, they will never work with 2D functions / rigidbody

lethal smelt
#

not the same as box collider

rich adder
#

they are completly different physics system

dense root
wooden minnow
#

yeah idk the exact documentation because i cant find it either, that's why im going off of what i can find and this is the only thing i can find

lethal smelt
#

and make sure rigid body is 2D too

wooden minnow
#

or did you mean something else

dense root
#

No no that''s what I meant @wooden minnow. I guess the documentation is a bit sparse

fallow frigate
#

oh yeah, alright, i will go through my mess and check that. if i have a precise question once i have done that i will say.

swift crag
#

here is the definition for Oculus.Platform.Models.User

#

it indeed includes a DisplayName

wooden minnow
#

mine doesnt

dense root
#

Oh cool, thank you

#

Sorry, what was the problem again @wooden minnow?

swift crag
#

I cannot find a version of the SDK that doesn't have this property.

wooden minnow
dense root
rich adder
swift crag
wooden minnow
swift crag
rich adder
swift crag
#

and what is the exact error?

wooden minnow
#

it just doesnt exist

rich adder
#

is it IDE or just unity?

wooden minnow
#

if i try to write .GetUser().DisplayName it doesnt autofill and tells me that User doesnt contain the definition for DisplayName

#

using VS2022

swift crag
#

does Unity also complain?

wooden minnow
#

idk?

swift crag
#

you don't know?

#

look at the console

#

is there a compile error?

wooden minnow
#

it cant compile

swift crag
#

because of the same error you're seeing in the IDE?

#

or because of some unrelated error?

wooden minnow
#

yeah

swift crag
#

screenshot the error for me

spring tusk
#

Sorry to interrupt but I have a problem in my code and I need help. Can I get help next?

spring tusk
#

I just like to be polite

rich adder
#

yeah no worries this aint a doctors office or anything lol

spring tusk
#

lol

#
using System.Collections.Generic;
using TMPro;
using UnityEngine;

public class Controls : MonoBehaviour
{
    private Rigidbody2D rb;
    private float jumpforce = 40f;
    private bool engineIsOn;

    [SerializeField]
    public GameObject fire;

    [SerializeField]
    private TextMeshProUGUI fuelMeter;
    public static int fuelAmount;

    
    void Start()
    {
        engineIsOn = false;
        fire.SetActive(false);
        rb = GetComponent<Rigidbody2D>();

        fuelAmount = 100;
    }
    void Update()
    {
        fuelMeter.text = fuelAmount.ToString() + "%";

        if (fuelAmount == 0)
        {
            engineIsOn = false;
            fire.SetActive(false);
        }

        //if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began && fuelAmount > 0)
        if (Input.GetMouseButtonDown(0) && fuelAmount > 0)
        {
            fire.SetActive(true);
            engineIsOn = true;
            StartCoroutine(BurnFuel());

        }
        //if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Ended)
        if (Input.GetMouseButtonUp(0))
        {
            fire.SetActive(false);
            engineIsOn = false;
        }
    }
    private void FixedUpdate()
    {
        switch (engineIsOn)
        {
            case true:
                rb.AddForce(new Vector2(0f, jumpforce), ForceMode2D.Force);
                break;
            case false:
                rb.AddForce(new Vector2(0f, 0f), ForceMode2D.Force);
                break;
        }
    }
    private IEnumerator BurnFuel()
    {
        for (int i = fuelAmount; i >= 1; i--)
        {
            fuelAmount -= 1;
            yield return new WaitForSeconds(0.2F);

            //if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Ended)
            if (Input.GetMouseButtonUp(0))
                break;
        }
    }
}```
wooden minnow
#

?code

spring tusk
#

This is the code

wooden minnow
#

that wasnt the command damnit

spring tusk
#

It supposed to stop burning fuel when I stop touching/clicking but it keeps burning

#

and more

#

it burns faster

rich adder
#

more than likely you're running the Coroutine multiple times
Aka creating a new one each time

spring tusk
#

with each click

rich adder
#

bool is prob easiest

#
  if(isBurningFuel) return;
            StartCoroutine(BurnFuel());```
#
bool isBurningFuel;
    private IEnumerator BurnFuel()
    {
        isBurningFuel = true;
        for (int i = fuelAmount; i >= 1; i--)
        {
            fuelAmount -= 1;
            yield return new WaitForSeconds(0.2F);

            //if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Ended)
            if (Input.GetMouseButtonUp(0))
                break;
        }
        isBurningFuel = false;
    }```
wooden minnow
dense root
#

Sometimes it be like that

rich adder
#

it was likely just your IDE not reading the assemblies properly

#

or unity needed it

swift sedge
#

you could reload the assemblies in the unity editor