using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class MoveAbleButtonSystem : MonoBehaviour
{
public Transform ObjectToMove;
public bool moveLeft = true;
public bool moveRight = false;
public float SpeedToMove = 1f;
private bool pressed = false;
public float minZ = 0f;
public float maxZ = 0f;
void OnMouseDown()
{
pressed = true;
}
void OnMouseUp()
{
pressed = false;
}
void Update()
{
Transform T = ObjectToMove.transform;
if (pressed && moveLeft)
{
T.Translate(Vector3.forward * SpeedToMove * Time.deltaTime, Space.World);
}else
if(pressed && moveRight)
{
T.Translate(Vector3.back * SpeedToMove * Time.deltaTime, Space.World);
}
if(T.position.z > maxZ)
{
T.position.z = maxZ;
}
}
}
Assets\Scripts\MainMenu\MoveAbleButtonSystem.cs(42,13): error CS1612: Cannot modify the return value of 'Transform.position' because it is not a variable
I dont get why I cannot change the position. All I want to do is for the ObjectToMove to move until it passes a certain point, after what it is not supposed to move anymore. Using Clamp provides the same error.