0 votes

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 by (12 points)

1 Answer

0 votes

Also https://www.youtube.com/watch?v=x5e0EMLaz1Y

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:
  elsif body == mushroom:

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

please can you implement your explanation in my project, i know i am asking a lot.
moreover there is less tutorial on gadot.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.