[SOLVED] Let a Platform spawn in a Solid

Get help using Construct 2

Post » Tue Feb 25, 2014 7:58 am

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:
Code: Select all
LayoutHeight - Block.Height - BlockHeightRandom

My understanding was, that I need to half the Block.Height, to get it of half the Block height, so I tried this:
Code: Select all
LayoutHeight - Block.Height /2 - BlockHeightRandom
but nothing changed on the positioning of the enemy.

I also tried
Code: Select all
LayoutHeight - Block.Height - BlockHeightRandom -200
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
Image

Image

Help would be much appreciated!
Last edited by genbatzu on Tue Feb 25, 2014 9:25 am, edited 1 time in total.
B
8
S
1
G
1
Posts: 29
Reputation: 735

Post » Tue Feb 25, 2014 8:24 am

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.
B
17
S
8
G
4
Posts: 473
Reputation: 6,191

Post » Tue Feb 25, 2014 8:38 am

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
Code: Select all
LayoutHeight - Block.Height - BlockHeightRandom + 40
, 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.
B
8
S
1
G
1
Posts: 29
Reputation: 735

Post » Tue Feb 25, 2014 8:50 am

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
B
17
S
8
G
4
Posts: 473
Reputation: 6,191

Post » Tue Feb 25, 2014 9:10 am

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 =)
B
8
S
1
G
1
Posts: 29
Reputation: 735


Return to How do I....?

Who is online

Users browsing this forum: Exabot [Bot], Kin, ratboy3, tinhofiel and 38 guests