So in my game, when a player hits a wall with a weapon, it makes a spark when and where the player hits wall. In the following code, everything works as intended EXCEPT that the spark is never made at the right y coordinate (i in the for loop). The sprite stops at the good time (ie it doesn't enter the wall (that code is in the alarm[0] and works well)) BUT the spark (ob_1_loop_effect) is created at the right X, but not at the right Y. Especially when hitting the lower portions of the wall, the spark is created in the upper section of the wall. The origin of my sprite wall is 0.0 and changing it from that only worsens the problem.
THIS CODE IS IN THE WEAPON OBJECT
Thank you for your help
THIS CODE IS IN THE WEAPON OBJECT
GML:
if ob_player.stance == 1//spark wall slash on wall when in katana form
{
if image_index > 1
{
if place_meeting(x,y,ob_wall)
{
wall = instance_nearest(x,y,ob_wall)
if x < wall.x
{
var i
for (i = wall.bbox_top-96; i < wall.bbox_bottom-96; i += 1) //I FOUND THAT ADDING -96 (sprite height) TO EACH HELPS, WITHOUT THAT THE SPARK IS ALWAYS CREATED AT THE BOTTOM OF THE WALL
{
if place_meeting(wall.bbox_left,i,ob_wall) //TRIED collision_point WITH THE SAME RESULTS
{
if alarm[0] < 0
{
alarm[0] = 1.5/ob_player.image_speed
spark = instance_create(wall.bbox_left,i,ob_1_loop_effect)
spark.image_speed = 0.5
spark.sprite_index = spr_wall_slash_spark
spark.depth = ob_wall.depth-1
}
}
}
}
}
}
}
Thank you for your help
Last edited: