Page 2 of 2

Re: Top-down liquid (water) physics simulation

Posted: Thu Apr 13, 2023 9:34 pm
by dusoft
Some basic pointers (where fixture is fixture of player's body):

Code: Select all

player.state.x, player.state.y = fixture:getBody():getPosition() -- X,Y in world
    player.state.heading = math.round(math.deg(fixture:getBody():getAngle())) -- heading angle, beware it can be multiplies of 0-360 and even negative
    local speed_x, speed_y = fixture:getBody():getLinearVelocity() -- linear velocity on two axes
    player.state.speed = math.sqrt(speed_x ^ 2 + speed_y ^ 2) -- merged vehicle speed, e.g. for speedometer