Hi,
I got a problem with the game i’m trying to develop.
I move a ball like an Agar.io
The ball should be switching color (smoothly) then it Moving or not
But it doesn’t work.
The moving script:
public class Move : MonoBehaviour {
public float Speed;
public bool inMove = false;
private void Start()
{
Vector3 target = Camera.main.ScreenToWorldPoint(Input.mousePosition);
target.x = transform.position.x;
target.y = transform.position.y;
}
// Update is called once per frame
void Update () {
Vector3 target = Camera.main.ScreenToWorldPoint(Input.mousePosition);
target.z = transform.position.z;
if ((target.x != transform.position.x) | (target.y != transform.position.y))
{
inMove = true;
//target.x = transform.position.x;
//target.y = transform.position.y;
}
else
{
inMove = false;
}
transform.position = Vector3.MoveTowards(transform.position, target, Speed * Time.deltaTime);
}
}
the changing color script :
public class ColorSpeed : MonoBehaviour
{
public List<Material> Mats = new List<Material>();
private float value1;
private float value2;
private float value3;
public Move _move;
public float timeLeft;
private void Update()
{
GetComponent<Renderer>().material = Mats[0];
if (_move.inMove == false)
{
// Assign target color
GetComponent<Renderer>().material = Mats[1];
//change smoothly the color
GetComponent<Renderer>().material.color = Color.Lerp(GetComponent<Renderer>().material.color, Mats[0].color, Time.deltaTime / 2);
}
else
{
GetComponent<Renderer>().material = Mats[0];
GetComponent<Renderer>().material.color = Color.Lerp(GetComponent<Renderer>().material.color,Mats[1].color, Time.deltaTime / 2);
// Update timer
}
}
the move animation is working, the condition with bool too , but what it’s not working is Lerp .
I tryied many code on internet just for test this fonction and I always had the same issue
: CS0121 C# The call is ambiguous between the following methods or properties: and
thank you in advance