#💻┃code-beginner

1 messages · Page 284 of 1

silver girder
#

this is a play sound script
It Doesnt work when the handball falls
doesnt play sound on collision

rare basin
#

to see what exactly is failing and why

fossil gulch
#

so I wanted to check whether there was a grid point in the direction that the player tries to move, but I've been unable to figure out how to do so

silver girder
rare basin
#

do you know what's google?

#

you can look it up "debugging in unity"

silver girder
rare basin
#

then read about it

polar acorn
# silver girder i dont understand what is debugging

Debug Log should literally have been the first line of code you ever wrote. If you don't know what that is, then you're progressing too fast and you should fall back to the basics, like the ones pinned here or on !learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

tidal kiln
#

i think the issue might be with CanMove / FindClosestTarget

fossil gulch
#

just got it working

merry spade
#

Hi @tidal kiln its me again with the tetris problem. I used the fix u suggested and It works perfectly thank you again!

tidal kiln
#

oh what was it

fossil gulch
#

well I was snapping the player back to the last grid point if they tried to move off of the grid

#

and it was doing that infinitely

fossil gulch
#

so I added a check

tidal kiln
#

yea thats what i thought it was

fossil gulch
#

lemme show you rq

#

this also means I can save on colliders as all I have to pay attention to is the grid points

tidal kiln
#

nice looks great

fossil gulch
#

now I can stop caring about all that and just go to a basic test map 😂

#

for enemies, etc

tidal kiln
#

lets gooo

fossil gulch
#

also thinking of adding mod support, done it in past projects and I think it'd be fun. Thanks a lot for your help!

tidal kiln
#

no problem

fossil gulch
#

@timber tide (Sorry for ping but also just wanted to thank you for helping me out a few hours ago)

tidal kiln
#

btw i dont see the player stopping but i think might be an issue with resettingn the animator

fossil gulch
tidal kiln
#

this

fossil gulch
#

oh, that's happening because a targetPosition is set upon making input, which is reached using the transform.position = Vector3.MoveTowards(transform.position, targetPos, baseMoveSpeed * Time.deltaTime); line in the MoveRoutine, and that makes it so the player stops

blissful spindle
#

Hi, I ran into a little confusing problem for me, the thing is, that I am instantiating an empty object(floating DMGnumber) which works pretty much perfectly, but when it instantiates it turns by 180 degrees and I have no idea why can someone pls help me?

if something isnt clear juts ask me and I will provide everything you need 🙂

fossil gulch
#

also why I wanted to stop the MoveRoutine from finishing in the first place, or wanted to alter the targetPos to 2 points ahead if the button was being held down, but I was unable to do that

#

if that makes sense

tidal kiln
#

did you fix it

fossil gulch
#

I did not

#

but your script found a work around

#

I'll revisit the issue if it pisses me off in the future but this is fine

timber tide
blissful spindle
timber tide
#

shouldnt be instantiating a new canvas per text either

#

one canvas, instantiate the string onto that

blissful spindle
timber tide
#

it's more that canvas is actually pretty terrible for floating combat text but that's something you can probably look into later

#

but one canvas per text isn't a good solution for right now

blissful spindle
blissful spindle
timber tide
#

each canvas is an additional draw call for one

#

for performance comparisons, usually mobile games try to stick around 100 drawcalls

#

now for a single canvas solution, it does a full redraw everytime something moves on that canvas

blissful spindle
#

will it be hard to make it work with one canvas with how it works now (what I mean is: do I need to rewrite the whole code?)

timber tide
#

I'm just saying there's better solutions out there, but until you run into performance problems it's nothing to worry about.

#

but you'd see the implications quicker if you stick to a one canvas one text solution

wind raptor
#

I'm struggling to understand how sprites scale and how they correspond to scene coordinates. I have a png which is 225x225 pixels. I put it on a sprite renderer, and it is tiny in the scene. I know I can scale it up, but I'm just trying to wrap my head around how the units convert/relate to one another.

wintry quarry
#

That's what determines the size, along with the sprite resolution of course

#

so if you set PPU to 225, your 225x225 sprite will be 1x1

sleek orchid
#

Ey! I don't know if this is the proper place. However, any ideas of starter games just to get Unity's grasp. I've made a crappy version of Flappy Bird so far. I am mainly looking for 2D projects

wintry quarry
#

if PPU is 100, it will be 2.25 x 2.25

wind raptor
#

1 to 1

wintry quarry
#

no the conversion factor is the PPU setting

#

If you set that to 1, it will be 1 to 1

edgy needle
#

hello, so i have school work to do, im making game like jetpack joyride, i made almost everything but 2 things are killing me so bad, first being map generation, i understand how it works but even chat gpt cant help me, can someone help me write chunk map gen?

summer stump
edgy needle
summer stump
#

Chat gpt is a spam machine that doesn't understand anything and lies to you while providing garbage

Even 4

edgy needle
blissful spindle
summer stump
edgy needle
#

i cant fix it for month now, i coded coin spawn, score, everything, even animation stuff on ground n shi, but map gen is js trolling atp

edgy needle
summer stump
#

What specific methods did you try

polar acorn
#

Well, first off, you're going to need to decide what "map gen" even is. That's a vague term. What are you trying to do

cosmic quail
# edgy needle i cant fix it for month now, i coded coin spawn, score, everything, even animati...

did u find this by googling https://www.youtube.com/watch?app=desktop&v=ofZtyysHp1s maybe that has map gen in it

In this tutorial, I make a very simple version of Jetpack Joyride using Unity in half an hour.

Source code: https://github.com/wkwan/jetpack-joyride-tut

Features implemented:

  • Jetpack acceleration/gravity
  • Ceiling/floor
  • Zapper obstacles
▶ Play video
edgy needle
edgy needle
summer stump
edgy needle
#

i have bg 1, 2 and 3, and player is static, i first tried when x seconds passed, based on movement, remove bg1 and when is he on bg2, make next 2 random bgs in front, when time passes, remove bg2 and assign 2 random etcc

timber tide
cosmic quail
edgy needle
#

tried

#

already

timber tide
#

not using the canvas

#

3D -> text

edgy needle
#

my player is also static, like flappy bird does

blissful spindle
polar acorn
edgy needle
polar acorn
#

If you need to know "everything" then you're never going to reach it. Start thinking about what specific things you need to do, and do them one at a time

edgy needle
polar acorn
edgy needle
polar acorn
#

What, specifically, isn't working, and what is the code that led to that

ornate lynx
queen adder
#

how to stop my rigidbody character from sticking to walls when i move into them?

edgy needle
ivory bobcat
queen adder
#

nope

rich adder
queen adder
eternal falconBOT
blissful spindle
summer stump
rich adder
sleek orchid
queen adder
#

but I will still slip right?

rich adder
queen adder
#

new Vector2(x,y)

#

idk what that is called

rich adder
#

that answered neither

queen adder
#

wdym

blissful spindle
#

its better to sned the whole code as printscreen if you can

queen adder
#

player.velocity = new vector2

#

thats my script

rich adder
#

so velocity then

edgy needle
edgy needle
chilly moat
#

How does one play an audio clip with a random starting time? Setting audiosource.time to a random value between 0 and clip.length does not work, it throws an error 😦

blissful spindle
ivory bobcat
bitter carbon
#

for some reason this says game object with animator inactive even though i instantiate it the line before, could anyone help me please
Image

bitter carbon
rich adder
polar acorn
#

not the thing you just spawned

summer stump
queen adder
#

friction set to 0 does nothing, it slips if I walk on the object

bitter carbon
queen adder
#

why does my character even stick to the wall in the first place?

summer stump
rich adder
queen adder
#

I get it

rich adder
#

if you kept applying Velocity towards a wall why should it slide down

bitter carbon
queen adder
#

in other platformers you cant stick to walls and still walk on same surfaces fine

rich adder
#

the best solution is the one i mentioned imo

#

normally a Physics cast is done to check the direction of movement if its blocked or not

#

if its blocked you prevent movement in that direction

ivory bobcat
queen adder
#

yes I have raycast for isGrounded

#

have to figure out how to do the one for walls then

rich adder
#

..ok so the concept is similiar

#

instead of checking solid down, check in front of you / behind n whatever

queen adder
#

and if touching, x movementSpeed = 0?

rich adder
#

raycasts can be used as "Sensors"

queen adder
#

is that how it works in other games like supermario?

rich adder
#

probably not

#

there is never one way to do something

#

some games the walls aren't even colliders, they are just 1s and 0s on a grid

queen adder
#

I think I could make 2 box colliders for object and put different friction values on the top (floor) and its wall

#

what do you think about that?

bitter carbon
rich adder
#

just increase the players drag

polar acorn
bitter carbon
#

no but unity has one built in, doesnt it

queen adder
#

very weird there arent any tutorials on yt about it

bitter carbon
rich adder
polar acorn
willow scroll
willow scroll
# bitter carbon

This's Animator's property, so you access it via Animator.controller

polar acorn
blissful spindle
#

can someon help me to afjust this line of code to face this object away from my camer instead towards? transform.LookAt(Camera.main.transform, Vector2.up);

polar acorn
blissful spindle
# rich adder ~~`-`~~ nvm that 😅

I tried it like this -transform.LookAt(Camera.main.transform, Vector2.up); and like this transform.LookAt(-Camera.main.transform, Vector2.up); neither worked

fossil gulch
#

Does anyone know why the movement is so jittery?
https://gyazo.com/f3008793a9a9d010e9f8a4d1684089d9

using UnityEngine;

public class FreeMovement : MonoBehaviour
{
    public float speed = 5f; 
    public float rotationSpeed = 10f; 
    public Animator animator; 
    public string movementParam = "forward"; 

    Rigidbody rb; 

    void Start()
    {
        rb = GetComponent<Rigidbody>();
        rb.useGravity = false;
    }

    void FixedUpdate()
    {
        
        float horizontal = Input.GetAxisRaw("Horizontal");
        float vertical = Input.GetAxisRaw("Vertical");

        
        Vector3 direction = new Vector3(horizontal, 0f, vertical).normalized;

       
        rb.velocity = direction * speed;

        
        if (direction != Vector3.zero)
        {
            Quaternion targetRotation = Quaternion.LookRotation(direction);
            transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime * rotationSpeed);
        }

        
        animator.SetFloat(movementParam, direction.magnitude);
    }
}
rich adder
#

Ah yeah just realized its LookAt

#

ops

fossil gulch
#

the camera movement is very smooth but the player is jittering

rich adder
polar acorn
fossil gulch
blissful spindle
fossil gulch
#

the movement script is on the Child Player and the Parent player is just an empty gameobject

blissful spindle
bitter carbon
polar acorn
#

So why are you trying to set it to one

bitter carbon
#

im trying to set its value to it

rich adder
#

are you just guessing stuff?

#

don't

polar acorn
bitter carbon
#

like there is one called New Animatoe Controller

#

so i thought it would assign it

summer stump
bitter carbon
summer stump
rich adder
#

you just have to actually learn how to read the documentation

summer stump
tidal kiln
fossil gulch
#

nah it was the rigidbody not being set to interpolate and continuous

tidal kiln
#

oh nice

rich adder
fossil gulch
#

it is

#

is it not?

tidal kiln
#

you have it in fixedupdate

fossil gulch
#

oh lmao

#

I changed it

#

was already changed in my script so that's why I was confused

bitter carbon
#

can anyone telll me what does between these two

#

cant find it in the docs

eternal needle
rich adder
sleek orchid
#

Hello guys!
I have an issue, I am trying trying to do a BrickBreaker game, in which I want my player not be able to move if his next move would overlap the boundaries. I thought that doing a invisible box collider to check collision is a good idea, is there any other way to approach this problem?

bitter carbon
bitter carbon
rich adder
languid spire
bitter carbon
#

yea im missing it

#

idk what the type is]

rich adder
#

you look at the docs just like I did

bitter carbon
#

i did.. i dont get where it tells me'

rich adder
#

the type is literally on the screenshot

#

you're gonna have trouble if you don't learn the basics of c#

delicate venture
#

sorry to bring this up again but if anyone could help me out

bitter carbon
#

i tried that earilier

#

?? this what u mean

rich adder
bitter carbon
#

oh fuck me i spelt it wrong

#

yea i tried that at the start but i kept spelling it wrong

rich adder
#

what are you trying to do here anyway, what is the end goal?

bitter carbon
#

make a animation play

rich adder
#

why are you storing the controller then

#

just assign it directly to Animator in the inspector

#

you don't need a field for it

bitter carbon
#

i cant its a prefab

rich adder
#

yes you can , Animator Controller are just assets..

#

they can put on Prefabs just fine..

bitter carbon
#

idk my prefabs are all wierd

#

and have no area to add it

rich adder
#

thats just the Animation clip inside the Model(unity treats them as Prefab)

bitter carbon
#

so this isnt my prefab?

rich adder
#

this is the model

#

You need an Animator component on a GameObject that contains the model

#

you should really be following a tutorial or something..

#

takes 5 minutes

bitter carbon
rich adder
#

what does that have anything to do with animations

sleek orchid
#

How do I check collision on a Children Object?

rich adder
bitter carbon
#

what im trying to do is change the animation controller everytime the gameobjkect is added otherwise it is blank

#

and it wont work

sleek orchid
bitter carbon
#

idr understand any better ways to do this

sleek orchid
#

Something like this...

sleek orchid
rich adder
charred heart
bitter carbon
#

i have had so many problems cuz of this

sleek orchid
bitter carbon
#

that makes sence

rich adder
tidal kiln
rich adder
#

think they want to know which child was hit

tidal kiln
#

oh then yea send the message up manually

ashen hatch
#

Hello! I have a problem and I can't find an answer for it. I have a list of objects, right?

What I want to do is if list.count is bigger or equal 30, I want to remove all game objects from index 30 all the way to the end of the list, while also removing them from the list itself. So say I have list of count 45, I want to remove 15 objects from it.

timber tide
#

you sound like you got the idea, go for it

lost anvil
#

bump

ashen hatch
#

also I'm not sure if this is the right place to ask this question

tidal kiln
ashen hatch
polar acorn
#

that way you don't accidentally skip ones

ashen hatch
#

I have no clue how to do it and I've been at it for hours now

rich adder
#

funfact, if you type forr in IDE it gives you a reverse for loop

timber tide
#

the secret is to just forloop over the list and remove the 0 element by count

uneven locust
#

unironically

polar acorn
ashen hatch
#

loops always throw me for a... loop

#

its hard for me to understand them but I do know how to do foreach

rich adder
#

same thing

ashen hatch
#

later in code I do this

#
            {
                //we make sure each water has its own unique ID

                water._waterGUID = water.CreateWaterInstanceID();
                // then we force update for it to take effect and so each water actually spawns properly
                water.ForceUpdateWaterSettings();
            }```
rich adder
#

foreach wont work

#

esp removing list elements as you iterate

ashen hatch
#

are you able to help me by writing me an example? I know this is super lazy but this is how I've learned some programming. I apologise if it is, it's not my intention to seem like I'm unwilling but I really need some example.

#

For some reason I can't wrap my head around it.

rich adder
#

You already written it pretty much by words

ashen hatch
#

yeah but then how do I do it in the code? It's... idk

#

sorry XD

polar acorn
#

If the count is greater than 30, loop backwards from the end of the list back to 30. Destroy the element there, and removeAt that index

ashen hatch
#

that's what actually makes me confused

tidal kiln
#

its from end to start

polar acorn
rich adder
ashen hatch
#

so hold on:

for (int i = 30; i > 30; i++)
{

}

#

that?

rich adder
#

but backwards loop is what you need

ashen hatch
#

im sorry for being so annoying btw, not trying to be

tidal kiln
#

for (int i = list.Count - 1; i > 30; i--)
{ }

ashen hatch
#

so that's how you do it? :o

rich adder
#
 for (int i = myList.Count - 1; i > 30; i--)
 {
     Destroy( myList[i].gameObject);
     myList.RemoveAt(i);
 }```
ashen hatch
#

so plugging in my variables

#

one second!

#

(I appreciate btw, this is what I'm talking about, now I can see how its done and I can just do it in future myself)

#

I'll plug my variables

tidal kiln
#

ok but make sure you know why it works

#

it seems like youre missing some fundamentals

#

about c#

#

or coding in general

rich adder
#

well yeah you learn by making mistakes too

ashen hatch
#

I do, but its actually incredible that I was able to somewhat program a working character controller

rich adder
#

like trying regular for loop and seeing why removing that way isn't as good as backwards etc.

tidal kiln
#

yup i made that mistake before

ashen hatch
#

I just never had to actually use loops

#

but for example

tidal kiln
#

and i made it today again lol

rich adder
ashen hatch
#

this is piece of code I wrote for zooming in camera, its nothing special but it makes me happy:

    {
        //Debug.Log("Zooming in");
        lockStoredValues = true;
        currentLerpTime += Time.deltaTime;

        if (currentLerpTime > lerpTime)
        {
            currentLerpTime = lerpTime;
        }

        float perc = currentLerpTime / lerpTime;
        offset.x = (Mathf.Lerp(offset.x, maximum, perc));
        offset.y = (Mathf.Lerp(offset.y, maximum, perc));
        distanceTarget = (Mathf.Lerp(distanceTarget, maxDistance, perc));
        cam.fieldOfView = (Mathf.Lerp(cam.fieldOfView, 30f, perc));



        yield return new WaitForSeconds(1f);
        //Debug.Log("This is Done zoom In");
        currentLerpTime = 0f;
        canZoomOut = true;
        canZoomIn = false;
        yield break;
    }```
rich adder
#

anytime you got to do something more than 1 thing you need loops

ashen hatch
#

then at zoom out i do the reverse, except going back to stored values

ashen hatch
#

it is?

#

strange, because it actually works

#

it is supposed to move camera offsets to 0,0, bcs camera is slightly offset

rich adder
#

should be in a while loop currentLerpTime += Time.deltaTime;

#

example of proper Lerp

ashen hatch
#

oh while loop I know, I should look into it

#

(sry my code is a mess lol but im still happy to improve it)

tidal kiln
#

are you goingn for a smooth zoom?

ashen hatch
#

yes

tidal kiln
#

i dont understand how it works then

ashen hatch
#

it smoothly zooms in when ragdolled, then when character gets up, zooms back out

rich adder
#

cinemachine has that built in btw if you switch between 2 cameras

ashen hatch
#

nope, use singular camera

tidal kiln
#

theres no way that code you wrote is smooth zooming

ashen hatch
#

it does work, idk why

ivory bobcat
sleek orchid
#

At this moment I am trying to define some boundaries that if they collide my player can't move towards that direction. I am thinking that the only way to do this is by attaching one script to the GrandChild BoundLeft; another script to the GrandChild BoundRight then compare it in the PlayerMovement script. Is this the most optimal way?

tidal kiln
#

oh i dont think you should be starting a coroutine every frame

ashen hatch
#

only when certain conditions are met

#

it should be triggered

#

and then only once

tidal kiln
#

ok nevermind i dont get whats happening or how its working lol

ivory bobcat
#

You really should use a loop though to avoid having to maintain bools and checking when to start again

rich adder
ashen hatch
sleek orchid
#

Raycasts... Okay I will try to learn hem'
Thanks in advance ❤️

ashen hatch
#

I code or try to code in like 2-3 months?

tidal kiln
#

youre doing good so far keep up the learning 🙂

ashen hatch
#

I admit one thing, for character physics

#

I use PuppetMaster XD

#

its actually kinda fun to work with

ashen hatch
#

those are conditions

ashen hatch
twin granite
#

When i put my blender object in unity . In Hiearchy it look like packet not like cube.

#

Is it good

rich adder
flint heath
#

how would I go about modifying a specific tilemap tile at the point where the player is? something like what is below

public void Swing()
{
    if (Tilemap.GetTile(playerBody.transform.position))
    {

    }
}
ashen hatch
#

allow me to check, I kinda need to restart my PC due to Win 10 update -.-

twin granite
flint heath
#

what i posted above has an error message because what is inside the parentheses isn't a vector3 integer or something

rich adder
#

cache player pos as that

twin granite
#

Thank you

autumn tusk
#

im wondering

#

how do i concatinate multiple strings in a for loop

ashen hatch
# rich adder does it work?

Sir you and @tidal kiln are saviors. It works. So let me explain what I tried to do. I am learning to spawn instances. As a measure, I wanted to limit amount of water instances in my scene as optimisation to make sure it works smoothly.

#

I could use object pooling, I know

#

but I want to learn pooling later

wintry quarry
ashen hatch
#

as its much more difficult.

rich adder
#

honestly pooling is pretty easy

#

unity has its own thing now for it

#

built in

spiral narwhal
#

How would I go about doing a wheel selector? Like the weapon wheel in GTA or Red Dead?
I'm assuming I take the mouse position and divide it into N sections? Then checking which section the mouse is in? Or is there a better way?

tidal kiln
ashen hatch
#

Yes but if you have procedural generation based on prefabs and each prefab can be spawned x amount of times, then it kinda can break things

rich adder
# spiral narwhal How would I go about doing a wheel selector? Like the weapon wheel in GTA or Red...

In ths tutorial we make a radial menu. The principles really work for pretty much every type of menu, so you can extrapolate from this.

DoTween Pro
https://assetstore.unity.com/packages/tools/visual-scripting/dotween-pro-32416

Previous Tutorial
https://youtu.be/rVeS7oh3oug

(づ ̄ ³ ̄)づ ~(˘▾˘~)

TWITCH ( ͡° ͜ʖ ͡°)
https://www.twitch.tv/Pab...

▶ Play video
ashen hatch
#

I need to implement anti-intersection measure next

#

whats the best way to ensure rooms dont intersect?

rich adder
#

probably colliders and doing overlap checks

tidal kiln
timber tide
#

use an alg that doesnt intersect

ashen hatch
#

but only once, I don't want to run this forever

#

I already got it somewhat working

ashen hatch
ashen hatch
#

I will do it myself but I try to feel out the best way to do it

#

Collisions are expensive, I take

rich adder
#

thats how I did it a few times , had to resort to colliders because my doors are connected through opening

#

Physics overlaps are fairly cheap with non-alloc

#

also you only doing it when generating

ashen hatch
#

That's exactly what I want todo, connect rooms through aligned doors that snap to grid

rich adder
#

some algos i used expected same sized rooms / shapes so I had to resort to physics

#

as I often do

ashen hatch
#

I will not restort to room door sizes, so any differencies will be covered up by geometry

#

I think this would be solely because I want it to be as random as humanly possible.

rich adder
#

https://youtu.be/rfKcpp8UDQ0 this is what i watch a few years back when i did t

In this video I go over my approach to breaking down a large problem like procedural dungeon generation into an algorithm of smaller more simple steps. I follow the high-level steps outlined below to randomly create a top-down dungeon with various rooms, hallways and chambers. The tools I used to create this video are as follows.

  • Unity 3d
  • ...
▶ Play video
#

I did something similiar basically with colliders

sleek orchid
#

I've tried using Raycasts as Mr. Navarone told me. However, It doesn't seem to be working as intended. It is always printing out "False"

using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
    public int moveTiles = 2;

    [Range(0, 10)]
    [SerializeField] int maxRay = 2;
    
    public GameObject objectBoundaries;

    void Awake(){
        Debug.DrawLine(transform.position, new Vector2(-maxRay, 0));
    }
    void Update()
    {
        print(CanMoveRight());

        if((Input.GetKeyDown(KeyCode.D) || Input.GetKeyDown(KeyCode.RightArrow)) && CanMoveRight()){
            transform.Translate(new Vector2(moveTiles, 0));
        } else if((Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.LeftArrow)) && CanMoveLeft()){
            transform.Translate(new Vector2(-moveTiles, 0));
        }
    }
    bool CanMoveRight(){
        if(Physics2D.Raycast(transform.position, new Vector2(maxRay, 0))){
            return false;
        }
        return true;
    }

    bool CanMoveLeft(){
        if(Physics2D.Raycast(transform.position, new Vector2(-maxRay, 0))){
            return false;
        }
        return true;
    }
}
ashen hatch
flint heath
# rich adder use the `tilemap.WorldToCell` method first

dude i feel like a god right now i just used the unity documentation and wrote a bunch of random lines of code and it worked first try

    public void Swing()
    {
        GridLayout gridLayout = cropMap.GetComponent<GridLayout>();
        Vector3Int cellPos = gridLayout.WorldToCell(playerBody.transform.position);
        Debug.Log("Swung At" + cellPos);
    }
#

ty for help 🙏

autumn tusk
#

c# is being picky again

#

i have no idea what it wants me to do here

rich adder
autumn tusk
#

i tried putting in square brackets but i dont want to set an index

rich adder
#

use the static method

#

as it says

flint heath
rich adder
#

string.Join

autumn tusk
#

ah right

#

got it

rich adder
#

just incase you don't believe me 😛

#

you know why it works?

#

Tilemap is GridLayout :p

flint heath
sleek orchid
#

The Raycast was pointing ↖️ hehehehe

flint heath
#

How can I add a variable to each tile in a tilemap individually?

eternal needle
autumn tusk
#

im basically just making a wordle clone that generates a series of 5 random numbers

#

i only need one string for this

eternal needle
#

do you even need to concat individual numbers then? why not just 1 random 5 digit number

autumn tusk
#

actually yeah

#

was gonna say its a bikelock system but actually im not thinking straight

wintry quarry
autumn tusk
#

it would work near perfectly

#

alright that was easy

#

but yeah i should learn how string.join works

rich adder
flint heath
rich adder
#

you can make custom tiles

flint heath
#

I'm trying to make something so that when you click when you are on top of a tile, it decreases the value of a variable on that tile, and then the value of that variable is kept proportional to the darkness of that tile, so when you click repeatedly on top of a tile, it gets darker

rich adder
#
public class CoolTile : Tile {
public float MyFloat```
#

yeah use custom tiles

#

then when you GetTile

#

you can do cs var tile = tilemap.GetTile<CoolTile>(Tilepos); tile.MyFloat += 1;

#

or whatever

flint heath
#

there's going to be a lot of the tiles though... I don't think i'd be able to name each of them individually

rich adder
#

each tile is its own Instance of Tile

#

idk what you mean by naming

flint heath
rich adder
#

tilemap is a container for Tiles

flint heath
#

ah ok

#

ima take a break rahh

dusty silo
#

I have a list of custom objects that I am iterating through. Is there a way to better visualize how it's working? Could I use something like coroutines to show a visual "replay" of what happened?

wintry quarry
#

Is this a card game?

dusty silo
#

I'm trying to make a shape less concave

dusty silo
sleek orchid
#

ey ey! I am trying to learn TileMaps, while doing a Brick Breaker, any idea how to only destroy 1 tile when the ball hits it?

rich adder
#

why are you using tilemap for that though

dusty silo
#

Currently, I have three variables lead, follow and tail that run through the list and look at the triangle formed by the three. If it determines that the triangle is concave/vex it will then consider swapping either tail and follow or follow and lead. To stop it from creating self-intersections, I am running several checks to see if the hypothetical new configuration will intersect with any surrounding lines. However, my system does not seem to work at all. It will make swapping decisions that intersect through the entire shape while leaving obviously concave parts alone. Can I use co-routines to show me, on a human-visible delay what happened?

sleek orchid
rich adder
sleek orchid
#

oh..

#

sorry xdd

#

I thought it would be a good idea

#

It isnt?

rich adder
#

nah it will be cumbersome

#

if you want it for the Grid, you can use that with regular prefabs

#

interacting between worldObjects and TIlemap is a pain because of the different coordinate systems

sleek orchid
#

oooooh

#

That's was of great help.

#

So... we use tilemaps to build maps?

rich adder
#

yeah its better for static maps

sleek orchid
#

Cheers, you are cool s2

#

Imma go back to learning

rich adder
#

keeps the crisp pixel perfect

sleek orchid
rich adder
#

ohh..why you could still use those tiles lol just put them on the sprite renderer.
just make sure your Pixel Per Unit , matches original slices size

sleek orchid
#

Mr. Navarone?

Is having +100 Blocks a problem?

#

xdd

rich adder
#

ur fine lol

sleek orchid
carmine sierra
#

This is my current code for detecting colliders, right now it seems to only detect one collider at a time, I assume this is because it is triggered when a collider enters it, one at a time. But how could I detect multiple colliders at a time?

#

The long way would be to detect this script's gameobject's collider from the other collider's instead of this way round

#

BASICALLY: I want to detect multiple colliders at a time

eternal needle
tribal pendant
#

hey quick question, what is the difference between "Input.GetKeyDown(KeyCode.Mouse0)" and "Input.GetMouseButtonDown(0)"?

rich adder
tribal pendant
tribal pendant
rich adder
#

nope

carmine sierra
carmine sierra
#

that would definetly allow for multiple colliders at once to be detected?

#

I need both at the same time, or one, or either

#

if you get what i mean

eternal needle
carmine sierra
#

ohhh okay

#

thank you

#

so overlapcollider

eternal needle
#

yea it will fill an array you give it with the results

carmine sierra
#

how would I get these in an array?

#

just the bottom 3

#

I haven't used an array yet in unity

eternal needle
#

the physics functions will fill the array of whats currently overlapping. you dont fill it yourself

carmine sierra
#

oh okay

#

so i can return that array

#

and then compare it within an if statement

#

if (arrayname == [array]) something like this?

eternal needle
# carmine sierra I haven't used an array yet in unity

you should reallly do c# basics first if you havent used arrays. this all seems backwards because you are comparing to specific colliders. This will become a pain to do if you suddenly want to have another woodCollider, or 10 of them

polar acorn
carmine sierra
#

there will be many wood colliders as they will be instantiated multiple times

polar acorn
#

Why are you trying to compare arrays?

polar acorn
eternal needle
#

Yea so how are you gonna drag these in inspector for the user at runtime?

carmine sierra
#

basically I can only spawn wood in my game on the condition it is touching/not touching certain colliders

carmine sierra
#

each time they are spawned

#

by just appending them

#

everytime a new wood spawns in

#

if that sounds right I'll try it out

polar acorn
#

If you just need to check if the collider you've hit is wood, why not use tags

carmine sierra
#

and that array will be appended onto the colliders array

eternal needle
polar acorn
carmine sierra
carmine sierra
summer stump
carmine sierra
summer stump
thorn crater
#

I have a weird behaviour in my in my Editor right now, for some reason when i play, the objects in the scene are getting "refreshed" and it says: "This GameObject only exists at runtime", anyone else had this behaviour? If yes, is there a way to fix it?

carmine sierra
#

should i make a tag for every collider i want to check or separate them (not every collider will have the same effect)

eternal needle
polar acorn
carmine sierra
summer stump
#

You may want to consider checking if the object has a script though, if it is very complex. I think that was recommended above along with layers and tags

thorn crater
#

Well lets say i selected a gameobject inside the hierarchy, and while its selected i press play. Then suddenly my inspector is empty and there is only a text saying:
"This GameObject only exists at runtime"
And when i select this Object again, my Editor UI is gone, as i build the whole ui inside the editor and for some reason the object gets reinstantiated i believe

carmine sierra
summer stump
polar acorn
carmine sierra
#

sorry I understand what tags are now but I don't understand how this will allow for multiple colliders to be detected at the same time

summer stump
#

Is that the case you are using it for?

polar acorn
summer stump
#

It is non-trivial to detect specific colliders on the same object unless they are different types (like you could check if it is a sphere or capsule).

carmine sierra
carmine sierra
summer stump
#

Check each collision for the tag

carmine sierra
polar acorn
# thorn crater

This is something with a custom inspector. That inspector appears to be broken. Is this your own custom inspector script?

carmine sierra
# carmine sierra

in the case I used && here (which doesnt work as one collider is detected at a time), I intend for both colliders to be detected at once

lost anvil
#

bump

polar acorn
carmine sierra
#

when I use or (which works) I want either collider to have the same effect when entering the gameobjects collider

thorn crater
slender nymph
carmine sierra
polar acorn
carmine sierra
#

fair

summer stump
thorn crater
polar acorn
thorn crater
polar acorn
queen adder
#

Hey guys, I'm currently learning C# on CodeCademy and i have a small question ig, what's the difference between C# for websites and GameDev (Unity)?.

iron mango
#

hey, is there a way to use an interface but not do

public int Team
    {
        get { return team; }
        set { team = value; }
    }

for every single value? i have a huge code block because i did that for like 20 variables
or is that normal xD

polar acorn
polar acorn
iron mango
polar acorn
iron mango
#

thought i have to use a different one

polar acorn
#

You can use an auto-property if all you're doing is getting and setting it

queen adder
iron mango
#

ah

#

it's not visible anymore

iron mango
#

or i can't see them in the inspector

rich adder
#

it expects a field

iron mango
#

yeah i want to edit it in the inspector

iron mango
rich adder
iron mango
rich adder
#

cause you made it public get / set

#

just make it a field

iron mango
#

huh?

#

i mean i have multiple spaceship scripts but they have to have the same values, also for mod support,

#

idk ._.

rich adder
#

what does that have anything to do with a field vs property

iron mango
#

idk

#

what u mean xd

rich adder
#

you seem confused what they even are lol

iron mango
#

idk don't question my brain

#

but everything works, multiplayer and mod support, so i am not dumb i guess

rich adder
#

you made multiplayer but don't know difference between fields and props UnityChanThink

summer stump
#

public int thing; <-- not property

public int thing { get; set; } <-- property

iron mango
#

yes, i mean i use an interface, so i can use the values from there

#

that's why

#

-> the unity docs told me to so don't hate me pls

rich adder
#

yes interfaces cannot have fields

iron mango
#

xd

#

a do word i think

#

XD

iron mango
rich adder
iron mango
#

man

summer stump
summer stump
iron mango
# iron mango ok.

just looks weird because i want all scripts with that interface to access all values (like 20 or more) and that's what i use for mods, a custom ship just has to use that interface but can have it's own script

summer stump
#

Then put [field: SerializeField] above it

iron mango
iron mango
carmine sierra
#

what is contactfilter2d?

#

i need it as a parameter for overlap

carmine sierra
#

yh i tried reading that

#

what is filtering?

summer stump
#

It's exactly the same in and out of unity

carmine sierra
#

no in terms of unity

summer stump
#

It rejects some results, FILTERING what it returns

carmine sierra
#

so a contact filter would mean what do I want to detect overlaps for?

summer stump
#

Yes, i get what you mean now. That is correct

carmine sierra
#

the overlap functions want a second parameter of 'Colliders2D[] results'

#

what does this mean?

summer stump
carmine sierra
#

ohhh okay

#

Collider2D overlapingColliders = collider.Overlap(ContactFilter2D.NoFilter, collider, )

#

so instead of this

#

I can put 'overlapingColliders' as the second parameter

#

Sorry, not 'instead', as that is wrong

#

but yeah

summer stump
#

Well no, because it needs to be an array, and overlapingColliders is a single collider

carmine sierra
#

so what is wrong about my conclusion

#

there is no data type for multiple colliders is there?

#

collider.Overlap(ContactFilter2D.NoFilter, overlappingColliders);
what is wrong with this?

summer stump
carmine sierra
#

contactfilter2d.nofilter is the error

summer stump
#

Wait... it just says Overlap... can you link the docs for the method you are trying to use?

#

I don't use 2d that much

summer stump
carmine sierra
#

i am trying to get any colliders which the gameobject's collider goes over

summer stump
#

What does the error say?

carmine sierra
#

and put their gameobjects into the overlappingcolliders array

#

Argument 1: cannot convert from 'method group' to 'ContactFilter2D'

summer stump
#

I haven't used it before, but try ContactFilter2D.NoFilter()

carmine sierra
#

doesnt work

rocky canyon
#

new ContactFilter2D().NoFilter()

summer stump
#

Dang, I am kinda lost.

#

Ohhhh, interesting

carmine sierra
#

collider.OverlapCollider(new ContactFilter2D().NoFilter(), overlappingColliders);
}

rocky canyon
#

very, the documentation has no examples

carmine sierra
#

doesnt work

summer stump
#

Ahh yes, I see it's a steuct

rocky canyon
#

i had to find examples on threads

summer stump
#

Probably not inside the method

#

But before it. Maybe in awake or start

rich adder
teal viper
summer stump
carmine sierra
#

now just contactfilter has an error

#

lemme chec kit

rocky canyon
summer stump
#

That was the old one at least

teal viper
carmine sierra
#

Non-invocable member 'ContactFilter2D' cannot be used like a method.

#

collider.OverlapCollider(ContactFilter2D().NoFilter(), overlappingColliders);

summer stump
polar acorn
#

Either new ContactFilter2D().NoFilter() or ContactFilter2D.NoFilter()

teal viper
carmine sierra
carmine sierra
polar acorn
#

instead of trying to do it all in one line

carmine sierra
#

damn why do they need all of this

carmine sierra
#

when you just dont want to use a filter

#

what data type is the contactfilter

rocky canyon
#

its a ContactFilter2D

#

what are the filter types?

carmine sierra
#

ContactFilter2D NoFilter = new ContactFilter2D.NoFilter();

#

doesnt work

summer stump
polar acorn
carmine sierra
#

collider.OverlapCollider(new ContactFilter2D().NoFilter, overlappingColliders);

#

if you mean like this, it doesnt work

#

ContactFilter2D NoFilter;

#

and that is nofilter

polar acorn
#

No, I mean create an empty one and store it in a variable

#

and pass that variable to the function

summer stump
rocky canyon
#

ContactFilter2D contactFilter = new ContactFilter2D();

carmine sierra
#

ohh ok

polar acorn
rocky canyon
#

lol

polar acorn
#

there's a difference between a shoebox with nothing in it and the cosmic nothingness of the void

carmine sierra
#

fair

#

no such thing as nothingness

#

acc lemme stick to coding

polar acorn
rocky canyon
#

void is nothingness

polar acorn
#

Which makes it not work for your purposes

carmine sierra
#

collider.OverlapCollider(contactFilter, overlappingColliders);

#

this should have worked right?

rocky canyon
#

TIL about contactfilter2d

carmine sierra
#

sorry whats TIL

rocky canyon
#

Today I Learned

carmine sierra
#

fair enough

rocky canyon
#

just waiting for the working result 🍿

carmine sierra
#

'Collider2D.OverlapCollider(ContactFilter2D, Collider2D[])' is obsolete: 'OverlapCollider has been renamed to Overlap (UnityUpgradable) -> Overlap(*)'

#

and unity is asking for script changing consent 👀

rich adder
#

nice

rocky canyon
carmine sierra
#

really?

rocky canyon
#

i think so.. collider contactfilter2d array

grim stream
#

is there a code event in the Animation class for when the animation is done playing. i know the timeline (cutscene) thing has one of those

carmine sierra
rocky canyon
#

u can put an animation event on the last frame

rocky canyon
carmine sierra
#

theres also a physics2d one, not sure which to use

rocky canyon
#

ohh, Im looking at Phsyics2D.OverlapCollider

carmine sierra
#

yeah but what is the appropriate use case? I have no idea

rich adder
#

what are u trying to do

rocky canyon
#

me neither UnityChanSorry

rich adder
#

Collider2D.OverlapCollider works fine

carmine sierra
rich adder
carmine sierra
#

collider.OverlapCollider(contactFilter, overlappingColliders);

rocky canyon
#

ahh, its the same way,, just two different syntax's

carmine sierra
#

ContactFilter2D contactFilter = new ContactFilter2D();

teal viper
#

Why not OnCollisionEnter then?

carmine sierra
#

but it is not appropriate for my use case

summer stump
rocky canyon
#

^ yea i wouldnt see why that wouldnt work

teal viper
carmine sierra
summer stump
rich adder
carmine sierra
#

cannot convert from 'method group' to 'ContactFilter2D'

summer stump
#

Ah, well, it was just a guess, sorry

carmine sierra
#

np

rocky canyon
carmine sierra
#

appreciate any help

teal viper
#

We went over it already

rocky canyon
#

NoFilter() ?

carmine sierra
# teal viper Why not?

I want to detect multiple colliders at a time, as otherwise the game's function doesn't work properly

teal viper
#

Can you explain why OnCollision/TriggerEnter is not good enough for you?

rocky canyon
#

hehe, im interested as well

carmine sierra
#

i don't just want to detect one collider at a time

teal viper
#

You just need to cache whatever you're colliding with

rocky canyon
#

wats the odds that multiple colliders will enter at the same frame? ^

carmine sierra
#

zero

teal viper
#

Even if they do, the function would be called for all of them afaik

rocky canyon
#

well it should still work for u like dlich mentioned

rich adder
#

OnCollisionEnter add to list of colliders
OnCollisionExit remove it from list

carmine sierra
rocky canyon
#

each one would call it

carmine sierra
rocky canyon
#

and add themselves to the list

carmine sierra
#

ohh and then compare to the list?

rich adder
#

thats if you want to store them, or just call your functions directly. i

carmine sierra
#

like if both colliders are in the list, then so and so

rocky canyon
#

if(!inList){AddToList()}

rocky canyon
#

each time one enter the collision -> add to list -> now that its in the list do logic to check stuff

carmine sierra
#

okay cool that sounds good

carmine sierra
#

What is wrong with this:
Collider2D[] overlappingColliders;
...
void OnTriggerEnter2D(Collider2D otherCollider)
{
if (!overlappingColliders.Contains(otherCollider))
{

    }
timber tide
#

it's missing debugging

carmine sierra
#

but overlappingcolliders is not valid

#

in the if statement

#

so not sure how to debugf

#

says there is no definition for contains

crude prawn
timber tide
#

arrays dont have contains I believe without linq

crude prawn
#

its probaly overlappingcolliders cuz you put a ! infront of it so its a bool or smthing

frosty hound
#

Arrays don't have a Contains function

carmine sierra
#

ohh okay

#

so how do you check if an item is in a list for an array

frosty hound
#

Iterate through it and check

timber tide
#

ye old fashion way

carmine sierra
#

inlist?

frosty hound
#

That would be a contains function

summer stump
undone harbor
#

what editor do yall use?

carmine sierra
carmine sierra
#

Collider2D[] overlappingColliders;

summer stump
#

Collider2D[] <- array
List<Collider2D> <- list

carmine sierra
#

oh okay

summer stump
faint osprey
#
    {
        if(other.GetType() == typeof(SphereCollider))
        {
            inMagnetRadius = true;
        }

        if (other.GetType() == typeof(MeshCollider))
        {
            Player.BroadcastMessage("CoinPickup");
            Destroy(gameObject);
        }
    }```

how come the first if statement is called but the 2nd one never is
#

thats my object

carmine sierra
undone harbor
rocky canyon
# undone harbor what editor do yall use?

Started with Visual Studio, I use Rider when it's Freebie Giveaway season, and recently Installed and swap between VSCode and Visual Studio.. Visual Studio is my favorite so far.. and the editor that got me thru my beginning unity learning

vale karma
#

is there a difference when using the name 'Game Manager' for a script compared to a different name? This one changes the script to a cog wheel, and it looks cool, i just dont wanna mess anything up

rocky canyon
#

it gives it an icon, that is all

#

you can use the name no problem

gaunt ice
#

You can customise the icon iirc

rocky canyon
#

thats what its meant for.. ^

vale karma
#

oh no way

#

your joking

rocky canyon
#

yesway

vale karma
#

i shouldnt have asked. im doing it now

rocky canyon
#

Other and go crazy

cosmic dagger
#

yep, you cna create custom icons for any of your scripts or assets . . .

vale karma
#

oh im gonna put phalises everywhere

rocky canyon
#

Rabbit-Hole Discovered!

vale karma
#

lollll, thanku for the tip guys. Unity is much more fun now

cosmic dagger
rocky canyon
#

same 🤣

vale karma
#

oh i was gonna put like an old timey script, and probably forget waht it really was

#

probably like a banana for a game object

rocky canyon
#

whats the inspiration from? or is that ur own custom icon set

cosmic dagger
#

i kept mine simple. CS is a regular script. ED is an editor script. SO is a ScriptableObject . . .

#

custom icon set . . .

rocky canyon
#

noice 👍

vale karma
#

That helps alot

cosmic dagger
#

different colors to easily see which is what. i added types to see if it was too much or not . . .

#

E for enum, T for generic, I for interface, {} for class. Folder is an actual folder icon, but that can be confused for an actual folder to click on . . .

vale karma
#

😮 omg what happensss

#

IT BECOMES A FOLDER?

#

BUT ITS A SCRIPTTT
ohh what does it meaaannn

silent valley
#

This warning has gotten me a bit confused. I remember having this exact warning months ago and I never found a solution. Any help

tacit birch
#

I'm trying to set up a script so that my projectile does damage to an enemy.
For some reason though, it doesn't seem to be detecting collisions at all.
Both of the GameObjects have a Rigidbody 2D and a BoxCollider 2D.
Can anyone help me figure out what's wrong with this? D: It's actually driving me crazy

#

Enemy:

#

Projectile:

#

I also added this bit of code for the Projectile:

private void OnTriggerEnter2D(Collider2D collision)
    {
        Debug.Log("Collision detected with: " + collision.gameObject.name);
    }
vale karma
#

having the object discrete would probably cause issues

#

interpolate and collision detection should most likely be changed

tacit birch
#

For Interpolate, should I use Interpolate or Extrapolate?

vale karma
#

using UnityEngine;

public class GameManager : MonoBehaviour
{
    [SerializeField] private GameObject[] cards;
    [SerializeField] private GameObject gridLayoutEmpty;


    private void Start()
    {
        for (int i = 0; i < cards.Length; i++)
        {
            Instantiate(cards[i], gridLayoutEmpty.transform);
        }
    }

    public void FlipCard()
    {
        // Based on which card/button clicked, change sprite to that index #.
    }
}

im wondering if i could somehow store an index number along with each button, and pick it out once i click on one of the buttons

eternal falconBOT
vale karma
#

woopsie

cosmic dagger
vale karma
#

i feel like ``` cs
int index = #;

in a for loop would just recreate the same variable... i know there has to be something better than making a bazillion buttons
tacit birch
#

Hmmm I changed both of the objects to have Interpolate/Extrapolate as well as set the Collision Detection to Continuous. It doesn't seem to detect anything still

vale karma
#

post some some of the relevant code

cosmic dagger
tacit birch
gaunt ice
#

Use lambda expression to capture the index

tacit birch
#

because for the projectile, I wasn't able to get it to move either lmfao

vale karma
#

lambda? i heard the term before , ill give it a search

gaunt ice
#

You probably have used it ()=>{}

vale karma
#

i see how its written yea, but ive never used it. It seems simpel enough, but i still dont see how it pulls specific indexes out the hat

gaunt ice
#

Or making a struct/class (you can use monobehavior) associate with the button and store the index, when onclick, inform the game manager its index

cosmic dagger
gaunt ice
#

Int index=i
Onclick.addlistener(()=>{gamemanager.somemethod(index);});
You must assign i to local variable

tacit birch
vale karma
summer stump
cosmic dagger
gaunt ice
vale karma
#

haha thats perfect thanku

silent valley
summer stump
silent valley
#

yes

#

one sec

#

sent wrong one

vale karma
silent valley
summer stump
# silent valley

Can you not crop that please. Is that actually a state?

Sorry, missed the icon, that is a state

Is the state in the animator though?
You should probably just be asking in #🏃┃animation honestly

gaunt ice
#

It is a method of button.onclick (unity event)

vale karma
#

got eeet, im gonna watch a few videos to get the meaning of it. No point in asking all them questions

carmine sierra
#

anyone know what's wrong with this

polar acorn
carmine sierra
#

so it looks right?

polar acorn
#

What is the problem

carmine sierra
#

your right mb

#

forgot to mention one sec

cosmic dagger
carmine sierra
#

Object reference not set to an instance of an object
ColliderChecker.OnTriggerEnter2D (UnityEngine.Collider2D otherCollider) (at Assets/ColliderChecker.cs:30)

carmine sierra
#

Line 30 is the if statement

cosmic dagger
#

we have no line numbers. post the actual error message . . .

cosmic dagger
polar acorn
carmine sierra
#

but fair enough

carmine sierra
polar acorn
cosmic dagger
carmine sierra
#

but yeah i thought the list had to be made first

cosmic dagger
eternal falconBOT
polar acorn
tacit birch
vale karma
#

bro learning a new concept is so draining.. I wanted one lil mechanism and now i see the new terms 'delegates, action, func, and like 8 different ways to write a lambda

carmine sierra
#

do box colliders need to be on the same layer or z position to interact (unity 2d)

cosmic dagger
carmine sierra
#

the line renderer spawns only at negative z for some reason

teal viper
tacit birch
#

sure

teal viper
#

Can you enable gizmos so that we see the colliders?

carmine sierra
#

how can I check in an if statement if one list contains any items in another list

cosmic dagger
teal viper
#

Okay. Can you print something in OnCollisionEnter2d instead and see if it prints?

carmine sierra
tacit birch
# teal viper Okay. Can you print something in OnCollisionEnter2d instead and see if it prints...

Tried, nothing printed

Code:

    private void OnCollisionEnter2D(Collision2D collision)
    {
        Debug.Log("Collision detected with: " + collision.gameObject.name);
        if (collision.gameObject.CompareTag("Enemy"))
        {
            EnemyManager enemyManager = collision.gameObject.GetComponent<EnemyManager>();
            if (enemyManager != null)
            {
                // Calculate damage and critical hit status using PlayerManager methods
                int calculatedDamage = (int)playerManager.Damage();
                bool isCriticalHit = (bool)playerManager.Critical();

                // Call the TakeDamage method on the enemyManager
                enemyManager.TakeDamage(playerManager, calculatedDamage, isCriticalHit); // Adjust parameters as needed
            }

            // Destroy the projectile after damaging the enemy
            Destroy(gameObject);
        }
    }
polar acorn
tacit birch
#

yeah that's what i'm trying to figure out

polar acorn
#

The Three Commandments of OnCollisionEnter2D:

  1. Thou Shalt have a 2D Collider on each object
  2. Thou Shalt not tick isTrigger on either
  3. Thou Shalt have a 2D Rigidbody on at least one of them
tacit birch
polar acorn
tacit birch
#

Projectile:

#

Enemy:

teal viper
cosmic dagger
tacit birch
#

no, it's parented onto a different Canvas

cosmic dagger
#

wait, they're on a Canvas?

tacit birch
teal viper
polar acorn
teal viper
#

Is it a UI canvas component?

cosmic dagger
#

colliders are for actual GameObjects, not UI . . .

carmine sierra
tacit birch
#

I took it off of the Canvas and it still doesn't work

cosmic dagger
carmine sierra
#

alr thanks

teal viper