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 coreysnyder

Here's a photos to show you what I'm working with: http://imgur.com/7RuSt

Now You can see I have a friendly units that I don't want running into each other:
* cannon
* a base (house)
* snowballs

Then I have enemy units which come from the right of the screen.

Now I want the weapons fired from the cannon to:
* Not run into the top of the house
* Not run into the cannon & cause screwy flight paths
* DO run into the enemies and trigger a collision

I want the enemies to:
* Do collide with my house & trigger a collision in the check method
* Do get hit my snowballs

I feel like I've tried every combination of:
type: ig.Entity.TYPE.B,
checkAgainst: ig.Entity.TYPE.A,
collides: ig.Entity.COLLIDES.PASSIVE,

The only problem I'm running into now is that my snowballs when fired downward, will roll across the top of the house. When I set the house to collides.NEVER then the enemies run right past the house instead of stopping to say hello!

Any advice would be greatly appreciated.

Thanks,
Corey

1 decade ago by Joncom

Just a guess, but wouldn't you want your Friendlies to be TypeA, your weapon-fire to be TypeA, and your enemies to be TypeB? My thought is that TypeA shouldn't check against itself, therefor you'd have no issues with weapon fire hitting the tip of your house and would collide with enemies.

1 decade ago by coreysnyder

Yeah that's what I thought but I think something is seriously bugged here. Everything you see in that image is marked as type A or Type B appropriately. And yet snowball type A is colliding with slingshot(house) type A.

My only guess at this point is that because my ammo are Box-2D Entities that it's causing some issue. Anyone else have any ideas?

1 decade ago by Xatruch

If you're using box2d then your impact entities should always be
collides: ig.Entity.COLLIDES.NEVER,

use the box2d filter, here's a tutorial
http://www.aurelienribon.com/blog/2011/07/box2d-tutorial-collision-filtering/

1 decade ago by coreysnyder

Man that tutorial isn't even written using the Box2Djs implementation. Also, only my weapons are box2D entities. The building & everything else are written using only ig.Entity.extend. Is that tutorial going to do that trick?

Has anyone else worked with box2Dentity collisions? How did you do it?

1 decade ago by silverspectro

could you put some code on this ?
Like the defining of the types, collide and checkagainst ?

1 decade ago by coreysnyder

The Base & Slingshot are:
        type: ig.Entity.TYPE.A,
        checkAgainst: ig.Entity.TYPE.NONE,
        collides: ig.Entity.COLLIDES.FIXED,

The Ammo that is fired is:
        type: ig.Entity.TYPE.A,
        checkAgainst: ig.Entity.TYPE.B,
        collides: ig.Entity.COLLIDES.PASSIVE,

The Enemies are:
        type: ig.Entity.TYPE.B,
        checkAgainst: ig.Entity.TYPE.A,
        collides: ig.Entity.COLLIDES.PASSIVE,

Look right? I think I do need to do something special since they are Box2D entities. I saw in the Box2D example:
        type: ig.Entity.TYPE.A,
	checkAgainst: ig.Entity.TYPE.NONE,
	collides: ig.Entity.COLLIDES.NEVER, // Collision is already handled by Box2D!

So.. guess that's going to require some special code to prevent collisions.

1 decade ago by dungeonmaster

I'm also noobish and have no exp. with Box2D but mebbe you can try this:
Since base is FIXED and ammo is PASSIVE they'll surely collide. You need the house to be NEVER.

Now for the enemies, if you write .check() code for the type A entities, it should do the trick I guess.

in entityEnemy:
check: function (other) {
  if (other.isHouse) {
    this.bite (other)
    return
  }
 if (other.isBullet) {
    this.eatBullet(other)
 }

you need additional property isHouse : true for house and isBullet:true for the bullet.
.bite and .eatBullet are the procedures for the entityEnemy

Hope it works.
Page 1 of 1
« first « previous next › last »