#💻┃code-beginner

1 messages · Page 308 of 1

oblique herald
#

still no :/

ivory bobcat
#

Active doesn't necessarily mean visible but not greyed out.

oblique herald
#

it is greyed out

ivory bobcat
#

Are you setting it inactive anywhere?

oblique herald
#

wait hold on

#

ok so this is even weirder now

oak ginkgo
#

Does anybody know how to animate enemies in 8 directions (2d) using A* pathfinding? I've basically made a clone of my player animations and changed it from "input values" to calculate the transform - last position in hopes that it will work, but I honestly am over my head lmao

hexed terrace
#

Debug.Log($"VaultUI is active in hierarchy - {vaultUI.activeInHierarchy}", vaultUI); is what you should test

strong wren
#

i did the important stuff, idk if thats the issue i dont think so tho, u put the kill script on the canvas

#
{
    public int DMG = 1;
    public int Coins = 0;
    public TMP_Text CoinCounter;
    public Slider SlimeHealth;
    bool isDead = false;

    public void DmgSlime()
    {
        SlimeHealth.value =- DMG;
        if (SlimeHealth.value == 0)
        {
            isDead = true;
        }
    }

    public void AddMoney()
    {
        if (isDead == true)
        {
            Coins++;
            CoinCounter.text = Coins.ToString ();
            SlimeHealth.value = 5;
        }
    }
}```
#

theres the code too

oblique herald
#

@ivory bobcat do you mind if I put my problem in a thread to better communicate? its getting kinda complicated imo

oblique herald
strong wren
#

hm interesting, so theres a bug with the dmg output

#

i put it at 1 but it does infinite

#

and i think that causes the other stuff to break

#

oh nvm

#

the issue with the add money void i dont have a proper way to call on it

hexed terrace
strong wren
#

is there a chance u might know whats the reason of the dmg output being infinite?

#

i tried a huge number and it deplets it all

scarlet skiff
#

ive looked into that but idk i couldnt figure it out

there have several suggestoins for solutions now that ive become lost.
when i watched a interface tutorial it seemed to be pretty fitting for what im trying to do but idk

strong wren
#

THANK YOu

#

that was the issue

oblique herald
strong wren
#

now im going to look for a way to call on my AddMoney Method

scarlet skiff
#

ill look up a quick tutorial about this and see

strong wren
# languid spire -= not =-

or do you think i should put everything in the dmg slime method? it should work but i believe it would be a bad way to do it

strong wren
#

thats the thing i dont know how to call it thru my code

oak ginkgo
#

you mean call a method?

strong wren
oak ginkgo
#

so you'd use GetComponent<Thing>()right?

languid spire
#

why would calling one method, which you obviously do be any different than calling a different one?

slender nymph
strong wren
slender nymph
#

if you do that, you'll probably learn how to call a method, and when you learn how to do that you might realize that you can just call the method instead of using that useless bool

slender nymph
#

cool. now go learn the basics

rocky canyon
#
    public void DmgSlime()
    {
        SlimeHealth.value =- DMG;
        if (SlimeHealth.value == 0)
        {
            AddMoney(); // call a function from within another function
        }
    }```
strong wren
#

you just use the name of the void?

#

sorry method

slender nymph
rocky canyon
#

this most every tutorial will cover that

strong wren
#

i just made my first game with a little of help

#

idk if thats considred impressive here

fickle plume
atomic yew
#

Hello everyone, I have a problem. When I call an if block inside fixedupdate it works as I want, but it reduces FPS a lot. I want to write this in Coroutine, but this time if blocks do not work. For this reason, when I open as many coroutines as if blocks and rotate them in another coroutine, I feel like I'm doing something very stupid, and although it doesn't reduce the fps as much as the fixedupdate function, it reduces it a lot. How can I revise this code? Can you help me?

#

private void FixedUpdate()
{
if (TotemKoruyanlar[0].GetComponent<MaviDusmanlarScript>().DusmanM.hayvancan <= 0 && !DirilmeTF0)
{
DirilmeTF0 = true;
}
if (TotemKoruyanlar[1].GetComponent<MaviDusmanlarScript>().DusmanM.hayvancan <= 0 && !DirilmeTF1)
{
DirilmeTF1 = true;
}
if (TotemKoruyanlar[2].GetComponent<MaviDusmanlarScript>().DusmanM.hayvancan <= 0 && !DirilmeTF2)
{
DirilmeTF2 = true;
}
if (TotemKoruyanlar[3].GetComponent<MaviDusmanlarScript>().DusmanM.hayvancan <= 0 && !DirilmeTF3)
{
DirilmeTF3 = true;
}
if (TotemKoruyanlar[4].GetComponent<MaviDusmanlarScript>().DusmanM.hayvancan <= 0 && !DirilmeTF4)
{
DirilmeTF4 = true;
}
if (TotemKoruyanlar[5].GetComponent<MaviDusmanlarScript>().DusmanM.hayvancan <= 0 && !DirilmeTF5)
{
DirilmeTF5 = true;
}
if (TotemKoruyanlar[6].GetComponent<MaviDusmanlarScript>().DusmanM.hayvancan <= 0 && !DirilmeTF6)
{
DirilmeTF6 = true;
}
}

#

IEnumerator TotemTakasDongu2Cor()
{
yield return YarimSaniyeBekleme;

if (TotemKoruyanlar[0].GetComponent<MaviDusmanlarScript>().DusmanM.hayvancan <= 0 && !DirilmeTF0)
{
    DirilmeTF0 = true;
}
if (TotemKoruyanlar[1].GetComponent<MaviDusmanlarScript>().DusmanM.hayvancan <= 0 && !DirilmeTF1)
{
    DirilmeTF1 = true;
}
if (TotemKoruyanlar[2].GetComponent<MaviDusmanlarScript>().DusmanM.hayvancan <= 0 && !DirilmeTF2)
{
    DirilmeTF2 = true;
}
if (TotemKoruyanlar[3].GetComponent<MaviDusmanlarScript>().DusmanM.hayvancan <= 0 && !DirilmeTF3)
{
    DirilmeTF3 = true;
}
if (TotemKoruyanlar[4].GetComponent<MaviDusmanlarScript>().DusmanM.hayvancan <= 0 && !DirilmeTF4)
{
    DirilmeTF4 = true;
}
if (TotemKoruyanlar[5].GetComponent<MaviDusmanlarScript>().DusmanM.hayvancan <= 0 && !DirilmeTF5)
{
    DirilmeTF5 = true;
}
if (TotemKoruyanlar[6].GetComponent<MaviDusmanlarScript>().DusmanM.hayvancan <= 0 && !DirilmeTF6)
{
    DirilmeTF6 = true;
}

StartCoroutine(TotemTakasDongu2Cor());

}

eternal falconBOT
rare basin
#

jezus

#

that's not pleasent to look at code

loud mango
#

i need help with a small game of mine

The PROBLEM here is that the bullets are not depleting. ik why they are not but idk how to solve it.

GUN / SHOOTING SCRIPT : https://pastebin.com/TDqsRDpq

WEAPON SWITCHING SCRIPT: https://pastebin.com/1afDWMc6

atomic yew
#

My goal is to ensure that the values ​​I want are true when the if condition is met.

rare basin
#

you know why they are not depleting but you dont know how to solve it?

#

wdym?

languid spire
loud mango
#

yeh

loud mango
#

that will detect when the weapon is switched and will change the magazine size accordingly

#

but i had to use it in update

#

and thats why whenever the i change the weapon, the if statements are always true and thus infinite ammo

atomic yew
loud mango
#
        if(changeWeapon.isPistolStc){
            clipSize = 10f;
        }
    }

    void changeRifleClip(){
        if(!changeWeapon.isPistolStc){
            clipSize = 20f;
        }
    }```


``` void Update()
    {
        changePistolClip();
        changeRifleClip();
        if(Input.GetKeyDown(KeyCode.R)){
            clipSize = fullClipSize;
            noAmmo = false;
            rifleDMG = 20f;
            pistolDMG = 10f;
        }
}
#

the problems are here

loud mango
#

idk what the solution can be

frosty lantern
#

hey, I want an 16x16x16 byte structure, so I declared a ushort[16][], the idea being that each byte is already 16 bits, and I want an 16x16 of bytes. I have 2 concerns:

  • it doesn't let me specify that the second dimension of the array should also be 16
  • can I perform bitwise operations on this structure?
gaunt ice
loud mango
#

i need help plsssss

atomic yew
atomic yew
#

why

#

Can you revise the coroutine?

frosty lantern
atomic yew
#

Why isn't this Coroutine working the way I want it to? Can someone who knows revise it and correct me if I'm wrong?

languid spire
gaunt ice
#

no

rare basin
#

unless you make some kind of wrapper for it

atomic yew
languid spire
eternal falconBOT
loud mango
#

i still wanna thank you

#

u once helped me in a game dev

atomic yew
polar acorn
#

it tells you how to post code

atomic yew
frosty lantern
#

obviously not exactly

summer stump
rare basin
summer stump
#

You just have a variable with the type

frosty lantern
summer stump
summer stump
frosty lantern
gaunt ice
#

make a wrapper to contain the whole 2d array

frosty lantern
#

is a wrapper just a class with the 2d array in it?

#

as a variable?

gaunt ice
#

or struct

frosty lantern
#

struct sounds like it'd be better

gaunt ice
#
public struct Wrapper{
  Type theActualData;
}
atomic yew
atomic yew
# languid spire so show that code

My goal is to create a loop with coroutine and refresh it every 0.5f seconds. Thus, it will not reduce the fps as much as in fixedupdate.

summer stump
languid spire
atomic yew
languid spire
#

And cache the GetComponents

atomic yew
frail star
#

How can I get a float to count up from 0.00 to the value of a variable smooth over a period of time?

I am keeping track of a players score using a float and at the end of the level I want to have the score shown starting at 0.00 then start counting up to the value of the variable and I'm adding a star rating at certain score values

atomic yew
languid spire
rare basin
atomic yew
# languid spire you still have not explained what 'didn't work' means to you, we are not mind re...

I made a game, there are animal mobs and enemy soldiers in the game. When soldiers die, I record this so that they do not immediately revive when the player enters and exits, but when their time is up. I want to keep memory of whether he died or not at the ResurrectionTF value. I can already keep it in memory, but when a character dies in FixedUpdate, ResurrectionTF becomes true. I cannot do it in Coroutine. I want to do this because Coroutine also reduces FPS. Could you look at the screenshot? The soldier died, but the Inspector also did not ResurrectTF true.

atomic yew
atomic yew
languid spire
frail star
rare basin
#

just use dotween, it'd be easier and with more control

frail star
rare basin
#
DOVirtual.Float(0, correctPercentage, transitionDuration, f => endOfLevelCorrectPercentageDisplay.text = $"Final Score - {f}");
frail star
#

what's DOVirtual? do i need a namespace

rare basin
#

DOTween asset

frail star
rare basin
#

yup

#

then watch this @frail star https://www.youtube.com/watch?v=Y8cv-rF5j6c

DOTween is the very first thing I install upon creating a new project. Animate your position, rotation and scale in a single line of code, with all the customization you could hope for... and that's only scratching the surface.

For the full documentation: http://dotween.demigiant.com/documentation.php

❤️ Become a Tarobro on Patreon: https://ww...

▶ Play video
scarlet skiff
#

Did i cook?

every spawner rn is like:
public class FireballSpawner : MonoBehaviour, ISpawner

and i have this script

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

public class BaseSpawner : MonoBehaviour
{
    public interface ISpawner
    {
        void Spawn();
    }
}

polar acorn
scarlet skiff
split dragon
#

Hi. I have a question: Which option would be better or does it make no difference?

thorn holly
#

And takes less typing

#

All about s p e e d

split dragon
#

Ok. Thanks

#

I had a choice: I have 2 choices: make 1 variable: "GameObject" or make several variables, but already by components. What is the best choice and will it affect performance, etc.?

polar acorn
elder axle
#

I have the below script attached to the Object in the picture and when i click on the space bar i want it to call the Jump() Function via the Input Action

public class Player : MonoBehaviour
{
    public float speed = 3f;
    public float JumpForce = 11f;
    bool Grounded = true;
    Animator anim;
    public SpriteRenderer sr;
    Rigidbody2D rb;
    Transform trans;
    public InputAction playerControls;
    Vector2 MoveDirection = Vector2.zero;

    private void OnEnable(){
        playerControls.Enable();
    }

    private void OnDisable(){
        playerControls.Disable();
    }

    void Awake()
   {
        anim = GetComponent<Animator>();
        sr = GetComponent<SpriteRenderer>();
        rb = GetComponent<Rigidbody2D>();
        trans = GetComponent<Transform>();
    }
    void Start()
    {
        
    }

    void FixedUpdate(){
    }

    void Update()
    {
       Player_Jump(); 
       Player_Movement();
       Player_Animation();
    }

    void Player_Movement(){
        MoveDirection =  playerControls.ReadValue<Vector2>();
        Vector3 dir = new Vector3(MoveDirection.x, 0, 0);
        transform.position += dir * Time.deltaTime * speed;
    }
    void Player_Animation(){
        float h = Input.GetAxisRaw("Horizontal");
        if (h == -1){
            anim.SetBool("Walk", true);
            sr.flipX = true;
        }
        else if (h == 1){
            anim.SetBool("Walk", true);
            sr.flipX = false;
        }
        else if (h == 0){
            anim.SetBool("Walk", false);
        }
    }    
    void Player_Jump(){
        if (Input.GetButtonUp("Jump") && Grounded){
            Grounded=false;
            rb.AddForce(new Vector2(0,JumpForce), ForceMode2D.Impulse);
        }
    }
    public void Jump(){
        if(Grounded){
            Grounded=false;
            rb.AddForce(new Vector2(0,JumpForce), ForceMode2D.Impulse);            
        }
    }
}   
magic galleon
#

I'm trying to add a custom script to draw a radius for me, script derives from editor.

When adding to a gameobject I get an error to say it needs to derive from monobehaviour. Any ideas?

polar acorn
#

and you can't attach it to a GameObject

summer stump
summer stump
# magic galleon Unhelpful

Well, I am genuinely asking so I can make the issue clear to you
Maybe you didn't understand what a MonoBehaviour was? I dunno, we have people at all stages of their path

magic galleon
magic galleon
languid spire
polar acorn
#

So select an object with skeletonSpawner and see if you see your custom gizmo in the scene view

magic galleon
#

I see, it has worked but I was zoomed in further than the radius, I assumed it needed to be on the object to display the wire. Thank you all!

frigid ravine
#

Hello all. I'm developing a two-player game using Relay and NGO. Is there a way I can make the opposing player appear at one part of the screen. A good example is how airhockey works. A player is limited to their half of the screen. So I want that kind of mechanism. Where the opponent appears on the upper half for both players.

rich adder
oblique herald
#

I have a script running this to collect user input to TMP_InputField in the input field:

    [SerializeField]
    private string password;

    public void grabPW(string input) {
        password = input;
    }

but the password doesnt store the input. any fixes?
ps: it worked before... i just dont know what i couldve changed to make it not work ..

willow scroll
oblique herald
#

yes it should, but it doesnt 😿

willow scroll
#

If your password isn't changed, consider checking whether the grabPW method is called and input isn't the same as the previous password value

slender nymph
#

have you verified that method is being called

cosmic dagger
oblique herald
#

Debug.Log("The password is " + password); i used this to debug (not sure if good enough)
output was

The password is 
UnityEngine.Debug:Log (object)
vaultMech:grabPW (string) (at Assets/Script/vaultMech.cs:19)
UnityEngine.Events.UnityEvent`1<string>:Invoke (string)
TMPro.TMP_InputField:SendOnEndEdit () (at ./Library/PackageCache/com.unity.textmeshpro@3.0.6/Scripts/Runtime/TMP_InputField.cs:3149)
TMPro.TMP_InputField:ReleaseSelection () (at ./Library/PackageCache/com.unity.textmeshpro@3.0.6/Scripts/Runtime/TMP_InputField.cs:4146)
TMPro.TMP_InputField:DeactivateInputField (bool) (at ./Library/PackageCache/com.unity.textmeshpro@3.0.6/Scripts/Runtime/TMP_InputField.cs:4184)
TMPro.TMP_InputField:OnUpdateSelected (UnityEngine.EventSystems.BaseEventData) (at ./Library/PackageCache/com.unity.textmeshpro@3.0.6/Scripts/Runtime/TMP_InputField.cs:2161)
UnityEngine.EventSystems.EventSystem:Update () (at ./Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:530)

slender nymph
vestal shadow
south sky
#

Hey guys, I have a problem. The slider component gets given a value however when the scene is loaded again the value of the slider gets reset back to its max. Anyone know how to fix?

willow scroll
slender nymph
cosmic dagger
south sky
oblique herald
slender nymph
polar acorn
dry sail
#

hello ive never made a game before and im trying to install xr interaction toolkit but its not installing

dry sail
#

oh im asorry

slender nymph
vestal shadow
oblique herald
summer stump
slender nymph
vestal shadow
#

i am just a man

fickle plume
#

!ban save 1224236792354705408 Ignoring warnings, trolling

eternal falconBOT
#

dynoSuccess legends_of_the_summer was banned.

oblique herald
#

since the dipshit guy is gone, can i ask if I could re-ask an earlier question that is in a thread before cuz its yet to be resolved :<

polar acorn
oblique herald
#

but not this question haha

proven junco
#

omg man

#

vs and unity does not like me

#

I need to connect my vs every time I start unity

#

it is super annoying and I now I forgot how to connect them

slender nymph
#

that typically means unity is unable to write to the registry to apply the setting. close unity and the hub, launch the hub as admin, open unity, change the setting, close both, and relaunch normally and it should stick

proven junco
#

how do I change the setting

slender nymph
#

wdym? it's the setting you've had to change every time you've launched unity so that it would connect to vs correctly

proven junco
#

yeah but I havnt opended it in a week or so

#

so I hve forgotten

slender nymph
#

!ide 👇

eternal falconBOT
twin bolt
#

How could i change the pitch of an audio source each time it loops from script? I'm having an issue with my sfx moving audio, sounding repetitive.

cosmic dagger
#

instead of looping, have it play every time the player steps. then you can randomize the play before playing each sound . . .

twin bolt
#

The audio is played and looped, depending on if the objects velocity is over 0

oblique herald
#

okay another question:

    [SerializeField]
    BoxCollider2D vault;

    [SerializeField]
    BoxCollider2D itemCol;

i have two different collider, what i wanna do is when the vault is opened, i want to remove the box collider on the vault and enable the box collider for the item inside, i wrote something like this:

    private void openVault() {
        vault.enabled = false;
        itemCol.enabled = true;
    }

I put this script in the InputField, reason being I wanted to open it when the vault password was correct, something like this:

    public void CheckPassword() {
        switch (password)
        {
            case "combine":
                ChangeVaultText("Vault Unlocked!");
                openVault();
                break;

            default:
                ChangeVaultText("Wrong Password!");
                break;
        }
    }

However when i go to interact the vault, both my boxcollider2d variable were reseted to none, when i assigned it before play mode, is separating the script necessary, or is there something im doing wrong...

wintry quarry
#

it's probably different code you didn't share that's doing it

#

are you trying to assign those variables in Start or Awake or something?

oblique herald
#

Start

wintry quarry
#

why

#

You said you assigned it in the inspector right?

oblique herald
#

waut

wintry quarry
#

So why are you also trying to assign them in code?

oblique herald
#

wait

#
    public void Start() {
        vault = this.GetComponent<BoxCollider2D>();
        itemCol = this.GetComponent<BoxCollider2D>();
    }
#

so i dont need to dothis?

wintry quarry
#

why are you doing that

#

delete that

#

that makes no sense

oblique herald
#

i am braindead

#

wait so when should i assign then

wintry quarry
#

Didn't you already assign them in the inspector?

oblique herald
#

is it just never

wintry quarry
#

Well never because both of those GetComponents would end up returning the same collider lol

cosmic dagger
wintry quarry
oblique herald
#

damn, guess i need to watch more yt tutorial and learn again :/

wintry quarry
#

Do you understand what this.GetComponent<Collider2D>() means?

#

or what the = does?

languid spire
#

Did you read the error message?

oblique herald
languid spire
#

Then why did you post 3 scripts, none of which are the one with the error?

wintry quarry
#

it puts the thing on the right into the variable on the left

oblique herald
#

ah right

#

== is equal

wintry quarry
wintry quarry
#

so it's just going to find the first BoxCollider2D it sees on the same GameObject as your script and put it in your variable

oblique herald
#

ohhhh hahahaha i feel so stupid now

wintry quarry
#

since you don't have ANY BoxCollider2D it will just return null

#

also if there were more than one, you wouldn't get to pick which one it finds

oblique herald
#

ah ok, so next time I should just assign it with public BoxCollider2D name << and put it in the inspector

wintry quarry
#

no

#
    [SerializeField]
    BoxCollider2D vault;```
#

this is completely fine

#

no need to make it public

#

you assign it in the inspector

#

you just don't need to assign it again in code if it's already assigned in the inspector

#

pick one or the other

oblique herald
#

I gotchu :> thanks for the quick tutoiral my guy

south sky
#

How do I disable a collision detection method when there is a trigger detection method, or should I just find another way becuase I have overlapping colliders

summer stump
#

if (!checkTrigger) return;

south sky
#

Bet

#

Thanks man

#

+10 social credit

graceful spruce
#

Hey, so I'm having some issues to remove a hero/gameobject from a slot. the adding of hero works fine but I just don't know what might be the error since I'm getting no errors in unity.

Here's the code

using System.Collections.Generic;
using UnityEngine;

public class EquipCharactercopy : MonoBehaviour
{
    public Transform[] heroSlots; // Array of transforms representing the hero slots

    // Function to add a hero to a slot
    public void AddHero(GameObject hero)
    {
        // Find an empty slot and add the hero to it
        foreach (Transform slot in heroSlots)
        {
            if (slot.childCount == 0) // Check if the slot is empty
            {
                GameObject newHero = Instantiate(hero, slot.position, Quaternion.identity);
                newHero.transform.parent = slot;
                break;
            }
        }
    }

    // Function to remove a hero from a slot
    public void RemoveHero(GameObject hero)
    {
        // Find the slot containing the specified hero and remove it
        foreach (Transform slot in heroSlots)
        {
            if (slot.childCount > 0 && slot.GetChild(0).gameObject == hero) // Check if the slot contains the specified hero
            {
                Destroy(slot.GetChild(0).gameObject);
                break;
            }
        }
    }
}```
#

I placed the RemoveHero function into the button event, but it's just not doing anything

round mural
#

is anyone here familiar with RuleTiles?
im trying to make a game with an ingame level editor and i really want to make it possible through a script to place a ruleTile (use the ruleTile brush) on a tilemap but i dont know whether that can even be done or how

polar acorn
graceful spruce
#

👍 alright, I'

#

ll try it thanks

round mural
#

is anyone here familiar with RuleTiles?
im trying to make a game with an ingame level editor and i really want to make it possible through a script to place a ruleTile (use the ruleTile brush) on a tilemap but i dont know whether that can even be done or how
this is my code so far:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Tilemaps;

public class LevelEditor : MonoBehaviour
{
    public int selectID = 0;
    [SerializeField] Image[] tileIcons;
    [SerializeField] Image selectedTile;
    [SerializeField] Tile[] ruleTiles;
    public Tilemap tilemap;
    public void SelectTile(int selection){
        selectID = selection;
        selectedTile.sprite = tileIcons[selectID].sprite;
        if (selectID>0)selectedTile.color = new Color (255,255,255,255);
    }

    private void PlaceGroundTile()
    {
        Vector3 mouseWorldPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        Vector3Int cellPosition = tilemap.WorldToCell(mouseWorldPos);
        tilemap.SetTile(cellPosition, ruleTiles[selectID]);
    }

    private void placePrefabTile(){

    }

    public void placeTile(){
        if (selectID == 1){
            PlaceGroundTile();
        }
        else if(selectID>0){
            placePrefabTile();
        }
    }
}
scenic dragon
#

how do i make it possible for my character to look around

verbal dome
scenic dragon
#

i shoud prob of done that first

scenic dragon
#

whenever i use this move scipt it makes me fly instead

#

of walking

cinder crag
#

how can i check if an animation has finished?

scenic dragon
cinder crag
scenic dragon
scenic dragon
#

can i get assitance with making my character walk

languid spire
cinder crag
rich adder
cinder crag
#

I'm doing something with the animation event to instantiate the weapon and destroy it

rich adder
#

so whats the problem ?

cinder crag
#

was jsut curious if there was another way but i will try it my way lolol

rich adder
#

another way of what? animation event is exactly perfect fit here..

verbal dome
#

If you know that the animation will always reach the event, then it's fine.
If the animation might end earlier then you can check AnimatorStateInfo from a script like Steve suggested.
Third option is StateMachineBehaviour.OnStateExit

lethal bolt
#

Does anyone have that straigth line before 1 on the keyboard and after Escape?

rich adder
#

thats true maybe event might not hit if in transition

cinder crag
#

Yeah I know now lolol

rich adder
lethal bolt
#

I dont have it on my keyboard and i need to make or

rich adder
#

which keyboard style do you have?

lethal bolt
#

75%

rich adder
#

that helps nothing

#

keyboard have different setups

languid spire
lethal bolt
#

I have Windows if thats what you mean?

languid spire
#

omg

rich adder
#

how is this not a troll post rn

lethal bolt
#

I got an normal keyboard

#

NORMAL 75% keyboard

rich adder
#

what is "normal"

lethal bolt
#

ENGLISH

rich adder
#

was that so diffcult?

lethal bolt
#

no..

rich adder
#

its above enter

languid spire
#

do you no know that each language has it's own keyboard layout?

#

there are many kinds of English, which one?

lethal bolt
#

I live in Norway so i didnt know if it was Norwegian or English

#

Don't really know

rich adder
#

european keyboard..

lethal bolt
#

Yes.?

languid spire
#

what character is above the 3?

lethal bolt
#

Like fn3 or the other symoble on the three?

languid spire
#

number 3

#

like shift + 3

lethal bolt
#

Then i becomes an #

languid spire
#

ok, so that is a US or international keyboard so the or is the key above the enter key with shift

lethal bolt
#

Thanks!

hidden sleet
#

oh hang on i think it might be on a different script

#

that'll be it, it was referring to my camera controller rather than the player which I shared above

scarlet skiff
#

is there any way to organize variables in a way so i can collapes them by clicking the little minus symbol without then being only able to access them with something.variablename

cosmic dagger
#

use regions . . .

scarlet skiff
#

so thats what it called

#

thanks

wintry quarry
scarlet skiff
#

also

#

silly me

#

i meant without only able to access them with something.variablename

#

mb

#

so yea regions

rich adder
#

doo you have stack traces on those ?

hidden sleet
#

didn't grab it, I just looked at any possible script that had anything to do with aiming and found the problem there

summer stump
#

Oh, you fixed it? Nice

hidden sleet
#

yeye, i'll probably delete the post as to not confuse people

strong wren
#
    {
        if (MerchantPrice >= PS.Coins)
        {
            PS.Coins -= MerchantPrice;
            PS.Merchant++;
            PS.DMG++;
            MerchantPrice *= PriceMult; WRONG
        }
    }```
#

yo

#

so i know the issue i know where it is located but i do not know how to fix it

#

i know the issue too

polar acorn
#

So are you going to actually say what the problem is or are we just gonna have to guess

strong wren
#

i cant convert a Float into an int

strong wren
polar acorn
#

And what's the problem

scenic dragon
#

can i get help

strong wren
#

the line where it says WRONG that code is wrong

scenic dragon
#

with animations

strong wren
polar acorn
rich adder
strong wren
polar acorn
rich adder
polar acorn
#

How do you intend to handle decimals? Rounding or truncating?

strong wren
swift elbow
#

ez

#

thats literally all it does

strong wren
polar acorn
strong wren
polar acorn
strong wren
strong wren
rich adder
#

so how do you intent on dealing with end result of multiplying by decimal

#

if you get decimals as result

polar acorn
strong wren
polar acorn
#

That's not on the line your error says

strong wren
#

What if i make the Merchant price a float to? the additions in my game is mostly using whole numbers i think it should technically work

rich adder
strong wren
polar acorn
#

In order to set an integer variable to a float value, you need to decide what you want to do with that remainder: Rounding or truncating (or floor or ceiling I suppose but those are kinds of rounding)

strong wren
rich adder
#

its basic math my guy

polar acorn
languid spire
rich adder
#

2 * 3.2 = 6.4

#

what to do with .4

strong wren
#

where im from we call it smth else

#

well we could just round it

polar acorn
strong wren
topaz hull
#

Okay so I'm basically a full unity rookie that has just started to code a simple little remake of the game Doodle Jump and I was wondering how I would set up the camera system?

rich adder
#

Cinemachine!

topaz hull
#

Basically what I have now is a trigger box so when the player enters the camera that's locked to that object will start to follow the players movement until the player leaves the trigger

#

But the issue I am facing is that the camera is moving along the X axis as well

polar acorn
#

Cinemachine indeed!

topaz hull
#

I want it to be locked in the Y-axis only

strong wren
topaz hull
#

I just got cinemachine and haven't touched it way too much so I don't know it's capabilities

strong wren
#
public void BuyingMerchants()
   {
       if (MerchantPrice >= PS.Coins)
       {
           PS.Coins -= MerchantPrice;
           PS.Merchant++;
           PS.DMG++;
           MerchantPrice *= Mathf.RoundToInt(PriceMult);
       }
   }``` is this how i use Mathf 😭
#

i dont have an error

polar acorn
strong wren
swift elbow
#

thats all you really need

strong wren
#

ignore that, that was indeed a stupid move

topaz hull
#

What would I write to lock it to Y?

swift elbow
#

wdym "trigger box"

#

trigger box for what?

topaz hull
#

So when the player enters the camera starts to move upwards along with the player

polar acorn
#

Literally has a feature that does exactly this

topaz hull
#

Really?

#

I haven't touched it too much

strong wren
polar acorn
#

deadzones and follow areas

topaz hull
#

Where would I find it

#

Oh lemme look for it

polar acorn
rich adder
#

@swift elbow bro really hating on a tool, its like hating on a Chainsaw

polar acorn
topaz hull
#

I have cinemachine but where in cinemachine would you find the deadzones and such

strong wren
polar acorn
#

I mean, if you have a flathead screw you're gonna have a ton of trouble using a phillips on it

tepid summit
polar acorn
#

you could also do it in assembly code

tepid summit
#

easier

#

to me atleast

summer stump
#

Cinemachine should almost just be the default camera in unity

rich adder
#

And this opinion comes from which bias exactly ?

tepid summit
topaz hull
#

I can't seem to find it?

summer stump
tepid summit
topaz hull
#

Is it the one named "CinemachineVirtualCamera"?

polar acorn
rich adder
#

Oh so like the same opinions as dogs

tepid summit
topaz hull
#

I have a Cinemachine 2D camera

polar acorn
summer stump
tepid summit
#

i said its harder to me

topaz hull
strong wren
#

look im doing
M * P then i need to round the answer which is still M how do i do that

#

how do i round the answer after the calculations are done

tepid summit
summer stump
polar acorn
#

I really don't care if you want to shoot yourself in the foot repeatedly but don't suggest other people do so

topaz hull
#

Lemme google cinemachine deadzone rq

#

I might be able to find

rich adder
#

Welcome to my troll list .

tepid summit
strong wren
summer stump
polar acorn
strong wren
polar acorn
strong wren
#

it sitll isnt working btw

polar acorn
#

Do the math, then assign the value

rich adder
strong wren
polar acorn
#

and set your variable to it

strong wren
polar acorn
#

then set it to the result

#

You are aware you can just do multiplication without needing to use *= right

languid spire
strong wren
#

so it didnt stick

tepid summit
polar acorn
#

Let's have a race. Fresh project, who can get a third person orbit camera working faster, you with whatever and me with cinemachine

languid spire
tepid summit
#

the scripts are separated by a comment

#

damn

polar acorn
#

Okay, woops client updated the requirements now it's an FPS! Quick buzz convert it!

tepid summit
#

yes

polar acorn
tepid summit
#

because i change the value before its destroyed

#

but i see

#

let me try soomething

polar acorn
#

Hm, it's a classified system, no outside code allowed! Reusing your old code could be a security risk!

polar acorn
polar acorn
tepid summit
tepid summit
polar acorn
#

so when you add 1 to 0

#

it becomes 1

tepid summit
#

correct

polar acorn
topaz hull
#

Okay well now I have it following the player

polar acorn
#

so it'll never be anything but 1

strong wren
#

so one of em

tepid summit
polar acorn
topaz hull
#

The reason I made it with a trigger is to have it stop following the player after it leaves the trigger so if the player falls out of view the game ends

#

Is the are way to make the camera not go down?

strong wren
polar acorn
#

that's not multiplication

#

that's multiplication and assignment

tepid summit
#

wait nvm

south sky
#

I have build errors within my code but I don't know how to fix them. Unity isnt giving me a reason

polar acorn
tepid summit
#

yeah

polar acorn
#

because the object is gone

tepid summit
#

im gonna chaneg the code rq

polar acorn
# topaz hull Is the are way to make the camera not go down?

You probably already have a collider that detects when the player falls off of the bottom of the screen, using the CinemachineConfiner, you can make that collider a boundary. And then if you make that collider follow the bottom of the camera, it'll basically mean the camera is carrying along its floor with it as it goes up

topaz hull
#

CinemachineConfiner?

topaz hull
#

Damn I missed that thx

tepid summit
#

getting rid of 2 fixed it

#

so ill make them appear as you progress

topaz hull
#

Sorry if you already answered this question but how did I lock the x axis movement of the camera?

#

Isn't the deadzone now following the player as well?

topaz hull
#

Yeah but the player needs to be able to move on the x axis

#

And the camera is set to follow the player

polar acorn
topaz hull
#

I'll try the confiner

strong wren
#

public void BuyingMerchants()
{
if (MerchantPrice >= PS.Coins)
{
PS.Coins -= MerchantPrice;
PS.Merchant++;
PS.DMG++;
MerchantCounter.text = PS.Merchant.ToString();
MerchantPrice *= PriceMult;
}
}
i need help

#

still

polar acorn
strong wren
#

ive been trying with like 3 other tutorials which they do not work

strong wren
polar acorn
#

This is not a difficult thing to find

strong wren
#

then the others have nothing to do with maths

polar acorn
strong wren
polar acorn
#

Well, since I am not a video, I'm afraid this is where my ability to help you comes to an end

#

tragic

#

have fun looking for a ten minute video with midrolls to tell you what the multiplication symbol is

rich adder
#

it basic operator in c#

strong wren
#

but i need int times float

polar acorn
#

it's math

#

seriously

#

like, elementary school math

strong wren
summer stump
polar acorn
#

because as we have just explained you cannot do that

strong wren
#

no you didnt u just said to round it

polar acorn
summer stump
polar acorn
#

do you want to round or truncate it

rich adder
#

they said round or trucate about a dozen times..

polar acorn
#

What do you intend to do with the decimal after the multiplication

strong wren
polar acorn
polar acorn
#

then round it

#

then store it in the int

summer stump
rich adder
strong wren
polar acorn
#

Also, I specifically said RoundToInt

#

do

#

that

summer stump
#

Literally given the code needed

strong wren
summer stump
polar acorn
strong wren
#

mathf.round yeah but what do i do with it

polar acorn
#

and he's already said he won't read any words

polar acorn
rich adder
summer stump
#

Oh, too slow

polar acorn
strong wren
polar acorn
#

so you know how to use it and what it returns

summer stump
strong wren
#

i put the thing that wants to be rounded Debug.Log(Mathf.RoundToInt(HERE));

strong wren
rich adder
#

Time to make an app "Documentation to MP4"

polar acorn
summer stump
polar acorn
#

you know how to assign a variable, and you know how to round a value to int

#

so what's the fucking problem

#

that's literally the only two parts of this line

rich adder
#

ya mate , its only gonna get harder from here . Spoiler alert

polar acorn
#

I'm not writing the code for you

#

you're going to have to put two thoughts together

strong wren
polar acorn
rich adder
#

I guess this is why microsoft has a Console app as first project being a calculator lmao

strong wren
#

i read alot of math

summer stump
# strong wren i read alot of math

Perfect. You got it then.
It is saying it does not want a decimal assigned to the int.
If you understand math, you should know exactly how to handle that with the example code above

polar acorn
strong wren
polar acorn
strong wren
polar acorn
summer stump
#

Ok, so you have a variable that takes an int

You have a float you want to assign to that variable

You have a method that rounds a float to an int

#

Which part are you struggling with?

strong wren
strong wren
#

wait leme explain it a lil more

#

Mathf.RoundToInt(10.0f) like thats what i use right cool math, i need to somehow tell my code to put the answer Mathf.RoundToInt(HERERE!!!)

summer stump
#

10.0f

#

I don't get it

strong wren
slender nymph
summer stump
summer stump
#

Variable = Mathf.RoundToInt(floatIWantToRound)

strong wren
#

ok ok

summer stump
#

This was given to you before

strong wren
#

leme try smth

polar acorn
#

That's not how, like, logic works

strong wren
summer stump
strong wren
polar acorn
summer stump
#

And saw others say it too

#

If you lie (even unknowingly) about knowing something, we won't know to explain it more

naive lion
#
    {
        yield return new WaitForSeconds(delay);

        while (true)
        {
            if (EnemyHealth.count == 0)
            {
                _enemiesLeft = true;
                StartCoroutine(DelayRoundIncrease(roundDelay));
                yield break;
            }
        }
    }```
Anyone know why this coroutine is making my Unity freeze and crash.
It is called once:
'```            if(_toSpawn >= state)
            {
                StartCoroutine(EnemyCheck(4));
                yield break;
            }```
languid spire
summer stump
polar acorn
naive lion
#

ty

strong wren
polar acorn
strong wren
#

ive been stuck on the same thing for like 2 hours

languid spire
strong wren
#

i know what i have to and i kinda know how

rich adder
#

maybe you need a better hobby lol

strong wren
#

i have to round the answer using (Mathf.RoundToInt(10.0f) but where do i put the (Mathf.RoundToInt(10.0f)

summer stump
#

I literally spoonfed you the answere here

rich adder
strong wren
rich adder
#

why would you round the priceMulti..

strong wren
#

i cant round that float and its the only float i have

rich adder
#

You are supposed to round the result

summer stump
#

Like this is your game, you tell us?

polar acorn
#

Like we've said

#

a lot

#

do the math

strong wren
polar acorn
#

round the result

#

store it

rich adder
summer stump
#

Variable = Mathf.RoundToInt(number1 * number2)

polar acorn
#

Pass the result

#

to the function

#

that's the float you want to round

rich adder
#

notlikethis this has to be a troll post

strong wren
polar acorn
#

How many different ways do we have to literally give you the exact answer before you just fucking do it

summer stump
rich adder
strong wren
#

i got some good news

languid spire
#

let's see if this works

float = int * float
int = RoundToInt(float)
strong wren
#

im sorry for being slow

summer stump
rich adder
#

if you don't care about a result, then its void

strong wren
rich adder
#

this one returns int, meaning you can assign the result to a variable

strong wren
#

alr well i will go to sleep, BUT before i do

#
    public int MerchantPrice = 20;
    public TMP_Text MerchantCounter;
    public TMP_Text MerchantPriceCounter;
    float PriceMult = 1.2f;
    public void BuyingMerchants()
    {
        if (MerchantPrice >= PS.Coins)
        {
            PS.Coins -= MerchantPrice;
            PS.Merchant++;
            PS.DMG++;
            MerchantCounter.text = PS.Merchant.ToString();
            MerchantPrice = Mathf.RoundToInt(MerchantPrice * PriceMult);
        }
    }
``` is there an issue with this code?
#

i keep testing it but the Text That is the MerchantCounter isnt going up

rich adder
#

the only way it would not go up is if yu have console error or something

polar acorn
rich adder
#

ahh true that

strong wren
#

but its just not doing what im telling it to do

rich adder
#

maybe something is changing Merchant in update or something

summer stump
#

Is BuyingMerchants even being called?

strong wren
#

it should take 20 coins away and put 1 merchant and multiply the Price by 20%

summer stump
#

Use Debug.Logs

polar acorn
strong wren
#

lets see if the button being pressed is even being registered

strong wren
rich adder
#

spoiler alert it was not running

#

lol

polar acorn
#

log it

strong wren
#

alr this might sound stupid but how do i tell unity to send me smth in Unitys logs??? i only rememeber using Console.WriteLine(); when i was using console

#

just Debug.log()?

outer cobalt
#

i want to have multiple cinemachine cameras that i can switch to, but once my player respawns (i delete and instantiate a new clone of the player) the dupe only gets followed on my main camera which is then disabled, and the other cameras do not follow the new duplicate, does anyone know why this is happened

polar acorn
strong wren
rich adder
polar acorn
outer cobalt
polar acorn
#

Show

rich adder
#

soo much less complexity if you just reset the player instead of dealing with new clones

#

in the long run at least

outer cobalt
#

so i should just rewrite my GameManager / respawn to instead, reset instead of delete?

#

didnt rlly think of it in that way

strong wren
#

alr i thin i fond the issue

rich adder
#

and probably more performant than constant instantiate and destroy

strong wren
#

its the if statement

outer cobalt
#

cool cool cool, i'll try that, i needed to rewrite it anyway because im making a metroidvania and need to be able to keep track of it

#

thank you @polar acorn and @rich adder

summer stump
strong wren
#

yes it should have

#

someone said im doing it wrong tho

summer stump
strong wren
#

lets go its working

strong wren
summer stump
strong wren
#

how

#

thats like the only reason why i programmed 90% of my code alone

#

he explained it super well and it stuck

summer stump
#
  1. brackeys specifically is really not good for beginners. They do good stuff for more advanced things, but they are not good with beginners

  2. you need to know how to read docs and tutorials, so don't do videos

rich adder
strong wren
#

he tought me all i know

summer stump
#

And think of the struggle you just went through

All of that was stuff that should have been easy if he taught his course well AT ALL

rich adder
#

and it wasn't very good

strong wren
rich adder
#

popular != good (well not always)

summer stump
rich adder
#

its good for picking up a feature or something to learn quickly but you should at least have fundamentals before doing so

polar acorn
strong wren
#

i got bad news

#

theres an issue with the math

#

the original price of a merchant is 20 coins but once bought it increases to 200 coins

#

meaning that instead of it being 24 coins as it should since its 1.2 its 220

polar acorn
# strong wren isnt he loved thruout the programming communituy

Brackeys is a great presenter, and he is great at giving the broad strokes of systems. His code, specifically, is sloppy and usually just exists to demonstrate the topic at hand without regard towards expandability or useability and often breaks as soon as you try to do anything else

summer stump
strong wren
polar acorn
strong wren
#

oh no wait

#

like 1200% increase right:

summer stump
strong wren
#

ITS A BIG INCREASE

#

ok

#

number big

summer stump
#

What numbers are you actually plugging in?

strong wren
#

im just going to remove the NumberMult

#

i can just say 1.2f without using a variable

strong wren
#

which is 24

polar acorn
strong wren
#

oh

summer stump
polar acorn
strong wren
#

nope

strong wren
#

uhjm

#

wait thats quite interesting

#

i buy one for 20 coins then in creses to 220

#

then it deacreases to 29

#

wait but the price isnt changing tho? its a visual bug

#

the numbers are off, the price in the inspector is 50 whilsts its telling me that the price is 42 ingame

#

MerchantPriceCounter.text = MerchantPrice.ToString("Price " + MerchantPrice);

#

this line is giving me trouble

strong wren
#

but why is it incorrectly displaying the number

polar acorn
#

When that line runs, it will set the text to whatever MerchantPrice is at the time

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

public class Shop : MonoBehaviour
{
    public PlayerStats PS;
    public int NursePrice = 50;
    public int ZoologistPrice = 50;
    public int MerchantPrice = 20;
    public TMP_Text NurseCounter;
    public TMP_Text NursePriceCounter;
    public TMP_Text ZoologistCounter;
    public TMP_Text ZoologistPriceCounter;
    public TMP_Text MerchantCounter;
    public TMP_Text MerchantPriceCounter;
    public void BuyingMerchants()
    {
        if (MerchantPrice <= PS.Coins)
        {
            PS.Coins -= MerchantPrice;
            PS.Merchant++;
            PS.DMG++;
            MerchantCounter.text = PS.Merchant.ToString("You Have " + PS.Merchant);
            MerchantPriceCounter.text = MerchantPrice.ToString("Price " + MerchantPrice);
            MerchantPrice = Mathf.RoundToInt(MerchantPrice * 1.2f);
        }
    }

    public void BuyingNurses()
    {

    }
    public void BuyingZoologist()
    {

    }
}
#

this is my whole code

#

ignore the nurses asnd zoologist

summer stump
strong wren
#

its not a math bug the math is correct its displaying the wrong numbrr

polar acorn
strong wren
polar acorn
summer stump
strong wren
#

yes that is indeeed what i meant

polar acorn
strong wren
# polar acorn what did you actually change
{
    MerchantCounter.text = PS.Merchant.ToString("You Have " + PS.Merchant);
    MerchantPriceCounter.text = MerchantPrice.ToString("Price " + MerchantPrice);
    PS.Coins -= MerchantPrice;
    PS.Merchant++;
    PS.DMG++;
    MerchantPrice = Mathf.RoundToInt(MerchantPrice * 1.2f);
}```
#

put the counters to the top

polar acorn
#

You're still changing the text before you change the value

#

top to bottom

strong wren
polar acorn
strong wren
#

i want it to be put in a way that makes the code work

polar acorn
#

Only you know what you want the code to do

strong wren
strong wren
#

but wait

polar acorn
strong wren
#

that would break the game

#

nvm

summer stump
#

I would put the numbers to private. If the text is changing that much then something might be changing them

And you would likely want the text to update LAST inside the if statement
You put it first, which is the opposite of what digi was suggesting before

strong wren
#

once the game starts the prices wont be set til i buy a merchant which is not possible as the prices arent set yet or it would be as i manually set them to 20

strong wren
#

you know that

#

wait it seemed the change smth

#

i wouldnt get o see 24 before

#

now i go to 500 before the price changes

#

that did smth

polar acorn
#

Just, think about it. If you write down a price on a piece of paper, and then you change the price, would the paper magically change to the new price?

polar acorn
# strong wren no

So, in your code, if you change the text and then change the price, would the text magically change to the new price?

strong wren
#

i fixed my mistake alr

#

@summer stump u said to put all numbers to private right?

deft grail
strong wren
#

Should i put the TMP_Text into [SerializeField] too

deft grail
strong wren
#

i do need to TMP text into inspector

#

kk

#

anways

#

do you have any clue on why my Text is displaying the wrong information sometimes?

deft grail
#

it only displays what you tell it to

strong wren
#

no thats the thing

rich adder
#

prob ur not updating the text after changing values

strong wren
#

it only shows the wwonr number sometimes

strong wren
summer stump
rich adder
summer stump
#

So something is changing the numbers, you are updating the text in the wrong place, or something else is going wrong in the logic of the code

strong wren
summer stump
strong wren
#

these are the only refrences to MerchantPrice

#

ive only used This Variable in this script too

outer cobalt
#

@rich adder i rewrote the script, works beautifully, thank you and the other guy ❤️

summer stump
#

Do you have multiples of this script?

strong wren
#

all i have are these 3

rich adder
summer stump
# strong wren no

Debug.Log($"MerchantPrice: {MerchantPrice}");

Put that at the beginning and end of th BuyingMerchants method

strong wren
#

wait i found smth interesting

#

that not supposed to be here

#

i mean its not changing the code as i am never clicking on the Zoologist

summer stump
#

I don't understand what you mean about the Zoologist

strong wren
#

look i have three charachters
nurse zoologist and merchant i am working on the merchants and this was on the zoologists

rich adder
#

is this like your first project ?

strong wren
#

technicaly 2nd

rich adder
#

what happen to doing like tetris or angry bird, this sounds complex

strong wren
polar acorn
#

that's probably fine

#

just requires math

rich adder
#

oh ok

#

thought it was rpg.
i was gonna say different classes and abilities catcrymic

strong wren
#

bro its so easy that i wrote 90% of my code and it worked with no issue

strong wren
#

its a visual glich

polar acorn
strong wren
polar acorn
strong wren
#

the text is in the same Script as everything

summer stump
strong wren
#

20

polar acorn
strong wren
#

the price is 20 as thats the defualt price

rich adder
#

make the variable a property and use only Invoke event inside the set to update UI thinksmart

strong wren
#

thats litterally it

polar acorn
rich adder
#

haha yeah this would be too much of a challenge

polar acorn
strong wren
polar acorn
#

before clicking anything

polar acorn
# strong wren yes

So, if this is the only place you're changing the text, and the text becomes incorrect after clicking on it, then the price you're setting this to is incorrect

strong wren
#

idk if this helps

strong wren
#

it goes on for like 3 clicks as normal

summer stump
# strong wren ok

Did you add the debug.log I wrote for you in the two places I told you to put it?
If so, show the console when the game runs

strong wren
#

then boom 500

strong wren
#

the price increased normaly

polar acorn
strong wren
#

gimme 20 seconds i deleted them 😭

astral grail
#

What's wrong with that? (NullReferenceException)
1 script:
public void DropItem()
{
foreach (Transform child in transform)
{
child.GetComponent<Spawn>().SpawnDroppedItem();
GameObject.Destroy(child.gameObject);
}
}
2 script:
public class Spawn : MonoBehaviour
{
public GameObject Item;

private Transform Player;

private void Start()
{
    Player = GameObject.FindGameObjectWithTag("Player").transform;
}
public void SpawnDroppedItem()
{
    Vector2 PlayerPos = new Vector2(Player.position.x + 2, Player.position.y - 1);
    Instantiate(Item, PlayerPos, Quaternion.identity);
}

}

strong wren
slender nymph
eternal falconBOT
astral grail
strong wren
polar acorn
strong wren
#

for like 5 clicks

polar acorn
strong wren
#

but once i click on it with 50 coins it goes away

polar acorn
# strong wren

Now click it one more time and show this screenshot again

strong wren
polar acorn
strong wren
#

which is wierd

polar acorn
#

logs and text

#

just like the last image

#

you don't need to circle it

strong wren
#

to late

strong wren
polar acorn
polar acorn
# strong wren

Whenever it's showing the wrong number, show a screenshot of the inspector for this text component

strong wren
#

wait i found something wierd

polar acorn
strong wren
#

so when i got 500 coins then i had to actually pay 50 coins when i had to pay 60 coins i had the bug with 600 coins

polar acorn
#

What the hell is this

strong wren
#

now i need to pay 103 and it shows as 11033

strong wren
polar acorn
#

why are you using the number inside of its own format string

rich adder
#

nailed it

#

nice catch

summer stump
#

Dang, I saw that earlier and then got distracted! Dropped the ball
Thought process: "huh, that looks wei- oh I have to do this other thing"

strong wren
#

tbh i enjoy that yall are not screaming at me anymore

polar acorn
summer stump
rich adder
#

haha yeah since its string the ide doesn't throw an error lol

strong wren
polar acorn
strong wren
#

if i remove the 2nd Merchantprice it removes the counter

#

but if i delete PRICE and Merchantprice theres only THE counter

polar acorn
#

You don't want to put anything in there

strong wren