#collision

1 messages · Page 1 of 1 (latest)

deep glacier
#

.

#

these sound like separate problems that should be tackled separately

#

a laser hitting the player doesn't really depend on direction: either we're getting zapped or we aren't

mystic tapir
#

the wall jump one matters the most to be honest

deep glacier
#

let's focus on that, then

mystic tapir
deep glacier
#

I feel like it's going to be very hard to meaningfully remember which side a collision came from, and to also correctly discard that information when the collision ends

mystic tapir
#

(whether a player is fully covered by the laser or just his left hand)

deep glacier
#

If you have multiple places that can get hit by a laser, I'd just give each one its own hitbox

#

each one can then independent learn that it is or isn't being zapped

deep glacier
#

I guess I'd do an overlap-circle to check for a wall, and then an overlap-circle to check for anything that isn't a wall

#

or maybe an overlap-box

#

depends on the shape, I guess

#

it's going to be way harder to keep track of all of the collision events and to keep all of that straight

mystic tapir
deep glacier
#

I would separate colliders used for movement from colliders used for hitboxes

#

The movement collider should be nice and smooth: no weird lumps to get caught on things

#

The hitboxes should be lumpier: better matched to your visuals

#

(and i'd use triggers for the things that can damage you)

#

a laser shouldn't be a thing you can collide with and stand on, probably!

deep glacier
#

if that wasn't the case, then you could have a simple damage collider (or even re-use the movement collider, at that point)

mystic tapir
analog elm
mystic tapir
#

but won't even more colliders overlaping make it have even weirder detections?

deep glacier
#

If damage is purely directional (and not a feature of specific parts of your hitbox), then I'd just measure the direction from the bullet to the player

#

maybe mix in the bullet velocity, too

mystic tapir
deep glacier
#

get a vector from the bullet to the player's center

deep glacier
#

That would avoid the issue entirely

mystic tapir
deep glacier
#

i don't currently see any reason to check which side a collision exited from, though :p

#

wall jumping is handled by just doing a few OverlapBox queries

mystic tapir
deep glacier
mystic tapir
#

hmm

#

it'd work for bullets , not really for walls tho

deep glacier
#

which is why you should be doing separate things for those two

#

you don't have to use a single collider for everything

analog elm
mystic tapir
deep glacier
#

premature optimization is evil

analog elm
deep glacier
#

having a few colliders is fine

analog elm
#

one collider cannot always represent the shape of an object, so yes, you can use multiple . . .

analog elm
mystic tapir
deep glacier
#

Different colliders for different duties.

mystic tapir
#

how does it fix my walljump problem then

#

ohh

deep glacier
#

you don't get a prize for using just one collider

mystic tapir
#

I could do it using tags

#

different for walls and walls

#

wait no

deep glacier
#

I would raycast.

#

you can get the normal of the surface you hit

#

if that normal is mostly horizontal, allow a walljump

mystic tapir
#

I don't have a clue about raycasting 😭

analog elm
#

casting is sooo much easier for all this . . .

deep glacier
#

yeah, you definitely got XY problem'd, haha

mystic tapir
#

I really thought there is no other way since I tried doing it so many ways 😭

#

I will try raycasting and different colliders then, thanks

analog elm
# mystic tapir

have you tried looging contactCount before accessing contacts?

deep glacier
#

(also, make sure you're always using the Physics2D functions)

mystic tapir