G#m_Player2
Member
Hello GameMaker Community, I recently have a problem in my melee attacks. I watched Shaun spalding's melee attack tutorial together with my other knowledge with his other videos about attacking enemies and parent objects but I may still have a lack of coding knowledge and I want to learn more hopefully you can provide the help that I needed . I have 2 problems about the process after which the player finishes melee attacking the enemy:
[1] First is the sense of direction which where my last melee attack is used. Example is when I kill the enemy from the left side, the "oEnemyD" (stands for obj_enemydead) will be sent flying to the right side instead. Which I expect the oEnemyD should be flying to the side from where it was attacked.
[2] Second is my other object "oEnemy2" when killed by the oPlayer it spawns the same instance as the first "oEnemy"
I am using the script of Shaun Spalding's Melee attack tutorial:
------------PlayerState_MeleeAttack1();-----------
and EnemyHit(); script:
If you need anymore script or event that can help you understand my problem I am happy to assist you. I hope someone can help
[1] First is the sense of direction which where my last melee attack is used. Example is when I kill the enemy from the left side, the "oEnemyD" (stands for obj_enemydead) will be sent flying to the right side instead. Which I expect the oEnemyD should be flying to the side from where it was attacked.
[2] Second is my other object "oEnemy2" when killed by the oPlayer it spawns the same instance as the first "oEnemy"
I am using the script of Shaun Spalding's Melee attack tutorial:
------------PlayerState_MeleeAttack1();-----------
GML:
hsp = 0;
vsp = 2;
//Start of attack
if(sprite_index != sPlayerA)
{
image_index = 0;
image_speed = 2;
sprite_index = sPlayerA
ds_list_clear(hitByAttack);
}
//Use attack hitbox & check for hits
mask_index = sPlayerA_HB;
var hitByAttackNow = ds_list_create();
var hits = instance_place_list(x,y,oEnemy,hitByAttackNow,false);
if(hits > 0)
{
for(var i = 0; i < hits; i++)
{
//if hits instance has not yet been hit by this attack
var hitID = hitByAttackNow[| i];
if (ds_list_find_index(hitByAttack,hitID) == -1)
{
ds_list_add(hitByAttack,hitID);
with (hitID)
{
EnemyHit(2);
}
}
}
}
ds_list_destroy(hitByAttackNow);
mask_index = sPlayer;
if(animation_end())
{
sprite_index = sPlayer;
state = PLAYERSTATE.FREE;
}
GML:
var _damage = argument0;
hp -= _damage;
flash = true;
if(hp <= 0)
{
with (instance_create_layer(x,y,layer,oEnemyD))
{
if (other.image_xscale == 1) direction = 0;
else direction = 180;
}
instance_destroy();
}