In both Wicked Shooter and Character controller scene the right foot footstep is not shown, this happens because of an incorrect UV mirror.
The current code is material.SetTexMulAdd(Vector(-1, 1, 0, 0)) while it should be material.SetTexMulAdd(Vector(-1, 1, 1, 0)).
Also, the code could be simplified, since both left and right footsteps code are almost the same, I currently have this code here for Wicked Shooter:
function self:Update_Footprints()
if not enable_footprints then
return
end
local radius = 0.1
-- this is used to only intersect 1 foot per frame
self.footprint_index = (self.footprint_index + 1) % 2
-- Create decal + footstep sound at a nav-mesh contact point
local function PlaceFootDecal(collEntity, collPos, flip)
local entity = CreateEntity()
local transform = scene.Component_CreateTransform(entity)
local material = scene.Component_CreateMaterial(entity)
local decal = scene.Component_CreateDecal(entity)
local layer = scene.Component_CreateLayer(entity)
local soundcomponent = scene.Component_CreateSound(entity)
transform.MatrixTransform(
matrix.LookTo(Vector(), self:GetFacing()):Inverse()
)
transform.Rotate(Vector(math.pi * 0.5))
transform.Scale(0.16)
transform.Translate(collPos)
material.SetTexture(TextureSlot.BASECOLORMAP, footprint_alpha)
material.SetTexture(TextureSlot.NORMALMAP, footprint_normal)
material.NormalMapStrength = 4
if flip then
-- Mirror for right foot
material.SetTexMulAdd(Vector(-1, 1, 1, 0))
end
decal.SetBaseColorOnlyAlpha(true)
decal.SetSlopeBlendPower(2)
layer.SetLayerMask(~(soldier_layer | projectile_layer))
scene.Component_Attach(entity, collEntity)
table.insert(temp_decal_array, entity)
soundcomponent.SetSound(sounds)
soundcomponent.SetSoundInstance(SoundInstance(sounds, 0, 0.33))
soundcomponent.SetLooped(false)
soundcomponent.Play()
end
-- Test one foot capsule against the nav mesh and stamp if newly placed
local function CheckFoot(foot, toes, placed_field, flip)
local capsule = Capsule(
scene.Component_GetTransform(foot).GetPosition(),
scene.Component_GetTransform(toes).GetPosition(),
radius
)
local collEntity, collPos = scene.Intersects(
capsule, FILTER_NAVIGATION_MESH
)
if collEntity ~= INVALID_ENTITY then
if not self[placed_field] then
self[placed_field] = true
PlaceFootDecal(collEntity, collPos, flip)
end
else
self[placed_field] = false
end
end
if self.footprint_index == 0 then
CheckFoot(
self.left_foot,
self.left_toes,
"foot_placed_left",
false
)
else
CheckFoot(
self.right_foot,
self.right_toes,
"foot_placed_right",
true
)
end
end
In both Wicked Shooter and Character controller scene the right foot footstep is not shown, this happens because of an incorrect UV mirror.
The current code is
material.SetTexMulAdd(Vector(-1, 1, 0, 0))while it should bematerial.SetTexMulAdd(Vector(-1, 1, 1, 0)).Also, the code could be simplified, since both left and right footsteps code are almost the same, I currently have this code here for Wicked Shooter: