DistanceClose
Overview
Closes the door as the player moves closer, opens it as the player moves away.
Actions
|
Play Animation
Play an Opening animation.
In the animation the door is closed at the start, and open at the end.
So if set the animation time to 0, the door is closed, at 1 the door is open, and at 0.5 it's halfway open.
|
|
Get Distance
Get the distance of the First Person Controller to the door.
Store the result in the distance variable.
So this every frame since we want a smooth continuous relationship between distance and door opening.
|
|
Float Operator
We know the hallway is 8 units long.
So if we divide the distance variable by 8 we get roughly what we want.
Store the result in the closeAmount variable that we will use to set the door's animation time.
|
|
Float Add
But we have to cheat it a bit since the player's collider prevents them from getting all the way up to the door.
This number leaves the door open a tiny crack so you can see the exit sign on the other side!
|
|
Set Animation Time
Finally we can set the animation time to closeAmount.
|
Tags:
Last modified on 12/16/2010 7:35 AM by User.