#💻┃code-beginner

1 messages · Page 399 of 1

willow scroll
#

Yeah, that's what I told you about doing it multiline. The code is too big, so use a paste site

wooden socket
#

AH valid mb

willow scroll
#

Also not sure how you were able to make so many inline code lines so fast

wooden socket
#

wdym

#

i copieid my code over

#

from VScode

rich adder
#

i think it just never closed until they did threebackticks

wooden socket
#

found it lol

rich adder
#

this problem is like the plague

willow scroll
rich adder
#

how do we kill it

wooden socket
#

lemme send my other code

rich adder
#

are you sure also your text is Text not Text mesh Pro

#

do you have errors

wooden socket
#

nope

#

its text

rich adder
#

why is everyone using the legacy Text

wooden socket
#

lemme send the code for actually adding the score

rich adder
#

put a log and debug the collision

wooden socket
#

the collision does work, it even adds the score

rich adder
wooden socket
#

i just dont know how to make it save the score and post it on the other scene

willow scroll
rich adder
#

oh I misunderstood, thought you said you dont see the text

willow scroll
#

In the first case, you don't even have to save it, as you already have a Singleton

wooden socket
#

the score should go away when leaving the game, but show when the scene goes to the leaderboard

#

i already got an online leaderboard thing

wooden socket
#

wdym

rich adder
#

if you already have an online leaderboard just save it there..

wooden socket
#

no thats not what I mean

#

i want the score to appear as text IN that scene

#

like before its saved

late verge
willow scroll
rich adder
wooden socket
#

the score is coming from the scene where the game actually is, and is then displayed on the leaderboard scene

rich adder
#

so whats the problem ?

wooden socket
#

before it is ACTUALLY saved to the leaderboard

#

the problem is iti isnt displaying on the scene

#

okay wait lemme send a ss

willow scroll
wooden socket
#

yes

willow scroll
#

This seems pretty vague to me

wooden socket
willow scroll
wooden socket
#

when the scene loads, the new text in the middle disappears

rich adder
willow scroll
wooden socket
#

idk how I would do that

wooden socket
willow scroll
rich adder
raw token
rich adder
#

since its a singleton

#

how did you link the Text in scene 2 to the Text

late verge
willow scroll
#

You create a method for displaying the text and call it on new scene loaded

neon ivy
#

is there a way to use GetKey / GetKeyDown when not having the window focussed? it doesn't seem to work for me. I have "run in background" selected

wooden socket
wooden socket
#

in scene 2

#

should I delete that?

willow scroll
rich adder
#

how's that answer How you linked the ScoreManager from scene 1 to Text in scene 2

wooden socket
#

idk if I even did do that

raw token
rich adder
#

you def have null refs then unless you never call AddPoint there
then you need to pass the reference properly

neon ivy
#

I want a second opinion -3-

wooden socket
#

should I have delete other scripts I made that make the objects consistent

#

i think I should

#

like the text camera and canvas

#

i made 3 seperate scripts

#

i dont wanna bloat my project lol

rich adder
wooden socket
#

they are now gone

willow scroll
# neon ivy D: that's not a satisfactory answer :C

Well, it doesn't seem to be something you can control. You cannot really tell the window to be focused, because the Unity user is the one doing it. Note that these issues won't happen when playing your game outside of the Unity editor.

Second option: ignore.

rich adder
neon ivy
wooden socket
rich adder
willow scroll
neon ivy
#

that's what I thought

wooden socket
#

okay I put it under the canvas

willow scroll
wooden socket
#

should I test it?

rich adder
wooden socket
#

okay

rich adder
raw token
# late verge

I'm not great with render pipeline stuff... but maybe the Skybox itself is scuffed. Try changing that to Solid Color and see if the issue disappears. If so, you might need to figure out what's up with the skybox, or maybe just find a new one

wooden socket
#

lmk when I should test, ur taking the lead here and im following

wooden socket
rich adder
wooden socket
#

should I delete this

rich adder
#

don't blindly follow

neon ivy
wooden socket
#

like the scoreText

wooden socket
eager spindle
# late verge

this usually happens when skybox type is set to none

wooden socket
#

lol

rich adder
late verge
willow scroll
# neon ivy that's what I thought

Also not sure how you tested it. Simply opened the game window? When doing so, your tab is not focused, so you first have to click somewhere within the game window

eager spindle
#

so it doesnt clear the last buffer

wooden socket
#

shit im sorry

#

OH

eager spindle
#

if you changed any editor settings that somehow got rid of skybox then revert it

rich adder
wooden socket
#

i read that backwards

#

im sorry

neon ivy
wooden socket
#

okay I did it

#

sorry, yestarday I worked on this for like 15 hours

#

like the whole game

rich adder
wooden socket
#

can I hide it in the first scene?

#

and not the last one

rich adder
#

you can sure

wooden socket
#

thats just the checkbox right?

late verge
rich adder
wooden socket
#

okay valid

rich adder
#

which leads you back into detecting when scene changed occurred

wooden socket
#

okay

rich adder
#

the alternative is have Other script inside Scene 2 detect when there is a ScoreManager in awake/Start
then just grab score data for Text component / Canvas in that scene

wooden socket
#

should I send my code that detects when lives = 0?

willow scroll
# neon ivy I need it to work without being focussed on the game window though...

Don't want to tell you that it's definitely impossible, but some time ago I was not able to find any way to do it, so it doesn't seem like you're able to "force" the player to focus on your game.
It seems like you should use the Application.isFocused boolean in suitable parts of your code, and (or) wait until the button, which activates the game, is pressed.

rich adder
wooden socket
neon ivy
willow scroll
wooden socket
#

okay so whats next

rich adder
neon ivy
wooden socket
#

i dont just

#

copy it in right?

#

that would make 0 sense

rich adder
#

again, thats needed if you don't go with Option2

wooden socket
#

yea ik

willow scroll
wooden socket
#

which do u reccomend?

neon ivy
#

trying to find stuff about it

rich adder
wooden socket
#

okay I will do that

raw token
rich adder
# wooden socket okay I will do that

If the UI Text is only meant to live on scene2 but scoremanager needs to be in multiple scenes, no point on having it carry canvas with it here..

wooden socket
#

okayy

willow scroll
bleak glacier
#

I hate using this channel so much but I don't understand what I'm missing here. This seems like it should work but it doesn't. Where have I gone wrong?

using System.Collections.Generic;
using UnityEngine;

public class InventoryCloseButton : MonoBehaviour
{
    bool isOpen = false;
        public void ButtonPressed()
    {
        GameObject.Find("Inventory").GetComponent<Canvas>().enabled = false; 
        isOpen = false;
    }

    void Start()
    {
      GameObject.Find("Inventory").GetComponent<Canvas>().enabled = false;  
      isOpen = false;
    }

     void Update()
    {

      if (Input.GetKeyDown("e") && isOpen == false)
      {
      GameObject.Find("Inventory").GetComponent<Canvas>().enabled = true;  
      isOpen = true;
      } 
      

      if (Input.GetKeyDown("e") && isOpen == true)
      {
        GameObject.Find("Inventory").GetComponent<Canvas>().enabled = false; 
        isOpen = false;
      }
    }
}
polar acorn
#

What are you expecting to happen that isn't happening

#

or what is something that you're not expecting to happen but is

bleak glacier
wooden socket
bleak glacier
#

It works without the bools and the second GetKeyDown though

#

But I want e to close the canvas on the second press

rich adder
wooden socket
#

so how do I edit the code to where it detects when it appears

rich adder
willow scroll
rich adder
#

assuming they're not gameobject disabled

wooden socket
#

okay so im going to removve that

#

okay i will not

ionic zephyr
#

If my craftying system is based on the number of objects you have on the crafting station (for example: If I place 3 sticks and 2 stones it will craft a hammer, the order in which this objects are placed does not matter just the number of them that are in the station at that moment). I am also using Receipt ScriptableObjects but what should those objects have, any ideas?

willow scroll
rich adder
wooden socket
#

im sorry

neon ivy
wooden socket
#

i meant make them unrelalted

polar acorn
# bleak glacier It works without the bools and the second GetKeyDown though

So, read through the Update function in the order the code runs:

  1. Check if you pressed e this frame. For the sake of demonstration, let's assume yes.
  2. Check if isOpen is false. Let's assume it is.
  3. Enable the canvas (you should cache this reference please for the love of god don't use a find in update)
  4. Set isOpen to true
  5. Check if you pressed e this frame. As established in step 1, you have
  6. Check if isOpen is true. As established in 4, it is
  7. Disable the canvas
  8. Set isOpen to false.

There is no possible outcome in which the canvas is enabled when this function ends

rich adder
#

ScoreManager should only Keep track of score, or modify it

#

it should not deal with UI

wooden socket
#

okay unparented

willow scroll
wooden socket
#

now which script do I put where

#

i put the script in the leaderboard right?

rich adder
wooden socket
#

like leaderboard scene

wooden socket
rich adder
wooden socket
#

ok

#

put the script that changes UI which iirc is scoreManager in a new empty?

raw token
# willow scroll Is it really possible? When having 2 windows opened at the same time, and e.g. s...

I assume you could do that, yeah... Like you can definitely capture input events regardless of which window is consuming them. And you could forward the events to another window if you have it's window handle, or possibly process ID?

This isn't a realm I've explored to a great degree, but I believe it's all plausible. Absolutely no clue how to accomplish within a Unity game though, or even how you make calls directly to system libraries 😁

willow scroll
rich adder
wooden socket
#

okay

ionic zephyr
rich adder
dusty shell
#

could anyone explain how'd use raycast to check if the player is colliding with a floor or wall

wooden socket
#

so im making a new script

#

wait no i have one iirc

#

nvm

rich adder
# wooden socket so im making a new script

it needs to be a script in scene2 so yes its a seperate script as I said already

    ScoreManager scoreManager;
    private void Awake()
    {
        scoreManager = ScoreManager.instance;
        if (scoreManager)
        {
            myUiText.text = scoreManager.score;
        }
    }```
willow scroll
polar acorn
# dusty shell could anyone explain how'd use raycast to check if the player is colliding with ...

Raycast in the direction the player is moving. RaycastHit has a normal property to get the normal vector of the surface it hits.
https://docs.unity3d.com/ScriptReference/RaycastHit-normal.html

You can use the dot product of that normal with Vector3.up. If the value is close to 1, it's a floor. If it's close to 0, it's a wall. If it's close to -1, it's a ceiling. You can adjust the allowable difference in the dot product to change how sloped of a surface you want to count as what

willow scroll
polar acorn
wooden socket
#

my UItext should be renamed to what i called the text object? I called it displayText

#

ok that didnt work

eager spindle
wooden socket
#

doesnt exist in current context

ionic zephyr
#

how can I check if an object is craftable (using Receipt ScriptableObjects) only based in the quantity of each object inserted in the Crafting station?

rich adder
eager spindle
#

oh

willow scroll
# wooden socket ok that didnt work

Didn't work? Have you not succeeded in renaming the text object to "displayText"?
Also it seems like all the texts can be called "displayText"...

wooden socket
#

WAIT

rich adder
wooden socket
#

THATS AN EMPTY NOT TEXT

rich adder
#

show what you actually wrote

bleak glacier
polar acorn
wooden socket
willow scroll
ionic zephyr
willow scroll
eager spindle
eager spindle
rich adder
eager spindle
#

in fact cant you just add a bool to say if its craftable

wooden socket
polar acorn
eager spindle
rich adder
wooden socket
#

ok

polar acorn
#

There's nothing in the script named displayText

rich adder
#

scripts have 0 knowledge of whats in the scene hierarchy

eager spindle
#

you made a thing in the scene called displayText, but your code dont know what displayText is

rich adder
#

naming the object displayText doesn't magically appear in code lol

swift crag
#

that would be a nightmare

wooden socket
#

so i make a new field called what

rich adder
#

All my Container objects 🥵

polar acorn
eager spindle
rich adder
eager spindle
#

dumb name but theres an explanation for it

rich adder
polar acorn
swift crag
#

A field needs two things:

  • the type: what it holds
  • the name: how you refer to it
#

The name does not matter, as long as C# allows you to use the name at all

eager spindle
dusty shell
rich adder
#

just make sure the type is correct @wooden socket

eager spindle
#

and if the beam hits something then you can retrieve it

wooden socket
rich adder
dusty shell
eager spindle
rich adder
# wooden socket

at this point you need basic c# courses pinned in this channel

wooden socket
#

idk how to make a field im sorry

eager spindle
#

it depends on what you want, but in your case you can make it from the center of the player

eager spindle
wooden socket
eager spindle
#

it will save you a lot of brai ncells

rich adder
eager spindle
eager spindle
rich adder
#

instead of just guessing it

eager spindle
#

This complete C# tutorial for beginners will take you from the basics of C# programming to advanced concepts.

✏️ Course developed by @CoffeeNCode

Learn more from the course creator: https://www.udemy.com/course/csharp-complete-masterclass/?couponCode=FREECODECAMP

⭐️ Contents ⭐️
(0:00:00) Introduction
(0:01:56) Installing Visual Studio 2022
(...

▶ Play video
#

boo

#

c# tutorial

wooden socket
#

okay got it

eager spindle
#

freecodecamp saved me a lot

wooden socket
#

i didnt know it was called a field

#

i know what that does though

#

mb

rich adder
eager spindle
#

as a programmer you learn everything by googling

dusty shell
rich adder
#

manual always comes first

eager spindle
wooden socket
#

so in my case its

#

public string Text displayText

#

because its a string of text

rich adder
#

at this point you're just guessing

wooden socket
#

im not

eager spindle
# rich adder manual always comes first

i find it interesting how the first programmers who had no internet could only consult manuals and maybe a few $200 books, now everything is so convenient

wooden socket
#

im genuinely trying to figure this out

eager spindle
rich adder
#

no one is saying to learn the whole language overnight, but the basics are needed

wooden socket
#

i just am worried to google stuff because I want to make a career in game design and i think it would look bad to google stuff so I want to remember it all

#

is that wrong/unprofessional?

eager spindle
#

string, int, float, double, bool are primitive types.

TextMeshProUGUI, MeshRenderer, Rigidbody are all classes. classes are made off primitive types

eager spindle
#

you need to google to survive

rich adder
eager spindle
#

there is no memorisation in programming

wooden socket
eager spindle
languid spire
wooden socket
#

thank you

rocky canyon
#

the world before the internet was almost a better place.. bitter - sweet the internet was

rich adder
eager spindle
#

im too young for that 😴

rich adder
raw token
wooden socket
#

okay so no more errors, but the text still isnt appearing

eager spindle
rich adder
wooden socket
#

the script is on the text object under the canvas called displayText

rocky canyon
rich adder
#

there are serveral steps involved

wooden socket
eager spindle
#

could you also show the inspector panel of the gameobject that the script is attached to?

eager spindle
rich adder
rocky canyon
rich adder
rocky canyon
#

ooof-sicles

rich adder
#

i literally spoon fed them the way to do it and they copied wrong

rocky canyon
#

see what happens when u do that

#

when i do that im usually about to bolt 🤣

rich adder
eager spindle
#

i will give a step by step breakdown of what you need to do.

  1. add a public Text to your class.
  2. set the text of your Text to your score, as a string.
  3. in your scene, go to the gameObject that the script is attached to. drag the Text in your scene into the field
wooden socket
#

im sorry if im messing this up a lot

eager spindle
#

issok we will all learn

rocky canyon
#

no worries.. thats how u learn

rich adder
eager spindle
#

to delve straight into unity is a big undertaking, I'd rather do projects in c# without unity first

wooden socket
#

should the script be on an empty or the ACTUAL text object

eager spindle
rich adder
#

we said already were it belongs..

#

scroll up

rocky canyon
#

as long as u drag in the Gameobject the Text is on into the slot u declaared in the inspctor

#

it doesn't matter where the script is

#

most times it makes most sense to include it on the object its manipulating the most

rich adder
#

ideally you dont want to put scripts on UI elements

rocky canyon
#

like u'd put a rigidbody controller on the object w/ the rigidbody.. vs putting it on a random empty

severe lynx
#

how come this isnt working?

rich adder
#

they are difficult to find

ionic zephyr
#

If my crafting system is based on the number of objects you have on the crafting station (for example: If I place 3 sticks and 2 stones it will craft a hammer, the order in which this objects are placed does not matter just the number of them that are in the station at that moment). I am also using Receipt ScriptableObjects but what should those objects have, any ideas?

severe lynx
#

im trying to figure it out

rich adder
#

GameObject is not LogicScript

rocky canyon
eager spindle
rich adder
#

the function returns GameObject

severe lynx
eager spindle
#

how do you get a LogicScript from GameObject

rocky canyon
#

GameObject is a type (could be any gameobject)

#

gameObject however is this gameobject.. the one ur working the script on

rich adder
eager spindle
#

or what any of your code looks like

wooden socket
#

okay we are getting closer. now it just says "NEW TEXT"

rocky canyon
rich adder
rocky canyon
#

^ yes this too.. but i find as a beginner keeping gameObject around tends to help solidfy the idea

#

same with this

#

but people argue thats not needed either.. which its not.. but 🤷

eager spindle
severe lynx
#

oh, logicscript isnt gameobject

#

i see

ionic zephyr
eager spindle
rich adder
eager spindle
#

we dont know what Receipt is

raw token
#

Is Receipt a recipe?

eager spindle
#

even if its misspelled as Recipe we dont know what it has

severe lynx
ionic zephyr
eager spindle
rich adder
ionic zephyr
eager spindle
rocky canyon
wooden socket
#

since you said not to usually add scripts to text, I made a new empty

ionic zephyr
rich adder
#

this is wrong though

severe lynx
rich adder
#

idk how many times i had to say that

severe lynx
#

sorry for my impatience lol, thanks for putting up wit me

eager spindle
rocky canyon
#

altho thats a hella long line of code 😄

rich adder
eager spindle
#

changing the Text's text will let you change the script

eager spindle
rich adder
#

ScoreManager only carries the score

#

they are putting UI in the wrong script

rocky canyon
#

gonna make extra dependencies for no reason

rich adder
#

Scoremanager is a DDOL having the reference will just break

rich adder
#

thats why its been said from the beginning the UI Text belong in its own script in scene 2

eager spindle
#

I shouldve known

rich adder
#

I mean you kinda started interjecting without seeing the original problem lol

eager spindle
#

why not use a static variable for the score rather than introduce ddol

orchid pewter
#

yo can someone help me rq, im trying to load up smt i made from a video, and i copied the exact script he said, i can ss if someones willing to help

rocky canyon
#

especially if its a system

orchid pewter
#

ill send ss 1s

rich adder
#

and they also did a DDOl

eager spindle
wooden socket
#

wait shit lemme clarify

cosmic dagger
rocky canyon
#

u can static a variable.. im good with that.. but a DDOL is better for a Manager type script

rich adder
orchid pewter
#

its saying this, i can send screenshot of scripts

rocky canyon
#

i can tell now yes

wooden socket
#

this is in the new script i made

eager spindle
orchid pewter
rocky canyon
#

but not a screenshot

#

use !code

eternal falconBOT
rich adder
rocky canyon
#

one of these methods

rich adder
#

and you still copied the awake wrong..

cosmic dagger
rich adder
#

at this point Im not wasting my time goodluck to ya lol

#

go learn the basics

wooden socket
eager spindle
orchid pewter
rocky canyon
#

i'll spit out some code/logic from time to time.. but yea i think u need a bit more understanding of the basics

orchid pewter
#

1s im sending script

eager spindle
#

unity is a strange place theres multiple ways to do one thing

orchid pewter
#

!code

eternal falconBOT
cosmic dagger
orchid pewter
#

ok

eager spindle
#

or to a manager?

rocky canyon
#

irrelevant

wooden socket
#

displayScore is added to the text component

cosmic dagger
raw token
# ionic zephyr Thats what I want to discuss, could you give me any idea?

I guess at the very least, it needs to identify the required items and their quantities, and the item which they produce.

So maybe like a

[Serializable]
struct RecipeIngredient {
  public ItemSO Item;
  public int Quantity;
}

public RecipeIngredient[] Ingredients;
public ItemSO Product;

...or similar

eager spindle
rich adder
cosmic dagger
wooden socket
#

scoreManager is not a parent of the canas as well

#

let me add the under start part

polar acorn
#

just use ScoreManager.instance

rocky canyon
#

ohh digi in the house

eager spindle
#

changing displayText.text lets you change the text shown on screen. you can use this to display the score as well.

rich adder
eager spindle
#

the article that I sent earlier also has a lot of cool stuff you can play around with

orchid pewter
cosmic dagger
rocky canyon
#

ohh god.. did u not read the bot message?

eternal falconBOT
orchid pewter
#

its not letting me send full

rocky canyon
#

people on mobile can't see those things

#

use a link website ^

cosmic dagger
#

i can't see on mobile . . .

rocky canyon
#

theres 5 or 6 of em posted

cosmic dagger
#

plus there are no line numbers . . .

rocky canyon
#
private void CalculatePlayerMovement(){
    _movementVelocity.set(_playerInput.HorizontalInput,0f,_playerInput.VerticalInput);``` heres the good part
#

every one of his errors are on that line i believe

orchid pewter
#

wtf

rich adder
orchid pewter
#

mb

polar acorn
#

!code

eternal falconBOT
rocky canyon
#

use one of these just for ease

eager spindle
#

i wanna try my hand at making a bot that auto pastes stuff into the paste site

orchid pewter
# polar acorn !code

sorry, i cant understand it, i went to the 2nd website pasted the code and idk what to do

rocky canyon
rocky canyon
#

and then they'll talk to the Admiins

rocky canyon
#

oh if they let use have bots in here it'd be OV.. i'd have a bot response for everything imagineable

orchid pewter
#

this?

polar acorn
#

I kind of liked it better when the bot just deleted unformatted code

eager spindle
orchid pewter
#

lets gooo

rich adder
orchid pewter
#

i did it

polar acorn
wooden socket
#

okay im REALLY close. the "this text is working" part worked. I just need to learn how to pass the value from the scoreManager script into a string and add it to the points

eager spindle
wooden socket
#

like the points part of the text object

cosmic dagger
rich adder
#

until the next problem UnityChanLOL

cosmic dagger
#

or a link to it . . .

eager spindle
#

do you know how to use scoreManager.instance?

orchid pewter
polar acorn
rocky canyon
#

scoreManager.instance.variableYouWant = newValue;

eager spindle
cosmic dagger
rocky canyon
#

Vector.set <--

eager spindle
#

also line 21, *- is not a valid thing

polar acorn
wooden socket
#

okay I think you figured out the problem. inside of scoreManager, there some stuff with UI and thats not good

https://hastebin.com/share/ozucocitah.csharp

eager spindle
rocky canyon
#

scoreManager.instance.score; 😉

orchid pewter
eager spindle
polar acorn
rocky canyon
polar acorn
#

What were you intending that operation to be?

orchid pewter
#

wait let me make this easier imma send a ss, of the other person

orchid pewter
eager spindle
wooden socket
#

okay

rich adder
eager spindle
#

c# things: how to convert your variable to string?

cosmic dagger
rich adder
rocky canyon
#

@orchid pewter one error is Capitalization... its Vector.Set not Vector.set

eager spindle
orchid pewter
# polar acorn What are you _trying_ to do

im super new to this im trying to make a 3d game, from a course i bought from udemy, i just did everything he said, and copied everything, this was supposed to be a player movement

#

1s yall

rocky canyon
#

ur making simple mistakes

eager spindle
#

udemy course A_HuDead

rocky canyon
#

misspellings and capitalization errors

cosmic dagger
rocky canyon
#

oh i know it is

eager spindle
#

all the udemy courses jump straight into unity and want buyers to wing it in c#

rich adder
orchid pewter
cosmic dagger
#

i've (we've) been waiting for their code for what seems like forever . . .

eager spindle
#

theres a raccoon among us

cosmic dagger
#

that's it, i'm making a udemy course. all GetComponent and Find calls . . .

rocky canyon
#

Bandit 😉

rich adder
orchid pewter
#

i cant send ss, it turns dark yall

rocky canyon
#

well i alrady mentioned ur main error

polar acorn
#

Then I'll just pre-emptively post this anyway

#
"I did it exactly like the tutorial so why does theirs work and mine doesn't" counter:
Number of times it wasn't exactly like the tutorial: 167
Number of times it was exactly like the tutorial: 5
Number of times the code literally did not exist: 1
2022-07-19 to 2024-06-26
cosmic dagger
orchid pewter
rocky canyon
eager spindle
rich adder
#

learning C to use C# is just plain a waste of time

eager spindle
rocky canyon
eager spindle
#

know a little here and there

rocky canyon
orchid pewter
polar acorn
orchid pewter
#

velocity?

rocky canyon
#

movementVelocity is ur vector

polar acorn
#

Every one of these is one I personally witnessed

eager spindle
#

my salutations

orchid pewter
#

ahh ok thanks, sorry for not understanding shi btw, im very new to this

rocky canyon
#

_movementVelocity.Set(otherVector);

#

i believe thats it. i've never set a vector that way before personally

orchid pewter
#

ok, i reload now ye?

eager spindle
#

yea we all just vel = new Vector3(1,1,1)

rocky canyon
#

well save and let unity recompile.. it'll clear atleast (1) error

cosmic dagger
rocky canyon
wooden socket
#

im really close again. im sorry if im being annoying or unhelpful. my code for scoreManager looks like this. I even converted the int to a string, but it still says new text. What am I doing wrong :( https://hastebin.com/share/rabubiqomo.csharp

eager spindle
eager spindle
#

creating a new object just like that

rocky canyon
wooden socket
rich adder
wooden socket
#

wtf how

rich adder
#

that site sucks

wooden socket
rich adder
#

use gdl

wooden socket
#

THERE we go

cosmic dagger
rocky canyon
#

well i meant. i do vel = myVector;
i wasn't necessarily talkin about creating a new vector

eager spindle
rich adder
eager spindle
rich adder
#
  public static implicit operator ScoreManager(string v)
    {
        throw new NotImplementedException();
    }
}

``` wtf goin here
wooden socket
#

for some reason it still says "NEW TEXT"

rocky canyon
#

ohhhhh i see what ur saying

wooden socket
#

wtf

#

it added that on itself

rich adder
#

this is the wrong script

wooden socket
#

oh i must have misclicked

eager spindle
cosmic dagger
rich adder
#

there is no point of storing Scoremanager in ScoreManager thats nonsense

eager spindle
willow scroll
#

Are you still trying to display the text . . .

rich adder
#

bro fr

willow scroll
cosmic dagger
wooden socket
#

could it be because of scoreText.scoreText?

eager spindle
rich adder
rocky canyon
rich adder
wooden socket
#

dude

#

im really not

#

thats just rude

rich adder
#

explain that

eager spindle
#

your ide needs to be set correctly

wooden socket
#

i told you I just removed it

eager spindle
rocky canyon
cosmic dagger
rich adder
raw token
wooden socket
wooden socket
#

im sorry let me undo it

rich adder
#

you see wat I mean

#

thats literally troll

eager spindle
# wooden socket i told you I just removed it

let's explain the science here.

ScoreManager's ScoreText is set right now. however, when you switch a scene, ScoreManager's ScoreText no longer exists. it is null.

do you still have displayScore?

rich adder
#

you're just adding shit to scripts just for shits n gigs it seems

eager spindle
#

could you use displayScore instead of ScoreManager's scoreText to display stuff

rich adder
#

blind leading the blind

eager spindle
rich adder
#

does that click?

spiral raven
wooden socket
rich adder
eager spindle
rich adder
#

literally hand fed the solution and they still write their own lines just because ?

eager spindle
spiral raven
rich adder
willow scroll
eager spindle
#

do you remember what's in displayScore

#

the Text that you had

winged seal
#

Hello i am New to Unity im trying to make a mod For My summer Car. I have the Model But im doomed i cant code any tips or anyone can help?

wooden socket
#

man im sorry. ive been awake for over 15 hours working on this game and im really tired and just want to finish this part and then ill go to bed

willow scroll
eager spindle
rich adder
#

you being tired should not be a waste of time for us

summer stump
summer stump
wooden socket
eager spindle
# winged seal Yes.

its very helpful to know how to actually use unity now that you've decompiled the game, though we cant discuss that here you should know c# before you continue at all. focus on learning c# before learning unity, then learning to mod

summer stump
winged seal
eager spindle
#

lua is different tbf

summer stump
winged seal
#

Yes.

wooden socket
#

whats the command for the paste stuff

summer stump
#

Use that site

eager spindle
#

how do you convert the scoreManager's score to a string

wooden socket
#

okay in the update I wrote displayText.text = and now I think thats how you do it but i dont know what to put here

rich adder
#

why is it in update..

eager spindle
#

lets save us all the sanity for now

eager spindle
wooden socket
eager spindle
#

know the policy here: we will not give you whole lines of code but point you in the direction instead

rich adder
#

ScoreManager scoreManager; isn't needed anymore

wooden socket
rich adder
#

ScoreManager can just be accessed when you need it with .instance

eager spindle
wooden socket
#

is this the part of recieving the score or passing it

rich adder
wooden socket
#

ok

eager spindle
#

I suppose we're receiving the score? we want to receive the score and use it in the text

wooden socket
#

im really sorry

#

i know i look really stupid

eager spindle
#

come back

rich adder
#

just stubborn

#

not stupid

wooden socket
winged seal
eager spindle
#

in the beantime we should talk about the rubber ducky method. take your nearest rubber ducky or person, and explain every line of code you have to them

rich adder
#

You refuse to learn for 30 mins how to properly do some c# basics, instead you rather waste hours on one thing you barely understood

winged seal
#

thanks

eager spindle
rich adder
#

Oh god those long format C# videos

#

yuck

wooden socket
#

please tell me how to do it

eager spindle
rich adder
rich adder
#

they are delivered in short bursts

eager spindle
summer stump
#

Youtube is simply a bad place for learning code

eager spindle
rich adder
eager spindle
rich adder
#

what

wooden socket
#

ohh then I use ToString

rocky canyon
#

if its not a string originally u have to convert it to a string yes

eager spindle
eager spindle
#

now you got the string you can set the text to it

rich adder
languid spire
rocky canyon
#

terminology is super important in communication

#

w/o it = wasted time

rich adder
#

I mean dude is reading API expecting "non nerd terms"

wooden socket
rich adder
#

its from the docs

polar acorn
rich adder
#

I can see the references of API on the side

eager spindle
rocky canyon
rich adder
ivory bobcat
eager spindle
#

it is still from ms learn though

#

i want to find a way to exclude pages like these from my searches

rich adder
summer stump
wooden socket
#

i just dont know what tis line is

#

this

#

in the Awake

spiral raven
eager spindle
serene acorn
#

All the "base unity" functions such as OncollisionEnter() come from making a script inherit from monoBehavior right?

Is there any "unity custom function" that doesn't come from there?

eager spindle
wooden socket
#

like this?
scoreManager.ToString() = ScoreManager.instance;

#

OHG

rich adder
#

bro is trollin

rocky canyon
#

in the script that changes the text.. u can access the gameobject

wooden socket
#

wait gimme a se

spiral raven
serene acorn
#

Same for update,start, fixed update...

eager spindle
rocky canyon
#

theTextUrChanging = ScoreManager.instance.score.ToString();

serene acorn
summer stump
rocky canyon
#

^ read the lines of code in pieces.. this.this.that

eager spindle
#

but yes

polar acorn
wooden socket
#

scoreManager doesnt exist in the current context now

serene acorn
#

So I can check monoBehavior and see what functions do I have in unity

summer stump
rich adder
summer stump
#

But there are methods on other types as well of course

serene acorn
summer stump
#

This is called the "api"

ivory bobcat
rocky canyon
wooden socket
#

okay I added ScoreManager scoreManager back bcs someone told me to delete it earlieir

eager spindle
rich adder
spiral raven
# rich adder bro is trollin

Sorry for pointing my "let's behave" finger at you earlier. They should take a rest and come back to give it a try again later 🤓.

polar acorn
serene acorn
# eager spindle yeah

K thank, I was just a bit confused because I thought something like "OncollisionEnter" would be inside a collision component

#

Like boxcollider2D.oncollisionenter()

eager spindle
serene acorn
#

Or something like that

wooden socket
rocky canyon
#

it goes After the number or int or float or w/e it is ur wanting to change to a string

serene acorn
rich adder
eager spindle
serene acorn
eager spindle
#

but unity did not seperate collision from gameobject

summer stump
wooden socket
#

does it go before or after

ivory bobcat
eager spindle
serene acorn
polar acorn
eager spindle
#

you want to get the score from the ScoreManager's instance, as a string

serene acorn
#

I don't like to use "premade" functions unless is something basic

wooden socket
#

i put it there and it keeps saying it doesnt exist in the current context

ivory bobcat
#

It goes after an integer, float or some type that needs to be converted to string.

summer stump
#

You should absolutely make use of the api

wooden socket
#

AND in the scoreManager script itself it says the name scoreText also doesnt exist in the current context

serene acorn
eager spindle
#

you dont need every game developer to write the same box collider

summer stump
#

It is a callback.
Well in this case, it is a magic method using reflection, which gets a message sent

serene acorn
#

Then why wouldn't it make sense for a collider component to have the collider trigger functions inside of them?

eager spindle
serene acorn
eager spindle
#

sure

eager spindle
#

but why

#

actually no

#

you needto define it

wooden socket
#

i think fixing one will fix the other 2. Im really sorry

eager spindle
#

so you cant define the function of an object from another object

summer stump
serene acorn
wooden socket
#

do I have to make a scoreManager field?

#

i dont think I do

serene acorn
#

So it's just unity that instead of making the collision functions inside of the collider component, they did it outside of them?

eager spindle
eager spindle
raw token
summer stump
eager spindle
#

your objective is to set the Text's text to ScoreManager's instance's score as a string

serene acorn
wooden socket
#

im sorry to be that guy, but just tell me. I feel genuinely ill from how much ive worked on this straight and im very tired and I feel so badly for coming off so stupid and incompetent

summer stump
wooden socket
#

damn

summer stump
ivory bobcat
serene acorn
#

Where does "OnCollisionEnter()" come from exactly then?

polar acorn
rich adder
polar acorn
wooden socket
#

okay so heres what im trying to do

#

make the int a string

#

but i dont know where to put it

eager spindle
#

let's talk about the int first

polar acorn
wooden socket
#

from the Awake that says "scoreManager = ScoreManager,instance

eager spindle
#

wooden socket
#

*. instance

eager spindle
#

that's not an int, that's a ScoreManager

polar acorn
wooden socket
#

okay

serene acorn
eager spindle
#

the ScoreManager has the int though

wooden socket
#

im working in the displayScore script

serene acorn
#

Will check again

wooden socket
#

do i go to the scoreManager script?

eager spindle
wooden socket
#

ok

polar acorn
eager spindle
#

You already have the reference to the scoremanager

summer stump
wooden socket
#

is there anything in the void Update?

eager spindle
ivory bobcat
wooden socket
#

its like

#

the object template right

eager spindle
#

yes

rich adder
#

not a Unity object mind you

serene acorn
#

So if I reference that game object with something like

#

'''Boxcollider2d mycollider'''

rich adder
serene acorn
#

I could do something like mycollider.oncollidionenter()

rich adder
serene acorn
#

Aren't messages functions?

eager spindle
#

in this case the ScoreManager class contains a few things to use.

public class ScoreManager {
public static ScoreManager instance;
public int score;
}

the way you access something in an object is to use the .

in this case if you have a scoreManager, you can do scoreManager.score.

scoreManager is the same as ScoreManager.instance

summer stump
rich adder
eager spindle
#

so now you can use ScoreManager.instance to get the score

serene acorn
summer stump
polar acorn
# serene acorn Aren't messages functions?

They are functions called by Unity. If you have a function with that signature, Unity calls it. That's the thing I linked you to. A list of message functions and when they run

wooden socket
eager spindle
ivory bobcat
#

There are some prerequisites for having them fired though, read the docs for the specific method.

wooden socket
#

okay so in the Awake I have scoreManager.score = and thren I deleted the scoreManager.instance

#

what do I put now

polar acorn
eager spindle
ivory bobcat
wooden socket
eager spindle
polar acorn
#

This is the first I'm seeing about you wanting to change the score

wooden socket
#

no i just want the score to update with the value from another scene which is the actual game

serene acorn
ivory bobcat
polar acorn
serene acorn
#

The thing I just didn't get is why the collision managing was on unity instead of in the collider components

wooden socket
#

like something means something elsse

serene acorn
#

And yeah In the docs it says collider.oncollisionenter

rich adder
#

the rigidbodies are what send the event

serene acorn
#

But doesn't seem to refer to a boxcollider or a rigidbody

summer stump
polar acorn
long jacinth
#

yo so i wanted to add some recoil to my gun so it rotates up when it shoots but umm i dont know how to do that

wooden socket
#

x is equal to 7

summer stump
rich adder
serene acorn
polar acorn
summer stump
rich adder
serene acorn
#

So why isn't it build on those components, instead of having those functions outside of those components

polar acorn
#

Phrase your answer in the form of an imperative statement or a question

summer stump
wooden socket
#

how do I make the int a strig

#

string

polar acorn
wooden socket
#

im not trying to man

serene acorn
eager spindle
summer stump
polar acorn
eager spindle
#

🥣

serene acorn
#

Like, if I put a sprite component I would hope it to have sprite related functions

polar acorn
rich adder
long jacinth
summer stump
rich adder
polar acorn
wooden socket
#

all im asking is

#

okay wait

polar acorn
#

Which is not what you wanted to do, correct?

eager spindle
polar acorn
#

So then why were you trying to write that?

serene acorn
#

I'm not a dev

eager spindle
#

make a Vector3 where the X and y is 0, then change Z

summer stump
polar acorn
#

. in code is the same as 's in English

long jacinth
polar acorn
#

It's a possessive

#

ScoreManager.instance means "ScoreManager's instance"

eager spindle
polar acorn
#

ScoreManager.instance.score is "ScoreManager's instance's score"

wooden socket
polar acorn
#

Now, what you want to get it the score's ToString(). How might you do that

serene acorn
#

Instead of having them in a component

wooden socket
#

I just dont know where to put ToSttring()

serene acorn
#

Independently

summer stump
rich adder
polar acorn
# wooden socket I just dont know where to put ToSttring()

My messages got a bit scattered because of other conversations, so I'll put them together in one go so you can read it:

. in code is the same as 's in English
It's a possessive
ScoreManager.instance means "ScoreManager's instance"
ScoreManager.instance.score is "ScoreManager's instance's score"
Now, what you want to get it the score's ToString(). How might you do that?

ivory bobcat
wooden socket
#

its on the same line right

eager spindle
#

have a good night's sleep and do c# tomorrow 😴

polar acorn
serene acorn
#

And I suppose that most of the base unity components were also created by the engine devs

summer stump