Walls do not move with camera

I have this wall module that I use to create walls, however, when creating them the physics bodies of the walls move, but the walls themselves don’t. They don’t move with the camera I am using, the camera works fine with all other objects.

--call in level.lua levelManager.load(levelToLoad, cameraGroup, enemyGroup) --level manager module local M = {} local wall = require "HelperModules.OtherMods.wall" local function loadLevel1(group, enemyGroup) wall.new(group, 100, 100, 40, 500, false, false) end local levels = { loadLevel1 } function M.load(levelNumber, group, enemyGroup) levels[levelNumber](group, enemyGroup) end return M --wall module local segLength = 127 local segWidth = 29 local debugEn = false local wallChunk = require "HelperModules.OtherMods.wallChunk" local bullet = require "HelperModules.GameMods.bullet" local wallM = {} function wallM.new( group, x, y, angle, length, allowEndGap, isPassive) group = group or display.currentStage angle = angle or 0 length = length or 260 -- if( length \< segLength ) then return nil, nil, nil end -- local parts = {} -- -- local numSegments = math.floor( length/segLength ) local remaining = length - (numSegments \* segLength) -- local numGaps = (allowEndGap==true) and numSegments or numSegments-1 local gapLen = 0 if( numGaps \> 0 ) then gapLen = remaining/numGaps end -- local vec = ssk.math2d.angle2Vector( angle, true ) vec = ssk.math2d.scale( vec, segLength + gapLen ) table.dump(vec) -- for i = 1, numSegments do local seg = wallChunk.new(group, x, y, angle, 0, isPassive) seg.rotation = angle - 90 -- parts[#parts+1] = seg -- if( debugEn ) then local tmp = display.newCircle( group, x, y, 5 ) tmp:setFillColor(unpack(\_R\_)) tmp.alpha = 0.75 end -- x = x + vec.x y = y + vec.y physics.addBody(seg, "static") end return parts, x, y end return wallM --wallChunk module local M = {} local bullet = require "HelperModules.GameMods.bullet" local id = 0 --non-passive walls react to player collision --passive walls do not react to any collisions local function fiveSpread(obj) local group = obj.parent local x = obj.x local y = obj.y bullet.new(group, x, y, obj.rotation - 30, 500, 4) bullet.new(group, x, y, obj.rotation - 15, 500, 4) bullet.new(group, x, y, obj.rotation, 500, 4) bullet.new(group, x, y, obj.rotation + 15, 500, 4) bullet.new(group, x, y, obj.rotation + 30, 500, 4) end function wallCollision(self, event) if event.phase == "began" then if self.isPassive then return end if event.other.id == "char" and self.active then threeSpread(self) self.active = false timer.performWithDelay(1500, function() self.active = true end) end end end function M.new(group, x, y, angle, myId, isPassive) local wall = display.newImageRect("Assets/Sprite/Tile1.png", 149, 34) wall.x = x wall.y = y wall.rotation = angle id = myId wall.isPassive = isPassive wall.active = true physics.addBody(wall, "static") wall.collision = wallCollision wall:addEventListener("collision") return wall end return M

Sorry that it’s a lot of code, but I can’t seem to narrow where this problem is so I added the entire flow of the modules and calls.

Wait… I just realized a fatal flaw in my thought process!

I think my brain went on airplane mode for a bit… But the walls are not supposed to move!

Sorry, this whole topic was pointless.

Actually wait they are supposed to move, crap.

Yeah, I am having a problem, sorry.  :stuck_out_tongue:

Ignore my previous posts except for the initial problem.

Hi sdktester15, 

I’m not sure it helps but here you go.

You don’t use group parameter in new method in wallChunk module at all. I think it will be better use

local wall = display.newImageRect(group, "Assets/Sprite/Tile1.png", 149, 34)

Also you probably want in wallChunk module use

wall.id = myId

instead of 

id = myId

Do you provide a good group for ssk.camera.tracking function?

Have a nice day:)

ldurniat

Yeah, that was it, I forgot to provide that group parameter. My bad, that was a silly mistake.

Also, the id is not actually the wall’s id it was for something else that I am not using anymore, so I will delete that.

Thanks a lot!

Wait… I just realized a fatal flaw in my thought process!

I think my brain went on airplane mode for a bit… But the walls are not supposed to move!

Sorry, this whole topic was pointless.

Actually wait they are supposed to move, crap.

Yeah, I am having a problem, sorry.  :stuck_out_tongue:

Ignore my previous posts except for the initial problem.

Hi sdktester15, 

I’m not sure it helps but here you go.

You don’t use group parameter in new method in wallChunk module at all. I think it will be better use

local wall = display.newImageRect(group, "Assets/Sprite/Tile1.png", 149, 34)

Also you probably want in wallChunk module use

wall.id = myId

instead of 

id = myId

Do you provide a good group for ssk.camera.tracking function?

Have a nice day:)

ldurniat

Yeah, that was it, I forgot to provide that group parameter. My bad, that was a silly mistake.

Also, the id is not actually the wall’s id it was for something else that I am not using anymore, so I will delete that.

Thanks a lot!