Moving through the ground

mtrain

New member
I want to make an enemy that appear from below when you standing on the rooftop (like helicopter or flying enemy). Have you any methods to make that without changing offset of each frame by frame and get smooth movement?
 
I assume you want entities which appear from back of building?

Yes, exactly, i miss that i have cut second example)) I need make enemy that walk upstairs, or moving up from the building on the rooftop, or a giant enemy that rise from the pit (like giant one eye robot from Contra HC), or any kind of visual appearing from below to above.
 
IMO sounds more like from behind to front

Anyways, to achieve what you want, you need to play with setlayer. If the entity you want to appear from behind never comes to front (e.g that giant cyclops robot and helicopter), setting setlayer in their header is sufficient
However, if entity appears from behind then drops to playing field you need this script:
Code:
@script
    if(frame == 0){
      void self = getlocalvar("self");
      changeentityproperty(self, "setlayer", -10);
    }
    if(frame == 5){
      void self = getlocalvar("self");
      changeentityproperty(self, "setlayer", 0);
    }
@end_script

At first frame, setlayer is set to -10 which puts entity behind panels. Then at 6th frame, setlayer is set to 0 which removes setlayer effect aka back to normal

It doesn't matter what entity does to move from behind to front i.e jump, fly and teleport. Since this is just setlayer trick, entity could be from anywhere for instance, if you want flying enemy to appear from behind building then floats down to playing field, you can just spawn that enemy right on playing field (no need to move from back to front)

HTH
 
Moving entity from behind to front is the previous problem I have solved few days ago ( have found that script at crime buster) . But I am talking about appearing from down to up ( also like cyclope robo from CHC , he move from below to the top of the building) . But in openbor it is hard to code it becase I dont know how to move entity offset lower than base. I think ill draw a scheme when ill be at home

image.png
 
I think i have solve this, i have tried it several times and it is working:

anim follow10
loop 0
offset 700 0
delay  45
                            frame data/chars/misc/empty.gif
@cmd    degravity 1
                            frame data/chars/misc/empty.gif
@cmd dasher 0 5 0
frame data/chars/atlas/a/01.gif
frame data/chars/atlas/a/01.gif
frame data/chars/atlas/a/01.gif
frame data/chars/atlas/a/01.gif
@cmd stop
delay  10
frame data/chars/atlas/a/01.gif
delay  2
offset 700 900
@cmd move 0 0 -900
frame data/chars/atlas/a/01.gif
@cmd stop
frame data/chars/atlas/a/01.gif
frame data/chars/atlas/a/01.gif
@cmd    degravity 0
frame data/chars/atlas/a/01.gif

So when enemy is on the ground his offset is 700 900, but for making him "rising from the pit" i make him offset 700 0 (to make him being "under ground"), so the moving height will be 900 pixels, so when he rises he will stand exactly on his 900 px offset, then i set degravity to 1. Next frame i make him rise move with dasher (using my previous calculations, during 4 frames with speed 5 and delay 45 the moving height will be exactly 900). Then i stop his movement. But i need to get his offset back, so i set the offset back to 700 900, but to not make him instantly appearing 900 px above, i move him 900 px back down at the same time with move command. Next frame i stop him from moving and set the gravity back. Of course depend on the enemy you can use setlayer at the header or layer cmd to place him behind panels or decorations. Thats it. Hope this will be useful for someone.
 
Yep, that's exactly the same way I did it in Contra : Locked 'N' Loaded. Some bosses even have their offset set couple pixels above instead of below their belly ;)
 
Back
Top Bottom