Why doesn't the player move to another object?

  • 0
    The object does not move to another, but the code is correct in my opinion;

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.EventSystems;
    using UnityEngine.UI;

    public class PLAYER1: MonoBehaviour
    {
    public GameObject goal1;
    public GameObject goal2;

    bool check = false;

    void Update ()
    {
    if (check) transform.position = Vector3.MoveTowards (transform.position, goal1.transform.position, 2f * Time.deltaTime);
    if (! check) transform.position = Vector3.MoveTowards (transform.position, goal2.transform.position, 2f * Time.deltaTime);
    transform.rotation * = Quaternion.Euler (0f, 0f, 1f);
    }
    }
    Unity Game Engine Eliot Harmon, Apr 23, 2020

  • 0 Answers
Your Answer
To place the code, please use CodePen or similar tool. Thanks you!