#💻┃code-beginner

1 messages · Page 113 of 1

sudden grove
#

i mean i got the script to show up fine

#

i mean the actual head bobbing isnt working

wild cargo
#

Wait lemme read the context because I have no idea what it's even suppose to do

sudden grove
#

bet

sudden grove
# wild cargo Wait lemme read the context because I have no idea what it's even suppose to do

https://www.youtube.com/watch?v=2ysd9uWmUfo should be the code from this video, save me typing it all out i got the code from the comments haha

lets create a simple and easy head bob system for our fps games in unity3d.
in this part you will learn a basic one and for the next parts of this series we will have a much more advanced head bob dydtem.

#unity3d #fps


scripts are avaipable in discord server:
https://discord.gg/BzZMFvmdKW
_________________________...

▶ Play video
zealous oxide
#

oh my word, how did I miss that

#

thank you!!

rocky canyon
wild cargo
sudden grove
#

😭

wild cargo
#

but maybe you can give us some insight as to what doesn't work

#

does it move at all?

sudden grove
#

not at all

wild cargo
#

have you tried setting a breakpoint into the startheadbob function?

sudden grove
#

i even set the settings for maximum bobbage

#

and nothing

sudden grove
wild cargo
#

or if you don't know about debugging yet try putting a print statement into StartHeadbob()

sudden grove
#

im still kinda a beginner

wild cargo
#

like print("Entered headbob function")

#

and see if it triggers at all

sudden grove
#

howw would i add that in c#?

#

would i need a text object at all or just "print"

wild cargo
#

just add a new line inside the function and type "print("whatever here")"

sudden grove
#

i added it and nothing

wild cargo
#

did you save the script

sudden grove
#

yeah

rocky canyon
#

Debug.log is better b/c u get context and console functionallity (click to view gameobject) etc

wild cargo
rocky canyon
#

then best to learn that debug is better than print 😉

rich adder
#

good habits should be taught early

wild cargo
#

I thought he would learn that 100% later on but ok

rocky canyon
#

but yea, print works too

rich adder
#

Debug.Log should've been the first thing they learned

sudden grove
#

teach me your ways

rich adder
#

Debug.Log(someVlaue)

rocky canyon
#

basics

sudden grove
wild cargo
sudden grove
rich adder
#

learn how to use Debugging in your favor

sudden grove
#

oh wait

#

i might already be getting an idea on this

wild cargo
#

why is the stopheadbob in the update loop right after startheadbob occurs?

#

it would stop it even if it ran

sudden grove
rocky canyon
#

yup, that'll inform you when ur if statement is running true 👍

sudden grove
#

okay im getting my warning!

wild cargo
#

anything happening?

sudden grove
#

which means theres something wrong functionailty-wise right?

wild cargo
#

yupp

sudden grove
wild cargo
#

I think the StopHeadbob() call should not be in the update method

#

because it will literally stop the headbob right after you've invoked it

sudden grove
#

i removed it and still nothing

wild cargo
#

ok now try replacing CheckForHeadbobTrigger() with this

private void CheckForHeadbobTrigger()
    {
        float inputMagnitude = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")).magnitude;

        bool isMoving = inputMagnitude > 0;
        if (isMoving) StartHeadBob();
        else StopHeadbob();
    }
#

so now you can see, when the player is moving, it will start the head bob, and when it's the opposite it will stop it

#

oh and also is the script attached to your camera?

#

because it should be

sudden grove
#

its attached to my "cameraHolder"

wild cargo
#

ok and I assume PlayerCam has a Camera component

#

and that camera is the main camera of the scene

#

correct?

sudden grove
#

uhm yeah

#

but i still dont see any bob?

wild cargo
#

okay good

sudden grove
#

lemme send you a video

wild cargo
#

nah you don't have to

#

I don't know how I can explain the code that may work without your brain exploding lol

sudden grove
#

my bad

wild cargo
#

could you set the "amount" field on your script to a higher value?

#

hold on

#

you have a "MoveCamera" script?

#

it must also be accessing the camera then

sudden grove
wild cargo
#

so there may be a conflict where both scripts are trying to modify the transform's properties at the same time

hollow carbon
#

hello

wild cargo
#

and because they don't seem to have any communication between eachother, it will not work

sudden grove
wild cargo
#

wait lemme rewatch

#

so your MoveCamera script is modifying the position of the cam holder

#

maybe delete the headbob script from the cam holder

#

and add it to the cam holder's next child

sudden grove
#

Player Cam?

wild cargo
sudden grove
#

still nuthin

wild cargo
#

so then MoveCamera modifies the transform on the holder and the bob modifies the other one

sudden grove
#

unless i make a new object

#

in which i put the cam holder in that

#

and use the code to move that

wild cargo
#

nah I don't think it's necessary

#

check if Player Cam's transform position is being modified

#

when you try moving

wild cargo
hollow carbon
#

Nah, im fine

wild cargo
#

alr

sudden grove
wild cargo
#

as you can see the amount the position is being modified by is very tiny

clear seal
#

that's gud what is it about?

wild cargo
#

change the [Range] attribute you have on top of the Amount variable to be something bigger

#

or just delete it entirely for clarity

#

I gtg sleep in like 5 minutes so let's hope we get this done in that time

sudden grove
#

but its kinda wweird

wild cargo
#

great!

sudden grove
#

cause it feels like the character is slowing down each time it bobs?

wild cargo
#

that's odd

#

maybe another clip could be useful?

sudden grove
wild cargo
#

oh yeah that doesn't look normal

#

the Z value isn't being changed so that isn't the issue

#

maybe it's just your eyes messing with you idk lol

sudden grove
#

dont you see it slowing my character down?

wild cargo
#

it can't be if it's not accessing the movement script

clear seal
#

quick question

sudden grove
#

shoot

wild cargo
clear seal
#

um how do we use destroy if we want to destroy the object where the script is

north kiln
#

the bobbing is huge, I imagine it's just a perspective problem

north kiln
wild cargo
#

also that ^

clear seal
#

k thanks

sudden grove
#

okay guys i wanna make a very simple horror game, and i have a few basics down, i need to make a list so i can hold multiple items

#

is there a good place you guys can refer me to?

sudden grove
#

maybe be able to view the inventory system

#

but that comes later on

#

i just want fuinctionality first

wild cargo
#

so you need a fully fledged one, or expect scalability

#

not just a hotbar

sudden grove
#

yeah

wild cargo
#

let me find a video I used for this when working on a 3d game a while back

#

it teaches about SOs and layout groups and stuff like that

sudden grove
#

if anyone also knows of any good free low poly forest packs then im your man!

rocky canyon
wild cargo
#

https://www.youtube.com/watch?v=oJAE6CbsQQA

this was that video I believe

🏗 @TamaraMakesGames building system video: https://youtu.be/G2w78Xk6UhU
🏞 FREE assets download: https://www.patreon.com/posts/72631393?s=yt
🎁 Support me and DOWNLOAD Unity project: https://www.patreon.com/posts/72632413?s=yt

This tutorial guide will show you how to create a full inventory system with draggable items, bottom toolbar, full inven...

▶ Play video
sudden grove
wild cargo
#

for me, just watching the video, even when fully focused was not enough to grasp the concepts, so you should google stuff when something is not completely clear

#

it's also 40 minutes long soo

sudden grove
#

yeah i know 😭

#

this is for a 2d game tho no?

wild cargo
#

it doesn't matter because there's only 2d ui, no 3d ui

#

2d and 3d games both have 2d ui

#

like in Minecraft for example, the ui is 2d

#

even tho it's 3d

sudden grove
#

tbf just thinking about it i can grasp the concept from previous knowledge

wild cargo
#

also just realised I'm past my bedtime soo

#

time to say goodbye I guess

#

hopefully someone else helps you l8r

sudden grove
# wild cargo alr well you do you

so i can create the image/UI then from that i can make it so that a button eg. esc can open this image, in which it also enables the scripts that gives the menu functionality?

wild cargo
sudden grove
rocky canyon
#

u can use a gameobject to hold a scriptable obect as well.. with slots for everything like the image etc

#

and just change out the scriptable object.. each one having a different image, different functionallity, etc

wild cargo
sudden grove
#

that sorta thing

wild cargo
#

then I don't think you need such a complex system for your game

sudden grove
#

is there a name for what im looking for?

wild cargo
#

a hotbar might be enough idk

#

do you expect a save / load system in your game later on?

sudden grove
#

i do

wild cargo
#

ohh ok

#

i honestly haven't seen a video for a system you're looking for so

#

maybe try looking for one yourself

#

but I'm going to bed soo tired

#

cya

sudden grove
brittle plume
#

could someone please explain why I am getting this error on line 23 of my PatrolState script, Im new and have been trying to fix it for so long

summer stump
queen adder
#

Ur missing a reference to the enemy

summer stump
#

What even is enemy in this scope?
Ah, from BaseState probably

swift crag
#

It looks like it's from BaseState

#

A NullReferenceException occurs when you try to access a non-static member from a reference-typed object

#

mmmm words

swift crag
#

it happens when you don't have a thing and try to use it anyway

brittle plume
#

Could someone dumb it down for me

summer stump
swift crag
#

enemy is null or enemy.Agent is null.

queen adder
#

Did u copy and paste the code?

summer stump
#

Where do you tell unity which enemy you want?
I'd guess agent is fine if it's actually on the same object as Enemy

queen adder
#

Id be surprised if u knew about inheritance and statemachines but not NREs

slender nymph
#

the state machine is probably from a tutorial

queen adder
#

Oh prolly

#

Could u share the BaseState code?

brittle plume
#

At the top

queen adder
#

Thats the patrol state

swift crag
#

that's the definition of Enemy

brittle plume
#

Ohh shit

swift crag
#

you've defined the concept of an Enemy with that script

queen adder
#

Its ok i figured u did that on accident

swift crag
#

but I can't eat the concept of a hamburger

#

i can only eat actual hamburgers

queen adder
#

Its giving plankton eating that hologram burger on spongebob

swift crag
#

even more abstract than that

brittle plume
swift crag
brittle plume
#

So the problem is the enemy variable isn’t assigned

queen adder
#

Yes pretty much

queen adder
#

Is the Enemy script on the same Gameobject as the PatrolState script?

summer stump
# brittle plume So the problem is the enemy variable isn’t assigned

A quick note. What you have is a Declaration of a variable. It points to a value called null right now (some things have a default value, but a reference type like a Class, which enemy is, points to null).
You want an Assignment. That means using the = sign, or dragging in something via the inspector. If you don't do one of those two things, but try to use the variable, the compiler will say "hey, you just gave me null, that isn't right. You promised me it would have a reference. This betrayal forces me to give you an error!"

swift crag
#

a declaration says "I can store an X"

#

alas, having a box to put my hamburger in does not create one

brittle plume
#

Thanks a lot

#

I’ll get back to y’all when I’m home and check it out more

zealous oxide
#

time to manifest a hamburger

sudden grove
#

guys im trying to make a second canvas for my inventory, but its sticking to the 1st canvas i have ?

swift crag
#

I don't understand your problem

#

Do you mean both canvases are the same size?

sudden grove
#

i cant resize the second canvas or anything?

summer stump
swift crag
#

That is expected by default. Screen Space cameras are fitted to your screen size

summer stump
swift crag
#

Resize the things you put in the canvas

#

for example, this image is stuck to the bottom of its parent, covers 100% of the available width, and is 300 pixels tall

sudden grove
swift crag
#

Yes, that's expected

sudden grove
#

dont i want them in seperate locations?

#

or do i just end up turning one off and the other on when i activate it?

swift crag
#

the "Screen Space - Overlay" mode draws directly onto your screen

#

the canvas doesn't really have a meaningful position in the world

#

this is just how Unity decide to position it in the scene view

#

(it has to go somewhere)

summer stump
swift crag
#

changing the mode sounds irrelevant here

#

Screen Space - Camera would be the same issue; it's automatically positioned in front of the camera

#

and World makes no sense for an inventory display

#

If you want to make the inventory appear on only part of the screen, you need to set up your UI elements accordingly

summer stump
swift crag
#

that would be an answer to Y

#

"how do I make the canvas smaller?"

#

but X is "how do I make an inventory window?"

#

also, this isn't a code problem at all

sudden grove
swift crag
sudden grove
#

yeah im kinda tryna make it

rich adder
sudden grove
#

i just thought positioning was a big thing?

swift crag
#

You position stuff that's attached to the canvas

swift crag
#

noooooo

#

I'd give that page a read

#

as well as the subsequent "Basic Layout" page.

sudden grove
#

im following the first 2 mins of this video https://www.youtube.com/watch?v=-IPjFSWeyrg
so people can get abit of a grasp as to what im trying to achieve

An Inventory System that replicates Minecraft's, featuring equipment slots, switching items and basic movement.

Project Download ► https://github.com/ItsPogle/Minecraft-Like-Inventory-System-Unity

Discord ►► https://discord.gg/EevPKhxs34
Twitter ►► https://twitter.com/ItsPogle

Inventory Equipment Placeholder Art ► https://game-icons.net/
Inve...

▶ Play video
swift crag
#

I bet there are also some Unity Learn courses on UI

rich adder
#

what is problem? is the UI not showing on Render Texture

copper magnet
sudden grove
swift crag
#

I am curious why there's a RenderTexture involved, yes

rich adder
#

faking Low-Poly / pixel look

summer stump
eternal falconBOT
sudden grove
#

makes level design a teensy bit easier on me too hahaha

copper magnet
rich adder
# copper magnet <@968604165150507078>

I meant more like, post your issue with relavent code not me exactly. I haven't made much car controllers, i mostly get one from Asset Store and just put my own mesh onit :

copper magnet
#

oh okay

summer stump
rich adder
#

also use links for code because this doesnt show on mobie

copper magnet
#

Oh right sorry, never knew that

sudden grove
#

guys how do i make an "empty transform"

rich adder
#

you dont, you create an empty game object

summer stump
sudden grove
#

ohhhhh

#

okay he just said that in the vid

#

so i was confuised as

rich adder
#

every gameObject has a transform

#

and vice versa, but gameobject is kinda the whole container

copper magnet
#

Update: The error resides in the conversion from Quat to V3 and vice-versa

rocky canyon
#

a tip, use a parent container... that way u can rotate it (steer) left and right.. and u wont be fighting against the normal rotations of the tires

#

u can spin the tires within that extra container to keep the two rotations seperate

copper magnet
#

I fixed my actual problem simply by avoiding the infamous conversion i mentioned earlier

#

the problem really is in quaternion.eulerAngles

real falcon
#
        if (hit.normal.y < 0f) {
            playerVelocity.y = Mathf.Min(playerVelocity.y, -1f);
            Debug.Log("Hit Ciel " + hit.normal);
            return;
        }```

how exactly is it getting into this block if the y component is 0.00?
north kiln
#

The Vector3 ToString only reports 2 digits, if you care about precision use .ToString("F7") or similar to get more digits

real falcon
#

the wall is perfectly upright

#

and grid aligned

#

like its normal is 0 0 1

swift crag
#

log hit.normal.y to find out what you're actually getting

north kiln
#

I mean, what if it was 0.0000000025, -0.000000001, 1

#

You would never know with that debug

real falcon
#

it shouldn't be, since its exported from hammer editor which you have to use a specific tool to even get anything which isn't grid aligned

north kiln
#

Which is why you should probably have a less precise check

north kiln
real falcon
#

when im jumping against a wall it says the Y vector is -1 now

#

which makes no sense

north kiln
#

You can't even represent a value like 0.2 as a float accurately

real falcon
#

I am at my limit with this stupid collider

#

why is it so hard to get VECTOR OF WALL I HIT

north kiln
#

Draw the collision using Debug.DrawRay

sudden grove
#

guys im a little confused with this inventory tutorial

#

so im pretty sure i have everything in place

#

but i dont know how to actually make it so that an item is equipable and how to actually ADD it into my inventory?

real falcon
#

I just wish there was a collider that could actually tell me the vector of the wall I hit

#

not some random vector that kind of relates

north kiln
#

Well, with no screenshots of the setup and little debugging, nobody can help you

real falcon
#

this doesn't even make any sense

sudden grove
real falcon
#

how???

north kiln
#

Makes a lot of sense to me

real falcon
#

its the same variable

north kiln
#

that's -0.0000000476837

real falcon
#

oh its really small

#

why can't I get the vector of the wall I actually hit though

#

its the stupid capsule shape the collider has, nothing makes sense because its using tangents or something

#

in the debug view the ray is displayed as expected

#

pointing down, despite the wall being vertical

north kiln
#

I mean, ~0, 0, 1 sounds like a normal vector for a wall

real falcon
#

yes but that's not the vector it's giving me

#

that's the vector of the wall, in the mesh

#

if I Looked at the vericies I guarentee you there is no y component do the normal

#

because it's a brush exported from hammer

north kiln
#

There's barely a y component here, it's a floating point error

#

your logic just doesn't account for any error, which is not how to program this sort of logic

real falcon
#

ok, yet, if I set the condition to hit.normal.y < -0.1f which is well within error it still doesn't work, gonna try it again

north kiln
#

It shouldn't trigger when hitting the wall with a value like that

real falcon
#

ok yeah it seems fine now. the log still seems weird but the movement itself seems correct

#

mostly

#

still seems a bit jittery when I jump against a wall

#

that might be fps tbh

#

I still need to find a way to figure out what wall I collided with though, this collider can collide with an edge without colliding with either surface which contains that edge

#

and so the normal is just compeltely unintuitive

#

but whatever ill do that later

#

nevermind this is definitely not fps

#

if I hold into the wall it's stuttery

#

but that might be an issue with my code and not collider nonsense again

delicate venture
#

hey man, sorry for the late response i´be trying to figure out the problem for the last two days and i only resolved today, the article you send was really helpful so thank you : )

sudden grove
#

hi guys, could you guys help walk me through this variable inventory system?

#

or if its uneccesary ill just use a plain one

#

would prbs be better tbf if i used a plain one

sudden grove
abstract finch
#

do people typically name the variable timeElapsed to simply 't'?

sudden grove
#

really simple but i dont know how to reference my canvas?

teal viper
clear seal
teal viper
#

I will not recognize it the next week without reading through all the relevant code and understanding it.

swift crag
#

I do not use t when the variable is going to live for a long time

teal viper
#

I want to see the variable name and know what it's for.

swift crag
#
float t = Mathf.InverseLerp(lower, upper, amount);
float result = Mathf.Lerp(from, to, t);
teal viper
#

It might be justifiable in this case👆

swift crag
#

t is also more valid than elapsedTime if I'm counting up towards 1 from 0

#
public class Explodinator : MonoBehaviour {
  public float duration;
  [SerializeField] Renderer targetRenderer;
  private float t;
 
  void Update() {
    t = Mathf.MoveTowards(t, 1, Time.deltaTime / duration);
    
    targetRenderer.material.color = Color.Lerp(Color.green, Color.red, t);

    if (t == 1) {
      Debug.Log("Explodination time!");
      Destroy(gameObject);
    }
  }
}
#

something like that

#

I don't use it in most other contexts

amber spruce
#

quick question if i add a event to the animation from the project files instead of it via clicking on my player does that change anything

#

because this is what i see

#

how do i have it set a bool to smth

teal viper
#

Wasn't it the same for from the import settings?🤔

#

As a bool you can use int 0/1

swift crag
#

There's no bool paramter, yeah

#

just use an int

amber spruce
#

how do i have it set it for that script though

#

and how do i reference the correct variable

#

video im watching has this

teal viper
#

I've never seen that. Can you share the link of the video?

amber spruce
teal viper
amber spruce
#

well slight problem is the script would be on a parent object of the one with the animator lol but its animator reference is the correct one

#

Attacks/Methods/FinishAttack ( ) set that as the function ??

#

and what goes for object

teal viper
teal viper
#

Ah, I guess animation events are a bit different for animations you made in unity and that's what you see in the video

amber spruce
amber spruce
teal viper
#

Just type the function name same as in your code and change whatever params you want to be passed in.

amber spruce
#

it doesnt show what to put for it

#

thats the only image it gives of that

teal viper
#

wdym?

#

Type the name of the function in "Function" field

amber spruce
#

what if i have multiple functions with the same name

teal viper
#

All of them will be called

#

You'd usually create a function specifically for the animation event

amber spruce
#

FinishAttack so thats good

teal viper
#

like OnAttackAnimationEvent or something

amber spruce
#
 public void FinishAttack()
 {
     canAttack = true;
 }

for that one

teal viper
#

FinishAttack

queen adder
amber spruce
#

so thats the problem because technically no

#

i use animation overides for my attack combo system

unreal imp
#

how works the getContact?

teal viper
#

it gets the cotnact I guess. You'd need to provide some more details for a better answer.

swift crag
#

I was wondering about that

teal viper
#

Probably if you create an animation in unity tied to a specific object, it has a reference to it, so it can show available functions..? I don't know for sure. Just a guess.

uneven swallow
#

Had a good look around the internet but couldn't find any guidance that worked.

I am trying to bake a navmesh at run time. If I do this manually everything works just fine. When I attempt to use "using UnityEngine.AI;" to create my mesh as per some tutorials, I'm faced with this.

Assets\Scripts\DungeonManager.cs(9,12): error CS0246: The type or namespace name 'NavMeshSurface' could not be found (are you missing a using directive or an assembly reference?)

The reason I'm baking at runtime is because Im procedurally generating a map at start.
I have the Unity AI Navigation package installed.
Here is an example of my script.

    {
        SpawnMobs();
        if (navMeshSurface != null)
        {
            navMeshSurface.BuildNavMesh(); // Build the NavMesh
        }
        else
        {
            Debug.LogError("NavMeshSurface is not set.");
        }
    } ```

Any advice would be greatly appreciated.
queen adder
amber spruce
teal viper
amber spruce
uneven swallow
teal viper
uneven swallow
teal viper
#

What namespace are you using?

#

It seems to be in Unity.​AI.​Navigation

cosmic dagger
# uneven swallow Had a good look around the internet but couldn't find any guidance that worked. ...

Hi ! Today I'll be showing you a unity package allowing us to bake navmesh during runtime aka Playmode.

Package name : com.unity.ai.navigation

📄 Documentation : https://docs.unity3d.com/Packages/com.unity.ai.navigation@1.1/manual/index.html

🐦 Follow me on Twitter : https://twitter.com/thecodefriend
👪 Join the Discord server : https://www.disc...

▶ Play video
uneven swallow
queen adder
# amber spruce that means that they arent in there

put both the AnimatorController and the AnimationClip in question inside the AnimatorOverrideController.

in the target GameObject, throw an Animator component on it AND your script containing the method(s) (functions) your targeting, then feed the Animator your AnimatorOverrideController.

with the GameObject select, head to the Animation tab, select the animation containing the event from the dropdown menu, and select the event.

now you should see the AnimationEvent window properly on the inspector.

uneven swallow
teal viper
#

you just need to google "unity API apiNameYouSearch".

amber spruce
#

it just swaps the punching one with 3 different punch animations

queen adder
uneven swallow
north kiln
uneven swallow
north kiln
#

!vscode

eternal falconBOT
#
Visual Studio Code guide

If your IDE is not underlining errors in red or autocompleting code,
please configure it using the link below:

https://on.unity.com/vscode

queen adder
queen adder
#

Add missing usings / imports

uneven swallow
#

I've got VS Code set up correctly and it's helping me now :D
Thanks @queen adder @north kiln .

lapis halo
#

How could I add a delay to instantiate an object?

lapis halo
#

👍

cosmic dagger
amber spruce
queen adder
lapis halo
rich adder
queen adder
lapis halo
rich adder
#

WaitForSeconds

lapis halo
#

I get the terms mostly, just utilizing them is confusing. If that maeks any sense

teal viper
rich adder
lapis halo
teal viper
lapis halo
teal viper
#

Well, use it to delay the instantiation.

lapis halo
#

Wait, something just clicked.

teal viper
#

yield return allows you to pause the coroutine for the specified amount of time.

queen adder
teal viper
#

returning what?

queen adder
#

a Coroutine

rich adder
#

to stop it usually

teal viper
#

To have a reference to the instance of the running coroutine.

lapis halo
#

I've figured it out. Thanks a ton.

queen adder
glad fiber
#

this sounds out of blue but anyone willing to help me out with my project? im running late on deadline. I will literally pay u and price is negotiable.

teal viper
#

!collab

eternal falconBOT
glad fiber
#

woah. thats cool

queen adder
glad fiber
#

thats alright. thank you for the kind words tho

true pasture
#

how would I change the color of the name text here?

true pasture
#

thanks that was easy

uneven path
#

Helo does anyone know the code to like

#

Make a script wait for like 2 seconds

#

Then execute the next part of the script?

summer stump
lapis halo
#

Enemy's spawning in and going towards players spawn pos, instead of the players current pos.

uneven path
frosty hound
#

Yes

uneven path
#

Nooo

eternal needle
teal viper
untold idol
lapis halo
#
{
    public GameObject blood;
    public GameObject player;
        public float speed = 5;


    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
   private void Update()
    {
        gameObject.transform.position = Vector2.MoveTowards(gameObject.transform.position, player.transform.position, speed * Time.deltaTime);
    }```
frosty hound
#

If this object is moving towards what was the player's spawn position, then you've probably incorrectly assigned that object to player, instead of the actual player.

lapis halo
#

only the player's prefab

untold idol
#

Then the script that spawns the enemy should have a reference to the player

#

then it can be assigned from there

uneven path
#

But I see

teal viper
eternal needle
eternal needle
uneven path
grand badger
lapis halo
#

singletons?

teal viper
#

Don't bring singletons into this... There's nothing requiring a singleton here.😅

grand badger
#

e.g.:

   private void Update()
    {
        if (player == null) { player = FindObjectOfType<PlayerMovement>().transform; }
        transform.position = Vector2.MoveTowards(transform.position, player.position, speed * Time.deltaTime);
    }
grand badger
uneven path
ivory bobcat
#

Just properly reference this from the inspector or with the manager that spawns the object.

uneven path
#

I appreciate the thoughts tho

eternal needle
ivory bobcat
teal viper
ivory bobcat
#

They'd pass that reference to the enemy after spawning itcs var enemy = Instantiate(enemyPrefab); enemy.player = player;

grand badger
teal viper
eternal needle
#

true for the last part, the Find methods isnt really a valid option imo though

grand badger
#

I personally dislike both Find and assigning a reference from the manager, unless it's part of the game design
(e.g.: you want SOME enemies to target non-player objects sometimes, but want to keep it really simple)

ivory bobcat
eternal needle
grand badger
#

idea is:

  • if you're going for fully simple, singletons is the simplest choice
  • if you're going for more than that, passing reference via manager won't be enough anyway, and you'll eventually need a FSM that deduces target
summer stump
teal viper
ivory bobcat
teal viper
#

And what do you mean by FSM? Finite State Machine? What does it have to do with referencing an object?

grand badger
teal viper
ivory bobcat
#

Constructing and maintaining the aberration to provide global access of variables isn't easier.

grand badger
#

we're exactly dealing with assigning dependencies xD your choice is to add a dependency of EnemySpawner to Enemy.target, therefore to Enemy

#

whereas in clean architecture the Enemy should be able to retrieve its target by itself (either its FSM, or a fixed static reference, if that's enough)

teal viper
#

It depends. If we're talking about AI, there's a lot more involved. It might have sensors that would get the required references themselves. But that's a totally different story.

summer stump
ivory bobcat
grand badger
#

that's a valid architecture choice as well -- as long as you follow through.
from my experience I found avoiding external dependencies to important variables allows for a more flexible design

#

like -- sry.. I mean avoiding direct assignments to those important variables from outside the class

ivory bobcat
#

Initialization and configuration from others who have reference to the instance is okay in my opinion. An instance accessing more than what's given to it would be a red flag for me.

#

It's definitely less of a hassle to directly have access to everything though.. (extreme: global/public everything)

grand badger
# ivory bobcat Initialization and configuration from others who have reference to the instance ...

This sounds great in theory but could end up with extreme complexity to make up for that loss of accessible references and ability to spaghettify.
e.g.: you could initialize with ITargetSolver, IMovementSolver, IAttackSolver instead of creating a new class for each combination.
..which is great but overkill in a lot of cases and would likely end up requiring multiple times the code, especially if solver code has more dependencies (e.g.: animator).

I love that pattern but haven't found much success pulling it through besides basic alterations without going for a full-pledged AI system.
(e.g.: basic aka configuring only AttackPatternSettings, EnemyStats, etc)

nimble scaffold
#

Guys can anyone give any good starting mobile game ideas

grand badger
#

an Infinite Runner sounds like a good start

nimble scaffold
#

Like 3d good game except the runner ones

#

Okay..... What about a good AAA racing game?

#

But @grand badger can you help me by saying where to get good high poly models for free??

nimble scaffold
#

Okay

lapis halo
nimble scaffold
#

Lul

#

But do unity textbooks work??
I mean do they worth?

queen adder
#

we are antimeme society

pseudo pasture
#

nooooo

queen adder
#

remove that meme before the cops get you

pseudo pasture
#

where am i supposed to post funny unity memes now

queen adder
#

somewhere else blushie

pseudo pasture
#

smh

#

can you just laugh before i delete it then 🥺

queen adder
#

No 😛

pseudo pasture
#

nooooooooooooo

#

ok but fr tho chatgpt being helpful af

dense cargo
#

You still need to know more than it. Otherwise it will feed you straight garbage.

pseudo pasture
#

not just because it's doing the work for me, but it's also explaining how the bits work

pseudo pasture
queen adder
#

it's helpful for biginner stuffs, but can hinder your learning a lot. it can be a frustation when you at intermediate level already

pseudo pasture
#

good thing im a beginner then

rich adder
round scaffold
pseudo pasture
#

yeah im hoping i can figure out most of the practical stuff with this game im making. then i can always just refer back to it and copy paste bits of old code to new programs like everyone else does!

glacial blade
#

i have this code

#

and when i take damage the fill amount just drops to zero?

#

my healt is still 95 and the print says its zero?

#

i have this cvode where the fillamount works dine

#

fine

pseudo pasture
#

where's the part that tells the code that damage was dealt?

glacial blade
gaunt ice
#

integer division

rich adder
#

OOF

#

i just noticed

#

good catch

glacial blade
glacial blade
#

damn

pseudo pasture
#

the hecky is integer division

rich adder
#

i usualy make my health floats so it make sense

rich adder
pseudo pasture
#

oh

#

wait so does that mean like

#

this is a division equation?

glacial blade
#

yes?

#

"/" means division

grand badger
#

you gotta cast one to float

pseudo pasture
#

yeah sorry my brain had a slow moment and i thought it was like a string sort of thing and the "/" was just a visual separator, but strings need ""

glacial blade
#

yeah making it float is working nw

pseudo pasture
#

i feel like a neanderthal trying to understand why it's health divided by max health

glacial blade
#

fill amount has to be 0 to 1 . so 95/100 is 0.95

#

health is 95 and max health is 100

#

and if you dividehealth when its full or 100 to max health which is 100 you will get 1 so the fill amount if full

pseudo pasture
#

ooohhhhhhhh

grand badger
glacial blade
grand badger
#

health makes sense to be an integer

pseudo pasture
#

thanks for explaining that, makes so much more sense

grand badger
#

semantics, mostly

#

if you don't want floating numbers in the UI, int makes more sense

glacial blade
#

so like what is casting? just turning it int to float?

grand badger
#

yeah

grand badger
#

float c = intA / (float) intB;

rich adder
#

just format the float via text

glacial blade
#

eh im sure thats on ones prefrence

#

btw like how do you guys make something thats not on tutorial. i have very hard time making something new

rich adder
#

experience

#

learn stuff until you can piece it together on your own

glacial blade
#

ok

rich adder
grand badger
#

e.g.: design your thing first, what you want (maybe a top-down roguelite puzzle with immovable enemies)

#

then search top-down movement, triggers, tilemap, etc, until you have something close to what you want

queen adder
#

@glacial blade I say make it a float,

and keep the value between 0 and 1, then when displayed, multiply the value by 100

multiplication is faster than division* anyway 😅

Why Division is Slower Than Multiplication?

grand badger
#

MaxHealth is not a great variable to have if it's intended to be always 1 😛

pseudo pasture
#

lots of things do that

rich adder
#

yea 0-1 is silly

#

but making health/max health floats is normal and prob better

#

dealing with casting every time is annoying

eternal needle
queen adder
#

and I wouldn't say it becomes harder, having a property that calculates the desired value is a thing in C#

#

you only have to write it once.

rich adder
#

0-1 you have no room to expand max health

eternal needle
#

just store the true value

grand badger
#

is there a thing people don't argue about in this discord? xD how is this possible lol

#

I guess makes sense since there are tons of people, each having different practices

rich adder
#

i think its just a regular discussion dont think anyone is arguing lol

grand badger
#

but a float casting? XD

eternal needle
#

we're just talking, no ones breaking out the weapons dude

cosmic dagger
gaunt ice
#

it is impossible to get rid of division in your case
then how would you deal damage? multiply with 1f/their max health (though this can be precalculated, actually you will get wrong answer, but i think that fine in game software....)?

grand badger
eternal needle
brittle plume
#

can someone help me with this please

#

I dont know how to fix the error

rich adder
eternal falconBOT
rich adder
#

id like not to squint to view code

grand badger
eternal needle
brittle plume
#

im honestly just watching a tutorial and still very new

grand badger
cosmic dagger
eternal needle
cosmic dagger
#

Keep watching the tutorial and see if they do that . . .

grand badger
#

100 + 1 because of late set hp=1 oh nvm

brittle plume
rich adder
#

so you copied wrong

eternal needle
brittle plume
#

ive looked at the tut over so many times and it seems i have everything right

cosmic dagger
rich adder
low perch
#

is vector2 =
any different from vector2.set() performance wise

brittle plume
grand badger
#

yeah no it's a mystery 😆

gaunt ice
#

floating point error

rich adder
#

if you need to pass a new vetcor2/3 you can't, as only takes 2 floats

summer stump
queen adder
cosmic dagger
brittle plume
grand badger
rich adder
cosmic dagger
brittle plume
brittle plume
#

i really did just miss a very small thing

rich adder
#

usually is

cosmic dagger
brittle plume
#

I was worried that maybe it wasnt working because the navigation component was changed since the video was made

#

but i was wrong

#

so thank you

queen adder
unreal venture
#

i am very confused
i have a vector3 rb.velocity and i'm trying to scale it to avoid side drift of a vehicle
but even scaling it by local 1,1,1 doesnt work and the vehicle completely spazzes out ...?
scaling it with world space vector3 doesnt work because it's unable to turn, then.

//TEST: scale velocity to local 1,1,1
//forward: 0,0,1    right: 1,0,0    up: 0,1,0
rb.velocity = Vector3.Scale( transform.forward + transform.right + transform.up , rb.velocity);

//reduce sideways drift
rb.velocity = Vector3.Scale( transform.forward + transform.right * 0.2f + transform.up , rb.velocity);
lavish terrace
#

how to activate this by coding ?

rich adder
spiral glen
#

Idk if this is UI but when I attempt to use an inputfield I need to click on it to actually interact with it, is there a way to make it auto-clicked on scene opening?

eternal needle
rich adder
#

no

#

Select

spiral glen
#

Where would I find that?

rich adder
#

there might be another one you may need

spiral glen
#

I'm usinga method connected to an input field to get the actual value

rich adder
spiral glen
#

if I just throw it into the keyboard class would that work?

#

it just needs to be run on scene

rich adder
spiral glen
#

swag, thansk

#

💋

cosmic dagger
queen adder
#

yes, please do the ++

spiral glen
rich adder
spiral glen
#

is TMP important?

rich adder
#

if yours is textmesh pro

#

yeah id say it is

spiral glen
#

how do I know if it is

rich adder
#

read the label ?

spiral glen
#

I changed the name to text area for some reason

rich adder
spiral glen
#

yeah it's the pro one but it's make an error

rich adder
#

using TMPro

spiral glen
#

wdym

#

oh ok

spiral glen
#

YIPPEEE

#

it works

#

🙂

rich adder
#

Namespace is just a "group" scripts belong to

spiral glen
#

So like a library

#

or a collection in a library

rich adder
spiral glen
#

Ah ok

queen adder
unreal venture
spiral glen
#

is there a way to see if something is visible or not?

#

trying to make a button that shows a list but removes it if it is already shown

eternal needle
spiral glen
#

holy guacamole it's 3:30 am

hushed badge
#

yall

#

what would be the index for crouch layer

#

im not sure if c# starts counting from 0 or from 1

rich adder
#

yes pretty much all indexes start at 0

#

so crouch is Layer(1)

hushed badge
#

ok thanks

hushed badge
rich adder
hushed badge
#

i havent used lerping before

rich adder
north kiln
#

That will always evaluate to roughly 10, because Time.deltaTime is small

hushed badge
#

im assuming this is a function?

#

not sure tho

rich adder
# hushed badge im assuming this is a function?
    IEnumerator LerpWeight(float targetValue, float duration = 1)
    {
        float startValue = anim.GetLayerWeight(1);
        float elapsedTime = 0;
        // Wait until the time has reached the target duration.
        while (elapsedTime < duration)
        {
            // Increment our timer.
            elapsedTime += Time.deltaTime;
            // Normalise our timer, and use it to interpolate.

            anim.SetLayerWeight(1, Mathf.Lerp(startValue, targetValue, elapsedTime / duration));
            yield return null;
        }
    }```
north kiln
#

So you can comprehend the rest of the logic

hushed badge
#

ok thanks

hushed badge
#

its working but

#

for some reason theres a delay when uncrouching

#

like a 1-2 sec delay before the coroutine starts

#

this is how its looking rn

rich adder
#

10 is overkill since its fully activate only at 1

hushed badge
#

oh youre right

#

setting it to 1 fixed

#

but i thought that at 1 it would be kinda in between base and crouch

#

isnt that how weight works

hushed badge
#

damn what

#

i couldve sworn the max weight was 10

#

😭

#

im tripping

rich adder
#

yea lol

hushed badge
#

so now i also gotta lerp the camera and the collisions?

#

i mean i guess i dont need to lerp collisions i could just set them normally

#

but the camera

rich adder
#

you mean lerp the collider ? thats also common

#

there are also tweening libraries out there (DOTween is good)

#

Coroutine simple enough, the result is pretty good when done correct

hushed badge
#

ok thanks

#

so should i make another function for lerping vector3s

#

or should i try putting it all into one

rich adder
#

make different methods

#

yes one for vector3

hushed badge
#

and also what uhh

#

type? i guess
are objects

#

like strings ints floats etc

#

what do i use when getting the camera for example or the player model

rich adder
#

Camera

#

model is part of the Mesh FIlter, Mesh renderer displays how it will look aka texture/material

rich adder
eternal falconBOT
rich adder
#

under API

#

All the components have access to their gameobject/transform

hushed badge
#

wait what if i just change the center of the collider instead of lerping the camera down

rich adder
#

pretty common

#

are you using character controller?

hushed badge
#

yeah

rich adder
#

this dude does that and with lerp

#

they actually lerp correct too which is rare on YT

queen adder
hushed badge
#

yall how can i move the camera position up while still keeping it on the character

queen adder
abstract finch
#

I have two varaibles i want to track, the prefab of an object and its interface. I want to store a list of these two varaibles, should i be using dictionary or classes?

Think of it like an enemy pool.

hexed terrace
queen adder
# hushed badge yeah

you don't have the camera as a child of the player's head, do you? (you don't need to btw)

hexed terrace
hushed badge
#

jus let us talk

hexed terrace
#

Follow the server rules ¯_(ツ)_/¯

hushed badge
#

mods will handle it if they wish to

dry tendon
#

hi everyone... does someone knows why do i get this log?

#

and what does it mean

rich adder
#

thats a Null Reference

#

something on line 85 is null on Night Background

dry tendon
#

i can ignore it?

rich adder
#

gamedata is null

#

no you shoud never ignore errors

wind meteor
#

can you help me with code

gaunt ice
#

what is interactable object?

wind meteor
#

i dont know

gaunt ice
#

then we dont know ofc if you dont know what this type is
and there is a method called as TryGetComponent

wind meteor
#

and i create code "InteractableObcject" and now its work

#

thanks

queen adder
#

you're welcome!

rich adder
#

not code question

queen adder
# wind meteor can you help me with code

@wind meteor and try dis, it's 🤵‍♂️er

var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
/// if (Physics.Raycast(ray, out RaycastHit hooray) is false) return;
if (Physics.Raycast(ray, out var hooray) is false) return;

/* TODO: ... */ _ = hooray.transform;```
wind meteor
#

how to create cod like photo

gaunt ice
#

!code

eternal falconBOT
gaunt ice
#

read inline code section

queen adder
rich adder
#

cod like the fish

queen adder
#

XD

#

you see me

#

now you don't

last venture
#

Hey i have an animation for a 2d character (the player) attack (dash attack) so the animation move the sprite. Id like to know how could i make the player collider and position match the animation

#

The attack is the sweep

craggy lava
#

Error

MissingReferenceException: The object of type 'GameManager' has been destroyed but you are still trying to access it.

Its on this line

 DontDestroyOnLoad(Instance);

I know what the error means but like i dont know a fix

    private async void Awake()
    {
        try
        {
            await UnityServices.InitializeAsync();
        }
        catch (Exception e)
        {
            Debug.LogException(e);
        }

        SetupEvents();

        await SignInAnonymouslyAsync();
        await EconomyService.Instance.Configuration.SyncConfigurationAsync();

        if (Instance == null)
        {
            Instance = this;
            DontDestroyOnLoad(Instance);
        }
        else if (Instance != this)
        {
            Destroy(gameObject);
        }
    }
keen dew
#

The singleton setup should be before all the async stuff

keen dew
#

Which part is unclear?

languid spire
#

yes, why would you initiate all the async stuff to just then go and destroy the object it's running on?

craggy lava
keen dew
#

Probably not a good idea to use code that you don't understand

#

but the singleton setup is from the if (Instance == null) line onwards

craggy lava
keen dew
#

I mean it's the code that sets up the singleton

craggy lava
#

I fixed the code now i got a new error

#
NullReferenceException: Object reference not set to an instance of an object
MainMenuManager.Awake () (at Assets/Scripts/Managers/MainMenuManager.cs:26)

line of error

PlayerBalance playersCoinBalance = await coinCurrencyDefinition.GetPlayerBalanceAsync();

here is my code

private async void Awake()
{
    await EconomyService.Instance.Configuration.SyncConfigurationAsync();

    var gemCurrencyDefinition = EconomyService.Instance.Configuration.GetCurrency("GEMS_DATA");
    PlayerBalance playersGemBalance = await gemCurrencyDefinition.GetPlayerBalanceAsync();

    var coinCurrencyDefinition = EconomyService.Instance.Configuration.GetCurrency("COIN_DATA");
    PlayerBalance playersCoinBalance = await coinCurrencyDefinition.GetPlayerBalanceAsync();

    gameManager = GameManager.Instance;

    coins = playersCoinBalance.Balance;
    coinsText.text = "Coins: " + coins;

    gems = playersGemBalance.Balance;
    gemsText.text = "Gems: " + gems;
}
hollow raft
#

i am using visual studio, but it give me the "The type or namespace name 'type/namespace' could not be found" error, but the game works fine (without error) when i launch it via unity, but i can't code if it can't access the namespaces (this error started when i switched pc)
(the namespaces should be referenced i check in the solution explorer, i thus have no idea what to do)
(i am using assembly-CSharp definitions)

willow scroll
craggy lava
willow scroll
willow scroll
#

By double clicking it with your right mouse

hollow raft
#

yes?

willow scroll
hollow raft
#

yes :' (

willow scroll
hollow raft
willow scroll
#

just in vs?

hollow raft
#

yes

willow scroll
#

That's strange

hollow raft
#

it is xD

#

that's why i am seeking for help, i am super confused

willow scroll
hollow raft
willow scroll
hollow raft
#

when i changed pc

willow scroll
#

What about other scripts? Do you have the same weird behavior there?

queen adder
hollow raft
#

i have the unity addon and it seems to be a reference issue so i doubt it would be a .Net

craggy lava
#

Error

The best overloaded Add method 'SortedDictionary<int, string>.Add(int, string)' for the collection initializer has some invalid arguments

Line of error

        {1000000000000.ConvertTo<int>, "T" }

Code

public static class AbbrevationUtility
{
    private static readonly SortedDictionary<int, string> abbrevations = new SortedDictionary<int, string>
    {
        {1000,"K"},
        {1000000, "M" },
        {1000000000, "B" },
        {1000000000000.ConvertTo<int>, "T" }
    };

    public static string AbbreviateNumber(float number)
    {
        for (int i = abbrevations.Count - 1; i >= 0; i--)
        {
            KeyValuePair<int, string> pair = abbrevations.ElementAt(i);
            if (Mathf.Abs(number) >= pair.Key)
            {
                int roundedNumber = Mathf.FloorToInt(number / pair.Key);
                return roundedNumber.ToString() + pair.Value;
            }
        }
        return number.ToString();
    }
}
gaunt ice
#

idk how you can convert long to int

craggy lava
#

I also dont know but if i remove the .ConvertTo<int> it still does not work

craggy lava
gaunt ice
#

try to run it
i think you will get an overflow error
you should change the generic parameter int to long

craggy lava
hushed badge
#

i finished my first movement system and now idk what to do

#

should i make a map

#

or

#

interactions

#

or something else idk

craggy lava
#

Make the mechanics then the visuals

#

thats what i would do because if you have some mechanics you can make a map if you need a map just make a little prototype map

hushed badge
#

im tryna make like a low poly horror game about cleaning up murder scenes

craggy lava
hushed badge
#

with ps1 graphics

gaunt ice
#

you mean the -1T?

craggy lava
# gaunt ice you mean the -1T?

yea like i have 5 gems and it says i have -1T i will just try and find another way of formatting my numbers so i can get K, M, B, T, Qa, Qi, Sx, Sp (sp is 100e24)

gaunt ice
#

i am not sure if it is due to some number type conversion (the rounded number is -1), try to change all the type to long first (except the i in for loop)

#

oh wait it shouldne fall into the if block, it should return "5" directly

craggy lava
gaunt ice
#

I try to reproduce it but it works....

craggy lava
craggy lava
swift crag
#

which wraps around to something like negative one billion

#

I presume that's why you tried to use ConvertTo. Any numeric literal that's too big for an int will automatically become a long.

#

long will give you some more headroom. You can also use double if you want to use extremely large numbers, but note that you'll pay for it in precision

quick kelp
#

i gave my player controller the ability to crouch but i honestly have no idea how to make it to where the controller checks if there is a ceiling there to keep it crouched

swift crag
gaunt ice
#

i have checked

Mathf.Abs(5)>=1000000000000L
```returns false, so sorted Dictionary<long,string> works (tested)
#

so i have no idea why it returns -1, if he has changed it

swift crag
#

they said it works correctly now

#

it was wrong when they had a dictionary mapping ints to strings

#

since one trillion overflows to a negative number when stored in an int

charred spoke
cosmic dagger
desert elm
#

hm-
this should select a new chosentargetlocation if its closer than the already selected one, but this doesn't appear to work- where did I make a mistake?

cosmic dagger
gaunt ice
#

what is chosenTargXXX at first? the first element?

desert elm
cosmic dagger
desert elm
#

right yeah okay-

#

yeah I guess ill need to log- but you know
the red square in the firing range ( white circle ) is certainly closer than the placeholder at X=500

shrewd swift
#

is there a way to comment enum elements ? so when i hover them i can get some text showing in VS

swift crag
#

I don't understand.

#

Do you mean when you hover over a variable holding an enum?

verbal dome
#

I guess like a summary for individual enum entries

shrewd swift
swift crag
#

Oh, comment!

shrewd swift
#

like i can hover
whateverenum.whatevervalue

swift crag
#

a triple slash starts a documentation comment

#

You can put these in quite a few places

verbal dome
shrewd swift
#

okay ty

#

idk why i didnt try the default way of commenting first, in my head enum were "special"

swift crag
cosmic dagger
#

Man, I like having documentation (summary info) for all members of a class. I did that for one of my packages and the entire thing is just comments everywhere! 80 lines turned into 400 . . . 😄 🤣

quick kelp
#

ok looked at the Documentation and implemented it to the best of my knowledge
and im still clipping through the ceiling

hidden sun
#

hi, why i'm starting to get this type of errors on everything i do?

#

it used to work only with Debug.Log();

cosmic dagger
hidden sun
#

ty, now i've seen that it added somehow

cosmic dagger
#

You need to specify which one by using the fully qualifying name . . .

#

You don't need the System.Diagnostics one . . .

unborn gale
#

why doesnt this code work (trying to make a bullet collide)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class bulletDistroy : MonoBehaviour
{
public string tar;
// Start is called before the first frame update
void Start()
{

}

// Update is called once per frame
void Update()
{
    
}
 void OnCollisionEnter2D(Collision2D collision)
{
    print ("boom");
    // Check if the colliding object has the specified tag
    if (collision.gameObject.CompareTag(tar))
    {
        // Destroy the colliding object
        Destroy(collision.gameObject);

        // Destroy the object that holds this script
        Destroy(gameObject);
    }
}

}

quick kelp
eternal falconBOT
unborn gale
#

i dont think so

unborn gale
ivory bobcat
#

Second, for a collision to have occurred both objects must have colliders and one must have a rigid body

ivory bobcat
subtle canyon
#

@unborn gale It would be easier to read your code which would help you and us so why not?

unborn gale
unborn gale
eternal falconBOT
ivory bobcat
unborn gale
#
public class bulletDistroy : MonoBehaviour
{
    public string tar;
    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {

    }
     void OnCollisionEnter2D(Collision2D collision)
    {
        print ("boom");
        // Check if the colliding object has the specified tag
        if (collision.gameObject.CompareTag(tar))
        {
            // Destroy the colliding object
            Destroy(collision.gameObject);

            // Destroy the object that holds this script
            Destroy(gameObject);
        }
    }
}
cosmic dagger
unborn gale
#

yay

subtle canyon
#

you just assigned it to a string

unborn gale
cosmic dagger
ivory bobcat
#

Does it print anything?

subtle canyon
unborn gale
uncut holly
#

before anyone ask why isnt my vscode configured i already given up on that long time ago. the question now is that i not sure if theres a syntax error since the error shown in the unity is the type or namespace names LogicScript could not be found. what is LogicScript in unity mean

cosmic dagger
subtle canyon
unborn gale
subtle canyon
cosmic dagger
ivory bobcat