- Home /
ERROR BCE0043 i need help pls
hi, i try to do a javascript for a animated door but when i go to put the scrypt in my project to can animate the door in the game, this error appears "Type ´doorscript1´ already has definition for ´distToOpen" i don`t know to do, help pls, my script:
var open: boolean = false;
var openAnimationString : String;
var closeAnimationString : String;
var buttonTransform : Transform;
var distToOpen : float = 4;
@HideInInspector
var playerTransform : Transform;
var distToOpen : float = 4;
@HideInInspector
var cameraTransform : Transform;
var openSound : AudioClip;
var closeSound : AudioClip;
function Awake ()
{
playerTransform =
GameObject.FindWithTag("Player").Transform; cameraTransform = GameObject.FindWithTag("MainCamera").Transform; if (open)
animation.Play(openAnimationString);
}
function Update ()
{
var alreadyChecked : boolean = flase;
var angle : float =
Vector3.Angle(buttonTransform.position - cameraTransform.position, buttonTransform.position + (cameraTransform.right * buttonTransform.localScale.magnitude) - cameraTransform.position);
if
(Vector3.Distance(playerTransform.position, buttonTransform.position) <= distToOpen)
if
(Vector3.Angle(buttonTransform.position - cameraTransform.position, cameraTransform.forward) <= angle)
if (Input.GetButtonDown("Use Key") && !animation.isPlaying)
{
if (open)
{
animation.Play(closeAnimationString);
open = false;
alreadyChecked = true;
if(closeSound)
audio.PlayOneShot(closeSound);
}
if(!open && !alreadyChecked)
{
animation.Play(openAnimationString);
open = true;
if (openSound)
audio.PlayOneShot(openSound);
}
}
}
Out of genuine curiousity, what did you think the error message was telling you?
Type ´doorscript1´ already has definition for "distToOpen"
As someone who writes technical support for users, I'd be interested to know how that could have been written any more clearly?
Answer by aditya · Sep 08, 2016 at 05:32 AM
You have defined variable distToOpen
two times ... one before variable playerTransform
and one after it