[SOLVED] Let a Platform spawn in a Solid

0 favourites
  • 5 posts
From the Asset Store
Who wants to be a Millionaire Clone. An educational coding source
  • Hi there!

    I'm currently building a "simple" Infinity Runner Level and just began to add Assets and Animation.

    I also spawn Enemies on the generated Platforms, which works fine. The only Problem I'm facing right now is, that the Enemies (Platform Behaviour) always spawns on top of the Platform (Solid)

    I am positioning the Enemy with this line of code on top of the block:

    LayoutHeight - Block.Height - BlockHeightRandom[/code:17q8gqvb]
    My understanding was, that I need to half the Block.Height, to get it of half the Block height, so I tried this:  [code:17q8gqvb]LayoutHeight - Block.Height /2 - BlockHeightRandom[/code:17q8gqvb] but nothing changed on the positioning of the enemy.
    
    I also tried [code:17q8gqvb]LayoutHeight - Block.Height - BlockHeightRandom -200 [/code:17q8gqvb] to see if it changes anything, but it doesn't.
    
    Last thing I tried was to set the origin of the Enemie higher and not bottom left. but that doesn't worked either.
    
    this screenshot shows the desired behaviour
    [img="http://abload.de/img/solid_platformw1xab.jpg"]
    
    [img="http://abload.de/img/blockcodeg1ymq.jpg"]
    
    Help would be much appreciated!
  • No matter where you spawn the enemy, the platform behavior is supposed to make things be on top of solids, not inside. So this will always be the case.

    What you should do :

    • if it's only 1 particular enemy type that is half in the floor : change this enemy collision box so its feet are not "solid".
    • if it's all your enemies, change the floor collision box so that the half top part isn't solid.
  • Thanks for your help Guizmus!

    My character is supposed to walk on the blocks, so I can't change the floor collision box. But I use the same Enemy (Sprite) for all Enemies.

    When you say "change collision box", how do I implement this exactly?

    What I can think of right now is an invisible box with the platform behaviour where I put the actual Enemy Graphic and use an "On Every Tick" Command to place the Enemy Graphic on top of the Enemy Box?

    But I just saw that I don't need the Platform Behaviour on the Enemies, since they don't move... My bad, It's a remnant from first design

    So I can easily change the behaviour of the Enemies. only Condition they have to have is : On Collision with Player -> Destroy Player. But I don't think it needs a behaviour for this.

    //edit: still not working with no behaviours (except Flash). So I think I've to go with the collision box change. Any further details on this would be very helpful

    //edit2: ok, strange it's working now with

    LayoutHeight - Block.Height - BlockHeightRandom + 40[/code:2u5xitoh], I tried with +20 and it didn't changed anything, so I reset to "+0" and all Enemies were floating over the blocks and +20 was the normal "on top of the blocks height" now, which makes +40 half the block size now.
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Nop, you just double click the enemy to access the animation editor. Then, on the left side of the animation, you can see various buttons. One of those let you define the "collision polygon", the box that will tell what is solid and what isn't in your object. This should be set for every frame (different polygon per frame). You can also use the function "guess polygon shape", that will roughly set the collisions on all your frames.

    This won't matter though if you remove the platform behavior.

    Why your enemy isn't spawning where you want him without the platform behavior is a mystery though for me right now. Maybe a look at your capx could help understand it.

    Edit after your edit 2 : nice to see it work ^^ still no idea why :p

  • This Information with collision polygon is a very useful piece of information! thanks for that.

    I'll try it out (soon). I'm pretty sure it's helpful on a later project =)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)