Legacy GM need some help with collision

E

EZTALES

Guest
hey yall,
needed some help with a little issue I'm having, I wanted it so that when the player punches an NPC it will start a fight against them, however, when I do nothing appears to happen. This is the code that I have below and I was wondering what I did wrong. any help is appreciated cheers!
Code:
/// start fight (in Step Event)
if (place_meeting(x,y,obj_NPC_5)) && (spr_player_attacking_U = 7)
{
room_goto(rm_test_3);
}
 

Joe Ellis

Member
It might be "spr_player_attacking_U = 7"
That looks like your asking if a sprite equals 7, but I don't know if spr_player_attacking_U is a variable..
Could you show any more code?
 
E

EZTALES

Guest
It might be "spr_player_attacking_U = 7"
That looks like your asking if a sprite equals 7, but I don't know if spr_player_attacking_U is a variable...
Could you show any more code?
it's not a variable, it is referring to the final animation of the players up attack if you think that making a variable for this is a good idea i will try it out
 

Joe Ellis

Member
Ohh,
No the thing your doing wrong is, you need to check if the player's sprite is spr_player_attacking_U

Code:
/// start fight (in Step Event)
if (place_meeting(x,y,obj_NPC_5))
&& (sprite_index = spr_player_attacking_U)
{
room_goto(rm_test_3);
}
 
E

EZTALES

Guest
Ohh,
No the thing your doing wrong is, you need to check if the player's sprite is spr_player_attacking_U

Code:
/// start fight (in Step Event)
if (place_meeting(x,y,obj_NPC_5))
&& (sprite_index = spr_player_attacking_U)
{
room_goto(rm_test_3);
}
Thanks man, I'll check it out and get back to you, thanks for the help!
 
E

EZTALES

Guest
Ohh,
No the thing your doing wrong is, you need to check if the player's sprite is spr_player_attacking_U

Code:
/// start fight (in Step Event)
if (place_meeting(x,y,obj_NPC_5))
&& (sprite_index = spr_player_attacking_U)
{
room_goto(rm_test_3);
}
okay, so it does work, but i would like it to play out the animation of the punch before directly going to the next room, the problem being that when i press x it immediantly goes to the next room anyway to do that?
 
In addition to your code above, use image_index to get the current animation frame. Bear in mind image_index can be fractional, so use >= rather than ==.
 
Top