Trying to open a door by y access but it wont work i found the guidance to do so on a youtube video i will post the video if anyone is interseted in the bio. But i think the only thing i did wrong is i want to use the empty game object to the far left of game object, And that and clearly each error i get is only over symbol ‘timeleft’ But im completely new to this so i have no idea how to possibly understand what that means i need to do without a professinal of some sorts o,o
Errors______________
-
Assets/Doors.cs(48,110): error CS1525: Unexpected symbol `timeleft’
-
Assets/Doors.cs(50,111): error CS1525: Unexpected symbol `timeleft’
Code________
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Doors : MonoBehaviour {
public float timeleft = 0;
public RaycastHit hit;
public Transform currentdoor;
public bool open;
public bool IsOpeningDoor;
public Transform cam;
public LayerMask mask;
// Update is called once per frame
void Update() {
if (Input.GetKeyDown (KeyCode.F) && timeleft == 0.0f)
CheckDoor();
}
public void CheckDoor()
{
if (Physics.Raycast(cam.position, cam.forward, out hit, 5, mask))
{
print(hit.collider.gameObject.name);
open = false;
if(hit.transform.localRotation.eulerAngles.y > 45)
{
open = true;
}
IsOpeningDoor = true;
currentdoor = hit.transform;
}
}
public void OpenAndCloseDoor()
{
timeleft += Time.deltaTime;
if (open)
currentdoor.localRotation = Quaternion.Slerp(currentdoor.localRotation, Quaternion.Euler(0, 0, 0) timeleft);
else
currentdoor.localRotation = Quaternion.Slerp(currentdoor.localRotation, Quaternion.Euler(0, 90, 0) timeleft);
if (timeleft > 1)
{
timeleft = 0;
IsOpeningDoor = false;
}
}
}
But thank you for making the software free to use and everything!!
But heres the video
Video i was learning form_________
By Gamad