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 TommyBs

Hi,

I'm trying to implement some collision logic in my game, where I have obstacle entities (that have a fixed position) that stop the player entity but I want to allow another enemy entity (subclassed from obstacle but can move) to "Jump" over it. How would I go about this? I obviously can't set the obstacle to "passive" collision as this will mean the player can pass through as well. My player is currently set to LITE.

Forgot to mention this is a "top down" game, so by "jump" my entity basically just needs to move over the other entity

I've also tried messing around with touches(other) but to no avail. In fact, just overriding this method causes collision to stop working for that entity entirely, even when calling this.parent(other) still
Any ideas?

1 decade ago by Joncom

Maybe try:
Player = active
Obstable = fixed
Other = none

1 decade ago by TommyBs

Sorry forgot to mention, I also want the jumping entity to be able to collide with the player and stop him

1 decade ago by TommyBs

To do what I wanted to do, I've had to override the ig.Entity.checkPair function in ig.Entity.

Basically I've changed these lines to be:
if(
		a.collides && b.collides &&
		a.collides + b.collides > ig.Entity.COLLIDES.ACTIVE
	) {
		ig.Entity.solveCollision( a, b );
	}

if(
		a.collides && b.collides &&
		a.collides + b.collides > ig.Entity.COLLIDES.ACTIVE && a.type != b.type
	) {
		ig.Entity.solveCollision( a, b );
	}

checking that they are of different types for collision. I don't really want to be updating the Entity core, but I'm not sure how I can extend things like this

1 decade ago by Joncom

Quote from TommyBs
I don't really want to be updating the Entity core, but I'm not sure how I can extend things like this
You probably do not want to change anything within the Impact library directly, but you can overload the parts you need to in main.js for example.

Game = ig.Game.extend({
    /* your game here */
});

// overload the function here.
// note that you may need to require 'impact.entity' in main.js
ig.Entity.checkPair = function() {} 
Page 1 of 1
« first « previous next › last »