Hi! In my game I have a platform on which the player can walk. This platform moves horizontally and I want the player to move with it.

I tried this, but it doesn't work:
Code:
........

mvec[0]=character.movespd*time_step; //movement vector
mvec[1]=character.strafespd*time_step;
c_trace(character.x,vector(character.x,character.y,character.z-1000),IGNORE_ME|IGNORE_SPRITES|SCAN_TEXTURE|IGNORE_PASSABLE|USE_BOX); 
mvec[2]=((hit.z - character.min_z)-character.z);

if (hit.entity==NULL)
	dist=c_move(character,mvec,nullvector,IGNORE_PASSABLE|GLIDE);
else
{
	character.rel_x=character.x-hit.entity.x;
	character.rel_y=character.y-hit.entity.y;
	wait(1); //let the entity move
	mvec_abs[0]=hit.entity.x+character.rel_x-character.x; //this line generates a crash
	mvec_abs[1]=hit.entity.y+character.rel_y-character.y;
	mvec_abs[2]=0;
	dist=c_move(character,mvec,mvec_abs,IGNORE_PASSABLE|GLIDE);
}

........



Platform movement code:
Code:
function move_platform()
{
	if (me.x<=-140)
		while(me.x<640)
		{
			me.x+=4*time_step;
			wait(1);
		}
	else
		while(me.x>-144)
		{
			me.x-=4*time_step;
			wait(1);
		}
}

action platform()
{
	me.emask |= ENABLE_SCAN;
	me.event=move_platform;
}



When the platform is not moving the player can walk on it, but when it starts moving the engine crashes (Crash in biped_movement: SYS). The crash occurs when hit.entity.x is accessed.

Any better idea?

Thanks.