Better boat handling
This commit is contained in:
@@ -413,9 +413,34 @@ local vehicles = {}
|
||||
local player_vehicles = {}
|
||||
local actuators = {}
|
||||
|
||||
|
||||
function create_vehicle(vtype, passengers, position)
|
||||
local vehicle = {}
|
||||
vehicle.id = ecs_vehicle_set(vtype, position[1], position[2], position[3], position[4])
|
||||
vehicle.passengers = {}
|
||||
vehicle.actuators = {}
|
||||
vehicle.add_passenger = function(this, data)
|
||||
local npc_id = ecs_npc_set(data.model, data.position[1], data.position[2], data.position[3], data.position[4])
|
||||
table.insert(this.passengers, npc_id)
|
||||
ecs_character("physics-control", npc_id, false)
|
||||
ecs_character("params-set", npc_id, "gravity", false)
|
||||
ecs_character("params-set", npc_id, "buoyancy", false)
|
||||
ecs_set_slot(this.id, npc_id, data.slot)
|
||||
ecs_character("set-actuator", npc_id, data.animation)
|
||||
end
|
||||
for i, v in ipairs(passengers) do
|
||||
vehicle:add_passenger(v)
|
||||
end
|
||||
return vehicle
|
||||
end
|
||||
function create_boat()
|
||||
local boat = {}
|
||||
boat.boat_id = ecs_vehicle_set("boat", 0, 0, -10, 1.75)
|
||||
local boat = create_vehicle("boat", {
|
||||
model = "normal-female.glb",
|
||||
position = {0, 2, -10, 1.75},
|
||||
slot = "captain_seat",
|
||||
animation = "sitting"}, {0, 0, -10, 1.75})
|
||||
--[[
|
||||
boat.id = ecs_vehicle_set("boat", 0, 0, -10, 1.75)
|
||||
local npc_id = ecs_npc_set("normal-female.glb", 0, 2, -10, 1.75)
|
||||
boat.passengers = {npc_id}
|
||||
ecs_character("physics-control", npc_id, false)
|
||||
@@ -426,6 +451,7 @@ function create_boat()
|
||||
ecs_character("set-actuator", npc_id, "sitting")
|
||||
-- ecs_set_animation_state(npc_id, "main", "actuator", true)
|
||||
-- ecs_set_animation_state(npc_id, "actuator-state", "sitting", true)
|
||||
]]--
|
||||
boat.event = function(this, event, event_data)
|
||||
print("boat: ", event)
|
||||
if event == "boat_control_enter" then
|
||||
|
||||
Reference in New Issue
Block a user