using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class moveCar : MonoBehaviour
{
public GameObject background;
public GameObject car;
public GameObject controllerModel;
public GameObject rayDir;
public GameObject myUI;
bool startGame=false;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
RaycastHit hit;
if (Physics.Raycast(transform.position, (rayDir.transform.position-transform.position) *1000, out hit))
{
// Debug.DrawRay(transform.position,(rayDir.transform.position-transform.position) *1000, Color.yellow);
Debug.Log("Did Hit");
startGame=true;
background.SetActive(true);
myUI.SetActive(false);
}
if(startGame)
{
Vector3 now = transform.position;
float angle = transform.rotation.eulerAngles.z;
transform.TransformPoint(Vector3.zero);
car.transform.position = new Vector3(now.x*87, now.y*27, 0);
car.transform.rotation = Quaternion.Euler(0, 0, angle);
// print(angle);
}
// /transform.rotation;
}
}
沒有留言:
張貼留言