Car obstacle in progress
This commit is contained in:
parent
52abf0266d
commit
851dec0ba3
3 changed files with 10725 additions and 167 deletions
32
Game/Assets/Car.cs
Normal file
32
Game/Assets/Car.cs
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
Author : Wai Lam
|
||||||
|
Date : 10/2/2025
|
||||||
|
Description : Car obstacle
|
||||||
|
*/
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class Car : MonoBehaviour
|
||||||
|
{
|
||||||
|
public Transform playerRig; // Assign your XR Rig here
|
||||||
|
public Transform startPoint; // Assign the starting point here
|
||||||
|
|
||||||
|
private void OnTriggerEnter(Collider other)
|
||||||
|
{
|
||||||
|
Debug.Log("Triggered by: " + other.name);
|
||||||
|
// Check if the collider belongs to the player
|
||||||
|
if (other.CompareTag("Player"))
|
||||||
|
{
|
||||||
|
Debug.Log("Teleporting Player...");
|
||||||
|
TeleportPlayer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TeleportPlayer()
|
||||||
|
{
|
||||||
|
Vector3 offset = playerRig.position - Camera.main.transform.position;
|
||||||
|
playerRig.position = startPoint.position + offset;
|
||||||
|
playerRig.rotation = startPoint.rotation;
|
||||||
|
}
|
||||||
|
}
|
11
Game/Assets/Car.cs.meta
Normal file
11
Game/Assets/Car.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 068fbcec103081147a0588ec72e53ee0
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
File diff suppressed because one or more lines are too long
Loading…
Add table
Reference in a new issue