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

1 decade ago by Gamma

Hello everyone, recently I've been playing Biolab Disaster for awhile, I've played it a couple of times, and I noticed that the "Blob" creatures wait for the players presence and then start crawling to the player. Now, I don't want to emulate the action of making something jump, instead I would like to make my enemy simply chase the player and if the creature collides with the player, the player is damaged. I appreciate it if anyone would like to help out.

1 decade ago by alexandre

3 possible ways would be:

1. in enemy update, scan for nearness of player using the distanceTo method. If close enough, activate A* and hunt player down.

2. via WM, add triggers that toggle enemy patrolling/chasing behaviour. As player walks over them (I suspect that's what dom did in bd), trigger fires & enemies respond.

3. via WM, setup scalable zone entities. These overlap areas of your map. Zones may even overlap each other. Enemies are placed over these zones. Zones have a check method, scanning for the player. When a zone's check is called, it looks for enemies within and notifies them of presence of trespassing player. These enemies then go into chase mode.

I'd probably try #3, as I think it has ramifications that may improve gameplay.

Note: for #3, you will have to modify wm so that it allows selection of entities lying underneath others, otherwise it'll be hell.

1 decade ago by Gamma

I believe BioLab Disaster uses option #1, I don't quite remember, but in the "making-of" video of the game, I saw this;

Update:  function() {
var  ydist  =
var  xdist  =
var  xdir    =
var  wasStanding  

if ( !this.seenPlayer)

Making-of Video for my HTML5 game "Biolab Disaster"

Skip to --> 06:30

This is a bit confusing for me to be honest, but I'll experiment around for a bit.

1 decade ago by silverspectro

Hi !

If you're just looking for an ennemy that will change his path toward the player when he arrives in a certain distance, you could do that.

update: function() {
	var player = EntityPlayer )[0];
	var xdir = this.flip ? -1 : 1;
	if ( this.distanceTo( player ) < 50 && player.standing ) {
		var target = 0;
		target = player.pos.x;
		//ig.log ( );
		if ( target < this.pos.x ) {
			this.flip = true;
			this.vel.x = this.speed * xdir;
		} else if ( target > this.pos.x ) {
			this.flip = false;
			this.vel.x = this.speed * xdir;
		} else {
			this.vel.x = this.speed*xdir;
		// near an edge? return!
		if( !
				this.pos.x + (this.flip ? +4 : this.size.x -4),
				this.pos.y + this.size.y+1
		) {
			this.flip = !this.flip;

But of course it only works on an x axis, but it could easily be modified to implement some jump function or increase the velocity ( like if the ennemy had spotted the player )

( i know this is noob stuff... ^^' )

1 decade ago by bitmapshades

Interesting thread! For my action RPG I'm developing I wanted enemies to only follow and attack the player depending on the active game state. I can effectively pause the action while dialogue or cut scenes are in effect using a modified mover update function.

update: function() {
		//If game not in chat mode
		if( != 'chat'){
		    // Evalute targets and move towards them
		    var oldDistance = 0;
		    var target = this.targets[this.currentTarget] );
		    if( target ) {
			oldDistance = this.distanceTo(target);
			var angle = this.angleTo( target );
			this.vel.x = Math.cos(angle) * this.speed;
			this.vel.y = Math.sin(angle) * this.speed;
			this.currentAnim = this.anims.walk;
			this.currentAnim.angle = angle;
		else {
		    // Stand idle
		    this.vel.x = 0;
		    this.vel.y = 0;
		    this.currentAnim = this.anims.idle;
		if( != 'chat'){
		    // Are we close to the target or has the distance actually increased?
		    // -> Set new target
		    var newDistance = this.distanceTo(target);
		    if( target && (newDistance > oldDistance || newDistance < 0.5) ) {
			    this.pos.x = target.pos.x + target.size.x/2 - this.size.x/2;
			    this.pos.y = target.pos.y + target.size.y/2 - this.size.y/2;
			    if( this.currentTarget >= this.targets.length && this.targets.length > 1 ) {
				    this.currentTarget = 0;
Page 1 of 1
« first « previous next › last »