Read the title for my problem,
You can visit the code over Pastebin (Opens an external website)
Because i don’t know how to use Code Markdowns here
Code: using System.Collections;using System.Collections.Generic;using UnityEngine; - Pastebin.com
How it should work:
Everytime when the GameObject hits an sertain Z-Rotation an AudioSource / Audio Clip is starting playing.
The same with an other Z-Rotation (E.g Door Close / Open).
Thanks
!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Door_Framework : MonoBehaviour {
public GameObject DoorMesh;
public float DoorRotation;
public GameObject doorOpenGO;
public GameObject doorClosedGO;
void Start()
{
AudioSource doorOpen = doorOpenGO.GetComponent<AudioSource>();
AudioSource doorClosed = doorClosedGO.GetComponent<AudioSource>();
DoorRotation = DoorMesh.transform.rotation.y;
}
void update()
DoorRotation = gameObject.transform.rotation.y;
{
if (DoorRotation == 1.0f)
{
doorClosed.Play();
}
if (DoorRotation == 7.0f)
{
doorOpen.Play();
}
}
}
Sorry, that it took so long. The hole thing is in VR and takes a bit longer.
The DoorRotation thing isnt working, the Door is rotated on the Y-Axes but it doesnt update in the Inspector & the Audio are missing.
Code
@winterfluxstudio Btw the door is based on an Hingejoint, im not sure if this is important.