Hi...
I want to change character apperance like super mario when player hits an object and transform to another apperance.
Here my problem is when mario is small mario, he cant break bricks and dies when he collide with enemies(which all his abblities is in one scene)

So i want to transform when he collide with mushroom and become big mario.

The problem here:
1.i cant figure it out how to transform when he collide with mushroom and become big mario and loose the abilites of small mario(such as dying with one hit and cant break bricks).

Please anyone can help me this...

in Engine

The first thing you need to do is set up collisions. The bare minimum is using the same collision shape for solids (level) and enemies/powerups

Once the game is detecting collisions, that's where you apply the logic, in this case, inside the signal function, usually `_on_Area2D_body_entered(body)`.

``````func _on_Area2D_body_entered(body):
if body == enemy:
mario_shrink()
elsif body == mushroom:
mario_grow()
``````

If you're having trouble figuring the logic, I highly recommend taking some math logic and/or programming logic studies.

For this particular case, you can either have two collision shapes, one for big and one for small Mario, or have one shape and have it grow OR shrink depending on powerup or if he's crouching.
If the touch detected an enemy, first you check if Mario is big. If he is, shrink him. If he's already small, kill him. If the touch detected the mushroom, you check if Mario is already big: if he's not big, make him grow and either modify the collision shape OR deactivate small shape and activate big shape, otherwise just give 1000 points.
Similarly, for checking if Mario jumped on an enemy, you can compare both objects' Y position and assume that if Mario's Y position is 8 pixels lower than the enemy's, the enemy dies, otherwise Mario gets hit. Note that a lower Y position means the object is further up.

by (294 points)

Hello thank you for the answers

I did understand some of your explanations, it would be helpful if i see this explanation in codes

I have attach link to my project: https://mega.nz/file/Ex9FxS6b#hSmZ46uGCcTGRcUk6grS8qQL8WWzCUl1yhYRJFMHpuE