Answer the question
In order to leave comments, you need to log in
How to change the position of an object with the mouse?
There is a script that, according to the idea, should move the object (as well as increase it) when the mouse is pressed on the object itself
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class scale : MonoBehaviour
{
Vector3 pos = new Vector3();
private void OnMouseEnter()
{
transform.localScale = new Vector3(0.30f, 0.02f, 0.50f);
}
private void OnMouseExit()
{
transform.localScale = new Vector3(0.25f, 0.01f, 0.45f);
}
void OnMouseDrag()
{
transform.position = Vector3(pos);
}
}
But the unit gives an error
Assets\Script\scale.cs(20,30): error CS1955: Non-invocable member 'Vector3' cannot be used like a method.
How to fix it?
Answer the question
In order to leave comments, you need to log in
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class scale : MonoBehaviour
{
Vector3 pos = new Vector3();
private void OnMouseEnter()
{
transform.localScale = new Vector3(0.30f, 0.02f, 0.50f);
}
private void OnMouseExit()
{
transform.localScale = new Vector3(0.25f, 0.01f, 0.45f);
}
void OnMouseDrag()
{
transform.position = new Vector3(pos);
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class scale : MonoBehaviour
{
Vector3 pos = new Vector3();
private void OnMouseEnter()
{
transform.localScale = new Vector3(0.30f, 0.02f, 0.50f);
}
private void OnMouseExit()
{
transform.localScale = new Vector3(0.25f, 0.01f, 0.45f);
}
void OnMouseDrag()
{
transform.position = pos;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question