Hey, i need help with health

hey im making a RPG and im working on a combat system, for some reason
my player disapears whenever he takes damage from the enemy.
Ive been searching for the cause of this problem for 45 minutes and found nothing!
could you guys you through the code and find out why?
(press p on your key-board to start enemy turn)
(P.S once you find the issue show me it and
send a screenshot of how to fix it please!)

thanks in advance!


@glowbug @CodeAlpaca @ManiacPumpkin

The player’s X position is changing from 239 to 400, which is off the screen. That is ~160 pixels. You have the Position behavior set to “Use Grid”, which means that inputting 5 will move you 32 pixels*5 or 160 pixels. If you change it to “Use Pixels” then the player will no longer disappear and only move 5 pixels.


Btw the string of timers and positions you’re using is pretty inefficient, doing something like this is much better.

Also, I recommend you bundle things into groups. So 1 bundle for movement, 1 for attacking, etc.

thank you!
can you send screenshot of the fixed code tho?

Just check the “Use Pixels” box and that will fix it.

but that wont work, the reason that code is like that is so that after the player
attacks he returns to his og position! :thinking:

You’re trying to make a really simple way of making the player step back, then return, but that’s a little too simple. I could send a screenshot of how to do this, but trying to figure it out on your own will be really beneficial in the future.

Think of what you have,

  1. A detection for when the enemy hits the player.
  2. A message telling the player to attack.

Think of what you want to happen,

  1. The player to move back 5 pixels when hit
  2. The player moves back to the starting position after attacking.

You have Message(fight) → Move Forwards. You can add onto that, → Switch(on) and a different Switch(off)

That switch will do this Animation(attack)[Done) → Switch → 240 Position(X)

That will bring the player back to the original position. After that have the switch turn itself off. and the other switch turn on

If the player collides with the enemy just move the player back 5 pixels

Collision(Enemy) → Switch → Position(X+)

a note, a Toggle Switch can be used over 2 Switches, but switches are much more flexible.

The code you have in the player and enemy I could probably make in 2 minutes, but that’s because I know what I want to make (Player move forward, attack, then move to start position. Enemy attack then move to start position). Knowing what you still need to make and what you already have is very important, it allows me to continue making things while never slowing down because I’m constantly thinking of the next thing that needs to be done.

You don’t always have to plan everything out, but it’s useful to realize what is going to be needed. If I’m making an inventory system I don’t know right as I begin how it will look, but I do know that I will need a List and a List Modify, so I can place those behaviors without knowing what they’ll do, but know they will be used. Then I just go through the steps of adding an item to the List, removing it via the List Modify, etc.

1 Like

oh i know!

thanks a lot for your help!

1 Like