#💻┃code-beginner

1 messages · Page 606 of 1

honest iron
#

yes, i will show information about it

rich adder
#

well either use a component or they need to be contained inside one

thorn holly
#

So what’s the issue here, why can’t you just do what you outlined here

#

Make a new skill, give the game object a reference to it

wintry quarry
#

otherwise wth is "gameobj.add"?

rich adder
sand heath
#

Maybe your skill information should be stored in scriptable objects.

thorn holly
honest iron
#

so NewObj.AddComponent<s1>????????

thorn holly
#

Oh so skill is a component?

honest iron
#

skill is a class

rich adder
#

skill needs to be a component to be attached to a gameobject

#

otherwise it needs to be inside a MB container class, like thru a list or something

thorn holly
honest iron
#

let me start over because its ot what i meant

rich adder
thorn holly
honest iron
#

Skill is not a component, its a class(OOP)

honest iron
#

i not trying to add it

rich adder
#

mate components are also classes technically. OOP means nothing. its all objects

honest iron
#

all im asking if there is a way to store it

rich adder
#

the difference here is POCO vs Component

thorn holly
thorn holly
rich adder
#

Poco being a plain c# object, like public class MyPoco vs component public class MyComponent : Monobehaviour

wintry quarry
rich adder
honest iron
#

1min

thorn holly
thorn holly
#

I don’t think

rich adder
#

store it on a gameobject as a component or as a poco inside a list/variable in component

wintry quarry
thorn holly
#

Ohhh

#

Ohhhh wait is that what they were asking the whole time?

#

Whoops

wintry quarry
#

but really this whole question is way too vague to actually recommend any kind of cohesive or useful architecture

#

it's not clear what exactly a "skill" is or does

rich adder
#

just going by "store it" we don't really know what they plan on doing with it

honest iron
#
 public Skill GetSkill(GameObject gameObject)
 {
     string skillName = gameObject.name;
     for (int i = 0; i < Skills.Length; i++)
         foreach (Skill skill in Skills[i])
             if (skillName == skill.skillName)
                 return skill;
     return null;
 }

if there is a way to make a gameobject to hold Skill, i wont need to use this func

wintry quarry
#

Yes - of course - to add data to a GameObject you make a script that holds the data and attach it to the GameObject

#

What you're doing here is insane

thorn holly
wintry quarry
#

you're basically just using an entire Gameobject to hold a string

honest iron
#

so what 200+ scripts with the same fields just diff data

rich adder
#

you almost never need the GameObject class , work directly with a specific component

wintry quarry
#
public class SkillHolder : MonoBehaviour {
  public Skill TheSkill;
}```
#

maybe 200 instances

#

with different data

#

that part's up to you

thorn holly
rich adder
#

also this might be good usecase for ScriptableObjects
especially if you have a growing list of Skill

wintry quarry
#

Ideally set it up in the inspector - ScriptableObjects are good here, or just make it a serializable class

honest iron
#

i can see the mess i'll have if i use Skillholder

rich adder
#

how so ?

thorn holly
eternal needle
#

Not another string based system notlikethis

honest iron
#

i'll try it and see how it goes

honest iron
#

done and working, but for reason i feels like im gonna have problems with that in the future

#

maybe im just to exhausted and confused

#

anyway thanks

dense mica
#

Howdy folks, in Unity 6 with a Core 2D URP project, I'm experiencing some odd behavior with my cameras. Trying to use a second camera to a render texture via raw image in the UI to display something. My problem is the camera preview is just completely wrong. Its vertical, not square and the zoom level isn't right. You can hopefully see what I mean here:

#

Any ideas what I might be missing?

honest iron
#

i have a new problem with images(sprites)😫

#

the images arries are fix but the player skills are not, some skill getting wrong images

rocky canyon
dense mica
#

Hmm. Well it is true I'm in a mobile profile mode, but given how the camera is not the main camera, and is rendering to the texture as a 1:1 aspect, I'd have figured the preview would know what to do.

#

Is there a way to make them not inherit the global (wrong) aspect ratio?

#

It would just be handy to get an accurate preview while I'm off inspecting other stuff.

rocky canyon
#

im not too versed in 2d and render textures but ur camera should control all that..

#

the build prob wont look like that preview..

#
  • i never use the camera preview *
dense mica
#

You are correct the build doesn't look like this. Neither does the actual rendered texture in scene/game view.

#

I just like the preview since it docks and hangs around while I do other stuff.

rocky canyon
#

ahh soo its a pet peeve kinda prob

dense mica
#

Render textures are also kind of broken in the editor. They often get stuck and blank out, and only refresh if you modify a value in the editor forward and backwards.

rocky canyon
#

i just use the game-view

dense mica
#

ie, I often have to change the camera background to skybox and back to solid color hehe

rocky canyon
#

it also docks.. lol

dense mica
#

Yeah but I am editing in scene view.

#

You mean just unodck the game view into its own window and use that. Harder to do since the actual game view is locked on the UI, which isn't necessarily going to have the render texture in view.

rocky canyon
#

its just preference.. set up ur editor however u feel 🙂

dense mica
#

Yeah but my camera is rendering to a texture. It isn't used for the scene view.

#

I cant make it render to the game window.

#

Sorry if that isn't clear.

rocky canyon
#

ya little

#

so this render texture its UI i imagine?

#

is ur UI scaling/ set correctly? the canvas/

dense mica
#

The render texture gets put on a quad out of view of the game view.

#

Another camera looks at the quad and sometimes renders that to a spot in the UI. But not always. And that camera isn't done yet so there's no way to make it work in final form yet.

#

Render textures are really cool. In a 3D scene you might use them for all the display renderings of monitors in a ship's bridge for example. I wouldn't necessarily be on the bridge in the game view to look at them. Hence why its handy to cycle through all the cameras via the preview window.

#

But hey, at least I know why its acting strange now....

rocky canyon
#

ive used em for TV's and Monitors

dense mica
#

Yeah exactly.

rocky canyon
#

not as UI tho.. seems like a clever idea for some cases

dense mica
#

Yeah the RAW IMAGE type is actually only used for UI.

#

That threw me for a bit until I realized I could set the render texture to a material and add it to a quad.

rocky canyon
#

unfortunately nothing stands out to check in ur situation.. seems like it could be a handful of things

rocky canyon
#

w/ the texture slotted into the albedo/base

dense mica
#

:nod:

rocky canyon
#

i still havent found a good solution to make tv screens and stuff actually glow..

#

i can make it a bit emissive i guess. but i remember doing that before and didnt lead the results i wanted

dense mica
#

Maybe add a point light on the surface?

rocky canyon
#

unlit was the best i could come up with lol.. Shader-illiterate

dense mica
#

Every time I try to get learned on shaders I fall into the pit of learning something old or outdated because shaders have changed so much over the years.

rocky canyon
#

when it comes to render-textures and stuff

dense mica
#

:nod:

#

I'm sticking with 2D and 2.5D for now haha. Works better on mobile too.

rocky canyon
#

raytracing

#

facts lol 🙂

#

good luck w/ ur question... you might have some luck in #📲┃ui-ux

dense mica
#

Yeah I didn't think asking about Cameras in non UI/UX space would make sense there.

#

Always hard to say.

ruby python
# rocky canyon this is my ultimate goal

I'm not sure about this, but, you can build UI Shader graphs in Unity6 right? not sure if RenderTextures can be 'plugged in' as an image source, but if they can, plug the render texture in both the albedo and emission slots, add some bloom, glowing surface.

lavish magnet
#

This doesnt explain a thing 😭

#

How can i make the transition seamless

dense mica
lavish magnet
#

I want it to be chopped

#

Chipped

#

So a barrel starts with its whole mesh

#

And when i shoot it

#

I taken a tandom piece of it and disable it

#

I can do that with code but

#

or i guess shoot it out somehow wirh particles idk how to do thag neither

#

but the model that i broke with blender looks off and looks dunb even with 1 piece missing

dense mica
#

Well its mostly a skill issue. I'd work on breaking down the complex problem into manageable chunks. Start with modeling a solid barrel. Get that into the game as a thing. Get hits registering on it and delete it when hit. Then move onto a barrel that has some damage. Maybe 2-3 damage levels. If you are looking for dynamic breaking apart modeled on the fly stuff, that could be a tall order for anyone outside of a journeyman/expert.

#

So you have 4 models. A full barrel. A barrel with 1 piece, 2 piece and 3 pieces removed. Or damage levels or whathaveyou.

#

Start with just having the barrel cycle through its models as its shot.

lavish magnet
#

I have 2 models? One model is sperated into a lot of pieces

#

WHen split it looks like this

dense mica
#

So make versions of it that have a progression of splits. A whole barrel. A barrel with one piece removed. Two pieces, Three.

lavish magnet
#

that seems like quite literally the most ineffeicent way to do this if im being honest

dense mica
#

Start by just replacing the whole barrel with each progressively more damaged versions.

lavish magnet
#

Why not just cycle through an array and randomly select one

lavish magnet
dense mica
#

That is why you model it with different pieces removed.

lavish magnet
#

Maunally?

dense mica
#

You can still have an array. You can still choose what to remove each time.

#

Physics isn't amazing in game engines.

#

You can't have a thing made of parts that is dynamically destructable like you'd expect.

#

You'll need to do some fudging

#

It can SEEM dynamic to the user though if done properly.

#

So you'll have an array of barrel gameobjects. Whole, Damage 1, 2, 3, 4 ,whatever.

#

Then you'll have an array of pieces.

#

You'll replace the whole barrel with one of the models with a piece removed. And spawn in the piece in approximately the location it needs to be, and let physics move that broken off piece.

lavish magnet
#

I think i get it

#

Like manually model it 15 times.?

dense mica
#

Usually a explosion sprite/flash/smoke or whatever will hide some of the transition.

#

Given this is unlikely a core component of the game I'd follow KISS. Have damage level 0, 1, 2, 3. Have pieces 1, 2, 3.

charred spoke
#

The real question here is why are your barrel pieces offset so that a seam is visible

dense mica
#

And rely on rotation when its hit to hide the fact its always the same progression.

lavish magnet
dense mica
#

If you don't even want to model the barrel pieces and whatnot.

lavish magnet
#

Oh nice

#

Yeah nvm

#

'$50 whoppers

dense mica
#

Its all about how much you value your time.

#

And there are likely other assets, probably some cheaper. I've just run across them trying to do various things on my own.

#

A $50 asset that can slice/cut/mangle 1000s of destructables in your scene? Or a zillion hours modeling each one to be destructable? That is a way to look at it.

charred spoke
lavish magnet
#

maybe my setting are wrong

charred spoke
#

Could be. I know we use voronoii fracture

lavish magnet
#

In blednder?

charred spoke
#

Yea but unfortunately I do not know the details of that part of the pipeline…

#

Maybe we have a special plugin

#

Actually cell fracture is probably voronoii

dense mica
#

Having stability in physics based systems is tricky. Particularly if you want something like a barrel made of pieces fitting together and using friction to keep them together until interacted with.

#

In this specific case I don't see the point in overcomplicating it. I'm sure there are really good reasons to attempt such things.

#

I am reminded of this every time I'm playing an Oblivion Engine game and the room becomes a vortex of Havoc haha ;p

white girder
#

Why arent my functions showing up on the button Thinkge

charred spoke
dense mica
#

There's a framework you need to write to manage such things in a meaningful way.

#

We are in code beginner... so trying to keep things reasonable if that makes sense?

median hatch
#

model different sprites with different damaged states

lusty star
#

Hi im a code beginner, i love code

median hatch
#

once interacted with by a trigger collider you'd then add physics to it

#

giving the feeling of it falling apart or sth

dense mica
#

Well as the other user said, you could spawn them in and disable the physics on all pieces thereby "locking" it into place until you chose to unlock pieces. But that requires scripting to track and manage which pieces are hit, and their heirarchy in the model. Seems very much like overkill for a piece of scenery that you can shoot and have blow up?

#

Many different ways to skin the cat heh

dense mica
#

Can't really see how the button is fully setup from the screen grab.

white girder
#

I had the script on the Main Menu empty object guess I had to add the object into the button instead of the script itself? Thinkge

dense mica
#

The GameObject that is the button needs to have a Button Component and the Script Component added to it. Then the OnClick handler has the button gameobject referenced. Once that is all setup you should be able to pick which function on the OnClick handler calls from the script component assigned to it.

#

I still get mixed up on it from time to time too.

#

Alright well, time I get some sleep here too!

wintry quarry
#

If you think about it you can only call a function on an actual instance of a script. You can't call it on the script itself

#

that wouldn't make sense

white girder
#

It does in my head AsukaCry

wintry quarry
#

Then you don't really understand how scripts work yet.

#

A script itself is just a blueprint for creating components.

#

it's not an actual component itself.

white girder
#

I dont I just write it and it does things Thumbglass

median hatch
wintry quarry
#

but that's not the normal way of things

median hatch
#

oh yea i only do it for utility scripts

lavish magnet
#

I also wonder

#

How can i make a particle system, each particle be a random mesh

lavish magnet
#

i tried

wintry quarry
#

at least for HDRP

lavish magnet
#

URP?

wintry quarry
#

unlit meshes only for URP

lavish magnet
#

unlit is a neutral term right

rich ice
#

lit means its affected by light
unlit isn't affected by light

median hatch
lavish magnet
#

okay okay

#

damn

#

with the rednerer function in the particle systems

#

you can assign a mesh

wintry quarry
#

Oh apparently you can, yes.

lavish magnet
#

Just gotta figure out how to make the mesh textured i guess?

wintry quarry
#

wdym

#

just assign the material you want

rich ice
#

or use multiple particle systems

wintry quarry
#

it supports multiple meshes at random it looks like

median hatch
#

damn thats cool

rich ice
median hatch
#

had no idea

wintry quarry
#

same

lavish magnet
#

It kinda just turns into nothing

#

Mesh im linking

wintry quarry
#

idk, works for me. You sure you're using the right material?

lavish magnet
#

Im using this

#

None of these meshes will work

#

ica n set it to aircraft carriers tho

#

i think theirs just something wrong with my mesh for NO REASON

median hatch
#

if youre using blender

lavish magnet
#

im ngl

median hatch
#

then export the texture to unity

lavish magnet
#

i didnt even do that once

#

i just be using materials not tetures

median hatch
#

textures and custom meshes should be managed outside of unity

#

then assembled in unity

wintry quarry
#

According to the docs^

#

Did you set read/write on them?

lavish magnet
#

Is that set in unity.?

wintry quarry
#

yes...

lavish magnet
#

I have now...

wintry quarry
#

And is it working>

lavish magnet
#

hell no

wintry quarry
#

show what you did?

lusty star
#

Hi i want to import a model from blender to unity, how do i make a collision box that is the same as the mesh

lavish magnet
#

I enasbeled read and write here

wintry quarry
#

what about the one you're using in the particle system?

lavish magnet
#

i Cant edit anything

wintry quarry
lavish magnet
wintry quarry
#

you need to look at the mesh import settings

wintry quarry
lavish magnet
#

all mesh are the same i dont know what you are saying..

#

all have read/write enabeled to true

wintry quarry
lavish magnet
#

i can use any 50 interchangebly in the partrcicle system

#

all fail

#

all ahve readwrite true

wintry quarry
#

Well idk - I just discovered particle system can uses meshes 10 minutes ago

#

so this is the limit of my knowledge

lavish magnet
#

i cant believe i just taught you something

#

partially

wintry quarry
#

I learn new stuff about Unity all the time

lavish magnet
#

i am

#

getting these errors

wintry quarry
#

Ah that explains it

lavish magnet
#

Sorry

#

Just noticed

wintry quarry
#

Apparently it only supports a single submesh

#

and your mesh(es) have more than one

lavish magnet
#

i dont even

#

I cant understand that 😭

#

my broken barrel has 50 sub meshes

wintry quarry
#

no

#

those aren't submeshes

lavish magnet
#

what is a SUB mesh

earnest ginkgo
#

dose anyone know how to like when you press a button you disable the button that is active

wintry quarry
#

hard to explain... basically a set of triangles in the mesh which gets drawn with a material

#

multiple submeshes -> multiple materials

#

it's probably how you have the two different textures on the barrel

wintry quarry
earnest ginkgo
#

yes

lavish magnet
#

had to explain and hard t understand

#

if ane asy fix, what is it in my case or?

#

do i bake a texture or something or like

wintry quarry
earnest ginkgo
#

so im making a shop but when i open a tab the others are still open

wintry quarry
#

(which means only one material in Blender)

wintry quarry
#

pictures and a better explanation might help

earnest ginkgo
#

no so one sec

lavish magnet
#

BUT IM USING 2 COLORS

wintry quarry
#

That can be done with UV mapping

earnest ginkgo
#

so when i press a button i want the other one that is open to close

wintry quarry
#

the other... button? tab?

#

I'm not sure I see what's open here that needs to be closed

earnest ginkgo
#

so for example if the colour button is active then i want the hats button to be disabled because otherwise they are both open

wintry quarry
#

I think you want all the buttons to be active all the time

#

it sounds like you want the tab that the button opens to close

#

Otherwise how would you switch back to the hats?

#

or am I still misunderstanding?

#

ANyway I already answered above how to disable a button

lusty star
earnest ginkgo
#

so if i press all the bottuns all the other bits inside are open

wintry quarry
earnest ginkgo
#

ughh idk its hard to like understand

wintry quarry
#

I think it's pretty simple

#

you either want to close the "bits", or you want to disable the buttons

earnest ginkgo
#

so if i poen the colours tab i want the other tab that is open to close

wintry quarry
#

right exactly

earnest ginkgo
#

yeah

wintry quarry
#

So... deactivate it

#

keep a variable:

GameObject currentlyOpenTab;```
lavish magnet
#

baking rn

#

my first one

earnest ginkgo
#

but i want it to do it automatically

wintry quarry
# earnest ginkgo ohh

and when you switch:

void SwitchToNewTab(GameObject newTab) {
  // close the old one
  if (currentlyOpenTab != null) currentlyOpenTab.SetActive(false);

  currentlyOpenTab = newTab;
  // open the new one
  currentlyOpenTab.SetActive(true);
}```
earnest ginkgo
#

yeah ok

#

thanks

#

@wintry quarry but then how would it know that tab is open?

#

!code

eternal falconBOT
earnest ginkgo
#

cs

#

cs [SerializeField] GameObject currentlyOpenTab;

wintry quarry
earnest ginkgo
#

nope

#

but how would it know what the "currentlyopentab" is

wintry quarry
#

Your code tells it

#

look at my function

#

we store whichever object you pass in there in that variable

#

currentlyOpenTab = newTab;

earnest ginkgo
#

so now with the script what would i do to the tabs

#

where wold i put it

wintry quarry
#

to use this you would do like:

public GameObject HatTab;
public GameObject ShirtTab;

public void OpenHatTab() {
  SwitchToNewTab(HatTab);
}

public void OpenShirtTab() {
  SwitchToNewTab(ShirtTab);
}
#

for example^

#

those functions would be the ones assigned to your buttons

earnest ginkgo
#

im not sure what to do

wintry quarry
earnest ginkgo
#

like i put the code in a c# script but where do i put ti

#

it dosent know what the currently opentabs are

lavish magnet
#

praetor you have sent me down a rabbit hole

olive lintel
#

Hey guys, stupid question but is there any function equivalent of Transform.InverseTransformDirection that only needs a quaternion for efficiencies sake? ergo, instead of needing to create a gameobject with a transform and destroy it each time I want to find a direction relative to a rotation, I can just use a Quaternion related function? This is the example code I've been using right now for a building system for my game. Currently the system is working perfectly, it's just that I dislike building and destroying gameObjects each frame just for this one simple function. It seems really inefficient. Any help is greatly appreciated.

Transform testTransf = new GameObject().transform;
testTransf.rotation = Quaternion.Euler(0, buildAngle, 0);
float addZ = Vector3.Angle(buildForward * Vector3.up, getHit.normal);
if (testTransf.InverseTransformDirection(getHit.normal).x > 0)
        {
            addZ = -addZ;
        }
Destroy(testTransf.gameObject);
dispTransf.rotation = Quaternion.Euler(buildForward.eulerAngles) * Quaternion.Euler(new Vector3(0, 0, addZ));```
#

(Quaternion.Euler(buildForward.eulerAngles) * Quaternion.Euler(new Vector3(0, 0, addZ)); is the end goal roation I'm trying to find)

wintry quarry
#
var rotation = Quaternion.Euler(0, buildAngle, 0);
Vector3 rotatedNormal = rotation * gethit.normal;
Vector3 inverseRotatedNormal = Quaternion.Inverse(rotation) * getHit.normal;```
olive lintel
lusty star
#

So i added a mesh collider but the mesh still falls thru the floor

wintry quarry
#

If you don't have your console window open when you're using Unity, it's like driving a car with your eyes closed.

lusty star
#

So you are saying i should listen to my console

wintry quarry
#

yes

#

it means you would need to mark the Convex checkbox on that collider for it to work

lusty star
#

Oh

#

You made it sound extremely simple thx ill find it

grand snow
#

UnityChanOops phone pics

lusty star
#

Holy shit it fucking works

#

Thx

#

But concave = convex??

#

What are those

lusty star
wintry quarry
#

basically - collision math is much simpler for convex shapes. It wouldn't be performant to allow concave shapes to be dynamic.

lusty star
#

So concave is not filling the whole mesh?

wintry quarry
lavish magnet
#

using a moving particle system with a box collider for ubllets, on collision with a barrel, on my barrel script i have an oncoliision enter, or i guess ontriggerenter since the bullettrail isTrigger is true. but nothing triggers in the script

slender nymph
lavish magnet
#

IM NGL

#

I READ IT AND

#

NO NEW INFO IS UNDERSTOOD

slender nymph
#

pay actual attention to it then

lavish magnet
#

im trying man

#

i cant focus on it

#

i literally am like

wintry quarry
lavish magnet
#

even if i just have a box collider on it?

#

should i parent a box collider then?

#

particle system as a hcild

slender nymph
#

please finish a thought before sending a message

lusty star
wintry quarry
#

Why are we mentioning the particle system then

#

Anyway it seems like you're mixing up 2D and 3D stuff

#

which that link box sent you would be showing you

#

if you just follow it

lavish magnet
#

well its literally just a moving gameboecjt

#

OH MY

#

i just had a typo

#

dawg

#

it stioll doesnt work but at least i fixed the typo

#

preshy

slender nymph
#

now go through the rest of the steps in that link i sent to find out what else you've done wrong

lavish magnet
#

am rn

#

i have a questiojn do you know exactly what it is

#

DONT TELL ME

#

dont spoilt it

#

but do you

#

ypur read it 3 times nothing

slender nymph
#

then show the relevant objects

lavish magnet
#

bad photo sorry

slender nymph
#

😮‍💨
so you didn't pay much attention to the information in that link

lavish magnet
#

boxfriend i literally just

#

i hate my type of people too

#

i just cannot

#

i dont have it in me

#

i read it so many rimes

#

and i clicked istrgiger and other struff so many times

#

regardless, shouldn't ONE of those prints go through.

slender nymph
#

again, finish a thought before sending a message. we don't need this spam

lavish magnet
#

okay

#

opp 😔

slender nymph
#

alright i'm out good luck

lavish magnet
#

bleh

#

Its something with thew trigger matrix

#

goodness gracious

#

thanki got it

slender nymph
lavish magnet
#

wowd dude do you want me to use capitalization and periods too?

sand gate
#

why is the trail pink?

slender nymph
#

that's the "no material or shader not supported on this pipeline" color. also not a code question

slender nymph
sand gate
slender nymph
#

yes, you install the package for the other pipeline and assign the relevant pipeline asset in the graphics settings. but that is not something you need to do for this, you need to make sure you have actually assigned a valid material to the trail renderer and that the material has a shader that is made for the pipeline you are using

woeful vortex
#

How do I remove this error. Its all looking fine. btw i am watching gmtk's tuotorial

slender nymph
#

you're probably missing a }

muted pawn
#

you missing a }

woeful vortex
#

its there

slender nymph
#

show the entire class because errors don't lie

muted pawn
#

noo show the whole code

#

@slender nymph okay you are quicker, ill leave it up to you

woeful vortex
#

using UnityEngine;
public class BirdScript : MonoBehaviour
{
public Rigidbody2D myrigidbody;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{

}

// Update is called once per frame
void Update()
{
    if (Input.GetKeyDown(KeyCode.Space) == true)
    {
        myrigidbody.linearVelocity = Vector2.up * 10;
    }
}
slender nymph
#

first, !code
second, you are missing a }

eternal falconBOT
muted pawn
#

you are missing the one at "public class BirdScript : MonoBehaviour
{"

you didnt close the class at the end

woeful vortex
#

now there are 2 reds

slender nymph
#

well you've gone and added a { for some reason instead of adding the missing }

muted pawn
# woeful vortex this?

noo, you put the } at the end of the whole code. If you find yourself with more of these errors maybe I suggest you to maybe understand syntax in C#

woeful vortex
#

oh k

slender nymph
#

there are beginner c# courses pinned in this channel that will teach the fundamentals of the language, like the basic structure

woeful vortex
#

👍 thank you

halcyon dagger
#

Shouldnt this detect only colliders tagged "Player"?

cuz its just ignoring everything.

muted pawn
#

@slender nymph good luck with your flappy bird game 😊

halcyon dagger
#

this works, but everytime u add a layer new it automatically gets added as unchecked so is not a valid solution

slender nymph
halcyon dagger
#

So it just overrides this?

slender nymph
#

yes

halcyon dagger
#

Alr, thx

rough lynx
#

Past few questions have been an interesting read lmao

quick star
#

Friendly reminder for all that you when you're spawning game objects at different points in your game to include the in game location. (Position.x + x, position.y + y, position.z +z). I pass this on to you because it took me a lot longer than I'm comfortable admitting to realize the error in my thinking. Maybe there's a better way, but that's just my take

tulip nimbus
#

I have this error message:

Assets\Scripts\Enemies\Wolf.cs(126,35): error CS7036: There is no argument given that corresponds to the required formal parameter 'damage' of 'Wolf.TakeDamage(int)'

This is my Coroutine in Player

{
    Debug.Log("PlayerDamaged");
    isDamageable = false;
    Body.color = Color.red;
    HP--;
    yield return new WaitForSeconds(0.2f);
    Body.color = Color.white;
    isDamageable = true;
}```

And this is the code that is supposed to Start this coroutine, but i get an error message, even tho i have no int paremeter. 

```Player.StartCoroutine(TakeDamage());```


Whats wrong here?
slender nymph
#

seems like your TakeDamage method previously had an int parameter but you haven't saved that file since making that change

#

wait, is the TakeDamage method you just showed the same one on the Wolf class?

tulip nimbus
tulip nimbus
slender nymph
#

right and you're starting the coroutine from the Wolf class. which means that is this.TakeDamage() not Player.TakeDamage()

#

and Wolf.TakeDamage expects an int parameter

tulip nimbus
#

Oh i figured it out, im so sorry

slender nymph
#

remember, unless you call a method on a specific object, you are implicitly calling it on this

tulip nimbus
#

It was Player.StartCoroutine(Player.PlayerTakeDamage());

instead of Player.StartCoroutine(PlayerTakeDamage());

#

Thank you!

vapid plinth
#

I have the most random glitch icl, I tried to implement a camera rotation system and it ended up causing the players position and rotation to change

muted pawn
vapid plinth
muted pawn
naive pawn
vapid plinth
naive pawn
#

you're giving very little info here, some context would help

frigid sequoia
#

Mmmm... how can this cause that error?

#

Could it be that there are no components?

naive pawn
vapid plinth
naive pawn
#

!code

eternal falconBOT
naive pawn
frigid sequoia
#

The error is on the line of the foreach though

muted pawn
# vapid plinth Ok

that too, I always think its best to make a camera controller script that takes the transform from the player object :)

#

and treat them seperate if that makes sense?

slender nymph
vapid plinth
#

ok thanks. I will try that now

frigid sequoia
grand snow
#

for loop and go backwards!

slender nymph
#

use a reverse for loop instead

grand snow
#

for(int i = list.Count - 1; i >= 0; i--)

naive pawn
frigid sequoia
#

Isn't that gonna return error as soon as I remove anything?

naive pawn
#

(im biased against mutations)

grand snow
#

its also valid to use .Where().ToList() but its gonna make more garbage than the manual method

naive pawn
west radish
# frigid sequoia Isn't that gonna return error as soon as I remove anything?

You get the error when going forwards, because the loop might start with 10 items, you remove 1 item, so once you are at item 9 the loop wants to then move to the next non-existent item as it was told 10 items exist.

But going backwards, you start at item 10 and go backwards to the first item. So once you reach the first item in the list, it doesnt actually matter at that point that the list was modified to only have 9 items

naive pawn
#

(you won't get an error, you'll get a bug)

slender nymph
#

yeah looping forward and removing items will cause items in the list to be skipped

naive pawn
#

with lists there's generally no need to cache the count, so you'd just get the count of the list in the condition; the loop won't go over the bounds of the list

grand snow
#

🗣️ 🧱

naive pawn
#

im. just absolutely lost on what that's supposed to mean lmao

grand snow
#

guy speaking to brick wall meme

west radish
#

hes breathing on the brick

grand snow
#

many people explaining the same thing but person who needs it probably not even reading it

naive pawn
#

i read it "spitting bricks"

rich ice
rich ice
sand gate
#

where should i learn arrays and lists from

#

i have 0 knowledge abt how to use them

queen adder
slender nymph
fierce shuttle
# sand gate where should i learn arrays and lists from

Arrays and lists are C# specific and not Unity specific, so you should be able to finds lots of resources online - w3schools has a great C# course which covers both arrays and lists in good detail imo, and with a "sandbox"-like way of practicing on the site, all for free

sand gate
#

thanks a lot

sand gate
#

ill look it up

unique quail
#

Hi, i have a little problem when i'm trying to add a script in my gameobject i have this message, and all my script didn't work now

woeful vortex
#

how much time does it take to learn the basics of C# in unity

slender nymph
#

How long is a piece of string

modest dust
#

As much time as you'd need to go through the courses on !learn or pinned in this channel and becoming accustomed to reading the docs when you don't know something + a bit of time to understand that such questions are meaningless

eternal falconBOT
#

:teacher: Unity Learn ↗

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

ruby python
# woeful vortex how much time does it take to learn the basics of C# in unity

It all depends really on how best you yourself learn things.

For example, some people learn best by reading, some by someone verbally explaining, some by visual learning or by picking apart existing code etc.

So, I learn best usually visually and verbally, so I've learned a lot by watching Youtube tutorials about things. Granted they usually tell you the wrong way to do things and there's a lot of lazy coding in them, but for the most part they've been a good resource for me personally.

#

A lot of times, just asking a question in here and talking about it 'out loud' helps me get to the solution.

last radish
#

Im tryinh to make procedural wall generation for the backrooms, and stumpled accross this video(https://www.youtube.com/watch?v=wQj-l0vDQsA that describes how he generates walls. At around 3:13 he slightly explains it but i have no clue how to actually do it. Could someone help?

I think im supposed to describe stuff here...

I made the backrooms in unity and unreal and also a bunch of other stuff.

0:00 - Intro
0:04 - Time Stamps
0:28 - using Unity
0:43 - Prop Hunt
1:03 - Mario Kart
2:00 - 3D Among Us
3:00 - Backrooms ( Unity )
5:03 - Switching to Unreal
5:35 - Backrooms ( Unreal )
7:04 - Visuals
8:25 - Walls
8:50 - Wa...

▶ Play video
polar acorn
#

Not sure if a video with "in unreal" in the thumbnail is gonna help much with unity

last radish
#

its in unity

#

he does it in both for some reason, but the underlying logic of how the wall generation works is what i dont understand

queen adder
teal viper
chrome apex
#
// void Start()
    {
        rb = gameObject.GetComponent<Rigidbody2D>();
        rb.AddForce(new Vector2(Random.Range(10, 20), Random.Range(10, 20)),ForceMode2D.Impulse);
    }

This doesn't seem to have an effect, even if I scale the force values to thousands. Why? Mass of the object is 1

polar acorn
#

Well your function declaration is commented out kappa

chrome apex
polar acorn
#

Assuming that's just a copy-paste error, my guess is that something's rewriting the velocity in update

polar acorn
chrome apex
#

I deleted the update method

chrome apex
#

there you go

polar acorn
polar acorn
naive pawn
#

where's the MenuBallMove?

chrome apex
#

Oh my god

#

what a fkn moron

#

ofc it works now

visual linden
chrome apex
#

I swear, the easiest problems are the hardest to solve cause you'd never think you would be so stupid as to miss it

visual linden
#

Happens to the best of us

cosmic dagger
# woeful vortex how much time does it take to learn the basics of C# in unity

There is no timetable for learning a programming language. It solely depends on the person learning, their aptitude, discipline, and determination. Two people can practice for 5 hours for a week and be a drastically different levels

Discipline is key. Practice every day, write ALL of your code, and repeat, repeat, repeat . . .

cosmic dagger
naive pawn
#

if code doesn't do anything at all, is it even running? thinksmart

cosmic dagger
#

I didn't hear back from you, so here's a sample test—this is similar to what I suggested. If you don't need Unity, you can run a quick test in c# . . .

wanton epoch
#

I was wondering if anyone could help guide me to the correct information for my question? I am trying to connect my unity game's data to a website to allow players to see their stats (damage taken/time played/etc). What would be the best way to connect my game and website to allow this transfer of data as well as store this data?

naive pawn
#

you'd need a server+database as a central system to hold everything

#

the website interacts with the server, the game interacts with the server

#

#archived-networking would be relevant for specific parts, but i think your current question is more about architecture/system design, no specific channel for it

wanton epoch
#

would you know of a tutorial to perform this? or additionally any free/simple ways to create the server and connect the website and game to?

visual linden
#

I think https://playfab.com/ is a pretty popular choice, and I'm sure there's plenty of tutorials on Youtube

naive pawn
#

ive given you some new keywords, try looking those up

grand snow
wanton epoch
#

thanks a lot guys

winged seal
#

game went kaputt

hardy phoenix
#

Hello

#

I'm trying to add music to my unity game

#

I have an Audio Source obiect with that script:

frigid sequoia
hardy phoenix
#

On some scenes where I want to turn the music off I use object with that script:

frigid sequoia
#

But yeah, I should try that now, just to know how to do it

hardy phoenix
#

but when I'm comming back to the basic scene where I want to start music again I get this warring and it doesn't work

wintry quarry
# hardy phoenix
  1. Using static variable (playOnNextScene) is discouraged. Make that a regular variable on the singleton instance.
  2. your code in lines 21-24 in BG_Music will run even when you destroy the object. That's not a good idea.
#
  1. Awake is not going to run when you load a new scene. so the actual singleton instance will not be able to consume that bool.
cosmic dagger
wintry quarry
# hardy phoenix

yeah because you're trying to play the audio source you're destroying on line 19 on line 23

hardy phoenix
#

wait

#

what?

wintry quarry
#

think about the code

#

and how it runs

#

and on which object it will run

hardy phoenix
#

but there is always an instance

wintry quarry
#

Yes in fact there are multiple instances

hardy phoenix
#

how?

wintry quarry
#

when you load the scene there's an instance in the scene that you loaded

#

which destroys itself on line 19 right?

#

But taht is also the instance which runs the code on lines 23 and 24

hardy phoenix
#

DontDestroyOnLoad

wintry quarry
#

so it's trying to play its own audio source as it destroys itself

polar acorn
wintry quarry
hardy phoenix
#

it's used to DON'T destroy object

wintry quarry
#

I'm fully aware of what it does

#

I'm talking about what your code does

hardy phoenix
#

so normally it dont destroy objects but in my code it destroy it?

polar acorn
#

What happens in Awake when instance is not null, but also playOnNextScene is true?

wintry quarry
#

Do you know what your code is doing?

hardy phoenix
wintry quarry
#

You have the DDOL instance that stays between scenes, and then other instances that are destroying themselves

#

do you understand that bit?

#

DO you understand when Awake runs?

hardy phoenix
#

on load

wintry quarry
#

on load for that particular instance

#

It will only run once per instance

#

So your first instance will DDOL itself

#

Second and subsequent instances will destroy themselves

#

this is all just what your code is doing in Awake

#

But your subsequent instances are also the ones running lines 23 and 24, after they have already started the process of destroying themselves

#

It's not your original DDOL instance that is running those lines

hardy phoenix
#

thankss!

#

now I understand

slow knot
#

NullReferenceException: Object reference not set to an instance of an object
UnityEditor.SceneViewMotion.SetInputVector (UnityEditor.ShortcutManagement.ShortcutArguments args, UnityEditor.SceneInputAxis axis) (at <18226ebcc7724db583d19c0aeb6444e9>:0)
UnityEditor.SceneViewMotion.WalkLeft (UnityEditor.ShortcutManagement.ShortcutArguments args) (at <18226ebcc7724db583d19c0aeb6444e9>:0)
UnityEditor.ShortcutManagement.Trigger.ExecuteShortcut (UnityEditor.ShortcutManagement.ShortcutEntry entry, UnityEditor.ShortcutManagement.ShortcutStage stage, System.Object context, System.Boolean reset) (at <18226ebcc7724db583d19c0aeb6444e9>:0)
UnityEditor.EditorApplication:Internal_CallGlobalEventHandler()

did my unity spazz out or did i do something

rich adder
#

spazzed

slow knot
#

alright

#

also, i duplicated a wall, but they didnt even get duplicated, just a new plane with completely different scripts and attributes

#

oh wait im just stupid newvermind

swift crag
#

That's caused by non-uniform scaling of a parent

#

The rule of thumb is to not parent things to an object whose scale isn't uniform

#

e.g. [5, 1, 1] is a non-uniform scale

#

As the child rotates, it aligns with the parent's scaling in different ways

#

causing shearing

slow knot
#

thanks

rich adder
#

skewcity

rich adder
slow knot
#

Yeah i know, its just that every sinmgle time without fail the nvidia apps videos take more than 10 mb lmao

rich adder
#

OBS is 🐐

#

ShareX is good too

#

both can record like 30 min video for less than 20mb lol (a bit exaggerated but you get the point)

grand snow
#

sharex is great

slow knot
#

alright thanks a lot, i like this server a lot more than most other coding servers. Almost every single one have most people been more of a hassle than a help

swift crag
#

also, for recording the game view itself, the Recorder package is fantastic

#

(not relevant here, though)

forest orbit
#

I'm trying to do some basic netcode setups but the buttons I have made to start client, server and host dont work at all, they dont even highlight when I hover over them.
follow this tutorial https://www.youtube.com/watch?v=3yuBOB3VrCk&t=676s stuck at 13:00

wintry quarry
#

doesn't seem related to any of the networking stuff

#

You need an event system if you want UI to be interactable

forest orbit
#

added that and it worked, ty

#

what does an event system do tho? why doesnt a canvas suffice?

swift crag
#

the event system reads input and checks if you've interacted with something

#

typically UI elements, but it can also hit things with colliders

polar acorn
#

It's automatically added when you create your first canvas

wintry quarry
#

Also if you add a canvas or any UI element from the menu it adds an event system automatically

forest orbit
#

ohh

wintry quarry
#

The fact you didn't have one means you either copied these objects from another scene or you manually added the components

swift crag
#

or just deleted it

#

i've done that

#

"weird object, die"

forest orbit
#

I think I just didnt recognize it and deleted it

#

haha yea exactly

wintry quarry
#

"what's this do? Doesn't look important"

swift crag
#

it's like how i instantly close most popup windows without actually reading them

lusty star
#

Hi i got mesh collider on an object and it doesnt give it collision

wintry quarry
lusty star
wintry quarry
#

screenshot please, not phone photos 😭 , and why did you cut out the inspector

#

the inspector is the most important part here

lusty star
wintry quarry
#

so there will be no collision geometry

polar acorn
lusty star
#

I cant screenshot normally rn

lusty star
wintry quarry
lusty star
#

Btw i see its not hollow in the inside

wintry quarry
#

you need to either rotate the child or put the collider on the child.

polar acorn
#

Put the mesh collider on the object that already has the mesh

lusty star
#

How do i access the child

wintry quarry
#

In what context?

polar acorn
lusty star
#

I found but now another problem

#

How do i center

lusty star
wintry quarry
wintry quarry
#

you can only put it on a child object and move/rotate/scale that child object

lusty star
#

Oh shit you were correct

wintry quarry
#

the simplest solution is yes to just put it on the same object as the renderer with the same mesh

lusty star
wintry quarry
#

I'm telling you it

lusty star
#

Alr alr i got it

#

So another problem

#

Its not hollow

polar acorn
#

but if you do, it cannot have a rigidbody

lusty star
#

Waot

#

Wait

#

So THAT is convex ahhhhh

wintry quarry
#

it can have a Rigidbody just not a dynamic one

#

yes that's what convex means

lusty star
#

Like convex and concave i understand now

#

So convex fills the gap

#

HELL YEAH IM LEARNING

#

I didnt see the hitbox when doing convex so i got scare its not there

#

Also you typed "hitbox" its not called hitbox??

wintry quarry
#

it's called a Collider

lusty star
#

Alr alr gotcha

wintry quarry
#

but I typed "move the hitbox" because I was quoting you

earnest ginkgo
#

hey i need some help so im creating a runner game but in my shop scene i want to be able to equip a cosmetic and for it to show up in a different scene? anyone know to to?

lusty star
wintry quarry
wintry quarry
#

that means a Kinematic RB

#

Kinematic Rbs will not move on their own or with the physics simulation, only via your script

wintry quarry
earnest ginkgo
#

ok

wintry quarry
#

for example:

GameObject equippedHat;```
forest orbit
#

anyone have experience with downloading this? I'm trying to right now but it won't let me, when I add by git url nothing happens

wintry quarry
#

most likely you don' have git installed or your URL is wrong

forest orbit
#

I don't think I have git installed, how do I install it?

cosmic charm
#

what do we call this type of bosses where he follows you and your job is to keep distance between you to and dodge his attacks? and do you know any tutorial on how to do it?

wintry quarry
#

but check your console to make sure that's the problem first

swift crag
#

although it doesn't have to be an auto-scroller; the screen can stay focused on the character

cosmic charm
#

Fen you'r awesome you're always here to help

forest orbit
wintry quarry
# forest orbit nothing there :/

Make sure errors aren't disabled in console. Also Can you show a screenshot of the console directly after entering the git url?

forest orbit
#

mb, found the error

#

yea no git installed

cosmic dagger
lusty star
forest orbit
#

@wintry quarry new error 💔

wintry quarry
rich adder
#

make sure you dont have any trailing extra chars or whitespaces

#

pretty sure that sample is now already part of the Package Manager no need to even pull from git

swift crag
misty sand
#

anyone know the problem with this code? it wont change scenes when i go through the box collider, yes my box collider is set as a trigger

slender nymph
#

do the logs print

misty sand
#

no

slender nymph
misty sand
rich adder
#

thats why

polar acorn
misty sand
#

can you explain?

rich adder
#

you need the 2D version.this one checks for 3d colliders

slender nymph
misty sand
#

im using the 2d version

slender nymph
#

no you aren't

rich adder
#

not the function

misty sand
#

oh

rich adder
#

that function looks for 3D colliders

misty sand
#

how could you tell its the 3d version

rich adder
#

because it doesn't have the word 2D in it

polar acorn
misty sand
#

where should i add the 2d

rich adder
#

anything 2D physics related in unity has 2D usually affixed to it

rich adder
gleaming wagon
#

Opened my project and this 3d model is suddenly transparent in scene view but not in game view?? This makes no sense and wasnt happening before. Any ideas how to fix this?

wintry quarry
#

(also goddamn why are the unity docs like this. You don't see the OnTrigger2D code until the very bottom of the page / code sample 😢 )

swift crag
#

You have the object hidden

#

notice the crossed-out eye

gleaming wagon
#

My bad 😭

swift crag
#

You can quickly clear this from everything in your scene by double clicking the eye next to the scene in the hierarchy

#

that hides everything, then unhides everything

gleaming wagon
#

I must have pressed a shortcut to hide it accidentally, thanks

misty sand
#

i changed it but now its saying this "onTriggerEnter has an incorrect signature"

misty sand
#

im new thats why im here

rich adder
#

did you look at the link praetor sent literally has the signature written

slender nymph
polar acorn
misty sand
#

i dont understand what its saying

#

im a complete begginer

#

2nd ever game

polar acorn
#

It's written for complete beginners

#

If you don't know what it's saying, look up the words you don't know

slender nymph
misty sand
#

i dont understand c# to that level

rich adder
polar acorn
misty sand
#

its just confusing

polar acorn
#

Do you have logs in your function?

slender nymph
eternal falconBOT
#

:teacher: Unity Learn ↗

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

polar acorn
#

The page is literally step by step, question and answer. You click on the links that answer the questions. It's the most simple thing you're going to see.

#

First step: put in some logs. Do you see em?

rich adder
#

a lot this is reading , not so much to do with c#

slender nymph
#

i'm willing to bet they are actually looking at the doc page that praetor linked rather than the much more useful huh.how site that was linked almost immediately after they asked for help

misty sand
#

why do you guys have to be so mean

slender nymph
#

literally where has anyone been mean

polar acorn
#

This whole back and forth question and answer thing is literally how the page is structured

rich adder
#

yes, those are courses to start from beginning

acoustic belfry
#

i dont know what's going on, but the bullets in my script dont decrease, and also after some time when i fire the player bullets, it stops the game, somethings wrong, maybe is the enemy script? How do i post huge scripts?

slender nymph
#

!code

eternal falconBOT
acoustic belfry
#

btw, this is the script of my enemy, i dont know what im doing wrong.

What i tried to do, wich didnt worked, was that after the bullets of the enemy dry out, it executes an animation, and the enemy must wait till that animation ends to return shooting

earnest ginkgo
#
using JetBrains.Annotations;
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.SceneManagement;

public class HatSwitcher : MonoBehaviour
{
    public static HatSwitcher instance;

    public GameObject Hat;

    private void Awake()
    {
    
        instance = this;

        DontDestroyOnLoad(this.gameObject);
}
#

dose anyone know what is wrong?

swift crag
#

you are generally expected to match every opening { with a closing }

earnest ginkgo
#

yes ik but when i take away the { it is all an error

verbal dome
#

You are supposed to add a }, not remove a {

north kiln
#

Classes and methods both need braces

#

You can't take either away

earnest ginkgo
#

yeah it worked tbh i didn't even think of doing that

rich adder
#

also might wanna do a proper disposal of copies of Instance, incase you have more than 1 in scene

#
if(instance != null && instance != this)
Destroy(gameobject); return;
instance = this ```
acoustic belfry
verbal dome
rich adder
#

start putting logs

#

check points of failure

verbal dome
#

Do you perhaps have Error Pause enabled in console?

acoustic belfry
# verbal dome What do you mean "randomly stops"?

well, thats not the big of the issues, but for an strange reason the gameplay "crashes" mid game, when i shoot the enemy, or thats what i thought, it just happened twice, and with random circustances.

But the issue is, the animation doesn't play, an the bullets dont decrease

rich adder
#

crashes as in what it freezes?

acoustic belfry
#

no, it closes

#

its like the player dies...But without having her dying

#

wich is...weird

verbal dome
#

Whole unity closes?

acoustic belfry
#

no

#

only the game, it returns to the editor window

rich adder
#

are you getting a Bug report window ?

acoustic belfry
#

as i said

#

like when the player dies

#

but without having her to die

swift crag
rich adder
#

thats not game crashing lol

hollow prism
#

Hi

swift crag
#

That's probably the editor pausing.

acoustic belfry
#

my bad, the game stops

acoustic belfry
swift crag
#

This will happen if Error Pause is turned on (and you get an error)

rich adder
#

then yes you probably have pause on error

acoustic belfry
#

the issue (wich wasn't the main issue but still), is why?

verbal dome
#

Ugh so much noise

rich adder
#

if you have an error you need to fix it lol

#

have you checked console at all

acoustic belfry
#

but the main issue, atleast for me, and i think this might fix it, cuz this happened after all the code editing i did

Is why it happens the bullet thing

acoustic belfry
rich adder
acoustic belfry
hallow acorn
acoustic belfry
rich adder
rich adder
#

it still wouldnt pause

#

you have to show runtime errors if any

verbal dome
#

You can also make it show only errors by selecting this

acoustic belfry
#

dis is all

rich adder
#

seems your controller doesnt have whatever string / name you're passing to it

#

clips

wintry quarry
swift crag
#

importantly, you have errors hidden in the console right now

verbal dome
#

:|

acoustic belfry
swift crag
#

There are zero errors in this screenshot, but, if you had one, it wouldn't show up in the console window

acoustic belfry
#

i mean, with looking at the code u can't see the problem?

wintry quarry
#

Or a disabled GameObject

acoustic belfry
#

the enemy walks good

acoustic belfry
rich adder
#

was this after the reloading tthing or was that working?

#

tbh I always prefered transition states than calling Play directly

swift crag
#

Note that these are warnings, not errors. Trying to play a missing animation state wouldn't throw an exception and break your code.

rich adder
#

there is def more code throwing these

swift crag
#

If your game was pausing, that means that an actual error was happening

rich adder
#

when the game pauses, screenshot your entire console window

swift crag
acoustic belfry
#

as said, its random, i play it and didnt trigger :<

verbal dome
verbal dome
#

How do you know? Are you looking at the inspector?

acoustic belfry
#

aaah the decreasing part

#

yes

#

im looking at it

verbal dome
#

Since balas is public, something else could be modifying it

acoustic belfry
#

oh

#

btw now i changed it name

verbal dome
#

Like another script of yours, or maybe an animation (unlikely)

acoustic belfry
#

lets see if works

rich adder
#

you generally want to keep all fields private

#

if something else needs access, usually a read only use a Property getter or Method that returns that value

#

otherwise stick to methods to modify them so clearer whos touching it (eg you can invoke events or print logs when its modified)

acoustic belfry
#

what the fluck this thing means?

rich adder
#

youre trying to destroy a prefab

slender nymph
#

you're likely passing the prefab to Destroy rather than the instantiated object

rich adder
#

yep

acoustic belfry
#

w h y

#

i never signed for that

slender nymph
#

it's your code, you tell us why

rich adder
#

You're doing cs private Bullet bulletPrefab; Destroy(bulletPrefab)
instead of

var bulletInstance = Instantiate(bulletprefab
Destroy(bulletInstance )```
acoustic belfry
rich adder
#

one is destroying the prefab in your project (an asset)
the other is Destroying clone, aka the instance made from that asset

acoustic belfry
#

o h

grand snow
#

and unity stopped you as well you probably dont want to delete your asset...

rich adder
#

haha yeah that wouldn't be good if you can just start deleting assets that easy

acoustic belfry
slender nymph
#

that is just an example of what you are doing, not your literal code

acoustic belfry
#

oh

verbal dome
#

And no it's not in the code you linked us

acoustic belfry
#

the deleting thing is in the object


public class MortemRifleProyectile : MonoBehaviour
{
    public int damage = 5;

    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.transform.TryGetComponent(out ValeriaController player))
        {
            player.TakeDamage(damage);
            Destroy(gameObject);
        }
    }
}```
rich adder
#

thats not it

acoustic belfry
#

well, there's nothing else

rich adder
#

there is

acoustic belfry
#

...where

#

o-o

rich adder
#

dont you have something shooting bullets?

acoustic belfry
#

yes

#

but i dont have a script that looks like the script you did

polar acorn
acoustic belfry
#

or i think

rich adder
polar acorn
#

We don't know where you're calling Destroy

acoustic belfry
verbal dome
# acoustic belfry AHA!

Does this not take you to the code where it happens, when you double click the error message?

acoustic belfry
rich adder
#

the game crashed? or the game stopped doing what you coded it to do..

hallow acorn
#

hey my player gains height as long as i keep my jump button pressed and i dont know how to do something about it. im relatively sure this section of my code is what causes the problem. i watched the tutorial i was following 3 times and i just cant find it.

acoustic belfry
verbal dome
rich adder
#

cause if that appeared you have pause on error on

verbal dome
acoustic belfry
#

but i mean, this didnt happened before trying to make the reloading s h i t

rich adder
#

so you try to destroy an asset according to your error, then it pauses

acoustic belfry
verbal dome
#

Double click that error message and see if it shows the code where it happened

acoustic belfry
#

my T R U E issue, atleast for now, is that the bullets amount dont decrease

rich adder
acoustic belfry
#

i mean

rich adder
#

look for all scripts that contain Destroy 😬

acoustic belfry
#

only one

#

public class MortemRifleProyectile : MonoBehaviour
{
    public int damage = 5;

    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.transform.TryGetComponent(out ValeriaController player))
        {
            player.TakeDamage(damage);
            Destroy(gameObject);
        }
    }
}```
verbal dome
#

Add a log after balas --; line:

Debug.Log("Bullets left: " + balas);```
Show what it prints when you shoot
rich adder
#

dont think Destroy(gameObject) would throw such error

acoustic belfry
#

no destroying

verbal dome
#

But I don't think ontriggerenter can run on a prefab

#

Or something went horribly wrong

acoustic belfry
verbal dome
#

If the *