Hello… I’m noob in scripting.
It might be a simple script, but I totally noob :v
first here is my 2D game scene
So I want to make my object “Curtain” to move down to the terrain automatically when the “player” reach the “boxtrigger”.
So far I add this code to my curtain object and it moved to the targeted terrain but only when every I start the game.
using UnityEngine;
using System.Collections;
public class Movement2 : MonoBehaviour {
public Transform Target;
public float MoveToSpeed;
private Transform _transform;
private void Start()
{
_transform = transform;
}
private void FixedUpdate()
{
_transform.position = Vector3.MoveTowards(_transform.position, Target.position, MoveToSpeed);
}
}
So how do I make “Boxtrigger” as I trigger to move “Curtain” when my player reach it?