At "Step by step tutorial for GDevelop" (with the turret)

Hi
I work through the Beginner-Tutorial “Step by step tutorial for GDevelop” and I remember this:
The explosion of an enemy is always in the wrong place … not the enemy, but next to it . I was thinking , why this is and I found out that it must be due to the assignment of the origin point of the explosion.

Trying CreateObject explosion(Centre) at position Enemy.X()... was not working .

Trying CreateObject explosion at position Enemy.CentreX()... worked, but the explosion was always in the top left corner.

Although the following experiment worked, but it is not in my opinion satisfactory :
I have the values ​​of explosion > Origin of 0/0 to 60/60 amended ( 1/2 the size of the animation ). Now the explosion appeared wherever the enemy was or even where the turret explodes.

My question is : Is this the only way to correct the place of origin or is there a version that is designed so that I can use coordinates of the center from the object "explosion "?

Rawir

This doesn’t work becuase GD objects doesn’t expect parameters to be created, just has no sense…

GD sprite objects has no property “CentreX()”, but “PointX(Centre)” :slight_smile:

The easiest way (I think) is to move the object to center it:

Conditions: Condition to create the explosion Actions: Create explosion at 0;0 Do = Enemy.PointX(Centre) - explosion.Width()/2; Enemy.PointY(Centre) - explosion.Height()/2 to the position of explosion
This should center the explosion in the object Enemy, if the Origin is at 0;0
If the Centre is not at the middle of width/height, you can use another formula:

         Do = Enemy.PointX(Centre) - ( explosion.PointX(Centre) - explosion.PointX(Origin) ); Enemy.PointY(Centre) - ( explosion.PointY(Centre) - explosion.PointY(Origin) ) to the position of explosion

Not tested, but should work too…

By the way, there is a button in the point editor window to modify all the frames simultaneously, if you enable it you can change the Origin from 0;0 to 60;60 for every frame just modifying one :smiley:

i dont see thepoint on this question…no need complicated formulas…

Explosion i s based on particule system, and it’s not a sprite, so it doesnt have Point like Centre or Origin, just origin 0;0. So the only function you can use to get the coordinates of the explosion is explosion.X(), but you don’t have to touch this object to place it on ennemy.

Just create the explosion at enemy.PointX(Centre);enemy.PointY(Centre) before deleting the “ennemy” object, it will be at his perfect Centre, if it’s not it’s because your particule object isn’t configurated to throw particulesat 360°.

If you want the explosion to be somewhere else, you can use a “tips”, create another point for example on the sprite bullet in front of it (called here “explosion_origin”), then when the collision happen just create the explosion on bullet
point like this : bullet.PointX(explosion_origin);bullet.PointY(explosion_origin).

Just remember particule system objets can’t have point, even if it’s based on image (wich in particule is not a sprite!).

Thank you both. :slight_smile: