#💻┃code-beginner

1 messages · Page 277 of 1

whole idol
#

ok i fixed that

#

still getting all these errors

timber tide
#

there should be a dot operator after the null check ?

wintry quarry
#

OnInteactAction also doesn't exist

whole idol
#

ok
TypeCache is unable to load attribute info on method Unity.QuickSearch.Providers.BoltProvider:CreateProvider (<unable to load signature>). Are you missing a reference?

timber tide
#

but your ide should be pointing it out if you have it configured like you should

wintry quarry
#

not your code

#

update all your packages

#

and regenerate the library folder (by deleting it)

#

also restart Unity

ornate lynx
summer stump
ornate lynx
#

i clicked a thousand times

#

didn't do anything

polar acorn
#

Did you do it while VS was closed

ornate lynx
#

yeah

whole idol
summer stump
ornate lynx
#

i even clicked the repaire button in the visual studio installer in case that works

ornate lynx
#

wdym?

summer stump
#

It is part of installing vs

ornate lynx
#

ah yeah i did check the game dev with unity along with unity hub

wintry quarry
whole idol
#

Now I only get 2 errors

wintry quarry
#

yep now that's just your code

#

line 20

whole idol
summer stump
whole idol
ornate lynx
summer stump
#

But alright. I dunno, sorry

ornate lynx
wintry quarry
#

Most likely your line 20 is just completely off and weird

#

and the compiler doesn't know what to do

#

Especially if it still looks like this

summer stump
ornate lynx
#

np np

#

soooo got any idea on how i can possibly fix this issue?

ivory bobcat
#

Maybe try regenerating project

ornate lynx
#

u mean recreate it?

#

ah no i did that a bunch of times

#

didn't do anything

whole idol
#

I decapitalzied the "T" though and still get the error

ornate lynx
#

shall i reinstall vs?

grand sigil
#

im having a bit of a problem. The script has a Start method which assigns a button component to the variable "button". I verified it that it actually gets the component but then when i use the variable. It says Null reference.
`public Button button;
private int desInt;
private void Start()
{
button = this.GetComponent<Button>();
}

public void AddListener(int index, SideBarManager insideBarManager)
{
    sideBarManager = insideBarManager;
    button.onClick.AddListener(this.SendWindowIndex);
    desInt = index;        
}

public void SendWindowIndex()
{
    sideBarManager.ActivateNewWindow(desInt);
}`
stuck palm
#

i want to make a debug object that points in the direction of a vector i gave it, but it seems to be pointing at the normal of the vector?

void Update()
    {
        transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.LookRotation(Vector3.forward, cc.moveVector), 0.5f) ;
    }```
ivory bobcat
ornate lynx
#

doing it

grand sigil
wintry quarry
#

you're also using a delegate that doesn't exist (OnInteactAction)
And you're missing a . between the ? and the Invoke

ivory bobcat
#

Maybe the ide isn't configured? UnityChanThink

ornate lynx
#

nothing changed

ivory bobcat
ornate lynx
#

yeah i opened the file from unity after it booted up again

buoyant knot
#

yes, the IDE should show Rigidbody2D in the same green color as a class

ornate lynx
#

monobehavior should be colored as well

buoyant knot
#

did you follow the !IDE guide?

eternal falconBOT
ornate lynx
#

yes i did

#

didn't work :/

ivory bobcat
#

Their history isn't too long

ornate lynx
#

i updated unity, hub and repaired vs

#

nothing changed

timber tide
#

could always try vs code :)

young warren
ornate lynx
#

i like vs

#

i really like it

buoyant knot
#

this doesn’t look like a unity issue specifically, but that VS doesn’t acknowledge you are in C#

#

as opposed to VS not knowing you are in unity

ornate lynx
#

are there extensions i have to install or smth?

buoyant knot
#

are you on mac or windows?

ornate lynx
#

win

buoyant knot
#

this is so strange

ornate lynx
#

ik :/

buoyant knot
#

perhaps the C# discord can help

ornate lynx
#

maybe something in the directories is messed up?

ornate lynx
buoyant knot
#

i remember having this issue a month ago, and I can’t remember wtf i did to resolve it

#

but it is something very simple

ornate lynx
#

hopefully

buoyant knot
#

so simple I don’t recall lol

#

if it was actually hard, i’d remember

ornate lynx
#

that's good to hear

summer stump
ornate lynx
#

1 sec

#

u mean this?

grand sigil
buoyant knot
young warren
buoyant knot
#

i have never had to click that, because I’m pretty sure VS does that automatically sometimes via unity

#

it is possible it never went for you

young warren
ornate lynx
#

idk i'll give it try

#

let's hope it works 😄

buoyant knot
#

what do you have to lose? lol

summer stump
grand sigil
#

Its in another script

ornate lynx
#

load failed

summer stump
#

Hmmm very odd

young warren
buoyant knot
#

that might explain it

#

which probably means you are missing a package

ornate lynx
#

yeah it's been showing (unloaded) already

ornate lynx
grand sigil
young warren
ornate lynx
#

what is it?

buoyant knot
#

it failing to reload is a good sign, because now we know what the problem is

young warren
#

where is this in

#

Start? Update? Awake?

buoyant knot
#

we don’t know exactly the fix, but it is narrowed down a lot

ornate lynx
#

i remember learning gamedev before and i remember adding packages, i just don't seem to remember what it is

young warren
#

okay, where is CreateDraw called?

#

I want to know if you call it before or after the Start function of your first script

grand sigil
#

The method it is in happens from a different working button

buoyant knot
#

does your project only have the one file in the solution?

polar acorn
#

How about just send the !code for both scripts so we can stop this game of telephone

eternal falconBOT
buoyant knot
#

you probably need to install extensions to VisualStudio

ornate lynx
#

what r they?

grand sigil
polar acorn
#

both of them

swift sedge
ornate lynx
#

hold on lemme read the error

buoyant knot
#

usually going through this should download everything you need.

ornate lynx
swift sedge
#

Well that's great! 🙃

buoyant knot
#

i misread it as a regular smiley mb

rotund bronze
#

how can this.skill.Activate called while this.skill i null? can anyone give me an explaination for this?

ornate lynx
buoyant knot
#

oh shit

#

so do you know how assemblies work?

ornate lynx
#

what?

#

uhhh no

ornate lynx
#

might start learning abt them

buoyant knot
#

it’s like a group of code that all gets compiled together, with dependencies so compiler knows what blocks of code to compile to bring the whole project together

polar acorn
rotund bronze
ornate lynx
buoyant knot
#

meaning VisualStudio can’t find that assembly file that it needs to put together the unity project

ivory bobcat
ornate lynx
#

sooooo how is this fixable?

buoyant knot
#

it literally tells VS the list of all the files for your project

#

either 1) Unity fucked up and didn’t make the assembly file, 2) Unity did make it, but VS can’t find it

ornate lynx
#

soo how can i look for it

polar acorn
ornate lynx
#

in case it exists

swift sedge
ornate lynx
#

or how can i know if unity made it in the first place

astral falcon
#

You can reset your External Tools inside the unity preferences window and see, if the correct IDE is set.

buoyant knot
#

i don’t recall where. I think there should be a bunch of .dlls or something

ivory bobcat
buoyant knot
#

i don’t have the knowledge to fix this issue, but now we know exactly what it is

rotund bronze
#

@ivory bobcat @polar acorn found the reason, its because skill derived from mono and unity dont allow creating a new class inherited from it

ornate lynx
#

literally everyone says to regenerate project files

polar acorn
swift sedge
#

you could try cleaning the solution but that has a slim chance of working

grand sigil
polar acorn
buoyant knot
#

that is an assembly that Unity is responsible for making.

ivory bobcat
grand sigil
#

I basically want to add a listener to a button i instantiated and give it a number

ornate lynx
#

i'm looking up the problem in google

polar acorn
grand sigil
#

Like this. But the prefab has empty

ornate lynx
swift sedge
ornate lynx
#

load failed, i did that

swift sedge
#

So it's caboose

grand sigil
ornate lynx
#

give me some hope 😂

swift sedge
#

Create a new project and copy the assets folder to it

ornate lynx
#

ok i'll just create a new project, create a script, see if anything get's colored

#

but w8

#

well uhh, i found the file itself in github, idk if that helps

whole idol
#

why cant i delete this file?

#

it says project still in use?

#

this is a project i wanna delete

#

i closed unity

#

all apps unity related

#

this is in the file exporter btw, i deleted it from unity hub library

queen adder
#

Sounds like something is still open using it, your IDE perhaps?

whole idol
#

oh yes

#

thats rtue

#

thank you

polar acorn
ornate lynx
#

the thing is

#

i can see it

#

except the directory isn't the same

#

vs says i need to find it in the obj folder, while it is outside that folder

#
  • it says the name of the file is Assembly-CSharp.csproj.*.props
#

all i can find in the "obj" folder is another "Debug" folder

buoyant knot
#

does this work with other unity projects?

ornate lynx
#

i'll create a new one and see

#

well NOW monobehavior is colored

#

yeah everything works fine

#

perfectly fine

#

but i still wanna fix my older project

ivory bobcat
#

Move your scene objects, assets and resources over.

astral falcon
#

Did you just try to backup and remove thewhole csproj files, let Unity try to regenerate it?

ornate lynx
#

wait

#

all the csproj files in my project are outside the obj folder, while in the one i created, none is existing

#

but still the assembly file is outside the obj folder

#

this is the new one

#

this is the old one

ivory bobcat
#

Does this differ from the other project?

ornate lynx
#

yes

#

a lot

ornate lynx
ivory bobcat
#

Seems like you've got lots of extra stuff

ornate lynx
#

is it extra or in the wrong folder?

#

here's some

ivory bobcat
#

I'm only aware of you having two assembly project files (maybe a concern)

hexed terrace
#

No, you get loads of csproj files in the project folder.. depends on what you have in the project

ornate lynx
#

uhhh soo what can i do

hexed terrace
#

delete it

ornate lynx
#

tho the error for the project not loading was the assembly file not existing in the obj folder

ivory bobcat
#

Reimport everything into the new project and pray the unwanted behavior is forever destroyed with the previous project.

ornate lynx
#

alr

ornate lynx
#

yeah well i still want my project to be fixed

swift sedge
#

just copy'n paste the assets

ornate lynx
#

for some reason those files showed up

ivory bobcat
#

They'll auto generate as you add/import stuff into your project

#

Likely had some corrupted file or (hopefully not) broken asset.

ornate lynx
#

what i don't understand is that the new project works fine even tho the assembly file is still not in the obj folder

ivory bobcat
#

That tells you it doesn't need to be in the folder

ornate lynx
#

well the error said that it has to be there

ivory bobcat
#

Thus why it's a bit important to understand what's definitely the problem to not create XY problem/solutions

ornate lynx
#

yeah ik

ivory bobcat
#

Hopefully everything turns out fine/great

ornate lynx
#

i wanna know what the problem is so that i get a little more familiar with unity...maybe

ornate lynx
#

ty all for helping me out

shy orbit
#

Hi im struggling to attach scripts to my game objects, it comes up with a message saying "Cant add script behaviour VisualContainerAsset. The script needs to derive from Monobehaviour!"

polar acorn
shy orbit
#

how do i check?

polar acorn
#

Open the script and look at it

shy orbit
#

public class TesterScript : MonoBehaviour {

#

this line?

polar acorn
shy orbit
#

i have no idea what VisualContainerAsset is

astral falcon
#

You are trying to add it obviously. So it has to be in your workflow of trying to add a script to the GO somewhere

polar acorn
shy orbit
#

right but when i open the script, where do i see if it derives from MonoBehaviour?

astral falcon
shy orbit
astral falcon
#

Well

#

Read the second part of that sentence

#

Whats your file called?

shy orbit
#

Tester script.cs

summer stump
ivory bobcat
# shy orbit

Maybe the script name doesn't match the class name

summer stump
ivory bobcat
#

And apparently there isn't any mono behavior classes in the file

astral falcon
ivory bobcat
#

Maybe what you're looking at in your ide is something other than that file - maybe a cache due to name changes while the file was still open.

shy orbit
#

ahhhhh

#

i got it

#

thank you

#

i had a space in it

muted glen
#

hey. can anyone help me with my pause menu and the buttons included. Everything should be working but i cant seem to find the issue with the buttons not actually being interactable. I just need a more experienced person to lookover it. thanks

#

This is my script.

frigid sequoia
polar acorn
#

Do you have an Event System in the scene?

muted glen
#

@frigid sequoia@polar acorn Thank you. I'll send screenshots of my scene and the appropriate things included

naive lion
#
    {
        float mouseY = Input.GetAxis("Mouse Y");

        float newRotation = Mathf.Clamp(cannonPivot.localRotation.eulerAngles.y + mouseY, minYRotation, maxYRotation);

        cannonPivot.localRotation = Quaternion.Euler(0f, newRotation, 0f);
    }```

Im tryna have a simple script where a gameobject can only move on the Y axis and are limited by a min and max rotation float
Anyone know why its not rotating on the Y and also why when it hits 0 it just snaps back to the max rotation value
muted glen
#

and then i have both buttons (on click has the representative stuff for the different buttons)

frigid sequoia
# muted glen

The last image makes it seem that you have no EventSystem; do you?

keen dew
naive lion
frigid sequoia
# muted glen i do. sorry

So... your issue is that you cannot interact with anything in the UI? Even though they are marked as interacteble?

muted glen
#

yep. so when i click on any button the menu doesnt go away nor does the actual function its meant to do happen

#

only when i press esc does it go away

astral falcon
#

Do you have a raycaster on your canvas? Do you have an image as last child in the hierarchy that is marked as raycast and blocks all raycasts?

whole idol
#

Ι just tried importing Unity's Bolt and all I got was a bunch of ERRORS!

muted glen
astral falcon
whole idol
astral falcon
polar acorn
# whole idol Ι just tried importing Unity's Bolt and all I got was a bunch of ERRORS!

I mean, if it doesn't work with 2021 "yet" it probably doesn't work with later versions.

Bolt no longer exists, it's been incorporated into Unity itself under the name Unity Visual Scripting.
https://unity.com/features/unity-visual-scripting

Unity

Add interactivity without writing code. Unity Visual Scripting allows rapid prototyping and testing enabling game developers to save hours of their time.

#

Why are you trying to open Unity 5?

muted glen
frigid sequoia
#

Maybe, this a stupid sugestion, but maybe it is not running cause the timeScale is 0? Can that be a thing?

polar acorn
#

So make it in an actual modern version

summer stump
#

You can do that without a near decade old editor

polar acorn
#

Then we can't be bothered to help you goodbye

summer stump
#

Well what you are attempting is not working....

muted glen
polar acorn
#

<@&502884371011731486>

astral falcon
frosty hound
#

!warn 1135924484327616553 If you cannot be civil, then please leave.

eternal falconBOT
#

dynoSuccess plainrocky has been warned.

muted glen
astral falcon
polar acorn
muted glen
#

okay thank you. im new to all this stuff sorry. this what i see when i click on the 'button'

polar acorn
muted glen
frosty hound
#

!ban save 1135924484327616553 Not mature enough to bother trying to correct their behaviour.

eternal falconBOT
#

dynoSuccess plainrocky was banned.

polar acorn
# muted glen

Hm, it has a raycaster, your button is interactable, nothing's blocking it, I'm not sure what else it could be

muted glen
#

wait mate

#

what is this

#

hold on

#

its working but only when im in dialogue with my npc????

astral falcon
muted glen
#

man...

shy orbit
#

void Start () {
float a = 8f;
float b = 6f;

    int sum = (int)a + (int)b;
}
#

why is this not giving me a value in console? is it cast incorrectly?

muted glen
#

ive done it..

#

thank you guys so much

rocky canyon
#

u dont debug the sum ?

polar acorn
shy orbit
#

oh lol forgot to print it my bad

#

thanks

swift sedge
#

you can use print or Debug.Log

hushed hinge
#

even though it is fixed now, I cannot see the list which I think is supposed to be shown there?

flint falcon
#

@rich adder

#

I did it

polar acorn
summer stump
hushed hinge
#

changing they both to public right away

#

there we go

rich adder
flint falcon
#

i got it working. I was over thinking it way to much

#

I think the way I'm doing my sprite movements is causing me to flip through my edge of map colliders

autumn tusk
#

dont understand why my for loop is acting up all of a sudden

summer stump
autumn tusk
#

ill explain

summer stump
#

Maybe show the code and describe what "acting up" means?

autumn tusk
#

basically i have a burst gunner enemy that fires in bursts of 3

#

its functions based off a for loop

#

basically i define how many shots the enemy shoots out in an integer and get a for loop to generate an "enemy bullet" for each cycle

wintry quarry
#

sounds reasonable so far. What makes you think the loop is "acting up"?

autumn tusk
#

it stopped working suddenly

wintry quarry
#

what does "stopped working" mean?

flint falcon
#

show the goods\

autumn tusk
#

basically only fires once

#

!code

eternal falconBOT
autumn tusk
#

issues are found at line 95

wintry quarry
#

what are they printing?

autumn tusk
polar acorn
wintry quarry
#

exceptions cause code to stop

polar acorn
#

that would have been good information to start with up front

#

What line?

autumn tusk
#

68

wintry quarry
#

Basically you're passing null in here audiosource.PlayOneShot(shootclip);

#

you're passsing in a null audio clip

summer stump
#

Always fix any errors before worrying about anything else. Your for loop is irrelevant here, because it simply cannot complete due to the error

wintry quarry
#

Which means you forgot to assign it in the inspector

ivory bobcat
autumn tusk
#

strange

#

audiosource and playshooting are assigned at awake

wraith valley
#

Help please

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

public class PlayerController : MonoBehaviour
{
    // Start is called before the first frame update
    public float speed = 10;
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.LeftArrow)) { transform.position = new Vector3(-5f, transform.position.y, transform.position.z) += Time.deltaTime * speed; }
    }
}
summer stump
wintry quarry
polar acorn
wintry quarry
#

why did you write += here

#

instead of just +

wraith valley
#

Lol misclick

#

Thanks

polar acorn
wraith valley
polar acorn
eternal falconBOT
summer stump
# wraith valley No

Then it is still unconfigured
You've been linked this guide a number of times
Stop everything and do it. It is a requirement to get help here

wintry quarry
ivory bobcat
polar acorn
wraith valley
#
if (Input.GetKeyDown(KeyCode.LeftArrow)) { transform.position = new Vector3(-5f, transform.position.y, transform.position.z) + Time.deltaTime * speed; }
summer stump
wintry quarry
#

think about what it's doing

#

and make it make sense

wintry quarry
#

think about it

#

what is this code doing?

summer stump
polar acorn
wraith valley
polar acorn
#

Now you just need to make it mathematically sound. You can't add a float to a vector. What are you actually trying to do with this value?

wraith valley
#

On the left side

ivory bobcat
wraith valley
#

Speed is a speed

ivory bobcat
#

And to not use the += operator

ivory bobcat
#

Your offset needs to be a vector 3 as well - assuming that's what you're intending to do.

#

My assumption:cs position = modifiedPosition + offset

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

public class PlayerController : MonoBehaviour
{
    // Start is called before the first frame update
    public float speed = 10f;
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.LeftArrow)) { transform.position += new Vector3(-1, 0, 0) * Time.deltaTime * speed; }
    }
}
ivory bobcat
#

Where offset would be the speed vector scaled by delta time etc

wraith valley
#

I should have use *

exotic hazel
wraith valley
hushed hinge
wraith valley
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerController : MonoBehaviour
{
    // Start is called before the first frame update
    public float speed = 10f;
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.LeftArrow)) { transform.position += new Vector3(-1, transform.position.y, transform.position.z) * Time.deltaTime * speed; }
    }
}
#

Because of +

#

Lol

#

🗿

exotic hazel
#

Good thing u noticed I spent 2 hours fixing a + sign issue when I was making an inventory

exotic hazel
#

So there was one line when I was making the drag feature in inventory

#

It was smthing like

#

Recttransform.anchoredposition = eventdata. Delta

#

It was meant to be += eventdata.delta

#

And i just Couldnt see it

wraith valley
#

Doesn`t work

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

public class PlayerController : MonoBehaviour
{
    // Start is called before the first frame update
    public float speed = 10f;
    public float velocity = 10f;
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.LeftArrow)) { transform.position += new Vector3(-1, transform.position.y, transform.position.z) * Time.deltaTime * speed; }
        if (Input.GetKeyDown(KeyCode.RightArrow)) { transform.position += new Vector3(1, transform.position.y, transform.position.z) * Time.deltaTime * speed; }
        if (Input.GetKeyDown(KeyCode.UpArrow)) { transform.position += new Vector3(transform.position.x, 1, transform.position.z) * Time.deltaTime * velocity; }
    }
}
#

That`s shoud work

wraith valley
polar acorn
polar acorn
exotic hazel
polar acorn
# wraith valley Adding

So why are you also adding the current y and z position to the current y and z position while you're trying to change the x position?

exotic hazel
#

And is there supposed to be a + sign there?

#

Only =

polar acorn
exotic hazel
polar acorn
#

Code doesn't just happen, you were surely thinking of something when you wrote it

polar acorn
exotic hazel
#

Week?

ivory bobcat
wraith valley
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerController : MonoBehaviour
{
    // Start is called before the first frame update
    public float speed = 10f;
    public float velocity = 10f;
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.LeftArrow)) { transform.position += Vector3.left * Time.deltaTime * speed; }
        if (Input.GetKeyDown(KeyCode.RightArrow)) { transform.position +=  Vector3.right * Time.deltaTime * speed; }
        if (Input.GetKeyDown(KeyCode.UpArrow)) { transform.position += Vector3.up * Time.deltaTime * velocity; }
    }
}
wraith valley
#

🤷‍♂️

exotic hazel
polar acorn
wraith valley
#

But don`t understand why Vector3.left and why not new Vector3 (1, 0,0)

exotic hazel
#

Same thing

wraith valley
exotic hazel
#

But u used transform. Position.y instead

exotic hazel
summer stump
exotic hazel
wraith valley
polar acorn
wraith valley
#

I`m taking position of object

exotic hazel
polar acorn
#

1, 0, 0 and 1, position.y, position.z are not the same

wraith valley
#

How?

summer stump
exotic hazel
#

If u totally new to unity I suggest watching the Junior programmer tutorial on the learn.unity page

polar acorn
exotic hazel
#

I started from there

polar acorn
#

I literally cannot explain this any clearer

exotic hazel
#

U will learn a lot from there

polar acorn
#

this is basic object permanence

wraith valley
# polar acorn I literally cannot explain this any clearer

I just thought logically, after all I saw in Unity learn that I can take there and change the coordinates I need without touching the other Y and Z, because it's like the same thing if I just write 0, 0. What would that be there are 0 and 0, that's right.

polar acorn
#

Do you get the same value back, or a different one

#

If you have two apples, and someone else gives you two more apples, how many apples do you have

wraith valley
#

I didn't understand the analogy, but thanks

exotic hazel
#

If ur transform. Position is (5, 5,5) aand u do transform.position += new vector 3(transfrom.position.x, transform.position. T, transform. Position. Z)

#

Then u actually do

#

(5+5, 5+5, 5+5)

polar acorn
exotic hazel
#

So the new coordinates are 10,10,20

#

I mean Qp

polar acorn
#

that's the analogy

exotic hazel
#

10

polar acorn
#

If you add two apples to two apples, you no longer have only two apples

#

you have a different number

wraith valley
#

Is it bad?

exotic hazel
#

Just wait a sex

#

Sec

polar acorn
#

and then you asked why it made a difference

#

and I'm trying to explain basic addition

exotic hazel
#

U aren't adding 0+0

#

U are adding the coordinates to itself or Mutliplying it by 2

wraith valley
#

What should i do?

exotic hazel
#

To make the object move?

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

public class PlayerController : MonoBehaviour
{
    // Start is called before the first frame update
    public float speed = 10f;
    public float velocity = 10f;
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey(KeyCode.LeftArrow)) { transform.position += Vector3.left * Time.deltaTime * speed; }
        if (Input.GetKey(KeyCode.RightArrow)) { transform.position +=  Vector3.right * Time.deltaTime * speed; }
        if (Input.GetKey(KeyCode.UpArrow)) { transform.position += Vector3.up * Time.deltaTime * velocity; }
    }
}
wraith valley
#

There`s too * coordinates

wraith valley
polar acorn
#

Yes, now your object will properly move speed units per second for one frame every time you tap the left or right key

exotic hazel
#

If(input.getkey(keycode.W))
{
Transform.Translate(vector3.right*time.deltatime * speed
}

junior quarry
#

Hello all, question regarding cameras and netcode - when i add a new client, the camera from the previous client switches to the camera of the new client... any idea how to fix this?

exotic hazel
#

To make it jump u can maybe add Rigidbody and use the addforce option

summer stump
wraith valley
summer stump
#

You don't want to mix

wraith valley
#

Thanks

exotic hazel
rich adder
#

just be aware Translation = no collisions

exotic hazel
wraith valley
rich adder
#

it doesn't respect the physics scene

wraith valley
#

Just teleport?

#

Should be good for teleporting units

rich adder
#

yeah for teleporting assigning position is more than enough, no need for translate

wraith valley
#

Then why was it added?

rich adder
#

to simplify movement with a few extra options like relative coordinate space etc.

#

but all its really doing is position +=

#

this is the function behind Translate

#

nothing fancy

summer stump
#

And not everything that moves is a player or enemy or something

#

And sometimes you DO just want to teleport something

wraith valley
#

Ok, thanks

hushed hinge
#

Lock door portal

gleaming kraken
#

what's an event system? I randomly found this on my hierarchy

short hazel
#

Makes interactable UI elements (buttons, input fields) work

summer stump
wraith valley
#

Really automatically?

summer stump
wraith valley
#

Lol

#

Doesn't created

#

And i'm created

hushed hinge
summer stump
# wraith valley Lol

The options are, there was a bug and it didn't get created. You deleted the one that was automatically created. You currently have two

wraith valley
#

No, really doesn't created

hollow forum
#

im just following a course and a random error has popped up with cinemachine

#

and im not sure why

summer stump
summer stump
tender stag
#

this is supposed to check if any of the equipmentCells item is not null

if((item as EquipmentItem).equipmentCells.Any(equipment => equipment.cell.item != null))

#

it doesnt work

#

even though theres clearly an item in at least one of them

#

i mean i could do this

#

but i was trying to simplify it

#

not having the loop

polar acorn
polar acorn
tender stag
#

wait it also doesnt work

#

hold on

#

im so dumb

#

i was doing equipment.cell.item instead of equipment.item

carmine sierra
#

whats the simplest way to access a textmeshpro UI

swift elbow
carmine sierra
#

thanks

wintry quarry
carmine sierra
#

is this valid

wintry quarry
#

It will compile definitely. Depending on what p1Balance is, it may or may not be what you want.

rocky canyon
#

might need some formatting depending on what it is

carmine sierra
#

why is the line in start not getting the variable?

#

I have linked the script

slender nymph
#

what do you mean by "not getting the variable" and also how have you verified that it isn't

carmine sierra
#

i have verified as I was logging it and it wasnt updating

#

whereas the original variable in the other script was updating

slender nymph
#

it sounds like you need to learn the difference between value types and reference types

carmine sierra
#

does it need to be public?

slender nymph
#

mate you haven't even properly described what you mean when you say it "isn't getting the variable". but also if this is in fact an issue of not understanding reference types versus value types, then the access modifier is entirely irrelevant

buoyant knot
#

public/private/internal changes what classes are allowed to call that function or access that variable

carmine sierra
#

i am getting the variable woodnumber from the script spawnwood which has a variable called woodnumber

carmine sierra
#

but i dont know why its not working

carmine sierra
#

is that not a good explanation

slender nymph
#

that isn't an explanation of what you think isn't working at all

carmine sierra
#

the original woodnumber variable is updating in the original script

buoyant knot
#

no

wintry quarry
wintry quarry
#

No you're getting it in Start

carmine sierra
#

ohhh

#

yeah your right

#

thanks

slender nymph
carmine sierra
#

yeah lol woops

#

i forgot that i need to keep calling it to update it

wintry quarry
#

Just read it directly from the reference to the other script

#

Otherwise you get this annoying headache of keeping them in sync

carmine sierra
#

how do i do that?

#

is it not already reading it directly

thorn holly
#

Yeah, so simply say SpawnWood.woodNumber instead of the variable you made

carmine sierra
#

oh okay

#

doesnt it make it easier to read through

thorn holly
#

Maybe, but int is a value type. You’d have to do some super uneccessary stuff for that to work

#

It’s easier just to say SpawnWood.woodNumber

buoyant knot
#

on a similar note, I have a UI used to modify a data structure with an input field. I’m having a bit of challenge trying to figure out how to properly keep them synced, to make the data match the UI and visa versa. Because it feels like methods that do one change should call methods to sync UI to/from data. Is there a simple way to organize without getting confused?

carmine sierra
#

how would you go about only subtracting when thewoodnumber changes. i know this is simple but the only way I can think of doing it (coding everything in one script) will make things messy

#

Right now it subtracts every frame (as expected)

buoyant knot
#

like, I have a method that writes current contents of data structure to imput field. I have another method that writes contents of input field to data structure. And when I do other things, I am getting confused to keep them in sync.

thorn holly
carmine sierra
#

this might sound stupid, but how would I detect when it changes

thorn holly
#

When you code it to change

carmine sierra
#

would I need to use another variable to save it's previous number

thorn holly
#

When you make the value change via code

thorn holly
carmine sierra
#

thanks

#

that requires me to do it in one code then

thorn holly
#

Do what in one code?

carmine sierra
#

im changing the variable in another code

thorn holly
#

So call the method in the other scripts

#

Right after you change it

carmine sierra
#

i didnt know i could do that

thorn holly
#

Yes, in the same way you would reference the variable

carmine sierra
#

so scriptname.functionname?

#

with the ()

thorn holly
#

If the method is static, yes

carmine sierra
#

sorry but what is a static method

#

i googled and i dont know

thorn holly
#

It seems like you need to learn some c# basics. I wouldn’t reccomend doing unity until you have a solid c# foundation

#

And google should be plenty to answer your question

carmine sierra
#

i know a bit

#

i need to finish my game by monday ish

thorn holly
#

Alright, try googling it

#

It should be plenty to answer your question

buoyant knot
#

no offense

carmine sierra
#

it's nearly finished so im not too worried about that

buoyant knot
#

that does not fill me with confidence

carmine sierra
#

it's just that i was learning on the go

thorn holly
#

Learning on the go is fine, but things like what static means are basic concepts you need to know before you start developing in unity

buoyant knot
#

you are driving without a license, then worrying you are going to miss your flight if you don’t gun it

thorn holly
carmine sierra
#

i used gemini ai and i still have a vague idea

#

does it just mean there are no more than one of the same name in the script

polar acorn
#

Static means they belong to the class, not any instances of the class

carmine sierra
#

i know what an instance is and the class is the script itself right?

#

but how could the script have instances

slender nymph
polar acorn
#

A script is like, the DNA genome of a cat. An instance is an actual Cat

carmine sierra
#

so whats an example of a static function

slender nymph
#

everything on the Mathf struct

polar acorn
#

Getting the absolute value of a number does not require a specific "thing" to do the math. You just pass it a number and it gives you a result

carmine sierra
#

when would a function not be static

polar acorn
carmine sierra
#

so your saying it shouldn't require parameters?

polar acorn
carmine sierra
#

damn

#

ohhhh

#

you mean the function should always be accessible

#

and callable

thorn holly
#

And something non static would be what color the cat is, bc that can vary from cat to cat (instance to instance)

polar acorn
#

A static function does not require any specific thing to exist.
A non-static function requires the thing it's defined on to exist.

You don't need to know about any specific cat to answer the question "Are cats mammals?"
But you do need to know about a specific cat to answer the question "What color is a cat?"

carmine sierra
carmine sierra
summer stump
open vine
#

I was able to make a path generator along a generated tile map but can anyone explain how to make it procedural and not directly from the start to end point?

polar acorn
#

it simply exists

#

It is a procedure that can be done regardless of any instances of any classes

carmine sierra
#

oh okay so my function that i need isn't static then

stone pilot
#

when the player dies

polar acorn
stone pilot
#

like this

    {
        StartCoroutine(Respawn(1f));
    }

    IEnumerator Respawn(float duration)
    {
        tr.Clear();
        rb.simulated = false;
        rb.velocity = new Vector2(0,0);
        transform.localScale = new Vector3(0,0,0);
        yield return new WaitForSeconds(duration);
        transform.position = startPos;
        transform.localScale = new Vector3(0.22f,0.22f,0.22f);
        rb.simulated = true;
    }```
polar acorn
stone pilot
zenith cypress
#

I remember having to do this to get the renderer to actually clear it properly #💻┃unity-talk message maybe they fixed it since then LUL

stone pilot
#

not working..

#

the problem is when the player dies then respawns again

polar acorn
#

Where did you put it?

stone pilot
#

i did that but its not working

#
    {
        rb.simulated = false;
        rb.velocity = new Vector2(0,0);
        transform.localScale = new Vector3(0,0,0);
        yield return new WaitForSeconds(duration);
        tr.Clear();
        transform.position = startPos;
        transform.localScale = new Vector3(0.22f,0.22f,0.22f);
        rb.simulated = true;
    }```
polar acorn
stone pilot
#

alr

#
    {
        rb.simulated = false;
        rb.velocity = new Vector2(0,0);
        transform.localScale = new Vector3(0,0,0);
        yield return new WaitForSeconds(duration);
        transform.position = startPos;
        transform.localScale = new Vector3(0.22f,0.22f,0.22f);
        rb.simulated = true;
        tr.Clear();
    }```
#

like this ?

polar acorn
#

Yes, try that

stone pilot
#

it worked, thanks

wild dagger
#

Hi, I'm having an issue where the game does decrease the enemy's health as it's supposed to, yet value of the slider doesn't change meaning that it doesn't move?

#

As you can see the HP value has decreased yet the bar itself hasn't moved at all, have I missed something?

swift elbow
wild dagger
swift elbow
#

your bar looks green bc you have an image component, the slider component is not what is controlling the color rn

wild dagger
#

Do I have to include the slider.MaxValue along with the value?

swift elbow
wild dagger
#

mb sent that just as u sent that message lol

#

Ok so its the actual slider itself that's the issue, so the slider IS decreasing but the green isbecause of the image itself?

#

how can I make sure it does decrease accordingly

swift elbow
swift elbow
#

your component should look something like this

wild dagger
#

Ah ok

swift elbow
#

if you rmb and reset it will do this automatically

wild dagger
#

ok now it looks like this

swift elbow
#

now assign fill rect and handle rect

wild dagger
#

sorry im not sure what exactly to assign it to in this case

swift elbow
#

create a new slider gameobj and delete your current one

#

that'll assign them automatically

wild dagger
#

ok

#

Done it, I'm trying to adjust the shape so its rectangular but im not sure how to

#

How do I make this rectangular? 💀

rich adder
#

swap the sprite

#

or remove it

wild dagger
#

ok

rocky canyon
#

u can use an empty image to get a perfect square

swift elbow
rocky canyon
#

rectangles can be squares.

#

squares cannot be rectangles

polar acorn
#

All squares are rectangles, but not all rectangles are squares

swift elbow
#

you have it the other way around

#

@rocky canyon

rocky canyon
#

anywho..

stone pilot
#

is there a way to make the pixel perfect camera follow the player without cinemachine ?

rich adder
#

huh? they're not related

wild dagger
#

Bro what do I even do with all of these different components 💀

#

can I get rid of some of them

rocky canyon
#

lol. theres some of em that are not really needed yea

rich adder
wild dagger
#

the code's ready its literally just creating the slider

rich adder
wild dagger
#

its supposed to go on top ofthis

rich adder
#

much easier and better than a slider

swift elbow
rocky canyon
#

these two objects are the important ones

#

and ofc the main slider component.. but yea image and fill's work great too

rich adder
#

yea you'll get a much better result with Image component than slider

wild dagger
#

aight

rich adder
#

You'll need something like this

#

download it put it in the image component set the mode to Fil

wild dagger
#

Cause I genuinely tried using a bar image and adding the slider component but that didn't work either

rich adder
#

it works i do it all the time

#

comes cleaner than slider

wild dagger
#

Bro scroll up I tried with my code and it didn't work

carmine sierra
#

is there a difference between destroying an object or turning it's setactive to false

rocky canyon
wild dagger
#

I couldn't add a fill and handle rect to the image lol

rich adder
#

both are pretty much already in memory, destroying will eventually free it up

carmine sierra
#

does anything to do with it run still

summer stump
rich adder
summer stump
rich adder
#

You can still call functions on disabled objects if you have references to those scripts

carmine sierra
#

and if it were just a sprite for example

#

would it be fine if it were setactive false

summer stump
#

We don't know what you want to happen

carmine sierra
#

if it still were using cpu power

rich adder
#

you're overthinking this

carmine sierra
#

probably

wild dagger
summer stump
#

It would consume space in ram still. But whatever

wild dagger
#

bro im so cooked

carmine sierra
#

cause in my script the sprite updates to the mouses position

#

so if its setactive is false would it still be moving to the mouse but invisibly

#

but yeah it doesnt really matter

rich adder
carmine sierra
#

updates it's position to the mouse

rich adder
carmine sierra
#

it's following the mouse

rich adder
#

yeah its not a big deal at all

#

everything was already drawn on screen and loaded

stone pilot
#

is there a way to make the pixel perfect camera follow the player without cinemachine ?

naive palm
#

is there any way to make the composite collider's collision edges thicker when using polygons geometry type instead of edges? My enemies can slip through the thin edges

rich adder
stone pilot
summer stump
rich adder
#

the pixel perfect can function perfectly fine without cinemachine..

summer stump
#

How do you want it to move, what should it follow, what axes do you move in?

#

There are tons of guides on how to have cameras follow things

stone pilot
summer stump
stone pilot
rich adder
stone pilot
#

alright

#

i'v added this script to the camera to make the camera follow the player but its not working with the pixel pefect

{
    private Vector3 offset = new Vector3(0f, 0f, -10f);
    public float smoothTime = 0.25f;
    private Vector3 velocity = Vector3.zero;

    [SerializeField] private Transform target;

    private void Update()
    {
        Vector3 targetPosition = target.position + offset;
        transform.position = Vector3.SmoothDamp(transform.position, targetPosition, ref velocity, smoothTime);
    }
}```
rich adder
stone pilot
#

i dont know but ya makin me feel dumb..

summer stump
rich adder
#

make sure there are no erros, also it should prob be inside LateUpdate for any cameras

#

or it will be chop

wild dagger
#

Bro im still stuck on making this damn slider the size I want it to be

stone pilot
#

i think the prob is that i hav a animator on the cam right ?

wild dagger
#

@rich adder Ik its bad man

summer stump
#

Could be the issue

rich adder
summer stump
#

What is the purpose of the animator there?

stone pilot
summer stump
#

Noice. Good job

stone pilot
#

i just forgot that i've got an animator on the camera

rich adder
wild dagger
#

atm its the perfect size its just a matter of decreasing it

#

aight

rich adder
#

i sent you one

#

its a plain white box

rocky canyon
#

^ add that as ur sprite and ur "Fill" option will reveal itself

#

looks like a circle until u click it 😄

rich adder
#

wish unity didn't make the built in square sprite a myster asset..

wild dagger
rich adder
wild dagger
#

sprite has been added

rocky canyon
#

ya, i have a square sprite i keep on my desktop 😄

#

now change Image Type to Fill

rich adder
wild dagger
#

O DAMN ITWORKS

rocky canyon
#

and then u have a .fillAmount variable u can use to update ur health/shield or w/e

rich adder
#

you can even do rounded ones

reef oyster
#

does anyone know why my included libraries namespaces are grey but mono isnt

wild dagger
rich adder
reef oyster
#

ah so it should be fine

rich adder
#

yea you can delete them

#

unless you need Lists or something

reef oyster
#

wb white

rich adder
#

the opposite lol

reef oyster
#

so its used

polar acorn
rich adder
#

what is real anymore

rocky canyon
#

ah shit, my square is circle too!

#

idk why i used 15x15..

#

trying to split pixels i guess

rich adder
#

prob min is 16 UnityChanLOL

rocky canyon
#

yea i had to check to see what was common

#

16x16 makes more sense lol

rich adder
#

idk assuming they love doing multiples of 2

rocky canyon
#

ya, thats where my 15 pixel block is gonna look faded on one side

wild dagger
#

IT WORKS OMG

rocky canyon
#

hellz ya

wild dagger
#

TYSM

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

public class Line : MonoBehaviour
{
    public Transform pos1;
    public Transform pos2;
    public LineRenderer line;
    // Start is called before the first frame update
    void Start()
    {
        line.positionCount = 2;
    }

    // Update is called once per frame
    void Update()
    {
        line.SetPosition(0, pos1.position);
        line.SetPosition(1, pos2.position);
    }
}

I am new to Unity.This is my first script and i have no idea why it doesn't works

honest trench
#

this has me so confused. I ahve this code that makes it so when the player touches it, it moves the camera and changes some other stuff. and it works great. the on screenshot with NewCam2 it works flawlessly. but on the screenshot with newcam3, it works but all the enemies become invisible. I can still interact with them, but they are just... invisible. why????

#

Ill provide any other info needed

stable moth
polar acorn
honest trench
#

the newCams?

polar acorn
stable moth
polar acorn
polar acorn
# stable moth

Okay, and what happens when you run the game? Send a screenshot of it then

honest trench
#

yep they were

#

why does that effect it

polar acorn
# honest trench why does that effect it

I'm guessing your code moves the camera to the position of newCamX, and depending on your culling distances, moving the camera to a different Z position might mean some things are outside of your culling range that weren't before

stable moth
polar acorn
stable moth
#

I mean in the editor

polar acorn
#

Again, why would it work in the editor?

#

Your script doesn't do anything in the editor

stable moth
#

I see

#

Ok

#

And btw how can i make a sprite renderer only be rendered from front

polar acorn
scarlet skiff
#

why bro doesnt wanna let me touch his x and y?

#

it is indeed a vector2

cosmic dagger
#

you're image doesn't show that variable . . .

scarlet skiff
#

oh woops

#

nvm i was suppsoed to use direction not movement

#

confused myself with variable naming

north kiln
#

!ban 971172399015940166 ignoring warnings

eternal falconBOT
#

dynoSuccess sevenenty7. was banned.

carmine sierra
#

should i calculate force using f = ma for a projectile

#

or is there a better way for unity

#

(2D)

summer stump
carmine sierra
#

life changer

#

thanks

#

does that add force though or also calculates it?

#

i need a magnitude of the force

#

and it should be dependant on an already set motion that i have

summer stump
#

Depends on what you want to do with it

carmine sierra
#

wait so how do I get the force magnitude?

#

Do i need to recode my projectile to use addforce

summer stump
carmine sierra
#

but isn't acceleration for force

summer stump
summer stump
#

Velocity is a speed and not an acceleration
(m/s vs m/s^2)

carmine sierra
carmine sierra
#

i need the force

summer stump
#

You plug in a vector and it applies force to the rigidbody

carmine sierra
summer stump
#

That is it

carmine sierra
#

but sorry to clarify can i also return the force magnitude value from the addforce thing?

summer stump
warped sorrel
#

How can I annotate a field's type as being a literal class rather than an instance of the class?

class Bar { } 
class Foo {
  public ? bar;
  Foo(? bar) {
    this.bar = bar
  }
}
// I don't want:
Foo f = new Foo(new Bar())
// I want:
Foo f = new Foo(Bar)
summer stump
carmine sierra
summer stump
#

You would have to calculate it I guess then

carmine sierra
#

cause i will have breakable objects which are destroyed when the force of the projectile on collision is great enough to destroy the object

slender nymph
carmine sierra
#

my rigidbody already has a projectile function

#

I just need to take the force from it now

summer stump
carmine sierra
#

actually?

#

why does newton say f = ma then

#

is it just more accurate

summer stump
#

What would you call the velocity at one point and then the velocity at another point?

carmine sierra
#

what do you mean?

summer stump
#

F = ma is more about finding the force enacting on one object, not collisions necessarily

summer stump
carmine sierra
#

yeah your right i just googled

#

ill use f = mv then thanks

summer stump
#

I dunno. Not something I have ever done. Just remembering physics class

mossy panther
warped sorrel
timber tide
#

Mmm foobars

charred pasture
rich adder
#

bad pivots mostlikely

#

since you seem to still have center mode on

charred pasture
#

Aghhh I got the same input from my friend too.. How can I change it?

rich adder
#

switch it to pivot

#

check all the children objects

#

or maybe they're far apart

mossy panther
charred pasture
rich adder
#

there is like a second part to that

warped sorrel
open vine
#

Hey so I have a bool that tells whether something can move up, down, left, and right. Any idea how I can get it to randomly choose one?

charred pasture
#

Got it! I solved it by changing the location of the player controller. Thank you so much for the tips

warped sorrel
mossy panther
warped sorrel
#

if getType == x

#

x needs to be the class