Boats mod improve y motion. Smaller collision box. Reverse turn with negative velocity only. Smooth turning. Enable underwater higher acceleration
This commit is contained in:
parent
ba8cbbcdbd
commit
d57cb0a110
@ -32,7 +32,7 @@ end
|
|||||||
|
|
||||||
local boat = {
|
local boat = {
|
||||||
physical = true,
|
physical = true,
|
||||||
collisionbox = {-0.6, -0.4, -0.6, 0.6, 0.3, 0.6},
|
collisionbox = {-0.5, -0.4, -0.5, 0.5, 0.3, 0.5},
|
||||||
visual = "mesh",
|
visual = "mesh",
|
||||||
mesh = "boat.x",
|
mesh = "boat.x",
|
||||||
textures = {"default_wood.png"},
|
textures = {"default_wood.png"},
|
||||||
@ -104,19 +104,17 @@ function boat.on_step(self, dtime)
|
|||||||
local yaw = self.object:getyaw()
|
local yaw = self.object:getyaw()
|
||||||
if ctrl.up then
|
if ctrl.up then
|
||||||
self.v = self.v + 0.1
|
self.v = self.v + 0.1
|
||||||
end
|
elseif ctrl.down then
|
||||||
if ctrl.down then
|
self.v = self.v - 0.1
|
||||||
self.v = self.v - 0.08
|
|
||||||
end
|
end
|
||||||
if ctrl.left then
|
if ctrl.left then
|
||||||
if ctrl.down then
|
if self.v < 0 then
|
||||||
self.object:setyaw(yaw - (1 + dtime) * 0.03)
|
self.object:setyaw(yaw - (1 + dtime) * 0.03)
|
||||||
else
|
else
|
||||||
self.object:setyaw(yaw + (1 + dtime) * 0.03)
|
self.object:setyaw(yaw + (1 + dtime) * 0.03)
|
||||||
end
|
end
|
||||||
end
|
elseif ctrl.right then
|
||||||
if ctrl.right then
|
if self.v < 0 then
|
||||||
if ctrl.down then
|
|
||||||
self.object:setyaw(yaw + (1 + dtime) * 0.03)
|
self.object:setyaw(yaw + (1 + dtime) * 0.03)
|
||||||
else
|
else
|
||||||
self.object:setyaw(yaw - (1 + dtime) * 0.03)
|
self.object:setyaw(yaw - (1 + dtime) * 0.03)
|
||||||
@ -125,6 +123,7 @@ function boat.on_step(self, dtime)
|
|||||||
end
|
end
|
||||||
local velo = self.object:getvelocity()
|
local velo = self.object:getvelocity()
|
||||||
if self.v == 0 and velo.x == 0 and velo.y == 0 and velo.z == 0 then
|
if self.v == 0 and velo.x == 0 and velo.y == 0 and velo.z == 0 then
|
||||||
|
self.object:setpos(self.object:getpos())
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local s = get_sign(self.v)
|
local s = get_sign(self.v)
|
||||||
@ -148,30 +147,33 @@ function boat.on_step(self, dtime)
|
|||||||
self.v = 0
|
self.v = 0
|
||||||
new_acce = {x = 0, y = 1, z = 0}
|
new_acce = {x = 0, y = 1, z = 0}
|
||||||
else
|
else
|
||||||
new_acce = {x = 0, y = -9.8, z = 0} -- freefall in air -9.81
|
new_acce = {x = 0, y = -9.8, z = 0}
|
||||||
end
|
end
|
||||||
new_velo = get_velocity(self.v, self.object:getyaw(), self.object:getvelocity().y)
|
new_velo = get_velocity(self.v, self.object:getyaw(), self.object:getvelocity().y)
|
||||||
|
self.object:setpos(self.object:getpos())
|
||||||
else
|
else
|
||||||
p.y = p.y + 1
|
p.y = p.y + 1
|
||||||
if is_water(p) then
|
if is_water(p) then
|
||||||
new_acce = {x = 0, y = 3, z = 0}
|
|
||||||
local y = self.object:getvelocity().y
|
local y = self.object:getvelocity().y
|
||||||
if y > 2 then
|
if y >= 4.5 then
|
||||||
y = 2
|
y = 4.5
|
||||||
end
|
elseif y < 0 then
|
||||||
if y < 0 then
|
new_acce = {x = 0, y = 20, z = 0}
|
||||||
self.object:setacceleration({x = 0, y = 10, z = 0})
|
else
|
||||||
|
new_acce = {x = 0, y = 5, z = 0}
|
||||||
end
|
end
|
||||||
new_velo = get_velocity(self.v, self.object:getyaw(), y)
|
new_velo = get_velocity(self.v, self.object:getyaw(), y)
|
||||||
|
self.object:setpos(self.object:getpos())
|
||||||
else
|
else
|
||||||
new_acce = {x = 0, y = 0, z = 0}
|
new_acce = {x = 0, y = 0, z = 0}
|
||||||
if math.abs(self.object:getvelocity().y) <= 2 then
|
if math.abs(self.object:getvelocity().y) < 1 then
|
||||||
local pos = self.object:getpos()
|
local pos = self.object:getpos()
|
||||||
pos.y = math.floor(pos.y) + 0.5
|
pos.y = math.floor(pos.y) + 0.5
|
||||||
self.object:setpos(pos)
|
self.object:setpos(pos)
|
||||||
new_velo = get_velocity(self.v, self.object:getyaw(), 0)
|
new_velo = get_velocity(self.v, self.object:getyaw(), 0)
|
||||||
else
|
else
|
||||||
new_velo = get_velocity(self.v, self.object:getyaw(), self.object:getvelocity().y)
|
new_velo = get_velocity(self.v, self.object:getyaw(), self.object:getvelocity().y)
|
||||||
|
self.object:setpos(self.object:getpos())
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -181,7 +183,6 @@ end
|
|||||||
|
|
||||||
minetest.register_entity("boats:boat", boat)
|
minetest.register_entity("boats:boat", boat)
|
||||||
|
|
||||||
|
|
||||||
minetest.register_craftitem("boats:boat", {
|
minetest.register_craftitem("boats:boat", {
|
||||||
description = "Boat",
|
description = "Boat",
|
||||||
inventory_image = "boat_inventory.png",
|
inventory_image = "boat_inventory.png",
|
||||||
@ -213,3 +214,4 @@ minetest.register_craft({
|
|||||||
{"group:wood", "group:wood", "group:wood"},
|
{"group:wood", "group:wood", "group:wood"},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user