why am i getting a vector2.scale error

Hi
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’

CODE

using UnityEngine;
using System.Collections;

public class Player : MonoBehaviour
{
	public float speed = 10;
	private Vector3 originalScale;
	
	void Start()
	{
		originalScale = transform.localScale;
	}
	
	void Update()
	{
		if (Input.GetMouseButtonDown(0))
		{
			transform.localScale = transform.localScale + Vector2.Scale * speed * Time.deltaTime;
			new Vector2(5.545318f, 0.5769206f);
		}
		
		if (Input.GetMouseButtonUp(0))
		{
			transform.localScale = originalScale;
		}
	}
}

Looks like you want:

transform.localScale += (Vector3)(Vector2.one * speed * Time.deltaTime);
// or
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.

edit

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.

Hi,

You are trying to multiplie a method with a float.
The prototype of Vector2.Scale is

Vector2 vec1;
Vector2 vec2;

Vector2.Scale(vec1, vec2);

Go to the doc :wink:
http://docs.unity3d.com/ScriptReference/Vector2.Scale.html