bounce of exact 180 degree

Posted By: Realspawn

bounce of exact 180 degree - 10/07/15 15:51

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
Posted By: MasterQ32

Re: bounce of exact 180 degree - 10/07/15 19:37

Code:
vec_to_angle(my.pan,bounce); // and bounce off any obstacles


should be replaced with
Code:
my.pan += 180;


no additional bouncing wink
Posted By: Realspawn

Re: bounce of exact 180 degree - 10/08/15 02:51

dang it it was that simple lol thank you laugh
© 2024 lite-C Forums