Huge problem ! Enemy/Tile coordination

Hello everybody, I’m running into a huge issue, I’ve been scratching my head to find a solution but found no way to solve this problem.

As shown in the video, the enemy is being affected by gravity only when it is within the screen’s bounds. This method works nicely only horizontally, which means that if the player falls downs, just like in the video, the enemy falls WHILE the tiles are not created, so it just gets stuck in the ground and falls down out of the level.

Also there’s another issue where some “platformSwitch” (big green tiles with a white P) are visible, while some others are not. This is really strange.

https://www.youtube.com/watch?v=yAS4XtRAIXs&feature=youtu.be

Is there any way to solve these problems ? Thanks you in advance !  :slight_smile:

Not sure if I understand your questions properly. The monsters have offscreen physics on? The entire map is loaded at the start before the monsters? Confused on what your questions was for the enemy part. I do believe Dyson added a new feature that better supports stuff from falling through the floor when he gives the newest update out.

That does seem strange with the big green tiles with white P, I would go to their tile and make sure all the settings like isVisible = false, etc and all that is done in the Tiled properties, so all their tiles have the same thing. After just get their obstacle key just like the MTE castleDemo example and can double set them there if it still doesn’t work in the program. But should be able to make them non visible through just the Tiled properties, assuming you want them all not visible?

Yo pull off your .zip ASAP!! It holds plugins that would ruin people’s business’s if you know what I mean.

I am so far the only downloader, but I am checking it out.

EDIT: the noDraw = true I put on your P tile and it makes them all invisible, MTE documentation says if you set it true it should still hold all of its tile properties.

I had no clue about the physicsOffScreen true being a big performance drain, I’m having a few performance problems myself and this is big info for me. I’m very interested in how you got the offscreenphysics to work better with performance, how do you determine to start moving if the screen reaches them?

Thanks for pointing this out, my bad. I updated the zip file.

As for the noDraw = true property, yeah I actually hides the tiles, but it doesn’t create the physic bodies…

I can’t delete just the attachment, so I had to delete the whole post.  You will need to repost it.

Rob

Ok this works:

local layerObjects = mte.getLayerObj({layer = 2})
layerObjects[1].isVisible = false

That hides the tiles but keeps all the properties of them! Just choose the layer, but if you wanted more control I’m sure one of those get “commands” will do the task. Could have a special layer for those special tiles you want to be hidden. Since MTE can use like a million layers, that should be fine?

*** Could you please go into more on how you stop a sprite from moving if not on the viewable screen or start the movement if on the viewable screen. If you wanna PM thats cool too! ***

But I removed it and posted the new one ! That was not the bad zip !

+Thanks you for the answer, Azmar. I’m going to try this out tomorrow, as it’s starting to be very late in France.

I would like to show the tweak here rather than in PM, so everybody can see it, and if somebody needs it he can use it.

First of all you need the object to have a .speed property so mte.lua can resume its movement.

Then, around line 9600 approximatively, search for this block of code

elseif (locX \<= masterGroup[i].vars.camera[1] or locX \>= masterGroup[i].vars.camera[3]) or (locY \<= masterGroup[i].vars.camera[2] or locY \>= masterGroup[i].vars.camera[4]) then object.isAwake = false object.isBodyActive = true else object.isAwake = true object.isBodyActive = true end

Just before the last end, add 

if object.speed ~= nil then object:setLinearVelocity(object.xScale\*object.speed,0) end

It’s really simple, it just applies a force to it depending on its determined speed and its direction.

Sorry, I was reacting to the trouble report that got filed and didn’t have any updates saying it was fixed.

Rob

It was fixed in a minute, so there was no trouble. I’m terribly sorry for the inconvenience.

Doesn’t work for me ??? I tried selecting different layers but it doesn’t hide anything at all, how did you proceed ?

mte.loadMap(mappath.."level1.tmx") -- load our map local layerObjects = mte.getLayerObj({layer = 3}) layerObjects[1].isVisible = false background:toFront()

I added the 2 middle lines inbetween your game.lua, I just started over your .zip planted those 2 lines in and it hides your entire “devant” layer. The layer number is for the way the layers are in Tiled. And you can still see the static wall objects even though they are hidden so it keeps the properties of the tiles.

Hello Azmar, thank you for your reply.

The layer=3 doesn’t hide the “devant” layer. I had to change it to 4.

And the layer I want to hide is the first in Tiled, the “switchs” layer. So I changed it to 5 randomly and I can see it hides only the “E” tiles, not the “F” nor “P”. So what’s happening, why doesn’t it hide the whole layer ? 

You sure the F and P are on that same exact layer? Cuz its hiding everything for me, I just tried it with all your tiles and it hides them. The only thing I noticed is if it has bodyType Dynamic and you try to hide it, it falls because of the gravity in your game and it draws them falling even though they should be invisible.  But works perfectly for bodyType static, could send Dyson a message to send a bug for the dynamic part and falling with gravity.

Yup, I’m sure of that, because when I hide the “switch” layer in Tiled, F, P and E hide. Also, concerning the bug, I think it’s normal as it keeps the physics properties. What you see I surely because of the “hybrid” physics mode…

So have you got any idea concerning this problem ? :confused:

Not sure if I understand your questions properly. The monsters have offscreen physics on? The entire map is loaded at the start before the monsters? Confused on what your questions was for the enemy part. I do believe Dyson added a new feature that better supports stuff from falling through the floor when he gives the newest update out.

That does seem strange with the big green tiles with white P, I would go to their tile and make sure all the settings like isVisible = false, etc and all that is done in the Tiled properties, so all their tiles have the same thing. After just get their obstacle key just like the MTE castleDemo example and can double set them there if it still doesn’t work in the program. But should be able to make them non visible through just the Tiled properties, assuming you want them all not visible?

Yo pull off your .zip ASAP!! It holds plugins that would ruin people’s business’s if you know what I mean.

I am so far the only downloader, but I am checking it out.

EDIT: the noDraw = true I put on your P tile and it makes them all invisible, MTE documentation says if you set it true it should still hold all of its tile properties.

I had no clue about the physicsOffScreen true being a big performance drain, I’m having a few performance problems myself and this is big info for me. I’m very interested in how you got the offscreenphysics to work better with performance, how do you determine to start moving if the screen reaches them?

Thanks for pointing this out, my bad. I updated the zip file.

As for the noDraw = true property, yeah I actually hides the tiles, but it doesn’t create the physic bodies…

I can’t delete just the attachment, so I had to delete the whole post.  You will need to repost it.

Rob

Ok this works:

local layerObjects = mte.getLayerObj({layer = 2})
layerObjects[1].isVisible = false

That hides the tiles but keeps all the properties of them! Just choose the layer, but if you wanted more control I’m sure one of those get “commands” will do the task. Could have a special layer for those special tiles you want to be hidden. Since MTE can use like a million layers, that should be fine?

*** Could you please go into more on how you stop a sprite from moving if not on the viewable screen or start the movement if on the viewable screen. If you wanna PM thats cool too! ***

But I removed it and posted the new one ! That was not the bad zip !

+Thanks you for the answer, Azmar. I’m going to try this out tomorrow, as it’s starting to be very late in France.

I would like to show the tweak here rather than in PM, so everybody can see it, and if somebody needs it he can use it.

First of all you need the object to have a .speed property so mte.lua can resume its movement.

Then, around line 9600 approximatively, search for this block of code

elseif (locX \<= masterGroup[i].vars.camera[1] or locX \>= masterGroup[i].vars.camera[3]) or (locY \<= masterGroup[i].vars.camera[2] or locY \>= masterGroup[i].vars.camera[4]) then object.isAwake = false object.isBodyActive = true else object.isAwake = true object.isBodyActive = true end

Just before the last end, add 

if object.speed ~= nil then object:setLinearVelocity(object.xScale\*object.speed,0) end

It’s really simple, it just applies a force to it depending on its determined speed and its direction.