Author Topic: Block player can push  (Read 994 times)

TattooGeek

  • Member
  • **
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Block player can push
« on: Tue, Aug 3, 2010 »
Hi

Iam creating a 2d platformer and I want my character to be able to push blocks left and right.  I want the block to travel half the speed as the player so the movement looks as though the block is heavy.

I have extended the FlxSprite class, over written the hitLeft and hitRight functions and tried modifying the velocity and drag within these functions but I just cant get it right.  The block movement is either jumpy, extremely slow, or the block continues to move by itself after the player has stopped pushing on it.

Iam really stuck on this one, any ideas?

zez

  • Active Member
  • ***
  • Posts: 203
  • Karma: +0/-0
    • View Profile
    • Devlog
Re: Block player can push
« Reply #1 on: Wed, Aug 4, 2010 »
drag.x is your friend in this case. You could probably even use the normal collision code, cap velocity.x at something low (maxVelocity.x = 50 or something;) set drag.x to something around the maxVelocity.x and let flixel do the rest.

TattooGeek

  • Member
  • **
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: Block player can push
« Reply #2 on: Sun, Aug 8, 2010 »
thanks for the tip zez, I got it moving but its a little jittery, guess I will just have to keep tweaking number till I get it nice.