Sign in to follow this  
Followers 0
Zonar Games

Grinding Help in Damizean's engine(Game Maker)

8 posts in this topic

I have been working on a script a couple of weeks ago for grinding but something is off. Ok first I created an object called objGrind(which is the parent) and used the platform example Damizean released here on these forums called layering + platform. But I copyed player_collision and made it for grinding. I wanted when the player is holding key_melee and player_collision_bottom with the rail he changes to action_grinding and moves across the rail. Here is the script for player_collision_rail:

    
// player_collision(x, y, layer)
if (place_meeting(argument0, argument1, objSolid)) return true; // Check for normal solid
if (place_meeting(argument0, argument1, objGrind)) return true; // Check for platform (without needing to be in ground)
if (argument2 == 0) return place_meeting(argument0, argument1, objLow); // Check for low layer
else return place_meeting(argument0, argument1, objHigh); // Check for high layer[/CODE]

And here is the code that goes in the step event for Shadow:

[CODE]if ( key_melee && ground = false ) == true
{
if ( player_collision_bottom( x, y, 0) && place_meeting(x,y,objGrind) ) == true
{
action = action_grinding;
sound_play(Grind);
}
}
[/CODE]

Whats wrong with my code? Something has to be off.:confused:

[b]Below is a double post that has been automagically merged into the original.[/b]

Can anyone help me?

Share this post


Link to post
Share on other sites

What happens with your error?...

Hey? what do you mean about this:

( player_collision_bottom( x, y, 0)

what is the object ''0''? This function works in this way: player_collision_bottom( x axis, y axis, object)

Share this post


Link to post
Share on other sites

Wait a sec I think you just found something I missed. I screwed that line up.

it would be something like this:

if ( player_collision_bottom( x, y, objGrind)) = true[/CODE]

*EDIT* Man it still is not working for me I tryed changing it a little but and he is still not colliding with the rail.:confused:

Share this post


Link to post
Share on other sites

in all technicality couldnt you just make 2 parents (one with a parent of objhigh and one with parent of objlow) for the grind rail and if your on the rail every step just multply the x_speed/hsp by something like 1.02 or so and let the existing engine do all the angling and positioning along with the rail

Share this post


Link to post
Share on other sites

I think I have an idea! Maybe for the rail objects their parent can be objPlatform that way if the bottom_sensor collides with the rail he changes to his grinding animation and maybe use the slope variable to move him. But I don't know how to put the code together.

EDIT: None of my code is working! It does the same thing. He does'nt collide with the rail. I have been working on this for 3 days straight. And the same stuff happens. What the hell could be wrong with my code?

Share this post


Link to post
Share on other sites

Actually, it's a tiny bit more complicated than this. And judging from you're code, Dami's slightly changed his layering engine since the old versions, so it'll be even more complicated. If you understand the way his layering works, however, you can easily create any sort of layer (including a grinding layer) to create 360 degree movement without needing to understand anything about how 360 degree engines work.

To create an independent grinding layer using the build in functions, the idea is to (whenever you're on the grinding layer) check for objGrind objects and only objGrind objects. The problem with the code you've posted is twofold: the fist problem is that the code checks for collision with objSolid, no matter what the layer argument is set to; the second problem is that the previous code is designed for two different types of layers (high=1 and low=0) and you need one that suports three (high=1, low=0, and grind=2 or something).

The first step is to individually change every collision code to where it checks only for objGrind if layer=2 and if layer!=2, check for objSolid then if layer=0, check for objLow/if layer=1, check for objHigh. Logically, that'd look like this:

if(argument2==2) return place_meeting(....,objGrind);
else
{
   return place_meeting(....,objSolid);
   if(argument2==0) return place_meeting(....,objLow);
   else return place_meeting(....,objHigh);
}

//Note that the .... should be the same for each and is the
//same as it was before you changed the code

That's using (from what I can tell), the method you have. Though, I'm not 100% familiar with the particular engine make you're using, so a link would help.

Once you've fixed all the collision functions to incorperate the grinding layer, the coding's pretty simple:

if ( player_collision_bottom( x, y, objGrind))
{
    //Start Grinding

    action = grinding;
    //set speed
    layer = 2;
}
else if( action == grinding )
{
    //Stop Grinding

    layer = 0;
    action = falling_out_of_grind;
}

And that code can go just about anywhere in a step event. (Note, though, that I'm assuming much in this engine, so I'd love to see the version you're using).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0