написал код в юнити:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class player: MonoBehaviour
{
private Vector2 targetPos;
public float Yincrement;
public float speed;
public float maxHeight;
public float minHeight;
public int health = 5;
private void Update()
{
transform.position = Vector2.MoveTowards(transform.position, targetPos, speed * Time.deltaTime);
if (Input.GetKeyDown(KeyCode.W) && transform.position.y < maxHeight)
{
targetPos = new Vector2(transform.position.x, transform.position.y + Yincrement);
}
else if (Input.GetKeyDown(KeyCode.S) && transform.position.y > minHeight)
{
targetPos = new Vector2(transform.position.x, transform.position.y - Yincrement);
}
}
}
но пишет ошибка:
Assets\scripts\player.cs(16,15): error CS0111: Type 'player' already defines a member called 'Update' with the same parameter types
что делать?