Box in water moves when Player moves

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
zell2002
Citizen
Posts: 60
Joined: Sun Feb 23, 2014 9:22 pm

Box in water moves when Player moves

Post by zell2002 » Sat Jun 09, 2018 3:32 pm

I have a Player and Box that are both Dynamic bodies, and a "water volume" that is a Sensor
I have written some water bobbing code (using applyForce()) so when the Player and Box land they bob up and down - and im quite happy with it.

When my Player jumps on the Box, the Box sinks a bit before the buoyancy kicks in, however when my player moves Left/Right the Box is pushed as well.

This doesnt happen when my Box is not in the water volume, and my Player runs on top of it.

Is there something I can do to fix/cheat this at all? Perhaps I'm tired and missed something obvious...

Cheers for any help!

User avatar
ivan
Party member
Posts: 1468
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Box in water moves when Player moves

Post by ivan » Sat Jun 09, 2018 3:52 pm

Hard to say without looking at the love file, but it sounds like this is related to mass and friction.
Try to set the mass of the box to be considerably greater compared to that of the player.
Massive objects are harder to push around compared to light objects.
Alternatively you could try lowering the friction for both objects.

zell2002
Citizen
Posts: 60
Joined: Sun Feb 23, 2014 9:22 pm

Re: Box in water moves when Player moves

Post by zell2002 » Sat Jun 09, 2018 4:01 pm

Hey ivan, cheers. I had tried changing the Mass/Density - but the Box would sink quite quickly. However mixing that with lowering Friction of the Box seems to have worked.

Thanks!

zell2002
Citizen
Posts: 60
Joined: Sun Feb 23, 2014 9:22 pm

Re: Box in water moves when Player moves

Post by zell2002 » Sat Jun 09, 2018 4:14 pm

Ah, it seems I have to lower the Friction a bit too much - and my Player picks up too much speed now when walking across

I guess I could make it heavier than player and adjust my water buoyancy code relative to that

User avatar
pgimeno
Party member
Posts: 1739
Joined: Sun Oct 18, 2015 2:58 pm

Re: Box in water moves when Player moves

Post by pgimeno » Sat Jun 09, 2018 5:51 pm

Other ideas:

You could try to add some kind of viscous friction of the box with water too. That would be a force that opposes the movement of the box with respect to water and that grows with velocity (horizontal in this case).

Another idea is to apply reaction to the box: a force opposed to the one you apply to the player. As your player walks on the box, the shoe of the player exerts a backwards force on the box.

Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests