I have a script which works when i hold the mouse down the player expands in the x axis and when i let go it returns to normal. But i keep getting the error Operator
*' cannot be applied to operands of type method group’ and `float’
public class Player : MonoBehaviour
public float speed = 10;
private Vector3 originalScale;
originalScale = transform.localScale;
transform.localScale = transform.localScale + Vector2.Scale * speed * Time.deltaTime;
new Vector2(5.545318f, 0.5769206f);
transform.localScale = originalScale;
Looks like you want:
transform.localScale += (Vector3)(Vector2.one * speed * Time.deltaTime);
transform.localScale += new Vector3(1f,1f,0f) * speed * Time.deltaTime;
Keep in mind that this will only add to the x and y scale and keep the z scale as it is.
Oh, another thing. Since you use “Input.GetMouseButtonDown” you either have to remove Time.deltaTime since you don’t execute this every frame. So it makes no sense to use deltaTime here.
Or replace “GetMouseButtonDown” with “GetMouseButton” to execute the code inside the if every frame as long as you hold down the mouse button. I guess this is what you actually want since the first thing doesn’t make much sense.
You are trying to multiplie a method with a float.
The prototype of Vector2.Scale is
Go to the doc