#πŸ–ΌοΈβ”ƒ2d-tools

1 messages Β· Page 28 of 1

distant pecan
#

but you should get at least the 2 on the console

fleet lily
#

what thing?

distant pecan
#

instead of

Debug.Log("2");
Destroy(gameObject);
levelManager.instance.Respawn();

should be

Debug.Log("2");
levelManager.instance.Respawn();
Destroy(gameObject);

or the respawn function wont be called, as the object will get destroyed before that happens

fleet lily
#

i have that now and same thing

distant pecan
#

send a print of all the enemy components

fleet lily
#

wdum

#

debug.prnint?

distant pecan
#

a screenshot of the enemy components/tag/layer info

#

just like the screenshot of the bullet

#

.

fleet lily
distant pecan
#

check if the enemy or the bullet have a rigidbody, and also make sure the collider is a collider2d instead of 3d

fleet lily
#

oh

#

the bullet has none

#

nvm

#

it does

#

they all do

distant pecan
#

send a screenshot of the collider component on both enemy/bullet

fleet lily
#

the bullet has no colider

#

i think if i do that its fixed

distant pecan
#

without collider it's collision cant be detected

fleet lily
#

im sry .-.

distant pecan
#

check if that fixes the problem, if not something else is wrong

rigid juniper
#

I’ll look into that thank you

fleet lily
fleet lily
#

can some one heelp me ^

#

.-.

crystal flax
#

S D goes the same direction with W D and W A goes the same direction with W S

#

wait I think I figured it out..

#

Yep, as always. When I ask for help I figure it out

polar pagoda
#

Is there a way to make specific frame(s) of an animation interact-able?

worldly patrol
#

what do you mean

polar pagoda
#

So for example I want to be able to interact with a game object, but only on the last couple frames of its animation.

#

I suppose another way of putting it is that I want only those last few 2D sprites to respond to a key press.

worldly patrol
#

if you are animating through the animator class you might need to lookup AnimationEvent

polar pagoda
#

I am, and I will try that. Thank you πŸ™‚

mossy coyote
#

I'm sure this gets asked a lot, but I can't seem to fix it. How do I get rid of these seams? I turned of antialising in the project, but it still happens to some tiles. I don't see these seams in Scene View, just when in Game View

livid pilot
#

Hi, I have a problem, I am doing a project to practice and improve in unity 2D and I am having a problem which I have been trying to identify for a long time and I cannot find it. When I am shooting the bullet which has a collisionador2d and a rigidbody2d and collides with a "Wall" the bullet is destroyed as I have assigned in the code but in certain parts of that wall the bullet penetrates, the problem is that the wall is single object and single collider, try adding the rigidbody2d of the bullet that does not sleep and the collision detection in "Continuous" but the problem continues, could someone help me? Thank you very much in advance

#

UsingTraductor sorry

copper stump
#

@livid pilot surprised this is happening when you have the collision mode set to continuous, how fast is your bullet moving?

robust ivy
#

make sure the wall collider is thicker than the bullet moving speed, if bullet move by 1f each frame and wall is 0.8, one time outta 5 it will pass

copper stump
#

@robust ivy isn't this the point of continuous rigidbody detection?

#

to avoid this substep problem?

robust ivy
#

if i have an object at 1f x and move it to 3f x instantly i can guarantee the collider wont see it

#

or hes moving the bullet without physic?

copper stump
#

right.. but you're not just moving it, you're using the Unity physics engine to move it?

copper stump
#

isn't the point of continuous collision detection to avoid objects passing through other objects which are smaller than the velocity vector

#

@livid pilot you could also raycast ahead of the bullet by the velocity

robust ivy
#

how are you moving the bullet

livid pilot
#

yeah i use rigidbody2d and collision

copper stump
#

and you're listening to a banger

livid pilot
#

That's what I'm doing

#

wait sorry

#

I uploaded the wrong video

#

1 sec please

robust ivy
#

well we understand the problem

#

but how are you moving the bullet in code?

livid pilot
#

velocity

copper stump
#

setting velocity directly?

livid pilot
#

Using rigidbody2d

copper stump
#

i.e r2d.velocity = ...

#

?

livid pilot
#

_direction = Camera.main.ScreenToWorldPoint(Input.mousePosition) - wPivotReference.position;
_rigidbody.velocity = _direction.normalized * ammoSpeed;

lament spire
copper stump
#

ahhhhhh

#

you're destroying the bullet via a raycast, not by collision

livid pilot
#

yep

copper stump
#

well step 1 with that code, instead of 0.5f in the raycast

livid pilot
#

Shouldn't I do that?

copper stump
#

it's ok to do but you're raycasting 0.5 units every time

#

even if the bullet is travelling much more than that each frame

#

so step 1 I would use rigidbody.velocity.magnitude instead of 0.5f

#

maybe clamped to a minimum of 0.5f if you want

#

so Mathf.Clamp(rigidbody.velocity.magnitude, 0.5, float.MaxValue)

#

something like that

lament spire
#

the built-in collision system might be more practical, up to you

copper stump
#

but that's not necessarily the root of the problem

#

yeah

#

I'd probably just go with the collision callbacks

#

OnCollisionEnter2D

#

but the fact your rigidbody2D is still going through the walls is weird to me

#

instead of setting the velocity @livid pilot try using add force, I have a feeling it won't make a difference but give it a go

livid pilot
#

Before I had a code using OnTriggerEnter2D but I couldn't find a way to make the damage be applied to a single enemy and not to all the enemies that collide with the bullet

copper stump
#

yeah use AddForce(Velocity, ForceMode2D.Impulse)

#

instead of velocity =

#

that should stop the bullet going through walls

#

if you're going to use OnTriggerEnter2D/Collision enter 2D and you want it to only affect 1 target then put that logic on the bullet, not the enemies

#

so the bullet sends damage to 1 enemy then deletes itself

#

instead of several enemies detecting the bullet and adding damage to themselves

robust ivy
#

should hit only once whoever have the ontrigger if it has a destroy in it

#

the first problem make the second

livid pilot
#

If I use addforce the bullet does not move

worldly patrol
#

hitinfo is a struct, you cant compare it with null

#

wait physics2d.raycast doesnt return a bool like the 3d ones?

livid pilot
#

yes

worldly patrol
#

remove the hitinfo != null

#

you only need hitInfo.Collider != null

#

probably

#

thats what unity documentation says

livid pilot
#

Yes, I added that because I was in a moment of despair

#

hahaha

worldly patrol
#

you cant do equality comparer with struct, only classes

livid pilot
#

Unity was giving me an error to find the instance or something like that

copper stump
#

uhhh

worldly patrol
#

its a struct

copper stump
#

I presume that the null reference was the hitinfo.collider

#

if it didn't hit anything

worldly patrol
#

yeah

copper stump
#

so just do if(hitInfo && hitInfo.Collider) I think

#

pretty sure if the first argument fails && won't evaluate the 2nd

worldly patrol
#

it doesnt extend Object, which is a class

#

so it cant use the implicit bool conversion

copper stump
#

oh weird wait you're right, ray2d isn't bool is it

livid pilot
worldly patrol
#

yeah it seems its only in 3d

copper stump
#

snap ofcourse

livid pilot
#

The problem continues

worldly patrol
#

doesnt matter i think

#

then it didnt hit anything

#

thats the logical explanation

robust ivy
#

did you try with addforce?

#

is there any other error in console?

livid pilot
#

I'm working with layers in case I forget to tell you

livid pilot
copper stump
#

yeah what's your error navarro, if(hit.collider != null) shouldn't be erroring

#

oh my b

#

so AddForce isn't making the bullet move? @livid pilot

worldly patrol
#

what is the error?

livid pilot
#

I try not to ask for help but this problem is breaking my head

worldly patrol
#

its okay to ask for help

copper stump
#

for sure, just trying to understand your problem

#

ok well debug the vector you're supplying, let's see what that is Debug.Log(_direction.normalized * ammoSpeed)

#

because the AddForce function definitely should be moving your rigidbody

livid pilot
#

ok 1sec

robust ivy
#

what is ammospeed

copper stump
#

check your rigidbody isn't kinematic, check it is being simulated, check ammospeed

worldly patrol
#

it cant throw a null reference error

livid pilot
worldly patrol
#

if you are doing a null comparison if

copper stump
#

shouldn't this be in your start code? or at the very least, comment out the velocity set in your start function

livid pilot
worldly patrol
#

so a collider has been found

#

Object? is that whats in the tag?

robust ivy
#

where does that debug come from

livid pilot
worldly patrol
#

sounds like its another debug log

copper stump
#

I told him to debug the velocity he was supplying the RB

#

cause it's not even moving right now

robust ivy
#

oh

livid pilot
livid pilot
worldly patrol
#

it doesnt make sense

livid pilot
robust ivy
#

addforce should definitly work

worldly patrol
#

it makes sense if the tag is "Object"

livid pilot
robust ivy
#

addforce should be in update also

livid pilot
worldly patrol
#

either the game objects Tag is "Object" or its another debug log

livid pilot
#

The code tells me well the names of the objects with which the ammunition collides

#

"Ground" "enemy"

robust ivy
#

your bullet is the actual collider

copper stump
#

that layermask is telling the raycast that it will ONLY raycast for objects on those layers

#

the way you have used it with your raycast

copper stump
#

ok cool

#

so your bullet is now moving with AddForce?

#

or is it staying still?

livid pilot
#

no

robust ivy
#

shouldnt it be a trigger collider

livid pilot
#

It does not move

copper stump
#

that shouldn't make a difference for AddForce, he doesn't even have an OnTrigger event in that code

livid pilot
#

The collider added it a while ago to test, maybe that's the problem, I forgot

copper stump
#

can you show me the rigidnody settings?

worldly patrol
#

where did you put the addforce

copper stump
#

your rigidbody can have a collider, that shouldn't be a problem

robust ivy
#

if ur bullet start on character its blocked? i think

livid pilot
#

The problem continues

livid pilot
copper stump
#

ok good

#

it should be in start

livid pilot
#

yep

copper stump
#

because you're using ForceMode2D.Impulse

worldly patrol
#

isnt it supposed to be in Update? or FixedUpdate

copper stump
#

no because he's using an impulse

#

it's a single fire modify to the velocity

#

which is perfect for a bullet

#

try turning up ammo speed

#

could you also show me your rigidbody settings?

worldly patrol
#

ah they assigned the addforce to the rigidbodys velocity?

livid pilot
copper stump
#

I mean, what he's saying works too - it could be an addforce in update, but then your bullet would be speeding up each frame

worldly patrol
#

assign a vector on rb.velocity

livid pilot
copper stump
#

@worldly patrol no, that's what he had before if you look higher up

#

we're trying to use addforce to solve another problem

livid pilot
robust ivy
#

all i know is if a collider is over another and you add force it wont move, its stuck in that collider

#

id check that

#

thats why i think it should be a trigger

livid pilot
copper stump
# robust ivy id check that

@livid pilot @robust ivy this is probably the problem, but setting your bullet to trigger will mean it doesn't collide with anything

livid pilot
#

And why rb.velocity work and rb.addforce not work?

copper stump
#

you're better to put your player on its own collision layer

#

of Player

worldly patrol
#

you sure the return statement code executed in the update before executing the method?

copper stump
#

and then disable the layer interaction with bullets

robust ivy
#

isnt he using a ray cast anyway to destroy it

copper stump
#

he is, but as somebody said further up - might be better to use the built on On Collision stuff

robust ivy
#

for sure

copper stump
#

but shit, if he's using a raycast, then why even use physics at all πŸ˜›

#

just raycast and move the object

#

from the player instead of the bullet even

robust ivy
#

the raycast is not necessary

#

and yeah id use ontriggercollision

copper stump
#

indeed

worldly patrol
#

you can use transform.Translate

#

but post your update method again here

copper stump
#

@livid pilot try what devil cut said though, at least it will tell us if that's the problem, set the collider to trigger

copper stump
#

right. but there are ways to do it.

robust ivy
#

first idea always the good one

#

;p

copper stump
#

I'm about to angrily code at quick demo at this rate

#

πŸ˜›

robust ivy
#

lol

worldly patrol
#

can you post your code again

livid pilot
#

That way it worked correctly

copper stump
#

this is giving me anxiety lmao

robust ivy
#

you have to go back to that way navarro

copper stump
#

what worked navarro?

robust ivy
#

the ontriggerenter

copper stump
#

ahhh

livid pilot
#

Only I did not find how to make the damage to an enemy alone

robust ivy
#

once you have that problem ask here

#

we will help

copper stump
#

not a problem. we can work that out

#

yeah

livid pilot
#

for that reason try using raycast

copper stump
#

that's a relatively simple problem by comparison

robust ivy
#

you are overcomplicating stuff with that raycast

#

prone to error

livid pilot
#

Great

#

I'll add everything as it was before

worldly patrol
#

so the bullet is moving now?

robust ivy
#

it will once its a triger

#

if he added a new entity with a collider that would just block the bullet from moving, creating more problem

#

bullet shouldnt be collider i think

#

since you want it to actually pass throught object (or get destroyed when it hit a certain collider on a certain layer)

copper stump
#

@livid pilot

worldly patrol
#

if the bullet is too fast it may pass through the enemy

livid pilot
#

ok im ready

copper stump
#

@robust ivy ranger actually has a point there

#

the original problem of the bullet passing through the enemies will happen if it's a trigger?

robust ivy
#

the continuous collision will be in effect

#

this time

copper stump
#

or does continuous collision detection account for that with triggers?

#

it does? damn, didn't know that

#

that's rad

robust ivy
#

well, using the good method

#

addforce

#

i dont know about velocity

#

should be the same imo but im not sure

worldly patrol
#

better use transform.translate

livid pilot
#

xd

copper stump
#

it is definitely not better to use transform.translate...??

worldly patrol
#

to give you the vector depending on bullets angle

copper stump
#

using transform.translate will mean he can't do any collision detection?

robust ivy
#

i dont think translate is physic

copper stump
#

and the bullet could just pass through the collider

worldly patrol
#

i meant to use that method on the rbs velocity

livid pilot
#

No, I'm using physics for the whole game, I don't think it's a good idea to use transform.translate xd

copper stump
#

Add Force is the method to use, it's the one unity wants you to use

#

and plays well with collision detection

robust ivy
#

yup

copper stump
#

setting the velocity directly can cause the problem he is having

worldly patrol
#

no i think i meant Transform Direction

#

let me check my game

livid pilot
#

add force no work for me

#

idk

worldly patrol
#

ah your bullet's angle doesnt rely on the player's angle right?

livid pilot
#

player and mouse

worldly patrol
#

i meant the player's angle

livid pilot
#

I do not understand the question

#

I am using a translator and it is difficult to understand sometimes

#

Right now everything works fine

worldly patrol
#

sounds like your bullet does not have an angle

#

for example its going upwards but its facing to the right

livid pilot
#

I just want the ammunition to hurt a single player and not everyone in their collision.

#

the ammo goes off with the angle of the gun

robust ivy
#

on the enemy script you need a on trigger collision that will destroy the bullet once hit

worldly patrol
#

so your gun is a gameobject or a component?

robust ivy
#

or maybe its on your bullet?

livid pilot
#

"Gun"

#

is a simply rectangle

worldly patrol
#

how do you set the guns angle towards the mouse

#

transform.LookAt ?

livid pilot
#

I get the position and then I convert it to angle

#

transform rotation

#

of pivot

worldly patrol
#

the velocity of your bullet should be = gun.transform.TransformDirection(Vector2.right * speed) or something

#

it returns the vector to the gun's right direction

#

so if your gun is looking upwards, the bullet will go up

#

and so on

livid pilot
#

I rotation the gun as I mentioned and then when I instantiate the bullet I assign it Quaternion.Identity, anyway that already works correctly

#

As mentioned above I was trying to use raycast because using OnTriggerEnter2d the ammunition hurts more than one enemy and I didn't want that

#

But the guys told me that it will be easier to use OnTriggerEnter2D and fix the ammo problem because using raycast caused confusing problems

livid pilot
robust ivy
#

bullet should be destroyed on first hit, it pass through enemies?

livid pilot
#

no

#

i use collision.SendMessageUpwards("AddDamage", 30f);

robust ivy
#

how is it hurting more than one enemy if its not passing throught it

#

so it send message to all enemy?

livid pilot
livid pilot
robust ivy
#

sendmessageupwards send a message to each parent gameobject in hierarchy from where that script run

livid pilot
#

Should send a message only to the player who crashed

livid pilot
robust ivy
#

show enemyia script

#

the adddaamge function

livid pilot
#

The problem that the ammunition collider calls all the OnTriggerEnter2d of the enemies that are inside and that is why I hurt more than one enemy

robust ivy
#

is that the global health of all enemies or its the health of any child ?

#

when _health reach 0 what happen

livid pilot
#

The enemy is deactivated

robust ivy
#

show that code

livid pilot
robust ivy
#

ok

#

gameObject is the Hordes ?

#

which is the parent of all the enemies

#

if its disabled all enmies are gone

livid pilot
#

hordes

robust ivy
#

you already Destroy in each child

#

you dont need that gameObject.SetActive(false)

livid pilot
robust ivy
#

and health should be on each enemy

#

not in hordes

livid pilot
#

I am deactivating them for optimization

robust ivy
#

but when you kill one

#

they all get desactivated

livid pilot
#

If I destroy them I have to re-instantiate them and that is not good

livid pilot
#

I will send you a video

robust ivy
#

when you kill an enemy, sendmessageupwards send a message to EnemyAI and enemyAI gameObject get desactivated (which deactivate all child too)

robust ivy
#

if enemyAI is on hordes (which is the top parent object) then all enemy are being desactivated

livid pilot
#

That doesn't happen

#

Only the enemy is deactivated

robust ivy
#

ok

#

but everything is working there?

livid pilot
#

now I send you a video of the problem

robust ivy
#

i dont understand why you say it hit multiple enemy

livid pilot
#

yes

robust ivy
#

ok

robust ivy
#

yeah

worldly patrol
#

bullet damages more than 1 enemy?

robust ivy
#

but they are pretty stacked on each otehr

#

lol

#

not sure what cause that

worldly patrol
#

thats probably because

#

Destroy does not destroy the object immediatly

#

it gets destroyed after all update methods of all classes finishes

#

you could try DestroyImmediate

robust ivy
#

yeah

#

that would probably work

worldly patrol
#

but unity strongly recommends

#

destroy

livid pilot
robust ivy
#

if unity doesnt recommend it its not the way then

#

hmm

livid pilot
robust ivy
#

so instead of using the whole collider

#

you hsould use a point

#

thats where the raycast come in play i guess

worldly patrol
#

you could make a variable

#

something like bool bulletalreadyhitanobject

livid pilot
robust ivy
#

dont use that

#

they say to only use in editor

livid pilot
robust ivy
#

so now that you have a working collision

#

just add the raycast on the bullet to point at 1 pixel only

livid pilot
#

For that reason I tried to use raycast but when using it I generated more problems

worldly patrol
#

you could not use trigger, you can just for each loop on all enemies

livid pilot
robust ivy
#

yeah but you changed alot of thing too in that same time, like the trigger

#

now that is working just add the raycast check

livid pilot
#

I don't understand how I should add that

worldly patrol
#

i always do it this way

robust ivy
#

same way you did

#

HitInfo

#

you really just had to change the collider to trigger i think at start

worldly patrol
#
foreach(var enemy in FindGameObjectsWithTag("Enemy"))
{
  if (enemy.TryGetComponent<BoxCollider2D>(out var enemybox))
  {
    if (box.bounds.Intersects(enemybox.bounds))
    {
      // hurt enemy code
      Destroy(gameObject);
      break;
     }
  }
}
#

thats how i always do it

robust ivy
#

it will result the same thing as he have now

#

the collider will hit both ennemies

#

since both interesect

worldly patrol
#

see the break

#

it breaks out of the for loop

#

so when it finds the first enemy that collided with the box

#

the for loop ends immediatly

robust ivy
#

is it always hitting the first dude next to you

#

or could it be the second

worldly patrol
#

what?

robust ivy
#

if it intersect more than 1 collider

#

you dont have any order which one it hit

#

it could be the one further which make no sense ot hit

#

cause there an enemy in front of you

worldly patrol
#

look at the if condition

#

if box bounds intersects enemybox bounds

#

so the method under this if will never get executed if its a far enemy

livid pilot
#

Did they mean that?

robust ivy
#

but in his case both enemies are within the bounds

#

thats why he hit both

#

does that work navarro

livid pilot
#

The only way to solve it is to get a list of all the enemies that are colliding with the ammunition at that moment and apply damage to only one of them but I think it would not work correctly

robust ivy
#

shouldnt

#

since you still hitting both trigger

#

raycast should be from the bullet

livid pilot
#

yeah no work

#

:/

copper stump
#

if you're hitting multiple in the trigger, can't you just use a control bool?

#

have it set to "damageDealt = false"

worldly patrol
#

or you can try the code i posted above, put that in the update

copper stump
#

set it to true when you damage a target

livid pilot
#

The only way it could work is as it had before but it generated many problems

still tendon
#

can someone gave me a code I can copy past it
Code about control
D - Move Right
A - Move Left

copper stump
#

there are many tutorials online for input, depends what you're using

still tendon
#

thx so much

copper stump
#

google is your friend with unity!

still tendon
#

@copper stump sorry

copper stump
#

@livid pilot you want the bullet to ONLY affect 1 enemy, yes?

livid pilot
#

I'm stuck, in both ways I have problems

#

yes

copper stump
#

@still tendon it's alright man, no problem asking questions

#

ok so your bullet has the trigger logic on it yes?

still tendon
#

About unity 2d how much ram do i need?

#

is 2 gb ram good?

robust ivy
#

yes

copper stump
#

that's a pretty broad question, depends on the type of game, how much 'stuff' is going to be on screen, but 2gb sounds like a fine amount of ram for a 2d application

still tendon
#

Is 2 gb ram good unity 3d

#

for unity 3d

robust ivy
#

wont be full hd vr game but yeah it can work

still tendon
#

One time i download unity but it downloded for me hundred of files

#

on my download file

robust ivy
#

2gb is the minimum to use unity editor i think

still tendon
#

why?

robust ivy
#

cause its big

#

;p

copper stump
#

@livid pilot does this work?

#
    {
        if(collision.gameObject.CompareTag("World"))
        {
            Destroy(gameObject);
        }
        if(collision.gameObject.CompareTag("Enemy"))
        {
            collision.SendMessageUpwards("AddDamage", 30f);
            Destroy(gameObject);
        }
    }```
still tendon
#

can someone gave me the link of the unity 3d reL website

#

so i dont get scamed

livid pilot
#

Yes but it hurts more than one enemy

copper stump
#

right okay

#

so

#

    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (!damageDealt)
        {
            damageDealt = true;
            if (collision.gameObject.CompareTag("World"))
            {
                Destroy(gameObject);
            }
            if (collision.gameObject.CompareTag("Enemy"))
            {
                collision.SendMessageUpwards("AddDamage", 30f);
                Destroy(gameObject);
            }
        }
    }```
#

how about that?

#

I mean

#

probably not

#

given the Destroy should be dealing with it

robust ivy
#

trigger are on each enemy

#

the bullet collider overlap both enemies

#

which kill em both

#

it should be araycast for a point from the bullet

copper stump
#

okay, the trigger script wants to be on your bullet surely?

worldly patrol
#

with the if condition it will kill only 1

copper stump
#

you want the bullet to send damage, not the players

livid pilot
#

YEP

#

Currently the bullet is sending damage, that way I identify what it is colliding with

copper stump
#

ok 2 second

robust ivy
#

raycast a point in the bullet script, not from the ontrigger

copper stump
#

why are we back to using raycasts D:

robust ivy
#

cause the collider of the bullet overlaps both enemies

worldly patrol
#

ah i see now

#

what if the furthest enemy in the box died

#

it wouldnt make sense

#

you could use distance

robust ivy
#

or raycast from center player to wherever it hit

livid pilot
#

Any enemy that enters the collision of the ammunition before being destroyed takes damage

worldly patrol
#

but something is bugging me

#

are u gonna call the raycast on the 2 triggers?

copper stump
#

    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.CompareTag("World"))
        {
            Destroy(gameObject);
        }
        if (collision.gameObject.CompareTag("Enemy"))
        {
            hitCollider = collision;
        }
    }

    private void Update()
    {
        if(hitCollider != null)
        {
            hitCollider.SendMessageUpwards("ApplyDamage", 30);
            Destroy(gameObject);
        }
    }```
#

does that work?

#

that shouldn't require a raycast and should only hit 1 enemy

#

@livid pilot

robust ivy
#

As soon as bullet hit something, a raycast from center of the player should be done to the bullet, check which is the first collider hit, and destroy that one

livid pilot
#

That will apply 1000 damage to the player

worldly patrol
#

Catch2 we are discussing it could kill the farthest player in the collider

#

cult has a point

livid pilot
copper stump
#

eugh, I was worried about that too

#

yeah alright

#

I mean, put the player on their own collision layer, put the enemy bullets on their own and put the local player bullets on their own, disable collisions between the player and the local bullets and just use "OnCollisionEnter2D" instead is the real fix

livid pilot
copper stump
#

it should only delay it by a frame

worldly patrol
#

well in that case my new code would be like

foreach(var enemy in FindGameObjectsWithTag("Enemy").OrderBy(go => go.transform.position.Distance(gameObject.transform.position)
{
  if (enemy.TryGetComponent<BoxCollider2D>(out var enemybox))
  {
    if (box.bounds.Intersects(enemybox.bounds))
    {
      // hurt enemy code
      Destroy(gameObject);
      break;
     }
  }
}
``` something like that
livid pilot
#

i have hit and hurt layer

copper stump
#

so you have a player and an enemy layer

#

what's hit and hurt?

worldly patrol
#

layers and not tags?

copper stump
#

and what's enemy2?

#

yeah layers

worldly patrol
#

but you are using CompareTag

copper stump
#

right but we're discussing collision layers

#

separately

#

@livid pilot what layer are your bullets on?

livid pilot
#

Enemy2 is an extra layer that makes enemies collide with each other so that they do not merge

livid pilot
copper stump
#

what layer are your bullets on?

livid pilot
#

and the enemy have a empyobject with a collision trigger

copper stump
#

and player is on player?

copper stump
#

then if you set the collider on the bullet to be NOT a trigger, you should be able to use AddForce without issues

#

because player does not collide with hit

livid pilot
#

hit only collide with ground

copper stump
#

right, so set the collider to not trigger

#

ahhh

livid pilot
#

ok

livid pilot
copper stump
#

can your bullets still shoot?

#

because you were having issues with that earlier

livid pilot
#

with add forces?

copper stump
#

yessir

worldly patrol
#

he posted videos, seems to be working

livid pilot
#

I'll try

#

no

copper stump
#

show me your entire bullet code

robust ivy
#

addforce should be in update

#

or well, fixedupdate ?

livid pilot
#

no work

copper stump
#

surely it's alright in start, the bullets have no gravity, and he was using AddForce.Impulse earlier

#

ForceMode2D.Impulse even

#

it's either colliding with something or the force is too weak, are you sure the wall colliders aren't overlapping the

#

bullets

worldly patrol
#

its not bad to set rigidbody.velocity = gun.transform.TransformDirection(Vector2.right * speed); is it?

copper stump
#

well yes because you're hard setting the velocity

livid pilot
#

same

copper stump
#

where addforce does collision detection and sets the velocity to 0 if you collide with something

#

if you're setting the velocity manually, you end up with the problem he had earlier where the bullet just skips over colliders

livid pilot
copper stump
#

yes your bullets collider with the "Ground" layer

#

are you sure there's no ground collider they're spawning inside

#

and anyway @worldly patrol addforce should work if just setting the velocity works

livid pilot
#

I'll disable that to be sure, ok?

copper stump
#

so he may as well figure out why this is happening

#

yeah good idea @livid pilot try to isolate exactly the problem

livid pilot
#

i disable hurt and ground

#

The problem continues

copper stump
#

okay, can you show me your rigidbody settings and collider settings?

livid pilot
#

Even try adding a value manually

copper stump
#

instead of direction.normalized too, try just Vector2.Up * 1000

#

just a hard coded value

worldly patrol
#

by your logic addforce should be added in update or fixedupdate right?

copper stump
#

it shouldn't matter..

#

add a single force on start should still move the object surely?

worldly patrol
#

but wouldnt it go through walls which is the issue right now?

livid pilot
#

I think I know what the problem is
I think I know what the problem is

copper stump
#

no the issue right now is that the bullet doesn't move at all

#

and no it wouldn't mean that

#

@livid pilot the way you're determining the direction is Vector 3 too

livid pilot
#

kinematic is the problem i think

copper stump
#

YES

#

disable kinematic definitely

livid pilot
#

the fucking addforce work only dinamic

copper stump
#

yes

opal socket
#

Kinematic means "I am affected by physics, but something else is controlling me"

livid pilot
#

ok work

copper stump
#

RIGHT

#

good

#

we have a moving bullet

#

NOW

robust ivy
#

lmao

opal socket
#

use AddForce instead

#

You can set ForceMode to continuous iirc

livid pilot
#

Maybe we can try raycast again

worldly patrol
#

raycast in the trigger method?

worldly patrol
#

you probably need to use the one where it has the raycasthit2d array as a parameter

robust ivy
#

or make the bullet collider very tiny

worldly patrol
#

and iterate in the array and pick the closest enemy

livid pilot
#

With raycast it is the only way to damage a single enemy

copper stump
#
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if(collision.collider.CompareTag("World"))
        {
            Destroy(gameObject);
        }
        else if(collision.collider.CompareTag("World"))
        {
            collision.collider.SendMessageUpwards("AddDamage", 30f);
            Destroy(gameObject);
        }
    }```
#

@livid pilot

worldly patrol
#

yes but it wouldnt make sense if the furthest enemy in the collider died

livid pilot
#

ok i try it

copper stump
#

but yes, navarro, using a raycast from the player is a good way to do it

worldly patrol
#

@opal socket in 2d games i dont even use rigidbody

#

i make my own class

copper stump
#

@worldly patrol they very much do?

#

Rigidbody2D

#

there's an entire 2d physics engine my guy

#

oh

worldly patrol
#

does not fit with my games

copper stump
#

I miss read

#

fair enough

livid pilot
#

It does not work

#

Does not collide

worldly patrol
#

did you disable the trigger?

copper stump
#

^

livid pilot
#

Oh ok

#

I forgot to activate the layers

#

this is leaving me without a brain

opal socket
worldly patrol
#

does not fit with my games

opal socket
#

You'll end up using physics anyways

#

Fairs

worldly patrol
#

i make my own physics

opal socket
#

Fairs x2

copper stump
#

I guess non deterministic physics can be an issue

#

but they're pretty poo for characters too

livid pilot
#

The ammunition is destroyed with the world but it does not detect the player, I am finding out why

coral nest
#

its cause the ammunition can't detect after its been destroyed ;D

green veldt
livid pilot
#

I have to deactivate the trigger to the enemy's hurt collider

green veldt
livid pilot
#

Sorry to say the problem continues

coral nest
#

D:

#

you're taking me on a train ride here

coral nest
green veldt
#

wdym

#

its a issue with the function constructor, i just dont know what

coral nest
#

which line is it

#

when does it happen

#

is it above the constructor or below?

green veldt
#

it seems right....

#

is it bc of the tile[]

coral nest
#

if its above then the error might be above the constructor

#

i don't think the constructor actually has a issue

green veldt
#

hrmm

copper stump
#

might be a missing semi colon, some syntax error above that line likely @green veldt

livid pilot
#

I'm testing with the raycast and I don't know if it helps anything but if I activate the trigger in the ammunition, the ammunition pierces the ground as at the beginning

#

But if I deactivate it, it no longer does it

green veldt
#

this is all thats above

livid pilot
#

Could the ammo go too fast or the raycast be a problem?

copper stump
#

@green veldt are you sure that's the error line? You double clicked the error in unity?

green veldt
#

yes

copper stump
#

@livid pilot raycast just shoots a line between points/a point + direction and detects colliders

#

shouldn't care about the physics of that object, just the postion etc

worldly patrol
#

can one have 2 rigidbodies?

#

one a trigger and one isnt

coral nest
#

i've only had bad experiences

#

i think its possible though

copper stump
#

wouldn't you have 1 rigidbody and 2 colliders? why would you want two rigidbodies?

green veldt
#

Β―_(ツ)_/Β―

copper stump
#

@green veldt well there's no error in that code as far as I can see, I think we need more information, can you show more of the script you're using there?

green veldt
#

ye

worldly patrol
#

because 1 is for trigger, and 1 is for physics collisions

copper stump
#

syntactically that's all fine

green veldt
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Tilemaps;

public class Pathfinder : MonoBehaviour
{

    public Tilemap tilemap;
    public Tile wall;
    public Tile entry;
    public Tile exit;
    public Tile me;
    // Start is called before the first frame update
    void Start()
    { 
        
    }

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

    Tile[] getNextTiles(Vector3Int base) 
    {
        Tile[] toReturn = new Tile[8];
        /*
        ORDER
        0 - left
        1 - leftDOWN
        2 - leftUP

        3 - right
        4 - rightDOWN
        5 - rightUP

        6 - Down
        7 - UP
        */
        
        toReturn[0] = tilemap.GetTile(new Vector3Int(base.x-1, base.y, 0));

        return toReturn;
    }
}
``` here ya go
#

@copper stump

copper stump
#

@worldly patrol sure, but you flag colliders as triggers, not rigidbodies

coral nest
#

hey loook exit is red

#

could that be an issue?

#

doesn't hurt to change it

worldly patrol
#

its red in discord

#

i think

copper stump
#

@green veldt it's the word base

#

base is a reserved keyword

#

you can't use it as a parameter in that function name

green veldt
#

oooh

coral nest
#

base?

copper stump
#

yeah

#

needs to be something else

#

maybe

#

baseTile

coral nest
#

oh wow

copper stump
#

and needs changing in your get tile function too

coral nest
copper stump
#

yeah

coral nest
#

definitely a keyword

green veldt
#

thanks

copper stump
#

refers to the base class in inheritance

#

hence the funky error messages which don't make sense

green veldt
#

ah

copper stump
#

what text editor are you using?

#

visual studio?

green veldt
#

vs code

copper stump
green veldt
#

first time w/ unity

copper stump
#

keep an eye on your syntax highlighting

green veldt
#

ye, for some reason it didnt pick up

copper stump
#

keyworks will typically get a colour

#

ahh fairs haha

green veldt
#

lol ye

copper stump
#

@livid pilot I've been thinking and I think you're right about the raycast solution being more reliable

#

    private void Awake()
    {
        _direction = Camera.main.ScreenToWorldPoint(Input.mousePosition) - wPivotReference.position;
        bulletRigidBody2D = GetComponent<Rigidbody2D>();
        bulletRigidBody2D.AddForce();
        Destroy(gameObject, livingTime);
    }

    // Update is called once per frame
    void Update()
    {
        RaycastHit2D hitInfo = Physics2D.Raycast(transform.position, _direction, bulletRigidBody2D.velocity.magnitude, layer);

        if(hitInfo.collider)
        {
            if (hitInfo.collider.CompareTag("Ground"))
            {
                Destroy(gameObject);
            }
            if (hitInfo.collider.CompareTag("Enemy"))
            {
                hitInfo.collider.SendMessageUpwards("ApplyDamage", 30f);
                Destroy(gameObject);
            }
        }
    }```
#

this is how I would advise you implement it, if you wanted to

#
          bulletRigidBody2D.velocity.magnitude
#

here you can see I'm using the bulletRigidBody2D.velocity.magnitude

#

as the length for the raycast

#

so you're casting ahead of the bullet as far as it will move on the next frame

livid pilot
#

I think i fix it

copper stump
#

fair enough, only thing with the on collision solution is it CAN in rare circumstances apply damage to more than 1 enemy

#

but if that's not a problem for you then good job, got there in the end

livid pilot
#

In this way I solve it

copper stump
#

interesting

#

how are you getting the on trigger call?

#

do you have 2 colliders?

livid pilot
#

no

robust ivy
#

enemy is trigger

livid pilot
#

the ammo is not trigger

#

but the enemy is trigger

robust ivy
#

probably didnt want the enemy to collide

copper stump
#

ohhhh and you can call OnTriggerEnter from the "entering" object?

#

I did not know that

livid pilot
#

I did not know it either

robust ivy
#

what is the 0.5f

#

in the raycast

#

distance from the bullet?

livid pilot
#

no

#

Thank you so much to everyone who helped me, I was really exploding my head trying to figure it out

robust ivy
#

shoudlnt it be tiny number

livid pilot
#

From what I understand it is the distance where the raycast will go, at least that is what I think it is

copper stump
#

again, I would suggest doing the velocity IMO

robust ivy
#

its same thing

copper stump
#

I guess, given it's in on trigger it's not a problem

robust ivy
#

at least its better than bullet going trought floor

#

;p

copper stump
#

@livid pilot that look awesome man, damn.. more polished than anything I've ever made, feelsbadman

#

digging the flashing enemies

robust ivy
#

lmao

copper stump
#

how have you done the animation for that?

livid pilot
#

ahahahaha

#

hours and hours of animation

#

ahahsahah

#

Thank you very much for the help, I will go to sleep

robust ivy
#

cya

livid pilot
#

I guess this is the best programming practice one can do, blow your head

robust ivy
#

the sleep will put order in all this

#

;p

copper stump
#

you'll be dreaming in code tonight

livid pilot
#

Hahahahahaha

copper stump
#

seriously, it happens

green veldt
#

also one more question

#

how can i get the vector3int position from a Tile object

#

or Tilebase

green veldt
#

nvm

#

oop

green veldt
#

im pretty new to unity, can i have some help here

#

trying to make a simple pathfinding algo

#

its not elegant nor effiecent, just doesnt rly work

#

not very good behaviour

robust ivy
#

path finding is a deep subject not meant for beginner, either use NavMesh from unity or a solution already made or follow some tutorial on youtube

#

cant really explain how it work from a to z, its long

green veldt
#

well, im just trying the most simplest of methods, getting nearby tiles and going to whichever is closest

#

seems logical enough....

coral nest
#

use A*

#

It's not too complicated if you keep it simple

#

@green veldt

tropic inlet
#

Pathfinding can be simple

#

just scan around the object

#

above, to the upper right, to the right, bottom-right etc

#

u can make an array of the choices

#

pick the one that is most effective at decreasing the distance between u and the goal

green veldt
#

alright

#

i think its kinda what im doin

craggy kite
#

Is this the right place for UI script questions?

pale tide
#

Hey, I need some ideas to make this script better. Right now I have a script that shows the tiles that are within the camera but each time this method is run it clears the whole Tilemap. Removing this line makes it so it only renders what the camera sees but it does not remove it after the camera leaves. Using this line has huge performance impact. Instead of removing every tile and adding back the tiles within the camera view I should only remove the tiles that are outside the view and leave the rest. How would I achieve this?

leaden flame
#

@pale tide can't you set tilemap mode to chunk or something

pale tide
leaden flame
#

To save performance

#

Also what do you mean by

huge performance impact
Good or bad

pale tide
#

and that line into an void Update()

#

makes it go from 600 fps to 60 fps

leaden flame
robust ivy
#

what line are you talking about Jelles

#

and why do you clearAllTiles?

#

camera frustrum will get the tile that arent needed off

leaden flame
pale tide
robust ivy
#

yeah

#

try making a super huge map and see by yourself if performance is hit

#

objects are still loaded in memory thought, dont make a 16000x16000 tiles map (that take alot of memory), that would be more like 4 scenes of 4000x4000 tiles or something (which take 1/4 of the memory) then you load the other scene/map part additivly when you get near (but that is some mega huge map you probably wont make)

#

Its just an example but you get the idea

#

I think since 2018 or 2019 tilemaps got upgraded alot

pale tide
robust ivy
#

should be fine

pale tide
#

Okay youre right it did resolve the performance

#

thanks

#

If I ever plan on making longer maps I should divide them into chunks?

robust ivy
#

if you reach a bottleneck yeah

#

if not continue like that

#

look at memory used by all this

#

see if its too much for you

#

a 2d game using 5gb of memory is usually a bit too much

#

;p

#

i have a 600x500 map with over 10k objects and still under 1gb

#

it take alot

pale tide
#

You can check memory in the profiler right?

#

Its using 1.5gb lol

robust ivy
#

yeah

#

but you got editor on that too i think

pale tide
#

ah yeah

#

500mb then

#

thats ok

robust ivy
#

yep

pale tide
#

okay great tysm

robust ivy
#

if you build for webgl there a 1gb limit you want to try to stay at i think

#

there also another limit

#

just thought about it

#

the floating point error thingy

#

i think the general idea is dont go over 2000f distance from origin (up bottom left right) which would be a 4000x4000

#

not totally sure

#

if you need more you reset the position of map and character to the origin (0,0) once you reach that limit

#

or weird animation and weird things will start to happen

wicked knot
#

I'm attempting to build a large 2D World using tilemaps in unity, and was wondering how to prevent lag, should I just load tiles within a certain range?

pale tide
wicked knot
#

Did you figure out how to fix it?

#

If I can get all the tiles in a tile map, I can make sure they're all unloaded when the scene starts, and then load each one and unload it based on my distance to them

ionic jay
#

No clue if this is a standard approach for Unity, but long, long ago with an OpenGL framework I used an Octree to partition the space and load different "chunks" of tiles, for 2d you can use a quadtree I believe

#

I am hoping there is a Unity specific, cleaner solution that someone can correct me with though

wicked knot
#

I honestly think Unity might handle it on its own I haven't checked

raw minnow
#

When I try to create a game that makes clones of enemies and spawns them at a specific point, unity always makes the clones invisible. Does anybody know what the issue is?

wicked knot
#

What is the enemy Z position?

#

Also i reccomend using sorting layers

raw minnow
wicked knot
#

Making make sure the Z position is lower than the camera's

#

Also, again, look in the Sorting layers. They really help when you have a lot of things on different layers

raw minnow
#

I know i might sound dumb but how do I look into sorting layers?

raw minnow
wicked knot
#

Just Google Unity 2D sorting layers to look into sorting layers

#

Try going into 3D View and moving around to see if you can find the enemy

raw minnow
#

I tried sorting layer and going into 3d mode, but I still cannot see my enemy

robust ivy
#

is the gameobject there

#

if you double click it while in scene view it will bring you to it, if you still cant see it make sure it has a material

#

if its still not there screenshot

raw minnow
#

I did double click on my clone, but it just shows the polygon colider around it.

#

What properties should my material have?

wicked knot
#

"Missing sprite" in sprite renderer

#

You can't see it because there's nothing to see

versed osprey
#
        {
            return new Vector3(x, y) * cellSize;
        }```
#

what did i do wrong

versed osprey
#

nvm

pale tide
still tendon
#

this is weird, I attached a particle emitter to a game object and, when the particle lifetime is over, the parent sprite is deleted as well! How do I stop this from happening?

#

It seems to be related to me Destroying the component on OnBecameInvsible. Why does the particle life timer override the whole object? Is there something I'm not getting about how a particle emitter as a component works?

solemn latch
#

@still tendon how are you calling the destroy? Are you specifying the component?

#

@pale tide assuming you sliced each sprite properly, you'd move them in the scene view.

pale tide
#

oh

solemn latch
#

You can either assign bones in the sprite editor or just move each sprite as a solid chunk.

snow pilot
#

can anyone help me on how to make my 2d character look/rotate wherever he is moving?

fallen flicker
#

how do i change the position of a button from a script? Mine moves the button but to the completely wrong spot

mossy coyote
fallen flicker
#

I just realized I had completely set a variable wrong using random. So sorry to bother you, I'm just dumb

mossy coyote
# snow pilot can anyone help me on how to make my 2d character look/rotate wherever he is mov...

are you starting from scratch or do you have something already? If you are starting new, start with a tutorial and post when you have a question. heres one: https://www.youtube.com/watch?v=dwcT-Dch0bA

Let’s give our player some moves!

● Check out Skillshare: https://skl.sh/brackeys7

● Character Controller: https://bit.ly/2MQAkmu
● Download the Project: https://bit.ly/2KPx7pX
● Get the Assets: https://bit.ly/2KOkwjt

β™₯ Support Brackeys on Patreon: http://patreon.com/brackeys/

Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·...

β–Ά Play video
valid dune
#

how would i return the x and y values of a transform as 1 or negative 1 say +x,+y then it would output 1,1

#

basically want to use that as a direction the player is in that i can multiply by speed

hollow crown
#

if you just want a direction that is called normalisation, it doesn't set things to 1, it makes the vector have a length of 1

valid dune
#

ahh ok

hollow crown
#

Unity has multiple parts of the API that does it, just look for .normalize properties and Normalize functions in the docs

valid dune
#

ok gotcha

#

thanks

glass pulsar
#

does anyone know where to find scripts for expanding the sprite sheet editor built into unity, I am trying to have a script to batch rename all and batch change custom pivot without deleting all sprites

#

also batch trim

valid dune
#

how would one disable all gameobjects in an array

#

would it be like for(int i = 0;i< GameObject[i];i++){GameObject[i].enabled = false;}

civic knot
#

For starters, GameObjects are active/inactive, not enabled. SetActive(bool).

#

Then I'd advice against using GameObject as your array identifier.

#

In the loop condition you probably want to check the length of the array.

valid dune
#

for(int i =0;i<Enemies.Count;i++)
{
Enemies[i].SetActive(true);

}
mossy bough
#

yes

still tendon
#

If anything, if there were an alternate method for destroying objects that are outside of the camera that would probably help since becameInvisible is related to the renderer and may behave unexpectedly for example when the object is hidden behind another

solemn latch
#

@mossy coyote every time someone links that tutorial, a 2d fairy loses their wings and falls into lava and then posts here asking how to debug their being on fire.

#

@still tendon if you put the game object as the thing to be destroyed, then it will destroy the game object. You need to specify the component you want to destroy.

#

'Removes a GameObject, component or asset.

The objectΒ objΒ is destroyed immediately after the current Update loop, orΒ tΒ seconds from now if a time is specified. IfΒ objΒ is aΒ Component, this method removes the component from theΒ GameObjectΒ and destroys it. IfΒ objΒ is aΒ GameObject, it destroys theΒ GameObject, all its components and all transform children of theΒ GameObject.'

#

So you'd use a GetComponent or assign the particle system in the inspector.

leaden flame
valid dune
#

welp i have no idea why my coroutine is working

#

im spawning my player 4 seconds after the game starts ive tried getting a reference using a bool on the coroutine in the player script but anyway after 4 seconds all attatched game objects get destroyed on that destroy thing i have the wait time set to 16f

#

hmm

#

also my editor is being dumb im sure it wasnt marking the coroutine as an error before

lean estuary
light latch
#

Hello,
Why doesn't this work?

void Update()
    {
        CountDownAndShoot();
        if (moving)
        {
            laserProjectile.transform.position = Vector2.MoveTowards(transform.position, player.transform.position,
                                                                         projectileSpeed * Time.deltaTime);
            if (laserProjectile.transform.position == player.transform.position)
            {
                moving = false;
            }
        }
    }
valid dune
#

its even

light latch
valid dune
#

12 for me

#

and i am looking at the image

lean estuary
valid dune
#

oh im dumb

#

wait

#

there has to be nine

#

including the end bracket

light latch
#

What is the 6th bracket for?

#

According to the 6 in the image I've sent

valid dune
#

the bracket at the beginning of the script needs an end

light latch
#

Ah. You should format your code a bit... It's pretty hard to read for me

#

And what is the 9th for?

valid dune
#

the 9th is the end

light latch
#

The end of what

valid dune
#

of the class

#

/script

#

6 is the end of the spawn function

light latch
#

Yeah, I get that

#

What is it saying when you hover over the red line?

#

Could you please send me the Code of this Script, so I can look at it as good as I can

valid dune
#

https://pastebin.com/q2KXugNy
https://pastebin.com/eTfxaDpg
heres a pastebin for the scripts i think are the problems

#

if anyone wants to take a crack at it lmk

lean estuary
#

@valid dune Just format your code properly and remove brace on line 45

valid dune
#

is there an auto format in vs code also line 45 on the 2nd pastebin is a else if

#

and 45 in 1 is instantiate afaik brackets are needed

lean estuary
#

it will make it obvious

valid dune
#

just did

still tendon
#

anyone need help?

karmic storm
#

Is there a simple way to add a automatic player movement to a topdown game?

#

this is my code. I want the player to automaticly move in the specific directions. (just like snake)

mossy coyote
still tendon
tropic inlet
#

spawn a GameObject that exists for the sole purpose of having the particlesystem, maybe

mossy coyote
#

anyone have any suggestions: I have a 2d game that I use tilemaps to draw the environment. I want to create a rain effect (both raid drops falling as well as creating drops hitting the surface). I created the drops falling using a particle effect. What about drops hitting the surface (creating little splatters image overlays randomly on the tile grid). Can that be done by a particle effect?

tender swan
#

Not quite sure

#

Maybe would be better to have a rain animation

#

Can anyone recomend me what to use as a background to my 2d game cause i want to be able to texture paint it inside of unity

snow pilot
#

anyone have any good tutorials on movement scripts and animation? I would prefer not brackeys because I've done his tutorial 4 times and the jump animation is always bugged

#

I would also prefer if you could send an easy one because I am VERY new to C#

timid thistle
#

Hello everyone. I have this issue that I am trying to solve for 2 weeks now. I want to create a spawning system similar to Hack and slash games, but I can't find any resources online. Keep in mind that I am not a beginner developer. I can create normal spawners that just spam enemies every few seconds and enemies are also recycable. But this thing that I am trying to create is more open worldish. The level has a limit of enemies and the enemies can be also cleared the same way like in hack and slash games. I don't need code example, but a more design pattern, like what is the logic behind it? The game is top down 2D shooter in space

glossy marten
#

Hello guys. How do I make a gameobject follow a player and that it always stays on top of it?

robust ivy
#

simple way is align the gameobject like you want and drop it as a child of the player, that way moving the player all child follow and rotate like the player do

still tendon
#

Hey guys one question

#

I created this code because my game has not gravity i dont know why, and i want to have a key for the mass

#

But when i press S the mass doesnt go up, why? What is wrong?

lean estuary
#

Doing a tutorial that illustrate working with physics systems first would help a lot. Tutorial links are pinned in #πŸ’»β”ƒcode-beginner . Also debugging guide. You need to test what's happening with inputs, what script is actually running etc.

polar pagoda
#

Not sure if this is the correct place to post. I am trying to have a game object become interact-able within a certain frame window. Currently I have an Animation Event assigned to one of the key frames towards the end of the Animation Clip. It seems like this variable would need to be defined as a boolean value because it is either true or false. Maybe there is a better way to approach this?

lean estuary
#

@polar pagoda Don't cross-post.

polar pagoda
#

@lean estuary πŸ‘

nova coyote
#

Is there a way to make it so enemies will go through the player when they are invincible?

#

I played with isTrigger on the collider, but they all just fall through the floor lmao

lean estuary
#

You can set them temporarily to a layer that ignores collision with player (set in Physics collision matrix)

ancient sail
#

Hey, I need help on my 2d unity game if someone can please help me, I don't know how to add a shooting mechanic to my 2d side scroller

zenith saddle
#

Hi everyone

#

It's me πŸ˜„

#

Again πŸ˜’

#

I have one question

#

Maybe some of you know that i write game to work of as engineering work]

#

My problem is this that when i colison with "coins" i have example 100 points

#

and

#

when i die and i klick again Play Game

#

this coins dont exist

#

in my code I have a command Destroy

#

and i dont know how do this that whene i restart game i have this again :

coral nest
#

load? destroy?

#

exist?

#

you could reload coins by spawning them back in?

#

or just reload the scene

zenith saddle
#

when i reload lvl i have that i cant see coins which I collected

still tendon
#

can someone help me

#

why does when my char collide