Problem with physics of combined objects

Hi, can anybody help me with physics?
I had 2 types of spheres: transparent and yellow
Transparent sphere jumps in a good way, I like it
But when yellow sphere added inside, transparent sphere jumps bad :frowning: and no configuration of yellow sphere helps :frowning:
Any idea what to do?

pjysicsBug

1 Like

If you have a collision object that is dynamic then it will override any attempt to control the game objects position from code using go.animate or go.set_position. Attaching a dynamic collision object to a game object means that you hand over all control to the physics engine. I’m guessing this is what happens in your case.

So there is no way to make yellow ball bouncing in a transparnt so that transparent will jump well?

I’m not sure what it is you are trying to achieve? What is the purpose of the transparent spheres? And why are you mixing dynamic and kinematic collision objects like that?

Now it is not obvious, but it is an egg :slight_smile:
The idea is that this character can jump as in typical runners
I want that yellow part bounce inside transperent part because it will be funny
Transparent part is kinematic in order to have ability to jump
Yelow part is dynamic in order to have ability to have behaviour of bouncing ball

so smth like this

file

but how to make it to jump higher? as if there is no yellow part? (take a look at 1st gif at the top of topic) :frowning:

2 Likes

Ah, so it’s an egg! Ok, cool. Well, hmm, ok, so using one kinematic and one dynamic game object will not work for two reasons 1) A dynamic game object will take full control of the game object 2) A collision object that is completely inside another game object will not generate any collisions.

Also, what you want is some kind of inverse collision, bouncing when you’re about to leave the bounds of the outer object.

My first idea was to have two game objects (not parented), one for the egg white and one for the yolk. The egg white would be moved/controlled by the player. The egg yolk would follow the egg white with some inertia/delay. This would result in something like this:

Demo: https://britzl.github.io/Eggs (click to drag egg)
Code: https://gist.github.com/britzl/178df101da58a5ed38562094ae436d84

In your animations the egg yolk bounces on the edges. This should be doable as well. I’d probably assign a velocity to the yolk and move it while keep track of the distance to the edge. If on the edge I’d inverse the velocity to make it bounce.

4 Likes

It’s bouncing not in the same way as on gif in my previous reply, but still looks cool :slight_smile:
Thank you, I’ll try it in the evening

1 Like

Wow, I take a look at code and get how to move object (with mouse). It looks cooler than I get at a first look. Thank ou very much :slight_smile:

3 Likes