Skip to content

Commit

Permalink
Render car speed from update
Browse files Browse the repository at this point in the history
  • Loading branch information
aglitchman authored Sep 22, 2023
1 parent 6d8a2a0 commit 65707b3
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions scene3d/scripts/vehicles/car/car_main.script
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,25 @@ function final(self)
frustum_mesh.final(self)
end

function update(self, dt)
if not self.car_data then
return
end
local c = self.car_data

--
-- DEBUG
--
if self.debug_info then
render3d.debug_log("Car speed " .. string.format("%.0f KMH", math.abs(c.car_speed) * 3.6))
end

--
-- FRUSTUM CULL
--
frustum_mesh.update(self, c.car_position)
end

function fixed_update(self, dt)
if not self.car_data then
return
Expand Down Expand Up @@ -249,15 +268,6 @@ function fixed_update(self, dt)
msg.post("@render:", "draw_line", { start_point = c.car_position, end_point = c.car_position + debug_accel_direction, color = vmath.vector4(1, 0, 0, 1) } )
msg.post("@render:", "draw_line", { start_point = c.car_position + debug_front, end_point = c.car_position + debug_front + debug_turn_dir, color = vmath.vector4(0, 1, 0, 1) } )
end

if self.debug_info then
render3d.debug_log("Car speed " .. string.format("%.0f KMH", math.abs(c.car_speed) * 3.6))
end

--
-- FRUSTUM CULL
--
frustum_mesh.update(self, c.car_position)
end

function on_message(self, message_id, message, sender)
Expand Down

0 comments on commit 65707b3

Please sign in to comment.