hello everyone i have an if statement that i repeat it in many scripts related to raycasting ... !

void Update () {

	RaycastHit hitinfo;

	if (Physics.Raycast (fpscam.transform.position, fpscam.transform.forward, out hitinfo, range)) 
	{

so i need this if statement in every script that the player must interact with something so with different scripts …

If the issue you’re having is redundancy - having to rewrite the same code over and over - wouldn’t it make sense to put your raycasting code inside its own function that many other scripts can call?