using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ScaleOneSide : MonoBehaviour
{
public float speed = 1;
float mfX;
float mfY;
// Use this for initialization
void Start()
{
mfX = transform.position.x - transform.localScale.x / 2.0f;
mfY = transform.position.y - transform.localScale.y / 2.0f;
}
// Update is called once per frame
void Update()
{
if (Input.GetMouseButton(0))
{
Vector3 v3Scale = transform.localScale;
transform.localScale = new Vector3(v3Scale.x + 0.1f, v3Scale.y, v3Scale.z);
transform.position = new Vector3(mfX + transform.localScale.x / 2.0f, mfY + transform.localScale.y / 2.0f, 0);
}
}
}
When I’m pressing on the mouse left button it keep scaling it only to the right side.
But the scaling speed is at constant speed. How can I use the speed variable to change the scaling speed ?
The reason i’m not using startcoroutine is that I want to use GetMouseButton(0) pressing and not one click.
So I’m using Update for that.
What I want is when I will press the mouse left button non stop it will scale the object to one side only at a certain speed.