
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
Dog가 움직일 때 쭉쭉 이동하지를 않습니다.
https://drive.google.com/file/d/1InY4pZsVpIY8AliMcjmvDnJnLLwz2j6q/view?usp=drive_link
(문제의 영상 링크입니다.)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Dog : MonoBehaviour
{
public GameObject food;
// Start is called before the first frame update
void Start()
{
InvokeRepeating("MakeFood", 0f, 0.5f);
}
private void Update()
{
Vector2 mousePos = Camera.main.ScreenToViewportPoint(Input.mousePosition);
float x = mousePos.x;
if (x > 8.5f)
{
x = 8.5f;
}
if(x < -8.5f)
{
x = -8.5f;
}
transform.position = new Vector2(mousePos.x, transform.position.y);
}
// Update is called once per frame
void MakeFood()
{
float x = transform.position.x;
float y = transform.position.y * 2.0f;
Instantiate(food, new Vector2(x, y), Quaternion.identity);
}
}
작성한 코드 및 에러 메세지
