Поиск в блоге

понеділок, 10 березня 2025 р.

Гра Neon Rider в Unity3D

 Гра Neon Rider в Unity3D




MoveScript

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

 

public class MoveScript : MonoBehaviour

{

    Rigidbody2D physic;

    public float force;

    public Transform camera;

    bool isFLy = true;

    public float rotate;

 

    // Start is called before the first frame update

    void Start()

    {

        physic = GetComponent<Rigidbody2D>();

    }

 

    // Update is called once per frame

    void FixedUpdate()

    {

        camera.position = new Vector3(transform.position.x, transform.position.y, camera.position.z);

        if (Physics2D.Raycast(transform.position, -transform.up, 2, ~(1 << 9)))

        {

            isFLy = false;

        }

        else

        {

            isFLy = true;

        }

        if (Input.GetKey(KeyCode.Mouse0))

        {

            if (!isFLy)

            {

                    physic.AddRelativeForce(new Vector3(force, 0));

            }

            else

            {

                    physic.AddTorque(rotate);

            }

        }

    }

}

 




Немає коментарів:

Дописати коментар