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 Oliver

Hi there, im pretty noob using impact so this is probably a easy quesiton...
Im trying to do a platform game, and want to make some elevators. The problem is that when i take the player entity on top of a elevator, the player CANT jump... he can move to the sides, but he CANT make a movement in Y axis until he gets away from the elevator.
this is my player entity:

ig.module(
	'game.entities.jugador'
)
.requires(
	'impact.entity'
)
.defines(function(){
	
EntityJugador = ig.Entity.extend({
    
    	type: ig.Entity.TYPE.A,
        collides: ig.Entity.COLLIDES.PASSIVE,
        checkAgainst: ig.Entity.TYPE.NONE,
        animSheet: new ig.AnimationSheet( 'media/jugador.png', 60, 100 ),
	size: {x: 60, y:100},
	flip: false,
	maxVel: {x: 300, y: 800},
	friction: {x: 1000, y: 0},
	accelGround: 1000,
	accelAir: 1000,
        jump: 600,
        armaselec: 1,
        name: "jugador",
		
        init: function( x, y, settings ) {
            this.parent(x, y, settings);
            this.addAnim( 'idle', 1, [0] );
            ig.game.jugador = this;
            armaselec = 1;
        },
	update: function()
        {
            this.currentAnim = this.anims.idle;
            this.parent();
            
            
            //mover el personaje
            var accel = this.standing ? this.accelGround : this.accelAir;
            if( ig.input.state('izquierda') ) {
                this.accel.x = -accel;
                this.flip = true;
            }
            else if( ig.input.state('derecha') ) {
                this.accel.x = accel;
                this.flip = false;
            }
            else {
            	this.accel.x = 0;
            }
            if( this.standing && ig.input.pressed('saltar') ) {
			this.vel.y = -this.jump;
	    }
        },
    });
});

and this is my elevator entity:

ig.module(
	'game.entities.plataforma'
)
.requires(
	'impact.entity'
)
.defines(function(){

    EntityPlataforma = ig.Entity.extend({
        type: ig.Entity.TYPE.B,
        checkAgainst: ig.Entity.TYPE.NONE,
        collides: ig.Entity.COLLIDES.FIXED,
	animSheet: new ig.AnimationSheet( 'media/robotito.png', 20, 40 ),
        size: {x: 20, y: 40},
        maxVel: {x: 100, y: 100},
        flip: false,
        friction: {x: 150, y: 0},
        speed: 80,
	gravityFactor: 0,
        
        init: function( x, y, settings ) {
            this.parent( x, y, settings );	
            this.addAnim( 'crawl', 1, [0] );
        },
        update: function() {
            this.parent();
        },

    });
});

its driving me crazy, If someone has any idea of what could solve this problem i would really appreciate it.

1 decade ago by Joncom

Maybe this will help: http://impactjs.com/forums/help/entity-standing-over-another-entity

1 decade ago by Oliver

That is helples for me... becouse im trying to do a elevator, and tiles wont help me there, i need it to move :(
Is there a reason why my player cant jump if he is having gravity and standing on another entity?

1 decade ago by Joncom

Quote from Oliver
Is there a reason why my player cant jump if he is having gravity and standing on another entity?
Because the .standing property is calculated based on collision map only.

Edit:

A very simple workaround would be to:

- When the player tries to jump, loop through all the elevator entities.
- If the player is touching an elevator entity, assume he's on top, allow jump.

Obviously this is not perfect, but perhaps it's a step in the right direction.

1 decade ago by Oliver

I noticed that when there is some gravity and one entity is on top of another, they kind of fucionate (?) the player entity gets IN the elevator entity like 0.0000001 pixels and the elevator moves him back up that 0.000001 pixels but that is calculated AFTER all the update cicle. so that is why the player entity didnt want to jump when it was on a elevator. What i found as a solution is to add to the player entity something like this:

update: function()
        {
            if ( this.standing && this.pos.y - this.last.y < 1 ) {
                if( ig.input.pressed('saltar') ) {
                    this.bounciness = 1;
                    this.vel.y = -this.jump;
                    console.log(this.pos.y);
                }
                
            }
            else{
                this.bounciness = 0;
            }
}

and this is the important part: this.pos.y - this.last.y < 1
it means "if i was pushed up that 0.00001 pixels up from a elevator". I hope it helps someone sometime :P
Srry for my horrible english

1 decade ago by Joncom

I&039;m a little confused because #this.standing should never equal true unless resting on a collision tile. Therefore, you should not be able to jump while resting on an elevator entity.

However, it sounds like you're happy with how things are working. Congrats.
Page 1 of 1
« first « previous next › last »