Jump to content
A 2021 backup has been restored. Forums are closed and work in progress. Join our Discord server for more updates! ×
SoaH City Message Board

Trouble with Wall Kicking in Damizean's engine?


Recommended Posts

I'm trying to implement Wall kicking in my Sonic game using the (new pack) Sonic engine. Well what I'm trying to do is that when Sonic if near a wall and action == action_jumping and collision with objSolid his animation changes to action = action_wallkick and he goes in the reverse direction/speed. A good example Shinobi 3 for SEGA Genesis. I am really having problems with doing this. Can anyone help me with this? I will give credit, also here is the script:

if( action==action_jumping && key_up && key_melee && player_collision_left(x,y,0,maskBig) == true ) 
{
//wall jump from left wall
animation_direction = 1;
action = action_wallkick;
x_speed = x_speed*0.5;
y_speed = -6;

}
if( action==action_jumping && key_up && key_melee && player_collision_right(x,y,0,maskBig) == true )
{
//wall jump from right wall
animation_direction = -1;
action = action_wallkick;
x_speed = x_speed*-0.5;
y_speed = -6;

}
[/CODE]

I think the x/y_speed is wrong too, this script is really screwed.:confused:

Link to comment
Share on other sites

I don't see anything wrong with you're code. Are you sure action is set to action_jumping when you want it to and that you're pressing up and melee (use the debug mode to watch the variables)? Does the code work at all; what does it do right and what does it do wrong and how does it do it wrong?

Link to comment
Share on other sites

I think I see what's wrong: he's changing the x_speed to it's negative self without taking in count that when the left/right sensors collide with a wall, the x_speed is set to 0. That might be the problem

Edit: Typo. My english skills sucks

Link to comment
Share on other sites

Ah, I see. I thought it said xspeed = +-0.5, not xspeed = xspeed*(+-5).

It's probably better to set it to a constant value (like 4 and -4) than making it depend on the horizontal speed anyway. But if you manage to do it without stopping on the wall, they should both be xspeed = xspeed * -0.5, since they'd both need to change directions. Your code still should make you go up, just not left or right.

Link to comment
Share on other sites

Place the following right above "// move the player outside in case he has got stuck into the wall":

if ( player_collision_right( x, y, global.gravity_angle, maskBig ) == true
&& y_speed >= 0 && !ground && key_action_pressed ) 
{
    animation_direction = -1;
    x_speed = top_x_speed/1.5 * animation_direction;
    y_speed = -4.6875;
    action = action_wallkick;
    <play sound here>
}
if ( player_collision_left( x, y, global.gravity_angle, maskBig ) == true
&& y_speed >= 0 && !ground && key_action_pressed ) 
{
    animation_direction = 1;
    x_speed = top_x_speed/1.5 * animation_direction;
    y_speed = -4.6875;
    action = action_wallkick;
    <play sound here>
}

The checks are done in their own individual cases, even though it would seem more efficient to merge the repetitive parts together, because the player can change animation_direction mid-check using the directional keys, and disabiling those keys would also disable the player's abillity to move after the wallkick.

Link to comment
Share on other sites

The only thing the code does right is that his animation changes to action_wallkick. He does'nt kick off the walls like he is supposed too. And that is what I am having major trouble on.

The only problem with your code is that it's acting on variables that'll almost always be 0. Also, in the wall jump from left, you should also be multiplying by 0.5.

You have two choices in fixing it:

-The first is putting the code (with 0.5 changed to -0.5 in "wall jump from left wall") right where AeroGP said (i.e. after the horizontal movement but before the get out of wall movement).

-The second choice is to change "x_speed = x_speed*0.5" to "x_speed = 4" or so and "x_speed = x_speed*-0.5" to "x_speed = -4".

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...