I need to make a layer that isnt the sprite layer solid so the player sprite cant pass through it on a isometric map
I’m using the demo code from the IsometricComposer 0v984-7 and have then created a new map in tiled
my map has the following layers
Layer 3 - player sprite
Layer 2 - walls
Layer 1 - ground
if I have the walls and player sprite on the same layer (which I dont want) then the player sprite can not pass through the walls (which I want) with them on different layers the sprite passes straight through.
I have set the layer and tile properties to “solid” and “true” but this just doesnt seem to have any effect when the solid object and sprite are on different layers.
The collision detection for IsometricComposer is controlled programmatically in scene.lua, in the obstacle() function at line 21. Detection of solid obstacles is handled in lines 34 to 44:
local isSolid = false local isSlopeNext = false local detectNext = mte.getTileProperties({layer = player.layer, locX = locX, locY = locY}) if detectNext then if detectNext.solid then isSolid = true end if detectNext.slope then isSlopeNext = true end end
As you can see, the code retrieves the properties of a tile on layer = player.layer. The simplest way to get the effect you want on the map you describe is to change this to layer = player.layer - 1, or layer = 2 as follows:
local isSolid = false local isSlopeNext = false local detectNext = mte.getTileProperties({layer = player.layer - 1, locX = locX, locY = locY}) if detectNext then if detectNext.solid then isSolid = true end if detectNext.slope then isSlopeNext = true end end
Also, is the tile you’re trying to update currently involved in a physics collision? Do you get the same error at map locations with a non-physics tile?
nope I’m not doing any physics collision yet, its just a static tile
the error I’m getting is
c:\users\rj\downloads\million tile engine 0v984-7\million tile engine 0v984-7\sample projects\ isometriccomposer 0v984-7\MTE\mte.lua:4564: attempt to perform arithmetic on field '?' (a nil value) message stack traceback: ?: in function \<?:218\> [C]: ? c:\users\rj\downloads\million tile engine 0v984-7\million tile engine 0v984-7\sample projects\ isometriccomposer 0v984-7\MTE\mte.lua:4564: in function 'updateTile' c:\users\rj\downloads\million tile engine 0v984-7\million tile engine 0v984-7\sample projects\ isometriccomposer 0v984-7\scene.lua:298: in function \<c:\users\rj\downloads\million tile engine 0v984-7\million tile engine 0v984-7\sample projects\ isometriccomposer 0v984-7\scene.lua:277\> ?: in function 'dispatchEvent' ?: in function '\_nextTransition' ?: in function \<?:1439\> ?: in function 'gotoScene' c:\users\rj\downloads\million tile engine 0v984-7\million tile engine 0v984-7\sample projects\ isometriccomposer 0v984-7\main.lua:43: in main chunk
Are you calling mte.updateTile() before the first call to mte.update()? If so try adding an mte.update() call above the mte.updateTile() call and see if that has any effect. A lot of the variables MTE uses internally are set or calculated the first time mte.update() executes.
The collision detection for IsometricComposer is controlled programmatically in scene.lua, in the obstacle() function at line 21. Detection of solid obstacles is handled in lines 34 to 44:
local isSolid = false local isSlopeNext = false local detectNext = mte.getTileProperties({layer = player.layer, locX = locX, locY = locY}) if detectNext then if detectNext.solid then isSolid = true end if detectNext.slope then isSlopeNext = true end end
As you can see, the code retrieves the properties of a tile on layer = player.layer. The simplest way to get the effect you want on the map you describe is to change this to layer = player.layer - 1, or layer = 2 as follows:
local isSolid = false local isSlopeNext = false local detectNext = mte.getTileProperties({layer = player.layer - 1, locX = locX, locY = locY}) if detectNext then if detectNext.solid then isSolid = true end if detectNext.slope then isSlopeNext = true end end
Also, is the tile you’re trying to update currently involved in a physics collision? Do you get the same error at map locations with a non-physics tile?
nope I’m not doing any physics collision yet, its just a static tile
the error I’m getting is
c:\users\rj\downloads\million tile engine 0v984-7\million tile engine 0v984-7\sample projects\ isometriccomposer 0v984-7\MTE\mte.lua:4564: attempt to perform arithmetic on field '?' (a nil value) message stack traceback: ?: in function \<?:218\> [C]: ? c:\users\rj\downloads\million tile engine 0v984-7\million tile engine 0v984-7\sample projects\ isometriccomposer 0v984-7\MTE\mte.lua:4564: in function 'updateTile' c:\users\rj\downloads\million tile engine 0v984-7\million tile engine 0v984-7\sample projects\ isometriccomposer 0v984-7\scene.lua:298: in function \<c:\users\rj\downloads\million tile engine 0v984-7\million tile engine 0v984-7\sample projects\ isometriccomposer 0v984-7\scene.lua:277\> ?: in function 'dispatchEvent' ?: in function '\_nextTransition' ?: in function \<?:1439\> ?: in function 'gotoScene' c:\users\rj\downloads\million tile engine 0v984-7\million tile engine 0v984-7\sample projects\ isometriccomposer 0v984-7\main.lua:43: in main chunk
Are you calling mte.updateTile() before the first call to mte.update()? If so try adding an mte.update() call above the mte.updateTile() call and see if that has any effect. A lot of the variables MTE uses internally are set or calculated the first time mte.update() executes.