News:

FOR INFORMATION ON DONATIONS, AND HOW TO OBTAIN ACCESS TO THE GAME, PLEASE VIEW THE FOLLOWING TOPIC: http://stick-online.com/boards/index.php?topic=2.0

Main Menu

Game Maker gravity issue =(

Started by WereWaffle, March 27, 2011, 05:35:34 PM

Previous topic - Next topic

WereWaffle

I've been waiting forever trying to figure out how to get GOOD grvity in game maker but i can never get gravity like in stick online  :'(
And Whenever I look at videos on youtube the gravity is REALLY bad and i can walk while in the air.
Does anybody know how to get gravity exactly like stick online?
Please help!

T-Rok

#1
There are many ways to do gravity. This one comes to mind right now. Probably not the best way, but you sound like you just need something to get you started.


if place_meeting(x,y+vspeed,objGParent)
{
move_contact_solid(direction,gravfall)
gravity=0
vspeed=0
jump=1
}

direction is a built in variable.
gravfall can (and you should in your case) be replaced with a number, usually 12.
vspeed is a built in variable.
gravity is a built in variable as well.
objGParent is a solid object with a black line for a sprite.

WereWaffle

Quote from: T-Rok on March 27, 2011, 05:59:13 PM
There are many ways to do gravity. This one comes to mind right now. Probably not the best way, but you sound like you just need something to get you started.


if place_meeting(x,y+vspeed,objGParent)
{
move_contact_solid(direction,gravfall)
gravity=0
vspeed=0
jump=1
}

direction is a built in variable.
gravfall can (and you should in your case) be replaced with a number, usually 12.
vspeed is a built in variable.
gravity is a built in variable as well.
objGParent is a solid object with a black line for a sprite.
What???????can you give it to me step by step please? but a little simpler?

T-Rok

Please don't PM me and post in the topic.

Create your player object. In the step event add this code


if place_meeting(x,y+vspeed,objGround)
{
move_contact_solid(direction,12)
gravity=0
vspeed=0
}


Now create your ground object, it needs a sprite that is a line, something around 680x1 should work fine. Make it solid and place it in the room with the player object.

That should be it.

WereWaffle

Quote from: T-Rok on March 27, 2011, 06:33:52 PM
Please don't PM me and post in the topic.

Create your player object. In the step event add this code


if place_meeting(x,y+vspeed,objGround)
{
move_contact_solid(direction,12)
gravity=0
vspeed=0

}


Now create your ground object, it needs a sprite that is a line, something around 680x1 should work fine. Make it solid and place it in the room with the player object.

That should be it.
it says: Error in code at line 1:
   if place_meeting(x,y+vspeed,objGround) can you help?

T-Rok

did you name your ground object to objGround?

WereWaffle


WereWaffle

Quote from: T-Rok on March 27, 2011, 06:52:58 PM
did you name your ground object to objGround?
I Did that and he still hovers!  :'(

T-Rok

Ohh, hahaha, I forgot to turn on gravity. Sorry about that.


if !place_meeting(x,y+1,objGround)
{
jump=0;
sit=0;
gravity=1.2;
}


That goes in the same step event as the other.

WereWaffle

Quote from: T-Rok on March 27, 2011, 07:20:50 PM
Ohh, hahaha, I forgot to turn on gravity. Sorry about that.


if !place_meeting(x,y+1,objGround)
{
jump=0;
sit=0;
gravity=1.2;
}



That goes in the same step event as the other.
Are there any better ones that dont make you go through a bunch of the objects?
And my guy can infinatley jump and he can walk in the air!
also when i hit the groun he is still in the jump sprite  :'(
Are there any other ones that are like stick online?

T-Rok

...I'm done. This is not the place for such questions. You're not even attempting to learn it yourself. Please refer to http://gmc.yoyogames.com/ for any further questions you have.

WereWaffle

Quote from: T-Rok on March 27, 2011, 07:27:42 PM
...I'm done. This is not the place for such questions. You're not even attempting to learn it yourself. Please refer to http://gmc.yoyogames.com/ for any further questions you have.
:'(
I Dont see why you couldnt just answer my question but ok  :'(

11clock

Game Maker requires a lot of practice in order to be good at it. I suggest reading some tutorials around the GMC. Also, read the manual.

JoEL

To do anything "like" stick online, you will need to learn the basics of GML. I suggest you look at tutorials and not request people to generate code for you. Copying and pasting code gets you no where. Look at the examples, read their comments and have a bit of a play with the functions.

krele

Quote from: JoEL on March 27, 2011, 09:57:31 PM
To do anything "like" stick online, you will need to learn the basics of GML. I suggest you look at tutorials and not request people to generate code for you. Copying and pasting code gets you no where. Look at the examples, read their comments and have a bit of a play with the functions.
Don't tell him what to do! He's going to create his own MMO! =P