#💻┃code-beginner

1 messages · Page 97 of 1

summer stump
#

Privataly settable

safe hull
#

ah, ok

#

alright, Im so used to java

#

that looks good

summer stump
#

You still cannot do new

#

You can't new an enum

safe hull
#

oh yeah

#

lol

#

do I just get rid of that?

summer stump
#

public ObjectType objectType { get; private set; } = ObjectType.Stone;

If you want a default

#

It should default to stone already though. I think default is 0

safe hull
#

ah so that just makes it appear as a dropdown, which can change

#

sorry for the inconvienience

summer stump
#

You may need to do a [field: SerializeField] attribute above it.
Unless you mean you already see the dropdown?

safe hull
#

yeah, I just noticed that

#

looked up enums it said that was necessary

summer stump
safe hull
#

Great!

#

Amazing 😄

dreamy light
#

Hello, I'm trying to make a movement system in the style of the collide and slide algorithm but the walls kill all velocity and the ramps make you much faster, is there anything obviously wrong with my code?

This is the script:
https://hastebin.com/share/agoqurucad.csharp

safe hull
#

change the materials you are using

#

something like this idk

#

then they won't get stuck

dreamy light
#

It's not a rigidbody

safe hull
#

oh

#

then idk

ebon robin
#

why is Coroutine is so buggy when placed in FixedUpdate, I created extra animations for the slime to leap toward the player but when I try to execute it in Coroutine, it is just terrible. The amount he dashes is usually half the Distance i set, or maybe even one tenth, or zero. I use virtually the same code in fixedupdate with SlimeDash a new State, it works just fine

slow dew
#

Still can't get curly braces to auto format on the same line on the new unity vs code extention with c# dev kit

fierce shuttle
fierce wasp
#

Hello

#

is there a channel for getting help?

wicked cairn
fierce wasp
#

Ah ok, thank you

slow dew
#

tried editorconfig, doesnt do anything with the new line thingy

abstract finch
#

I'm using the class reference method but the variable value is not being retained between classes

    {
        PathContext pathContext = new PathContext();
        while (pathContext.TotalTimeElapsed < chaseDuration)
        {
            yield return _pathfinder.MoveAlongPoints(pathContext, _pathfinder.GetPoints(target.position), RecalculateSpeed, _moveSpeed);
            Debug.Log(pathContext.TotalTimeElapsed);
        }
    }```
I'm modifying its value on the pathfinder class but when it returns the value is the same
teal viper
abstract finch
teal viper
#

Use a pastebin site if it's too long.

abstract finch
#
    {
        int pointIndex = 0;
        while (pathContext.PathTimeElapsed < duration)
        {
            Vector3 targetVelocity = Vector3.zero;
            if (pointIndex >= points.Length)
            {
                targetVelocity = Vector3.zero;
            }
            else if (Vector3.Distance(transform.position, points[pointIndex]) > .1f)
            {
                targetVelocity = points[pointIndex] - transform.position;
            }
            else
            {
                pointIndex++;
            }
            Move(targetVelocity, moveSpeed * Time.deltaTime);
            pathContext.PathTimeElapsed += Time.deltaTime;
            pathContext.TotalTimeElapsed += Time.deltaTime;

            yield return null;
        }
        yield return null;

    }````
teal viper
#

Hmm

abstract finch
#

Debug.Log is returning the same value 0.1012646

#

which is the duration inside movealongpoints so it makes sense

#

its not retaining the modified value in the class called

teal viper
#

I feel like there's some confusion with the coroutine yields.

abstract finch
#

let me fix some

#

you mean the yield return null?

teal viper
#

No. With yield return AnotherCoroutine.

abstract finch
#

is there an alternative? this is the only way i know how to run another coroutine within one

teal viper
#

For starters debug what's going on. Use the debugger to step through the code or add more logs.

abstract finch
#

ok

wintry quarry
teal viper
#

I kinda feel like the nested coroutine just only does one loop before finishing.

abstract finch
#

I just tried declaring the time elapsed value on the second coroutine, whats happening is the value of TotalTimeElapsed is not being saved when being modified in the other coroutine

worthy chasm
#

i finished the brackeys tutorial and its good but glimpses over the coding too fast, whats a better series to follow with a lot of focus on coding?

abstract finch
teal viper
abstract finch
#

I had to reset this variable every time it entered the second coroutine

true heart
#

in my game i have a grappling hook and right now im using a lienrenderer to draw the line between the player and the end of the grappling hook but i want to make the line look like a rope and not just a renderer line. so i made a rope sprite but how should i go about making a rope sprite that can dynamically change sizes depending on the distance between the player and the grapple end and that conencts the 2.

worthy chasm
#

why is he multiplying the mouse movement and not just adding it to the rotation, can someone explain the logic?

eternal needle
worthy chasm
#

can u tell me a better tutorial

eternal needle
worthy chasm
#

i watched another tutorial and it also u ses time.deltatime

#

what should it be instead

eternal needle
# worthy chasm i watched another tutorial and it also u ses time.deltatime

i believe you can just exclude the Time.deltaTime, most tutorials do this because one guy did it and every tutorial is a copy paste of each other. Most people who make beginner tutorials arent very good themselves.
As for your question about "not just adding it to the rotation" im not sure what you mean, .Rotate will rotate the object

timber tide
#

I was looking that up too and I see a lot of tutorials multiplying by deltatime

#

but I swear I've had it working without it

#

oh right doesn't a brackys video do that

languid spire
#

From the GetAxis docs

#

I do wish people would read them

eternal needle
timber tide
#

Ah, ok GetAxisRaw is frame independent, but you have to do your own lerping if you want to smooth it, but GetAxis seems to already do most of that work for you.

#

If I'm understanding correctly

#

So I guess it's just people getting mixed up between the two

#

Mouse.current.delta.ReadValue(); would be considered the raw values too

north kiln
#

Scaling by deltaTime doesn't smooth something that is already frame-rate independent anyway, it just ruins it

#

you would need to actually perform some sort of filter to smooth

fringe pike
#

how do i call a function from another script?

wide crown
#

guys, I have a question!

#

do I need to normalize the input of vector2s of the input package??

static cedar
worthy chasm
#

is invoke deprecated?

keen dew
#

no

fringe pike
#

how can i fix this? Find is not allowed to be called from a MonoBehaviour constructor (or instance field initializer), call it in Awake or Start instead. Called from MonoBehaviour 'KeyClicks' on game object 'KeyHandler'.

languid spire
#

what do you not understand about that message?

fringe pike
#

what i need to do to fix it

#

im not sure

languid spire
#

you need to understand the message and do what it tells you to do

fringe pike
#

it says to call it in start

languid spire
#

no it does not

fringe pike
#

then what do i need to do

#

i don't understand can you help me understand?

languid spire
#

ok, what line of code is producing the error?

fringe pike
#

those

languid spire
#

no

gaunt ice
#

!ide

eternal falconBOT
fringe pike
#

it doesn't say what line is making the problem but it started after i made that line

languid spire
#

screenshot the console with the message selected

fringe pike
fickle geyser
#

literally just downloaded unity randomly doing things

trying to make the camera rotate around the x axis of the player. Keeps spinnin on y axis when i hold down right arrow.

well im sure this will look bizzare but im just piecing anything together

languid spire
fringe pike
languid spire
#

do you have domain reload turned off?

fringe pike
#

what does that mean?

languid spire
#

do your scripts recompile automatically when you change them?

fringe pike
#

i dont know

#

havent turned it off manually i think

crude dragon
#

facing this exeption when create build

languid spire
keen dew
fringe pike
#

only this

languid spire
#

so what is KeyClick.cs line 14?

fringe pike
languid spire
#

so audioHandler is null

fringe pike
#

yes

#

i think i fixed it though

#

i got it working, thank you so much @languid spire you made my day

eternal needle
topaz mortar
#

Item equippedItem = equipmentSlot2.GetComponentInChildren<Item>();
does this always throw an error if there is no Item?
should I use var instead?

keen dew
#

var just means that the compiler guesses the type from context; the end result is exactly the same

languid spire
fickle geyser
twilit pilot
bold nova
#

In my game enemy attacks if float attackRandom > attackProbability. I want to increase the chance of attack steadily on runtime. But Im not sure how to keep incapsulation here. I dont think making attackProbabillity public is a good idea. Score is saved in GameManager and attackProbability is stored in enemy script. How do i keep attackProbabillity private?

#

So, depending on the score, attack probabillity should be increased

timber tide
#

You can consider reading from GameManager's score from where attackProbability is calculating

bold nova
#

So, making score public?

timber tide
#

You can always read publicly if you want to do that, and set as private

bold nova
#

Attack method is realized throught InvokeRepeating and i thought maybe i should += to attackProb some multiplier that is calculated based on score until probabillity reaces 0.6

bold nova
#

public get, private set

#

thanks!

timber tide
#

Yeah, there's a bit more to it when it comes to reading references publicly, but if it's some sort of value type then it's as easy as that.

rare basin
#

what if you will have 10 equipmentSlots

#

equipmentSlot1 equipmentSlot2 equipmentSlot3 ...

topaz mortar
rare basin
#

just trying to advice ;p

topaz mortar
#

the 2 is just because I'm checking if I need to unequip the item in the right hand slot when equipping a 2 handed weapon

safe hull
#

KeyBindType.text = objectData.keyBind; I'm trying to convert a KeyCode into a string, any idea how to do that?

keen dew
#

.ToString()

safe hull
#

huh

#

I forgot the ()

normal arrow
#

Hi guys, how are you ?
I'm trying to add an onclickFunction on a Instantiated button. I know the add listener system, but since my button is not instantiate at the beginning of the game, i dont know how to do that :/

keen dew
#

Why would it matter when it's instantiated?

safe hull
#

is it a prefab?

normal arrow
keen dew
#

I still don't see how that prevents you from adding the listener

tawdry nymph
fickle geyser
#

i dont know why, ive been scripting in another engine for more than a year but when im using unity it feels like im starting from square one again. I feel so clueless despite my experience in another engine.

normal arrow
normal arrow
languid spire
#

So you ask how to post code in another channel and then post it incorrectly here. Why?

keen dew
safe hull
#
                ObjectData objectData = interacted.GetComponent<ObjectData>();
                KeyBindType.text = objectData.keyBind.ToString();``` wouldn't this get the script component from the raycasted object, and then take the KeyBind variable and put it into the string?
#

I debuged it and am getting the error right after:

keen dew
#

Which one is line 30?

languid spire
timber tide
#

debug it all

buoyant knot
#

keep in mind the Debugger can be good for some of these things. Debug mode lets you peak into the contents of all variables up to your breakpoint.

cosmic hinge
#

Why I am getting null refernce when i call mergelist function?

safe hull
#

The third line of the code I put in

languid spire
safe hull
#

Alright

#

Well the KeyBinfTyoe is empty

#

The text

languid spire
languid spire
safe hull
#

No you didn't

timber tide
safe hull
#

Mb

safe ore
#

Hi!

I know I'm having amoment where I'm being very dumb, but my brain cannot currently figure this out. Why can't the GameManager see exitpermitted() ?

I'm doing a Uni assignmkent, but the professor isn't available due to ahving covid.

timber tide
#

what's the error

safe ore
#

exitpermitted doesnt exist in current context

languid spire
polar acorn
safe ore
#

exitpermitted() is in the ExitPossibleIndicator class within a script document of the same name. I thought I'd be able to reference it in the GameManager since it's all set to public.

languid spire
#

you need to learn some c# basics

polar acorn
#

You have to call that function on an instance of ExitPossibleIndicator

#

You have to tell it which of those you want to call the exitpermitted function on

tawdry nymph
#

I am currently working on a boss and i have 3 attacks for it, spray which works fine, bulletwall, which works occasionally but sometimes doesn't register as completed, and smash which doesn't work at all. I've been having trouble with this for a while now and I can't seem to figure out the problem. this is the script attached to the Object: https://gdl.space/xiyezuroye.cpp

rare basin
#

would fit percetly in there instead of doing everyhing in one big function in Update()

#

what if you will have 10 attacks, you will need to make 10 if/else statements and a huge code wall

safe ore
# polar acorn https://unity.huh.how/references

Thank you, and sorry for doubt you but I wanted to make sure you had all of the information.

This is exactly what the professor wants. I am stuck on the very end, trying to call the thing from another script. I want to make sure this still applies. We've only been coding in Unity for 4 weeks, a couple of hours every Monday so I'm not used to this yet.

polar acorn
tawdry nymph
languid spire
#

best to always put AttackFinished = false; first

tawdry nymph
#

but the smash attack still doesn't work at all

buoyant knot
#

I'm making a simple class (Bounds2) which is basically Bounds but for 2D.
I want separate constructors to make by min and max, and another to specify by center and size. But both would have the same arguments. Is there a way to do this with constructors? or is the cleanest way just to make a static method that makes a new Bounds2

icy grotto
#

hi! is there an attribute that can make a header collapsible?

quick ruin
#

Hi is netcode the best option for multiplayer in unity?

timber tide
#

otherwise there's stuff like naughtyattributes (could be a unity attribute but I forget)

timber tide
#

at least in my opinion there

undone rampart
nimble scaffold
#

@icy grotto how u made model's AI???

icy grotto
undone rampart
#

ima DM it to you cuz idk if im allowed to send it here

modest barn
#

How do I make my app's UI work with all screen sizes? I've got my Canvas on Scale with screen size but my text boxes will look great on one device and then when I switch to an iPad Mini 4 or something like that, the text boxes are off the screen. My UI is currently a couple of input fields that I'm using for testing i.e. there is nothing fancy

undone rampart
modest barn
#

@undone rampart how do you think I could implement code that checks for overlapping text boxes and reduces the size so they fit correctly? That will be an issue too

modest barn
#

Great, I'll check that out. Thank you.

#

Edited a script while in play mode accidentally. How can I fix?

#

The referenced script (Unknown) on this Behaviour is missing!

wintry quarry
timber tide
#

those are kinda tricky to find sometimes

modest barn
#

There are no references in the scene, the script that was edited is instantiated by another script

timber tide
#

may have edited a prefab

wintry quarry
#

Check the prefab

modest barn
#

Pretty sure I don't have a prefab

wintry quarry
#

What are you instantiating then?

modest barn
wintry quarry
#

The error is talking about a broken MonoBehaviour reference

#

You wouldn't be using new for a MonoBehaviour

#

If you are that's a problem in and of itself

modest barn
#

Yeah that's what I was confused about

#

The only script that I edited during play mode

#

Was a script that does NOT inherit from MonoBehaviour

#

So I don't understand how there's a broken reference there

#

But I restarted Unity and all is well so I'm not sure...

rare basin
#

you can't really make changes in the code during playmode

#

that can lead to many random errors

modest barn
#

Yeah I know, just thought I had stopped the game, but I guess not

rare basin
#
  • dont modify scripts during playmode (even at paused)
  • dont refresh the project during playmode
  • dont make new scripts, dont delete any scripts, don't do anything that requries re-compiling the scripts
solemn fractal
#

Hey guys, is there a way to reset the Time.time? I am trying but it is not allowing me saying its just readable. And I am having a problem where if you die in the game, you go to the main screen again, and when you press play, the Time.time is not ZERO again, its the same as before and that is messing with stuff..

modest barn
#

This is a TMP_Dropdown object. How can I increase the size of the option backgrounds?

solemn fractal
wintry quarry
wintry quarry
solemn fractal
modest barn
summer stump
#

Time.time is the number of seconds since the application began running. You can use it for differences, but should not use it for absolute values

Closing the game and starting it will reset that value

Resetting it artificially would defeat the purpose of it

modest barn
glad cliff
#

Hello! please help me in creating a code, I have no idea on how I can display data in a unity scene from firebase, I know how to get data from unity to firebase but I don't know how I can display it on my unity scene. For ex. the age of player, I know how to get it using api to firebase, but how can I display to my unity scene in terms of "Text"?

please provide example code

modest barn
summer stump
modest barn
#

let's say

[SerializeField] Text textBox;
#

Then use your API, let's say this:

#
string APItext = GetAPIText();
textBox.text = APItext;
#

And boom

glad cliff
#

Thank you so much to the both of you! I'll try them! 😊

wintry quarry
#

you almost definitely want TMP_Text not Text

glad cliff
#

Okay! so something like this

[SerializeField] TMP_Text textBox;

versed fog
#

Hello!! I am working on FPS mouse and player movement scripts. They both work and I can move / look around in game mode. But when I start game mode my camera is facing straight down to the ground… is there something I am missing in camera settings or is this a script issue?

autumn tusk
#

how do i increase and decrease the y value of a game object by a set amount?

summer stump
languid spire
#

no

summer stump
#

Yeah, that is wrong sorry

#

Add a new vector3 with the y component as 5

#

Can't add to the y property directly

queen adder
#

How would I check collision in a class?
I made a class that creates projectile, but how would I check if it is colliding with something? (I want to do the collision check in the same script, because projectiles can collide into others projectiles)

thanks

autumn tusk
summer stump
#

Edited

queen adder
summer stump
eager elm
rich adder
summer stump
queen adder
#

Sorry!

summer stump
queen adder
#

It doesnt let me

summer stump
#

What have you tried?

#

Maybe time to show !code

eternal falconBOT
polar acorn
queen adder
#

My script looks something like this: (I'm on phone sorry)


public class Projectile

//Info bla bla
But then I can not do OnTriggerEnter
rich adder
summer stump
queen adder
#

It gives me an error wait let me bootup my computer

summer stump
#

See how it is done correctly

queen adder
#

Alright so that's my class (i don't need to s end everything)

 public class Projecticle : MonoBehaviour
    {
        GameObject projectileBullet;
        public Vector3 projectileSize;
        public Vector3 projectilePosition;
        public Sprite projectileSprite;
        public string projectileName;
        public float projectileSpeed;
        public Rigidbody2D projectileRigid;
    }
#

and when I do that, this happens

#

You are trying to create a MonoBehaviour using the 'new' keyword. This is not allowed. MonoBehaviours can only be added using AddComponent(). Alternatively, your script can inherit from ScriptableObject or no base class at all
UnityEngine.MonoBehaviour:.ctor ()
PlayerHandle/Projecticle:.ctor ()
PlayerHandle:Shoot () (at Assets/Scripts/PlayerHandle.cs:135)
PlayerHandle:Update () (at Assets/Scripts/PlayerHandle.cs:145)

polar acorn
queen adder
#

I'm not?

summer stump
#

Ok, that error has absolutely nothing to do with OnCollisionEnter btw

polar acorn
queen adder
polar acorn
#

what did you think that meant

#

If you want to instantiate something, you should, y'know, use instantiate

queen adder
#

Instiantiate works on class too? I didn't know thanks!

#

It doesn't let me do this though
Projecticle newProjectile = Instantiate<Projecticle>();

rich adder
queen adder
#

Right

rich adder
polar acorn
#

you pass it an object to clone

zenith cypress
polar acorn
#

Such as a prefab

acoustic arch
#

can't figure out why the player is only

#

grounded when thier moving

queen adder
#
Projectile projectile = gameObject.AddComponent<Projectile>();

thanks, that's what i needed

wintry quarry
wintry quarry
polar acorn
#

that's probably not what you needed

rich adder
#

the one built into CC sucks ass

#

it only check when moving as you said

queen adder
polar acorn
wintry quarry
polar acorn
#

and that you don't make The Brackeys Error of calling Move twice

rich adder
#

but def combine Move into.1 call

queen adder
polar acorn
acoustic arch
#

what's a better way

queen adder
polar acorn
#

and spawn that when you want one

zenith cypress
rich adder
acoustic arch
#

i'm probably gonna change it back

#

cause i prefer it

delicate notch
#

its Class -> Object right?

queen adder
#

Yeah i get what you guys wanted me to do !

I'm just really used to SFML, where I code everything in one script

I didnt think about making another script lol

queen adder
delicate notch
#

ye

queen adder
polar acorn
delicate notch
#

Parent

polar acorn
#

I still don't fully follow what you mean by that

delicate notch
#

Objects are created by classes

polar acorn
#

Do you mean Object, the class, or object the concept

#

An object is an instance of a type, and classes are types

delicate notch
polar acorn
#

Okay, so yes, an object is a concrete representation of data defined by a class (or struct)

languid spire
#

be careful, in Unity, Object and object are 2 different things

delicate notch
#

Unity is hard man

languid spire
#

no it's not, you just need to know a few things

delicate notch
#

Hm btw could u help me with one small thing about unity

polar acorn
#

Well, almost every object oriented language at least

#

no Objects in Haskell

delicate notch
#

I am having an issue in my unity project

#

I think I know why

#

but not sure how to fix it

rich adder
#

yet still doesnt say what it is 👍

delicate notch
#

how to Do the things to paste code

eternal falconBOT
delicate notch
#
// Being destroyed and recreated? Therefore its always going to put you in level two
IEnumerator DropPointGivers()
{
    isDropping = true; // Start coroutine

    for (int i = 0; i < pointCount; i++)
    {
        float waitTime = Random.Range(dropTimerMin, dropTimerMax);
        Instantiate(pointGiverPrefab, transform.position, Quaternion.identity).GetComponent<Rigidbody2D>().velocity = Vector2.down * dropSpeed;
        yield return new WaitForSeconds(waitTime);
    }

    isDropping = false; // Spawner Dropper dropped 10 flags and is ready for next wave.
    
    if (isLevel2 == false)
    {
        isLevel2 = true;
        FindObjectOfType<LevelManager>().LoadLevel2();
        Debug.Log("Level Two");
    }
    else
    {
        FindObjectOfType<LevelManager>().Win();
    }
}

#

This how to keep this script alive

polar acorn
delicate notch
#

When switching scenes

delicate notch
languid spire
#

look at DDOL

delicate notch
#

what?

languid spire
#

Dont Destroy On Load

delicate notch
#

but when i do that

#

Would I have to create some sort of loop

#

to allow the script to run well again when press play again

#

or Does it allow specific scenes for it to live

polar acorn
#

What?

languid spire
#

you want to keep the Coroutine alive or the script alive?

polar acorn
#

What do loops have to do with things?

delicate notch
#

basically

polar acorn
#

regardless of DDOL

delicate notch
#

Ye so I just watn this script to live for 2 scenes then it dies

#

The whole thing

polar acorn
#

Then use DDOL to keep it across a scene load then manually destroy it when you're done with it

delicate notch
#

I see

#

DDOL is the singleton thing?

#

jsut to confirm

languid spire
#

no

delicate notch
#

oh

polar acorn
delicate notch
#

k thx

polar acorn
#

It marks the object to stick around when a scene change happens

solemn fractal
#

!code

eternal falconBOT
summer stump
polar acorn
#

or just like, remember em

#

gdl.space is like eight letters

solemn fractal
#

just bookmarked 😛

rich adder
#

hatebin is the best

solemn fractal
#

Anyone?

worthy chasm
#

i cant find any guide on unity 2023 collaborative and how to do it with other people

summer stump
#

I recommend the former

worthy chasm
#

does it allow live collaboration git?

summer stump
rich adder
worthy chasm
#

damn thats sad

fickle geyser
#

well how to team create then??

dapper knot
#

guys ima gonna go crazy 😭
how can i fix thiss
so when i click on my game when the UI pops up the mouse disapears when i SPECIFICLY TOLD IT NOT TO IT STILL DOES
im only a begginer and no one has the same problem i do :c
https://hastebin.com/share/iguzijiroy.csharp
thats the only one that has it and i dont know where to put it so i just put it on the camera or the player

fickle geyser
#

i mean collaborate on a game project with people!!!!!

summer stump
ruby python
#

Evenin' all. soooooo, I'm having a bit of a brain issue figuring out the logic on this script.

https://pastebin.com/eSqjY0pJ

What I want it to do is for the 'end point' of the linerenderer to move back to its origin ( left side of the screen, pink character), but I can't seem to figure out code.

Could anyone point me in the right direction please?

https://streamable.com/y16vss

eager elm
eager elm
rich adder
#

it gets turned into Approximation

polar acorn
#

It's floats you shouldn't compare with ==

ruby python
summer stump
ruby python
#

Yeah I just read. lol.

craggy lava
#

Hi i have this code and i want the code to spawn a prefab in like 3x3x3 or 6x10x8 like you choose how many to spawn and i am getting stuck my code is under

 [SerializeField] private GameObject boxPrefab;
 [SerializeField] private float boxWidth = 1.0f;
 [SerializeField] private float boxLength = 1.0f; 
 [SerializeField] private float boxHeight = 1.0f; 
 private float amountToSpawn;

 void Start()
 {
     SpawnBoxes();
 }

 void SpawnBoxes()
 {
     if (boxWidth > 1 && boxLength > 1 && boxHeight > 1)
     {
         amountToSpawn = boxWidth * boxLength * boxHeight;
         while (amountToSpawn > 0)
         {
             // Code to spawn them like 3x3x3 or boxWidth x boxLength x boxHeight
             amountToSpawn--;
         }
     }
     else
     {
         Instantiate(boxPrefab, transform.position, Quaternion.LookRotation(Vector3.forward));
     }
 }
eager elm
ruby python
#

Thanks 🙂

craggy lava
wintry quarry
#

3 nested loops

ruby python
eager elm
# craggy lava may i ask why?
for (int x = 0; x < width; x++)
{
    for (int y = 0; y < height; y++)
    {
        //Instantiate here and set position to (x, y)
    }
}```
Then it will Instantiate width * height objects.
summer stump
#

The nested loops for the 3x3x3 would run like this with their indexes

0, 0, 0
Then 0, 0, 1
Then 0, 0, 2
Then 0, 1, 0
Then 0, 2, 1
Etc

It would give you all 3x3x3 coordinates

craggy lava
#

Oh

ruby python
#

Loop inside a loop

summer stump
#

Nested just means a thing inside another thing

#

Like russian nesting dolls

craggy lava
#

it spawns something but there is too many now my script looks like this

    void SpawnBoxes()
    {
        if (boxWidth > 1 && boxLength > 1 && boxHeight > 1)
        {
            amountToSpawn = boxWidth * boxLength * boxHeight;
            while (amountToSpawn > 0)
            {
                for (int x = 0; x < boxWidth; x++)
                {
                    {
                        for (int y = 0; y < boxHeight; y++)
                        {
                            for (int z = 0; z < boxLength; z++)
                            {
                                GameObject boxToSpawn = GameObject.Instantiate(boxPrefab);
                                Vector3 pos = new Vector3(x * boxWidth, y * boxHeight, z * boxLength);
                                boxToSpawn.transform.position = pos;
                            }
                        }
                    }
                    amountToSpawn--;
                }
            }
        }
        else
        {
            Instantiate(boxPrefab, transform.position, Quaternion.LookRotation(Vector3.forward));
        }
    }
summer stump
#

Also, you have an extra scope in there
The curly braces

#

Right after the for loop with x

craggy lava
#

Kinda works

#

Wait i found it out

eager elm
craggy lava
#

but the spaceing is because of this cs Vector3 pos = new Vector3(x * boxWidth, y * boxHeight, z * boxLength); then the grid is 3 from each pilar

ruby python
#

!code

eternal falconBOT
ruby python
#

Apologies all, but I'm missing something really obvious here (been staring at it for a while).
My debug is only firing once and I'm not entirely sure why.

IEnumerator StopGrapple()
    {
        if (currentGrapplePosition != tongueRootPosition.transform.position)
        {
            currentGrapplePosition = Vector3.Lerp(currentGrapplePosition, tongueRootPosition.transform.position, Time.deltaTime * 8f);
            Debug.Log(currentGrapplePosition);
        }

        if (currentGrapplePosition == tongueRootPosition.transform.position)
        {
            lr.positionCount = 0;
            tongueEnd.SetActive(false);
            Destroy(joint);
        }
        yield return null;
    }
polar acorn
#

You're waiting a frame before doing nothing

summer stump
ruby python
#

How so?

summer stump
#

The t parameter of lerp is supposed to increase or decrease between 0 and 1

#

Yours is going up and down randomly based on frame rate

summer stump
ruby python
#

Okay, thanks. Will take a look 🙂

queen adder
#

Hello im tryna replace an item in a list when a value changes in a tmp_inputfield, the problem is that the newText string is empty, even though the onvaluechanged() function actually triggers

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

public class Answer : MonoBehaviour
{
    [HideInInspector] public GameObject questionItem;
    [HideInInspector] public int arrayOrder;
    [SerializeField] TMP_InputField answerName;
    [SerializeField] GameObject question;
    private void Start()
    {
        arrayOrder = questionItem.GetComponent<Question>().answers.Count();
        Debug.Log(arrayOrder);
    }
    public void OnValueChanged(string newText)
    {
        questionItem.GetComponent<Question>().answers[arrayOrder - 1] = newText;
    }
}
#

can i get some help fellas?

eager elm
fickle geyser
#

tryna make a collaborate is it nromal to be uplaoding 15k files??

gaunt ice
#

since the newText in inspector is empty so unity passes an empty string each times it calls it

eager elm
fickle geyser
gaunt ice
#

ignore some files

fickle geyser
#

well i have no idea how to uncommit to main now

eager elm
fickle geyser
#

and its taking ages to upload

summer stump
#

You do NOT want to upload a lot of the stuff you are pushing

queen adder
#

@eager elm i used these ' as parenthesis

#

and its empty indeed

gaunt ice
#

show the newText in inspector
i am pretty sure it is an empty string

eager elm
queen adder
gaunt ice
#

the newtext is serialized so unity passes the value in inspector when it calls this method

polar acorn
summer stump
queen adder
#

lmao i figured out the issue

#

huge thanks

queen adder
#

one sec

polar acorn
queen adder
#

but it works now

polar acorn
gaunt ice
#

yes, empty string

polar acorn
#

You probably want to use the dynamic version of the function

#

instead of passing in a hard-coded empty string

queen adder
#

how do i do that

polar acorn
#

which passes the value of the input

queen adder
polar acorn
queen adder
#

i found it

#

did it

#

it works :)

#

thank you unity discord

ruby python
#

I figured it out. lol. I was being a moron and trying to do the 'snap back' in the wrong place.

fickle geyser
#

how do i know if the .ignore file is working??

wintry quarry
fickle geyser
#

should it be a txt documnet?

wintry quarry
#

wdym?

#

The name of your .gitignore file is correct

fickle geyser
wintry quarry
# fickle geyser

The thing that says "Text Document" is just Windows classifying the file based on some heueristic

#

it's completely meaningless/irrelevant

fickle geyser
#

well

gaunt ice
#

your os classify it as text document

fickle geyser
#

it still shows me 13k files

wintry quarry
#

what does

summer stump
fickle geyser
#

git

summer stump
#

Commit the gitignore file 🤷‍♂️

fickle geyser
#

ah..

summer stump
#

Did you commit anything else yet?

wintry quarry
#

If so it's not named properly

#

it should just be .gitignore

summer stump
#

Ahhhhhh, that would do it

fickle geyser
#

should not be called that wth..

wintry quarry
short hazel
#

Yeah please turn on file extensions for the explorer

wintry quarry
# fickle geyser

My guess is you have file extensions hidden in windows explorer

#

turn them on

short hazel
#

That should be on by default

fickle geyser
#

turned it on

eager elm
fickle geyser
#

it is .ignore.ignore wtherv

wintry quarry
#

fix that

fickle geyser
#

what the hell

#

i think it worked now i just have 29 files

#

in teh thing

wintry quarry
#

great

summer stump
fickle geyser
#

Well i guess i wait untill github updates or shows the commit whtever it is

short hazel
#

It's usually instant, once the files are uploaded from your computer

#

Make sure you Pushed the commit

fickle geyser
#

well its been a while

#

still nothing

summer stump
#

Last screenshot you hadn't even published the branch yet

fickle geyser
#

woops

#

well all good now

#

hope if someone downloads this they can just open it and edit immediatly

#

dont want to go through some weird process again

summer stump
#

You need to push any changes you make, and they would need to pull them to see them

#

But the remote repo is created, and set up now

queen adder
#

can anyone tell me how i can check if a function could be called in unity or it throws an error. in c++ you just do if( function() ) but idk about c#

scarlet tiger
queen adder
#

wdym

scarlet tiger
#

wdym by check if it can be called

queen adder
#

if it throws an error

scarlet tiger
#

you can catch the error

#

using try {} catch(Exception error) {}

queen adder
#

for example if im trying to reach an item in a list that doesnt exist and it returns the outofbounds error, i wanna check that

queen adder
queen adder
scarlet tiger
#

so for you it would be

try
{
  function();
}
catch (IndexOutOfRangeException e)
{
  //do something on fail
}
#

in general though you'd put checks in to prevent the throw

#

so checking index is valid before trying to access

queen adder
#

wait

#

how will it be in the case of this error

scarlet tiger
#

can you show the code too

#

generally you want to avoid try catching throws in the first place

queen adder
#

wait i dont think i need to do catch {}

scarlet tiger
#

I know, but show the current code you have

#

question manager around line 46

queen adder
#

i tried the c++ method, but its not good, imma implement it with try{}

queen adder
scarlet tiger
#

if (questionContainer.transform.childCount > index + 1 && ...) nextButton...

#

I think that should prevent the error

queen adder
#

ty man

true pasture
#

this switch statement doesnt activate on the slash case. I printed the mySkill and it matches but the switch doesnt run.

hollow zenith
short hazel
#

There might be a space or other "invisible" characters at the end of that string

polar acorn
short hazel
#

Well actually the issue is that you're using a TextMeshProUGUI to interface with an input field, that's incorrect

queen adder
short hazel
#

The field should be of type TMP_InputField

true pasture
#

oh

#

lemme try that real fast ty

polar acorn
#

TMP_InputField adds a non-print character that isn't stripped with Trim(). You can manually cut it with:
.Replace("\u200B", "")

#

Or use the input field directly

scarlet tiger
#

otherwise you are asking for an index that doesnt exist

true pasture
#

okay ty guys that fixed it

queen adder
scarlet tiger
#

ok lol, why are you having negative indexes?

queen adder
#

i can do that also

scarlet tiger
#

add a check to make sure it's greater than 0 too then

queen adder
#

im so dumb lol

#

thanks

calm coral
#

Is there a way to use GameObject.Find() for inactive game objects?

wintry quarry
calm coral
wintry quarry
#

You should avoid GameObject.Find in general for many reasons, including this

wintry quarry
wintry quarry
#

GameObject.Find is very inefficient

#

it's also fragile, as it depends on object names which can change at any time in development

#

The preferred way is a direct reference in the inspector.

#

But again it depends on the context

calm coral
# wintry quarry GameObject.Find is very inefficient
void Reset()
{
    GameObject.Find("Virtual Camera 1st person").TryGetComponent(out a1stPersonVirtualCamera);
    GameObject.Find("Virtual Camera 3rd person").TryGetComponent(out a3rdPersonVirtualCamera);
}
```Yes, it is inefficient but I'm running it just once, not in `Update()`. The thing is if game object is disabled it can't get its component and I have null reference exception
#

It's like null.TryGetComponent(out a1stPersonVirtualCamera); and that's not going to work

slender nymph
#

so null check the result of the Find before calling TryGetComponent on it

calm coral
#

So I was wondering if I can do something in case if game object is disabled

calm coral
wintry quarry
reef sphinx
#

Why am I getting this error?

I have a steam_appid set to 480

This is my current code:

public class Texture2PFP : MonoBehaviour
{
    [SerializeField]
    private RawImage m_Texture;

    private CSteamID userID;
    protected Callback<AvatarImageLoaded_t> avatarImageLoaded;
    ulong m_SteamID;

    private void Start()
    {
        if (!SteamManager.Initialized) return;

        userID = SteamUser.GetSteamID();
        avatarImageLoaded = Callback<AvatarImageLoaded_t>.Create(OnAvatarImageLoaded);
    }

    private void OnAvatarImageLoaded(AvatarImageLoaded_t callback)
    {
        if (callback.m_steamID.m_SteamID != m_SteamID) return;
        m_Texture.texture = GetSteamImageAsTexture(callback.m_iImage);
    }

    private Texture2D GetSteamImageAsTexture(int iImage)
    {
        Texture2D texture = null;
        bool isValid = SteamUtils.GetImageSize(iImage, out uint width, out uint height);

        if (isValid)
        {
            byte[] image = new byte[width * height * 4];
            isValid = SteamUtils.GetImageRGBA(iImage, image, (int)(width * height * 4));

            if (isValid)
            {
                texture = new Texture2D((int)width, (int)height, TextureFormat.RGBA32, false, true);
                texture.LoadRawTextureData(image);
                texture.Apply();
            }

        }

        return texture;
    }
}

I am trying to set a texture to a steam PFP, but its crashing out

slender nymph
reef sphinx
calm coral
# wintry quarry why don't you just: - do this once when they're still active and save the refere...
  1. Well, the thing is if one camera is activated then the other one is deactivated and vice versa. So one of cameras is always disabled by default.
  2. Uh, that's going to make more mess I guess aniblobsweat I'd have to create a new class to store references for deactivated game objects, it's rather faster to just manually assign them in inspector

I was wondering if there's a way to convert Instance ID to game object, something opposite to GetInstanceID();

wintry quarry
#

make a script that references both of these obejcts, directly, through the inspector

#

Then you can do whatever you want with the references

#

share them with other scripts, etc.

short hazel
calm coral
polar acorn
calm coral
wintry quarry
calm coral
polar acorn
reef sphinx
short hazel
#

So the code isn't really related to the issue

reef sphinx
short hazel
#

Where exactly is it crashing? Because that code does nothing apart from running Start() when the game starts.
Do you have an exception occurring somewhere? You should post its stack trace here

pliant oyster
#

In an if, when checking collision, how do I check if the first object collides with any object in the second object?
The code is this:

if (Collider2D.Equals(gameObject, deletionAreas))
{
    Destroy(gameObject);
}
````deletionAreas` is a List.
wintry quarry
#

Can you be more clear about what you're trying to do?

#

You want to check if a certain object is contained in an array?

#

What types of obijects are we talking about?

#

GameObject? Collider2D?

#

What is the type of the array?

wintry quarry
pliant oyster
#

The code is for a bullet. I have two squares outside of the screen. I want the bullet to delete itself when it touches it (or an enemy/player, which I will add later).

wintry quarry
#

it's just checking if two object references refer to the same object... sort of, in a really wrong way.

wintry quarry
pliant oyster
#

In the if, or as a new method?

polar acorn
pliant oyster
wintry quarry
#

This whole question is a "throw this out and start from scratch"

pliant oyster
#

I tried finding some but it was all videos instead of text.

queen adder
#

hello, i am new to unity but i am very good at computer science and understanding coding ( at least i think so ). how would i use the new input system to return a value of the mouse's x and y coordinate?

wintry quarry
polar acorn
queen adder
wintry quarry
#

details depends on which style of input handling you're using

queen adder
#

oh

#

sorry

#

did not see that

pliant oyster
#

I just realized, I can do that without using colliders by just doing a "if bigger than x or smaller than y" check

#

Thanks, though!

queen adder
#

i think?

#

i binded delta mouse to a 2d vector action

wintry quarry
queen adder
#

sorry

wintry quarry
#

Are you using PlayerInput?
Are you using the generated C# class?
Are you using InputActionReference?

queen adder
#

ahhhhh

#

is PlayerInput a object that holds methods useful towards input reading

wintry quarry
queen adder
#

oh

#

i'll do that

#

i tried starting from unity's manual but it wasnt very helpful

nimble inlet
#

ok first I'd like to ask why " GameObject playerObject = GameObject;"
=> trying to hover a gameobject from scene onto inspector doesn't work. (type mismatch of somekind?)

#

maybe the syntax is wrong (that used to be from find object with tag. ) but couldn't really assign that eithe.r

polar acorn
nimble inlet
#

yeah that should be. it wasn't though, there was this that checked null

#

^tagging is bad but I was in a hurry and couldn't assign shit. xd

#

how should I do it?

nimble inlet
#

this tag I think doesn't find its way home, and it's the right title.

short hazel
#

You talked about:

hover a gameobject from scene onto inspector
So are you drag-dropping? Or are you referencing it from the code?

nimble inlet
#

drag dropping.

short hazel
#

Because when it refuses to drag-drop into an object in the scene, it means the thing you're trying to drag-drop is an asset (prefab) that is not in the scene, and that's not allowed

nimble inlet
#

I'm trying to drag an object from the hierarchy in the scene onto a prefab. :C

#

maybe that's not allowed.

short hazel
#

Yes, because there is no guarantee the scene will exist when the prefab exists

nimble inlet
#

right. but I do need the link from that object to the prefab (I'm using the prefab to spread a script that needs the player location).

#

maybe I'm going all about this wrong.

short hazel
#

The code that Instantiates the prefab will have to pass the references you need at runtime, fully from the code, then

nimble inlet
#

ugh.

rocky canyon
#

spawn it, set it, forget it

nimble inlet
#

right now it adds the script that asks for the reference to the object. That script needs that link, but I don't think I can assign things to a script from the inspector, and tagging is bad (and didn't work...)

rocky canyon
#

there's other alternatives

#

but you'll have to assign it during runtime..

#

the only other alternative is to have the stuff u need packaged into the prefab already

nimble inlet
#

I have the script packaged in the prefab, but that's one I cannot drag to. otherwise I do not know what to add to it. x-x

short hazel
#

Who talked about finding, when Instantiate returns the object that was just created?

GameObject inst = Instantiate(prefab, pos, rot);
inst.GetComponent<SomeScript>().thing = something; // injection of the reference
rocky canyon
#

no the things you drag must also be inside hte prefab

#

or u assign it after the fact ^

nimble inlet
#

aagh. I'm too tired for this x_X

nimble inlet
rocky canyon
#

heres a reference manager i use

nimble inlet
#

taking some of its component.

rocky canyon
#

in start i find all my references.. during the loading screen

polar acorn
#

You want to set the variable of the object you just spawned

rocky canyon
#

then afterwards they're assigned so i dont need to call expensive find calls or w/e

nimble inlet
#

amaznig

rocky canyon
#

just that once

nimble inlet
#

shit I should've done that. it's a little late now.

rocky canyon
#

note, thats just 1 method.. and it does use find calls.. which somepeople don't ever use

nimble inlet
rocky canyon
#

in my experience i use them in start and awake functions (just once) and its been a pretty decent system

polar acorn
#

and then pass it to the spawned object

nimble inlet
#

object spawning prefab aka the enemyspawn manager?

#

noooo x_x

#

I can't follow.

#

maybe just scrap that whole thing. it's getting super late.

nimble inlet
#

it would truly take some time to get to the bottom of this/understand the thing fully

#

this script worked a while ago

#

it stopped working out of nowhere with basically no changes. x_x

bleak pasture
summer stump
#

It's for instantiating copies

#

You CAN do it across scenes, but they are useful even in one scene

bleak pasture
#

I thought I would only do a ui control in one scene, prefab it and then reuse it in other scenes...

summer stump
bleak pasture
#

so I dont have to redo that ui control in a canvas over and over again

summer stump
#

Just use DDOL

Oh, maybe I misunderstood

#

You mean copy the same canvas/ui into multiple scenes? That makes sense

#

I thought you meant copy the current state of the ui to a prefab at runtime, then instantiate that state in a new scene

bleak pasture
#

Like the ui control is actually a text with separator and part of the text is clickable etc. text is dynamic (so monobehaviour) and I want to use the whole thing as a control in multiple scenes. SO I thought of making it a prefab so the monbehavior follow around to manage the dynamic text as well so I can use the whole control in multiple scene

#

And no it's not to copy the state it's for code/gameobjects reuse

summer stump
#

You could just put it in DDOL still

#

But yeah, that works

bleak pasture
#

Just to clarify to make sure the context of the discussion is understood: Im going to have a breadcrumb in this format: $"{myFief.parentRegion.name} > {myFief.parentDepartement.name} > {myFief.parentArrondissement.name} > {myFief.ParentCounty.name} > {myFief.ParentBarony.name} > {myFief.name} > {myBuilding.buildingType} > {myBuilding.buildingID}" and each of these parts between the > would be clickable. It's something I'll use in every UI so you can quickly navigate and so far I'd do one scene = one UI so that control would be used all over the game

nimble inlet
#

ngh. I tried this fancy way to assign it but it remains null..

bleak pasture
#

Kinda ruins my plans if I can't prefab it and simply drop it in multiple scenes

nimble inlet
#

guess 'm gonna have to alter script to just shoot down lmfao. xD

#

wait that wouldn't even help

#

what on earth is going on though. I saw these things shoot bullets for 10 hours straight and suddenly it's null x_x

polar acorn
#

What is null? There's a few things that could be null there

summer stump
nimble inlet
#

the bullets I assume, since they aren't instantiating. I tried switching the script from tracking the player, and something stayed null so, yeah. probably bullets. :/

#

I think I debug logged it about them bullets as well. ah, and I did check that the instantiated objects dont have that reference in the inspector at runtime.

bleak pasture
nimble inlet
#

Imma send the script your way. Idon't think it's the problem though.

bleak pasture
#

They mean that many things could be null it there like bulletPrefab or bulletprefabname. So you should debug that or put a breakpoint and inspect

nimble inlet
tiny hawk
#

My Unity projects are often breaking with doing a push from one developer and a pull from another developer's machine. We're using PlasticSCM, but it's still happening.

bleak pasture
#

also where is bullet2 in the editor ?

bleak pasture
#

Assets/Bullets/Bullet2 ?

nimble inlet
#

I think so.

#

yep

tiny hawk
nimble inlet
tiny hawk
#

And file IDs messing up

nimble inlet
#

that bullet prefab vanishes at instantiate

#

it's assigned to the prefab.

#

looking like this at idle.

wintry quarry
tiny hawk
tiny hawk
#

How do I fix this?

nimble inlet
#

what. suddenly it works. I made no changes.

wintry quarry
#

Make sure anyone making changes is properly checking in all modified files including meta files

tiny hawk
#

Ohh ok

#

Thanks @wintry quarry !

bleak pasture
#

what's wrong with git ? It doesnt work with unity or something ?

#

not a criticism Dudesss, just a subtopic because you remind me of why unity doesn't show me git as possible source control in the edit preferences

summer stump
#

It is the standard

nimble inlet
#

or maybe not. x_x gah

#

had a nice view of screen full of bullets for a video presentation 2 hours ago.

#

basically no changes->they are gone. x_x

wintry quarry
nimble inlet
#

you can see in that image, that they are no longer assigned.

#

two images, first of instantiated objects which no longer have an assigned bulletPrefab

#

and second of one which has it assigned to the prefab of those instantiations at rest.

wintry quarry
nimble inlet
#

that makes sense, but I don't think..

bleak pasture
wintry quarry
#

it's unclear to me if this is a component on a bullet or on a thing that spawns bullets

nimble inlet
#

this is a component on a thing that spawns bullets.

wintry quarry
nimble inlet
#

yeah.

wintry quarry
#

Ok so show:

  • the script that spawns this thing that spawns bullets
  • the inspector for the thing that spawns the thing that spawns bullets
  • The Bullet Pattern 1 script
  • the inspector for the prefab that is referenced from the first script.
#

Wait you're doing this:
GameObject bulletPrefab = Resources.Load<GameObject>("Bullets/" + bulletPrefabName);

nimble inlet
wintry quarry
#

in other words the variable you have in the inspector is pointless

#

why on earth are you doing this?

bleak pasture
nimble inlet
wintry quarry
wintry quarry
#

just do Instantiate(bulletPrefab)

nimble inlet
#

this is all I have on the spawn that spawns the bullet spawners.

wintry quarry
#

which prefab is the bullet spawner?

nimble inlet
#

this is what I had in the script before, and now even.

wintry quarry
#

one you got from Resources.Load

nimble inlet
#

this was used before I had resource load.

wintry quarry
#

ok well go back

nimble inlet
#

I can do that yeah.

wintry quarry
nimble inlet
#

the holymines.

wintry quarry
#

Ok click on the holymines prefab

#

show its inspector

nimble inlet
wintry quarry
#

ok great so - now with the resources.load removed, what happens?

nimble inlet
#

the screen would be full of bullets by now if things worked out.

wintry quarry
nimble inlet
#

the uh, holy mines, sir.

wintry quarry
#

which one

#

the prefab?

nimble inlet
#

yeah.

wintry quarry
#

Some instance from the scene?

nimble inlet
#

no, the

#

instantiated

#

objects.

#

yes.

wintry quarry
acoustic arch
#

for jumping with a character controller, for a very simple movement 3D game can i just make it a very fast cooldown instead of checking if it's grounded

wintry quarry
#

because nothing in the code you shared thus far would ever change that

nimble inlet
#

yeah, that's why it's so confusing.

wintry quarry
# nimble inlet yes.

are you 100% sure the exact copy of HolyMines that is referenced from the spawn manager is the one you showed the inspector for?

wintry quarry
nimble inlet
#

yes

wintry quarry
#

That's what you should do to look at it

#

Also is that screenshot from the copy of the SpawnManager that's in the scene? Or elsewhere?

nimble inlet
#

on the scene.

polar acorn
eternal falconBOT
wintry quarry
nimble inlet
nimble inlet
#

neither of the search bars (hierarchy) and assets show anything

polar acorn
wintry quarry
wintry quarry
nimble inlet
#

no compile error after adjusting serialized field

wintry quarry
#

the only thing I can imagine then is just that we're looking at the wrong instances

polar acorn
#

Okay, so, let's see a screenshot of the entire unity window with the HolyMines prefab selected and the inspector visible

#

(This will make it possible to check several things at once)

nimble inlet
nimble inlet
polar acorn
# nimble inlet

Now, double click on that Bullet2 prefab in the inspector, and show another full screenshot of what comes up

nimble inlet
polar acorn
# nimble inlet

Can you show the code for BulletDamage and BulletCollisionHandler

nimble inlet
#

they can affect this? uh oh.

polar acorn
#

You might be destroying the prefab

#

instead of an instance of it

wintry quarry
#

shouldn't be able to 🤔

bleak pasture
#

this is much better than mystery shows on the discovery channel. Cant wait to know the cause 🙂

wintry quarry
#

If the prefab was destroyed I would expect "Missing (GameObject)" not "None (GameObject)" in the inspector

polar acorn
nimble inlet
#

these are the last scripts I meddled in tbh

wintry quarry
#

loopk fine to me, at least in terms of this problem

polar acorn
# nimble inlet

Okay, right before the Destroy call, add this log:

Debug.Log($"{gameObject.name} has collided with {other.gameObject.name} and is self-destructing", this);
#

Then go through the process that gave you the empty inspector parameter and see if this was ever logged. If it is, show what it prints

nimble inlet
#

this will take a bit

#

that was it.

polar acorn
# nimble inlet

Okay, those are the clones and they're after the error so it doesn't seem like it's that

nimble inlet
#

but at least the bullets instantiate right?

#

I mean the collision happens...

polar acorn
nimble inlet
#

which script?

polar acorn
#

Let's put in another surgical log:
The line before you instantiate the bullet, the place the error is at, put this:

Debug.Log($"{gameObject.name} is attempting to spawn bullet prefab: {bulletPrefab}", this);
nimble inlet
#

have now gone through all the scripts involved: no duplicates in the assets.

polar acorn
nimble inlet
#

this looks weird to me.

wintry quarry
#

hmm at least one of them works

#

and another doesn;'t

polar acorn
# nimble inlet

Click on the first log, just once. See which object it highlights.
Then click on the second log and see which object it highlights.

#

Are they different objects?

queen adder
#

both my capsule and my camera are at the position 0,0,0.

#

what is wrong?

polar acorn
queen adder
#

yes

nimble inlet
#

about that, how do see what ithighlights? cause clicking on things generally doesn't show anything to me...

queen adder
#

thank you that was really quick

polar acorn
#

So these logs will show something in the hierarchy when you click on them

#

as long as that object still exists at least

nimble inlet
#

oh rght. it does show the mineclone.

#

I may be detecting some flash of light from those mines. maybe they are destructing.

polar acorn
nimble inlet
#

yes.

polar acorn
# nimble inlet yes.

Can you show the full inspector of that object, during play mode. Even if it has to be multiple screenshots

nimble inlet
#

should I just remove this script from function?

polar acorn
nimble inlet
#

should I still send something?

polar acorn
nimble inlet
#

what, really?

polar acorn
#

Duplicate component

nimble inlet
#

gasdlfkasnlkfdnaslködfa

#

AAAAAAAAAAAAAAAAAAAAAAAAGH

nimble inlet
#

how does that happen, it's there only once in the prefab... x_x

#

the script..

polar acorn
nimble inlet
#

yes.

polar acorn
nimble inlet
#

yes. I do

#

oh no XD

#

aahahahaha

#

I'm dying.

#

thank you I can finish this project in time XD

#

I can get a grade man. XD

keen crescent
#

I'm trying to destroy tiles in a tilemap by using a tilemap collider 2D and setting the tiles to null based on the hit position as follows:

    {
        if (boxCollider != null)
        {
            Vector3 hitPosition = Vector3.zero;
            foreach (ContactPoint2D hit in collision.contacts)
            {
                hitPosition.x = hit.point.x - 0.01f * hit.normal.x;
                hitPosition.y = hit.point.y - 0.01f * hit.normal.y;
                tileMap.SetTile(tileMap.WorldToCell(hitPosition), null);
            }
        }
    }
    ```
It somewhat works, but the object is for some reason capable of resting on the tiles without destroying them at low velocities
You can see that if I move it again, it continues destroying them
Any idea how I can fix this?
ivory bobcat
#

Maybe your offset is setting the wrong tiles to null

#

Log the to-be nulled tile and see if the point is valid (not null already)
There shouldn't be any reason for a nulled tile to have made a collision.

bleak pasture
# polar acorn Since you asked, ^

🙂 I enjoy trying to learn from the issues other users encounter. It gives me some additional ways to resolve an issue if something similar happens to me

#

Whjen I started to code as an intern Id peruse the technologies my employer was using for a good part of the day (docs/stack overflow/msdn/etc) so I would have a bank of problems/solution in my head of problems I would potentially encounter and some way I could fix it like that

keen crescent
# ivory bobcat Log the to-be nulled tile and see if the point is valid (not null already) There...
private void OnCollisionEnter2D(Collision2D collision)
    {
        if (boxCollider != null)
        {
            Vector3 hitPosition = Vector3.zero;
            foreach (ContactPoint2D hit in collision.contacts)
            {
                hitPosition.x = hit.point.x - 0.01f * hit.normal.x;
                hitPosition.y = hit.point.y - 0.01f * hit.normal.y;
                //check if the tile at the hit position is null
                if (tileMap.GetTile(tileMap.WorldToCell(hitPosition)) == null)
                {
                    Debug.Log("Tile is null");
                }

                tileMap.SetTile(tileMap.WorldToCell(hitPosition), null);
                
            }
        }
    }

Is this approach for debugging valid? Because I'm definitely getting some debug logs

ivory bobcat
#

That means your hitPosition isn't the expected tile

#

Log the hit position for more info on what you made it set to null

keen crescent
tiny hawk
#

@wintry quarry We're uploading all our changes and there's still missing references. For us in this case, it's our NetworkManager gameobject in our scene that's missing all the references.

keen crescent
bleak pasture
keen crescent
boreal tangle
#

is the best way to move the player setting their velocity or is it using addforce

tender stag
#

why is this arc too long?cs //Draw upper arc Quaternion tiltRotation = Quaternion.AngleAxis(-scientist.yVisionAngle / 2, scientist.visionPosition.right); Handles.DrawWireArc(scientist.visionPosition.position, tiltRotation * scientist.visionPosition.up, upLeftEndpoint - scientist.visionPosition.position, scientist.xVisionAngle, scientist.visionRadius);

#

also its not quite connecting

hasty spire
#

how would 1 go about adding boundaries for the player in a 2d game

tender stag
#

colliders?

wintry quarry
hasty spire
#

i have an unactivate polygon collider to keep my cinemachine camera wigthin boundaries

#

if i activate collision with that would that work?

wintry quarry
#

assuming your character actually moves via physics, it will interact with colliders, yes

tiny hawk
#

Right after pulling my project with free download PlasticSCM, my NetworkManager looks like this. I need to run the scene, stop the scene, run cm update with PlasticSCM, change scenes in the editor, and go back to the original scene, then it gets populated

#

Is there a quicker way to do this?

tender stag
tiny hawk
#

Maybe I'm not supposed to run the scene right from the beginning, and there's another way to build the project

hasty spire
hasty spire
#

or should i try and edge collider?

#

ok

wintry quarry
#

you could also use 4 box colliders

#

or a single polygon that is in a "picture frame" shape

tender stag
muted wadi
#

how do I fix this error?

tender stag
#

whats the main difference between late update and update?

muted wadi
#

i think late update is run after the frame ends

#

wait no

#

late update is run after Update functions have been called

slender nymph
tender stag
muted wadi