Dynamic Body Stop Moving

Hello everyone,

So, I have a question, I’m creating a joystick based game, and I need some dynamic bodies for collisions, (kinda walls).

My player is static (/dynamic, doesn’t change here). And when my player collides with a wall, the wall moves with the action. How can I stop dynamic objects moving and still have the wall stopping my player?

Thank you

Philippe

P.S.: Maybe I didn’t understood well some physics actions :stuck_out_tongue: I’m a newbie in lua

Hi Philippe,

Would it be more logical to make the player “dynamic” and the walls “static”? Is there a reason why you’re doing it the opposite?

Regards,

Brent

 

No and yes

This is when I start the
game my player is dynamic the walls static:

This is when I move the
joystick(player) The walls block my player but my player isn’t in the center
anymore:

This is now when player is
static and walls dynamic:

 

My player stays in the
center but my walls move.

 

So this is the reason why
my player is static :slight_smile:

 

Are you moving the player with the joystick, or the “camera” while the player remains in the center and the “walls” move around it? If so, how are you moving the world around, via display group X and Y shifting?

Could you create a quick video showing the game in action? If you’re on Mac, I think the basic Quicktime Player can record a game demo (with no sound, but who cares in this case). On Windows, I imagine there’s a similar utility.

Brent

I tried to move the camera with the joystick, but actually it moves all the other objects, just not the player. I’ll upload the vid another time. Now it’s 22 o clock, sorry time for me to sleep! (exams tomorow :frowning: )

but thank you for your help!

I love this staff :slight_smile:

How can I upload a video?

Hmmm… do you have a YouTube or Vimeo account, or similar? If you put it there and provide a link, I can check it out.

Brent

http://www.youtube.com/watch?v=38JFKza55oo&feature=youtube_gdata
There you go!

Here is the link :slight_smile:

thanks alot Brent

Hi @philippe,

The video is locked (marked as “private”). Can you please unlock it or upload a public version?

Thanks.

Done!

The video is now as a public version :slight_smile:

Hi Phillippe,

Thanks for unlocking the video. I’m curious now, how are you moving all of these objects? Are you shifting the entire display group that they’re in? I notice around 6 seconds into the video, the box passes through the bottom wall. This leads me to think you’re moving the walls as an entire display group by shifting its X and Y position independently of the player. Is this true? That practice isn’t allowed, at least in terms of maintaining the collision system properly. There are workarounds, but it’s just something to be aware of.

Brent

Yes you are right!

So how could I do it?

Thank you so much Brent,

Philippe

Should I give you all my code?

Hi Philippe,

Basically, when it comes to collisions, you need to keep all objects in the same “coordinate space” based on (0,0). You can certainly move the entire world around as an entire unit, but you can’t move different display groups around independently of each other. For example, if your “walls” are in one group, and your “player” in another, moving “wallsGroup” to 50,50 while “playerGroup” remains at 0,0 will cause collisions to malfunction (the player will consider that the walls existed in their original 0,0 coordinate space).

There are various ways around this, but it depends on the gameplay. Can your player object stay exactly centered, or does it need to move around a bit?

Brent

Hi Philippe,

Would it be more logical to make the player “dynamic” and the walls “static”? Is there a reason why you’re doing it the opposite?

Regards,

Brent

 

No and yes

This is when I start the
game my player is dynamic the walls static:

This is when I move the
joystick(player) The walls block my player but my player isn’t in the center
anymore:

This is now when player is
static and walls dynamic:

 

My player stays in the
center but my walls move.

 

So this is the reason why
my player is static :slight_smile:

 

Are you moving the player with the joystick, or the “camera” while the player remains in the center and the “walls” move around it? If so, how are you moving the world around, via display group X and Y shifting?

Could you create a quick video showing the game in action? If you’re on Mac, I think the basic Quicktime Player can record a game demo (with no sound, but who cares in this case). On Windows, I imagine there’s a similar utility.

Brent

I tried to move the camera with the joystick, but actually it moves all the other objects, just not the player. I’ll upload the vid another time. Now it’s 22 o clock, sorry time for me to sleep! (exams tomorow :frowning: )

but thank you for your help!

I love this staff :slight_smile:

How can I upload a video?

Hmmm… do you have a YouTube or Vimeo account, or similar? If you put it there and provide a link, I can check it out.

Brent