Hey guys and gals,
I will make this quick but in essence i would like to know if i am going about this in the right manner.
I Have an elevator with 1 inside_door. There are 2 floors, with 1 outside_door_bottom at the 1st floor and 1 outside_door_top at the 2nd floor.
I would like for the Inside_door to follow the transform.z of the outside_door only once the On Trigger Enter is triggered for that floor
Example would be the elevator moves down through the On Trigger Enter associated with the outside_door_bottom then in turn the inside_door follows the transform of the outside_door_bottom.z.
Alternatively the elevator moves up through the On Trigger Enter associated with the outside_door_top then in turn the inside_door follows the transform of the outside_door_top.z.
Side note: The outside doors have there own means of moving between way points once there trigger has been entered.
Here is what i have so far but is this the right manner of doing this if not please help to guide my ways and many thanks those who help.
This is the script attached to trigger collider for the outside_door_bottom
using UnityEngine;
using System.Collections;
public class ElevatorDoorsTrigger: MonoBehaviour {
private Transform ouside_door_bottom1;
private Transform inside_door1;
public GameObject ouside_door_bottom = null;
public GameObject inside_door = null;
bool trigger = false;
void Awake ()
{
// Setting up the references.
ouside_door_bottom1 = ouside_door_bottom.transform;
inside_door1 = inside_door.transform;
}
void OnTriggerEnter(Collider collider)
{
if (collider.tag == "Elevator")
{
trigger = true;
vp_MovingPlatform platform1 = inside_door .GetComponentInChildren<vp_MovingPlatform> ();
platform1.SendMessage ("GoTo", platform1.TargetedWaypoint == 0 ? 1 : 0, SendMessageOptions.DontRequireReceiver);
}
}
public void OnTriggerExit(Collider collider)
{
if (collider.tag == "Elevator")
{
trigger = false;
}
}
public void LateUpdate ()
{
if (trigger)
{
inside_door1.position = new Vector3 (inside_door1.position.x, inside_door1.position.y, ouside_door_bottom1.position.z);
}
}
}
Then i would copy this and change the ouside_door_bottom to ouside_door_top and use for the ouside_door_top collider.