Hello! This is the first post on what I hope will be a regular blog! The aim to post updates on development of my games. At the moment am working on “Behind” a virtual reality game for the oculus rift. I will do a version for normal monitors too.
Okay, Today I worked on The “Bedroom Sequence” and The “Dining Room Sequence”
You can see the videos on my Youtube Channel and Below-
Note to learning Developers-
The way I did the locked doors in my games is the following-
I have two Prefabs, one door that Opens and one door that is locked both in the same place, only One Active. ( e.g if I wanted the door to be locked I would Keep the locked door active and the Unlocked door Un-active. (If any one wants a post about how to make a door Open I will reply to you when I have time) Here is the Code I Made-
Attach to your Key Object-
*Make Sure you have A Box collider attached to the key Object, and check the “Is Trigger” and Make it big enough for the range :D*
///////////////////////////////////////////////
var InRange : boolean; //Determines If your Character is near
var DoorUnlocked : GameObject; // assign the Unlocked Door
var DoorLocked : GameObject; // assign The Locked Door
var ForCorrutine = false; // random Shiz ( will explain if you ask :D)
function Start(){
DoorLocked.SetActive(true);
DoorUnlocked.SetActive(false);
ForCorrutine = false;
}
function Update (){
if ( Input.GetMouseButtonDown(0)&& InRange){
GetComponent.<MeshRenderer>().enabled = false;
DoorLocked.SetActive(false);
DoorUnlocked.SetActive(true);
GetComponent.<AudioSource>().Play();
ForCorrutine = true;
}
}
function OnTriggerEnter (other : Collider){
if (other.gameObject.tag == “Player”) {
InRange = true;
if(ForCorrutine == true){ yield WaitForSeconds(1);
Destroy(gameObject);
}
}
}
function OnTriggerExit (other : Collider){
if (other.gameObject.tag == “Player”) {
InRange = false;
}
}
Hoped this helped for any one that was struggling with Key Pick-up and unlock Door Code! 😀
Nice looking site CB! Good work feller!
Christian – staggering piece of work here! I’ll be trying out your Mac games first thing tomorrow!
Thanks! 😀