- Home /
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.
Answer by Puck · Mar 13, 2017 at 09:37 PM
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
Your answer
Follow this Question
Related Questions
I need to set the path for saving the pictures with an application for Android and IOS 2 Answers
Displaying profile pictures in all connected devices 1 Answer
Displaying a picture on terrain under moving actor 0 Answers
How to manipulate Crosshair with DrawTexture? (total Newbie) 2 Answers
Aiming to the crosshair 1 Answer