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

Grinding Trouble in GM6.1???


Recommended Posts

I seem to have trouble making Sonic grind on a rail object. I am currently using Damizean's engine(Pack of Stuff Beta). And I've been trying to do this for months but no luck at all so if anyone can help me that will be great?

When Sonic runs or jumps onto a rail I want him to change to action_grind and move across the rail at a certain speed. Can anyone show me how to do this? thx

Link to comment
Share on other sites

What methods have you tried and what happens as a result? May help in getting you some assistance, you know.

I tried something like this but it is way wrong. But I made an object called objGrind so I could use it as a parent for all the rail objects. and the script I tried to figure out went like this:

if ( player_collision_bottom( x, y, objGrind)) 
{
//Start Grinding
action = action_grinding;
//speed
layer = 2;
}
else if( action == action_grinding )
{
//Stop Grinding
layer = 0;
action = action_grindfall;
}[/CODE]

Thats all I got. And it does'nt work at all. Does anyone know a way to add grinding to the 360 engine with GM?

Link to comment
Share on other sites

I'm not sure which version of Dami's engine you're using nor can I recall how they all work off-hand, but if you're trying to add a new layer, I'm pretty sure you have to edit every collision statement to have the new layer, perhaps including a new constant which'll be the next higher power of 2.

Link to comment
Share on other sites

Here is the link to his (new pack). This is from GMC...

http://forums.gamemaker.nl/index.php?showtopic=99044

I'm not sure which version of Dami's engine you're using nor can I recall how they all work off-hand, but if you're trying to add a new layer, I'm pretty sure you have to edit every collision statement to have the new layer, perhaps including a new constant which'll be the next higher power of 2.

Thats what I don't get how to do.:confused: Can anyone help me?

Link to comment
Share on other sites

Haven't had time to look at Dami's engine, but couldn't you just use a modified form of the code for slopes? Like, when Sonic collides with the rail, activate the copied slope code, and set his speed to whatever you want it to be. Then, when you just off or whatever, deactivate the modified slope code.

Link to comment
Share on other sites

if(argument2==2) return place_meeting(argument0,argument1,objGrind);

else

{

return place_meeting(argument0,argument1,objSolid);

if(argument2==0) return place_meeting(argument0,argument1,objLow);

else return place_meeting(argument0,argument1,objHigh); }

I started something like this for grinding which was a script based off of the objPlatform script.

Link to comment
Share on other sites

Haven't had time to look at Dami's engine, but couldn't you just use a modified form of the code for slopes? Like, when Sonic collides with the rail, activate the copied slope code, and set his speed to whatever you want it to be. Then, when you just off or whatever, deactivate the modified slope code.

It's a little more complicated than that...At least I think it is.

Link to comment
Share on other sites

If we want to have grinding wich should be activated when landing after a jump, and only while pressing the B action key, we just need a way to activate/deactivate collision with them easily. If you want a quick way to activate/deactivate stuff, you can have a parent objGrindingGround object wich parent is a objParentTerrainone, and at creation event stores the mask index on a variable, like this:

InitialCollisionMask = mask_index;

After this, we create a transparent 1x1 sprite called something like sprCollisionMaskTransparent. By doing this, we now can toggle collision activation/deactivation at our will by just changing Grinding object's mask_index to the transparent collision mask. We will use this for grinding. Before the Sonic movement starts, we need to activate or deactivate the collision with the grinding objects. We can do this using a routine something like this:

objGrindingGround.mask_index = sprCollisionMaskTransparent;
if ((Ground == false && Gravity >= 0 && Action == consActionJumping && KeyActionB) || (Ground == true && Action == consActionGrinding))
    objGrindingGround.mask_index = InitialCollisionMask;

Now it's only up to us to check wether when Sonic should activate the grinding action. We can do something as follows, on jumping's action routine:

if (Gravity >= 0 && scrPlayerCollisionBottomObject(Angle, 1, objGrindingGround)==true) {
    Action = consActionGrinding;
}

And to make sure we're on the grinding ground, we can check this on grinding routine.

if ((Ground == false) || (scrPlayerCollisionBottomObject(Angle, 1, objGrindingGround)==false)) {
    Action = consActionNormal;
}

Now the rest is just setting the speed to a value and well, I leave that up to you.

P.S.: These codes are in the Xmas Engine form, wich is definately the most organizated one and the one I currectly encourage to use in your projects, you might want to update your stuff to it :3. Anyway, adapting this to the previous ones, shouldn't be much hard.

Link to comment
Share on other sites

@ Damizean: This is my attempt to convert your scripts for the xmas pack to one of your older engines and here is was:

objGrindingGround.mask_index = sprCollisionMaskTransparent;
if ((ground == false && y_speed >=0 && action == action_jumping && key_melee) || (ground == true && action == action_grinding))
objGrindingGround.mask_index = InitialCollisionMask;

//Start Grinding
if (y_speed >= false && player_collision_bottom(angle, 1, objGrindingGround) == true) {
action = action_grinding;
x_speed += 3;
}
//Stop Grinding
if ((ground == false) || (player_collision_bottom(angle, 1, objGrindingGround) == false)) {
action = action_normal;
}
[/CODE]

But somethings wrong, when sonic jumps he does'nt turn into a ball/action_jumping instead he jumps with the animation action_normal which is wierd. Is there something wrong with my script?

EDIT: This is what I did for [b]objGrindingGround[/b] too:

[CODE]InitialCollisionMask = mask_index;[/CODE]

with the parent of [b]objSolid[/b] since your older engine does'nt use [b]objParentTerrain[/b]

Link to comment
Share on other sites

I think because all the scripts Dami gave you are in the same script. I forgot what I did so I did'nt test it yet. Dami do you think you can help him out so this topic can end already.

It pretty much seems like that. Activation/Deactivation of collision for grinding should go before the engine does the movement of Sonic.

Link to comment
Share on other sites

Maybe try using the code in the Begin Step Event of objSonic. I think that would work.

EDIT: I just tryed out what I sayed the jumping seems to be working fine but I can't spin dash and the grinding does'nt work.

EDIT2: Yeah it is the same when I put the code in the Begin Step event. I just don't whats up.

Hey Damizean what if I was able to make a duplicate copy of the collision scripts and make a parent object called objSolidGrind and when in contact with objSolidGrind the animation turns into action_grind and when not on objSolidGrind then the animation is normal?

Link to comment
Share on other sites

It does the samething for me too. So there is still something wrong. Here is my modified code:

objGrindingGround.mask_index = sprCollisionMaskTransparent;

if ((ground == false && y_speed >=0 && action == action_jumping && key_melee_pressed) || (ground == true && action == action_grinding))
objGrindingGround.mask_index = InitialCollisionMask;
Start Grinding
if (y_speed >= false && player_collision_bottom(angle, 1, objGrindingGround) == true) {
action = action_grinding;
x_speed += 3;
}
Stop Grinding
if ((ground == false) || (player_collision_bottom(angle, 1, objGrindingGround) == false)) {
action = action_normal;
}[/CODE]

Link to comment
Share on other sites

  • Recently Browsing   0 members

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