- Home /
How to make a sliding door and add a trigger event?
Hi,
So I'm pretty new to Unity3D and I've been making a bunch of levels for my game. The problem is that I don't want players to cheat my game.
SO my question is: How to I use Walls to make them sliding doors, after grabbing a certain amount of Pick Up Objects?
Do you implement it into PlayerController?
And by sliding doors, I mean like, making the wall go down after grabbing a certain amount of Pick Up Objects.
If possible, I would like to see it in a script so I can copy and paste it easily.
Here's my PlayerController script as of now:
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class PlayerController : MonoBehaviour {
public float speed;
public Text countText;
public Text winText;
private Rigidbody rb;
private int count;
void Start()
{
rb = GetComponent<Rigidbody>();
count = 0;
SetCountText();
winText.text = "";
}
void FixedUpdate()
{
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
rb.AddForce(movement * speed);
}
void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("Pick Up Object"))
{
other.gameObject.SetActive(false);
count = count + 1;
SetCountText();
}
}
void SetCountText ()
{
countText.text = "Current Total: " + count.ToString();
if (count >= 21)
{
winText.text = "Level Complete, and that is all for now. Please go to the link in the Game Jolt description of this game, and then please exit out the game. Thank you for testing it! More builds soon! =D";
}
}
}
Your answer

Follow this Question
Related Questions
How to combine animation control with custom script based control for NPCs and player to use doors. 0 Answers
I need help with my audio slider 0 Answers
How to play an animation when a slider is at a certain value. 1 Answer
Weird UI slider behaviour 1 Answer
How to make script affect only one this game object 2 Answers