increased physics.cast() for action tokens above mat

This commit is contained in:
Chr1Z93 2024-05-21 14:29:05 +02:00
parent 6c2741a9df
commit 5eb2fcf071

View File

@ -16,6 +16,7 @@ local DISCARD_BUTTON_X_START = -1.365
local DISCARD_BUTTON_X_OFFSET = 0.455
local SEARCH_AROUND_SELF_X_BUFFER = 8
local SEARCH_AROUND_SELF_Z_BUFFER = 1.75
-- defined areas for object searching
local MAIN_PLAY_AREA = {
@ -166,11 +167,13 @@ end
-- finds all objects on the playmat and associated set aside zone.
function searchAroundSelf(filter)
local scale = self.getScale()
local bounds = self.getBoundsNormalized()
-- Increase the width to cover the set aside zone
bounds.size.x = bounds.size.x + SEARCH_AROUND_SELF_X_BUFFER
bounds.size.y = 1
bounds.size.z = bounds.size.z + SEARCH_AROUND_SELF_Z_BUFFER
-- 'setAsideDirection' accounts for the set aside zone being on the left or right,
-- depending on the table position of the playmat
@ -179,7 +182,8 @@ function searchAroundSelf(filter)
-- Since the cast is centered on the position, shift left or right to keep
-- the non-set aside edge of the cast at the edge of the playmat
local localCenter = self.positionToLocal(bounds.center)
localCenter.x = localCenter.x + setAsideDirection * SEARCH_AROUND_SELF_X_BUFFER / 2 / self.getScale().x
localCenter.x = localCenter.x + setAsideDirection * SEARCH_AROUND_SELF_X_BUFFER / 2 / scale.x
localCenter.z = localCenter.z - SEARCH_AROUND_SELF_Z_BUFFER / 2 / scale.z
return searchArea(self.positionToWorld(localCenter), bounds.size, filter)
end