A
ammu678
Guest
So i have 2 objects, one is the hero and other is enemy so i already designed the hero's attacks and enemy's attacks, so now the problem i have is that say the user presses a button to start the attack then at that time
candmg=1//a local variable in hero object
then in that object collison is checked with the enemy if its true then
global.dmg=1;
then in enemy object again a collison with hero is checked and provide global.dmg=1
then he enter damage state and cant move nor attack.(as corresponding variables are set to 0)
its somewhat similiar when enemy attacks the hero, a collison is checked and an attack is chosen at random
candmg=1;(local to enemy)
then a collison is checked with the hero object in step event of the enemy object
if (candmg=1 && place_meeting(obj_enemy.x,obj_enemy.y,obj_ichigo))
{
obj_ichigo.herodmg=1;
}
then accordingly hero enter dmg state.. so the problem is when the enemy detects collison with hero's attack sprite its starts its own attack choosing at random to solve this i created a variable as a conditon
canattack=1
for enemy to start the attack and also set in damaged state of the enemy canattack=0. but now it seems choosing attacks code is executed earlier than checking if enemy has to go in damaged state or not..so canattack isn't set to 0 early enough since when i start the game enemy also attacks when i attack him simultaneously . i tried putting the code(to check enemy is in damaged state or not) early in the step event that didnt work as of now i have the code in a separate drag and drop collison check.
Edit:turned out my enemy's damage animation time was very less so before my hero's attack was finished canattack was set to 1(since after my enemy damage state was over canattack was set to 1)
candmg=1//a local variable in hero object
then in that object collison is checked with the enemy if its true then
global.dmg=1;
then in enemy object again a collison with hero is checked and provide global.dmg=1
then he enter damage state and cant move nor attack.(as corresponding variables are set to 0)
its somewhat similiar when enemy attacks the hero, a collison is checked and an attack is chosen at random
candmg=1;(local to enemy)
then a collison is checked with the hero object in step event of the enemy object
if (candmg=1 && place_meeting(obj_enemy.x,obj_enemy.y,obj_ichigo))
{
obj_ichigo.herodmg=1;
}
then accordingly hero enter dmg state.. so the problem is when the enemy detects collison with hero's attack sprite its starts its own attack choosing at random to solve this i created a variable as a conditon
canattack=1
for enemy to start the attack and also set in damaged state of the enemy canattack=0. but now it seems choosing attacks code is executed earlier than checking if enemy has to go in damaged state or not..so canattack isn't set to 0 early enough since when i start the game enemy also attacks when i attack him simultaneously . i tried putting the code(to check enemy is in damaged state or not) early in the step event that didnt work as of now i have the code in a separate drag and drop collison check.
Edit:turned out my enemy's damage animation time was very less so before my hero's attack was finished canattack was set to 1(since after my enemy damage state was over canattack was set to 1)
Last edited by a moderator: