Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by Richard

I'm trying to put a crate in my game world that my player can't walk into. However, I also don't want it to push the player around either.

My player entity is PASSIVE.

If I set the crate to ACTIVE (as suggested in the collision tutorial), then when I walk into it, it moves. I can push it along rather than it being solid.

If I set the crate to FIXED, then it doesn't move when I walk into it. However when it moves because I start changing it's velocity according to other game rules I have, it starts pushing my player along.

I want a crate that just sits there, like a solid object that the player can't pass through, but when moved towards the player, stops if it hits it.

I've tried various combinations of using check to resolve the collision between them and try changing the velocity of each, but can't seem to find the magic combination.

Somehow I want FIXED && LITE. :)

1 decade ago by Arantor

I'm not clear... under what circumstances can the crate move, exactly?

It sounds like it just needs to be FIXED and be done with it, and I'm not sure how the game rules should be giving it any kind of velocity.

However, entity-entity collision is still resolved even for FIXED items, so when the collision occurs, you can still take out the entity's velocity.

Assuming it's just collision with the player that will prevent the crate moving if it already has velocity, make sure the player entity is defined as a requirement for the crate entity, then make this the crate's check method:

  check: function (other)
  {
    if (other instanceof EntityPlayer)
    {
      this.vel.x = 0;
      other.vel.x = 0;
    }
  },

That way, both get stopped if the crate collides with the player, and FIXED will prevent the crate being moved by anything other than your game's rules (e.g. entity interaction)

1 decade ago by Richard

My player can "suck" the crate towards it. Which applies an acceleration to the crate.

Even with setting the velocity of both to 0 when they collide, both from the player entity POV, and the crate POV, as I sit and suck it bangs off my player entity and moves it 1 pixel every couple of seconds or so.

The other problem is when the crate pins the player up against a wall, the player then pops up and onto the top of the crate.

1 decade ago by Arantor

So when they collide make sure there's no acceleration and no velocity after the collision...
Page 1 of 1
« first « previous next › last »