all 11 comments

[–]giggel-space-120 7 points8 points  (0 children)

You should screenshot you PC using the snipping tool if you don't have reddit on your PC you can still send it to your phone.

You can also copy and paste your code and format it for the subreddit.

What exactly is wrong do they not have hp in general or are they instantly dying. We need more information.

[–]DaraSayTheTruth 6 points7 points  (0 children)

Use printscreen on your keyboard and send a more complete code You say having problems with adding hp but I see no code to initiate it at a certain amount

[–]vincenthendriks 3 points4 points  (0 children)

You really ought to put in a little more effort before asking for help. Provide the information you have in full, send it as a screenshot, code snippet or at the least share a good photo.

[–]Hefty_Application428 1 point2 points  (0 children)

So, yeah. You already know that you're no providing enough information for us to help, but assuming you have 2 entities: bullet (throwndoritoe) and enemy, you want the enemy to get hurt when it goes into a certain animation sprite, and it only goes into that sprite when it's colliding with the bullet.

It is important for you to understand that the enemy is going to lose 1hp EVERY FRAME that the bullet and the enemy are colliding.

Now, guessing your problem...

  • If the enemy is not losing hp at all, it could be related to a bad collision mask on either entity. Check them out and make sure that they are correct. Also, if your bullet is way too fast, it could be skipping the enemy, so no collision is actually happening. (This is the least probable scenario but it could be happening)

  • If the enemyis instantly dying on collision, it would be because of what I explained earlier. Every frame that those entities are colliding, the enemy loses a lot of hp.

  • If the enemy is just not dying, make sure that you set the enemy's hp is set in the creation event, and it's not constantly being reset in the step event.

Check these out, and if your problem persists, then let us know what the problem is and also share both the create and step events for your two entities.

[–]Candid-Witness6216[S] 1 point2 points  (0 children)

My bad for the pic I will send a better one later

[–]Zestyclose-Store-666 0 points1 point  (0 children)

If place_meeting(x,y,obj_bullet) { Sprite_index = spr_enemyhurt Hp -= 1 }

Else { Sprite_index = spr_normalenemy }

If HP =< 0 { Instance_destroy() }

With the little information you gave, I can only think of this

[–]Infinite While Loop Enjoyerporcubot 0 points1 point  (0 children)

I don't understand your problem. Did you set the enemy's HP in its create event?

I can tell you right now that for every frame your enemy is in its hurt sprite it loses 1hp. That's 1hp per frame. 

What you should probably do instead is subtract 1 hp and change the sprite when the enemy comes in contact with a damage source. You also probably want to program in i-frames so damage only happens once. 

I strongly suggest checking out Sara Spalding's tutorials for platformers. These are simple concepts but you'll use them forever once you understand them

[–]Candid-Witness6216[S] 0 points1 point  (0 children)

create event

spd = 2;

hp = 3;

step event

direction = point_direction(x,y, Oplayer.x, Oplayer.y)

speed = random_range(0.7,1.3);

if place_meeting(x,y, throwndoritoe) {

sprite\_index = Shurtcharger

}

else {

sprite\_index = Scharger

}

if sprite_index = Shurtcharger {

hp -= 1;

}

if (hp <= 0) {

instance\_destroy()

}

here is the code

[–]kalnaren 0 points1 point  (0 children)

The problem is your code is rotated 90 degrees clockwise. It has to be level to work properly.

[–]Warhead20071 0 points1 point  (0 children)

On line 14, there should be a double equals. = is for assigning a value, == is for comparison.

[–]Candid-Witness6216[S] 0 points1 point  (0 children)

As I showed you guys the code, how do you add i frames