Jump to content

Androvikus

Registered
  • Posts

    0
  • Joined

  • Last visited

Posts posted by Androvikus

  1. Hi.

    I have made a door with 2 animations open and close, and put them to legazy in unity3d.

    Then i created an Object with a BoxColllider on, tied my script to the Object and placed the Collider around the door. see script below:

     

    using UnityEngine;

    using System.Collections;

    using System.Collections.Generic;

     

    public class OpenDoor_PCP_2 : MonoBehaviour

    {

    public enum Trigger

    {

    Collide,

    Click

    }

     

    private GameObject anim2;

    private Animation animation2;

    public GameObject t;

    public GameObject target;

    public Trigger trigger;

    public bool state = false;

    public AudioClip OpenSound;

    public AudioClip CloseSound;

     

    void OnMouseDown()

    {

    float distance = Vector3.Distance(target.transform.position, transform.position);

     

    if (state == true)

    {

    CloseInstance();

    }

     

    else if(trigger == Trigger.Click && distance < 2.5f)

    {

    EnterInstance();

    }

    }

     

    void EnterInstance()

    {

    Debug.Log("Open Sesame");

     

    anim2 = GameObject.FindGameObjectWithTag ("OpenDoor_PCP_2");

    animation2 = anim2.GetComponent();

    animation2.animation.Play("OpenStyleA");

     

     

    audio.clip = OpenSound;

    audio.Play();

     

    t = GameObject.FindGameObjectWithTag ("OpenDoor_PCP_2_1");

    t.collider.isTrigger = true;

    state = true;

    }

     

    void CloseInstance()

    {

    anim2 = GameObject.FindGameObjectWithTag ("OpenDoor_PCP_2");//AndersPrisonDoor

    animation2 = anim2.GetComponent();

    animation2.animation.Play("CloseStyleA");

     

    audio.clip = CloseSound;

    audio.Play();

     

    t = GameObject.FindGameObjectWithTag ("OpenDoor_PCP_2_1");

    t.collider.isTrigger = false;

    state = false;

    }

    }

     

     

    I looged in and could open and close the door with sound. All perfect, so i thought!

     

    Then i logged in with a new instance, so i had 2 players out, looking on the same door. When 1 of the players opened the door, the other player only saw a closed door?

     

    I looked around for a solution, but the only thing i found was 2 tutorial on Coordinated Effects, but none showed how to do a "coord object animation" to the door.

     

    So i dont know how to do a coord objecty animation to my door, andd i dont know how to coonect one to my door.

     

    So thats what i want to know how to do!!

    PLEASE HELM ME!!!!!

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.