Build Man
Member
I have adapted changes made by TheouAegis regarding interaction with tiles. Then I copied some of those changes and transferred them to other objects with physics.
Here is some code:
Step Event
wall_parent collision code
For enemies, I have copied Collision code, minus friction thing. For fireball... Well, same thing.
And now after I did those changes, fireballs freeze the game when they collide with vertical wall.
The same goes for enemies in their damaged state when they hit a wall.
Just so you know, here is the full information for fireball:
And here is just a part of Fungus enemy's coding:
Here is some code:
Step Event
Code:
while place_meeting(x+hspeed,y,wall_parent)
{
hspeed = round(hspeed);
hspeed -= sign(hspeed);
}
Code:
y -= vspeed;
while place_meeting(x,y+vspeed,wall_parent)
vspeed -= sign(vspeed);
y += vspeed;
vspeed = 0;
friction = 0.6;
And now after I did those changes, fireballs freeze the game when they collide with vertical wall.
The same goes for enemies in their damaged state when they hit a wall.
Just so you know, here is the full information for fireball:
Code:
Information about object: Fireball
Sprite: Proj_Fireball
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Create Event:
execute code:
image_xscale = Protagonist.image_xscale
hspeed = image_xscale*9
execute code:
projectiles -= 1
Destroy Event:
execute code:
instance_create(x,y,Fireball_Particle)
if projectiles < 2
projectiles += 1
Step Event:
if at relative position (0,1) there is object wall_parent
set the gravity to 0 in direction 270
set the vertical speed to -7
else
set the gravity to 1 in direction 270
execute code:
if (bbox_right < view_xview[0] || bbox_left > view_xview[0]+view_wview[0] || bbox_bottom < view_yview[0] || bbox_top > view_yview[0]+view_hview[0])
{
instance_destroy();
}
Collision Event with object wall_parent:
execute code:
//Vertical Collision
y -= vspeed;
while place_meeting(x,y+vspeed,wall_parent)
vspeed -= sign(vspeed);
y += vspeed;
vspeed = 0;
execute code:
if place_meeting(x+hspeed,y,wall_parent)
instance_destroy()
Code:
Information about object: Fungus
Sprite: Enemy_Fungus
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: <no parent>
Mask: <same as sprite>
Create Event:
execute code:
enemy_health = 10
Step Event:
if at relative position (0,1) there is object platform_parent
set the gravity to 0 in direction 270
execute code:
if enemy_health <= 0 && vspeed = 0
{
instance_create(x,y,Knockout)
instance_destroy()
score += 100
}
set the sprite to Enemy_Fungus with subimage image_index and speed 0.3
else
set the gravity to 1 in direction 270
execute code:
if image_xscale = -1 && sprite_index = Enemy_Fungus
hspeed = 1
if image_xscale = 1 && sprite_index = Enemy_Fungus
hspeed = -1
execute code:
if place_meeting(x,y-16,Protagonist) && Protagonist.vspeed > 2 && Protagonist.sprite_index != Mako_Damaged && enemy_health != 0
{
with Protagonist{vspeed = -18}
sprite_index = Enemy_Fungus_Damaged
vspeed = -9
hspeed = 0
enemy_health -= Protagonist.normal_dmg
}
End Step Event:
execute code:
//Horizontal Collision
if (place_meeting(x+hspeed,y,wall_parent))
{
while(!place_meeting(x+sign(hspeed),y,wall_parent))
{
x += sign(hspeed);
}
hspeed = 0;
image_xscale = -image_xscale
}
Collision Event with object wall_parent:
execute code:
//Vertical Collision
y -= vspeed;
while place_meeting(x,y+vspeed,wall_parent)
vspeed -= sign(vspeed);
y += vspeed;
vspeed = 0;
After many more attempts at making enemy react to collision with vertical wall properly, I have pretty much abandoned all hope at fixing it myself. Nothing ever makes it work properly. Ever.
If you are new to this thread, and do not get what I am saying about, here is the video of what is happening:
This should not be happening. The enemy should not suddenly reappear on the top of the pillar and only then get knocked out. The enemy should stop moving horizontally if it touches the wall and fall down the floor. This gets especially problematic with enemies that are not one-hit point wonders.
I do not know what to try anymore. Nothing ever worked so far. Only with the help of other can I solve this.
If you are new to this thread, and do not get what I am saying about, here is the video of what is happening:
This should not be happening. The enemy should not suddenly reappear on the top of the pillar and only then get knocked out. The enemy should stop moving horizontally if it touches the wall and fall down the floor. This gets especially problematic with enemies that are not one-hit point wonders.
I do not know what to try anymore. Nothing ever worked so far. Only with the help of other can I solve this.
Last edited: