Hi.
I would like a door that opens as soon as the player get's close enough (no need to press any button). The player is a Standard Asset prefab for an FPS.
To door would open vertically and go up as soon as the player get's close to it.
Thanks
Set up an empty game object in front of the door, make the collider a trigger, and attach an OnTriggerEnter code on it. Compare the tag of the collider and if it's "Player" tag, have the animation play and the door open.
HI....although a newbie to both Unity and scripting...i found this using Raycast, just make sure your door has a collider and Is Trigger is off....
var RayCastlenght = 2;
//allows you to change the distance required to trigger the door
function update()
{
var hit : RaycastHit;
//check if we are colliding
if(Physics.Raycast(transform.position, transform.forward, hit, RayCastlenght))
{
//...check colliding with door
if(hit.collider.gameObject.tag == "BookCase")
{
//move the case
hit.collider.gameObject.animation.Play("BookCase_anim");
}
}
}
what you need to do is compose an animation for the door to open and then change Bookcase_anim with your new animation.....
best of luck