How to make reticle expands when shooting

I want my reticle to expand when I shoot stuff, but I don’t know how. Any help will be appreciated.

BTW, here’s my crosshair texture.

89764-crosshair.png

Yeah, you know in fps games where the individual parts of the crosshair just move away from each other when shooting and come back together when stopping

1 Answer

1

This depends a great deal on how you want to display your crosshair. If you’re using the most obvious method of dropping an Image UI element into the center of the canvas then a good way would be to set the pivot to the center of the reticle (which you should have already done anyway) and then simply adjust the scale using a script like this:

public Image reticle;
public float reticleSize = 1.0f;
public float delta = 0.01f;

Update() {
  reticleSize = Mathf.max(1.0f, reticleSize-delta);

  if ([player has shot])
    reticleSize += [accuracy delta value, perhaps from the weapon class];

  reticle.GetComponent(RectTransform).sizeDelta = new Vector2(reticleSize, reticleSize);
}

Yeah, you know in fps games where the individual parts of the crosshair just move away from each other when shooting and come back together when stopping

To test if you have created your Prefab correctly, drag it into your Scene, and see if it contains both a parent and a child.