Jump to content


Photo

Physics


  • Please log in to reply
71 replies to this topic

#61 Barling

Barling

    GMC Member

  • New Member
  • 122 posts

Posted 17 March 2012 - 09:37 PM

Replaced "main" with 0 and it still doesn't collide.
My circle just passes through.
  • 0

#62 chance

chance

    GMC Member

  • Reviewer
  • 5773 posts
  • Version:GM:Studio

Posted 17 March 2012 - 10:08 PM

Replaced "main" with 0 and it still doesn't collide.
My circle just passes through.

rtfm.

The values that can be assigned are based on positive or negative numbers, with 0 being the default value (meaning that the instance with this fixture setting is ignored unless a collision event is created for it).


Try using 1.
  • 0

#63 Barling

Barling

    GMC Member

  • New Member
  • 122 posts

Posted 18 March 2012 - 12:36 AM

I didn't actually read that because I read somewhere that the physics wasn't even documented yet.
Anyways, thanks its working.

Just one tiny little problem.
I hate having to set all of my sprites to center origin when using a fixture in place of it.

Here's how I set up a fixture for my 16x16 block:
physics_fixture_set_box_shape(blockFixture, sprite_get_width(sprite_index) / 2, sprite_get_height(sprite_index) / 2);

I want my box shape setup so that it's origin is 0,0 (or just the origin of my sprite_index).
Now the code above makes it the correct size, however it's displaced to the left and top a bit,
and I want it to be dead at 0,0 so it fits perfectly over my 16x16 block.

How would I do this?
  • 0

#64 Spector_Slayor

Spector_Slayor

    GMC Member

  • New Member
  • 81 posts

Posted 18 March 2012 - 02:54 AM

Edit: Known bugs:
- The game crash when trying to create the 513rd entity (The borders in the example count as 4)
- Does not work in a browser, sadly.


Fun example, thx for the post. I managed over 3,000 water entities so I'm assuming they raised/removed the limit as of the last GM:S update?

Edited by Spector_Slayor, 18 March 2012 - 03:19 AM.

  • 0

#65 JumpMan16

JumpMan16

    GMC Member

  • GMC Member
  • 219 posts
  • Version:GM:Studio

Posted 18 March 2012 - 08:46 AM

First off, the documentation for the physics functions is good, very easy to understand. I'm grateful.

I just started playing with the physics a couple days ago, I'm making a pinball game, and as a fun project, a Metroid Morphball game :D. One thing I ran into was with double bomb jumping. To make the exploding bomb affect the morphball, i just apply an impulse upwards on the morphball if it is close enough to the bomb, this works fine when the ball is at rest, or rolling horizontally. However when it's in the air, and a bomb explodes, the ball only jumps higher if it hasn't already started to fall from gravity, which makes it really hard to actually do a proper double bomb jump. Ideally, I'd like to be able to just add the falling speed of the ball to the impulse to counter gravity and make it act more like the less realistic physics in metroid games. To do that I need a way to get the current speed or vspeed or something. I'll probably just make a script for this, but if there was a function for returning velocity, or if those values were just passed to the already existing speed/vspeed etc variables when an object is using physics, that'd be helpful.

I'm having great fun with this though, and also impressed that it works without problems on my android phone.
  • 0

#66 superx140

superx140

    GMC Member

  • GMC Member
  • 51 posts

Posted 18 March 2012 - 11:41 AM

First off, the documentation for the physics functions is good, very easy to understand. I'm grateful.

I just started playing with the physics a couple days ago, I'm making a pinball game, and as a fun project, a Metroid Morphball game :D. One thing I ran into was with double bomb jumping. To make the exploding bomb affect the morphball, i just apply an impulse upwards on the morphball if it is close enough to the bomb, this works fine when the ball is at rest, or rolling horizontally. However when it's in the air, and a bomb explodes, the ball only jumps higher if it hasn't already started to fall from gravity, which makes it really hard to actually do a proper double bomb jump. Ideally, I'd like to be able to just add the falling speed of the ball to the impulse to counter gravity and make it act more like the less realistic physics in metroid games. To do that I need a way to get the current speed or vspeed or something. I'll probably just make a script for this, but if there was a function for returning velocity, or if those values were just passed to the already existing speed/vspeed etc variables when an object is using physics, that'd be helpful.

I'm having great fun with this though, and also impressed that it works without problems on my android phone.



I think you can use the built in varibles phy_speed_y and phy_speed_x to get the speed. More phy_ varibles exist.
  • 0

#67 alexfislegend

alexfislegend

    GMC Member

  • GMC:Member
  • 196 posts
  • Version:GM:Studio

Posted 18 March 2012 - 04:57 PM

I didn't actually read that because I read somewhere that the physics wasn't even documented yet.
Anyways, thanks its working.

Just one tiny little problem.
I hate having to set all of my sprites to center origin when using a fixture in place of it.

Here's how I set up a fixture for my 16x16 block:

physics_fixture_set_box_shape(blockFixture, sprite_get_width(sprite_index) / 2, sprite_get_height(sprite_index) / 2);

I want my box shape setup so that it's origin is 0,0 (or just the origin of my sprite_index).
Now the code above makes it the correct size, however it's displaced to the left and top a bit,
and I want it to be dead at 0,0 so it fits perfectly over my 16x16 block.

How would I do this?


I am in the same boat. I would like to keep my wall objects at an origin of 0,0 ... so I came up with this solution:

physics_fixture_set_polygon_shape(blockFixture);
physics_fixture_add_point(blockFixture, 0, 0);
physics_fixture_add_point(blockFixture, sprite_width, 0);
physics_fixture_add_point(blockFixture, sprite_width, sprite_height);
physics_fixture_add_point(blockFixture, 0, sprite_height);

Drop the above code in place of your current code listed below:

physics_fixture_set_box_shape(blockFixture, sprite_get_width(sprite_index) / 2, sprite_get_height(sprite_index) / 2);


#68 JumpMan16

JumpMan16

    GMC Member

  • GMC Member
  • 219 posts
  • Version:GM:Studio

Posted 18 March 2012 - 06:00 PM

I think you can use the built in varibles phy_speed_y and phy_speed_x to get the speed. More phy_ varibles exist.


Oh. Thanks.
  • 0

#69 Barling

Barling

    GMC Member

  • New Member
  • 122 posts

Posted 18 March 2012 - 08:18 PM

Request: Could someone possibly make a platformer example
with the physics engine?
  • 1

#70 gamedevmasta

gamedevmasta

    GMC Member

  • New Member
  • 2 posts

Posted 20 March 2012 - 03:42 AM

As per your request:

Simple Platformer

It took me a bit to get use to how the system works, but it seems to work very well and is quite fast for what it accomplishes.

Note: I only put in some basic comments to help guide..

Edited by gamedevmasta, 20 March 2012 - 03:43 AM.

  • 1

#71 JumpMan16

JumpMan16

    GMC Member

  • GMC Member
  • 219 posts
  • Version:GM:Studio

Posted 21 March 2012 - 05:21 AM

I'm trying to create the flippers in a pinball game. I tried using a revolute joint, but I'm not sure how to get the flipper fixture to rotate properly to fling balls around. Suggestions?
  • 0

#72 alexandervrs

alexandervrs

    GMC Member

  • GMC Member
  • 423 posts
  • Version:GM:Studio

Posted 09 May 2012 - 11:09 AM

As per your request:

Simple Platformer

It took me a bit to get use to how the system works, but it seems to work very well and is quite fast for what it accomplishes.

Note: I only put in some basic comments to help guide..


Physics sure do making a platformer an easy feat. However in your example I couldn't see how I could remove the "sliding" of the player when he moved left or right.
I used physics_fixture_set_restitution(myPlayer, 0); to omit the bouncing but I couldn't stop the player on the spot while moving.
I tried using physics_fixture_set_friction(myPlayer, 100); with all kinds of values but it seems it has no effect. Also there doesn't seem to be a phy_friction value.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users