Ask here your questions to get help using GDevelop.
By Arnaldo Miguel
#61733 I need to program the collision effect in a game that is only a single object, ie when object 1 collides with object 2 disappears, but if object 2 collides with object 1 then object 1 blinks , I hope someone can help me the game is like a super mario.
By Mats
#61735 What you're saying doesn't make sense. If object 1 collides with object 2, object 2 will also be colliding with object 1. Both conditions will always be true together, or always be false together. Can you clarify what you mean?
By Arnaldo Miguel
#61742 To see me explain I must remember the game of super mario, I need that when the character falls on the bad object it disappears because it kills, but if the bad object in its dismemberment collides with the character it blinks like it is hurting him. I hope you understand me and you can help me
User avatar
By kalel
#61744
Arnaldo Miguel wrote:To see me explain I must remember the game of super mario, I need that when the character falls on the bad object it disappears because it kills, but if the bad object in its dismemberment collides with the character it blinks like it is hurting him. I hope you understand me and you can help me


If I understand right, this is what you want to do:

1 - Different condition when character jumps on the enemy and hits the enemy from above
2 - Different condition when character hits the enemy from sides
(like in super mario)

I'm not sure on the easiest way in gdevelop, but you could measure the angle between two objects during collision and then consider this angle.

There might be a function that checks the angle between 2 objects built into gdevelop. If not, you can use:

atan2(mario.Y()-enemy.Y()+mario.X()-enemy.X())

This will give you the angle in radians. You can convert them to degrees using ToDeg(), so:
ToDeg(atan2(mario.Y()-enemy.Y()+mario.X()-enemy.X()))

From that angle, it would be possible to determine if you hit the enemy from above, or from the sides.

Of course, there must be a simpler solution such as using a separate collision object on top of the enemy or etc. I'm also interested in hearing the simplest or best approach here. :)
By Mats
#61747 Two options:

Player is in collision with enemy
-Player is falling - Kill enemy
-Player is NOT falling - Injure player

You will need to use the platform automatism to have the player is falling condition.

Second option:

Place a hitbox (just a solid colour sprite) on the top of the enemy. Make it slightly shorter than the enemy so it does not stick out at the back and the front. Link the enemy and hitbox.
Make sure all enemy movement is also done to the hitbox.
Add to enemy a force of x
-Consider all hitbox linked to enemy
--Add to hitbox a force of x

Player is in collision with enemy
-Consider hitbox linked to enemy
--Player is in collision with hitbox - Kill enemy
--Player is NOT in collision with hitbox - Injure player

I would choose the second method as it lets you set anywhere on the enemy as a kill or damage zone. e.g. You can have a boss that only takes damage on headshot, or an enemy that only takes damange from arrows to the knee...
By Arnaldo Miguel
#61830 I'm doing a platform game but I need to increase the screen size so that I stay full screen either on the PC or on a mobile device, please if someone can tell me how to do it already the game I have done and I can not find This feature of Gdevelop that I'm sure should have.
User avatar
By kalel
#61835
Arnaldo Miguel wrote:I'm doing a platform game but I need to increase the screen size so that I stay full screen either on the PC or on a mobile device, please if someone can tell me how to do it already the game I have done and I can not find This feature of Gdevelop that I'm sure should have.


Isn't this somewhat automatic with HTML 5 export? But the screen ratio (height/width ratio) needs to be the same.

E.g. 1920 x 1080 can be displayed on many computers and smartphones, but it will not be full screen on all computers and smartphones without either black border or image stretching.

P.S. if you need actual full screen mode you may need to write a small JavaScript or host your game on a website that offers fullscreen automatically. Itch.io is one such website: https://kalel.itch.io/turret-defense-ty ... sword=test
By Arnaldo Miguel
#61841 Hello yesterday I did not know how to explain correctly, I need some way that the screen even if it is made responsive to any screen resolution because in tablets it is small in PC it looks good and in some phones it also looks good, so I just need to be responsive The screen in the game according to the device. I hope you can help me