How to make a player ride on top of a box/platform?

pxlpfctpxlpfct Member Posts: 37
edited April 2012 in Working with GS (Mac)
Hello! I'm making a game where one of the way for the player to move is for the player to jump on top of a block. In this game magnetic charges can be shot at blocks and walls, so the way you would move is having standing on top of the block and shooting the magnetic charges in a way so that the block would be attracted to a wall. Anyways, I'm achieving this magnetic effect with move towards and it works great, but I'm having a problem with the above said way of movement. The problem is that because the player has a mass of more than 0 it weighs down the block and it can only move horizontally and I need to move both horizontally and vertically. Ok, great, I set the mass to zero, but now since its technically not colliding with the block it goes to the jumping animation and falls off the block. I've tried ways of constraining the x and y of the block and making the player's x and y equal them with the player having a mass of zero but that doesn't work either. This was probably confusing, so let me sum this up quickly.
I need to have a player travel on horizontally and vertically moving blocks without falling off.
These blocks are moving with a move towards behavior.
The player's mass is weighing down the vertical movement.
Making the mass 0 creates more problems.
Thanks!

Answers

  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    Im not 100% but I think gshelper.com as a video about this

  • pxlpfctpxlpfct Member Posts: 37
    No, sorry, there is a video with a title which would make you think so but it doesn't tell you how to do what I wanted. Any other ideas?
  • jckmcgrawjckmcgraw Member Posts: 647
    @pxlpfct

    First of all, is having 0 mass causing problems on or off the blocks, or just while on them? If it is causing problems if they are only off the blocks, then try this...

    Create a boolean att called game.blocks (or whatever)
    Rule: When character overlaps or collides with block, change att game.blocks to true
    When att game.blocks = true, change mass to 0
    Otherwise, change mass to whatever it was before.

    If this doesn't work I would need a little bit more explaining on the problem with having no mass.

    Hope this helps,
    Jack McGraw
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    @jckmcgraw

    Physics attributes cannot be changed in game.
  • pxlpfctpxlpfct Member Posts: 37
    The 0 mass is having problems on the block, it doesn't matter off, but thank you anyways.
  • pxlpfctpxlpfct Member Posts: 37
    It just kind of floats off because the block is pushing the actor up.
  • jckmcgrawjckmcgraw Member Posts: 647
    @JohnPapiomitis

    Really? That's a bummer... I had no idea.

    Sorry @pxlpfct I guess my idea wouldn't work at all. If I can think of something else later today, I'll post another comment.

    Jack McGraw
  • pxlpfctpxlpfct Member Posts: 37
    Alright, thanks, I'll do some more experimenting of my own.
  • LiquidGameworksLiquidGameworks Anchorage, AKMember, Sous Chef Posts: 956
    Does your block move to wherever you shoot your "magnetic charge"? If so, maybe you should try interpolating your block to the position of the charge (you'll need two interps, x and y). If you use interpolate instead of move, you can uncheck the "movable" in physics, so you won't have to worry about mass and whatnot.
  • pxlpfctpxlpfct Member Posts: 37
    thank you! Will try!
  • pxlpfctpxlpfct Member Posts: 37
    edited April 2012
    @LiquidGameworks how do I get it to move away from a point with interpolate? Also, it moves through the wall for a second now before recognizing the collision
  • CluvCluv Member Posts: 229
    @pxlpfct: Do they have to move both horizontally and vertically at the same time? If not, then you might want to set up a boolean with different physic parameters based on what works in each case. That way, when you "change gravity," the physics changes as well.

    In other words:
    boolean_horizontal_gravity is "on" with all the normal physics.

    man "shoots" grav-gun, sets boolean_horizontal_gravity to "off" with modified physics.

    I wish I knew the physics engine a bit better. I'm new to the game, but it seems to me that you have two different cases you are trying to marry into one. If you try to separate your cases, you might find a solution.
Sign In or Register to comment.