Z
zoncxs
Guest
Hello all! I am new to Game maker studio and started my first project 2 weeks ago. I followed all the steps on heartbeast youtube channel (all 32 videos on the beginner tutorial).
Once I got that far I wanted to back step, that is to say undo the edits I made to my game following video 32. This is because that video makes it so that the sprites of the objects swap places, making it look like you are picking up an object (or weapon) without changing anything else.
video 31 shows you how to make an object animate with the player object, that is to say swing a weapon with the weapon being a separate object. This is where my issues come in.
I thought I undid everything to get to that point but for some reason I get a few glitches:
1- the object does not animate when I attack, instead it spawns the object.
2- swapping the objects causes the attack state to spawn a different object. for example, if I try to swap the sword for the axe, it instead swaps it for an enemy object.
3- none of the weapon objects that I place in the room are visible.
Here is what I have that I need to modify (note, the room uses physics):
OBJECTS
obj_player
obj_weapon_animation
obj_sword
obj_stick
obj_axe
SCRIPTS
scr_move_state
scr_attack_state
scr_swap_weapons
scr_animation_hit_frame
the obj_player has the variable "weapon = obj_stick" in its create event and is set to use physics.
the obj_weapon_animation has:
create event
dir = 0;
step event
if (image_angle >= dir-45) {
image_angle -= 15;
} else {
instance_destroy();
}
end step event
if(instance_exists(obj_player)) {
x = obj_player.x;
y = obj_player.y;
} else {
instance_destroy();
}
collision event
with wall and player
obj_sword obj_axe and obj_stick have the obj_weapon_animation as the parent and the correct sprites for them, and are set to use physics.
scr_move_state has:
//swap weapons on ground
if (obj_input.swap_key) {
var nearest_weapon = instance_nearest(x, y, obj_weapon_animation);
if (place_meeting(x, y+4, nearest_weapon)) {
scr_swap_weapons(nearest_weapon);
}
}
scr_attack_state has:
if (scr_animation_hit_frame(2)) {
var attack_animation = instance_create(x, y, weapon);
attack_animation.dir = face*90;
attack_animation.image_angle = (face*90)+45;
}
scr_swap_weapons has:
var new_weapon = argument0;
var temp = weapon;
weapon = new_weapon.sprite_index;
new_weapon.sprite_index = temp;
scr_animation_hit_frame has:
var frame = argument0;
return (image_index >= frame+1 - image_speed) and (image_index < frame+1);
I want to be able to swap the weapon objects because each weapon will have a different hitbox and stats.
Once I got that far I wanted to back step, that is to say undo the edits I made to my game following video 32. This is because that video makes it so that the sprites of the objects swap places, making it look like you are picking up an object (or weapon) without changing anything else.
video 31 shows you how to make an object animate with the player object, that is to say swing a weapon with the weapon being a separate object. This is where my issues come in.
I thought I undid everything to get to that point but for some reason I get a few glitches:
1- the object does not animate when I attack, instead it spawns the object.
2- swapping the objects causes the attack state to spawn a different object. for example, if I try to swap the sword for the axe, it instead swaps it for an enemy object.
3- none of the weapon objects that I place in the room are visible.
Here is what I have that I need to modify (note, the room uses physics):
OBJECTS
obj_player
obj_weapon_animation
obj_sword
obj_stick
obj_axe
SCRIPTS
scr_move_state
scr_attack_state
scr_swap_weapons
scr_animation_hit_frame
the obj_player has the variable "weapon = obj_stick" in its create event and is set to use physics.
the obj_weapon_animation has:
create event
dir = 0;
step event
if (image_angle >= dir-45) {
image_angle -= 15;
} else {
instance_destroy();
}
end step event
if(instance_exists(obj_player)) {
x = obj_player.x;
y = obj_player.y;
} else {
instance_destroy();
}
collision event
with wall and player
obj_sword obj_axe and obj_stick have the obj_weapon_animation as the parent and the correct sprites for them, and are set to use physics.
scr_move_state has:
//swap weapons on ground
if (obj_input.swap_key) {
var nearest_weapon = instance_nearest(x, y, obj_weapon_animation);
if (place_meeting(x, y+4, nearest_weapon)) {
scr_swap_weapons(nearest_weapon);
}
}
scr_attack_state has:
if (scr_animation_hit_frame(2)) {
var attack_animation = instance_create(x, y, weapon);
attack_animation.dir = face*90;
attack_animation.image_angle = (face*90)+45;
}
scr_swap_weapons has:
var new_weapon = argument0;
var temp = weapon;
weapon = new_weapon.sprite_index;
new_weapon.sprite_index = temp;
scr_animation_hit_frame has:
var frame = argument0;
return (image_index >= frame+1 - image_speed) and (image_index < frame+1);
I want to be able to swap the weapon objects because each weapon will have a different hitbox and stats.