Skip to content

Commit

Permalink
Kartong: Minor optimization in Boost script.
Browse files Browse the repository at this point in the history
  • Loading branch information
apistol78 committed Jul 31, 2024
1 parent 6b39a6c commit bed026e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion data/Source/Scripts/Boost.xdi
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@ function Boost:new()
end
function Boost:update(contextObject, totalTime, deltaTime)
-- Get boost volume.
local vc < const > = self.owner:getComponent(world.VolumeComponent)
if vc == nil then return end
-- Get all karts and check if anyone is within boost volume.
local karts < const > = self.owner.world:getEntities("Kart")
for i = 0, karts.size - 1 do
local kart < const > = karts:get(i)
local position < const > = kart.transform.translation
if self.owner:getComponent(world.VolumeComponent):inside(position) then
if vc:inside(position) then
local rb < const > = kart:getComponent(physics.RigidBodyComponent)
rb.body:addForceAt(
position,
Expand Down

0 comments on commit bed026e

Please sign in to comment.