Hi, how might I add randomness to the angle of a bullet (c_trace bullet) originating from camera.x to simulate bullet spread? I am using the below method to create bullets:

bullet_create(camera.x,camera.pan,500);

Originally Posted By: Superku
Code:
void bullet_create(VECTOR* vpos,VECTOR* vang,var speed)
{
	var alive = 16;
	VECTOR pos,temp,vel;
	
	vec_set(pos,vpos);
	vec_set(vel,vector(speed,0,0));
	vec_rotate(vel,vang);

	while(alive > 0)
	{
		// calculate new position
		vec_set(temp,vel);
		vec_scale(temp,time_step);
		vec_add(temp,pos);
		c_trace(pos,temp,IGNORE_PASSABLE | USE_POLYGON); // optional: SCAN_TEXTURE
		if(trace_hit)
		{
			/*if(you) ... // reduce health, blood effect
			else ... // spark effect*/
			alive = 0;
		}
		effect(p_bullet,1,pos,vel); // you may want to shorten vel on impact
		vec_set(pos,temp); // move to new position

		alive -= time_step;
		wait(1);
	}
}


My apologies I am not too familiar with vector mathematics.