#Any idea on what is happening? (Objects are teleported after collision)

54 messages · Page 1 of 1 (latest)

wanton stone
#

After the collision, small object is teleported to (1100.586, -8137.253) while large object is teleported to (2344.019, 48675.1)

foggy quartz
#

is something supposed to happen when they collide?
may we see your code for the objects?

wanton stone
#

i tried to find one but failed

#

I have no idea how to do something when they collide

#

btw, I'm trying to reproduce this with a minimal scene

dense zephyr
#

what type of node are the objects?

wanton stone
#

yellow: rigidbody2d

#

white: staticbody2d

#

the small rigidbody2d's shape is a irregular shape generated by code

#

(player draws shapes on screen and my code generated collider based on it)

#

the large one is a rectangle

wanton stone
dense zephyr
#

RigidBody has the body_entered signal

wanton stone
#

i thought it is only for area2d

#

thanks

dense zephyr
#

you can check all the signals and methods here

wanton stone
#

I googled about that before and everything I saw was about interaction between area2d and rigidbody2d. (Now I know, the actual reason is physics simulation game is rare)

dense zephyr
#

you can always press F1 in engine and search the documentation of anything

#

Nodes even have that little DOC button on the corner

#

or right-clicking in the code you can Lookup Symbol

wanton stone
#

nothing is printed when a collision happens

#

did i connect the correct signal?

#

this is the entire test scene

#

i turned on contact moniter and it doens't make a change

#

sorry, i didn't set maxcontacts to a larger value

#

(but it still doesn't solve the gif's problem, at least i'm able to debug now)

wanton stone
#

this one shows what happened: the large object crushes small object into ground, then something weird happens

lilac spade
#

You should try the box2d plugin

#

Godot physics isn't great, box2d is more established and better maintained atm

wanton stone
wanton stone
#

should i replace my "generate a polygon outline of player drawn line" code with "generate a series of capsules and attach all of them to the line's collider"?

lilac spade
#

There are also some project settings in the physics 2d section that might help with this. But that's not something I have experience with.
What I would try is going back to godot physics, maybe increase the ticks to 240 and see if that helps and if not try some different solver, margin or penetration settings.

lilac spade
#

You could also open an issue on the box2d plugin github page and see if the dev there has any ideas.
Box2d should definitely be able to handle this imo, and the dev is usually very helpful and quick to respond

wanton stone
#

does godot-box2d support colliders with holes and self intersecting colliders?

#

(godot physics doesn't support these, and my game is about hand drawn colliders, I can't say "player, you cant draw a ring")

#

i just installed it, it seems godot box2d only supports godot's collider shapes?

lilac spade
#

but usually its more stable

#

using your series-of-capsules-approach it should be possible to make a ring. otherwise you might have to generate a polygon hull from those ring edge points so you get a solid shape

wanton stone
#

my solution for self-intersecting shape was: cut a 0 width slice from the ring, so that game engine no longer thinks it has a hole

#

still a bit weird, at least players won't complain for this

#

(i replaced my outline function with series of collision shapes, and godot physcis with box2d)

#

thank you for the help

lilac spade
#

I'm glad it works now !! 🥳