I am trying to make my character turn exactly 180 degree every time it walks against a level block or entity I found this in the manual.

Code:
action walking_enemy()
{
	set(my,SHADOW | METAL);
	c_setminmax(my);

	my.skill100 =100;
	while(1)
	{	
		c_move (my, vector (10* time_step,0,0), nullvector, IGNORE_PASSABLE | NULL);
		my.skill22 += 8 * time_step; // 5 gives the "walk" animation speed
		ent_animate(my, "walk", my.skill22, ANM_CYCLE);
		if (trace_hit) { 
			vec_to_angle(my.pan,bounce); // and bounce off any obstacles
			my.tilt = 0;
			my.roll =0;
			
		} 
		wait(1);
	}
}



I tried adding my.pan -=180 but no effect sometimes it seems to work
but then suddenly he walks a random direction instead of right back ? aniy idea


Find all my tutorials & Workshops at : www.rp-interactive.nl

Creativity starts in the brain