Hi everyone!
My main goal is to indicate the radius of a grenade from top-down-view. The grenades are placed randomly as well as the damage radius is random-generated. To make life easier for the player, I want to indicate this radius.
I tried to use a sphere without collider to indicate the radius, but I don’t know how to change size of a gameObject from another one (The script runs on an empty one called “Grenade Spawner”). I’ve read about a projector, which can project circles on the ground, but I couldn’t find any in Unity.
So I thought I should use a forum now for the first time and hope for some answers!
You need to reference that object in your current script, then access and change parameters in it.
i.e. something like this. Naturally you need to adapt it to your purposes:
[Range(0,2)] public float indicatorScale = 1;
public GameObject indicatorSphere;
void Update()
{
indicatorSphere.transform.localScale = Vector3.one * indicatorScale;
}
If you put this code to a script and drag another object to the exposed GameObject field, you can then control that object’s size with that slider. And of course you could do the same with code.
I think it’s best to check some tutorials on Unity and C# coding, so that you understand how object oriented programming works. You need to be referencing other objects all the time in your game anyway
P.S. Please also fix your title - there’s a typo now there and that might make it harder for others to find this solution later.