r/UnityHelp • u/Defiant_Noise_8630 • Mar 03 '22
PROGRAMMING Issue with code. Basically I want there to be a value that represents the chosen objects localScale x and y value.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class circleScale : MonoBehaviour
{
[SerializeField]
private Transform transformScale;
private void Start()
{
private float ratioX = transformScale.localScale.x;
}
}
This says that ratioX is reffering to a non static variable or something.
Also it says that it is missing an end bracket...
3
Upvotes
1
u/Bonejob Code Guru Mar 03 '22
Scale is a vector3, to get a scale for a specific object you would need to get a reference to the transform component for the object you want the scale from and then grab the localscale value.
you can reference directly if you choose