- Home /
Question by
superseb123abc · Dec 14, 2013 at 05:34 PM ·
wallshorror
How to make walls slowly close in on player?
Hi guys, i'm quite new to Unity3D I know a little bit of JavaScript and C# but not much. Anyways i am making a horror game and i want to have to long cubes slowly closing in on you after you enter an area. Thanks in advance :)
Comment
Answer by xandermacleod · Dec 14, 2013 at 06:03 PM
hi, and welcome to the unity answer forums.
At a basic level, the function you will want to use is Transform.Translate For example, a script with the following code should make an object move every continuously in one direction over time:
public Vector3 movementDirection;
public float Speed;
void Update
{
gameObject.transform.Translate(movementDirection * Speed * Time.deltaTime);
}
Your answer