How to create a script that shows the object in unity

I would like to create a script which will show an object in my game, e.g. a red dot, and after a few milliseconds it will disappear. i would like the script to be very short and to work quickly because it’s all about milliseconds.

You can create shader graph like this;

You can change color via inspector.
You should add your textures which is normal map or base texture.

Click the outline float variable and get the reference name.

199391-screen-shot-2022-09-01-at-092452.png

and on your script you should write code something like this (i didn’t checked my code but its probably has no problem);

        public interface IInteractable
        {
            public void Interact();
        }

        public class TheScriptShouldOnTheObjectNotPlayer : MonoBehaviour, IInteractable
        {
            private Renderer _rendererPlayer;

            private void Start()
            {
                _rendererPlayer = GetComponent<Renderer>();
            }

            IEnumerator CreateDot(float totalSecond)
            {
                float totalTime = 0;
                _rendererPlayer.material.SetFloat("_outLine", 2);
                while(totalTime <= totalSecond)
                {
                    totalTime += Time.deltaTime;

                    yield return null;
                }
                _rendererPlayer.material.SetFloat("_outLine", 0);
            }

            public void Interact()
            {
                StartCoroutine(CreateDot(1));
            }
        }

        public class PlayerScript : MonoBehaviour
        {
            private float _rayDistance = 5; // distance ray
            private RaycastHit _raycastHit;
            private void FixedUpdate()
            {
                if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out _raycastHit, _rayDistance))
                {
                    Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.forward) * _raycastHit.distance, Color.yellow);
                    var interactable = _raycastHit.collider.GetComponent<IInteractable>();
                    interactable.Interact();
                }
            }
        }